@@ -10,11 +10,41 @@ namespace flutter_embedder_test {
1010
1111constexpr char kParentViewUrl [] = " fuchsia-pkg://fuchsia.com/parent-view#meta/parent-view.cmx" ;
1212
13- constexpr scenic::Color kParentBackgroundColor = {0x00 , 0x00 , 0xFF , 0xFF }; // Blue
14- constexpr scenic::Color kParentTappedColor = {0x00 , 0x00 , 0x00 , 0xFF }; // Black
15- constexpr scenic::Color kOverlayBackgroundColor = {0x00 , 0xFF , 0x00 , 0xFF }; // Green
16- constexpr scenic::Color kChildBackgroundColor = {0xFF , 0x00 , 0xFF , 0xFF }; // Pink
17- constexpr scenic::Color kChildTappedColor = {0xFF , 0xFF , 0x00 , 0xFF }; // Yellow
13+ constexpr scenic::Color kParentBackgroundColor = {0x00 , 0x00 , 0xFF , 0xFF }; // Blue
14+ constexpr scenic::Color kParentTappedColor = {0x00 , 0x00 , 0x00 , 0xFF }; // Black
15+ constexpr scenic::Color kChildBackgroundColor = {0xFF , 0x00 , 0xFF , 0xFF }; // Pink
16+ constexpr scenic::Color kChildTappedColor = {0xFF , 0xFF , 0x00 , 0xFF }; // Yellow
17+
18+ // TODO(fxb/64201): The new flutter renderer draws overlays as a single, large layer. Some parts of
19+ // this layer are fully transparent, so we want the compositor to treat the layer as transparent and
20+ // blend it with the contents below.
21+ //
22+ // The gfx Scenic API only provides one way to mark this layer as transparent which is to set an
23+ // opacity < 1.0 for the entire layer. In practice, we use 0.9961 (254 / 255) as an opacity value
24+ // to force transparency. Unfortunately this causes the overlay to blend very slightly and it looks
25+ // wrong.
26+ //
27+ // Flatland allows marking a layer as transparent while still using a 1.0 opacity value when
28+ // blending, so migrating flutter to Flatland will fix this issue. For now we just hard-code the
29+ // broken, blended values.
30+ constexpr scenic::Color kOverlayBackgroundColor1 = {0x00 , 0xFF , 0x0E ,
31+ 0xFF }; // Green, blended with blue (FEMU local)
32+ constexpr scenic::Color kOverlayBackgroundColor2 = {0x0E , 0xFF , 0x0E ,
33+ 0xFF }; // Green, blended with pink (FEMU local)
34+ constexpr scenic::Color kOverlayBackgroundColor3 = {0x00 , 0xFF , 0x0D ,
35+ 0xFF }; // Green, blended with blue (AEMU infra)
36+ constexpr scenic::Color kOverlayBackgroundColor4 = {0x0D , 0xFF , 0x0D ,
37+ 0xFF }; // Green, blended with pink (AEMU infra)
38+ constexpr scenic::Color kOverlayBackgroundColor5 = {0x00 , 0xFE , 0x0D ,
39+ 0xFF }; // Green, blended with blue (NUC)
40+ constexpr scenic::Color kOverlayBackgroundColor6 = {0x0D , 0xFF , 0x00 ,
41+ 0xFF }; // Green, blended with pink (NUC)
42+
43+ static size_t OverlayPixelCount (std::map<scenic::Color, size_t >& histogram) {
44+ return histogram[kOverlayBackgroundColor1 ] + histogram[kOverlayBackgroundColor2 ] +
45+ histogram[kOverlayBackgroundColor3 ] + histogram[kOverlayBackgroundColor4 ] +
46+ histogram[kOverlayBackgroundColor5 ] + histogram[kOverlayBackgroundColor6 ];
47+ }
1848
1949// / Defines a list of services that are injected into the test environment. Unlike the
2050// / injected-services in CMX which are injected per test package, these are injected per test and
@@ -54,114 +84,23 @@ const std::vector<std::pair<const char*, const char*>> GetInjectedServices() {
5484 " fuchsia-pkg://fuchsia.com/ime_service#meta/ime_service.cmx"
5585 },{
5686 " fuchsia.ui.scenic.Scenic" ,
57- " fuchsia-pkg://fuchsia.com/scenic #meta/scenic.cmx"
87+ " fuchsia-pkg://fuchsia.com/flutter-embedder-test #meta/scenic.cmx"
5888 },{
5989 " fuchsia.ui.pointerinjector.Registry" ,
60- " fuchsia-pkg://fuchsia.com/scenic #meta/scenic.cmx"
90+ " fuchsia-pkg://fuchsia.com/flutter-embedder-test #meta/scenic.cmx"
6191 },{
6292 " fuchsia.ui.policy.Presenter" ,
63- " fuchsia-pkg://fuchsia.com/root_presenter #meta/root_presenter.cmx"
93+ " fuchsia-pkg://fuchsia.com/flutter-embedder-test #meta/root_presenter.cmx"
6494 },{
6595 " fuchsia.ui.input.InputDeviceRegistry" ,
66- " fuchsia-pkg://fuchsia.com/root_presenter #meta/root_presenter.cmx"
96+ " fuchsia-pkg://fuchsia.com/flutter-embedder-test #meta/root_presenter.cmx"
6797 },
6898 // clang-format on
6999 }};
70100 return injected_services;
71101}
72102
73- TEST_F (FlutterEmbedderTests, BasicLegacyEmbedding) {
74- RunAppWithArgs (kParentViewUrl , {" --no-usePlatformView" });
75-
76- // Take screenshot until we see the child-view's embedded color.
77- ASSERT_TRUE (
78- TakeScreenshotUntil (kChildBackgroundColor , [](std::map<scenic::Color, size_t > histogram) {
79- // Expect parent and child background colors, with parent color > child color.
80- EXPECT_GT (histogram[kParentBackgroundColor ], 0u );
81- EXPECT_GT (histogram[kChildBackgroundColor ], 0u );
82- EXPECT_GT (histogram[kParentBackgroundColor ], histogram[kChildBackgroundColor ]);
83- }));
84- }
85-
86- TEST_F (FlutterEmbedderTests, HittestLegacyEmbedding) {
87- RunAppWithArgs (kParentViewUrl , {" --no-usePlatformView" });
88-
89- // Take screenshot until we see the child-view's embedded color.
90- ASSERT_TRUE (TakeScreenshotUntil (kChildBackgroundColor ));
91-
92- // Tap the center of child view.
93- InjectInput ();
94-
95- // Take screenshot until we see the child-view's tapped color.
96- ASSERT_TRUE (TakeScreenshotUntil (kChildTappedColor , [](std::map<scenic::Color, size_t > histogram) {
97- // Expect parent and child background colors, with parent color > child color.
98- EXPECT_GT (histogram[kParentBackgroundColor ], 0u );
99- EXPECT_EQ (histogram[kChildBackgroundColor ], 0u );
100- EXPECT_GT (histogram[kChildTappedColor ], 0u );
101- EXPECT_GT (histogram[kParentBackgroundColor ], histogram[kChildTappedColor ]);
102- }));
103- }
104-
105- TEST_F (FlutterEmbedderTests, HittestDisabledLegacyEmbedding) {
106- RunAppWithArgs (kParentViewUrl , {" --no-hitTestable" , " --no-usePlatformView" });
107-
108- // Take screenshots until we see the child-view's embedded color.
109- ASSERT_TRUE (TakeScreenshotUntil (kChildBackgroundColor ));
110-
111- // Tap the center of child view. Since it's not hit-testable, the tap should go to the parent.
112- InjectInput ();
113-
114- // The parent-view should change color.
115- ASSERT_TRUE (
116- TakeScreenshotUntil (kParentTappedColor , [](std::map<scenic::Color, size_t > histogram) {
117- // Expect parent and child background colors, with parent color > child color.
118- EXPECT_EQ (histogram[kParentBackgroundColor ], 0u );
119- EXPECT_GT (histogram[kParentTappedColor ], 0u );
120- EXPECT_GT (histogram[kChildBackgroundColor ], 0u );
121- EXPECT_EQ (histogram[kChildTappedColor ], 0u );
122- EXPECT_GT (histogram[kParentTappedColor ], histogram[kChildBackgroundColor ]);
123- }));
124- }
125-
126- TEST_F (FlutterEmbedderTests, BasicLegacyEmbeddingWithOverlay) {
127- RunAppWithArgs (kParentViewUrl , {" --showOverlay" , " --no-usePlatformView" });
128-
129- // Take screenshot until we see the child-view's embedded color.
130- ASSERT_TRUE (
131- TakeScreenshotUntil (kChildBackgroundColor , [](std::map<scenic::Color, size_t > histogram) {
132- // Expect parent, overlay and child background colors.
133- // With parent color > child color and overlay color > child color.
134- EXPECT_GT (histogram[kParentBackgroundColor ], 0u );
135- EXPECT_GT (histogram[kOverlayBackgroundColor ], 0u );
136- EXPECT_GT (histogram[kChildBackgroundColor ], 0u );
137- EXPECT_GT (histogram[kParentBackgroundColor ], histogram[kChildBackgroundColor ]);
138- EXPECT_GT (histogram[kOverlayBackgroundColor ], histogram[kChildBackgroundColor ]);
139- }));
140- }
141-
142- TEST_F (FlutterEmbedderTests, HittestLegacyEmbeddingWithOverlay) {
143- RunAppWithArgs (kParentViewUrl , {" --showOverlay" , " --no-usePlatformView" });
144-
145- // Take screenshot until we see the child-view's embedded color.
146- ASSERT_TRUE (TakeScreenshotUntil (kChildBackgroundColor ));
147-
148- // Tap the center of child view.
149- InjectInput ();
150-
151- // Take screenshot until we see the child-view's tapped color.
152- ASSERT_TRUE (TakeScreenshotUntil (kChildTappedColor , [](std::map<scenic::Color, size_t > histogram) {
153- // Expect parent, overlay and child background colors.
154- // With parent color > child color and overlay color > child color.
155- EXPECT_GT (histogram[kParentBackgroundColor ], 0u );
156- EXPECT_GT (histogram[kOverlayBackgroundColor ], 0u );
157- EXPECT_EQ (histogram[kChildBackgroundColor ], 0u );
158- EXPECT_GT (histogram[kChildTappedColor ], 0u );
159- EXPECT_GT (histogram[kParentBackgroundColor ], histogram[kChildTappedColor ]);
160- EXPECT_GT (histogram[kOverlayBackgroundColor ], histogram[kChildTappedColor ]);
161- }));
162- }
163-
164- TEST_F (FlutterEmbedderTests, DISABLED_BasicPlatformViewEmbedding) {
103+ TEST_F (FlutterEmbedderTests, Embedding) {
165104 RunAppWithArgs (kParentViewUrl );
166105
167106 // Take screenshot until we see the child-view's embedded color.
@@ -174,7 +113,7 @@ TEST_F(FlutterEmbedderTests, DISABLED_BasicPlatformViewEmbedding) {
174113 }));
175114}
176115
177- TEST_F (FlutterEmbedderTests, DISABLED_HittestPlatformViewEmbedding ) {
116+ TEST_F (FlutterEmbedderTests, HittestEmbedding ) {
178117 RunAppWithArgs (kParentViewUrl );
179118
180119 // Take screenshot until we see the child-view's embedded color.
@@ -193,7 +132,7 @@ TEST_F(FlutterEmbedderTests, DISABLED_HittestPlatformViewEmbedding) {
193132 }));
194133}
195134
196- TEST_F (FlutterEmbedderTests, DISABLED_HittestDisabledPlatformViewEmbedding ) {
135+ TEST_F (FlutterEmbedderTests, HittestDisabledEmbedding ) {
197136 RunAppWithArgs (kParentViewUrl , {" --no-hitTestable" });
198137
199138 // Take screenshots until we see the child-view's embedded color.
@@ -214,23 +153,24 @@ TEST_F(FlutterEmbedderTests, DISABLED_HittestDisabledPlatformViewEmbedding) {
214153 }));
215154}
216155
217- TEST_F (FlutterEmbedderTests, DISABLED_BasicPlatformViewEmbeddingWithOverlay ) {
156+ TEST_F (FlutterEmbedderTests, EmbeddingWithOverlay ) {
218157 RunAppWithArgs (kParentViewUrl , {" --showOverlay" });
219158
220159 // Take screenshot until we see the child-view's embedded color.
221160 ASSERT_TRUE (
222161 TakeScreenshotUntil (kChildBackgroundColor , [](std::map<scenic::Color, size_t > histogram) {
223162 // Expect parent, overlay and child background colors.
224163 // With parent color > child color and overlay color > child color.
164+ const size_t overlay_pixel_count = OverlayPixelCount (histogram);
225165 EXPECT_GT (histogram[kParentBackgroundColor ], 0u );
226- EXPECT_GT (histogram[ kOverlayBackgroundColor ] , 0u );
166+ EXPECT_GT (overlay_pixel_count , 0u );
227167 EXPECT_GT (histogram[kChildBackgroundColor ], 0u );
228168 EXPECT_GT (histogram[kParentBackgroundColor ], histogram[kChildBackgroundColor ]);
229- EXPECT_GT (histogram[ kOverlayBackgroundColor ] , histogram[kChildBackgroundColor ]);
169+ EXPECT_GT (overlay_pixel_count , histogram[kChildBackgroundColor ]);
230170 }));
231171}
232172
233- TEST_F (FlutterEmbedderTests, DISABLED_HittestPlatformViewEmbeddingWithOverlay ) {
173+ TEST_F (FlutterEmbedderTests, HittestEmbeddingWithOverlay ) {
234174 RunAppWithArgs (kParentViewUrl , {" --showOverlay" });
235175
236176 // Take screenshot until we see the child-view's embedded color.
@@ -243,13 +183,13 @@ TEST_F(FlutterEmbedderTests, DISABLED_HittestPlatformViewEmbeddingWithOverlay) {
243183 ASSERT_TRUE (TakeScreenshotUntil (kChildTappedColor , [](std::map<scenic::Color, size_t > histogram) {
244184 // Expect parent, overlay and child background colors.
245185 // With parent color > child color and overlay color > child color.
246- // EXPECT_EQ((std::map<scenic::Color, size_t>){}, histogram) << "Unexpected colors" ;
186+ const size_t overlay_pixel_count = OverlayPixelCount (histogram) ;
247187 EXPECT_GT (histogram[kParentBackgroundColor ], 0u );
248- EXPECT_GT (histogram[ kOverlayBackgroundColor ] , 0u );
188+ EXPECT_GT (overlay_pixel_count , 0u );
249189 EXPECT_EQ (histogram[kChildBackgroundColor ], 0u );
250190 EXPECT_GT (histogram[kChildTappedColor ], 0u );
251191 EXPECT_GT (histogram[kParentBackgroundColor ], histogram[kChildTappedColor ]);
252- EXPECT_GT (histogram[ kOverlayBackgroundColor ] , histogram[kChildTappedColor ]);
192+ EXPECT_GT (overlay_pixel_count , histogram[kChildTappedColor ]);
253193 }));
254194}
255195
0 commit comments