Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2022 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 <memory> |
| 18 | |
Arpit Singh | 3d84add | 2023-10-10 19:08:29 +0000 | [diff] [blame] | 19 | #include <com_android_input_flags.h> |
| 20 | #include <flag_macros.h> |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 21 | #include <gestures/GestureConverter.h> |
| 22 | #include <gtest/gtest.h> |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 23 | #include <gui/constants.h> |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 24 | |
| 25 | #include "FakeEventHub.h" |
| 26 | #include "FakeInputReaderPolicy.h" |
| 27 | #include "FakePointerController.h" |
| 28 | #include "InstrumentedInputReader.h" |
| 29 | #include "NotifyArgs.h" |
| 30 | #include "TestConstants.h" |
Prabir Pradhan | e3b28dd | 2023-10-06 04:19:29 +0000 | [diff] [blame] | 31 | #include "TestEventMatchers.h" |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 32 | #include "TestInputListener.h" |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 33 | #include "include/gestures.h" |
Harry Cutts | edf6ce7 | 2023-01-04 12:15:53 +0000 | [diff] [blame] | 34 | #include "ui/Rotation.h" |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 35 | |
| 36 | namespace android { |
| 37 | |
Byoungho Jung | ee6268f | 2023-10-30 17:27:26 +0900 | [diff] [blame] | 38 | namespace input_flags = com::android::input::flags; |
| 39 | |
Arpit Singh | 3d84add | 2023-10-10 19:08:29 +0000 | [diff] [blame] | 40 | namespace { |
| 41 | |
| 42 | const auto TOUCHPAD_PALM_REJECTION = |
Byoungho Jung | ee6268f | 2023-10-30 17:27:26 +0900 | [diff] [blame] | 43 | ACONFIG_FLAG(input_flags, enable_touchpad_typing_palm_rejection); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 44 | const auto TOUCHPAD_PALM_REJECTION_V2 = |
| 45 | ACONFIG_FLAG(input_flags, enable_v2_touchpad_typing_palm_rejection); |
Arpit Singh | 3d84add | 2023-10-10 19:08:29 +0000 | [diff] [blame] | 46 | |
| 47 | } // namespace |
| 48 | |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 49 | using testing::AllOf; |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 50 | using testing::Each; |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 51 | using testing::ElementsAre; |
| 52 | using testing::VariantWith; |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 53 | |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 54 | class GestureConverterTest : public testing::Test { |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 55 | protected: |
| 56 | static constexpr int32_t DEVICE_ID = END_RESERVED_ID + 1000; |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 57 | static constexpr int32_t EVENTHUB_ID = 1; |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 58 | static constexpr stime_t ARBITRARY_GESTURE_TIME = 1.2; |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 59 | |
| 60 | void SetUp() { |
| 61 | mFakeEventHub = std::make_unique<FakeEventHub>(); |
| 62 | mFakePolicy = sp<FakeInputReaderPolicy>::make(); |
| 63 | mFakeListener = std::make_unique<TestInputListener>(); |
| 64 | mReader = std::make_unique<InstrumentedInputReader>(mFakeEventHub, mFakePolicy, |
| 65 | *mFakeListener); |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 66 | mDevice = newDevice(); |
| 67 | mFakeEventHub->addAbsoluteAxis(EVENTHUB_ID, ABS_MT_POSITION_X, -500, 500, 0, 0, 20); |
| 68 | mFakeEventHub->addAbsoluteAxis(EVENTHUB_ID, ABS_MT_POSITION_Y, -500, 500, 0, 0, 20); |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 69 | } |
| 70 | |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 71 | std::shared_ptr<InputDevice> newDevice() { |
| 72 | InputDeviceIdentifier identifier; |
| 73 | identifier.name = "device"; |
| 74 | identifier.location = "USB1"; |
| 75 | identifier.bus = 0; |
| 76 | std::shared_ptr<InputDevice> device = |
| 77 | std::make_shared<InputDevice>(mReader->getContext(), DEVICE_ID, /* generation= */ 2, |
| 78 | identifier); |
| 79 | mReader->pushNextDevice(device); |
| 80 | mFakeEventHub->addDevice(EVENTHUB_ID, identifier.name, InputDeviceClass::TOUCHPAD, |
| 81 | identifier.bus); |
| 82 | mReader->loopOnce(); |
| 83 | return device; |
| 84 | } |
| 85 | |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 86 | std::shared_ptr<FakeEventHub> mFakeEventHub; |
| 87 | sp<FakeInputReaderPolicy> mFakePolicy; |
| 88 | std::unique_ptr<TestInputListener> mFakeListener; |
| 89 | std::unique_ptr<InstrumentedInputReader> mReader; |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 90 | std::shared_ptr<InputDevice> mDevice; |
Byoungho Jung | ee6268f | 2023-10-30 17:27:26 +0900 | [diff] [blame] | 91 | }; |
| 92 | |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 93 | TEST_F(GestureConverterTest, Move) { |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 94 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 95 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 96 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 97 | |
| 98 | Gesture moveGesture(kGestureMove, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, -5, 10); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 99 | std::list<NotifyArgs> args = |
| 100 | converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, moveGesture); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 101 | ASSERT_THAT(args, |
| 102 | ElementsAre(VariantWith<NotifyMotionArgs>( |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 103 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 104 | WithRelativeMotion(0, 0))), |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 105 | VariantWith<NotifyMotionArgs>( |
| 106 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 107 | WithRelativeMotion(-5, 10), WithButtonState(0), |
| 108 | WithPressure(0.0f))))); |
| 109 | ASSERT_THAT(args, |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 110 | Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0), |
| 111 | WithToolType(ToolType::FINGER), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 112 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 113 | |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 114 | // The same gesture again should only repeat the HOVER_MOVE, not the HOVER_ENTER. |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 115 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, moveGesture); |
| 116 | ASSERT_THAT(args, |
| 117 | ElementsAre(VariantWith<NotifyMotionArgs>( |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 118 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE), WithCoords(0, 0), |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 119 | WithRelativeMotion(-5, 10), WithToolType(ToolType::FINGER), |
| 120 | WithButtonState(0), WithPressure(0.0f), |
| 121 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 122 | } |
| 123 | |
Harry Cutts | edf6ce7 | 2023-01-04 12:15:53 +0000 | [diff] [blame] | 124 | TEST_F(GestureConverterTest, Move_Rotated) { |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 125 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 126 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
Harry Cutts | edf6ce7 | 2023-01-04 12:15:53 +0000 | [diff] [blame] | 127 | converter.setOrientation(ui::ROTATION_90); |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 128 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
Harry Cutts | edf6ce7 | 2023-01-04 12:15:53 +0000 | [diff] [blame] | 129 | |
| 130 | Gesture moveGesture(kGestureMove, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, -5, 10); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 131 | std::list<NotifyArgs> args = |
| 132 | converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, moveGesture); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 133 | ASSERT_THAT(args, |
| 134 | ElementsAre(VariantWith<NotifyMotionArgs>( |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 135 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 136 | WithRelativeMotion(0, 0))), |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 137 | VariantWith<NotifyMotionArgs>( |
| 138 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 139 | WithRelativeMotion(10, 5), WithButtonState(0), |
| 140 | WithPressure(0.0f))))); |
| 141 | ASSERT_THAT(args, |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 142 | Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0), |
| 143 | WithToolType(ToolType::FINGER), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 144 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Harry Cutts | edf6ce7 | 2023-01-04 12:15:53 +0000 | [diff] [blame] | 145 | } |
| 146 | |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 147 | TEST_F(GestureConverterTest, ButtonsChange) { |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 148 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 149 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 150 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 151 | |
| 152 | // Press left and right buttons at once |
| 153 | Gesture downGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, |
| 154 | /* down= */ GESTURES_BUTTON_LEFT | GESTURES_BUTTON_RIGHT, |
| 155 | /* up= */ GESTURES_BUTTON_NONE, /* is_tap= */ false); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 156 | std::list<NotifyArgs> args = |
| 157 | converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, downGesture); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 158 | ASSERT_THAT(args, |
| 159 | ElementsAre(VariantWith<NotifyMotionArgs>( |
| 160 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN), |
| 161 | WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY | |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 162 | AMOTION_EVENT_BUTTON_SECONDARY))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 163 | VariantWith<NotifyMotionArgs>( |
| 164 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS), |
| 165 | WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 166 | WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 167 | VariantWith<NotifyMotionArgs>( |
| 168 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS), |
| 169 | WithActionButton(AMOTION_EVENT_BUTTON_SECONDARY), |
| 170 | WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY | |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 171 | AMOTION_EVENT_BUTTON_SECONDARY))))); |
| 172 | ASSERT_THAT(args, |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 173 | Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 174 | WithToolType(ToolType::FINGER), |
| 175 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 176 | |
| 177 | // Then release the left button |
| 178 | Gesture leftUpGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, |
| 179 | /* down= */ GESTURES_BUTTON_NONE, /* up= */ GESTURES_BUTTON_LEFT, |
| 180 | /* is_tap= */ false); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 181 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, leftUpGesture); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 182 | ASSERT_THAT(args, |
| 183 | ElementsAre(VariantWith<NotifyMotionArgs>( |
| 184 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE), |
| 185 | WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY), |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 186 | WithButtonState(AMOTION_EVENT_BUTTON_SECONDARY), WithCoords(0, 0), |
| 187 | WithToolType(ToolType::FINGER), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 188 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 189 | |
| 190 | // Finally release the right button |
| 191 | Gesture rightUpGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, |
| 192 | /* down= */ GESTURES_BUTTON_NONE, /* up= */ GESTURES_BUTTON_RIGHT, |
| 193 | /* is_tap= */ false); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 194 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, rightUpGesture); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 195 | ASSERT_THAT(args, |
| 196 | ElementsAre(VariantWith<NotifyMotionArgs>( |
| 197 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 198 | WithActionButton(AMOTION_EVENT_BUTTON_SECONDARY))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 199 | VariantWith<NotifyMotionArgs>( |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 200 | WithMotionAction(AMOTION_EVENT_ACTION_UP)), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 201 | VariantWith<NotifyMotionArgs>( |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 202 | WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER)))); |
| 203 | ASSERT_THAT(args, |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 204 | Each(VariantWith<NotifyMotionArgs>(AllOf(WithButtonState(0), WithCoords(0, 0), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 205 | WithToolType(ToolType::FINGER), |
| 206 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 207 | } |
| 208 | |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 209 | TEST_F(GestureConverterTest, ButtonDownAfterMoveExitsHover) { |
| 210 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 211 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
| 212 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
| 213 | |
| 214 | Gesture moveGesture(kGestureMove, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, -5, 10); |
| 215 | std::list<NotifyArgs> args = |
| 216 | converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, moveGesture); |
| 217 | |
| 218 | Gesture downGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, |
| 219 | /*down=*/GESTURES_BUTTON_LEFT, /*up=*/GESTURES_BUTTON_NONE, |
| 220 | /*is_tap=*/false); |
| 221 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, downGesture); |
| 222 | ASSERT_THAT(args.front(), |
| 223 | VariantWith<NotifyMotionArgs>( |
| 224 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_EXIT), WithButtonState(0), |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 225 | WithCoords(0, 0), WithToolType(ToolType::FINGER), |
| 226 | WithDisplayId(ADISPLAY_ID_DEFAULT)))); |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 227 | } |
| 228 | |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 229 | TEST_F(GestureConverterTest, DragWithButton) { |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 230 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 231 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 232 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 233 | |
| 234 | // Press the button |
| 235 | Gesture downGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, |
| 236 | /* down= */ GESTURES_BUTTON_LEFT, /* up= */ GESTURES_BUTTON_NONE, |
| 237 | /* is_tap= */ false); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 238 | std::list<NotifyArgs> args = |
| 239 | converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, downGesture); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 240 | ASSERT_THAT(args, |
| 241 | ElementsAre(VariantWith<NotifyMotionArgs>( |
| 242 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 243 | WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 244 | VariantWith<NotifyMotionArgs>( |
| 245 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS), |
| 246 | WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 247 | WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY))))); |
| 248 | ASSERT_THAT(args, |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 249 | Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 250 | WithToolType(ToolType::FINGER), |
| 251 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 252 | |
| 253 | // Move |
| 254 | Gesture moveGesture(kGestureMove, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, -5, 10); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 255 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, moveGesture); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 256 | ASSERT_THAT(args, |
| 257 | ElementsAre(VariantWith<NotifyMotionArgs>( |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 258 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE), WithCoords(0, 0), |
| 259 | WithRelativeMotion(-5, 10), WithToolType(ToolType::FINGER), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 260 | WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY), WithPressure(1.0f), |
| 261 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 262 | |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 263 | // Release the button |
| 264 | Gesture upGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, |
| 265 | /* down= */ GESTURES_BUTTON_NONE, /* up= */ GESTURES_BUTTON_LEFT, |
| 266 | /* is_tap= */ false); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 267 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, upGesture); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 268 | ASSERT_THAT(args, |
| 269 | ElementsAre(VariantWith<NotifyMotionArgs>( |
| 270 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 271 | WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 272 | VariantWith<NotifyMotionArgs>( |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 273 | WithMotionAction(AMOTION_EVENT_ACTION_UP)), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 274 | VariantWith<NotifyMotionArgs>( |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 275 | WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER)))); |
| 276 | ASSERT_THAT(args, |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 277 | Each(VariantWith<NotifyMotionArgs>(AllOf(WithButtonState(0), WithCoords(0, 0), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 278 | WithToolType(ToolType::FINGER), |
| 279 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 280 | } |
| 281 | |
Harry Cutts | ef400b2 | 2022-12-16 21:26:24 +0000 | [diff] [blame] | 282 | TEST_F(GestureConverterTest, Scroll) { |
| 283 | const nsecs_t downTime = 12345; |
| 284 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 285 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 286 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
Harry Cutts | ef400b2 | 2022-12-16 21:26:24 +0000 | [diff] [blame] | 287 | |
Harry Cutts | a546ba8 | 2023-01-13 17:21:00 +0000 | [diff] [blame] | 288 | Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 289 | std::list<NotifyArgs> args = |
| 290 | converter.handleGesture(downTime, READ_TIME, ARBITRARY_TIME, startGesture); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 291 | ASSERT_THAT(args, |
| 292 | ElementsAre(VariantWith<NotifyMotionArgs>( |
| 293 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN), |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 294 | WithCoords(0, 0), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 295 | WithGestureScrollDistance(0, 0, EPSILON), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 296 | WithDownTime(downTime))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 297 | VariantWith<NotifyMotionArgs>( |
| 298 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE), |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 299 | WithCoords(0, -10), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 300 | WithGestureScrollDistance(0, 10, EPSILON))))); |
| 301 | ASSERT_THAT(args, |
| 302 | Each(VariantWith<NotifyMotionArgs>( |
| 303 | AllOf(WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE), |
| 304 | WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE), |
| 305 | WithToolType(ToolType::FINGER), |
| 306 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Harry Cutts | ef400b2 | 2022-12-16 21:26:24 +0000 | [diff] [blame] | 307 | |
Harry Cutts | a546ba8 | 2023-01-13 17:21:00 +0000 | [diff] [blame] | 308 | Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -5); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 309 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, continueGesture); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 310 | ASSERT_THAT(args, |
| 311 | ElementsAre(VariantWith<NotifyMotionArgs>( |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 312 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE), WithCoords(0, -15), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 313 | WithGestureScrollDistance(0, 5, EPSILON), |
| 314 | WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE), |
| 315 | WithToolType(ToolType::FINGER), |
| 316 | WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE), |
| 317 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Harry Cutts | ef400b2 | 2022-12-16 21:26:24 +0000 | [diff] [blame] | 318 | |
| 319 | Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 1, 1, |
| 320 | GESTURES_FLING_START); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 321 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, flingGesture); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 322 | ASSERT_THAT(args, |
| 323 | ElementsAre(VariantWith<NotifyMotionArgs>( |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 324 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP), |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 325 | WithCoords(0, -15), |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 326 | WithGestureScrollDistance(0, 0, EPSILON), |
| 327 | WithMotionClassification( |
| 328 | MotionClassification::TWO_FINGER_SWIPE), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 329 | WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE))), |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 330 | VariantWith<NotifyMotionArgs>( |
| 331 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER), |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 332 | WithCoords(0, 0), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 333 | WithMotionClassification(MotionClassification::NONE))))); |
| 334 | ASSERT_THAT(args, |
| 335 | Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER), |
| 336 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Harry Cutts | ef400b2 | 2022-12-16 21:26:24 +0000 | [diff] [blame] | 337 | } |
| 338 | |
| 339 | TEST_F(GestureConverterTest, Scroll_Rotated) { |
| 340 | const nsecs_t downTime = 12345; |
| 341 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 342 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
| 343 | converter.setOrientation(ui::ROTATION_90); |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 344 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
Harry Cutts | ef400b2 | 2022-12-16 21:26:24 +0000 | [diff] [blame] | 345 | |
Harry Cutts | a546ba8 | 2023-01-13 17:21:00 +0000 | [diff] [blame] | 346 | Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 347 | std::list<NotifyArgs> args = |
| 348 | converter.handleGesture(downTime, READ_TIME, ARBITRARY_TIME, startGesture); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 349 | ASSERT_THAT(args, |
| 350 | ElementsAre(VariantWith<NotifyMotionArgs>( |
| 351 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN), |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 352 | WithCoords(0, 0), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 353 | WithGestureScrollDistance(0, 0, EPSILON), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 354 | WithDownTime(downTime))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 355 | VariantWith<NotifyMotionArgs>( |
| 356 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE), |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 357 | WithCoords(-10, 0), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 358 | WithGestureScrollDistance(0, 10, EPSILON))))); |
| 359 | ASSERT_THAT(args, |
| 360 | Each(VariantWith<NotifyMotionArgs>( |
| 361 | AllOf(WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE), |
| 362 | WithToolType(ToolType::FINGER), |
| 363 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Harry Cutts | ef400b2 | 2022-12-16 21:26:24 +0000 | [diff] [blame] | 364 | |
Harry Cutts | a546ba8 | 2023-01-13 17:21:00 +0000 | [diff] [blame] | 365 | Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -5); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 366 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, continueGesture); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 367 | ASSERT_THAT(args, |
| 368 | ElementsAre(VariantWith<NotifyMotionArgs>( |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 369 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE), WithCoords(-15, 0), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 370 | WithGestureScrollDistance(0, 5, EPSILON), |
| 371 | WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE), |
| 372 | WithToolType(ToolType::FINGER), |
| 373 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 374 | |
Harry Cutts | ef400b2 | 2022-12-16 21:26:24 +0000 | [diff] [blame] | 375 | Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 1, 1, |
| 376 | GESTURES_FLING_START); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 377 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, flingGesture); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 378 | ASSERT_THAT(args, |
| 379 | ElementsAre(VariantWith<NotifyMotionArgs>( |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 380 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP), |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 381 | WithCoords(-15, 0), |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 382 | WithGestureScrollDistance(0, 0, EPSILON), |
| 383 | WithMotionClassification( |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 384 | MotionClassification::TWO_FINGER_SWIPE))), |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 385 | VariantWith<NotifyMotionArgs>( |
| 386 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER), |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 387 | WithCoords(0, 0), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 388 | WithMotionClassification(MotionClassification::NONE))))); |
| 389 | ASSERT_THAT(args, |
| 390 | Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER), |
| 391 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Harry Cutts | ef400b2 | 2022-12-16 21:26:24 +0000 | [diff] [blame] | 392 | } |
| 393 | |
Harry Cutts | a5f98c9 | 2023-05-17 15:05:44 +0000 | [diff] [blame] | 394 | TEST_F(GestureConverterTest, Scroll_ClearsClassificationAfterGesture) { |
Harry Cutts | ef400b2 | 2022-12-16 21:26:24 +0000 | [diff] [blame] | 395 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 396 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 397 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
Harry Cutts | ef400b2 | 2022-12-16 21:26:24 +0000 | [diff] [blame] | 398 | |
Harry Cutts | a546ba8 | 2023-01-13 17:21:00 +0000 | [diff] [blame] | 399 | Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 400 | std::list<NotifyArgs> args = |
| 401 | converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture); |
Harry Cutts | ef400b2 | 2022-12-16 21:26:24 +0000 | [diff] [blame] | 402 | |
Harry Cutts | a546ba8 | 2023-01-13 17:21:00 +0000 | [diff] [blame] | 403 | Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -5); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 404 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, continueGesture); |
Harry Cutts | ef400b2 | 2022-12-16 21:26:24 +0000 | [diff] [blame] | 405 | |
| 406 | Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 1, 1, |
| 407 | GESTURES_FLING_START); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 408 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, flingGesture); |
Harry Cutts | ef400b2 | 2022-12-16 21:26:24 +0000 | [diff] [blame] | 409 | |
| 410 | Gesture moveGesture(kGestureMove, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, -5, 10); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 411 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, moveGesture); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 412 | ASSERT_THAT(args, |
| 413 | ElementsAre(VariantWith<NotifyMotionArgs>( |
| 414 | AllOf(WithMotionClassification(MotionClassification::NONE), |
| 415 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Harry Cutts | ef400b2 | 2022-12-16 21:26:24 +0000 | [diff] [blame] | 416 | } |
| 417 | |
Harry Cutts | a5f98c9 | 2023-05-17 15:05:44 +0000 | [diff] [blame] | 418 | TEST_F(GestureConverterTest, Scroll_ClearsScrollDistanceAfterGesture) { |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 419 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 420 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 421 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 422 | |
Harry Cutts | a5f98c9 | 2023-05-17 15:05:44 +0000 | [diff] [blame] | 423 | Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 424 | std::list<NotifyArgs> args = |
| 425 | converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture); |
Harry Cutts | a5f98c9 | 2023-05-17 15:05:44 +0000 | [diff] [blame] | 426 | |
| 427 | Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -5); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 428 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, continueGesture); |
Harry Cutts | a5f98c9 | 2023-05-17 15:05:44 +0000 | [diff] [blame] | 429 | |
| 430 | Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 1, 1, |
| 431 | GESTURES_FLING_START); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 432 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, flingGesture); |
Harry Cutts | a5f98c9 | 2023-05-17 15:05:44 +0000 | [diff] [blame] | 433 | |
| 434 | // Move gestures don't use the fake finger array, so to test that gesture axes are cleared we |
| 435 | // need to use another gesture type, like pinch. |
| 436 | Gesture pinchGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dz=*/1, |
| 437 | GESTURES_ZOOM_START); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 438 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, pinchGesture); |
Harry Cutts | a5f98c9 | 2023-05-17 15:05:44 +0000 | [diff] [blame] | 439 | ASSERT_FALSE(args.empty()); |
| 440 | EXPECT_THAT(std::get<NotifyMotionArgs>(args.front()), WithGestureScrollDistance(0, 0, EPSILON)); |
| 441 | } |
| 442 | |
| 443 | TEST_F(GestureConverterTest, ThreeFingerSwipe_ClearsClassificationAfterGesture) { |
| 444 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 445 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 446 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
Harry Cutts | a5f98c9 | 2023-05-17 15:05:44 +0000 | [diff] [blame] | 447 | |
| 448 | Gesture startGesture(kGestureSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dx=*/0, |
| 449 | /*dy=*/0); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 450 | std::list<NotifyArgs> args = |
| 451 | converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture); |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 452 | |
| 453 | Gesture liftGesture(kGestureSwipeLift, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 454 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, liftGesture); |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 455 | |
Harry Cutts | a5f98c9 | 2023-05-17 15:05:44 +0000 | [diff] [blame] | 456 | Gesture moveGesture(kGestureMove, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dx=*/-5, |
| 457 | /*dy=*/10); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 458 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, moveGesture); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 459 | ASSERT_THAT(args, |
| 460 | ElementsAre(VariantWith<NotifyMotionArgs>( |
| 461 | WithMotionClassification(MotionClassification::NONE)))); |
Harry Cutts | a5f98c9 | 2023-05-17 15:05:44 +0000 | [diff] [blame] | 462 | } |
| 463 | |
Harry Cutts | 8743f18 | 2023-05-17 12:03:49 +0000 | [diff] [blame] | 464 | TEST_F(GestureConverterTest, ThreeFingerSwipe_ClearsGestureAxesAfterGesture) { |
Harry Cutts | a5f98c9 | 2023-05-17 15:05:44 +0000 | [diff] [blame] | 465 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 466 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 467 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
Harry Cutts | a5f98c9 | 2023-05-17 15:05:44 +0000 | [diff] [blame] | 468 | |
| 469 | Gesture startGesture(kGestureSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dx=*/5, |
| 470 | /*dy=*/5); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 471 | std::list<NotifyArgs> args = |
| 472 | converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture); |
Harry Cutts | a5f98c9 | 2023-05-17 15:05:44 +0000 | [diff] [blame] | 473 | |
| 474 | Gesture liftGesture(kGestureSwipeLift, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 475 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, liftGesture); |
Harry Cutts | a5f98c9 | 2023-05-17 15:05:44 +0000 | [diff] [blame] | 476 | |
| 477 | // Move gestures don't use the fake finger array, so to test that gesture axes are cleared we |
| 478 | // need to use another gesture type, like pinch. |
| 479 | Gesture pinchGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dz=*/1, |
| 480 | GESTURES_ZOOM_START); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 481 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, pinchGesture); |
Harry Cutts | a5f98c9 | 2023-05-17 15:05:44 +0000 | [diff] [blame] | 482 | ASSERT_FALSE(args.empty()); |
Harry Cutts | 8743f18 | 2023-05-17 12:03:49 +0000 | [diff] [blame] | 483 | EXPECT_THAT(std::get<NotifyMotionArgs>(args.front()), |
| 484 | AllOf(WithGestureOffset(0, 0, EPSILON), WithGestureSwipeFingerCount(0))); |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | TEST_F(GestureConverterTest, ThreeFingerSwipe_Vertical) { |
| 488 | // The gestures library will "lock" a swipe into the dimension it starts in. For example, if you |
| 489 | // start swiping up and then start moving left or right, it'll return gesture events with only Y |
| 490 | // deltas until you lift your fingers and start swiping again. That's why each of these tests |
| 491 | // only checks movement in one dimension. |
| 492 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 493 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 494 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 495 | |
| 496 | Gesture startGesture(kGestureSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dx= */ 0, |
| 497 | /* dy= */ 10); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 498 | std::list<NotifyArgs> args = |
| 499 | converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture); |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 500 | ASSERT_EQ(4u, args.size()); |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 501 | ASSERT_THAT(args, |
| 502 | Each(VariantWith<NotifyMotionArgs>( |
| 503 | AllOf(WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE), |
| 504 | WithGestureSwipeFingerCount(3), WithToolType(ToolType::FINGER), |
| 505 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 506 | |
| 507 | // Three fake fingers should be created. We don't actually care where they are, so long as they |
| 508 | // move appropriately. |
| 509 | NotifyMotionArgs arg = std::get<NotifyMotionArgs>(args.front()); |
| 510 | ASSERT_THAT(arg, |
| 511 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN), WithGestureOffset(0, 0, EPSILON), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 512 | WithPointerCount(1u))); |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 513 | PointerCoords finger0Start = arg.pointerCoords[0]; |
| 514 | args.pop_front(); |
| 515 | arg = std::get<NotifyMotionArgs>(args.front()); |
| 516 | ASSERT_THAT(arg, |
| 517 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_POINTER_DOWN | |
| 518 | 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 519 | WithGestureOffset(0, 0, EPSILON), WithPointerCount(2u))); |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 520 | PointerCoords finger1Start = arg.pointerCoords[1]; |
| 521 | args.pop_front(); |
| 522 | arg = std::get<NotifyMotionArgs>(args.front()); |
| 523 | ASSERT_THAT(arg, |
| 524 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_POINTER_DOWN | |
| 525 | 2 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 526 | WithGestureOffset(0, 0, EPSILON), WithPointerCount(3u))); |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 527 | PointerCoords finger2Start = arg.pointerCoords[2]; |
| 528 | args.pop_front(); |
| 529 | |
| 530 | arg = std::get<NotifyMotionArgs>(args.front()); |
| 531 | ASSERT_THAT(arg, |
| 532 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 533 | WithGestureOffset(0, -0.01, EPSILON), WithPointerCount(3u))); |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 534 | EXPECT_EQ(arg.pointerCoords[0].getX(), finger0Start.getX()); |
| 535 | EXPECT_EQ(arg.pointerCoords[1].getX(), finger1Start.getX()); |
| 536 | EXPECT_EQ(arg.pointerCoords[2].getX(), finger2Start.getX()); |
| 537 | EXPECT_EQ(arg.pointerCoords[0].getY(), finger0Start.getY() - 10); |
| 538 | EXPECT_EQ(arg.pointerCoords[1].getY(), finger1Start.getY() - 10); |
| 539 | EXPECT_EQ(arg.pointerCoords[2].getY(), finger2Start.getY() - 10); |
| 540 | |
| 541 | Gesture continueGesture(kGestureSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, |
| 542 | /* dx= */ 0, /* dy= */ 5); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 543 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, continueGesture); |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 544 | ASSERT_EQ(1u, args.size()); |
| 545 | arg = std::get<NotifyMotionArgs>(args.front()); |
| 546 | ASSERT_THAT(arg, |
| 547 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE), |
Harry Cutts | 8743f18 | 2023-05-17 12:03:49 +0000 | [diff] [blame] | 548 | WithGestureOffset(0, -0.005, EPSILON), WithGestureSwipeFingerCount(3), |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 549 | WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE), |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 550 | WithPointerCount(3u), WithToolType(ToolType::FINGER), |
| 551 | WithDisplayId(ADISPLAY_ID_DEFAULT))); |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 552 | EXPECT_EQ(arg.pointerCoords[0].getX(), finger0Start.getX()); |
| 553 | EXPECT_EQ(arg.pointerCoords[1].getX(), finger1Start.getX()); |
| 554 | EXPECT_EQ(arg.pointerCoords[2].getX(), finger2Start.getX()); |
| 555 | EXPECT_EQ(arg.pointerCoords[0].getY(), finger0Start.getY() - 15); |
| 556 | EXPECT_EQ(arg.pointerCoords[1].getY(), finger1Start.getY() - 15); |
| 557 | EXPECT_EQ(arg.pointerCoords[2].getY(), finger2Start.getY() - 15); |
| 558 | |
| 559 | Gesture liftGesture(kGestureSwipeLift, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 560 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, liftGesture); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 561 | ASSERT_THAT(args, |
| 562 | ElementsAre(VariantWith<NotifyMotionArgs>( |
| 563 | AllOf(WithMotionAction( |
| 564 | AMOTION_EVENT_ACTION_POINTER_UP | |
| 565 | 2 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT), |
| 566 | WithGestureOffset(0, 0, EPSILON), |
| 567 | WithGestureSwipeFingerCount(3), |
| 568 | WithMotionClassification( |
| 569 | MotionClassification::MULTI_FINGER_SWIPE), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 570 | WithPointerCount(3u))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 571 | VariantWith<NotifyMotionArgs>( |
| 572 | AllOf(WithMotionAction( |
| 573 | AMOTION_EVENT_ACTION_POINTER_UP | |
| 574 | 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT), |
| 575 | WithGestureOffset(0, 0, EPSILON), |
| 576 | WithGestureSwipeFingerCount(3), |
| 577 | WithMotionClassification( |
| 578 | MotionClassification::MULTI_FINGER_SWIPE), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 579 | WithPointerCount(2u))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 580 | VariantWith<NotifyMotionArgs>( |
| 581 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP), |
| 582 | WithGestureOffset(0, 0, EPSILON), |
| 583 | WithGestureSwipeFingerCount(3), |
| 584 | WithMotionClassification( |
| 585 | MotionClassification::MULTI_FINGER_SWIPE), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 586 | WithPointerCount(1u))), |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 587 | VariantWith<NotifyMotionArgs>( |
| 588 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER), |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 589 | WithCoords(0, 0), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 590 | WithMotionClassification(MotionClassification::NONE))))); |
| 591 | ASSERT_THAT(args, |
| 592 | Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER), |
| 593 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 594 | } |
| 595 | |
Harry Cutts | 94f5bd5 | 2023-01-06 18:02:18 +0000 | [diff] [blame] | 596 | TEST_F(GestureConverterTest, ThreeFingerSwipe_Rotated) { |
| 597 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 598 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
| 599 | converter.setOrientation(ui::ROTATION_90); |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 600 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
Harry Cutts | 94f5bd5 | 2023-01-06 18:02:18 +0000 | [diff] [blame] | 601 | |
| 602 | Gesture startGesture(kGestureSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dx= */ 0, |
| 603 | /* dy= */ 10); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 604 | std::list<NotifyArgs> args = |
| 605 | converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture); |
Harry Cutts | 94f5bd5 | 2023-01-06 18:02:18 +0000 | [diff] [blame] | 606 | ASSERT_EQ(4u, args.size()); |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 607 | ASSERT_THAT(args, Each(VariantWith<NotifyMotionArgs>(WithDisplayId(ADISPLAY_ID_DEFAULT)))); |
Harry Cutts | 94f5bd5 | 2023-01-06 18:02:18 +0000 | [diff] [blame] | 608 | |
| 609 | // Three fake fingers should be created. We don't actually care where they are, so long as they |
| 610 | // move appropriately. |
| 611 | NotifyMotionArgs arg = std::get<NotifyMotionArgs>(args.front()); |
| 612 | ASSERT_THAT(arg, |
| 613 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN), WithGestureOffset(0, 0, EPSILON), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 614 | WithPointerCount(1u))); |
Harry Cutts | 94f5bd5 | 2023-01-06 18:02:18 +0000 | [diff] [blame] | 615 | PointerCoords finger0Start = arg.pointerCoords[0]; |
| 616 | args.pop_front(); |
| 617 | arg = std::get<NotifyMotionArgs>(args.front()); |
| 618 | ASSERT_THAT(arg, |
| 619 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_POINTER_DOWN | |
| 620 | 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 621 | WithGestureOffset(0, 0, EPSILON), WithPointerCount(2u))); |
Harry Cutts | 94f5bd5 | 2023-01-06 18:02:18 +0000 | [diff] [blame] | 622 | PointerCoords finger1Start = arg.pointerCoords[1]; |
| 623 | args.pop_front(); |
| 624 | arg = std::get<NotifyMotionArgs>(args.front()); |
| 625 | ASSERT_THAT(arg, |
| 626 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_POINTER_DOWN | |
| 627 | 2 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 628 | WithGestureOffset(0, 0, EPSILON), WithPointerCount(3u))); |
Harry Cutts | 94f5bd5 | 2023-01-06 18:02:18 +0000 | [diff] [blame] | 629 | PointerCoords finger2Start = arg.pointerCoords[2]; |
| 630 | args.pop_front(); |
| 631 | |
| 632 | arg = std::get<NotifyMotionArgs>(args.front()); |
| 633 | ASSERT_THAT(arg, |
| 634 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 635 | WithGestureOffset(0, -0.01, EPSILON), WithPointerCount(3u))); |
Harry Cutts | 94f5bd5 | 2023-01-06 18:02:18 +0000 | [diff] [blame] | 636 | EXPECT_EQ(arg.pointerCoords[0].getX(), finger0Start.getX() - 10); |
| 637 | EXPECT_EQ(arg.pointerCoords[1].getX(), finger1Start.getX() - 10); |
| 638 | EXPECT_EQ(arg.pointerCoords[2].getX(), finger2Start.getX() - 10); |
| 639 | EXPECT_EQ(arg.pointerCoords[0].getY(), finger0Start.getY()); |
| 640 | EXPECT_EQ(arg.pointerCoords[1].getY(), finger1Start.getY()); |
| 641 | EXPECT_EQ(arg.pointerCoords[2].getY(), finger2Start.getY()); |
| 642 | |
| 643 | Gesture continueGesture(kGestureSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, |
| 644 | /* dx= */ 0, /* dy= */ 5); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 645 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, continueGesture); |
Harry Cutts | 94f5bd5 | 2023-01-06 18:02:18 +0000 | [diff] [blame] | 646 | ASSERT_EQ(1u, args.size()); |
| 647 | arg = std::get<NotifyMotionArgs>(args.front()); |
| 648 | ASSERT_THAT(arg, |
| 649 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE), |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 650 | WithGestureOffset(0, -0.005, EPSILON), WithPointerCount(3u), |
| 651 | WithDisplayId(ADISPLAY_ID_DEFAULT))); |
Harry Cutts | 94f5bd5 | 2023-01-06 18:02:18 +0000 | [diff] [blame] | 652 | EXPECT_EQ(arg.pointerCoords[0].getX(), finger0Start.getX() - 15); |
| 653 | EXPECT_EQ(arg.pointerCoords[1].getX(), finger1Start.getX() - 15); |
| 654 | EXPECT_EQ(arg.pointerCoords[2].getX(), finger2Start.getX() - 15); |
| 655 | EXPECT_EQ(arg.pointerCoords[0].getY(), finger0Start.getY()); |
| 656 | EXPECT_EQ(arg.pointerCoords[1].getY(), finger1Start.getY()); |
| 657 | EXPECT_EQ(arg.pointerCoords[2].getY(), finger2Start.getY()); |
| 658 | |
| 659 | Gesture liftGesture(kGestureSwipeLift, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 660 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, liftGesture); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 661 | ASSERT_THAT(args, |
| 662 | ElementsAre(VariantWith<NotifyMotionArgs>( |
| 663 | AllOf(WithMotionAction( |
| 664 | AMOTION_EVENT_ACTION_POINTER_UP | |
| 665 | 2 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 666 | WithGestureOffset(0, 0, EPSILON), WithPointerCount(3u))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 667 | VariantWith<NotifyMotionArgs>( |
| 668 | AllOf(WithMotionAction( |
| 669 | AMOTION_EVENT_ACTION_POINTER_UP | |
| 670 | 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 671 | WithGestureOffset(0, 0, EPSILON), WithPointerCount(2u))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 672 | VariantWith<NotifyMotionArgs>( |
| 673 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 674 | WithGestureOffset(0, 0, EPSILON), WithPointerCount(1u))), |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 675 | VariantWith<NotifyMotionArgs>( |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 676 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER))))); |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 677 | ASSERT_THAT(args, Each(VariantWith<NotifyMotionArgs>(WithDisplayId(ADISPLAY_ID_DEFAULT)))); |
Harry Cutts | 94f5bd5 | 2023-01-06 18:02:18 +0000 | [diff] [blame] | 678 | } |
| 679 | |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 680 | TEST_F(GestureConverterTest, FourFingerSwipe_Horizontal) { |
| 681 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 682 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 683 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 684 | |
| 685 | Gesture startGesture(kGestureFourFingerSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, |
| 686 | /* dx= */ 10, /* dy= */ 0); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 687 | std::list<NotifyArgs> args = |
| 688 | converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture); |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 689 | ASSERT_EQ(5u, args.size()); |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 690 | ASSERT_THAT(args, |
| 691 | Each(VariantWith<NotifyMotionArgs>( |
| 692 | AllOf(WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE), |
| 693 | WithGestureSwipeFingerCount(4), WithToolType(ToolType::FINGER), |
| 694 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 695 | |
| 696 | // Four fake fingers should be created. We don't actually care where they are, so long as they |
| 697 | // move appropriately. |
| 698 | NotifyMotionArgs arg = std::get<NotifyMotionArgs>(args.front()); |
| 699 | ASSERT_THAT(arg, |
| 700 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN), WithGestureOffset(0, 0, EPSILON), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 701 | WithPointerCount(1u))); |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 702 | PointerCoords finger0Start = arg.pointerCoords[0]; |
| 703 | args.pop_front(); |
| 704 | arg = std::get<NotifyMotionArgs>(args.front()); |
| 705 | ASSERT_THAT(arg, |
| 706 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_POINTER_DOWN | |
| 707 | 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 708 | WithGestureOffset(0, 0, EPSILON), WithPointerCount(2u))); |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 709 | PointerCoords finger1Start = arg.pointerCoords[1]; |
| 710 | args.pop_front(); |
| 711 | arg = std::get<NotifyMotionArgs>(args.front()); |
| 712 | ASSERT_THAT(arg, |
| 713 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_POINTER_DOWN | |
| 714 | 2 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 715 | WithGestureOffset(0, 0, EPSILON), WithPointerCount(3u))); |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 716 | PointerCoords finger2Start = arg.pointerCoords[2]; |
| 717 | args.pop_front(); |
| 718 | arg = std::get<NotifyMotionArgs>(args.front()); |
| 719 | ASSERT_THAT(arg, |
| 720 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_POINTER_DOWN | |
| 721 | 3 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 722 | WithGestureOffset(0, 0, EPSILON), WithPointerCount(4u))); |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 723 | PointerCoords finger3Start = arg.pointerCoords[3]; |
| 724 | args.pop_front(); |
| 725 | |
| 726 | arg = std::get<NotifyMotionArgs>(args.front()); |
| 727 | ASSERT_THAT(arg, |
| 728 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 729 | WithGestureOffset(0.01, 0, EPSILON), WithPointerCount(4u))); |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 730 | EXPECT_EQ(arg.pointerCoords[0].getX(), finger0Start.getX() + 10); |
| 731 | EXPECT_EQ(arg.pointerCoords[1].getX(), finger1Start.getX() + 10); |
| 732 | EXPECT_EQ(arg.pointerCoords[2].getX(), finger2Start.getX() + 10); |
| 733 | EXPECT_EQ(arg.pointerCoords[3].getX(), finger3Start.getX() + 10); |
| 734 | EXPECT_EQ(arg.pointerCoords[0].getY(), finger0Start.getY()); |
| 735 | EXPECT_EQ(arg.pointerCoords[1].getY(), finger1Start.getY()); |
| 736 | EXPECT_EQ(arg.pointerCoords[2].getY(), finger2Start.getY()); |
| 737 | EXPECT_EQ(arg.pointerCoords[3].getY(), finger3Start.getY()); |
| 738 | |
| 739 | Gesture continueGesture(kGestureFourFingerSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, |
| 740 | /* dx= */ 5, /* dy= */ 0); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 741 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, continueGesture); |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 742 | ASSERT_EQ(1u, args.size()); |
| 743 | arg = std::get<NotifyMotionArgs>(args.front()); |
| 744 | ASSERT_THAT(arg, |
| 745 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE), |
Harry Cutts | 8743f18 | 2023-05-17 12:03:49 +0000 | [diff] [blame] | 746 | WithGestureOffset(0.005, 0, EPSILON), WithGestureSwipeFingerCount(4), |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 747 | WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE), |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 748 | WithPointerCount(4u), WithToolType(ToolType::FINGER), |
| 749 | WithDisplayId(ADISPLAY_ID_DEFAULT))); |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 750 | EXPECT_EQ(arg.pointerCoords[0].getX(), finger0Start.getX() + 15); |
| 751 | EXPECT_EQ(arg.pointerCoords[1].getX(), finger1Start.getX() + 15); |
| 752 | EXPECT_EQ(arg.pointerCoords[2].getX(), finger2Start.getX() + 15); |
| 753 | EXPECT_EQ(arg.pointerCoords[3].getX(), finger3Start.getX() + 15); |
| 754 | EXPECT_EQ(arg.pointerCoords[0].getY(), finger0Start.getY()); |
| 755 | EXPECT_EQ(arg.pointerCoords[1].getY(), finger1Start.getY()); |
| 756 | EXPECT_EQ(arg.pointerCoords[2].getY(), finger2Start.getY()); |
| 757 | EXPECT_EQ(arg.pointerCoords[3].getY(), finger3Start.getY()); |
| 758 | |
| 759 | Gesture liftGesture(kGestureSwipeLift, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 760 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, liftGesture); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 761 | ASSERT_THAT(args, |
| 762 | ElementsAre(VariantWith<NotifyMotionArgs>( |
| 763 | AllOf(WithMotionAction( |
| 764 | AMOTION_EVENT_ACTION_POINTER_UP | |
| 765 | 3 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT), |
| 766 | WithGestureOffset(0, 0, EPSILON), |
| 767 | WithGestureSwipeFingerCount(4), |
| 768 | WithMotionClassification( |
| 769 | MotionClassification::MULTI_FINGER_SWIPE), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 770 | WithPointerCount(4u))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 771 | VariantWith<NotifyMotionArgs>( |
| 772 | AllOf(WithMotionAction( |
| 773 | AMOTION_EVENT_ACTION_POINTER_UP | |
| 774 | 2 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT), |
| 775 | WithGestureOffset(0, 0, EPSILON), |
| 776 | WithGestureSwipeFingerCount(4), |
| 777 | WithMotionClassification( |
| 778 | MotionClassification::MULTI_FINGER_SWIPE), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 779 | WithPointerCount(3u))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 780 | VariantWith<NotifyMotionArgs>( |
| 781 | AllOf(WithMotionAction( |
| 782 | AMOTION_EVENT_ACTION_POINTER_UP | |
| 783 | 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT), |
| 784 | WithGestureOffset(0, 0, EPSILON), |
| 785 | WithGestureSwipeFingerCount(4), |
| 786 | WithMotionClassification( |
| 787 | MotionClassification::MULTI_FINGER_SWIPE), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 788 | WithPointerCount(2u))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 789 | VariantWith<NotifyMotionArgs>( |
| 790 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP), |
| 791 | WithGestureOffset(0, 0, EPSILON), |
| 792 | WithGestureSwipeFingerCount(4), |
| 793 | WithMotionClassification( |
| 794 | MotionClassification::MULTI_FINGER_SWIPE), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 795 | WithPointerCount(1u))), |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 796 | VariantWith<NotifyMotionArgs>( |
| 797 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER), |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 798 | WithCoords(0, 0), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 799 | WithMotionClassification(MotionClassification::NONE))))); |
| 800 | ASSERT_THAT(args, |
| 801 | Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER), |
| 802 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Harry Cutts | c5748d1 | 2022-12-02 17:30:18 +0000 | [diff] [blame] | 803 | } |
| 804 | |
Harry Cutts | b1e8355 | 2022-12-20 11:02:26 +0000 | [diff] [blame] | 805 | TEST_F(GestureConverterTest, Pinch_Inwards) { |
| 806 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 807 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 808 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
Harry Cutts | b1e8355 | 2022-12-20 11:02:26 +0000 | [diff] [blame] | 809 | |
| 810 | Gesture startGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dz= */ 1, |
| 811 | GESTURES_ZOOM_START); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 812 | std::list<NotifyArgs> args = |
| 813 | converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 814 | ASSERT_THAT(args, |
| 815 | ElementsAre(VariantWith<NotifyMotionArgs>( |
| 816 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN), |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 817 | WithCoords(-100, 0), WithPointerCount(1u))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 818 | VariantWith<NotifyMotionArgs>( |
| 819 | AllOf(WithMotionAction( |
| 820 | AMOTION_EVENT_ACTION_POINTER_DOWN | |
| 821 | 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT), |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 822 | WithPointerCoords(1, 100, 0), WithPointerCount(2u))))); |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 823 | ASSERT_THAT(args, |
| 824 | Each(VariantWith<NotifyMotionArgs>( |
| 825 | AllOf(WithMotionClassification(MotionClassification::PINCH), |
| 826 | WithGesturePinchScaleFactor(1.0f, EPSILON), |
| 827 | WithToolType(ToolType::FINGER), |
| 828 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Harry Cutts | b1e8355 | 2022-12-20 11:02:26 +0000 | [diff] [blame] | 829 | |
| 830 | Gesture updateGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, |
| 831 | /* dz= */ 0.8, GESTURES_ZOOM_UPDATE); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 832 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, updateGesture); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 833 | ASSERT_THAT(args, |
| 834 | ElementsAre(VariantWith<NotifyMotionArgs>( |
| 835 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE), |
| 836 | WithMotionClassification(MotionClassification::PINCH), |
| 837 | WithGesturePinchScaleFactor(0.8f, EPSILON), |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 838 | WithPointerCoords(0, -80, 0), WithPointerCoords(1, 80, 0), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 839 | WithPointerCount(2u), WithToolType(ToolType::FINGER), |
| 840 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Harry Cutts | b1e8355 | 2022-12-20 11:02:26 +0000 | [diff] [blame] | 841 | |
| 842 | Gesture endGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dz= */ 1, |
| 843 | GESTURES_ZOOM_END); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 844 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, endGesture); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 845 | ASSERT_THAT(args, |
| 846 | ElementsAre(VariantWith<NotifyMotionArgs>( |
| 847 | AllOf(WithMotionAction( |
| 848 | AMOTION_EVENT_ACTION_POINTER_UP | |
| 849 | 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT), |
| 850 | WithMotionClassification(MotionClassification::PINCH), |
| 851 | WithGesturePinchScaleFactor(1.0f, EPSILON), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 852 | WithPointerCount(2u))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 853 | VariantWith<NotifyMotionArgs>( |
| 854 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP), |
| 855 | WithMotionClassification(MotionClassification::PINCH), |
| 856 | WithGesturePinchScaleFactor(1.0f, EPSILON), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 857 | WithPointerCount(1u))), |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 858 | VariantWith<NotifyMotionArgs>( |
| 859 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER), |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 860 | WithCoords(0, 0), |
| 861 | WithMotionClassification(MotionClassification::NONE))))); |
| 862 | ASSERT_THAT(args, |
| 863 | Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER), |
| 864 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
| 865 | } |
| 866 | |
| 867 | TEST_F(GestureConverterTest, Pinch_Outwards) { |
| 868 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 869 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
| 870 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
| 871 | |
| 872 | Gesture startGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dz= */ 1, |
| 873 | GESTURES_ZOOM_START); |
| 874 | std::list<NotifyArgs> args = |
| 875 | converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture); |
| 876 | ASSERT_THAT(args, |
| 877 | ElementsAre(VariantWith<NotifyMotionArgs>( |
| 878 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN), |
| 879 | WithCoords(-100, 0), WithPointerCount(1u))), |
| 880 | VariantWith<NotifyMotionArgs>( |
| 881 | AllOf(WithMotionAction( |
| 882 | AMOTION_EVENT_ACTION_POINTER_DOWN | |
| 883 | 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT), |
| 884 | WithPointerCoords(1, 100, 0), WithPointerCount(2u))))); |
| 885 | ASSERT_THAT(args, |
| 886 | Each(VariantWith<NotifyMotionArgs>( |
| 887 | AllOf(WithMotionClassification(MotionClassification::PINCH), |
| 888 | WithGesturePinchScaleFactor(1.0f, EPSILON), |
| 889 | WithToolType(ToolType::FINGER), |
| 890 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
| 891 | |
| 892 | Gesture updateGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, |
| 893 | /* dz= */ 1.1, GESTURES_ZOOM_UPDATE); |
| 894 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, updateGesture); |
| 895 | ASSERT_THAT(args, |
| 896 | ElementsAre(VariantWith<NotifyMotionArgs>( |
| 897 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE), |
| 898 | WithMotionClassification(MotionClassification::PINCH), |
| 899 | WithGesturePinchScaleFactor(1.1f, EPSILON), |
| 900 | WithPointerCoords(0, -110, 0), WithPointerCoords(1, 110, 0), |
| 901 | WithPointerCount(2u), WithToolType(ToolType::FINGER), |
| 902 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
| 903 | |
| 904 | Gesture endGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dz= */ 1, |
| 905 | GESTURES_ZOOM_END); |
| 906 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, endGesture); |
| 907 | ASSERT_THAT(args, |
| 908 | ElementsAre(VariantWith<NotifyMotionArgs>( |
| 909 | AllOf(WithMotionAction( |
| 910 | AMOTION_EVENT_ACTION_POINTER_UP | |
| 911 | 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT), |
| 912 | WithMotionClassification(MotionClassification::PINCH), |
| 913 | WithGesturePinchScaleFactor(1.0f, EPSILON), |
| 914 | WithPointerCount(2u))), |
| 915 | VariantWith<NotifyMotionArgs>( |
| 916 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP), |
| 917 | WithMotionClassification(MotionClassification::PINCH), |
| 918 | WithGesturePinchScaleFactor(1.0f, EPSILON), |
| 919 | WithPointerCount(1u))), |
| 920 | VariantWith<NotifyMotionArgs>( |
| 921 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER), |
| 922 | WithCoords(0, 0), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 923 | WithMotionClassification(MotionClassification::NONE))))); |
| 924 | ASSERT_THAT(args, |
| 925 | Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER), |
| 926 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Harry Cutts | b1e8355 | 2022-12-20 11:02:26 +0000 | [diff] [blame] | 927 | } |
| 928 | |
Harry Cutts | a5f98c9 | 2023-05-17 15:05:44 +0000 | [diff] [blame] | 929 | TEST_F(GestureConverterTest, Pinch_ClearsClassificationAfterGesture) { |
Harry Cutts | b1e8355 | 2022-12-20 11:02:26 +0000 | [diff] [blame] | 930 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 931 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 932 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
Harry Cutts | b1e8355 | 2022-12-20 11:02:26 +0000 | [diff] [blame] | 933 | |
Harry Cutts | a5f98c9 | 2023-05-17 15:05:44 +0000 | [diff] [blame] | 934 | Gesture startGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dz=*/1, |
Harry Cutts | b1e8355 | 2022-12-20 11:02:26 +0000 | [diff] [blame] | 935 | GESTURES_ZOOM_START); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 936 | std::list<NotifyArgs> args = |
| 937 | converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture); |
Harry Cutts | b1e8355 | 2022-12-20 11:02:26 +0000 | [diff] [blame] | 938 | |
| 939 | Gesture updateGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, |
Harry Cutts | a5f98c9 | 2023-05-17 15:05:44 +0000 | [diff] [blame] | 940 | /*dz=*/1.2, GESTURES_ZOOM_UPDATE); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 941 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, updateGesture); |
Harry Cutts | b1e8355 | 2022-12-20 11:02:26 +0000 | [diff] [blame] | 942 | |
Harry Cutts | a5f98c9 | 2023-05-17 15:05:44 +0000 | [diff] [blame] | 943 | Gesture endGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dz=*/1, |
Harry Cutts | b1e8355 | 2022-12-20 11:02:26 +0000 | [diff] [blame] | 944 | GESTURES_ZOOM_END); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 945 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, endGesture); |
Harry Cutts | b1e8355 | 2022-12-20 11:02:26 +0000 | [diff] [blame] | 946 | |
| 947 | Gesture moveGesture(kGestureMove, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, -5, 10); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 948 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, moveGesture); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 949 | ASSERT_THAT(args, |
| 950 | ElementsAre(VariantWith<NotifyMotionArgs>( |
| 951 | WithMotionClassification(MotionClassification::NONE)))); |
Harry Cutts | a5f98c9 | 2023-05-17 15:05:44 +0000 | [diff] [blame] | 952 | } |
| 953 | |
| 954 | TEST_F(GestureConverterTest, Pinch_ClearsScaleFactorAfterGesture) { |
| 955 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 956 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 957 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
Harry Cutts | a5f98c9 | 2023-05-17 15:05:44 +0000 | [diff] [blame] | 958 | |
| 959 | Gesture startGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dz=*/1, |
| 960 | GESTURES_ZOOM_START); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 961 | std::list<NotifyArgs> args = |
| 962 | converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture); |
Harry Cutts | a5f98c9 | 2023-05-17 15:05:44 +0000 | [diff] [blame] | 963 | |
| 964 | Gesture updateGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, |
| 965 | /*dz=*/1.2, GESTURES_ZOOM_UPDATE); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 966 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, updateGesture); |
Harry Cutts | a5f98c9 | 2023-05-17 15:05:44 +0000 | [diff] [blame] | 967 | |
| 968 | Gesture endGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dz=*/1, |
| 969 | GESTURES_ZOOM_END); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 970 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, endGesture); |
Harry Cutts | a5f98c9 | 2023-05-17 15:05:44 +0000 | [diff] [blame] | 971 | |
| 972 | // Move gestures don't use the fake finger array, so to test that gesture axes are cleared we |
| 973 | // need to use another gesture type, like scroll. |
| 974 | Gesture scrollGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dx=*/1, |
| 975 | /*dy=*/0); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 976 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, scrollGesture); |
Harry Cutts | a5f98c9 | 2023-05-17 15:05:44 +0000 | [diff] [blame] | 977 | ASSERT_FALSE(args.empty()); |
| 978 | EXPECT_THAT(std::get<NotifyMotionArgs>(args.front()), WithGesturePinchScaleFactor(0, EPSILON)); |
Harry Cutts | b1e8355 | 2022-12-20 11:02:26 +0000 | [diff] [blame] | 979 | } |
| 980 | |
Harry Cutts | e9b7142 | 2023-03-14 16:54:44 +0000 | [diff] [blame] | 981 | TEST_F(GestureConverterTest, ResetWithButtonPressed) { |
| 982 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 983 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 984 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
Harry Cutts | e9b7142 | 2023-03-14 16:54:44 +0000 | [diff] [blame] | 985 | |
| 986 | Gesture downGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, |
| 987 | /*down=*/GESTURES_BUTTON_LEFT | GESTURES_BUTTON_RIGHT, |
| 988 | /*up=*/GESTURES_BUTTON_NONE, /*is_tap=*/false); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 989 | (void)converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, downGesture); |
Harry Cutts | e9b7142 | 2023-03-14 16:54:44 +0000 | [diff] [blame] | 990 | |
| 991 | std::list<NotifyArgs> args = converter.reset(ARBITRARY_TIME); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 992 | ASSERT_THAT(args, |
| 993 | ElementsAre(VariantWith<NotifyMotionArgs>( |
| 994 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE), |
| 995 | WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 996 | WithButtonState(AMOTION_EVENT_BUTTON_SECONDARY))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 997 | VariantWith<NotifyMotionArgs>( |
| 998 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE), |
| 999 | WithActionButton(AMOTION_EVENT_BUTTON_SECONDARY), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1000 | WithButtonState(0))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1001 | VariantWith<NotifyMotionArgs>( |
| 1002 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1003 | WithButtonState(0))), |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 1004 | VariantWith<NotifyMotionArgs>( |
| 1005 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1006 | WithButtonState(0))))); |
| 1007 | ASSERT_THAT(args, |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 1008 | Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1009 | WithToolType(ToolType::FINGER), |
| 1010 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Harry Cutts | e9b7142 | 2023-03-14 16:54:44 +0000 | [diff] [blame] | 1011 | } |
| 1012 | |
| 1013 | TEST_F(GestureConverterTest, ResetDuringScroll) { |
| 1014 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 1015 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 1016 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
Harry Cutts | e9b7142 | 2023-03-14 16:54:44 +0000 | [diff] [blame] | 1017 | |
| 1018 | Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 1019 | (void)converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture); |
Harry Cutts | e9b7142 | 2023-03-14 16:54:44 +0000 | [diff] [blame] | 1020 | |
| 1021 | std::list<NotifyArgs> args = converter.reset(ARBITRARY_TIME); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1022 | ASSERT_THAT(args, |
| 1023 | ElementsAre(VariantWith<NotifyMotionArgs>( |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 1024 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP), |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 1025 | WithCoords(0, -10), |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 1026 | WithGestureScrollDistance(0, 0, EPSILON), |
| 1027 | WithMotionClassification( |
| 1028 | MotionClassification::TWO_FINGER_SWIPE), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1029 | WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE))), |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 1030 | VariantWith<NotifyMotionArgs>( |
| 1031 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER), |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 1032 | WithCoords(0, 0), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1033 | WithMotionClassification(MotionClassification::NONE))))); |
| 1034 | ASSERT_THAT(args, |
| 1035 | Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER), |
| 1036 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Harry Cutts | e9b7142 | 2023-03-14 16:54:44 +0000 | [diff] [blame] | 1037 | } |
| 1038 | |
| 1039 | TEST_F(GestureConverterTest, ResetDuringThreeFingerSwipe) { |
| 1040 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 1041 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 1042 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
Harry Cutts | e9b7142 | 2023-03-14 16:54:44 +0000 | [diff] [blame] | 1043 | |
| 1044 | Gesture startGesture(kGestureSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dx=*/0, |
| 1045 | /*dy=*/10); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 1046 | (void)converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture); |
Harry Cutts | e9b7142 | 2023-03-14 16:54:44 +0000 | [diff] [blame] | 1047 | |
| 1048 | std::list<NotifyArgs> args = converter.reset(ARBITRARY_TIME); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1049 | ASSERT_THAT(args, |
| 1050 | ElementsAre(VariantWith<NotifyMotionArgs>( |
| 1051 | AllOf(WithMotionAction( |
| 1052 | AMOTION_EVENT_ACTION_POINTER_UP | |
| 1053 | 2 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT), |
| 1054 | WithGestureOffset(0, 0, EPSILON), |
| 1055 | WithMotionClassification( |
| 1056 | MotionClassification::MULTI_FINGER_SWIPE), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1057 | WithPointerCount(3u))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1058 | VariantWith<NotifyMotionArgs>( |
| 1059 | AllOf(WithMotionAction( |
| 1060 | AMOTION_EVENT_ACTION_POINTER_UP | |
| 1061 | 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT), |
| 1062 | WithGestureOffset(0, 0, EPSILON), |
| 1063 | WithMotionClassification( |
| 1064 | MotionClassification::MULTI_FINGER_SWIPE), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1065 | WithPointerCount(2u))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1066 | VariantWith<NotifyMotionArgs>( |
| 1067 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP), |
| 1068 | WithGestureOffset(0, 0, EPSILON), |
| 1069 | WithMotionClassification( |
| 1070 | MotionClassification::MULTI_FINGER_SWIPE), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1071 | WithPointerCount(1u))), |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 1072 | VariantWith<NotifyMotionArgs>( |
| 1073 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1074 | WithMotionClassification(MotionClassification::NONE))))); |
| 1075 | ASSERT_THAT(args, |
| 1076 | Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER), |
| 1077 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Harry Cutts | e9b7142 | 2023-03-14 16:54:44 +0000 | [diff] [blame] | 1078 | } |
| 1079 | |
| 1080 | TEST_F(GestureConverterTest, ResetDuringPinch) { |
| 1081 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 1082 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 1083 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
Harry Cutts | e9b7142 | 2023-03-14 16:54:44 +0000 | [diff] [blame] | 1084 | |
| 1085 | Gesture startGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dz=*/1, |
| 1086 | GESTURES_ZOOM_START); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 1087 | (void)converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture); |
Harry Cutts | e9b7142 | 2023-03-14 16:54:44 +0000 | [diff] [blame] | 1088 | |
| 1089 | std::list<NotifyArgs> args = converter.reset(ARBITRARY_TIME); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1090 | ASSERT_THAT(args, |
| 1091 | ElementsAre(VariantWith<NotifyMotionArgs>( |
| 1092 | AllOf(WithMotionAction( |
| 1093 | AMOTION_EVENT_ACTION_POINTER_UP | |
| 1094 | 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT), |
| 1095 | WithMotionClassification(MotionClassification::PINCH), |
| 1096 | WithGesturePinchScaleFactor(1.0f, EPSILON), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1097 | WithPointerCount(2u))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1098 | VariantWith<NotifyMotionArgs>( |
| 1099 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP), |
| 1100 | WithMotionClassification(MotionClassification::PINCH), |
| 1101 | WithGesturePinchScaleFactor(1.0f, EPSILON), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1102 | WithPointerCount(1u))), |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 1103 | VariantWith<NotifyMotionArgs>( |
| 1104 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER), |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 1105 | WithCoords(0, 0), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1106 | WithMotionClassification(MotionClassification::NONE))))); |
| 1107 | ASSERT_THAT(args, |
| 1108 | Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER), |
| 1109 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Harry Cutts | e9b7142 | 2023-03-14 16:54:44 +0000 | [diff] [blame] | 1110 | } |
| 1111 | |
Prabir Pradhan | f7c4b0e | 2023-05-10 21:25:16 +0000 | [diff] [blame] | 1112 | TEST_F(GestureConverterTest, FlingTapDown) { |
| 1113 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 1114 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 1115 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
Prabir Pradhan | f7c4b0e | 2023-05-10 21:25:16 +0000 | [diff] [blame] | 1116 | |
| 1117 | Gesture tapDownGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, |
| 1118 | /*vx=*/0.f, /*vy=*/0.f, GESTURES_FLING_TAP_DOWN); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 1119 | std::list<NotifyArgs> args = |
| 1120 | converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, tapDownGesture); |
Prabir Pradhan | f7c4b0e | 2023-05-10 21:25:16 +0000 | [diff] [blame] | 1121 | |
| 1122 | ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()), |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 1123 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER), WithCoords(0, 0), |
| 1124 | WithRelativeMotion(0.f, 0.f), WithToolType(ToolType::FINGER), |
| 1125 | WithButtonState(0), WithPressure(0.0f), WithDisplayId(ADISPLAY_ID_DEFAULT))); |
Prabir Pradhan | f7c4b0e | 2023-05-10 21:25:16 +0000 | [diff] [blame] | 1126 | } |
| 1127 | |
Harry Cutts | 39648ab | 2024-02-15 14:23:50 +0000 | [diff] [blame] | 1128 | TEST_F(GestureConverterTest, FlingTapDownAfterScrollStopsFling) { |
| 1129 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 1130 | input_flags::enable_touchpad_fling_stop(true); |
| 1131 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
| 1132 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
| 1133 | |
| 1134 | Gesture scrollGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10); |
| 1135 | std::list<NotifyArgs> args = |
| 1136 | converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, scrollGesture); |
| 1137 | Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 1, 1, |
| 1138 | GESTURES_FLING_START); |
| 1139 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, flingGesture); |
| 1140 | |
| 1141 | Gesture tapDownGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, |
| 1142 | /*vx=*/0.f, /*vy=*/0.f, GESTURES_FLING_TAP_DOWN); |
| 1143 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, tapDownGesture); |
| 1144 | ASSERT_THAT(args, |
| 1145 | ElementsAre(VariantWith<NotifyMotionArgs>( |
| 1146 | WithMotionAction(AMOTION_EVENT_ACTION_HOVER_EXIT)), |
| 1147 | VariantWith<NotifyMotionArgs>( |
| 1148 | WithMotionAction(AMOTION_EVENT_ACTION_DOWN)), |
| 1149 | VariantWith<NotifyMotionArgs>( |
| 1150 | WithMotionAction(AMOTION_EVENT_ACTION_CANCEL)), |
| 1151 | VariantWith<NotifyMotionArgs>( |
Harry Cutts | 574781a | 2024-04-23 15:30:45 +0000 | [diff] [blame] | 1152 | WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER)))); |
Harry Cutts | 39648ab | 2024-02-15 14:23:50 +0000 | [diff] [blame] | 1153 | ASSERT_THAT(args, |
Harry Cutts | 574781a | 2024-04-23 15:30:45 +0000 | [diff] [blame] | 1154 | Each(VariantWith<NotifyMotionArgs>( |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 1155 | AllOf(WithCoords(0, 0), WithToolType(ToolType::FINGER), |
Harry Cutts | 574781a | 2024-04-23 15:30:45 +0000 | [diff] [blame] | 1156 | WithDisplayId(ADISPLAY_ID_DEFAULT), |
| 1157 | WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE))))); |
Harry Cutts | 39648ab | 2024-02-15 14:23:50 +0000 | [diff] [blame] | 1158 | } |
| 1159 | |
Arpit Singh | a5ea7c1 | 2023-07-05 15:39:25 +0000 | [diff] [blame] | 1160 | TEST_F(GestureConverterTest, Tap) { |
| 1161 | // Tap should produce button press/release events |
| 1162 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 1163 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 1164 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
Arpit Singh | a5ea7c1 | 2023-07-05 15:39:25 +0000 | [diff] [blame] | 1165 | |
| 1166 | Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* vx= */ 0, |
| 1167 | /* vy= */ 0, GESTURES_FLING_TAP_DOWN); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 1168 | std::list<NotifyArgs> args = |
| 1169 | converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, flingGesture); |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 1170 | // We don't need to check args here, since it's covered by the FlingTapDown test. |
Arpit Singh | a5ea7c1 | 2023-07-05 15:39:25 +0000 | [diff] [blame] | 1171 | |
| 1172 | Gesture tapGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, |
| 1173 | /* down= */ GESTURES_BUTTON_LEFT, |
| 1174 | /* up= */ GESTURES_BUTTON_LEFT, /* is_tap= */ true); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 1175 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, tapGesture); |
Arpit Singh | a5ea7c1 | 2023-07-05 15:39:25 +0000 | [diff] [blame] | 1176 | |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1177 | ASSERT_THAT(args, |
| 1178 | ElementsAre(VariantWith<NotifyMotionArgs>( |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 1179 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_EXIT), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1180 | WithButtonState(0), WithPressure(0.0f))), |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 1181 | VariantWith<NotifyMotionArgs>( |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1182 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1183 | WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1184 | WithPressure(1.0f))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1185 | VariantWith<NotifyMotionArgs>( |
| 1186 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS), |
| 1187 | WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY), |
| 1188 | WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1189 | WithPressure(1.0f))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1190 | VariantWith<NotifyMotionArgs>( |
| 1191 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE), |
| 1192 | WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1193 | WithButtonState(0), WithPressure(1.0f))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1194 | VariantWith<NotifyMotionArgs>( |
| 1195 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1196 | WithButtonState(0), WithPressure(0.0f))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1197 | VariantWith<NotifyMotionArgs>( |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 1198 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1199 | WithButtonState(0), WithPressure(0.0f))))); |
| 1200 | ASSERT_THAT(args, |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 1201 | Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1202 | WithRelativeMotion(0.f, 0.f), |
| 1203 | WithToolType(ToolType::FINGER), |
| 1204 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Arpit Singh | a5ea7c1 | 2023-07-05 15:39:25 +0000 | [diff] [blame] | 1205 | } |
| 1206 | |
| 1207 | TEST_F(GestureConverterTest, Click) { |
| 1208 | // Click should produce button press/release events |
| 1209 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 1210 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 1211 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
Arpit Singh | a5ea7c1 | 2023-07-05 15:39:25 +0000 | [diff] [blame] | 1212 | |
| 1213 | Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* vx= */ 0, |
| 1214 | /* vy= */ 0, GESTURES_FLING_TAP_DOWN); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 1215 | std::list<NotifyArgs> args = |
| 1216 | converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, flingGesture); |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 1217 | // We don't need to check args here, since it's covered by the FlingTapDown test. |
Arpit Singh | a5ea7c1 | 2023-07-05 15:39:25 +0000 | [diff] [blame] | 1218 | |
| 1219 | Gesture buttonDownGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, |
| 1220 | /* down= */ GESTURES_BUTTON_LEFT, |
| 1221 | /* up= */ GESTURES_BUTTON_NONE, /* is_tap= */ false); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 1222 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, buttonDownGesture); |
Arpit Singh | a5ea7c1 | 2023-07-05 15:39:25 +0000 | [diff] [blame] | 1223 | |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1224 | ASSERT_THAT(args, |
| 1225 | ElementsAre(VariantWith<NotifyMotionArgs>( |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 1226 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_EXIT), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1227 | WithButtonState(0), WithPressure(0.0f))), |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 1228 | VariantWith<NotifyMotionArgs>( |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1229 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1230 | WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1231 | WithPressure(1.0f))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1232 | VariantWith<NotifyMotionArgs>( |
| 1233 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS), |
| 1234 | WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY), |
| 1235 | WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1236 | WithPressure(1.0f))))); |
| 1237 | ASSERT_THAT(args, |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 1238 | Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1239 | WithRelativeMotion(0.f, 0.f), |
| 1240 | WithToolType(ToolType::FINGER), |
| 1241 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Arpit Singh | a5ea7c1 | 2023-07-05 15:39:25 +0000 | [diff] [blame] | 1242 | |
| 1243 | Gesture buttonUpGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, |
| 1244 | /* down= */ GESTURES_BUTTON_NONE, |
| 1245 | /* up= */ GESTURES_BUTTON_LEFT, /* is_tap= */ false); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 1246 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, buttonUpGesture); |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 1247 | |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1248 | ASSERT_THAT(args, |
| 1249 | ElementsAre(VariantWith<NotifyMotionArgs>( |
| 1250 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE), |
| 1251 | WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1252 | WithPressure(1.0f))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1253 | VariantWith<NotifyMotionArgs>( |
| 1254 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1255 | WithPressure(0.0f))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1256 | VariantWith<NotifyMotionArgs>( |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 1257 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1258 | WithPressure(0.0f))))); |
| 1259 | ASSERT_THAT(args, |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 1260 | Each(VariantWith<NotifyMotionArgs>(AllOf(WithButtonState(0), WithCoords(0, 0), |
| 1261 | WithRelativeMotion(0.f, 0.f), |
| 1262 | WithToolType(ToolType::FINGER), |
| 1263 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Arpit Singh | a5ea7c1 | 2023-07-05 15:39:25 +0000 | [diff] [blame] | 1264 | } |
| 1265 | |
Arpit Singh | 3d84add | 2023-10-10 19:08:29 +0000 | [diff] [blame] | 1266 | TEST_F_WITH_FLAGS(GestureConverterTest, TapWithTapToClickDisabled, |
Arpit Singh | 82b27a0 | 2023-10-16 11:02:19 +0000 | [diff] [blame] | 1267 | REQUIRES_FLAGS_ENABLED(TOUCHPAD_PALM_REJECTION), |
| 1268 | REQUIRES_FLAGS_DISABLED(TOUCHPAD_PALM_REJECTION_V2)) { |
| 1269 | nsecs_t currentTime = ARBITRARY_GESTURE_TIME; |
| 1270 | |
Arpit Singh | a5ea7c1 | 2023-07-05 15:39:25 +0000 | [diff] [blame] | 1271 | // Tap should be ignored when disabled |
| 1272 | mReader->getContext()->setPreventingTouchpadTaps(true); |
| 1273 | |
| 1274 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 1275 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 1276 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
Arpit Singh | a5ea7c1 | 2023-07-05 15:39:25 +0000 | [diff] [blame] | 1277 | |
Arpit Singh | 82b27a0 | 2023-10-16 11:02:19 +0000 | [diff] [blame] | 1278 | Gesture flingGesture(kGestureFling, currentTime, currentTime, /* vx= */ 0, |
Arpit Singh | a5ea7c1 | 2023-07-05 15:39:25 +0000 | [diff] [blame] | 1279 | /* vy= */ 0, GESTURES_FLING_TAP_DOWN); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 1280 | std::list<NotifyArgs> args = |
Arpit Singh | 82b27a0 | 2023-10-16 11:02:19 +0000 | [diff] [blame] | 1281 | converter.handleGesture(currentTime, currentTime, currentTime, flingGesture); |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 1282 | // We don't need to check args here, since it's covered by the FlingTapDown test. |
Arpit Singh | a5ea7c1 | 2023-07-05 15:39:25 +0000 | [diff] [blame] | 1283 | |
Arpit Singh | 82b27a0 | 2023-10-16 11:02:19 +0000 | [diff] [blame] | 1284 | Gesture tapGesture(kGestureButtonsChange, currentTime, currentTime, |
Arpit Singh | a5ea7c1 | 2023-07-05 15:39:25 +0000 | [diff] [blame] | 1285 | /* down= */ GESTURES_BUTTON_LEFT, |
| 1286 | /* up= */ GESTURES_BUTTON_LEFT, /* is_tap= */ true); |
Arpit Singh | 82b27a0 | 2023-10-16 11:02:19 +0000 | [diff] [blame] | 1287 | args = converter.handleGesture(currentTime, currentTime, currentTime, tapGesture); |
Arpit Singh | a5ea7c1 | 2023-07-05 15:39:25 +0000 | [diff] [blame] | 1288 | |
| 1289 | // no events should be generated |
| 1290 | ASSERT_EQ(0u, args.size()); |
| 1291 | |
| 1292 | // Future taps should be re-enabled |
| 1293 | ASSERT_FALSE(mReader->getContext()->isPreventingTouchpadTaps()); |
| 1294 | } |
| 1295 | |
Arpit Singh | 82b27a0 | 2023-10-16 11:02:19 +0000 | [diff] [blame] | 1296 | TEST_F_WITH_FLAGS(GestureConverterTest, TapWithTapToClickDisabledWithDelay, |
| 1297 | REQUIRES_FLAGS_ENABLED(TOUCHPAD_PALM_REJECTION_V2)) { |
| 1298 | nsecs_t currentTime = ARBITRARY_GESTURE_TIME; |
| 1299 | |
| 1300 | // Tap should be ignored when disabled |
| 1301 | mReader->getContext()->setPreventingTouchpadTaps(true); |
| 1302 | |
| 1303 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 1304 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
| 1305 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
| 1306 | |
| 1307 | Gesture flingGesture(kGestureFling, currentTime, currentTime, /* vx= */ 0, |
| 1308 | /* vy= */ 0, GESTURES_FLING_TAP_DOWN); |
| 1309 | std::list<NotifyArgs> args = |
| 1310 | converter.handleGesture(currentTime, currentTime, currentTime, flingGesture); |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 1311 | // We don't need to check args here, since it's covered by the FlingTapDown test. |
Arpit Singh | 82b27a0 | 2023-10-16 11:02:19 +0000 | [diff] [blame] | 1312 | |
| 1313 | Gesture tapGesture(kGestureButtonsChange, currentTime, currentTime, |
| 1314 | /* down= */ GESTURES_BUTTON_LEFT, |
| 1315 | /* up= */ GESTURES_BUTTON_LEFT, /* is_tap= */ true); |
| 1316 | args = converter.handleGesture(currentTime, currentTime, currentTime, tapGesture); |
| 1317 | |
| 1318 | // no events should be generated |
| 1319 | ASSERT_EQ(0u, args.size()); |
| 1320 | |
| 1321 | // Future taps should be re-enabled |
| 1322 | ASSERT_FALSE(mReader->getContext()->isPreventingTouchpadTaps()); |
| 1323 | |
| 1324 | // taps before the threshold should still be ignored |
| 1325 | currentTime += TAP_ENABLE_DELAY_NANOS.count(); |
| 1326 | flingGesture = Gesture(kGestureFling, currentTime, currentTime, /* vx= */ 0, |
| 1327 | /* vy= */ 0, GESTURES_FLING_TAP_DOWN); |
| 1328 | args = converter.handleGesture(currentTime, currentTime, currentTime, flingGesture); |
| 1329 | |
| 1330 | ASSERT_EQ(1u, args.size()); |
| 1331 | ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()), |
| 1332 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE), WithRelativeMotion(0, 0))); |
| 1333 | |
| 1334 | tapGesture = Gesture(kGestureButtonsChange, currentTime, currentTime, |
| 1335 | /* down= */ GESTURES_BUTTON_LEFT, |
| 1336 | /* up= */ GESTURES_BUTTON_LEFT, /* is_tap= */ true); |
| 1337 | args = converter.handleGesture(currentTime, currentTime, currentTime, tapGesture); |
| 1338 | |
| 1339 | // no events should be generated |
| 1340 | ASSERT_EQ(0u, args.size()); |
| 1341 | |
| 1342 | // taps after the threshold should be recognised |
| 1343 | currentTime += 1; |
| 1344 | flingGesture = Gesture(kGestureFling, currentTime, currentTime, /* vx= */ 0, |
| 1345 | /* vy= */ 0, GESTURES_FLING_TAP_DOWN); |
| 1346 | args = converter.handleGesture(currentTime, currentTime, currentTime, flingGesture); |
| 1347 | |
| 1348 | ASSERT_EQ(1u, args.size()); |
| 1349 | ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()), |
| 1350 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE), WithRelativeMotion(0, 0))); |
| 1351 | |
| 1352 | tapGesture = Gesture(kGestureButtonsChange, currentTime, currentTime, |
| 1353 | /* down= */ GESTURES_BUTTON_LEFT, |
| 1354 | /* up= */ GESTURES_BUTTON_LEFT, /* is_tap= */ true); |
| 1355 | args = converter.handleGesture(currentTime, currentTime, currentTime, tapGesture); |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1356 | ASSERT_THAT(args, |
| 1357 | ElementsAre(VariantWith<NotifyMotionArgs>( |
| 1358 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_EXIT), |
| 1359 | WithButtonState(0))), |
| 1360 | VariantWith<NotifyMotionArgs>( |
| 1361 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN), |
| 1362 | WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY))), |
| 1363 | VariantWith<NotifyMotionArgs>( |
| 1364 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS), |
| 1365 | WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY), |
| 1366 | WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY))), |
| 1367 | VariantWith<NotifyMotionArgs>( |
| 1368 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE), |
| 1369 | WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY), |
| 1370 | WithButtonState(0))), |
| 1371 | VariantWith<NotifyMotionArgs>( |
| 1372 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP), |
| 1373 | WithButtonState(0))), |
| 1374 | VariantWith<NotifyMotionArgs>( |
| 1375 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER), |
| 1376 | WithButtonState(0))))); |
| 1377 | ASSERT_THAT(args, Each(VariantWith<NotifyMotionArgs>(WithRelativeMotion(0.f, 0.f)))); |
Arpit Singh | 82b27a0 | 2023-10-16 11:02:19 +0000 | [diff] [blame] | 1378 | } |
| 1379 | |
Arpit Singh | 3d84add | 2023-10-10 19:08:29 +0000 | [diff] [blame] | 1380 | TEST_F_WITH_FLAGS(GestureConverterTest, ClickWithTapToClickDisabled, |
| 1381 | REQUIRES_FLAGS_ENABLED(TOUCHPAD_PALM_REJECTION)) { |
Arpit Singh | a5ea7c1 | 2023-07-05 15:39:25 +0000 | [diff] [blame] | 1382 | // Click should still produce button press/release events |
| 1383 | mReader->getContext()->setPreventingTouchpadTaps(true); |
| 1384 | |
| 1385 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 1386 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
Josep del Rio | d074638 | 2023-07-29 13:18:25 +0000 | [diff] [blame] | 1387 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
Arpit Singh | a5ea7c1 | 2023-07-05 15:39:25 +0000 | [diff] [blame] | 1388 | |
| 1389 | Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* vx= */ 0, |
| 1390 | /* vy= */ 0, GESTURES_FLING_TAP_DOWN); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 1391 | std::list<NotifyArgs> args = |
| 1392 | converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, flingGesture); |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 1393 | // We don't need to check args here, since it's covered by the FlingTapDown test. |
Arpit Singh | a5ea7c1 | 2023-07-05 15:39:25 +0000 | [diff] [blame] | 1394 | |
| 1395 | Gesture buttonDownGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, |
| 1396 | /* down= */ GESTURES_BUTTON_LEFT, |
| 1397 | /* up= */ GESTURES_BUTTON_NONE, /* is_tap= */ false); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 1398 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, buttonDownGesture); |
Byoungho Jung | ee6268f | 2023-10-30 17:27:26 +0900 | [diff] [blame] | 1399 | |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1400 | ASSERT_THAT(args, |
| 1401 | ElementsAre(VariantWith<NotifyMotionArgs>( |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 1402 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_EXIT), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1403 | WithButtonState(0), WithPressure(0.0f))), |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 1404 | VariantWith<NotifyMotionArgs>( |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1405 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1406 | WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1407 | WithPressure(1.0f))), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1408 | VariantWith<NotifyMotionArgs>( |
| 1409 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS), |
| 1410 | WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY), |
| 1411 | WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY), |
Harry Cutts | ef95e71 | 2024-02-16 18:56:39 +0000 | [diff] [blame] | 1412 | WithPressure(1.0f))))); |
| 1413 | ASSERT_THAT(args, |
| 1414 | Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0), |
| 1415 | WithRelativeMotion(0.f, 0.f), |
| 1416 | WithToolType(ToolType::FINGER), |
| 1417 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Byoungho Jung | ee6268f | 2023-10-30 17:27:26 +0900 | [diff] [blame] | 1418 | |
| 1419 | Gesture buttonUpGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, |
| 1420 | /* down= */ GESTURES_BUTTON_NONE, |
| 1421 | /* up= */ GESTURES_BUTTON_LEFT, /* is_tap= */ false); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 1422 | args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, buttonUpGesture); |
Byoungho Jung | ee6268f | 2023-10-30 17:27:26 +0900 | [diff] [blame] | 1423 | |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1424 | ASSERT_THAT(args, |
| 1425 | ElementsAre(VariantWith<NotifyMotionArgs>( |
| 1426 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE), |
| 1427 | WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY), |
| 1428 | WithButtonState(0), WithCoords(0, 0), |
| 1429 | WithRelativeMotion(0.f, 0.f), |
| 1430 | WithToolType(ToolType::FINGER), WithButtonState(0), |
| 1431 | WithPressure(1.0f), WithDisplayId(ADISPLAY_ID_DEFAULT))), |
| 1432 | VariantWith<NotifyMotionArgs>( |
| 1433 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP), |
| 1434 | WithCoords(0, 0), WithRelativeMotion(0.f, 0.f), |
| 1435 | WithToolType(ToolType::FINGER), WithButtonState(0), |
| 1436 | WithPressure(0.0f), WithDisplayId(ADISPLAY_ID_DEFAULT))), |
| 1437 | VariantWith<NotifyMotionArgs>( |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 1438 | AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER), |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1439 | WithCoords(0, 0), WithRelativeMotion(0, 0), |
| 1440 | WithToolType(ToolType::FINGER), WithButtonState(0), |
| 1441 | WithPressure(0.0f), |
| 1442 | WithDisplayId(ADISPLAY_ID_DEFAULT))))); |
Byoungho Jung | ee6268f | 2023-10-30 17:27:26 +0900 | [diff] [blame] | 1443 | |
| 1444 | // Future taps should be re-enabled |
| 1445 | ASSERT_FALSE(mReader->getContext()->isPreventingTouchpadTaps()); |
| 1446 | } |
| 1447 | |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 1448 | TEST_F_WITH_FLAGS(GestureConverterTest, MoveEnablesTapToClick, |
Byoungho Jung | ee6268f | 2023-10-30 17:27:26 +0900 | [diff] [blame] | 1449 | REQUIRES_FLAGS_ENABLED(TOUCHPAD_PALM_REJECTION)) { |
| 1450 | // initially disable tap-to-click |
| 1451 | mReader->getContext()->setPreventingTouchpadTaps(true); |
| 1452 | |
| 1453 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 1454 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
| 1455 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
| 1456 | |
| 1457 | Gesture moveGesture(kGestureMove, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, -5, 10); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 1458 | std::list<NotifyArgs> args = |
| 1459 | converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, moveGesture); |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 1460 | // We don't need to check args here, since it's covered by the Move test. |
Byoungho Jung | ee6268f | 2023-10-30 17:27:26 +0900 | [diff] [blame] | 1461 | |
| 1462 | // Future taps should be re-enabled |
| 1463 | ASSERT_FALSE(mReader->getContext()->isPreventingTouchpadTaps()); |
| 1464 | } |
| 1465 | |
Prabir Pradhan | 8b05351 | 2024-05-03 23:15:39 +0000 | [diff] [blame^] | 1466 | TEST_F_WITH_FLAGS(GestureConverterTest, KeypressCancelsHoverMove, |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 1467 | REQUIRES_FLAGS_ENABLED(TOUCHPAD_PALM_REJECTION_V2)) { |
| 1468 | const nsecs_t gestureStartTime = 1000; |
| 1469 | InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); |
| 1470 | GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); |
| 1471 | converter.setDisplayId(ADISPLAY_ID_DEFAULT); |
| 1472 | |
| 1473 | // Start a move gesture at gestureStartTime |
| 1474 | Gesture moveGesture(kGestureMove, gestureStartTime, gestureStartTime, -5, 10); |
| 1475 | std::list<NotifyArgs> args = |
| 1476 | converter.handleGesture(gestureStartTime, READ_TIME, gestureStartTime, moveGesture); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1477 | ASSERT_THAT(args, |
| 1478 | ElementsAre(VariantWith<NotifyMotionArgs>( |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 1479 | WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER)), |
| 1480 | VariantWith<NotifyMotionArgs>( |
| 1481 | WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE)))); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 1482 | |
| 1483 | // Key presses with IME connection should cancel ongoing move gesture |
| 1484 | nsecs_t currentTime = gestureStartTime + 100; |
| 1485 | mFakePolicy->setIsInputMethodConnectionActive(true); |
| 1486 | mReader->getContext()->setLastKeyDownTimestamp(currentTime); |
| 1487 | moveGesture = Gesture(kGestureMove, currentTime, currentTime, -5, 10); |
| 1488 | args = converter.handleGesture(currentTime, READ_TIME, gestureStartTime, moveGesture); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1489 | ASSERT_THAT(args, |
| 1490 | ElementsAre(VariantWith<NotifyMotionArgs>( |
| 1491 | WithMotionAction(AMOTION_EVENT_ACTION_HOVER_EXIT)))); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 1492 | |
| 1493 | // any updates in existing move gesture should be ignored |
| 1494 | moveGesture = Gesture(kGestureMove, currentTime, currentTime, -5, 10); |
| 1495 | args = converter.handleGesture(currentTime, READ_TIME, gestureStartTime, moveGesture); |
| 1496 | ASSERT_EQ(0u, args.size()); |
| 1497 | |
| 1498 | // New gesture should not be affected |
| 1499 | currentTime += 100; |
| 1500 | moveGesture = Gesture(kGestureMove, currentTime, currentTime, -5, 10); |
| 1501 | args = converter.handleGesture(currentTime, READ_TIME, currentTime, moveGesture); |
Harry Cutts | 5f26e95 | 2023-11-30 18:20:27 +0000 | [diff] [blame] | 1502 | ASSERT_THAT(args, |
| 1503 | ElementsAre(VariantWith<NotifyMotionArgs>( |
Harry Cutts | 379ea42 | 2023-12-21 15:31:47 +0000 | [diff] [blame] | 1504 | WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER)), |
| 1505 | VariantWith<NotifyMotionArgs>( |
| 1506 | WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE)))); |
Arpit Singh | 33a10a6 | 2023-10-12 13:06:54 +0000 | [diff] [blame] | 1507 | } |
| 1508 | |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 1509 | } // namespace android |