summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2021-02-19 19:08:55 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2021-02-19 19:08:55 +0000
commit40dccb88879be9e7cd2c7ad1b569f3a28270e908 (patch)
tree9b1fbbec30ba74ef97e1449339cf5a6c11c89c53
parentf04cfdcbcb6b7311a8c19be30011c832d7fd0d59 (diff)
parentccd3dd65026cfb28285fb6119ae632384754e749 (diff)
Merge "Add InputDispatcher unit tests for untrusted touches [4/n]" into sc-dev
-rw-r--r--services/inputflinger/tests/InputDispatcher_test.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp
index dd044ca7a4..209639c880 100644
--- a/services/inputflinger/tests/InputDispatcher_test.cpp
+++ b/services/inputflinger/tests/InputDispatcher_test.cpp
@@ -4486,4 +4486,39 @@ TEST_F(InputDispatcherUntrustedTouchesTest, SelfWindowWithBlockUntrustedMode_All
mTouchWindow->consumeAnyMotionDown();
}
+TEST_F(InputDispatcherUntrustedTouchesTest,
+ OpacityThresholdIs0AndWindowAboveThreshold_BlocksTouch) {
+ mDispatcher->setMaximumObscuringOpacityForTouch(0.0f);
+ const sp<FakeWindowHandle>& w =
+ getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, 0.1f);
+ mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {w, mTouchWindow}}});
+
+ touch();
+
+ mTouchWindow->assertNoEvents();
+}
+
+TEST_F(InputDispatcherUntrustedTouchesTest, OpacityThresholdIs0AndWindowAtThreshold_AllowsTouch) {
+ mDispatcher->setMaximumObscuringOpacityForTouch(0.0f);
+ const sp<FakeWindowHandle>& w =
+ getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, 0.0f);
+ mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {w, mTouchWindow}}});
+
+ touch();
+
+ mTouchWindow->consumeAnyMotionDown();
+}
+
+TEST_F(InputDispatcherUntrustedTouchesTest,
+ OpacityThresholdIs1AndWindowBelowThreshold_AllowsTouch) {
+ mDispatcher->setMaximumObscuringOpacityForTouch(1.0f);
+ const sp<FakeWindowHandle>& w =
+ getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::USE_OPACITY, 0.9f);
+ mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {w, mTouchWindow}}});
+
+ touch();
+
+ mTouchWindow->consumeAnyMotionDown();
+}
+
} // namespace android::inputdispatcher