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

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

Issue 2875753002: Implement aura::WindowPortMus::CreateCompositorFrameSink() (Closed)
Patch Set: Fix build problem Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « services/ui/ws/window_tree.cc ('k') | ui/aura/local/window_port_local.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 2169 matching lines...) Expand 10 before | Expand all | Expand 10 after
2180 EXPECT_TRUE(changes1()->empty()); 2180 EXPECT_TRUE(changes1()->empty());
2181 } 2181 }
2182 2182
2183 TEST_F(WindowTreeClientTest, SurfaceIdPropagation) { 2183 TEST_F(WindowTreeClientTest, SurfaceIdPropagation) {
2184 const Id window_1_100 = wt_client1()->NewWindow(100); 2184 const Id window_1_100 = wt_client1()->NewWindow(100);
2185 ASSERT_TRUE(window_1_100); 2185 ASSERT_TRUE(window_1_100);
2186 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_100)); 2186 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_100));
2187 2187
2188 // Establish the second client at 1,100. 2188 // Establish the second client at 1,100.
2189 ASSERT_NO_FATAL_FAILURE(EstablishSecondClientWithRoot(window_1_100)); 2189 ASSERT_NO_FATAL_FAILURE(EstablishSecondClientWithRoot(window_1_100));
2190 changes2()->clear();
2190 2191
2191 // 1,100 is the id in the wt_client1's id space. The new client should see 2192 // 1,100 is the id in the wt_client1's id space. The new client should see
2192 // 2,1 (the server id). 2193 // 2,1 (the server id).
2193 const Id window_1_100_in_ws2 = BuildWindowId(client_id_1(), 1); 2194 const Id window_1_100_in_ws2 = BuildWindowId(client_id_1(), 1);
2194 EXPECT_EQ(window_1_100_in_ws2, wt_client2()->root_window_id()); 2195 EXPECT_EQ(window_1_100_in_ws2, wt_client2()->root_window_id());
2195 2196
2197 // Submit a CompositorFrame to window_1_100_in_ws2 (the embedded window in
2198 // wt2) and make sure the server gets it.
2199 {
2200 cc::mojom::MojoCompositorFrameSinkPtr surface_ptr;
2201 cc::mojom::MojoCompositorFrameSinkClientRequest client_request;
2202 cc::mojom::MojoCompositorFrameSinkClientPtr surface_client_ptr;
2203 client_request = mojo::MakeRequest(&surface_client_ptr);
2204 wt2()->AttachCompositorFrameSink(window_1_100_in_ws2,
2205 mojo::MakeRequest(&surface_ptr),
2206 std::move(surface_client_ptr));
2207 cc::CompositorFrame compositor_frame;
2208 std::unique_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create();
2209 gfx::Rect frame_rect(0, 0, 100, 100);
2210 render_pass->SetNew(1, frame_rect, frame_rect, gfx::Transform());
2211 compositor_frame.render_pass_list.push_back(std::move(render_pass));
2212 compositor_frame.metadata.device_scale_factor = 1.f;
2213 compositor_frame.metadata.begin_frame_ack =
2214 cc::BeginFrameAck(0, 1, 1, true);
2215 cc::LocalSurfaceId local_surface_id(1, base::UnguessableToken::Create());
2216 surface_ptr->SubmitCompositorFrame(local_surface_id,
2217 std::move(compositor_frame));
2218 }
2219 // Make sure the parent connection gets the surface ID.
2220 wt_client1()->WaitForChangeCount(1);
2221 // Verify that the submitted frame is for |window_2_101|.
2222 EXPECT_EQ(window_1_100_in_ws2,
2223 changes1()->back().surface_id.frame_sink_id().client_id());
2224 changes1()->clear();
2225
2196 // The first window created in the second client gets a server id of 2,1 2226 // The first window created in the second client gets a server id of 2,1
2197 // regardless of the id the client uses. 2227 // regardless of the id the client uses.
2198 const Id window_2_101 = wt_client2()->NewWindow(101); 2228 const Id window_2_101 = wt_client2()->NewWindow(101);
2199 ASSERT_TRUE(wt_client2()->AddWindow(window_1_100_in_ws2, window_2_101)); 2229 ASSERT_TRUE(wt_client2()->AddWindow(window_1_100_in_ws2, window_2_101));
2200 const Id window_2_101_in_ws1 = BuildWindowId(client_id_2(), 1); 2230 const Id window_2_101_in_ws2 = BuildWindowId(client_id_2(), 1);
2201 wt_client1()->WaitForChangeCount(1); 2231 wt_client1()->WaitForChangeCount(1);
2202 EXPECT_EQ("HierarchyChanged window=" + IdToString(window_2_101_in_ws1) + 2232 EXPECT_EQ("HierarchyChanged window=" + IdToString(window_2_101_in_ws2) +
2203 " old_parent=null new_parent=" + IdToString(window_1_100), 2233 " old_parent=null new_parent=" + IdToString(window_1_100),
2204 SingleChangeToDescription(*changes1())); 2234 SingleChangeToDescription(*changes1()));
2205 changes1()->clear(); 2235 // Submit a CompositorFrame to window_2_101_in_ws2 (a regular window in
2206 2236 // wt2) and make sure client gets it.
2207 // Submit a CompositorFrame to window_2_101 and make sure server gets it. 2237 {
2208 cc::mojom::MojoCompositorFrameSinkPtr surface_ptr; 2238 cc::mojom::MojoCompositorFrameSinkPtr surface_ptr;
2209 cc::mojom::MojoCompositorFrameSinkClientRequest client_request; 2239 cc::mojom::MojoCompositorFrameSinkClientRequest client_request;
2210 cc::mojom::MojoCompositorFrameSinkClientPtr surface_client_ptr; 2240 cc::mojom::MojoCompositorFrameSinkClientPtr surface_client_ptr;
2211 client_request = mojo::MakeRequest(&surface_client_ptr); 2241 client_request = mojo::MakeRequest(&surface_client_ptr);
2212 wt2()->AttachCompositorFrameSink(window_2_101, 2242 wt2()->AttachCompositorFrameSink(window_2_101,
2213 mojo::MakeRequest(&surface_ptr), 2243 mojo::MakeRequest(&surface_ptr),
2214 std::move(surface_client_ptr)); 2244 std::move(surface_client_ptr));
2215 cc::CompositorFrame compositor_frame; 2245 cc::CompositorFrame compositor_frame;
2216 std::unique_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create(); 2246 std::unique_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create();
2217 gfx::Rect frame_rect(0, 0, 100, 100); 2247 gfx::Rect frame_rect(0, 0, 100, 100);
2218 render_pass->SetNew(1, frame_rect, frame_rect, gfx::Transform()); 2248 render_pass->SetNew(1, frame_rect, frame_rect, gfx::Transform());
2219 compositor_frame.render_pass_list.push_back(std::move(render_pass)); 2249 compositor_frame.render_pass_list.push_back(std::move(render_pass));
2220 compositor_frame.metadata.device_scale_factor = 1.f; 2250 compositor_frame.metadata.device_scale_factor = 1.f;
2221 compositor_frame.metadata.begin_frame_ack = cc::BeginFrameAck(0, 1, 1, true); 2251 compositor_frame.metadata.begin_frame_ack =
2222 cc::LocalSurfaceId local_surface_id(1, base::UnguessableToken::Create()); 2252 cc::BeginFrameAck(0, 1, 1, true);
2223 surface_ptr->SubmitCompositorFrame(local_surface_id, 2253 cc::LocalSurfaceId local_surface_id(2, base::UnguessableToken::Create());
2224 std::move(compositor_frame)); 2254 surface_ptr->SubmitCompositorFrame(local_surface_id,
2255 std::move(compositor_frame));
2256 }
2225 // Make sure the parent connection gets the surface ID. 2257 // Make sure the parent connection gets the surface ID.
2226 wt_client1()->WaitForChangeCount(1); 2258 wt_client2()->WaitForChangeCount(1);
2227 // Verify that the submitted frame is for |window_2_101|. 2259 // Verify that the submitted frame is for |window_2_101|.
2228 EXPECT_EQ(window_2_101_in_ws1, 2260 EXPECT_EQ(window_2_101_in_ws2,
2229 changes1()->back().surface_id.frame_sink_id().client_id()); 2261 changes2()->back().surface_id.frame_sink_id().client_id());
2230 } 2262 }
2231 2263
2232 // Verifies when an unknown window with a known child is added to a hierarchy 2264 // Verifies when an unknown window with a known child is added to a hierarchy
2233 // the known child is identified in the WindowData. 2265 // the known child is identified in the WindowData.
2234 TEST_F(WindowTreeClientTest, AddUnknownWindowKnownParent) { 2266 TEST_F(WindowTreeClientTest, AddUnknownWindowKnownParent) {
2235 const Id window_1_100 = wt_client1()->NewWindow(100); 2267 const Id window_1_100 = wt_client1()->NewWindow(100);
2236 ASSERT_TRUE(window_1_100); 2268 ASSERT_TRUE(window_1_100);
2237 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_100)); 2269 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_100));
2238 2270
2239 // Establish the second client at 1,100. 2271 // Establish the second client at 1,100.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2296 2328
2297 // TODO(sky): make sure coverage of what was 2329 // TODO(sky): make sure coverage of what was
2298 // WindowManagerTest.SecondEmbedRoot_InitService and 2330 // WindowManagerTest.SecondEmbedRoot_InitService and
2299 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window 2331 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window
2300 // manager 2332 // manager
2301 // tests. 2333 // tests.
2302 2334
2303 } // namespace test 2335 } // namespace test
2304 } // namespace ws 2336 } // namespace ws
2305 } // namespace ui 2337 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/window_tree.cc ('k') | ui/aura/local/window_port_local.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698