Loading services/inputflinger/tests/InputReader_test.cpp +8 −23 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ #include <SingleTouchInputMapper.h> #include <SwitchInputMapper.h> #include <TestInputListener.h> #include <TestInputListenerMatchers.h> #include <TouchInputMapper.h> #include <UinputDevice.h> #include <VibratorInputMapper.h> Loading @@ -47,7 +48,7 @@ using android::hardware::input::InputDeviceCountryCode; namespace android { using namespace ftl::flag_operators; using testing::AllOf; using std::chrono_literals::operator""ms; // Timeout for waiting for an expected event Loading Loading @@ -96,24 +97,6 @@ static constexpr int32_t ACTION_POINTER_1_UP = // Error tolerance for floating point assertions. static const float EPSILON = 0.001f; using ::testing::AllOf; MATCHER_P(WithAction, action, "InputEvent with specified action") { return arg.action == action; } MATCHER_P(WithSource, source, "InputEvent with specified source") { return arg.source == source; } MATCHER_P(WithDisplayId, displayId, "InputEvent with specified displayId") { return arg.displayId == displayId; } MATCHER_P2(WithCoords, x, y, "MotionEvent with specified action") { return arg.pointerCoords[0].getX() == x && arg.pointerCoords[0].getY(); } template<typename T> static inline T min(T a, T b) { return a < b ? a : b; Loading Loading @@ -5133,8 +5116,9 @@ TEST_F(CursorInputMapperTest, ConfigureDisplayId_NoAssociatedViewport) { process(mapper, ARBITRARY_TIME, READ_TIME, EV_REL, REL_Y, 20); process(mapper, ARBITRARY_TIME, READ_TIME, EV_SYN, SYN_REPORT, 0); ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled( AllOf(WithAction(AMOTION_EVENT_ACTION_HOVER_MOVE), WithSource(AINPUT_SOURCE_MOUSE), WithDisplayId(SECONDARY_DISPLAY_ID), WithCoords(110.0f, 220.0f)))); AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE), WithSource(AINPUT_SOURCE_MOUSE), WithDisplayId(SECONDARY_DISPLAY_ID), WithCoords(110.0f, 220.0f)))); ASSERT_NO_FATAL_FAILURE(assertPosition(*mFakePointerController, 110.0f, 220.0f)); } Loading @@ -5159,8 +5143,9 @@ TEST_F(CursorInputMapperTest, ConfigureDisplayId_WithAssociatedViewport) { process(mapper, ARBITRARY_TIME, READ_TIME, EV_REL, REL_Y, 20); process(mapper, ARBITRARY_TIME, READ_TIME, EV_SYN, SYN_REPORT, 0); ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled( AllOf(WithAction(AMOTION_EVENT_ACTION_HOVER_MOVE), WithSource(AINPUT_SOURCE_MOUSE), WithDisplayId(SECONDARY_DISPLAY_ID), WithCoords(110.0f, 220.0f)))); AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE), WithSource(AINPUT_SOURCE_MOUSE), WithDisplayId(SECONDARY_DISPLAY_ID), WithCoords(110.0f, 220.0f)))); ASSERT_NO_FATAL_FAILURE(assertPosition(*mFakePointerController, 110.0f, 220.0f)); } Loading services/inputflinger/tests/TestInputListenerMatchers.h 0 → 100644 +60 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _UI_TEST_INPUT_LISTENER_MATCHERS_H #define _UI_TEST_INPUT_LISTENER_MATCHERS_H #include <android/input.h> #include <gmock/gmock.h> #include <gtest/gtest.h> namespace android { MATCHER_P(WithMotionAction, action, "InputEvent with specified action") { if (action == AMOTION_EVENT_ACTION_CANCEL) { *result_listener << "expected FLAG_CANCELED to be set with ACTION_CANCEL, but was not set"; return (arg.flags & AMOTION_EVENT_FLAG_CANCELED) != 0; } *result_listener << "expected action " << MotionEvent::actionToString(action) << ", but got " << MotionEvent::actionToString(arg.action); return action == arg.action; } MATCHER_P(WithSource, source, "InputEvent with specified source") { *result_listener << "expected source " << source << ", but got " << arg.source; return arg.source == source; } MATCHER_P(WithDisplayId, displayId, "InputEvent with specified displayId") { *result_listener << "expected displayId " << displayId << ", but got " << arg.displayId; return arg.displayId == displayId; } MATCHER_P2(WithCoords, x, y, "InputEvent with specified coords") { const auto argX = arg.pointerCoords[0].getX(); const auto argY = arg.pointerCoords[0].getY(); *result_listener << "expected coords (" << x << ", " << y << "), but got (" << argX << ", " << argY << ")"; return argX == x && argY == y; } MATCHER_P(WithFlags, flags, "InputEvent with specified flags") { *result_listener << "expected flags " << flags << ", but got " << arg.flags; return arg.flags == flags; } } // namespace android #endif services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp +13 −27 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include "ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter.h" #include "TestInputListener.h" #include "TestInputListenerMatchers.h" using ::testing::AllOf; Loading Loading @@ -55,21 +56,6 @@ constexpr int CANCEL = AMOTION_EVENT_ACTION_CANCEL; constexpr int32_t FLAG_CANCELED = AMOTION_EVENT_FLAG_CANCELED; MATCHER_P(WithAction, action, "MotionEvent with specified action") { bool result = true; if (action == CANCEL) { result &= (arg.flags & FLAG_CANCELED) != 0; } result &= arg.action == action; *result_listener << "expected to receive " << MotionEvent::actionToString(action) << " but received " << MotionEvent::actionToString(arg.action) << " instead."; return result; } MATCHER_P(WithFlags, flags, "MotionEvent with specified flags") { return arg.flags == flags; } static nsecs_t toNs(std::chrono::nanoseconds duration) { return duration.count(); } Loading Loading @@ -605,19 +591,19 @@ TEST_F(UnwantedInteractionBlockerTest, HeuristicFilterWorks) { // Small touch down NotifyMotionArgs args1 = generateMotionArgs(0 /*downTime*/, 0 /*eventTime*/, DOWN, {{1, 2, 3}}); mBlocker->notifyMotion(&args1); mTestListener.assertNotifyMotionWasCalled(WithAction(DOWN)); mTestListener.assertNotifyMotionWasCalled(WithMotionAction(DOWN)); // Large touch oval on the next move NotifyMotionArgs args2 = generateMotionArgs(0 /*downTime*/, RESAMPLE_PERIOD, MOVE, {{4, 5, 200}}); mBlocker->notifyMotion(&args2); mTestListener.assertNotifyMotionWasCalled(WithAction(MOVE)); mTestListener.assertNotifyMotionWasCalled(WithMotionAction(MOVE)); // Lift up the touch to force the model to decide on whether it's a palm NotifyMotionArgs args3 = generateMotionArgs(0 /*downTime*/, 2 * RESAMPLE_PERIOD, UP, {{4, 5, 200}}); mBlocker->notifyMotion(&args3); mTestListener.assertNotifyMotionWasCalled(WithAction(CANCEL)); mTestListener.assertNotifyMotionWasCalled(WithMotionAction(CANCEL)); } /** Loading @@ -633,14 +619,14 @@ TEST_F(UnwantedInteractionBlockerTest, StylusIsNotBlocked) { NotifyMotionArgs args1 = generateMotionArgs(0 /*downTime*/, 0 /*eventTime*/, DOWN, {{1, 2, 3}}); args1.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS; mBlocker->notifyMotion(&args1); mTestListener.assertNotifyMotionWasCalled(WithAction(DOWN)); mTestListener.assertNotifyMotionWasCalled(WithMotionAction(DOWN)); // Move the stylus, setting large TOUCH_MAJOR/TOUCH_MINOR dimensions NotifyMotionArgs args2 = generateMotionArgs(0 /*downTime*/, RESAMPLE_PERIOD, MOVE, {{4, 5, 200}}); args2.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS; mBlocker->notifyMotion(&args2); mTestListener.assertNotifyMotionWasCalled(WithAction(MOVE)); mTestListener.assertNotifyMotionWasCalled(WithMotionAction(MOVE)); // Lift up the stylus. If it were a touch event, this would force the model to decide on whether // it's a palm. Loading @@ -648,7 +634,7 @@ TEST_F(UnwantedInteractionBlockerTest, StylusIsNotBlocked) { generateMotionArgs(0 /*downTime*/, 2 * RESAMPLE_PERIOD, UP, {{4, 5, 200}}); args3.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS; mBlocker->notifyMotion(&args3); mTestListener.assertNotifyMotionWasCalled(WithAction(UP)); mTestListener.assertNotifyMotionWasCalled(WithMotionAction(UP)); } /** Loading @@ -664,21 +650,21 @@ TEST_F(UnwantedInteractionBlockerTest, TouchIsBlockedWhenMixedWithStylus) { // Touch down NotifyMotionArgs args1 = generateMotionArgs(0 /*downTime*/, 0 /*eventTime*/, DOWN, {{1, 2, 3}}); mBlocker->notifyMotion(&args1); mTestListener.assertNotifyMotionWasCalled(WithAction(DOWN)); mTestListener.assertNotifyMotionWasCalled(WithMotionAction(DOWN)); // Stylus pointer down NotifyMotionArgs args2 = generateMotionArgs(0 /*downTime*/, RESAMPLE_PERIOD, POINTER_1_DOWN, {{1, 2, 3}, {10, 20, 30}}); args2.pointerProperties[1].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS; mBlocker->notifyMotion(&args2); mTestListener.assertNotifyMotionWasCalled(WithAction(POINTER_1_DOWN)); mTestListener.assertNotifyMotionWasCalled(WithMotionAction(POINTER_1_DOWN)); // Large touch oval on the next finger move NotifyMotionArgs args3 = generateMotionArgs(0 /*downTime*/, 2 * RESAMPLE_PERIOD, MOVE, {{1, 2, 300}, {11, 21, 30}}); args3.pointerProperties[1].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS; mBlocker->notifyMotion(&args3); mTestListener.assertNotifyMotionWasCalled(WithAction(MOVE)); mTestListener.assertNotifyMotionWasCalled(WithMotionAction(MOVE)); // Lift up the finger pointer. It should be canceled due to the heuristic filter. NotifyMotionArgs args4 = generateMotionArgs(0 /*downTime*/, 3 * RESAMPLE_PERIOD, POINTER_0_UP, Loading @@ -686,14 +672,14 @@ TEST_F(UnwantedInteractionBlockerTest, TouchIsBlockedWhenMixedWithStylus) { args4.pointerProperties[1].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS; mBlocker->notifyMotion(&args4); mTestListener.assertNotifyMotionWasCalled( AllOf(WithAction(POINTER_0_UP), WithFlags(FLAG_CANCELED))); AllOf(WithMotionAction(POINTER_0_UP), WithFlags(FLAG_CANCELED))); NotifyMotionArgs args5 = generateMotionArgs(0 /*downTime*/, 4 * RESAMPLE_PERIOD, MOVE, {{12, 22, 30}}); args5.pointerProperties[0].id = args4.pointerProperties[1].id; args5.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS; mBlocker->notifyMotion(&args5); mTestListener.assertNotifyMotionWasCalled(WithAction(MOVE)); mTestListener.assertNotifyMotionWasCalled(WithMotionAction(MOVE)); // Lift up the stylus pointer NotifyMotionArgs args6 = Loading @@ -701,7 +687,7 @@ TEST_F(UnwantedInteractionBlockerTest, TouchIsBlockedWhenMixedWithStylus) { args6.pointerProperties[0].id = args4.pointerProperties[1].id; args6.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS; mBlocker->notifyMotion(&args6); mTestListener.assertNotifyMotionWasCalled(WithAction(UP)); mTestListener.assertNotifyMotionWasCalled(WithMotionAction(UP)); } using UnwantedInteractionBlockerTestDeathTest = UnwantedInteractionBlockerTest; Loading Loading
services/inputflinger/tests/InputReader_test.cpp +8 −23 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ #include <SingleTouchInputMapper.h> #include <SwitchInputMapper.h> #include <TestInputListener.h> #include <TestInputListenerMatchers.h> #include <TouchInputMapper.h> #include <UinputDevice.h> #include <VibratorInputMapper.h> Loading @@ -47,7 +48,7 @@ using android::hardware::input::InputDeviceCountryCode; namespace android { using namespace ftl::flag_operators; using testing::AllOf; using std::chrono_literals::operator""ms; // Timeout for waiting for an expected event Loading Loading @@ -96,24 +97,6 @@ static constexpr int32_t ACTION_POINTER_1_UP = // Error tolerance for floating point assertions. static const float EPSILON = 0.001f; using ::testing::AllOf; MATCHER_P(WithAction, action, "InputEvent with specified action") { return arg.action == action; } MATCHER_P(WithSource, source, "InputEvent with specified source") { return arg.source == source; } MATCHER_P(WithDisplayId, displayId, "InputEvent with specified displayId") { return arg.displayId == displayId; } MATCHER_P2(WithCoords, x, y, "MotionEvent with specified action") { return arg.pointerCoords[0].getX() == x && arg.pointerCoords[0].getY(); } template<typename T> static inline T min(T a, T b) { return a < b ? a : b; Loading Loading @@ -5133,8 +5116,9 @@ TEST_F(CursorInputMapperTest, ConfigureDisplayId_NoAssociatedViewport) { process(mapper, ARBITRARY_TIME, READ_TIME, EV_REL, REL_Y, 20); process(mapper, ARBITRARY_TIME, READ_TIME, EV_SYN, SYN_REPORT, 0); ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled( AllOf(WithAction(AMOTION_EVENT_ACTION_HOVER_MOVE), WithSource(AINPUT_SOURCE_MOUSE), WithDisplayId(SECONDARY_DISPLAY_ID), WithCoords(110.0f, 220.0f)))); AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE), WithSource(AINPUT_SOURCE_MOUSE), WithDisplayId(SECONDARY_DISPLAY_ID), WithCoords(110.0f, 220.0f)))); ASSERT_NO_FATAL_FAILURE(assertPosition(*mFakePointerController, 110.0f, 220.0f)); } Loading @@ -5159,8 +5143,9 @@ TEST_F(CursorInputMapperTest, ConfigureDisplayId_WithAssociatedViewport) { process(mapper, ARBITRARY_TIME, READ_TIME, EV_REL, REL_Y, 20); process(mapper, ARBITRARY_TIME, READ_TIME, EV_SYN, SYN_REPORT, 0); ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled( AllOf(WithAction(AMOTION_EVENT_ACTION_HOVER_MOVE), WithSource(AINPUT_SOURCE_MOUSE), WithDisplayId(SECONDARY_DISPLAY_ID), WithCoords(110.0f, 220.0f)))); AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE), WithSource(AINPUT_SOURCE_MOUSE), WithDisplayId(SECONDARY_DISPLAY_ID), WithCoords(110.0f, 220.0f)))); ASSERT_NO_FATAL_FAILURE(assertPosition(*mFakePointerController, 110.0f, 220.0f)); } Loading
services/inputflinger/tests/TestInputListenerMatchers.h 0 → 100644 +60 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _UI_TEST_INPUT_LISTENER_MATCHERS_H #define _UI_TEST_INPUT_LISTENER_MATCHERS_H #include <android/input.h> #include <gmock/gmock.h> #include <gtest/gtest.h> namespace android { MATCHER_P(WithMotionAction, action, "InputEvent with specified action") { if (action == AMOTION_EVENT_ACTION_CANCEL) { *result_listener << "expected FLAG_CANCELED to be set with ACTION_CANCEL, but was not set"; return (arg.flags & AMOTION_EVENT_FLAG_CANCELED) != 0; } *result_listener << "expected action " << MotionEvent::actionToString(action) << ", but got " << MotionEvent::actionToString(arg.action); return action == arg.action; } MATCHER_P(WithSource, source, "InputEvent with specified source") { *result_listener << "expected source " << source << ", but got " << arg.source; return arg.source == source; } MATCHER_P(WithDisplayId, displayId, "InputEvent with specified displayId") { *result_listener << "expected displayId " << displayId << ", but got " << arg.displayId; return arg.displayId == displayId; } MATCHER_P2(WithCoords, x, y, "InputEvent with specified coords") { const auto argX = arg.pointerCoords[0].getX(); const auto argY = arg.pointerCoords[0].getY(); *result_listener << "expected coords (" << x << ", " << y << "), but got (" << argX << ", " << argY << ")"; return argX == x && argY == y; } MATCHER_P(WithFlags, flags, "InputEvent with specified flags") { *result_listener << "expected flags " << flags << ", but got " << arg.flags; return arg.flags == flags; } } // namespace android #endif
services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp +13 −27 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include "ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter.h" #include "TestInputListener.h" #include "TestInputListenerMatchers.h" using ::testing::AllOf; Loading Loading @@ -55,21 +56,6 @@ constexpr int CANCEL = AMOTION_EVENT_ACTION_CANCEL; constexpr int32_t FLAG_CANCELED = AMOTION_EVENT_FLAG_CANCELED; MATCHER_P(WithAction, action, "MotionEvent with specified action") { bool result = true; if (action == CANCEL) { result &= (arg.flags & FLAG_CANCELED) != 0; } result &= arg.action == action; *result_listener << "expected to receive " << MotionEvent::actionToString(action) << " but received " << MotionEvent::actionToString(arg.action) << " instead."; return result; } MATCHER_P(WithFlags, flags, "MotionEvent with specified flags") { return arg.flags == flags; } static nsecs_t toNs(std::chrono::nanoseconds duration) { return duration.count(); } Loading Loading @@ -605,19 +591,19 @@ TEST_F(UnwantedInteractionBlockerTest, HeuristicFilterWorks) { // Small touch down NotifyMotionArgs args1 = generateMotionArgs(0 /*downTime*/, 0 /*eventTime*/, DOWN, {{1, 2, 3}}); mBlocker->notifyMotion(&args1); mTestListener.assertNotifyMotionWasCalled(WithAction(DOWN)); mTestListener.assertNotifyMotionWasCalled(WithMotionAction(DOWN)); // Large touch oval on the next move NotifyMotionArgs args2 = generateMotionArgs(0 /*downTime*/, RESAMPLE_PERIOD, MOVE, {{4, 5, 200}}); mBlocker->notifyMotion(&args2); mTestListener.assertNotifyMotionWasCalled(WithAction(MOVE)); mTestListener.assertNotifyMotionWasCalled(WithMotionAction(MOVE)); // Lift up the touch to force the model to decide on whether it's a palm NotifyMotionArgs args3 = generateMotionArgs(0 /*downTime*/, 2 * RESAMPLE_PERIOD, UP, {{4, 5, 200}}); mBlocker->notifyMotion(&args3); mTestListener.assertNotifyMotionWasCalled(WithAction(CANCEL)); mTestListener.assertNotifyMotionWasCalled(WithMotionAction(CANCEL)); } /** Loading @@ -633,14 +619,14 @@ TEST_F(UnwantedInteractionBlockerTest, StylusIsNotBlocked) { NotifyMotionArgs args1 = generateMotionArgs(0 /*downTime*/, 0 /*eventTime*/, DOWN, {{1, 2, 3}}); args1.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS; mBlocker->notifyMotion(&args1); mTestListener.assertNotifyMotionWasCalled(WithAction(DOWN)); mTestListener.assertNotifyMotionWasCalled(WithMotionAction(DOWN)); // Move the stylus, setting large TOUCH_MAJOR/TOUCH_MINOR dimensions NotifyMotionArgs args2 = generateMotionArgs(0 /*downTime*/, RESAMPLE_PERIOD, MOVE, {{4, 5, 200}}); args2.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS; mBlocker->notifyMotion(&args2); mTestListener.assertNotifyMotionWasCalled(WithAction(MOVE)); mTestListener.assertNotifyMotionWasCalled(WithMotionAction(MOVE)); // Lift up the stylus. If it were a touch event, this would force the model to decide on whether // it's a palm. Loading @@ -648,7 +634,7 @@ TEST_F(UnwantedInteractionBlockerTest, StylusIsNotBlocked) { generateMotionArgs(0 /*downTime*/, 2 * RESAMPLE_PERIOD, UP, {{4, 5, 200}}); args3.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS; mBlocker->notifyMotion(&args3); mTestListener.assertNotifyMotionWasCalled(WithAction(UP)); mTestListener.assertNotifyMotionWasCalled(WithMotionAction(UP)); } /** Loading @@ -664,21 +650,21 @@ TEST_F(UnwantedInteractionBlockerTest, TouchIsBlockedWhenMixedWithStylus) { // Touch down NotifyMotionArgs args1 = generateMotionArgs(0 /*downTime*/, 0 /*eventTime*/, DOWN, {{1, 2, 3}}); mBlocker->notifyMotion(&args1); mTestListener.assertNotifyMotionWasCalled(WithAction(DOWN)); mTestListener.assertNotifyMotionWasCalled(WithMotionAction(DOWN)); // Stylus pointer down NotifyMotionArgs args2 = generateMotionArgs(0 /*downTime*/, RESAMPLE_PERIOD, POINTER_1_DOWN, {{1, 2, 3}, {10, 20, 30}}); args2.pointerProperties[1].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS; mBlocker->notifyMotion(&args2); mTestListener.assertNotifyMotionWasCalled(WithAction(POINTER_1_DOWN)); mTestListener.assertNotifyMotionWasCalled(WithMotionAction(POINTER_1_DOWN)); // Large touch oval on the next finger move NotifyMotionArgs args3 = generateMotionArgs(0 /*downTime*/, 2 * RESAMPLE_PERIOD, MOVE, {{1, 2, 300}, {11, 21, 30}}); args3.pointerProperties[1].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS; mBlocker->notifyMotion(&args3); mTestListener.assertNotifyMotionWasCalled(WithAction(MOVE)); mTestListener.assertNotifyMotionWasCalled(WithMotionAction(MOVE)); // Lift up the finger pointer. It should be canceled due to the heuristic filter. NotifyMotionArgs args4 = generateMotionArgs(0 /*downTime*/, 3 * RESAMPLE_PERIOD, POINTER_0_UP, Loading @@ -686,14 +672,14 @@ TEST_F(UnwantedInteractionBlockerTest, TouchIsBlockedWhenMixedWithStylus) { args4.pointerProperties[1].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS; mBlocker->notifyMotion(&args4); mTestListener.assertNotifyMotionWasCalled( AllOf(WithAction(POINTER_0_UP), WithFlags(FLAG_CANCELED))); AllOf(WithMotionAction(POINTER_0_UP), WithFlags(FLAG_CANCELED))); NotifyMotionArgs args5 = generateMotionArgs(0 /*downTime*/, 4 * RESAMPLE_PERIOD, MOVE, {{12, 22, 30}}); args5.pointerProperties[0].id = args4.pointerProperties[1].id; args5.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS; mBlocker->notifyMotion(&args5); mTestListener.assertNotifyMotionWasCalled(WithAction(MOVE)); mTestListener.assertNotifyMotionWasCalled(WithMotionAction(MOVE)); // Lift up the stylus pointer NotifyMotionArgs args6 = Loading @@ -701,7 +687,7 @@ TEST_F(UnwantedInteractionBlockerTest, TouchIsBlockedWhenMixedWithStylus) { args6.pointerProperties[0].id = args4.pointerProperties[1].id; args6.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS; mBlocker->notifyMotion(&args6); mTestListener.assertNotifyMotionWasCalled(WithAction(UP)); mTestListener.assertNotifyMotionWasCalled(WithMotionAction(UP)); } using UnwantedInteractionBlockerTestDeathTest = UnwantedInteractionBlockerTest; Loading