| 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 | 214 |
| 215 Id NewWindow(ClientSpecificId window_id) { | 215 Id NewWindow(ClientSpecificId window_id) { |
| 216 return NewWindowWithCompleteId(BuildWindowId(client_id_, window_id)); | 216 return NewWindowWithCompleteId(BuildWindowId(client_id_, window_id)); |
| 217 } | 217 } |
| 218 | 218 |
| 219 // Generally you want NewWindow(), but use this if you need to test given | 219 // Generally you want NewWindow(), but use this if you need to test given |
| 220 // a complete window id (NewWindow() ors with the client id). | 220 // a complete window id (NewWindow() ors with the client id). |
| 221 Id NewWindowWithCompleteId(Id id) { | 221 Id NewWindowWithCompleteId(Id id) { |
| 222 std::unordered_map<std::string, std::vector<uint8_t>> properties; | 222 std::unordered_map<std::string, std::vector<uint8_t>> properties; |
| 223 const uint32_t change_id = GetAndAdvanceChangeId(); | 223 const uint32_t change_id = GetAndAdvanceChangeId(); |
| 224 tree()->NewWindow(change_id, id, std::move(properties)); | 224 tree()->NewWindow(change_id, id, std::move(properties), cc::LocalFrameId()); |
| 225 return WaitForChangeCompleted(change_id) ? id : 0; | 225 return WaitForChangeCompleted(change_id) ? id : 0; |
| 226 } | 226 } |
| 227 | 227 |
| 228 bool SetWindowProperty(Id window_id, | 228 bool SetWindowProperty(Id window_id, |
| 229 const std::string& name, | 229 const std::string& name, |
| 230 const std::vector<uint8_t>* data) { | 230 const std::vector<uint8_t>* data) { |
| 231 base::Optional<std::vector<uint8_t>> mojo_data; | 231 base::Optional<std::vector<uint8_t>> mojo_data; |
| 232 if (data) | 232 if (data) |
| 233 mojo_data.emplace(*data); | 233 mojo_data.emplace(*data); |
| 234 const uint32_t change_id = GetAndAdvanceChangeId(); | 234 const uint32_t change_id = GetAndAdvanceChangeId(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 tracker()->OnCaptureChanged(new_capture_window_id, old_capture_window_id); | 297 tracker()->OnCaptureChanged(new_capture_window_id, old_capture_window_id); |
| 298 } | 298 } |
| 299 void OnTopLevelCreated(uint32_t change_id, | 299 void OnTopLevelCreated(uint32_t change_id, |
| 300 mojom::WindowDataPtr data, | 300 mojom::WindowDataPtr data, |
| 301 int64_t display_id, | 301 int64_t display_id, |
| 302 bool drawn) override { | 302 bool drawn) override { |
| 303 tracker()->OnTopLevelCreated(change_id, std::move(data), drawn); | 303 tracker()->OnTopLevelCreated(change_id, std::move(data), drawn); |
| 304 } | 304 } |
| 305 void OnWindowBoundsChanged(Id window_id, | 305 void OnWindowBoundsChanged(Id window_id, |
| 306 const gfx::Rect& old_bounds, | 306 const gfx::Rect& old_bounds, |
| 307 const gfx::Rect& new_bounds) override { | 307 const gfx::Rect& new_bounds, |
| 308 const cc::LocalFrameId& local_frame_id) override { |
| 308 // The bounds of the root may change during startup on Android at random | 309 // The bounds of the root may change during startup on Android at random |
| 309 // times. As this doesn't matter, and shouldn't impact test exepctations, | 310 // times. As this doesn't matter, and shouldn't impact test exepctations, |
| 310 // it is ignored. | 311 // it is ignored. |
| 311 if (window_id == root_window_id_ && !track_root_bounds_changes_) | 312 if (window_id == root_window_id_ && !track_root_bounds_changes_) |
| 312 return; | 313 return; |
| 313 tracker()->OnWindowBoundsChanged(window_id, old_bounds, new_bounds); | 314 tracker()->OnWindowBoundsChanged(window_id, old_bounds, new_bounds); |
| 314 } | 315 } |
| 315 void OnClientAreaChanged( | 316 void OnClientAreaChanged( |
| 316 uint32_t window_id, | 317 uint32_t window_id, |
| 317 const gfx::Insets& new_client_area, | 318 const gfx::Insets& new_client_area, |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 mojom::WindowDataPtr root_data, | 441 mojom::WindowDataPtr root_data, |
| 441 bool drawn) override { | 442 bool drawn) override { |
| 442 NOTIMPLEMENTED(); | 443 NOTIMPLEMENTED(); |
| 443 } | 444 } |
| 444 void WmDisplayRemoved(int64_t display_id) override { NOTIMPLEMENTED(); } | 445 void WmDisplayRemoved(int64_t display_id) override { NOTIMPLEMENTED(); } |
| 445 void WmDisplayModified(const display::Display& display) override { | 446 void WmDisplayModified(const display::Display& display) override { |
| 446 NOTIMPLEMENTED(); | 447 NOTIMPLEMENTED(); |
| 447 } | 448 } |
| 448 void WmSetBounds(uint32_t change_id, | 449 void WmSetBounds(uint32_t change_id, |
| 449 uint32_t window_id, | 450 uint32_t window_id, |
| 450 const gfx::Rect& bounds) override { | 451 const gfx::Rect& bounds, |
| 452 const cc::LocalFrameId& local_frame_id) override { |
| 451 window_manager_client_->WmResponse(change_id, false); | 453 window_manager_client_->WmResponse(change_id, false); |
| 452 } | 454 } |
| 453 void WmSetProperty( | 455 void WmSetProperty( |
| 454 uint32_t change_id, | 456 uint32_t change_id, |
| 455 uint32_t window_id, | 457 uint32_t window_id, |
| 456 const std::string& name, | 458 const std::string& name, |
| 457 const base::Optional<std::vector<uint8_t>>& value) override { | 459 const base::Optional<std::vector<uint8_t>>& value) override { |
| 458 window_manager_client_->WmResponse(change_id, false); | 460 window_manager_client_->WmResponse(change_id, false); |
| 459 } | 461 } |
| 460 void WmCreateTopLevelWindow( | 462 void WmCreateTopLevelWindow( |
| (...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1308 Id window_1_1 = wt_client1()->NewWindow(1); | 1310 Id window_1_1 = wt_client1()->NewWindow(1); |
| 1309 ASSERT_TRUE(window_1_1); | 1311 ASSERT_TRUE(window_1_1); |
| 1310 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1)); | 1312 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1)); |
| 1311 | 1313 |
| 1312 ASSERT_NO_FATAL_FAILURE(EstablishSecondClient(false)); | 1314 ASSERT_NO_FATAL_FAILURE(EstablishSecondClient(false)); |
| 1313 | 1315 |
| 1314 changes2()->clear(); | 1316 changes2()->clear(); |
| 1315 | 1317 |
| 1316 wt_client2_->set_track_root_bounds_changes(true); | 1318 wt_client2_->set_track_root_bounds_changes(true); |
| 1317 | 1319 |
| 1318 wt1()->SetWindowBounds(10, window_1_1, gfx::Rect(0, 0, 100, 100)); | 1320 wt1()->SetWindowBounds(10, window_1_1, gfx::Rect(0, 0, 100, 100), |
| 1321 cc::LocalFrameId()); |
| 1319 ASSERT_TRUE(wt_client1()->WaitForChangeCompleted(10)); | 1322 ASSERT_TRUE(wt_client1()->WaitForChangeCompleted(10)); |
| 1320 | 1323 |
| 1321 wt_client2_->WaitForChangeCount(1); | 1324 wt_client2_->WaitForChangeCount(1); |
| 1322 EXPECT_EQ("BoundsChanged window=" + IdToString(window_1_1) + | 1325 EXPECT_EQ("BoundsChanged window=" + IdToString(window_1_1) + |
| 1323 " old_bounds=0,0 0x0 new_bounds=0,0 100x100", | 1326 " old_bounds=0,0 0x0 new_bounds=0,0 100x100", |
| 1324 SingleChangeToDescription(*changes2())); | 1327 SingleChangeToDescription(*changes2())); |
| 1325 | 1328 |
| 1326 // Should not be possible to change the bounds of a window created by another | 1329 // Should not be possible to change the bounds of a window created by another |
| 1327 // client. | 1330 // client. |
| 1328 wt2()->SetWindowBounds(11, window_1_1, gfx::Rect(0, 0, 0, 0)); | 1331 wt2()->SetWindowBounds(11, window_1_1, gfx::Rect(0, 0, 0, 0), |
| 1332 cc::LocalFrameId()); |
| 1329 ASSERT_FALSE(wt_client2()->WaitForChangeCompleted(11)); | 1333 ASSERT_FALSE(wt_client2()->WaitForChangeCompleted(11)); |
| 1330 } | 1334 } |
| 1331 | 1335 |
| 1332 // Verify AddWindow fails when trying to manipulate windows in other roots. | 1336 // Verify AddWindow fails when trying to manipulate windows in other roots. |
| 1333 TEST_F(WindowTreeClientTest, CantMoveWindowsFromOtherRoot) { | 1337 TEST_F(WindowTreeClientTest, CantMoveWindowsFromOtherRoot) { |
| 1334 // Create 1 and 2 in the first client. | 1338 // Create 1 and 2 in the first client. |
| 1335 Id window_1_1 = wt_client1()->NewWindow(1); | 1339 Id window_1_1 = wt_client1()->NewWindow(1); |
| 1336 Id window_1_2 = wt_client1()->NewWindow(2); | 1340 Id window_1_2 = wt_client1()->NewWindow(2); |
| 1337 ASSERT_TRUE(window_1_1); | 1341 ASSERT_TRUE(window_1_1); |
| 1338 ASSERT_TRUE(window_1_2); | 1342 ASSERT_TRUE(window_1_2); |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2055 const Id window_2_101 = wt_client2()->NewWindow(101); | 2059 const Id window_2_101 = wt_client2()->NewWindow(101); |
| 2056 ASSERT_TRUE(wt_client2()->AddWindow(window_1_100_in_ws2, window_2_101)); | 2060 ASSERT_TRUE(wt_client2()->AddWindow(window_1_100_in_ws2, window_2_101)); |
| 2057 const Id window_2_101_in_ws1 = BuildWindowId(client_id_2(), 1); | 2061 const Id window_2_101_in_ws1 = BuildWindowId(client_id_2(), 1); |
| 2058 wt_client1()->WaitForChangeCount(1); | 2062 wt_client1()->WaitForChangeCount(1); |
| 2059 EXPECT_EQ("HierarchyChanged window=" + IdToString(window_2_101_in_ws1) + | 2063 EXPECT_EQ("HierarchyChanged window=" + IdToString(window_2_101_in_ws1) + |
| 2060 " old_parent=null new_parent=" + IdToString(window_1_100), | 2064 " old_parent=null new_parent=" + IdToString(window_1_100), |
| 2061 SingleChangeToDescription(*changes1())); | 2065 SingleChangeToDescription(*changes1())); |
| 2062 changes1()->clear(); | 2066 changes1()->clear(); |
| 2063 | 2067 |
| 2064 // Change the bounds of window_2_101 and make sure server gets it. | 2068 // Change the bounds of window_2_101 and make sure server gets it. |
| 2065 wt2()->SetWindowBounds(11, window_2_101, gfx::Rect(1, 2, 3, 4)); | 2069 wt2()->SetWindowBounds(11, window_2_101, gfx::Rect(1, 2, 3, 4), |
| 2070 cc::LocalFrameId()); |
| 2066 ASSERT_TRUE(wt_client2()->WaitForChangeCompleted(11)); | 2071 ASSERT_TRUE(wt_client2()->WaitForChangeCompleted(11)); |
| 2067 wt_client1()->WaitForChangeCount(1); | 2072 wt_client1()->WaitForChangeCount(1); |
| 2068 EXPECT_EQ("BoundsChanged window=" + IdToString(window_2_101_in_ws1) + | 2073 EXPECT_EQ("BoundsChanged window=" + IdToString(window_2_101_in_ws1) + |
| 2069 " old_bounds=0,0 0x0 new_bounds=1,2 3x4", | 2074 " old_bounds=0,0 0x0 new_bounds=1,2 3x4", |
| 2070 SingleChangeToDescription(*changes1())); | 2075 SingleChangeToDescription(*changes1())); |
| 2071 changes2()->clear(); | 2076 changes2()->clear(); |
| 2072 | 2077 |
| 2073 // Remove 2_101 from wm, client1 should see the change. | 2078 // Remove 2_101 from wm, client1 should see the change. |
| 2074 wt1()->RemoveWindowFromParent(12, window_2_101_in_ws1); | 2079 wt1()->RemoveWindowFromParent(12, window_2_101_in_ws1); |
| 2075 ASSERT_TRUE(wt_client1()->WaitForChangeCompleted(12)); | 2080 ASSERT_TRUE(wt_client1()->WaitForChangeCompleted(12)); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2218 | 2223 |
| 2219 // TODO(sky): make sure coverage of what was | 2224 // TODO(sky): make sure coverage of what was |
| 2220 // WindowManagerTest.SecondEmbedRoot_InitService and | 2225 // WindowManagerTest.SecondEmbedRoot_InitService and |
| 2221 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window | 2226 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window |
| 2222 // manager | 2227 // manager |
| 2223 // tests. | 2228 // tests. |
| 2224 | 2229 |
| 2225 } // namespace test | 2230 } // namespace test |
| 2226 } // namespace ws | 2231 } // namespace ws |
| 2227 } // namespace ui | 2232 } // namespace ui |
| OLD | NEW |