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

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

Issue 2494833002: Revert of Replaced cc::SurfaceId::nonce_ with base::UnguessableToken (Closed)
Patch Set: 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
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"
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();
28 27
29 // Makes the window visible and creates the default surface for it. 28 // Makes the window visible and creates the default surface for it.
30 void InitWindow(ServerWindow* window) { 29 void InitWindow(ServerWindow* window) {
31 window->SetVisible(true); 30 window->SetVisible(true);
32 ServerWindowCompositorFrameSinkManager* compositor_frame_sink_manager = 31 ServerWindowCompositorFrameSinkManager* compositor_frame_sink_manager =
33 window->GetOrCreateCompositorFrameSinkManager(); 32 window->GetOrCreateCompositorFrameSinkManager();
34 compositor_frame_sink_manager->SetLatestSurfaceInfo( 33 compositor_frame_sink_manager->SetLatestSurfaceInfo(
35 mojom::CompositorFrameSinkType::DEFAULT, 34 mojom::CompositorFrameSinkType::DEFAULT,
36 cc::SurfaceId( 35 cc::SurfaceId(
37 cc::FrameSinkId( 36 cc::FrameSinkId(
38 WindowIdToTransportId(window->id()), 37 WindowIdToTransportId(window->id()),
39 static_cast<uint32_t>(mojom::CompositorFrameSinkType::DEFAULT)), 38 static_cast<uint32_t>(mojom::CompositorFrameSinkType::DEFAULT)),
40 cc::LocalFrameId(1u, kArbitraryToken)), 39 cc::LocalFrameId(1u, 1u)),
41 gfx::Size(100, 100)); 40 gfx::Size(100, 100));
42 } 41 }
43 42
44 } // namespace 43 } // namespace
45 44
46 class FrameGeneratorTest : public testing::Test { 45 class FrameGeneratorTest : public testing::Test {
47 public: 46 public:
48 FrameGeneratorTest() 47 FrameGeneratorTest()
49 : root_window_(base::MakeUnique<ServerWindow>(&window_delegate_, 48 : root_window_(base::MakeUnique<ServerWindow>(&window_delegate_,
50 kRootDisplayId)) {} 49 kRootDisplayId)) {}
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 EXPECT_EQ(child_opacity * root_opacity, child_sqs->opacity); 118 EXPECT_EQ(child_opacity * root_opacity, child_sqs->opacity);
120 119
121 // Pretend to create the UNDERLAY Surface for the child window, and confirm 120 // Pretend to create the UNDERLAY Surface for the child window, and confirm
122 // that this creates an extra SharedQuadState in the CompositorFrame. 121 // that this creates an extra SharedQuadState in the CompositorFrame.
123 child_window.GetOrCreateCompositorFrameSinkManager()->SetLatestSurfaceInfo( 122 child_window.GetOrCreateCompositorFrameSinkManager()->SetLatestSurfaceInfo(
124 mojom::CompositorFrameSinkType::UNDERLAY, 123 mojom::CompositorFrameSinkType::UNDERLAY,
125 cc::SurfaceId( 124 cc::SurfaceId(
126 cc::FrameSinkId( 125 cc::FrameSinkId(
127 WindowIdToTransportId(child_window.id()), 126 WindowIdToTransportId(child_window.id()),
128 static_cast<uint32_t>(mojom::CompositorFrameSinkType::UNDERLAY)), 127 static_cast<uint32_t>(mojom::CompositorFrameSinkType::UNDERLAY)),
129 cc::LocalFrameId(1u, kArbitraryToken)), 128 cc::LocalFrameId(1u, 1u)),
130 gfx::Size(100, 100)); 129 gfx::Size(100, 100));
131 130
132 render_pass = cc::RenderPass::Create(); 131 render_pass = cc::RenderPass::Create();
133 DrawWindowTree(render_pass.get()); 132 DrawWindowTree(render_pass.get());
134 quad_state_list = &render_pass->shared_quad_state_list; 133 quad_state_list = &render_pass->shared_quad_state_list;
135 EXPECT_EQ(3u, quad_state_list->size()); 134 EXPECT_EQ(3u, quad_state_list->size());
136 auto it = quad_state_list->begin(); 135 auto it = quad_state_list->begin();
137 EXPECT_EQ(child_opacity * root_opacity, (*it)->opacity); 136 EXPECT_EQ(child_opacity * root_opacity, (*it)->opacity);
138 EXPECT_EQ(child_opacity * root_opacity, (*++it)->opacity); 137 EXPECT_EQ(child_opacity * root_opacity, (*++it)->opacity);
139 EXPECT_EQ(root_opacity, (*++it)->opacity); 138 EXPECT_EQ(root_opacity, (*++it)->opacity);
140 } 139 }
141 140
142 } // namespace test 141 } // namespace test
143 } // namespace ws 142 } // namespace ws
144 } // namespace ui 143 } // namespace ui
OLDNEW
« no previous file with comments | « cc/surfaces/surface_unittest.cc ('k') | third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698