OLD | NEW |
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 2164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2175 EXPECT_TRUE(changes1()->empty()); | 2175 EXPECT_TRUE(changes1()->empty()); |
2176 } | 2176 } |
2177 | 2177 |
2178 TEST_F(WindowTreeClientTest, SurfaceIdPropagation) { | 2178 TEST_F(WindowTreeClientTest, SurfaceIdPropagation) { |
2179 const Id window_1_100 = wt_client1()->NewWindow(100); | 2179 const Id window_1_100 = wt_client1()->NewWindow(100); |
2180 ASSERT_TRUE(window_1_100); | 2180 ASSERT_TRUE(window_1_100); |
2181 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_100)); | 2181 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_100)); |
2182 | 2182 |
2183 // Establish the second client at 1,100. | 2183 // Establish the second client at 1,100. |
2184 ASSERT_NO_FATAL_FAILURE(EstablishSecondClientWithRoot(window_1_100)); | 2184 ASSERT_NO_FATAL_FAILURE(EstablishSecondClientWithRoot(window_1_100)); |
| 2185 changes2()->clear(); |
2185 | 2186 |
2186 // 1,100 is the id in the wt_client1's id space. The new client should see | 2187 // 1,100 is the id in the wt_client1's id space. The new client should see |
2187 // 2,1 (the server id). | 2188 // 2,1 (the server id). |
2188 const Id window_1_100_in_ws2 = BuildWindowId(client_id_1(), 1); | 2189 const Id window_1_100_in_ws2 = BuildWindowId(client_id_1(), 1); |
2189 EXPECT_EQ(window_1_100_in_ws2, wt_client2()->root_window_id()); | 2190 EXPECT_EQ(window_1_100_in_ws2, wt_client2()->root_window_id()); |
2190 | 2191 |
| 2192 // Submit a CompositorFrame to window_1_100_in_ws2 (the embedded window in |
| 2193 // wt2) and make sure the server gets it. |
| 2194 { |
| 2195 cc::mojom::MojoCompositorFrameSinkPtr surface_ptr; |
| 2196 cc::mojom::MojoCompositorFrameSinkClientRequest client_request; |
| 2197 cc::mojom::MojoCompositorFrameSinkClientPtr surface_client_ptr; |
| 2198 client_request = mojo::MakeRequest(&surface_client_ptr); |
| 2199 wt2()->AttachCompositorFrameSink(window_1_100_in_ws2, |
| 2200 mojo::MakeRequest(&surface_ptr), |
| 2201 std::move(surface_client_ptr)); |
| 2202 cc::CompositorFrame compositor_frame; |
| 2203 std::unique_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create(); |
| 2204 gfx::Rect frame_rect(0, 0, 100, 100); |
| 2205 render_pass->SetNew(1, frame_rect, frame_rect, gfx::Transform()); |
| 2206 compositor_frame.render_pass_list.push_back(std::move(render_pass)); |
| 2207 compositor_frame.metadata.device_scale_factor = 1.f; |
| 2208 compositor_frame.metadata.begin_frame_ack = |
| 2209 cc::BeginFrameAck(0, 1, 1, true); |
| 2210 cc::LocalSurfaceId local_surface_id(1, base::UnguessableToken::Create()); |
| 2211 surface_ptr->SubmitCompositorFrame(local_surface_id, |
| 2212 std::move(compositor_frame)); |
| 2213 } |
| 2214 // Make sure the parent connection gets the surface ID. |
| 2215 wt_client1()->WaitForChangeCount(1); |
| 2216 // Verify that the submitted frame is for |window_2_101|. |
| 2217 EXPECT_EQ(window_1_100_in_ws2, |
| 2218 changes1()->back().surface_id.frame_sink_id().client_id()); |
| 2219 changes1()->clear(); |
| 2220 |
2191 // The first window created in the second client gets a server id of 2,1 | 2221 // The first window created in the second client gets a server id of 2,1 |
2192 // regardless of the id the client uses. | 2222 // regardless of the id the client uses. |
2193 const Id window_2_101 = wt_client2()->NewWindow(101); | 2223 const Id window_2_101 = wt_client2()->NewWindow(101); |
2194 ASSERT_TRUE(wt_client2()->AddWindow(window_1_100_in_ws2, window_2_101)); | 2224 ASSERT_TRUE(wt_client2()->AddWindow(window_1_100_in_ws2, window_2_101)); |
2195 const Id window_2_101_in_ws1 = BuildWindowId(client_id_2(), 1); | 2225 const Id window_2_101_in_ws2 = BuildWindowId(client_id_2(), 1); |
2196 wt_client1()->WaitForChangeCount(1); | 2226 wt_client1()->WaitForChangeCount(1); |
2197 EXPECT_EQ("HierarchyChanged window=" + IdToString(window_2_101_in_ws1) + | 2227 EXPECT_EQ("HierarchyChanged window=" + IdToString(window_2_101_in_ws2) + |
2198 " old_parent=null new_parent=" + IdToString(window_1_100), | 2228 " old_parent=null new_parent=" + IdToString(window_1_100), |
2199 SingleChangeToDescription(*changes1())); | 2229 SingleChangeToDescription(*changes1())); |
2200 changes1()->clear(); | 2230 // Submit a CompositorFrame to window_2_101_in_ws2 (a regular window in |
2201 | 2231 // wt2) and make sure client gets it. |
2202 // Submit a CompositorFrame to window_2_101 and make sure server gets it. | 2232 { |
2203 cc::mojom::MojoCompositorFrameSinkPtr surface_ptr; | 2233 cc::mojom::MojoCompositorFrameSinkPtr surface_ptr; |
2204 cc::mojom::MojoCompositorFrameSinkClientRequest client_request; | 2234 cc::mojom::MojoCompositorFrameSinkClientRequest client_request; |
2205 cc::mojom::MojoCompositorFrameSinkClientPtr surface_client_ptr; | 2235 cc::mojom::MojoCompositorFrameSinkClientPtr surface_client_ptr; |
2206 client_request = mojo::MakeRequest(&surface_client_ptr); | 2236 client_request = mojo::MakeRequest(&surface_client_ptr); |
2207 wt2()->AttachCompositorFrameSink(window_2_101, | 2237 wt2()->AttachCompositorFrameSink(window_2_101, |
2208 mojo::MakeRequest(&surface_ptr), | 2238 mojo::MakeRequest(&surface_ptr), |
2209 std::move(surface_client_ptr)); | 2239 std::move(surface_client_ptr)); |
2210 cc::CompositorFrame compositor_frame; | 2240 cc::CompositorFrame compositor_frame; |
2211 std::unique_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create(); | 2241 std::unique_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create(); |
2212 gfx::Rect frame_rect(0, 0, 100, 100); | 2242 gfx::Rect frame_rect(0, 0, 100, 100); |
2213 render_pass->SetNew(1, frame_rect, frame_rect, gfx::Transform()); | 2243 render_pass->SetNew(1, frame_rect, frame_rect, gfx::Transform()); |
2214 compositor_frame.render_pass_list.push_back(std::move(render_pass)); | 2244 compositor_frame.render_pass_list.push_back(std::move(render_pass)); |
2215 compositor_frame.metadata.device_scale_factor = 1.f; | 2245 compositor_frame.metadata.device_scale_factor = 1.f; |
2216 compositor_frame.metadata.begin_frame_ack = cc::BeginFrameAck(0, 1, 1, true); | 2246 compositor_frame.metadata.begin_frame_ack = |
2217 cc::LocalSurfaceId local_surface_id(1, base::UnguessableToken::Create()); | 2247 cc::BeginFrameAck(0, 1, 1, true); |
2218 surface_ptr->SubmitCompositorFrame(local_surface_id, | 2248 cc::LocalSurfaceId local_surface_id(2, base::UnguessableToken::Create()); |
2219 std::move(compositor_frame)); | 2249 surface_ptr->SubmitCompositorFrame(local_surface_id, |
| 2250 std::move(compositor_frame)); |
| 2251 } |
2220 // Make sure the parent connection gets the surface ID. | 2252 // Make sure the parent connection gets the surface ID. |
2221 wt_client1()->WaitForChangeCount(1); | 2253 wt_client2()->WaitForChangeCount(1); |
2222 // Verify that the submitted frame is for |window_2_101|. | 2254 // Verify that the submitted frame is for |window_2_101|. |
2223 EXPECT_EQ(window_2_101_in_ws1, | 2255 EXPECT_EQ(window_2_101_in_ws2, |
2224 changes1()->back().surface_id.frame_sink_id().client_id()); | 2256 changes2()->back().surface_id.frame_sink_id().client_id()); |
2225 } | 2257 } |
2226 | 2258 |
2227 // Verifies when an unknown window with a known child is added to a hierarchy | 2259 // Verifies when an unknown window with a known child is added to a hierarchy |
2228 // the known child is identified in the WindowData. | 2260 // the known child is identified in the WindowData. |
2229 TEST_F(WindowTreeClientTest, AddUnknownWindowKnownParent) { | 2261 TEST_F(WindowTreeClientTest, AddUnknownWindowKnownParent) { |
2230 const Id window_1_100 = wt_client1()->NewWindow(100); | 2262 const Id window_1_100 = wt_client1()->NewWindow(100); |
2231 ASSERT_TRUE(window_1_100); | 2263 ASSERT_TRUE(window_1_100); |
2232 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_100)); | 2264 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_100)); |
2233 | 2265 |
2234 // Establish the second client at 1,100. | 2266 // Establish the second client at 1,100. |
(...skipping 28 matching lines...) Expand all Loading... |
2263 | 2295 |
2264 // TODO(sky): make sure coverage of what was | 2296 // TODO(sky): make sure coverage of what was |
2265 // WindowManagerTest.SecondEmbedRoot_InitService and | 2297 // WindowManagerTest.SecondEmbedRoot_InitService and |
2266 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window | 2298 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window |
2267 // manager | 2299 // manager |
2268 // tests. | 2300 // tests. |
2269 | 2301 |
2270 } // namespace test | 2302 } // namespace test |
2271 } // namespace ws | 2303 } // namespace ws |
2272 } // namespace ui | 2304 } // namespace ui |
OLD | NEW |