SF: Enforce that layers with invalid input bounds are not focusable
Bug: 162194035
Test: atest libgui_test
Change-Id: Ic561e8b3e52faae28888ef3d323583e09aa278c0
diff --git a/libs/gui/tests/EndToEndNativeInputTest.cpp b/libs/gui/tests/EndToEndNativeInputTest.cpp
index 83e9858..76844d2 100644
--- a/libs/gui/tests/EndToEndNativeInputTest.cpp
+++ b/libs/gui/tests/EndToEndNativeInputTest.cpp
@@ -987,6 +987,31 @@
EXPECT_EQ(surface->consumeEvent(100), nullptr);
}
+TEST_F(InputSurfacesTest, layer_with_empty_crop_cannot_be_focused) {
+ std::unique_ptr<InputSurface> bufferSurface =
+ InputSurface::makeBufferInputSurface(mComposerClient, 100, 100);
+
+ bufferSurface->showAt(50, 50, Rect::EMPTY_RECT);
+
+ bufferSurface->requestFocus();
+ EXPECT_EQ(bufferSurface->consumeEvent(100), nullptr);
+
+ bufferSurface->showAt(50, 50, Rect::INVALID_RECT);
+
+ bufferSurface->requestFocus();
+ EXPECT_EQ(bufferSurface->consumeEvent(100), nullptr);
+}
+
+TEST_F(InputSurfacesTest, layer_with_valid_crop_can_be_focused) {
+ std::unique_ptr<InputSurface> bufferSurface =
+ InputSurface::makeBufferInputSurface(mComposerClient, 100, 100);
+
+ bufferSurface->showAt(50, 50, Rect{0, 0, 100, 100});
+
+ bufferSurface->requestFocus();
+ bufferSurface->assertFocusChange(true);
+}
+
/**
* If a cropped layer's touchable region is replaced with a null crop, it should receive input in
* its own crop.