OLD | NEW |
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" |
11 #include "cc/quads/shared_quad_state.h" | 11 #include "cc/quads/shared_quad_state.h" |
12 #include "services/ui/surfaces/display_compositor.h" | 12 #include "services/ui/surfaces/display_compositor.h" |
13 #include "services/ui/ws/platform_display_init_params.h" | 13 #include "services/ui/ws/platform_display_init_params.h" |
14 #include "services/ui/ws/server_window.h" | 14 #include "services/ui/ws/server_window.h" |
15 #include "services/ui/ws/server_window_surface_manager.h" | 15 #include "services/ui/ws/server_window_surface_manager.h" |
16 #include "services/ui/ws/test_server_window_delegate.h" | 16 #include "services/ui/ws/test_server_window_delegate.h" |
17 #include "services/ui/ws/test_utils.h" | 17 #include "services/ui/ws/test_utils.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 | 19 |
20 namespace ui { | 20 namespace ui { |
21 namespace ws { | 21 namespace ws { |
22 namespace test { | 22 namespace test { |
23 namespace { | 23 namespace { |
24 | 24 |
25 // Makes the window visible and creates the default surface for it. | 25 // Makes the window visible and creates the default surface for it. |
26 void InitWindow(ServerWindow* window) { | 26 void InitWindow(ServerWindow* window) { |
27 window->SetVisible(true); | 27 window->SetVisible(true); |
28 ServerWindowSurfaceManager* surface_manager = | 28 ServerWindowSurfaceManager* surface_manager = |
29 window->GetOrCreateSurfaceManager(); | 29 window->GetOrCreateSurfaceManager(); |
30 surface_manager->CreateSurface(mojom::SurfaceType::DEFAULT, | 30 surface_manager->CreateSurface( |
31 mojo::InterfaceRequest<mojom::Surface>(), | 31 mojom::SurfaceType::DEFAULT, |
32 mojom::SurfaceClientPtr()); | 32 mojo::InterfaceRequest<cc::mojom::MojoCompositorFrameSink>(), |
| 33 cc::mojom::MojoCompositorFrameSinkClientPtr()); |
33 } | 34 } |
34 | 35 |
35 } // namespace | 36 } // namespace |
36 | 37 |
37 class FrameGeneratorTest : public testing::Test { | 38 class FrameGeneratorTest : public testing::Test { |
38 public: | 39 public: |
39 FrameGeneratorTest() : display_compositor_(new DisplayCompositor(nullptr)) {} | 40 FrameGeneratorTest() : display_compositor_(new DisplayCompositor(nullptr)) {} |
40 ~FrameGeneratorTest() override {} | 41 ~FrameGeneratorTest() override {} |
41 | 42 |
42 // Calls DrawWindowTree() on |frame_generator_| | 43 // Calls DrawWindowTree() on |frame_generator_| |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 cc::SharedQuadState* root_sqs = quad_state_list->back(); | 108 cc::SharedQuadState* root_sqs = quad_state_list->back(); |
108 cc::SharedQuadState* child_sqs = quad_state_list->front(); | 109 cc::SharedQuadState* child_sqs = quad_state_list->front(); |
109 EXPECT_EQ(root_opacity, root_sqs->opacity); | 110 EXPECT_EQ(root_opacity, root_sqs->opacity); |
110 // Child's SharedQuadState contains the effective opacity of the child layer, | 111 // Child's SharedQuadState contains the effective opacity of the child layer, |
111 // which should be a product of the child and the parent opacity. | 112 // which should be a product of the child and the parent opacity. |
112 EXPECT_EQ(child_opacity * root_opacity, child_sqs->opacity); | 113 EXPECT_EQ(child_opacity * root_opacity, child_sqs->opacity); |
113 | 114 |
114 // Create the UNDERLAY Surface for the child window, and confirm that this | 115 // Create the UNDERLAY Surface for the child window, and confirm that this |
115 // creates an extra SharedQuadState in the CompositorFrame. | 116 // creates an extra SharedQuadState in the CompositorFrame. |
116 child_window.GetOrCreateSurfaceManager()->CreateSurface( | 117 child_window.GetOrCreateSurfaceManager()->CreateSurface( |
117 mojom::SurfaceType::UNDERLAY, mojo::InterfaceRequest<mojom::Surface>(), | 118 mojom::SurfaceType::UNDERLAY, |
118 mojom::SurfaceClientPtr()); | 119 mojo::InterfaceRequest<cc::mojom::MojoCompositorFrameSink>(), |
| 120 cc::mojom::MojoCompositorFrameSinkClientPtr()); |
119 | 121 |
120 render_pass = cc::RenderPass::Create(); | 122 render_pass = cc::RenderPass::Create(); |
121 DrawWindowTree(render_pass.get()); | 123 DrawWindowTree(render_pass.get()); |
122 quad_state_list = &render_pass->shared_quad_state_list; | 124 quad_state_list = &render_pass->shared_quad_state_list; |
123 EXPECT_EQ(3u, quad_state_list->size()); | 125 EXPECT_EQ(3u, quad_state_list->size()); |
124 auto it = quad_state_list->begin(); | 126 auto it = quad_state_list->begin(); |
125 EXPECT_EQ(child_opacity * root_opacity, (*it)->opacity); | 127 EXPECT_EQ(child_opacity * root_opacity, (*it)->opacity); |
126 EXPECT_EQ(child_opacity * root_opacity, (*++it)->opacity); | 128 EXPECT_EQ(child_opacity * root_opacity, (*++it)->opacity); |
127 EXPECT_EQ(root_opacity, (*++it)->opacity); | 129 EXPECT_EQ(root_opacity, (*++it)->opacity); |
128 } | 130 } |
129 | 131 |
130 } // namespace test | 132 } // namespace test |
131 } // namespace ws | 133 } // namespace ws |
132 } // namespace ui | 134 } // namespace ui |
OLD | NEW |