From d575096d797628d7b39417fef23b78ca6e035d1a Mon Sep 17 00:00:00 2001 From: Haixia Shi Date: Mon, 27 Jul 2015 16:50:49 -0700 Subject: [PATCH] Add more SF tests to Transaction_test TEST=verify all tests pass on hammerhead-eng BUG=none Change-Id: Idb4df0996ac4ebbef3784ee86bd43c584d62cf1f --- services/surfaceflinger/tests/Transaction_test.cpp | 107 +++++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/services/surfaceflinger/tests/Transaction_test.cpp b/services/surfaceflinger/tests/Transaction_test.cpp index dcde512017..3ae85a9424 100644 --- a/services/surfaceflinger/tests/Transaction_test.cpp +++ b/services/surfaceflinger/tests/Transaction_test.cpp @@ -249,4 +249,111 @@ TEST_F(LayerUpdateTest, LayerResizeWorks) { } } +TEST_F(LayerUpdateTest, LayerCropWorks) { + sp sc; + { + SCOPED_TRACE("before crop"); + ScreenCapture::captureScreen(&sc); + sc->checkPixel( 24, 24, 63, 63, 195); + sc->checkPixel( 75, 75, 195, 63, 63); + sc->checkPixel(145, 145, 63, 63, 195); + } + + SurfaceComposerClient::openGlobalTransaction(); + Rect cropRect(16, 16, 32, 32); + ASSERT_EQ(NO_ERROR, mFGSurfaceControl->setCrop(cropRect)); + SurfaceComposerClient::closeGlobalTransaction(true); + { + // This should crop the foreground surface. + SCOPED_TRACE("after crop"); + ScreenCapture::captureScreen(&sc); + sc->checkPixel( 24, 24, 63, 63, 195); + sc->checkPixel( 75, 75, 63, 63, 195); + sc->checkPixel( 95, 80, 195, 63, 63); + sc->checkPixel( 80, 95, 195, 63, 63); + sc->checkPixel( 96, 96, 63, 63, 195); + } +} + +TEST_F(LayerUpdateTest, LayerSetLayerWorks) { + sp sc; + { + SCOPED_TRACE("before setLayer"); + ScreenCapture::captureScreen(&sc); + sc->checkPixel( 24, 24, 63, 63, 195); + sc->checkPixel( 75, 75, 195, 63, 63); + sc->checkPixel(145, 145, 63, 63, 195); + } + + SurfaceComposerClient::openGlobalTransaction(); + ASSERT_EQ(NO_ERROR, mFGSurfaceControl->setLayer(INT_MAX - 3)); + SurfaceComposerClient::closeGlobalTransaction(true); + { + // This should hide the foreground surface beneath the background. + SCOPED_TRACE("after setLayer"); + ScreenCapture::captureScreen(&sc); + sc->checkPixel( 24, 24, 63, 63, 195); + sc->checkPixel( 75, 75, 63, 63, 195); + sc->checkPixel(145, 145, 63, 63, 195); + } +} + +TEST_F(LayerUpdateTest, LayerShowHideWorks) { + sp sc; + { + SCOPED_TRACE("before hide"); + ScreenCapture::captureScreen(&sc); + sc->checkPixel( 24, 24, 63, 63, 195); + sc->checkPixel( 75, 75, 195, 63, 63); + sc->checkPixel(145, 145, 63, 63, 195); + } + + SurfaceComposerClient::openGlobalTransaction(); + ASSERT_EQ(NO_ERROR, mFGSurfaceControl->hide()); + SurfaceComposerClient::closeGlobalTransaction(true); + { + // This should hide the foreground surface. + SCOPED_TRACE("after hide, before show"); + ScreenCapture::captureScreen(&sc); + sc->checkPixel( 24, 24, 63, 63, 195); + sc->checkPixel( 75, 75, 63, 63, 195); + sc->checkPixel(145, 145, 63, 63, 195); + } + + SurfaceComposerClient::openGlobalTransaction(); + ASSERT_EQ(NO_ERROR, mFGSurfaceControl->show()); + SurfaceComposerClient::closeGlobalTransaction(true); + { + // This should show the foreground surface. + SCOPED_TRACE("after show"); + ScreenCapture::captureScreen(&sc); + sc->checkPixel( 24, 24, 63, 63, 195); + sc->checkPixel( 75, 75, 195, 63, 63); + sc->checkPixel(145, 145, 63, 63, 195); + } +} + +TEST_F(LayerUpdateTest, LayerSetAlphaWorks) { + sp sc; + { + SCOPED_TRACE("before setAlpha"); + ScreenCapture::captureScreen(&sc); + sc->checkPixel( 24, 24, 63, 63, 195); + sc->checkPixel( 75, 75, 195, 63, 63); + sc->checkPixel(145, 145, 63, 63, 195); + } + + SurfaceComposerClient::openGlobalTransaction(); + ASSERT_EQ(NO_ERROR, mFGSurfaceControl->setAlpha(0.75f)); + SurfaceComposerClient::closeGlobalTransaction(true); + { + // This should set foreground to be 75% opaque. + SCOPED_TRACE("after setAlpha"); + ScreenCapture::captureScreen(&sc); + sc->checkPixel( 24, 24, 63, 63, 195); + sc->checkPixel( 75, 75, 162, 63, 96); + sc->checkPixel(145, 145, 63, 63, 195); + } +} + } -- 2.11.0