summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/tests/unittests/SurfaceFlinger_SetDisplayStateTest.cpp
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2022-04-04 05:51:50 -0700
committerLinux Build Service Account <lnxbuild@localhost>2022-04-04 05:51:50 -0700
commitbcb95726067e422d4d55ab078c4b898915a91a45 (patch)
treedd8ded958bfdfda4007b7325353f5d10a45b00da /services/surfaceflinger/tests/unittests/SurfaceFlinger_SetDisplayStateTest.cpp
parent310298e2816e5393a85ea10a7661416376cf505d (diff)
parentc3e6bd2fb2223973f26325d11c28b32b8685cfbd (diff)
Merge c3e6bd2fb2223973f26325d11c28b32b8685cfbd on remote branch
Change-Id: Ic5966863c7610787847f8f7fc4f939af5f87f13e
Diffstat (limited to 'services/surfaceflinger/tests/unittests/SurfaceFlinger_SetDisplayStateTest.cpp')
-rw-r--r--services/surfaceflinger/tests/unittests/SurfaceFlinger_SetDisplayStateTest.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/services/surfaceflinger/tests/unittests/SurfaceFlinger_SetDisplayStateTest.cpp b/services/surfaceflinger/tests/unittests/SurfaceFlinger_SetDisplayStateTest.cpp
index be019848fb..fc40818ad1 100644
--- a/services/surfaceflinger/tests/unittests/SurfaceFlinger_SetDisplayStateTest.cpp
+++ b/services/surfaceflinger/tests/unittests/SurfaceFlinger_SetDisplayStateTest.cpp
@@ -224,6 +224,74 @@ TEST_F(SetDisplayStateLockedTest, setDisplayStateLockedRequestsUpdateIfLayerStac
EXPECT_EQ(456u, display.getCurrentDisplayState().layerStack);
}
+TEST_F(SetDisplayStateLockedTest, setDisplayStateLockedDoesNothingIfFlagsNotChanged) {
+ using Case = SimplePrimaryDisplayCase;
+
+ // --------------------------------------------------------------------
+ // Preconditions
+
+ // A display is set up
+ auto display = Case::Display::makeFakeExistingDisplayInjector(this);
+ display.inject();
+
+ // The display has flags set
+ display.mutableCurrentDisplayState().flags = 1u;
+
+ // The incoming request sets a different layer stack
+ DisplayState state;
+ state.what = DisplayState::eFlagsChanged;
+ state.token = display.token();
+ state.flags = 1u;
+
+ // --------------------------------------------------------------------
+ // Invocation
+
+ uint32_t flags = mFlinger.setDisplayStateLocked(state);
+
+ // --------------------------------------------------------------------
+ // Postconditions
+
+ // The returned flags are empty
+ EXPECT_EQ(0u, flags);
+
+ // The desired display state has been set to the new value.
+ EXPECT_EQ(1u, display.getCurrentDisplayState().flags);
+}
+
+TEST_F(SetDisplayStateLockedTest, setDisplayStateLockedRequestsUpdateIfFlagsChanged) {
+ using Case = SimplePrimaryDisplayCase;
+
+ // --------------------------------------------------------------------
+ // Preconditions
+
+ // A display is set up
+ auto display = Case::Display::makeFakeExistingDisplayInjector(this);
+ display.inject();
+
+ // The display has a layer stack set
+ display.mutableCurrentDisplayState().flags = 0u;
+
+ // The incoming request sets a different layer stack
+ DisplayState state;
+ state.what = DisplayState::eFlagsChanged;
+ state.token = display.token();
+ state.flags = 1u;
+
+ // --------------------------------------------------------------------
+ // Invocation
+
+ uint32_t flags = mFlinger.setDisplayStateLocked(state);
+
+ // --------------------------------------------------------------------
+ // Postconditions
+
+ // The returned flags indicate a transaction is needed
+ EXPECT_EQ(eDisplayTransactionNeeded, flags);
+
+ // The desired display state has been set to the new value.
+ EXPECT_EQ(1u, display.getCurrentDisplayState().flags);
+}
+
TEST_F(SetDisplayStateLockedTest, setDisplayStateLockedDoesNothingIfProjectionDidNotChange) {
using Case = SimplePrimaryDisplayCase;
constexpr ui::Rotation initialOrientation = ui::ROTATION_180;