| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "components/mus/public/interfaces/window_tree.mojom.h" | 9 #include "components/mus/public/interfaces/window_tree.mojom.h" |
| 10 #include "components/mus/public/interfaces/window_tree_host.mojom.h" | 10 #include "components/mus/public/interfaces/window_tree_host.mojom.h" |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 const std::string& name, | 250 const std::string& name, |
| 251 const std::vector<uint8_t>* data) { | 251 const std::vector<uint8_t>* data) { |
| 252 Array<uint8_t> mojo_data; | 252 Array<uint8_t> mojo_data; |
| 253 if (data) | 253 if (data) |
| 254 mojo_data = Array<uint8_t>::From(*data); | 254 mojo_data = Array<uint8_t>::From(*data); |
| 255 const uint32_t change_id = GetAndAdvanceChangeId(); | 255 const uint32_t change_id = GetAndAdvanceChangeId(); |
| 256 tree()->SetWindowProperty(change_id, window_id, name, mojo_data.Pass()); | 256 tree()->SetWindowProperty(change_id, window_id, name, mojo_data.Pass()); |
| 257 return WaitForChangeCompleted(change_id); | 257 return WaitForChangeCompleted(change_id); |
| 258 } | 258 } |
| 259 | 259 |
| 260 bool SetPredefinedCursor(Id window_id, mojom::Cursor cursor) { |
| 261 const uint32_t change_id = GetAndAdvanceChangeId(); |
| 262 tree()->SetPredefinedCursor(change_id, window_id, cursor); |
| 263 return WaitForChangeCompleted(change_id); |
| 264 } |
| 265 |
| 260 private: | 266 private: |
| 261 // Used when running a nested MessageLoop. | 267 // Used when running a nested MessageLoop. |
| 262 struct WaitState { | 268 struct WaitState { |
| 263 WaitState() : change_count(0) {} | 269 WaitState() : change_count(0) {} |
| 264 | 270 |
| 265 // Number of changes waiting for. | 271 // Number of changes waiting for. |
| 266 size_t change_count; | 272 size_t change_count; |
| 267 base::RunLoop run_loop; | 273 base::RunLoop run_loop; |
| 268 }; | 274 }; |
| 269 | 275 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 // Don't log input events as none of the tests care about them and they | 352 // Don't log input events as none of the tests care about them and they |
| 347 // may come in at random points. | 353 // may come in at random points. |
| 348 } | 354 } |
| 349 void OnWindowSharedPropertyChanged(uint32_t window, | 355 void OnWindowSharedPropertyChanged(uint32_t window, |
| 350 const String& name, | 356 const String& name, |
| 351 Array<uint8_t> new_data) override { | 357 Array<uint8_t> new_data) override { |
| 352 tracker_.OnWindowSharedPropertyChanged(window, name, new_data.Pass()); | 358 tracker_.OnWindowSharedPropertyChanged(window, name, new_data.Pass()); |
| 353 } | 359 } |
| 354 // TODO(sky): add testing coverage. | 360 // TODO(sky): add testing coverage. |
| 355 void OnWindowFocused(uint32_t focused_window_id) override {} | 361 void OnWindowFocused(uint32_t focused_window_id) override {} |
| 362 void OnWindowSetPredefinedCursor(uint32 window_id, |
| 363 mojom::Cursor cursor_id) override { |
| 364 tracker_.OnWindowSetPredefinedCursor(window_id, cursor_id); |
| 365 } |
| 356 void OnChangeCompleted(uint32_t change_id, bool success) override { | 366 void OnChangeCompleted(uint32_t change_id, bool success) override { |
| 357 if (waiting_change_id_ == change_id && change_completed_run_loop_) { | 367 if (waiting_change_id_ == change_id && change_completed_run_loop_) { |
| 358 on_change_completed_result_ = success; | 368 on_change_completed_result_ = success; |
| 359 change_completed_run_loop_->Quit(); | 369 change_completed_run_loop_->Quit(); |
| 360 } | 370 } |
| 361 } | 371 } |
| 362 void WmSetBounds(uint32_t change_id, | 372 void WmSetBounds(uint32_t change_id, |
| 363 Id window_id, | 373 Id window_id, |
| 364 mojo::RectPtr bounds) override {} | 374 mojo::RectPtr bounds) override {} |
| 365 void WmSetProperty(uint32_t change_id, | 375 void WmSetProperty(uint32_t change_id, |
| (...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1408 ASSERT_EQ(2u, windows.size()); | 1418 ASSERT_EQ(2u, windows.size()); |
| 1409 EXPECT_EQ(WindowParentToString(window_1_1, root_window_id()) + | 1419 EXPECT_EQ(WindowParentToString(window_1_1, root_window_id()) + |
| 1410 " visible=true drawn=true", | 1420 " visible=true drawn=true", |
| 1411 windows[0].ToString2()); | 1421 windows[0].ToString2()); |
| 1412 EXPECT_EQ(WindowParentToString(window_1_2, window_1_1) + | 1422 EXPECT_EQ(WindowParentToString(window_1_2, window_1_1) + |
| 1413 " visible=true drawn=true", | 1423 " visible=true drawn=true", |
| 1414 windows[1].ToString2()); | 1424 windows[1].ToString2()); |
| 1415 } | 1425 } |
| 1416 } | 1426 } |
| 1417 | 1427 |
| 1428 // Test that we hear the cursor change in other connections. |
| 1429 TEST_F(WindowTreeAppTest, SetCursor) { |
| 1430 // Get a second connection to listen in. |
| 1431 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); |
| 1432 Id window_1_1 = BuildWindowId(connection_id_1(), 1); |
| 1433 changes2()->clear(); |
| 1434 |
| 1435 ASSERT_TRUE(ws_client1()->SetPredefinedCursor(window_1_1, |
| 1436 mojom::Cursor::CURSOR_IBEAM)); |
| 1437 ws_client2_->WaitForChangeCount(1u); |
| 1438 |
| 1439 EXPECT_EQ("CursorChanged id=" + IdToString(window_1_1) + " cursor_id=4", |
| 1440 SingleChangeToDescription(*changes2())); |
| 1441 } |
| 1442 |
| 1418 // Assertions for SetWindowVisibility sending notifications. | 1443 // Assertions for SetWindowVisibility sending notifications. |
| 1419 TEST_F(WindowTreeAppTest, SetWindowVisibilityNotifications) { | 1444 TEST_F(WindowTreeAppTest, SetWindowVisibilityNotifications) { |
| 1420 // Create 1,1 and 1,2. 1,2 is made a child of 1,1 and 1,1 a child of the root. | 1445 // Create 1,1 and 1,2. 1,2 is made a child of 1,1 and 1,1 a child of the root. |
| 1421 Id window_1_1 = ws_client1()->NewWindow(1); | 1446 Id window_1_1 = ws_client1()->NewWindow(1); |
| 1422 ASSERT_TRUE(window_1_1); | 1447 ASSERT_TRUE(window_1_1); |
| 1423 ASSERT_TRUE(SetWindowVisibility(ws1(), window_1_1, true)); | 1448 ASSERT_TRUE(SetWindowVisibility(ws1(), window_1_1, true)); |
| 1424 Id window_1_2 = ws_client1()->NewWindow(2); | 1449 Id window_1_2 = ws_client1()->NewWindow(2); |
| 1425 ASSERT_TRUE(window_1_2); | 1450 ASSERT_TRUE(window_1_2); |
| 1426 ASSERT_TRUE(SetWindowVisibility(ws1(), window_1_2, true)); | 1451 ASSERT_TRUE(SetWindowVisibility(ws1(), window_1_2, true)); |
| 1427 ASSERT_TRUE(AddWindow(ws1(), root_window_id(), window_1_1)); | 1452 ASSERT_TRUE(AddWindow(ws1(), root_window_id(), window_1_1)); |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1759 // originating connection. | 1784 // originating connection. |
| 1760 | 1785 |
| 1761 // TODO(sky): make sure coverage of what was | 1786 // TODO(sky): make sure coverage of what was |
| 1762 // WindowManagerTest.SecondEmbedRoot_InitService and | 1787 // WindowManagerTest.SecondEmbedRoot_InitService and |
| 1763 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window | 1788 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window |
| 1764 // manager | 1789 // manager |
| 1765 // tests. | 1790 // tests. |
| 1766 | 1791 |
| 1767 } // namespace ws | 1792 } // namespace ws |
| 1768 } // namespace mus | 1793 } // namespace mus |
| OLD | NEW |