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" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "cc/surfaces/local_surface_id_allocator.h" | 14 #include "cc/surfaces/local_surface_id_allocator.h" |
15 #include "mojo/public/cpp/bindings/associated_binding.h" | 15 #include "mojo/public/cpp/bindings/associated_binding.h" |
16 #include "mojo/public/cpp/bindings/binding.h" | 16 #include "mojo/public/cpp/bindings/binding.h" |
17 #include "services/service_manager/public/cpp/binder_registry.h" | 17 #include "services/service_manager/public/cpp/binder_registry.h" |
18 #include "services/service_manager/public/cpp/interface_factory.h" | 18 #include "services/service_manager/public/cpp/interface_factory.h" |
19 #include "services/service_manager/public/cpp/service_test.h" | 19 #include "services/service_manager/public/cpp/service_test.h" |
20 #include "services/ui/public/interfaces/constants.mojom.h" | 20 #include "services/ui/public/interfaces/constants.mojom.h" |
21 #include "services/ui/public/interfaces/window_tree.mojom.h" | 21 #include "services/ui/public/interfaces/window_tree.mojom.h" |
22 #include "services/ui/public/interfaces/window_tree_host.mojom.h" | 22 #include "services/ui/public/interfaces/window_tree_host.mojom.h" |
23 #include "services/ui/ws/ids.h" | 23 #include "services/ui/ws/ids.h" |
24 #include "services/ui/ws/test_change_tracker.h" | 24 #include "services/ui/ws/test_change_tracker.h" |
25 #include "services/ui/ws/window_server_service_test_base.h" | 25 #include "services/ui/ws/window_server_service_test_base.h" |
| 26 #include "ui/base/cursor/cursor.h" |
26 | 27 |
27 using mojo::InterfaceRequest; | 28 using mojo::InterfaceRequest; |
28 using service_manager::Service; | 29 using service_manager::Service; |
29 using ui::mojom::WindowDataPtr; | 30 using ui::mojom::WindowDataPtr; |
30 using ui::mojom::WindowTree; | 31 using ui::mojom::WindowTree; |
31 using ui::mojom::WindowTreeClient; | 32 using ui::mojom::WindowTreeClient; |
32 | 33 |
33 namespace ui { | 34 namespace ui { |
34 namespace ws { | 35 namespace ws { |
35 namespace test { | 36 namespace test { |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 const std::string& name, | 230 const std::string& name, |
230 const std::vector<uint8_t>* data) { | 231 const std::vector<uint8_t>* data) { |
231 base::Optional<std::vector<uint8_t>> mojo_data; | 232 base::Optional<std::vector<uint8_t>> mojo_data; |
232 if (data) | 233 if (data) |
233 mojo_data.emplace(*data); | 234 mojo_data.emplace(*data); |
234 const uint32_t change_id = GetAndAdvanceChangeId(); | 235 const uint32_t change_id = GetAndAdvanceChangeId(); |
235 tree()->SetWindowProperty(change_id, window_id, name, mojo_data); | 236 tree()->SetWindowProperty(change_id, window_id, name, mojo_data); |
236 return WaitForChangeCompleted(change_id); | 237 return WaitForChangeCompleted(change_id); |
237 } | 238 } |
238 | 239 |
239 bool SetPredefinedCursor(Id window_id, mojom::CursorType cursor) { | 240 bool SetCursor(Id window_id, const ui::CursorData& cursor) { |
240 const uint32_t change_id = GetAndAdvanceChangeId(); | 241 const uint32_t change_id = GetAndAdvanceChangeId(); |
241 tree()->SetPredefinedCursor(change_id, window_id, cursor); | 242 tree()->SetCursor(change_id, window_id, cursor); |
242 return WaitForChangeCompleted(change_id); | 243 return WaitForChangeCompleted(change_id); |
243 } | 244 } |
244 | 245 |
245 bool SetWindowVisibility(Id window_id, bool visible) { | 246 bool SetWindowVisibility(Id window_id, bool visible) { |
246 const uint32_t change_id = GetAndAdvanceChangeId(); | 247 const uint32_t change_id = GetAndAdvanceChangeId(); |
247 tree()->SetWindowVisibility(change_id, window_id, visible); | 248 tree()->SetWindowVisibility(change_id, window_id, visible); |
248 return WaitForChangeCompleted(change_id); | 249 return WaitForChangeCompleted(change_id); |
249 } | 250 } |
250 | 251 |
251 bool SetWindowOpacity(Id window_id, float opacity) { | 252 bool SetWindowOpacity(Id window_id, float opacity) { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 uint32_t window_id, | 379 uint32_t window_id, |
379 int64_t display_id) override {} | 380 int64_t display_id) override {} |
380 void OnWindowSharedPropertyChanged( | 381 void OnWindowSharedPropertyChanged( |
381 uint32_t window, | 382 uint32_t window, |
382 const std::string& name, | 383 const std::string& name, |
383 const base::Optional<std::vector<uint8_t>>& new_data) override { | 384 const base::Optional<std::vector<uint8_t>>& new_data) override { |
384 tracker_.OnWindowSharedPropertyChanged(window, name, new_data); | 385 tracker_.OnWindowSharedPropertyChanged(window, name, new_data); |
385 } | 386 } |
386 // TODO(sky): add testing coverage. | 387 // TODO(sky): add testing coverage. |
387 void OnWindowFocused(uint32_t focused_window_id) override {} | 388 void OnWindowFocused(uint32_t focused_window_id) override {} |
388 void OnWindowPredefinedCursorChanged(uint32_t window_id, | 389 void OnWindowCursorChanged(uint32_t window_id, |
389 mojom::CursorType cursor_id) override { | 390 ui::CursorData cursor) override { |
390 tracker_.OnWindowPredefinedCursorChanged(window_id, cursor_id); | 391 tracker_.OnWindowCursorChanged(window_id, cursor); |
391 } | 392 } |
392 | 393 |
393 void OnDragDropStart( | 394 void OnDragDropStart( |
394 const std::unordered_map<std::string, std::vector<uint8_t>>& drag_data) | 395 const std::unordered_map<std::string, std::vector<uint8_t>>& drag_data) |
395 override { | 396 override { |
396 NOTIMPLEMENTED(); | 397 NOTIMPLEMENTED(); |
397 } | 398 } |
398 | 399 |
399 void OnWindowSurfaceChanged(Id window_id, | 400 void OnWindowSurfaceChanged(Id window_id, |
400 const cc::SurfaceInfo& surface_info) override { | 401 const cc::SurfaceInfo& surface_info) override { |
(...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1631 } | 1632 } |
1632 } | 1633 } |
1633 | 1634 |
1634 // Test that we hear the cursor change in other clients. | 1635 // Test that we hear the cursor change in other clients. |
1635 TEST_F(WindowTreeClientTest, SetCursor) { | 1636 TEST_F(WindowTreeClientTest, SetCursor) { |
1636 // Get a second client to listen in. | 1637 // Get a second client to listen in. |
1637 ASSERT_NO_FATAL_FAILURE(EstablishSecondClient(true)); | 1638 ASSERT_NO_FATAL_FAILURE(EstablishSecondClient(true)); |
1638 Id window_1_1 = BuildWindowId(client_id_1(), 1); | 1639 Id window_1_1 = BuildWindowId(client_id_1(), 1); |
1639 changes2()->clear(); | 1640 changes2()->clear(); |
1640 | 1641 |
1641 ASSERT_TRUE( | 1642 ASSERT_TRUE(wt_client1()->SetCursor(window_1_1, |
1642 wt_client1()->SetPredefinedCursor(window_1_1, mojom::CursorType::kIBeam)); | 1643 ui::CursorData(ui::CursorType::kIBeam))); |
1643 wt_client2_->WaitForChangeCount(1u); | 1644 wt_client2_->WaitForChangeCount(1u); |
1644 | 1645 |
1645 EXPECT_EQ("CursorChanged id=" + IdToString(window_1_1) + " cursor_id=4", | 1646 EXPECT_EQ("CursorChanged id=" + IdToString(window_1_1) + " cursor_type=4", |
1646 SingleChangeToDescription(*changes2())); | 1647 SingleChangeToDescription(*changes2())); |
1647 } | 1648 } |
1648 | 1649 |
1649 // Assertions for SetWindowVisibility sending notifications. | 1650 // Assertions for SetWindowVisibility sending notifications. |
1650 TEST_F(WindowTreeClientTest, SetWindowVisibilityNotifications) { | 1651 TEST_F(WindowTreeClientTest, SetWindowVisibilityNotifications) { |
1651 // Create 1,1 and 1,2. 1,2 is made a child of 1,1 and 1,1 a child of the root. | 1652 // Create 1,1 and 1,2. 1,2 is made a child of 1,1 and 1,1 a child of the root. |
1652 Id window_1_1 = wt_client1()->NewWindow(1); | 1653 Id window_1_1 = wt_client1()->NewWindow(1); |
1653 ASSERT_TRUE(window_1_1); | 1654 ASSERT_TRUE(window_1_1); |
1654 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_1, true)); | 1655 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_1, true)); |
1655 // Setting to the same value should return true. | 1656 // Setting to the same value should return true. |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2269 | 2270 |
2270 // TODO(sky): make sure coverage of what was | 2271 // TODO(sky): make sure coverage of what was |
2271 // WindowManagerTest.SecondEmbedRoot_InitService and | 2272 // WindowManagerTest.SecondEmbedRoot_InitService and |
2272 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window | 2273 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window |
2273 // manager | 2274 // manager |
2274 // tests. | 2275 // tests. |
2275 | 2276 |
2276 } // namespace test | 2277 } // namespace test |
2277 } // namespace ws | 2278 } // namespace ws |
2278 } // namespace ui | 2279 } // namespace ui |
OLD | NEW |