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

Side by Side Diff: components/mus/ws/window_tree_apptest.cc

Issue 1465803003: mus: Let clients set the cursor of their window. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Do it the other way + explicit checks that it is a mouse pointer. Created 5 years 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
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 "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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 const std::string& name, 241 const std::string& name,
242 const std::vector<uint8_t>* data) { 242 const std::vector<uint8_t>* data) {
243 Array<uint8_t> mojo_data; 243 Array<uint8_t> mojo_data;
244 if (data) 244 if (data)
245 mojo_data = Array<uint8_t>::From(*data); 245 mojo_data = Array<uint8_t>::From(*data);
246 const uint32_t change_id = GetAndAdvanceChangeId(); 246 const uint32_t change_id = GetAndAdvanceChangeId();
247 tree()->SetWindowProperty(change_id, window_id, name, mojo_data.Pass()); 247 tree()->SetWindowProperty(change_id, window_id, name, mojo_data.Pass());
248 return WaitForChangeCompleted(change_id); 248 return WaitForChangeCompleted(change_id);
249 } 249 }
250 250
251 bool SetPredefinedCursor(Id window_id, mojom::Cursor cursor) {
252 const uint32_t change_id = GetAndAdvanceChangeId();
253 tree()->SetPredefinedCursor(change_id, window_id, cursor);
254 return WaitForChangeCompleted(change_id);
255 }
256
251 bool SetWindowVisibility(Id window_id, bool visible) { 257 bool SetWindowVisibility(Id window_id, bool visible) {
252 const uint32_t change_id = GetAndAdvanceChangeId(); 258 const uint32_t change_id = GetAndAdvanceChangeId();
253 tree()->SetWindowVisibility(change_id, window_id, visible); 259 tree()->SetWindowVisibility(change_id, window_id, visible);
254 return WaitForChangeCompleted(change_id); 260 return WaitForChangeCompleted(change_id);
255 } 261 }
256 262
257 private: 263 private:
258 // Used when running a nested MessageLoop. 264 // Used when running a nested MessageLoop.
259 struct WaitState { 265 struct WaitState {
260 WaitState() : change_count(0) {} 266 WaitState() : change_count(0) {}
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 // Don't log input events as none of the tests care about them and they 349 // Don't log input events as none of the tests care about them and they
344 // may come in at random points. 350 // may come in at random points.
345 } 351 }
346 void OnWindowSharedPropertyChanged(uint32_t window, 352 void OnWindowSharedPropertyChanged(uint32_t window,
347 const String& name, 353 const String& name,
348 Array<uint8_t> new_data) override { 354 Array<uint8_t> new_data) override {
349 tracker_.OnWindowSharedPropertyChanged(window, name, new_data.Pass()); 355 tracker_.OnWindowSharedPropertyChanged(window, name, new_data.Pass());
350 } 356 }
351 // TODO(sky): add testing coverage. 357 // TODO(sky): add testing coverage.
352 void OnWindowFocused(uint32_t focused_window_id) override {} 358 void OnWindowFocused(uint32_t focused_window_id) override {}
359 void OnWindowPredefinedCursorChanged(uint32 window_id,
360 mojom::Cursor cursor_id) override {
361 tracker_.OnWindowPredefinedCursorChanged(window_id, cursor_id);
362 }
353 void OnChangeCompleted(uint32_t change_id, bool success) override { 363 void OnChangeCompleted(uint32_t change_id, bool success) override {
354 if (waiting_change_id_ == change_id && change_completed_run_loop_) { 364 if (waiting_change_id_ == change_id && change_completed_run_loop_) {
355 on_change_completed_result_ = success; 365 on_change_completed_result_ = success;
356 change_completed_run_loop_->Quit(); 366 change_completed_run_loop_->Quit();
357 } 367 }
358 } 368 }
359 void WmSetBounds(uint32_t change_id, 369 void WmSetBounds(uint32_t change_id,
360 Id window_id, 370 Id window_id,
361 mojo::RectPtr bounds) override {} 371 mojo::RectPtr bounds) override {}
362 void WmSetProperty(uint32_t change_id, 372 void WmSetProperty(uint32_t change_id,
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 ASSERT_EQ(2u, windows.size()); 1415 ASSERT_EQ(2u, windows.size());
1406 EXPECT_EQ(WindowParentToString(window_1_1, root_window_id()) + 1416 EXPECT_EQ(WindowParentToString(window_1_1, root_window_id()) +
1407 " visible=true drawn=true", 1417 " visible=true drawn=true",
1408 windows[0].ToString2()); 1418 windows[0].ToString2());
1409 EXPECT_EQ(WindowParentToString(window_1_2, window_1_1) + 1419 EXPECT_EQ(WindowParentToString(window_1_2, window_1_1) +
1410 " visible=true drawn=true", 1420 " visible=true drawn=true",
1411 windows[1].ToString2()); 1421 windows[1].ToString2());
1412 } 1422 }
1413 } 1423 }
1414 1424
1425 // Test that we hear the cursor change in other connections.
1426 TEST_F(WindowTreeAppTest, SetCursor) {
1427 // Get a second connection to listen in.
1428 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
1429 Id window_1_1 = BuildWindowId(connection_id_1(), 1);
1430 changes2()->clear();
1431
1432 ASSERT_TRUE(ws_client1()->SetPredefinedCursor(window_1_1,
1433 mojom::Cursor::CURSOR_IBEAM));
1434 ws_client2_->WaitForChangeCount(1u);
1435
1436 EXPECT_EQ("CursorChanged id=" + IdToString(window_1_1) + " cursor_id=4",
1437 SingleChangeToDescription(*changes2()));
1438 }
1439
1415 // Assertions for SetWindowVisibility sending notifications. 1440 // Assertions for SetWindowVisibility sending notifications.
1416 TEST_F(WindowTreeAppTest, SetWindowVisibilityNotifications) { 1441 TEST_F(WindowTreeAppTest, SetWindowVisibilityNotifications) {
1417 // Create 1,1 and 1,2. 1,2 is made a child of 1,1 and 1,1 a child of the root. 1442 // Create 1,1 and 1,2. 1,2 is made a child of 1,1 and 1,1 a child of the root.
1418 Id window_1_1 = ws_client1()->NewWindow(1); 1443 Id window_1_1 = ws_client1()->NewWindow(1);
1419 ASSERT_TRUE(window_1_1); 1444 ASSERT_TRUE(window_1_1);
1420 ASSERT_TRUE(ws_client1()->SetWindowVisibility(window_1_1, true)); 1445 ASSERT_TRUE(ws_client1()->SetWindowVisibility(window_1_1, true));
1421 Id window_1_2 = ws_client1()->NewWindow(2); 1446 Id window_1_2 = ws_client1()->NewWindow(2);
1422 ASSERT_TRUE(window_1_2); 1447 ASSERT_TRUE(window_1_2);
1423 ASSERT_TRUE(ws_client1()->SetWindowVisibility(window_1_2, true)); 1448 ASSERT_TRUE(ws_client1()->SetWindowVisibility(window_1_2, true));
1424 ASSERT_TRUE(AddWindow(ws1(), root_window_id(), window_1_1)); 1449 ASSERT_TRUE(AddWindow(ws1(), root_window_id(), window_1_1));
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
1756 // originating connection. 1781 // originating connection.
1757 1782
1758 // TODO(sky): make sure coverage of what was 1783 // TODO(sky): make sure coverage of what was
1759 // WindowManagerTest.SecondEmbedRoot_InitService and 1784 // WindowManagerTest.SecondEmbedRoot_InitService and
1760 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window 1785 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window
1761 // manager 1786 // manager
1762 // tests. 1787 // tests.
1763 1788
1764 } // namespace ws 1789 } // namespace ws
1765 } // namespace mus 1790 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/window_manager_access_policy.cc ('k') | components/mus/ws/window_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698