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/ws/ids.h" | 12 #include "services/ui/ws/ids.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_compositor_frame_sink_manager.h" | 15 #include "services/ui/ws/server_window_compositor_frame_sink_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 // Typical id for the display root ServerWindow. | 25 // Typical id for the display root ServerWindow. |
26 constexpr WindowId kRootDisplayId(0, 2); | 26 constexpr WindowId kRootDisplayId(0, 2); |
| 27 const base::UnguessableToken kArbitraryToken = base::UnguessableToken::Create(); |
27 | 28 |
28 // Makes the window visible and creates the default surface for it. | 29 // Makes the window visible and creates the default surface for it. |
29 void InitWindow(ServerWindow* window) { | 30 void InitWindow(ServerWindow* window) { |
30 window->SetVisible(true); | 31 window->SetVisible(true); |
31 ServerWindowCompositorFrameSinkManager* compositor_frame_sink_manager = | 32 ServerWindowCompositorFrameSinkManager* compositor_frame_sink_manager = |
32 window->GetOrCreateCompositorFrameSinkManager(); | 33 window->GetOrCreateCompositorFrameSinkManager(); |
33 compositor_frame_sink_manager->SetLatestSurfaceInfo( | 34 compositor_frame_sink_manager->SetLatestSurfaceInfo( |
34 mojom::CompositorFrameSinkType::DEFAULT, | 35 mojom::CompositorFrameSinkType::DEFAULT, |
35 cc::SurfaceId( | 36 cc::SurfaceId( |
36 cc::FrameSinkId( | 37 cc::FrameSinkId( |
37 WindowIdToTransportId(window->id()), | 38 WindowIdToTransportId(window->id()), |
38 static_cast<uint32_t>(mojom::CompositorFrameSinkType::DEFAULT)), | 39 static_cast<uint32_t>(mojom::CompositorFrameSinkType::DEFAULT)), |
39 cc::LocalFrameId(1u, 1u)), | 40 cc::LocalFrameId(1u, kArbitraryToken)), |
40 gfx::Size(100, 100)); | 41 gfx::Size(100, 100)); |
41 } | 42 } |
42 | 43 |
43 } // namespace | 44 } // namespace |
44 | 45 |
45 class FrameGeneratorTest : public testing::Test { | 46 class FrameGeneratorTest : public testing::Test { |
46 public: | 47 public: |
47 FrameGeneratorTest() | 48 FrameGeneratorTest() |
48 : root_window_(base::MakeUnique<ServerWindow>(&window_delegate_, | 49 : root_window_(base::MakeUnique<ServerWindow>(&window_delegate_, |
49 kRootDisplayId)) {} | 50 kRootDisplayId)) {} |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 EXPECT_EQ(child_opacity * root_opacity, child_sqs->opacity); | 119 EXPECT_EQ(child_opacity * root_opacity, child_sqs->opacity); |
119 | 120 |
120 // Pretend to create the UNDERLAY Surface for the child window, and confirm | 121 // Pretend to create the UNDERLAY Surface for the child window, and confirm |
121 // that this creates an extra SharedQuadState in the CompositorFrame. | 122 // that this creates an extra SharedQuadState in the CompositorFrame. |
122 child_window.GetOrCreateCompositorFrameSinkManager()->SetLatestSurfaceInfo( | 123 child_window.GetOrCreateCompositorFrameSinkManager()->SetLatestSurfaceInfo( |
123 mojom::CompositorFrameSinkType::UNDERLAY, | 124 mojom::CompositorFrameSinkType::UNDERLAY, |
124 cc::SurfaceId( | 125 cc::SurfaceId( |
125 cc::FrameSinkId( | 126 cc::FrameSinkId( |
126 WindowIdToTransportId(child_window.id()), | 127 WindowIdToTransportId(child_window.id()), |
127 static_cast<uint32_t>(mojom::CompositorFrameSinkType::UNDERLAY)), | 128 static_cast<uint32_t>(mojom::CompositorFrameSinkType::UNDERLAY)), |
128 cc::LocalFrameId(1u, 1u)), | 129 cc::LocalFrameId(1u, kArbitraryToken)), |
129 gfx::Size(100, 100)); | 130 gfx::Size(100, 100)); |
130 | 131 |
131 render_pass = cc::RenderPass::Create(); | 132 render_pass = cc::RenderPass::Create(); |
132 DrawWindowTree(render_pass.get()); | 133 DrawWindowTree(render_pass.get()); |
133 quad_state_list = &render_pass->shared_quad_state_list; | 134 quad_state_list = &render_pass->shared_quad_state_list; |
134 EXPECT_EQ(3u, quad_state_list->size()); | 135 EXPECT_EQ(3u, quad_state_list->size()); |
135 auto it = quad_state_list->begin(); | 136 auto it = quad_state_list->begin(); |
136 EXPECT_EQ(child_opacity * root_opacity, (*it)->opacity); | 137 EXPECT_EQ(child_opacity * root_opacity, (*it)->opacity); |
137 EXPECT_EQ(child_opacity * root_opacity, (*++it)->opacity); | 138 EXPECT_EQ(child_opacity * root_opacity, (*++it)->opacity); |
138 EXPECT_EQ(root_opacity, (*++it)->opacity); | 139 EXPECT_EQ(root_opacity, (*++it)->opacity); |
139 } | 140 } |
140 | 141 |
141 } // namespace test | 142 } // namespace test |
142 } // namespace ws | 143 } // namespace ws |
143 } // namespace ui | 144 } // namespace ui |
OLD | NEW |