| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 } | 58 } |
| 59 // This is *not* the tree associated with the WindowManagerState, use tree() | 59 // This is *not* the tree associated with the WindowManagerState, use tree() |
| 60 // if you need the window manager tree. | 60 // if you need the window manager tree. |
| 61 WindowTree* window_tree() { return window_tree_; } | 61 WindowTree* window_tree() { return window_tree_; } |
| 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 TestWindowTreeClient* last_tree_client() { | |
| 69 return window_event_targeting_helper_.last_window_tree_client(); | |
| 70 } | |
| 71 WindowTree* last_tree() { | |
| 72 return window_event_targeting_helper_.last_binding()->tree(); | |
| 73 } | |
| 74 WindowManagerState* window_manager_state() { return window_manager_state_; } | 68 WindowManagerState* window_manager_state() { return window_manager_state_; } |
| 75 WindowServer* window_server() { | 69 WindowServer* window_server() { |
| 76 return window_event_targeting_helper_.window_server(); | 70 return window_event_targeting_helper_.window_server(); |
| 77 } | 71 } |
| 78 | 72 |
| 79 void EmbedAt(WindowTree* tree, | 73 void EmbedAt(WindowTree* tree, |
| 80 const ClientWindowId& embed_window_id, | 74 const ClientWindowId& embed_window_id, |
| 81 uint32_t embed_flags, | 75 uint32_t embed_flags, |
| 82 WindowTree** embed_tree, | 76 WindowTree** embed_tree, |
| 83 TestWindowTreeClient** embed_client_proxy) { | 77 TestWindowTreeClient** embed_client_proxy) { |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 WindowTree* tree = | 558 WindowTree* tree = |
| 565 window_manager_display_root->window_manager_state()->window_tree(); | 559 window_manager_display_root->window_manager_state()->window_tree(); |
| 566 ASSERT_EQ(1u, tree->roots().size()); | 560 ASSERT_EQ(1u, tree->roots().size()); |
| 567 ClientWindowId root_client_id; | 561 ClientWindowId root_client_id; |
| 568 ASSERT_TRUE(tree->IsWindowKnown(*(tree->roots().begin()), &root_client_id)); | 562 ASSERT_TRUE(tree->IsWindowKnown(*(tree->roots().begin()), &root_client_id)); |
| 569 EXPECT_TRUE(tree->DeleteWindow(root_client_id)); | 563 EXPECT_TRUE(tree->DeleteWindow(root_client_id)); |
| 570 window_server->DestroyTree(tree); | 564 window_server->DestroyTree(tree); |
| 571 } | 565 } |
| 572 | 566 |
| 573 TEST_F(WindowManagerStateTest, CursorResetOverNoTarget) { | 567 TEST_F(WindowManagerStateTest, CursorResetOverNoTarget) { |
| 574 TestChangeTracker* tracker = window_tree_client()->tracker(); | |
| 575 ASSERT_EQ(1u, window_server()->display_manager()->displays().size()); | 568 ASSERT_EQ(1u, window_server()->display_manager()->displays().size()); |
| 576 Display* display = *(window_server()->display_manager()->displays().begin()); | 569 Display* display = *(window_server()->display_manager()->displays().begin()); |
| 577 DisplayTestApi display_test_api(display); | 570 DisplayTestApi display_test_api(display); |
| 578 // This test assumes the default is not a pointer, otherwise it can't detect | 571 const ClientWindowId child_window_id(11); |
| 579 // the change. | 572 window_tree()->NewWindow(child_window_id, ServerWindow::Properties()); |
| 580 EXPECT_NE(ui::mojom::Cursor::POINTER, display_test_api.last_cursor()); | 573 ServerWindow* child_window = |
| 574 window_tree()->GetWindowByClientId(child_window_id); |
| 575 window_tree()->AddWindow(FirstRootId(window_tree()), child_window_id); |
| 576 child_window->SetVisible(true); |
| 577 child_window->SetBounds(gfx::Rect(0, 0, 20, 20)); |
| 578 child_window->parent()->SetPredefinedCursor(ui::mojom::Cursor::COPY); |
| 579 EXPECT_EQ(ui::mojom::Cursor::COPY, display_test_api.last_cursor()); |
| 580 // Move the mouse outside the bounds of the child, so that the mouse is not |
| 581 // over any valid windows. Cursor should change to POINTER. |
| 581 ui::PointerEvent move( | 582 ui::PointerEvent move( |
| 582 ui::ET_POINTER_MOVED, gfx::Point(), gfx::Point(), 0, 0, 0, | 583 ui::ET_POINTER_MOVED, gfx::Point(25, 25), gfx::Point(25, 25), 0, 0, 0, |
| 583 ui::PointerDetails(EventPointerType::POINTER_TYPE_MOUSE), | 584 ui::PointerDetails(EventPointerType::POINTER_TYPE_MOUSE), |
| 584 base::TimeTicks()); | 585 base::TimeTicks()); |
| 585 window_manager_state()->ProcessEvent(move); | 586 window_manager_state()->ProcessEvent(move); |
| 586 // The event isn't over a valid target, which should trigger resetting the | 587 // The event isn't over a valid target, which should trigger resetting the |
| 587 // cursor to POINTER. | 588 // cursor to POINTER. |
| 588 EXPECT_EQ(ui::mojom::Cursor::POINTER, display_test_api.last_cursor()); | 589 EXPECT_EQ(ui::mojom::Cursor::POINTER, display_test_api.last_cursor()); |
| 589 EXPECT_TRUE(tracker->changes()->empty()); | |
| 590 } | 590 } |
| 591 | 591 |
| 592 } // namespace test | 592 } // namespace test |
| 593 } // namespace ws | 593 } // namespace ws |
| 594 } // namespace ui | 594 } // namespace ui |
| OLD | NEW |