Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Unified Diff: services/ui/ws/frame_generator_unittest.cc

Issue 2617603002: Revert of Mustash: Ensure surfaces submitted to Mus by WM and embedders contain Surfaces with embeded content. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/ui/ws/frame_generator_delegate.h ('k') | services/ui/ws/platform_display_default.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/ws/frame_generator_unittest.cc
diff --git a/services/ui/ws/frame_generator_unittest.cc b/services/ui/ws/frame_generator_unittest.cc
index ea6017e66c573e6b9591e7eafdd9f4f2190129a2..49c4a981cb4645f1e11662a936272e1e37e3e486 100644
--- a/services/ui/ws/frame_generator_unittest.cc
+++ b/services/ui/ws/frame_generator_unittest.cc
@@ -52,8 +52,8 @@
kRootDisplayId)) {}
~FrameGeneratorTest() override {}
- // Calls DrawWindow() on |frame_generator_|
- void DrawWindow(cc::RenderPass* pass);
+ // Calls DrawWindowTree() on |frame_generator_|
+ void DrawWindowTree(cc::RenderPass* pass);
ServerWindow* root_window() { return root_window_.get(); }
@@ -75,14 +75,14 @@
DISALLOW_COPY_AND_ASSIGN(FrameGeneratorTest);
};
-void FrameGeneratorTest::DrawWindow(cc::RenderPass* pass) {
- frame_generator_->DrawWindow(pass, root_window_.get());
+void FrameGeneratorTest::DrawWindowTree(cc::RenderPass* pass) {
+ frame_generator_->DrawWindowTree(pass, root_window_.get(), gfx::Vector2d(),
+ 1.0f);
}
void FrameGeneratorTest::SetUp() {
testing::Test::SetUp();
- frame_generator_delegate_ =
- base::MakeUnique<TestFrameGeneratorDelegate>(root_window_.get());
+ frame_generator_delegate_ = base::MakeUnique<TestFrameGeneratorDelegate>();
PlatformDisplayInitParams init_params;
frame_generator_ = base::MakeUnique<FrameGenerator>(
frame_generator_delegate_.get(), root_window_.get());
@@ -97,23 +97,51 @@
}
// Tests correctness of the SharedQuadStateList generated by
-// FrameGenerator::DrawWindow().
-TEST_F(FrameGeneratorTest, DrawWindow) {
+// FrameGenerator::DrawWindowTree().
+TEST_F(FrameGeneratorTest, DrawWindowTree) {
ServerWindow child_window(test_window_delegate(), WindowId(1, 1));
root_window()->Add(&child_window);
InitWindow(&child_window);
+ const float root_opacity = .5f;
const float child_opacity = .4f;
+ root_window()->SetOpacity(root_opacity);
child_window.SetOpacity(child_opacity);
std::unique_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create();
- DrawWindow(render_pass.get());
+ DrawWindowTree(render_pass.get());
cc::SharedQuadStateList* quad_state_list =
&render_pass->shared_quad_state_list;
- EXPECT_EQ(1u, quad_state_list->size());
+ // Both child and root have a DEFAULT Surface and no underlay Surfaces, so
+ // there should be two SharedQuadStates in the list.
+ EXPECT_EQ(2u, quad_state_list->size());
cc::SharedQuadState* root_sqs = quad_state_list->back();
- // Opacity should always be 1.
- EXPECT_EQ(1.0f, root_sqs->opacity);
+ cc::SharedQuadState* child_sqs = quad_state_list->front();
+ EXPECT_EQ(root_opacity, root_sqs->opacity);
+ // Child's SharedQuadState contains the effective opacity of the child layer,
+ // which should be a product of the child and the parent opacity.
+ EXPECT_EQ(child_opacity * root_opacity, child_sqs->opacity);
+
+ // Pretend to create the UNDERLAY Surface for the child window, and confirm
+ // that this creates an extra SharedQuadState in the CompositorFrame.
+ child_window.GetOrCreateCompositorFrameSinkManager()->SetLatestSurfaceInfo(
+ mojom::CompositorFrameSinkType::UNDERLAY,
+ cc::SurfaceInfo(
+ cc::SurfaceId(
+ cc::FrameSinkId(WindowIdToTransportId(child_window.id()),
+ static_cast<uint32_t>(
+ mojom::CompositorFrameSinkType::UNDERLAY)),
+ cc::LocalFrameId(1u, kArbitraryToken)),
+ 1.0f, gfx::Size(100, 100)));
+
+ render_pass = cc::RenderPass::Create();
+ DrawWindowTree(render_pass.get());
+ quad_state_list = &render_pass->shared_quad_state_list;
+ EXPECT_EQ(3u, quad_state_list->size());
+ auto it = quad_state_list->begin();
+ EXPECT_EQ(child_opacity * root_opacity, (*it)->opacity);
+ EXPECT_EQ(child_opacity * root_opacity, (*++it)->opacity);
+ EXPECT_EQ(root_opacity, (*++it)->opacity);
}
} // namespace test
« no previous file with comments | « services/ui/ws/frame_generator_delegate.h ('k') | services/ui/ws/platform_display_default.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698