@@ -360,6 +360,35 @@ TEST_F(MirrorLayerTest, OffscreenMirrorScreenshot) {
360360 }
361361}
362362
363+ TEST_F (MirrorLayerTest, MirrorLayerWithStopLayer) {
364+ if (!FlagManager::getInstance ().stop_layer ()) {
365+ GTEST_SKIP () << " skipping test - stop_layer feature flag disabled" ;
366+ }
367+
368+ sp<SurfaceControl> grandchild =
369+ createColorLayer (" Grandchild layer" , Color::BLUE, mChildLayer .get ());
370+ Transaction ()
371+ .setFlags (grandchild, layer_state_t ::eLayerOpaque, layer_state_t ::eLayerOpaque)
372+ .setCrop (grandchild, Rect (0 , 0 , 200 , 200 ))
373+ .show (grandchild)
374+ .apply ();
375+
376+ // Mirror child with stop layer set to grandchild.
377+ sp<SurfaceControl> mirrorLayer = mClient ->mirrorSurface (mChildLayer .get (), grandchild.get ());
378+ ASSERT_NE (mirrorLayer, nullptr );
379+
380+ // Add mirrorLayer as child of mParentLayer so it's shown on the display
381+ Transaction ()
382+ .reparent (mirrorLayer, mParentLayer )
383+ .setPosition (mirrorLayer, 500 , 500 )
384+ .show (mirrorLayer)
385+ .apply ();
386+
387+ auto shot = screenshot ();
388+ // Assert that we see the child's color and not the grandchild's color
389+ shot->expectColor (Rect (550 , 550 , 600 , 600 ), Color::GREEN);
390+ }
391+
363392} // namespace android
364393
365394// TODO(b/129481165): remove the #pragma below and fix conversion issues
0 commit comments