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

Side by Side Diff: services/ui/ws/frame_generator_unittest.cc

Issue 2453013002: Mus: Remove dependency on ServerWindowCompositorFrameSink from FrameGenerator (Closed)
Patch Set: Rebased Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « services/ui/ws/frame_generator.cc ('k') | services/ui/ws/server_window_compositor_frame_sink.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "services/ui/ws/frame_generator.h" 5 #include "services/ui/ws/frame_generator.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/test/test_message_loop.h" 9 #include "base/test/test_message_loop.h"
10 #include "cc/quads/render_pass.h" 10 #include "cc/quads/render_pass.h"
(...skipping 13 matching lines...) Expand all
24 namespace { 24 namespace {
25 25
26 // Typical id for the display root ServerWindow. 26 // Typical id for the display root ServerWindow.
27 constexpr WindowId kRootDisplayId(0, 2); 27 constexpr WindowId kRootDisplayId(0, 2);
28 28
29 // Makes the window visible and creates the default surface for it. 29 // Makes the window visible and creates the default surface for it.
30 void InitWindow(ServerWindow* window) { 30 void InitWindow(ServerWindow* window) {
31 window->SetVisible(true); 31 window->SetVisible(true);
32 ServerWindowCompositorFrameSinkManager* compositor_frame_sink_manager = 32 ServerWindowCompositorFrameSinkManager* compositor_frame_sink_manager =
33 window->GetOrCreateCompositorFrameSinkManager(); 33 window->GetOrCreateCompositorFrameSinkManager();
34 compositor_frame_sink_manager->CreateCompositorFrameSink( 34 compositor_frame_sink_manager->SetLatestSurfaceInfo(
35 mojom::CompositorFrameSinkType::DEFAULT, 35 mojom::CompositorFrameSinkType::DEFAULT,
36 mojo::InterfaceRequest<cc::mojom::MojoCompositorFrameSink>(), 36 cc::SurfaceId(
37 cc::mojom::MojoCompositorFrameSinkClientPtr()); 37 cc::FrameSinkId(
38 WindowIdToTransportId(window->id()),
39 static_cast<uint32_t>(mojom::CompositorFrameSinkType::DEFAULT)),
40 cc::LocalFrameId(1u, 1u)),
41 gfx::Size(100, 100));
38 } 42 }
39 43
40 } // namespace 44 } // namespace
41 45
42 class FrameGeneratorTest : public testing::Test { 46 class FrameGeneratorTest : public testing::Test {
43 public: 47 public:
44 FrameGeneratorTest() 48 FrameGeneratorTest()
45 : display_compositor_(new DisplayCompositor(nullptr)), 49 : display_compositor_(new DisplayCompositor(nullptr)),
46 root_window_(base::MakeUnique<ServerWindow>(&window_delegate_, 50 root_window_(base::MakeUnique<ServerWindow>(&window_delegate_,
47 kRootDisplayId)) {} 51 kRootDisplayId)) {}
(...skipping 19 matching lines...) Expand all
67 TestServerWindowDelegate window_delegate_; 71 TestServerWindowDelegate window_delegate_;
68 std::unique_ptr<ServerWindow> root_window_; 72 std::unique_ptr<ServerWindow> root_window_;
69 73
70 // Needed so that Mojo classes can be initialized for ServerWindow use. 74 // Needed so that Mojo classes can be initialized for ServerWindow use.
71 base::TestMessageLoop message_loop_; 75 base::TestMessageLoop message_loop_;
72 76
73 DISALLOW_COPY_AND_ASSIGN(FrameGeneratorTest); 77 DISALLOW_COPY_AND_ASSIGN(FrameGeneratorTest);
74 }; 78 };
75 79
76 void FrameGeneratorTest::DrawWindowTree(cc::RenderPass* pass) { 80 void FrameGeneratorTest::DrawWindowTree(cc::RenderPass* pass) {
77 frame_generator_->DrawWindowTree(pass, 81 frame_generator_->DrawWindowTree(
78 frame_generator_delegate_->GetRootWindow(), 82 pass, frame_generator_delegate_->GetRootWindow(), gfx::Vector2d(), 1.0f);
79 gfx::Vector2d(), 1.0f, nullptr);
80 } 83 }
81 84
82 void FrameGeneratorTest::SetUp() { 85 void FrameGeneratorTest::SetUp() {
83 testing::Test::SetUp(); 86 testing::Test::SetUp();
84 frame_generator_delegate_ = base::MakeUnique<TestFrameGeneratorDelegate>( 87 frame_generator_delegate_ = base::MakeUnique<TestFrameGeneratorDelegate>(
85 base::MakeUnique<ServerWindow>(&window_delegate_, WindowId())); 88 base::MakeUnique<ServerWindow>(&window_delegate_, WindowId()));
86 PlatformDisplayInitParams init_params; 89 PlatformDisplayInitParams init_params;
87 frame_generator_ = base::MakeUnique<FrameGenerator>( 90 frame_generator_ = base::MakeUnique<FrameGenerator>(
88 frame_generator_delegate_.get(), root_window_.get(), display_compositor_); 91 frame_generator_delegate_.get(), root_window_.get(), display_compositor_);
89 InitWindow(root_window()); 92 InitWindow(root_window());
(...skipping 23 matching lines...) Expand all
113 // Both child and root have a DEFAULT Surface and no underlay Surfaces, so 116 // Both child and root have a DEFAULT Surface and no underlay Surfaces, so
114 // there should be two SharedQuadStates in the list. 117 // there should be two SharedQuadStates in the list.
115 EXPECT_EQ(2u, quad_state_list->size()); 118 EXPECT_EQ(2u, quad_state_list->size());
116 cc::SharedQuadState* root_sqs = quad_state_list->back(); 119 cc::SharedQuadState* root_sqs = quad_state_list->back();
117 cc::SharedQuadState* child_sqs = quad_state_list->front(); 120 cc::SharedQuadState* child_sqs = quad_state_list->front();
118 EXPECT_EQ(root_opacity, root_sqs->opacity); 121 EXPECT_EQ(root_opacity, root_sqs->opacity);
119 // Child's SharedQuadState contains the effective opacity of the child layer, 122 // Child's SharedQuadState contains the effective opacity of the child layer,
120 // which should be a product of the child and the parent opacity. 123 // which should be a product of the child and the parent opacity.
121 EXPECT_EQ(child_opacity * root_opacity, child_sqs->opacity); 124 EXPECT_EQ(child_opacity * root_opacity, child_sqs->opacity);
122 125
123 // Create the UNDERLAY Surface for the child window, and confirm that this 126 // Pretend to create the UNDERLAY Surface for the child window, and confirm
124 // creates an extra SharedQuadState in the CompositorFrame. 127 // that this creates an extra SharedQuadState in the CompositorFrame.
125 child_window.GetOrCreateCompositorFrameSinkManager() 128 child_window.GetOrCreateCompositorFrameSinkManager()->SetLatestSurfaceInfo(
126 ->CreateCompositorFrameSink( 129 mojom::CompositorFrameSinkType::UNDERLAY,
127 mojom::CompositorFrameSinkType::UNDERLAY, 130 cc::SurfaceId(
128 cc::mojom::MojoCompositorFrameSinkRequest(), 131 cc::FrameSinkId(
129 cc::mojom::MojoCompositorFrameSinkClientPtr()); 132 WindowIdToTransportId(child_window.id()),
133 static_cast<uint32_t>(mojom::CompositorFrameSinkType::UNDERLAY)),
134 cc::LocalFrameId(1u, 1u)),
135 gfx::Size(100, 100));
130 136
131 render_pass = cc::RenderPass::Create(); 137 render_pass = cc::RenderPass::Create();
132 DrawWindowTree(render_pass.get()); 138 DrawWindowTree(render_pass.get());
133 quad_state_list = &render_pass->shared_quad_state_list; 139 quad_state_list = &render_pass->shared_quad_state_list;
134 EXPECT_EQ(3u, quad_state_list->size()); 140 EXPECT_EQ(3u, quad_state_list->size());
135 auto it = quad_state_list->begin(); 141 auto it = quad_state_list->begin();
136 EXPECT_EQ(child_opacity * root_opacity, (*it)->opacity); 142 EXPECT_EQ(child_opacity * root_opacity, (*it)->opacity);
137 EXPECT_EQ(child_opacity * root_opacity, (*++it)->opacity); 143 EXPECT_EQ(child_opacity * root_opacity, (*++it)->opacity);
138 EXPECT_EQ(root_opacity, (*++it)->opacity); 144 EXPECT_EQ(root_opacity, (*++it)->opacity);
139 } 145 }
140 146
141 } // namespace test 147 } // namespace test
142 } // namespace ws 148 } // namespace ws
143 } // namespace ui 149 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/frame_generator.cc ('k') | services/ui/ws/server_window_compositor_frame_sink.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698