OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "services/ui/ws/window_manager_state.h" | 5 #include "services/ui/ws/window_manager_state.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 TestWindowTreeClient* window_tree_client() { return window_tree_client_; } | 62 TestWindowTreeClient* window_tree_client() { return window_tree_client_; } |
63 ServerWindow* window() { return window_; } | 63 ServerWindow* window() { return window_; } |
64 TestWindowManager* window_manager() { return &window_manager_; } | 64 TestWindowManager* window_manager() { return &window_manager_; } |
65 TestWindowTreeClient* wm_client() { | 65 TestWindowTreeClient* wm_client() { |
66 return window_event_targeting_helper_.wm_client(); | 66 return window_event_targeting_helper_.wm_client(); |
67 } | 67 } |
68 WindowManagerState* window_manager_state() { return window_manager_state_; } | 68 WindowManagerState* window_manager_state() { return window_manager_state_; } |
69 WindowServer* window_server() { | 69 WindowServer* window_server() { |
70 return window_event_targeting_helper_.window_server(); | 70 return window_event_targeting_helper_.window_server(); |
71 } | 71 } |
| 72 ui::CursorType cursor_type() const { |
| 73 return window_event_targeting_helper_.cursor_type(); |
| 74 } |
72 | 75 |
73 void EmbedAt(WindowTree* tree, | 76 void EmbedAt(WindowTree* tree, |
74 const ClientWindowId& embed_window_id, | 77 const ClientWindowId& embed_window_id, |
75 uint32_t embed_flags, | 78 uint32_t embed_flags, |
76 WindowTree** embed_tree, | 79 WindowTree** embed_tree, |
77 TestWindowTreeClient** embed_client_proxy) { | 80 TestWindowTreeClient** embed_client_proxy) { |
78 mojom::WindowTreeClientPtr embed_client; | 81 mojom::WindowTreeClientPtr embed_client; |
79 mojom::WindowTreeClientRequest client_request(&embed_client); | 82 mojom::WindowTreeClientRequest client_request(&embed_client); |
80 ASSERT_TRUE( | 83 ASSERT_TRUE( |
81 tree->Embed(embed_window_id, std::move(embed_client), embed_flags)); | 84 tree->Embed(embed_window_id, std::move(embed_client), embed_flags)); |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 window_manager_display_root->window_manager_state()->window_tree(); | 637 window_manager_display_root->window_manager_state()->window_tree(); |
635 ASSERT_EQ(1u, tree->roots().size()); | 638 ASSERT_EQ(1u, tree->roots().size()); |
636 ClientWindowId root_client_id; | 639 ClientWindowId root_client_id; |
637 ASSERT_TRUE(tree->IsWindowKnown(*(tree->roots().begin()), &root_client_id)); | 640 ASSERT_TRUE(tree->IsWindowKnown(*(tree->roots().begin()), &root_client_id)); |
638 EXPECT_TRUE(tree->DeleteWindow(root_client_id)); | 641 EXPECT_TRUE(tree->DeleteWindow(root_client_id)); |
639 window_server->DestroyTree(tree); | 642 window_server->DestroyTree(tree); |
640 } | 643 } |
641 | 644 |
642 TEST_F(WindowManagerStateTest, CursorResetOverNoTarget) { | 645 TEST_F(WindowManagerStateTest, CursorResetOverNoTarget) { |
643 ASSERT_EQ(1u, window_server()->display_manager()->displays().size()); | 646 ASSERT_EQ(1u, window_server()->display_manager()->displays().size()); |
644 Display* display = *(window_server()->display_manager()->displays().begin()); | |
645 DisplayTestApi display_test_api(display); | |
646 const ClientWindowId child_window_id(11); | 647 const ClientWindowId child_window_id(11); |
647 window_tree()->NewWindow(child_window_id, ServerWindow::Properties()); | 648 window_tree()->NewWindow(child_window_id, ServerWindow::Properties()); |
648 ServerWindow* child_window = | 649 ServerWindow* child_window = |
649 window_tree()->GetWindowByClientId(child_window_id); | 650 window_tree()->GetWindowByClientId(child_window_id); |
650 window_tree()->AddWindow(FirstRootId(window_tree()), child_window_id); | 651 window_tree()->AddWindow(FirstRootId(window_tree()), child_window_id); |
651 child_window->SetVisible(true); | 652 child_window->SetVisible(true); |
652 child_window->SetBounds(gfx::Rect(0, 0, 20, 20)); | 653 child_window->SetBounds(gfx::Rect(0, 0, 20, 20)); |
653 child_window->parent()->SetCursor(ui::CursorData(ui::CursorType::kCopy)); | 654 child_window->parent()->SetCursor(ui::CursorData(ui::CursorType::kCopy)); |
654 EXPECT_EQ(ui::CursorType::kCopy, | 655 EXPECT_EQ(ui::CursorType::kCopy, cursor_type()); |
655 display_test_api.last_cursor().cursor_type()); | |
656 // Move the mouse outside the bounds of the child, so that the mouse is not | 656 // Move the mouse outside the bounds of the child, so that the mouse is not |
657 // over any valid windows. Cursor should change to POINTER. | 657 // over any valid windows. Cursor should change to POINTER. |
658 ui::PointerEvent move( | 658 ui::PointerEvent move( |
659 ui::ET_POINTER_MOVED, gfx::Point(25, 25), gfx::Point(25, 25), 0, 0, | 659 ui::ET_POINTER_MOVED, gfx::Point(25, 25), gfx::Point(25, 25), 0, 0, |
660 ui::PointerDetails(EventPointerType::POINTER_TYPE_MOUSE, 0), | 660 ui::PointerDetails(EventPointerType::POINTER_TYPE_MOUSE, 0), |
661 base::TimeTicks()); | 661 base::TimeTicks()); |
662 window_manager_state()->ProcessEvent(move, 0); | 662 window_manager_state()->ProcessEvent(move, 0); |
663 // The event isn't over a valid target, which should trigger resetting the | 663 // The event isn't over a valid target, which should trigger resetting the |
664 // cursor to POINTER. | 664 // cursor to POINTER. |
665 EXPECT_EQ(ui::CursorType::kPointer, | 665 EXPECT_EQ(ui::CursorType::kPointer, cursor_type()); |
666 display_test_api.last_cursor().cursor_type()); | |
667 } | 666 } |
668 | 667 |
669 } // namespace test | 668 } // namespace test |
670 } // namespace ws | 669 } // namespace ws |
671 } // namespace ui | 670 } // namespace ui |
OLD | NEW |