surfaceflinger: enable LayerTransactionTest in presubmit
Enable LayerTransactionTest in SurfaceFlinger_test.filter. Remove
duplicated tests from LayerUpdateTest, CropLatchingTest,
GeometryLatchingTest, and LayerColorTest.
Test: SurfaceFlinger_test
Change-Id: Ib6625e14d630ee93622b7bbf9ffd788cc7827b27
diff --git a/services/surfaceflinger/tests/SurfaceFlinger_test.filter b/services/surfaceflinger/tests/SurfaceFlinger_test.filter
index 5c188dc..be4127c 100644
--- a/services/surfaceflinger/tests/SurfaceFlinger_test.filter
+++ b/services/surfaceflinger/tests/SurfaceFlinger_test.filter
@@ -1,5 +1,5 @@
{
"presubmit": {
- "filter": "LayerUpdateTest.*:ChildLayerTest.*:SurfaceFlingerStress.*:CropLatchingTest.*:GeometryLatchingTest.*:LayerColorTest.*"
+ "filter": "LayerTransactionTest.*:LayerUpdateTest.*:ChildLayerTest.*:SurfaceFlingerStress.*:CropLatchingTest.*:GeometryLatchingTest.*"
}
-}
\ No newline at end of file
+}
diff --git a/services/surfaceflinger/tests/Transaction_test.cpp b/services/surfaceflinger/tests/Transaction_test.cpp
index 6ede562..943fafd 100644
--- a/services/surfaceflinger/tests/Transaction_test.cpp
+++ b/services/surfaceflinger/tests/Transaction_test.cpp
@@ -1626,273 +1626,6 @@
}
}
-TEST_F(LayerUpdateTest, LayerMoveWorks) {
- sp<ScreenCapture> sc;
- {
- SCOPED_TRACE("before move");
- ScreenCapture::captureScreen(&sc);
- sc->expectBGColor(0, 12);
- sc->expectFGColor(75, 75);
- sc->expectBGColor(145, 145);
- }
-
- asTransaction([&](Transaction& t) { t.setPosition(mFGSurfaceControl, 128, 128); });
-
- {
- // This should reflect the new position, but not the new color.
- SCOPED_TRACE("after move, before redraw");
- ScreenCapture::captureScreen(&sc);
- sc->expectBGColor(24, 24);
- sc->expectBGColor(75, 75);
- sc->expectFGColor(145, 145);
- }
-
- fillSurfaceRGBA8(mFGSurfaceControl, 63, 195, 63);
- waitForPostedBuffers();
- {
- // This should reflect the new position and the new color.
- SCOPED_TRACE("after redraw");
- ScreenCapture::captureScreen(&sc);
- sc->expectBGColor(24, 24);
- sc->expectBGColor(75, 75);
- sc->checkPixel(145, 145, 63, 195, 63);
- }
-}
-
-TEST_F(LayerUpdateTest, LayerResizeWorks) {
- sp<ScreenCapture> sc;
- {
- SCOPED_TRACE("before resize");
- ScreenCapture::captureScreen(&sc);
- sc->expectBGColor(0, 12);
- sc->expectFGColor(75, 75);
- sc->expectBGColor(145, 145);
- }
-
- ALOGD("resizing");
- asTransaction([&](Transaction& t) { t.setSize(mFGSurfaceControl, 128, 128); });
- ALOGD("resized");
- {
- // This should not reflect the new size or color because SurfaceFlinger
- // has not yet received a buffer of the correct size.
- SCOPED_TRACE("after resize, before redraw");
- ScreenCapture::captureScreen(&sc);
- sc->expectBGColor(0, 12);
- sc->expectFGColor(75, 75);
- sc->expectBGColor(145, 145);
- }
-
- ALOGD("drawing");
- fillSurfaceRGBA8(mFGSurfaceControl, 63, 195, 63);
- waitForPostedBuffers();
- ALOGD("drawn");
- {
- // This should reflect the new size and the new color.
- SCOPED_TRACE("after redraw");
- ScreenCapture::captureScreen(&sc);
- sc->expectBGColor(24, 24);
- sc->checkPixel(75, 75, 63, 195, 63);
- sc->checkPixel(145, 145, 63, 195, 63);
- }
-}
-
-TEST_F(LayerUpdateTest, LayerCropWorks) {
- sp<ScreenCapture> sc;
- {
- SCOPED_TRACE("before crop");
- ScreenCapture::captureScreen(&sc);
- sc->expectBGColor(24, 24);
- sc->expectFGColor(75, 75);
- sc->expectBGColor(145, 145);
- }
-
- asTransaction([&](Transaction& t) {
- Rect cropRect(16, 16, 32, 32);
- t.setCrop(mFGSurfaceControl, cropRect);
- });
- {
- // This should crop the foreground surface.
- SCOPED_TRACE("after crop");
- ScreenCapture::captureScreen(&sc);
- sc->expectBGColor(24, 24);
- sc->expectBGColor(75, 75);
- sc->expectFGColor(95, 80);
- sc->expectFGColor(80, 95);
- sc->expectBGColor(96, 96);
- }
-}
-
-TEST_F(LayerUpdateTest, LayerFinalCropWorks) {
- sp<ScreenCapture> sc;
- {
- SCOPED_TRACE("before crop");
- ScreenCapture::captureScreen(&sc);
- sc->expectBGColor(24, 24);
- sc->expectFGColor(75, 75);
- sc->expectBGColor(145, 145);
- }
- asTransaction([&](Transaction& t) {
- Rect cropRect(16, 16, 32, 32);
- t.setFinalCrop(mFGSurfaceControl, cropRect);
- });
- {
- // This should crop the foreground surface.
- SCOPED_TRACE("after crop");
- ScreenCapture::captureScreen(&sc);
- sc->expectBGColor(24, 24);
- sc->expectBGColor(75, 75);
- sc->expectBGColor(95, 80);
- sc->expectBGColor(80, 95);
- sc->expectBGColor(96, 96);
- }
-}
-
-TEST_F(LayerUpdateTest, LayerSetLayerWorks) {
- sp<ScreenCapture> sc;
- {
- SCOPED_TRACE("before setLayer");
- ScreenCapture::captureScreen(&sc);
- sc->expectBGColor(24, 24);
- sc->expectFGColor(75, 75);
- sc->expectBGColor(145, 145);
- }
-
- asTransaction([&](Transaction& t) { t.setLayer(mFGSurfaceControl, INT_MAX - 3); });
-
- {
- // This should hide the foreground surface beneath the background.
- SCOPED_TRACE("after setLayer");
- ScreenCapture::captureScreen(&sc);
- sc->expectBGColor(24, 24);
- sc->expectBGColor(75, 75);
- sc->expectBGColor(145, 145);
- }
-}
-
-TEST_F(LayerUpdateTest, LayerShowHideWorks) {
- sp<ScreenCapture> sc;
- {
- SCOPED_TRACE("before hide");
- ScreenCapture::captureScreen(&sc);
- sc->expectBGColor(24, 24);
- sc->expectFGColor(75, 75);
- sc->expectBGColor(145, 145);
- }
-
- asTransaction([&](Transaction& t) { t.hide(mFGSurfaceControl); });
-
- {
- // This should hide the foreground surface.
- SCOPED_TRACE("after hide, before show");
- ScreenCapture::captureScreen(&sc);
- sc->expectBGColor(24, 24);
- sc->expectBGColor(75, 75);
- sc->expectBGColor(145, 145);
- }
-
- asTransaction([&](Transaction& t) { t.show(mFGSurfaceControl); });
-
- {
- // This should show the foreground surface.
- SCOPED_TRACE("after show");
- ScreenCapture::captureScreen(&sc);
- sc->expectBGColor(24, 24);
- sc->expectFGColor(75, 75);
- sc->expectBGColor(145, 145);
- }
-}
-
-TEST_F(LayerUpdateTest, LayerSetAlphaWorks) {
- sp<ScreenCapture> sc;
- {
- SCOPED_TRACE("before setAlpha");
- ScreenCapture::captureScreen(&sc);
- sc->expectBGColor(24, 24);
- sc->expectFGColor(75, 75);
- sc->expectBGColor(145, 145);
- }
-
- asTransaction([&](Transaction& t) { t.setAlpha(mFGSurfaceControl, 0.75f); });
-
- {
- // This should set foreground to be 75% opaque.
- SCOPED_TRACE("after setAlpha");
- ScreenCapture::captureScreen(&sc);
- sc->expectBGColor(24, 24);
- sc->checkPixel(75, 75, 162, 63, 96);
- sc->expectBGColor(145, 145);
- }
-}
-
-TEST_F(LayerUpdateTest, LayerSetLayerStackWorks) {
- sp<ScreenCapture> sc;
- {
- SCOPED_TRACE("before setLayerStack");
- ScreenCapture::captureScreen(&sc);
- sc->expectBGColor(24, 24);
- sc->expectFGColor(75, 75);
- sc->expectBGColor(145, 145);
- }
-
- asTransaction([&](Transaction& t) { t.setLayerStack(mFGSurfaceControl, 1); });
- {
- // This should hide the foreground surface since it goes to a different
- // layer stack.
- SCOPED_TRACE("after setLayerStack");
- ScreenCapture::captureScreen(&sc);
- sc->expectBGColor(24, 24);
- sc->expectBGColor(75, 75);
- sc->expectBGColor(145, 145);
- }
-}
-
-TEST_F(LayerUpdateTest, LayerSetFlagsWorks) {
- sp<ScreenCapture> sc;
- {
- SCOPED_TRACE("before setFlags");
- ScreenCapture::captureScreen(&sc);
- sc->expectBGColor(24, 24);
- sc->expectFGColor(75, 75);
- sc->expectBGColor(145, 145);
- }
-
- asTransaction([&](Transaction& t) {
- t.setFlags(mFGSurfaceControl, layer_state_t::eLayerHidden, layer_state_t::eLayerHidden);
- });
- {
- // This should hide the foreground surface
- SCOPED_TRACE("after setFlags");
- ScreenCapture::captureScreen(&sc);
- sc->expectBGColor(24, 24);
- sc->expectBGColor(75, 75);
- sc->expectBGColor(145, 145);
- }
-}
-
-TEST_F(LayerUpdateTest, LayerSetMatrixWorks) {
- sp<ScreenCapture> sc;
- {
- SCOPED_TRACE("before setMatrix");
- ScreenCapture::captureScreen(&sc);
- sc->expectBGColor(24, 24);
- sc->expectFGColor(91, 96);
- sc->expectFGColor(96, 101);
- sc->expectBGColor(145, 145);
- }
-
- asTransaction([&](Transaction& t) {
- t.setMatrix(mFGSurfaceControl, M_SQRT1_2, M_SQRT1_2, -M_SQRT1_2, M_SQRT1_2);
- });
- {
- SCOPED_TRACE("after setMatrix");
- ScreenCapture::captureScreen(&sc);
- sc->expectBGColor(24, 24);
- sc->expectFGColor(91, 96);
- sc->expectBGColor(96, 91);
- sc->expectBGColor(145, 145);
- }
-}
-
class GeometryLatchingTest : public LayerUpdateTest {
protected:
void EXPECT_INITIAL_STATE(const char* trace) {
@@ -1928,53 +1661,6 @@
sp<ScreenCapture> sc;
};
-TEST_F(GeometryLatchingTest, SurfacePositionLatching) {
- EXPECT_INITIAL_STATE("before anything");
-
- // By default position can be updated even while
- // a resize is pending.
- asTransaction([&](Transaction& t) {
- t.setSize(mFGSurfaceControl, 32, 32);
- t.setPosition(mFGSurfaceControl, 100, 100);
- });
-
- {
- SCOPED_TRACE("After moving surface");
- ScreenCapture::captureScreen(&sc);
- // If we moved, the FG Surface should cover up what was previously BG
- // however if we didn't move the FG wouldn't be large enough now.
- sc->expectFGColor(163, 163);
- }
-
- restoreInitialState();
-
- // Now we repeat with setGeometryAppliesWithResize
- // and verify the position DOESN'T latch.
- asTransaction([&](Transaction& t) {
- t.setGeometryAppliesWithResize(mFGSurfaceControl);
- t.setSize(mFGSurfaceControl, 32, 32);
- t.setPosition(mFGSurfaceControl, 100, 100);
- });
-
- {
- SCOPED_TRACE("While resize is pending");
- ScreenCapture::captureScreen(&sc);
- // This time we shouldn't have moved, so the BG color
- // should still be visible.
- sc->expectBGColor(128, 128);
- }
-
- completeFGResize();
-
- {
- SCOPED_TRACE("After the resize");
- ScreenCapture::captureScreen(&sc);
- // But after the resize completes, we should move
- // and the FG should be visible here.
- sc->expectFGColor(128, 128);
- }
-}
-
class CropLatchingTest : public GeometryLatchingTest {
protected:
void EXPECT_CROPPED_STATE(const char* trace) {
@@ -1996,56 +1682,6 @@
}
};
-TEST_F(CropLatchingTest, CropLatching) {
- EXPECT_INITIAL_STATE("before anything");
- // Normally the crop applies immediately even while a resize is pending.
- asTransaction([&](Transaction& t) {
- t.setSize(mFGSurfaceControl, 128, 128);
- t.setCrop(mFGSurfaceControl, Rect(0, 0, 63, 63));
- });
-
- EXPECT_CROPPED_STATE("after setting crop (without geometryAppliesWithResize)");
-
- restoreInitialState();
-
- asTransaction([&](Transaction& t) {
- t.setSize(mFGSurfaceControl, 128, 128);
- t.setGeometryAppliesWithResize(mFGSurfaceControl);
- t.setCrop(mFGSurfaceControl, Rect(0, 0, 63, 63));
- });
-
- EXPECT_INITIAL_STATE("after setting crop (with geometryAppliesWithResize)");
-
- completeFGResize();
-
- EXPECT_CROPPED_STATE("after the resize finishes");
-}
-
-TEST_F(CropLatchingTest, FinalCropLatching) {
- EXPECT_INITIAL_STATE("before anything");
- // Normally the crop applies immediately even while a resize is pending.
- asTransaction([&](Transaction& t) {
- t.setSize(mFGSurfaceControl, 128, 128);
- t.setFinalCrop(mFGSurfaceControl, Rect(64, 64, 127, 127));
- });
-
- EXPECT_CROPPED_STATE("after setting crop (without geometryAppliesWithResize)");
-
- restoreInitialState();
-
- asTransaction([&](Transaction& t) {
- t.setSize(mFGSurfaceControl, 128, 128);
- t.setGeometryAppliesWithResize(mFGSurfaceControl);
- t.setFinalCrop(mFGSurfaceControl, Rect(64, 64, 127, 127));
- });
-
- EXPECT_INITIAL_STATE("after setting crop (with geometryAppliesWithResize)");
-
- completeFGResize();
-
- EXPECT_CROPPED_STATE("after the resize finishes");
-}
-
// In this test we ensure that setGeometryAppliesWithResize actually demands
// a buffer of the new size, and not just any size.
TEST_F(CropLatchingTest, FinalCropLatchingBufferOldSize) {
@@ -2083,28 +1719,6 @@
EXPECT_CROPPED_STATE("after the resize finishes");
}
-TEST_F(CropLatchingTest, FinalCropLatchingRegressionForb37531386) {
- EXPECT_INITIAL_STATE("before anything");
- // In this scenario, we attempt to set the final crop a second time while the resize
- // is still pending, and ensure we are successful. Success meaning the second crop
- // is the one which eventually latches and not the first.
- asTransaction([&](Transaction& t) {
- t.setSize(mFGSurfaceControl, 128, 128);
- t.setGeometryAppliesWithResize(mFGSurfaceControl);
- t.setFinalCrop(mFGSurfaceControl, Rect(64, 64, 127, 127));
- });
-
- EXPECT_INITIAL_STATE("after setting crops with geometryAppliesWithResize");
-
- asTransaction([&](Transaction& t) { t.setFinalCrop(mFGSurfaceControl, Rect(0, 0, -1, -1)); });
-
- EXPECT_INITIAL_STATE("after setting another crop");
-
- completeFGResize();
-
- EXPECT_RESIZE_STATE("after the resize finishes");
-}
-
TEST_F(LayerUpdateTest, DeferredTransactionTest) {
sp<ScreenCapture> sc;
{
@@ -2160,46 +1774,6 @@
}
}
-TEST_F(LayerUpdateTest, LayerSetRelativeLayerWorks) {
- sp<ScreenCapture> sc;
- {
- SCOPED_TRACE("before adding relative surface");
- ScreenCapture::captureScreen(&sc);
- sc->expectBGColor(24, 24);
- sc->expectFGColor(75, 75);
- sc->expectBGColor(145, 145);
- }
-
- auto relativeSurfaceControl = mComposerClient->createSurface(String8("Test Surface"), 64, 64,
- PIXEL_FORMAT_RGBA_8888, 0);
- fillSurfaceRGBA8(relativeSurfaceControl, 255, 177, 177);
- waitForPostedBuffers();
-
- // Now we stack the surface above the foreground surface and make sure it is visible.
- asTransaction([&](Transaction& t) {
- t.setPosition(relativeSurfaceControl, 64, 64);
- t.show(relativeSurfaceControl);
- t.setRelativeLayer(relativeSurfaceControl, mFGSurfaceControl->getHandle(), 1);
- });
-
- {
- SCOPED_TRACE("after adding relative surface");
- ScreenCapture::captureScreen(&sc);
- // our relative surface should be visible now.
- sc->checkPixel(75, 75, 255, 177, 177);
- }
-
- // A call to setLayer will override a call to setRelativeLayer
- asTransaction([&](Transaction& t) { t.setLayer(relativeSurfaceControl, 0); });
-
- {
- SCOPED_TRACE("after set layer");
- ScreenCapture::captureScreen(&sc);
- // now the FG surface should be visible again.
- sc->expectFGColor(75, 75);
- }
-}
-
TEST_F(LayerUpdateTest, LayerWithNoBuffersResizesImmediately) {
sp<ScreenCapture> sc;
@@ -2742,100 +2316,6 @@
}
}
-class LayerColorTest : public LayerUpdateTest {
-protected:
- void SetUp() override {
- LayerUpdateTest::SetUp();
-
- mLayerColorControl =
- mComposerClient->createSurface(String8("Layer color surface"), 128, 128,
- PIXEL_FORMAT_RGBA_8888,
- ISurfaceComposerClient::eFXSurfaceColor);
-
- ASSERT_TRUE(mLayerColorControl != NULL);
- ASSERT_TRUE(mLayerColorControl->isValid());
-
- asTransaction([&](Transaction& t) {
- t.setLayer(mLayerColorControl, INT32_MAX - 1);
- t.setPosition(mLayerColorControl, 140, 140);
- t.hide(mLayerColorControl);
- t.hide(mFGSurfaceControl);
- });
- }
-
- void TearDown() override {
- LayerUpdateTest::TearDown();
- mLayerColorControl = 0;
- }
-
- sp<SurfaceControl> mLayerColorControl;
-};
-
-TEST_F(LayerColorTest, ColorLayerNoAlpha) {
- sp<ScreenCapture> sc;
-
- {
- SCOPED_TRACE("before setColor");
- ScreenCapture::captureScreen(&sc);
- sc->expectBGColor(145, 145);
- }
-
- asTransaction([&](Transaction& t) {
- half3 color(43.0f / 255.0f, 207.0f / 255.0f, 131.0f / 255.0f);
- t.setColor(mLayerColorControl, color);
- t.show(mLayerColorControl);
- });
-
- {
- // There should now be a color
- SCOPED_TRACE("after setColor");
-
- ScreenCapture::captureScreen(&sc);
- sc->checkPixel(145, 145, 43, 207, 131);
- }
-}
-
-TEST_F(LayerColorTest, ColorLayerWithAlpha) {
- sp<ScreenCapture> sc;
- {
- SCOPED_TRACE("before setColor");
- ScreenCapture::captureScreen(&sc);
- sc->expectBGColor(145, 145);
- }
-
- asTransaction([&](Transaction& t) {
- half3 color(43.0f / 255.0f, 207.0f / 255.0f, 131.0f / 255.0f);
- t.setColor(mLayerColorControl, color);
- t.setAlpha(mLayerColorControl, .75f);
- t.show(mLayerColorControl);
- });
-
- {
- // There should now be a color with .75 alpha
- SCOPED_TRACE("after setColor");
- ScreenCapture::captureScreen(&sc);
- sc->checkPixel(145, 145, 48, 171, 147);
- }
-}
-
-TEST_F(LayerColorTest, ColorLayerWithNoColor) {
- sp<ScreenCapture> sc;
- {
- SCOPED_TRACE("before setColor");
- ScreenCapture::captureScreen(&sc);
- sc->expectBGColor(145, 145);
- }
-
- asTransaction([&](Transaction& t) { t.show(mLayerColorControl); });
-
- {
- // There should now be set to 0,0,0 (black) as default.
- SCOPED_TRACE("after setColor");
- ScreenCapture::captureScreen(&sc);
- sc->checkPixel(145, 145, 0, 0, 0);
- }
-}
-
class ScreenCaptureTest : public LayerUpdateTest {
protected:
std::unique_ptr<CaptureLayer> mCapture;