| 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/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 void OnWindowPredefinedCursorChanged(uint32_t window_id, | 370 void OnWindowPredefinedCursorChanged(uint32_t window_id, |
| 371 mojom::Cursor cursor_id) override { | 371 mojom::Cursor cursor_id) override { |
| 372 tracker_.OnWindowPredefinedCursorChanged(window_id, cursor_id); | 372 tracker_.OnWindowPredefinedCursorChanged(window_id, cursor_id); |
| 373 } | 373 } |
| 374 | 374 |
| 375 void OnDragDropStart( | 375 void OnDragDropStart( |
| 376 mojo::Map<mojo::String, mojo::Array<uint8_t>> drag_data) override { | 376 mojo::Map<mojo::String, mojo::Array<uint8_t>> drag_data) override { |
| 377 NOTIMPLEMENTED(); | 377 NOTIMPLEMENTED(); |
| 378 } | 378 } |
| 379 | 379 |
| 380 void OnWindowSurfaceChanged(Id window_id, | |
| 381 const cc::SurfaceId& surface_id, | |
| 382 const cc::SurfaceSequence& surface_sequence, | |
| 383 const gfx::Size& frame_size, | |
| 384 float device_scale_factor) override { | |
| 385 tracker_.OnWindowSurfaceChanged(window_id, surface_id, surface_sequence, | |
| 386 frame_size, device_scale_factor); | |
| 387 } | |
| 388 | |
| 389 void OnDragEnter(uint32_t window, | 380 void OnDragEnter(uint32_t window, |
| 390 uint32_t key_state, | 381 uint32_t key_state, |
| 391 const gfx::Point& position, | 382 const gfx::Point& position, |
| 392 uint32_t effect_bitmask, | 383 uint32_t effect_bitmask, |
| 393 const OnDragEnterCallback& callback) override { | 384 const OnDragEnterCallback& callback) override { |
| 394 NOTIMPLEMENTED(); | 385 NOTIMPLEMENTED(); |
| 395 } | 386 } |
| 396 void OnDragOver(uint32_t window, | 387 void OnDragOver(uint32_t window, |
| 397 uint32_t key_state, | 388 uint32_t key_state, |
| 398 const gfx::Point& position, | 389 const gfx::Point& position, |
| (...skipping 1715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2114 SingleChangeToDescription(*changes1())); | 2105 SingleChangeToDescription(*changes1())); |
| 2115 | 2106 |
| 2116 changes1()->clear(); | 2107 changes1()->clear(); |
| 2117 // Explicitly releasing capture should not notify of lost capture. | 2108 // Explicitly releasing capture should not notify of lost capture. |
| 2118 wt1()->ReleaseCapture(3, window_1_2); | 2109 wt1()->ReleaseCapture(3, window_1_2); |
| 2119 wt_client1_->WaitForAllMessages(); | 2110 wt_client1_->WaitForAllMessages(); |
| 2120 | 2111 |
| 2121 EXPECT_TRUE(changes1()->empty()); | 2112 EXPECT_TRUE(changes1()->empty()); |
| 2122 } | 2113 } |
| 2123 | 2114 |
| 2124 TEST_F(WindowTreeClientTest, SurfaceIdPropagation) { | |
| 2125 const Id window_1_100 = wt_client1()->NewWindow(100); | |
| 2126 ASSERT_TRUE(window_1_100); | |
| 2127 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_100)); | |
| 2128 | |
| 2129 // Establish the second client at 1,100. | |
| 2130 ASSERT_NO_FATAL_FAILURE(EstablishSecondClientWithRoot(window_1_100)); | |
| 2131 | |
| 2132 // 1,100 is the id in the wt_client1's id space. The new client should see | |
| 2133 // 2,1 (the server id). | |
| 2134 const Id window_1_100_in_ws2 = BuildWindowId(client_id_1(), 1); | |
| 2135 EXPECT_EQ(window_1_100_in_ws2, wt_client2()->root_window_id()); | |
| 2136 | |
| 2137 // The first window created in the second client gets a server id of 2,1 | |
| 2138 // regardless of the id the client uses. | |
| 2139 const Id window_2_101 = wt_client2()->NewWindow(101); | |
| 2140 ASSERT_TRUE(wt_client2()->AddWindow(window_1_100_in_ws2, window_2_101)); | |
| 2141 const Id window_2_101_in_ws1 = BuildWindowId(client_id_2(), 1); | |
| 2142 wt_client1()->WaitForChangeCount(1); | |
| 2143 EXPECT_EQ("HierarchyChanged window=" + IdToString(window_2_101_in_ws1) + | |
| 2144 " old_parent=null new_parent=" + IdToString(window_1_100), | |
| 2145 SingleChangeToDescription(*changes1())); | |
| 2146 changes1()->clear(); | |
| 2147 | |
| 2148 // Submit a CompositorFrame to window_2_101 and make sure server gets it. | |
| 2149 mojom::SurfacePtr surface_ptr; | |
| 2150 mojom::SurfaceClientRequest client_request; | |
| 2151 mojom::SurfaceClientPtr surface_client_ptr; | |
| 2152 client_request = mojo::GetProxy(&surface_client_ptr); | |
| 2153 wt2()->AttachSurface(window_2_101, mojom::SurfaceType::DEFAULT, | |
| 2154 mojo::GetProxy(&surface_ptr), | |
| 2155 std::move(surface_client_ptr)); | |
| 2156 cc::CompositorFrame compositor_frame; | |
| 2157 compositor_frame.delegated_frame_data = | |
| 2158 base::MakeUnique<cc::DelegatedFrameData>(); | |
| 2159 std::unique_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create(); | |
| 2160 gfx::Rect frame_rect(0, 0, 100, 100); | |
| 2161 render_pass->SetNew(cc::RenderPassId(1, 1), frame_rect, frame_rect, | |
| 2162 gfx::Transform()); | |
| 2163 compositor_frame.delegated_frame_data->render_pass_list.push_back( | |
| 2164 std::move(render_pass)); | |
| 2165 surface_ptr->SubmitCompositorFrame(std::move(compositor_frame), | |
| 2166 base::Closure()); | |
| 2167 // Make sure the parent connection gets the surface ID. | |
| 2168 wt_client1()->WaitForChangeCount(1); | |
| 2169 // Verify that the submitted frame is for |window_2_101|. | |
| 2170 EXPECT_EQ(window_2_101_in_ws1, | |
| 2171 changes1()->back().surface_id.frame_sink_id().client_id()); | |
| 2172 } | |
| 2173 | |
| 2174 // TODO(sky): need to better track changes to initial client. For example, | 2115 // TODO(sky): need to better track changes to initial client. For example, |
| 2175 // that SetBounsdWindows/AddWindow and the like don't result in messages to the | 2116 // that SetBounsdWindows/AddWindow and the like don't result in messages to the |
| 2176 // originating client. | 2117 // originating client. |
| 2177 | 2118 |
| 2178 // TODO(sky): make sure coverage of what was | 2119 // TODO(sky): make sure coverage of what was |
| 2179 // WindowManagerTest.SecondEmbedRoot_InitService and | 2120 // WindowManagerTest.SecondEmbedRoot_InitService and |
| 2180 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window | 2121 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window |
| 2181 // manager | 2122 // manager |
| 2182 // tests. | 2123 // tests. |
| 2183 | 2124 |
| 2184 } // namespace test | 2125 } // namespace test |
| 2185 } // namespace ws | 2126 } // namespace ws |
| 2186 } // namespace ui | 2127 } // namespace ui |
| OLD | NEW |