diff options
author | Scott Lobdell <slobdell@google.com> | 2020-11-16 12:06:47 -0800 |
---|---|---|
committer | Scott Lobdell <slobdell@google.com> | 2020-11-16 12:06:47 -0800 |
commit | a77d33f3caeab82ac727f807e2f727801533835c (patch) | |
tree | 2a7ded7cfffdf31877077e642b4f61bfb79fafe3 /libs/gui/tests/EndToEndNativeInputTest.cpp | |
parent | 193f16beba9e71942344ed83ad8bdddf486d41fc (diff) | |
parent | d411f7e05eb2390cdfee79fb9cefcc38ffd1b047 (diff) |
Merge SP1A.201116.001
Change-Id: I3edd90a225f8637ff14f147b8e7e4d24ca925444
Diffstat (limited to 'libs/gui/tests/EndToEndNativeInputTest.cpp')
-rw-r--r-- | libs/gui/tests/EndToEndNativeInputTest.cpp | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/libs/gui/tests/EndToEndNativeInputTest.cpp b/libs/gui/tests/EndToEndNativeInputTest.cpp index f5e196d652..b6b9dedb5e 100644 --- a/libs/gui/tests/EndToEndNativeInputTest.cpp +++ b/libs/gui/tests/EndToEndNativeInputTest.cpp @@ -157,6 +157,24 @@ public: EXPECT_EQ(0, mev->getFlags() & VERIFIED_MOTION_EVENT_FLAGS); } + void expectTapWithFlag(int x, int y, int32_t flags) { + InputEvent *ev = consumeEvent(); + ASSERT_NE(ev, nullptr); + ASSERT_EQ(AINPUT_EVENT_TYPE_MOTION, ev->getType()); + MotionEvent *mev = static_cast<MotionEvent *>(ev); + EXPECT_EQ(AMOTION_EVENT_ACTION_DOWN, mev->getAction()); + EXPECT_EQ(x, mev->getX(0)); + EXPECT_EQ(y, mev->getY(0)); + EXPECT_EQ(flags, mev->getFlags() & flags); + + ev = consumeEvent(); + ASSERT_NE(ev, nullptr); + ASSERT_EQ(AINPUT_EVENT_TYPE_MOTION, ev->getType()); + mev = static_cast<MotionEvent *>(ev); + EXPECT_EQ(AMOTION_EVENT_ACTION_UP, mev->getAction()); + EXPECT_EQ(flags, mev->getFlags() & flags); + } + ~InputSurface() { mInputFlinger->removeInputChannel(mClientChannel->getConnectionToken()); } void doTransaction(std::function<void(SurfaceComposerClient::Transaction&, @@ -606,4 +624,68 @@ TEST_F(InputSurfacesTest, rotate_surface_with_scale_and_insets) { surface->expectTap(5, 10); } +TEST_F(InputSurfacesTest, touch_flag_obscured) { + std::unique_ptr<InputSurface> surface = makeSurface(100, 100); + surface->showAt(100, 100); + + // Add non touchable window to fully cover touchable window. Window behind gets touch, but + // with flag AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED + std::unique_ptr<InputSurface> nonTouchableSurface = makeSurface(100, 100); + nonTouchableSurface->mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCHABLE; + nonTouchableSurface->mInputInfo.ownerUid = 22222; + nonTouchableSurface->showAt(100, 100); + + injectTap(190, 199); + surface->expectTapWithFlag(90, 99, AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED); +} + +TEST_F(InputSurfacesTest, touch_flag_partially_obscured_with_crop) { + std::unique_ptr<InputSurface> surface = makeSurface(100, 100); + surface->showAt(100, 100); + + // Add non touchable window to cover touchable window, but parent is cropped to not cover area + // that will be tapped. Window behind gets touch, but with flag + // AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED + std::unique_ptr<InputSurface> parentSurface = makeSurface(100, 100); + std::unique_ptr<InputSurface> nonTouchableSurface = makeSurface(100, 100); + nonTouchableSurface->mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCHABLE; + parentSurface->mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCHABLE; + nonTouchableSurface->mInputInfo.ownerUid = 22222; + parentSurface->mInputInfo.ownerUid = 22222; + nonTouchableSurface->showAt(0, 0); + parentSurface->showAt(100, 100); + + nonTouchableSurface->doTransaction([&](auto &t, auto &sc) { + t.setCrop_legacy(parentSurface->mSurfaceControl, Rect(0, 0, 50, 50)); + t.reparent(sc, parentSurface->mSurfaceControl); + }); + + injectTap(190, 199); + surface->expectTapWithFlag(90, 99, AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED); +} + +TEST_F(InputSurfacesTest, touch_not_obscured_with_crop) { + std::unique_ptr<InputSurface> surface = makeSurface(100, 100); + surface->showAt(100, 100); + + // Add non touchable window to cover touchable window, but parent is cropped to avoid covering + // the touchable window. Window behind gets touch with no obscured flags. + std::unique_ptr<InputSurface> parentSurface = makeSurface(100, 100); + std::unique_ptr<InputSurface> nonTouchableSurface = makeSurface(100, 100); + nonTouchableSurface->mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCHABLE; + parentSurface->mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCHABLE; + nonTouchableSurface->mInputInfo.ownerUid = 22222; + parentSurface->mInputInfo.ownerUid = 22222; + nonTouchableSurface->showAt(0, 0); + parentSurface->showAt(50, 50); + + nonTouchableSurface->doTransaction([&](auto &t, auto &sc) { + t.setCrop_legacy(parentSurface->mSurfaceControl, Rect(0, 0, 50, 50)); + t.reparent(sc, parentSurface->mSurfaceControl); + }); + + injectTap(101, 110); + surface->expectTap(1, 10); +} + } // namespace android::test |