blob: e2eb08096b3755ff3d351f04142fd6ba6b5ae1e2 [file] [log] [blame]
Prabir Pradhan3117a442023-08-11 17:48:43 +00001/*
2 * Copyright 2023 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <gtest/gtest.h>
18#include <input/InputVerifier.h>
19#include <string>
20
21namespace android {
22
Siarhei Vishniakou88daa902023-10-03 14:04:18 -070023using android::base::Result;
24
Prabir Pradhan3117a442023-08-11 17:48:43 +000025TEST(InputVerifierTest, CreationWithInvalidUtfStringDoesNotCrash) {
26 constexpr char bytes[] = {static_cast<char>(0xC0), static_cast<char>(0x80)};
27 const std::string name(bytes, sizeof(bytes));
28 InputVerifier verifier(name);
29}
30
Siarhei Vishniakou88daa902023-10-03 14:04:18 -070031TEST(InputVerifierTest, ProcessSourceClassPointer) {
32 InputVerifier verifier("Verify testOnTouchEventScroll");
33
34 std::vector<PointerProperties> properties;
35 properties.push_back({});
36 properties.back().clear();
37 properties.back().id = 0;
38 properties.back().toolType = ToolType::UNKNOWN;
39
40 std::vector<PointerCoords> coords;
41 coords.push_back({});
42 coords.back().clear();
43 coords.back().setAxisValue(AMOTION_EVENT_AXIS_X, 75);
44 coords.back().setAxisValue(AMOTION_EVENT_AXIS_Y, 300);
45
46 const Result<void> result =
47 verifier.processMovement(/*deviceId=*/0, AINPUT_SOURCE_CLASS_POINTER,
48 AMOTION_EVENT_ACTION_DOWN,
49 /*pointerCount=*/properties.size(), properties.data(),
50 coords.data(), /*flags=*/0);
51 ASSERT_TRUE(result.ok());
52}
53
Prabir Pradhan3117a442023-08-11 17:48:43 +000054} // namespace android