OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ui/wm/core/cursor_manager.h" | 5 #include "ui/wm/core/cursor_manager.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "ui/aura/client/cursor_client_observer.h" | 9 #include "ui/aura/client/cursor_client_observer.h" |
10 #include "ui/aura/test/aura_test_base.h" | 10 #include "ui/aura/test/aura_test_base.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 protected: | 47 protected: |
48 CursorManagerTest() | 48 CursorManagerTest() |
49 : delegate_(new TestingCursorManager), | 49 : delegate_(new TestingCursorManager), |
50 cursor_manager_(base::WrapUnique(delegate_)) {} | 50 cursor_manager_(base::WrapUnique(delegate_)) {} |
51 | 51 |
52 TestingCursorManager* delegate_; | 52 TestingCursorManager* delegate_; |
53 wm::CursorManager cursor_manager_; | 53 wm::CursorManager cursor_manager_; |
54 }; | 54 }; |
55 | 55 |
56 TEST_F(CursorManagerTest, ShowHideCursor) { | 56 TEST_F(CursorManagerTest, ShowHideCursor) { |
57 cursor_manager_.SetCursor(ui::kCursorCopy); | 57 cursor_manager_.SetCursor(ui::CursorType::kCopy); |
58 EXPECT_EQ(ui::kCursorCopy, cursor_manager_.GetCursor().native_type()); | 58 EXPECT_EQ(ui::CursorType::kCopy, cursor_manager_.GetCursor().native_type()); |
59 | 59 |
60 cursor_manager_.ShowCursor(); | 60 cursor_manager_.ShowCursor(); |
61 EXPECT_TRUE(cursor_manager_.IsCursorVisible()); | 61 EXPECT_TRUE(cursor_manager_.IsCursorVisible()); |
62 cursor_manager_.HideCursor(); | 62 cursor_manager_.HideCursor(); |
63 EXPECT_FALSE(cursor_manager_.IsCursorVisible()); | 63 EXPECT_FALSE(cursor_manager_.IsCursorVisible()); |
64 // The current cursor does not change even when the cursor is not shown. | 64 // The current cursor does not change even when the cursor is not shown. |
65 EXPECT_EQ(ui::kCursorCopy, cursor_manager_.GetCursor().native_type()); | 65 EXPECT_EQ(ui::CursorType::kCopy, cursor_manager_.GetCursor().native_type()); |
66 | 66 |
67 // Check if cursor visibility is locked. | 67 // Check if cursor visibility is locked. |
68 cursor_manager_.LockCursor(); | 68 cursor_manager_.LockCursor(); |
69 EXPECT_FALSE(cursor_manager_.IsCursorVisible()); | 69 EXPECT_FALSE(cursor_manager_.IsCursorVisible()); |
70 cursor_manager_.ShowCursor(); | 70 cursor_manager_.ShowCursor(); |
71 EXPECT_FALSE(cursor_manager_.IsCursorVisible()); | 71 EXPECT_FALSE(cursor_manager_.IsCursorVisible()); |
72 cursor_manager_.UnlockCursor(); | 72 cursor_manager_.UnlockCursor(); |
73 EXPECT_TRUE(cursor_manager_.IsCursorVisible()); | 73 EXPECT_TRUE(cursor_manager_.IsCursorVisible()); |
74 | 74 |
75 cursor_manager_.LockCursor(); | 75 cursor_manager_.LockCursor(); |
(...skipping 22 matching lines...) Expand all Loading... |
98 | 98 |
99 cursor_manager_.HideCursor(); | 99 cursor_manager_.HideCursor(); |
100 cursor_manager_.LockCursor(); | 100 cursor_manager_.LockCursor(); |
101 cursor_manager_.UnlockCursor(); | 101 cursor_manager_.UnlockCursor(); |
102 EXPECT_FALSE(cursor_manager_.IsCursorVisible()); | 102 EXPECT_FALSE(cursor_manager_.IsCursorVisible()); |
103 } | 103 } |
104 | 104 |
105 // Verifies that LockCursor/UnlockCursor work correctly with | 105 // Verifies that LockCursor/UnlockCursor work correctly with |
106 // EnableMouseEvents and DisableMouseEvents | 106 // EnableMouseEvents and DisableMouseEvents |
107 TEST_F(CursorManagerTest, EnableDisableMouseEvents) { | 107 TEST_F(CursorManagerTest, EnableDisableMouseEvents) { |
108 cursor_manager_.SetCursor(ui::kCursorCopy); | 108 cursor_manager_.SetCursor(ui::CursorType::kCopy); |
109 EXPECT_EQ(ui::kCursorCopy, cursor_manager_.GetCursor().native_type()); | 109 EXPECT_EQ(ui::CursorType::kCopy, cursor_manager_.GetCursor().native_type()); |
110 | 110 |
111 cursor_manager_.EnableMouseEvents(); | 111 cursor_manager_.EnableMouseEvents(); |
112 EXPECT_TRUE(cursor_manager_.IsMouseEventsEnabled()); | 112 EXPECT_TRUE(cursor_manager_.IsMouseEventsEnabled()); |
113 cursor_manager_.DisableMouseEvents(); | 113 cursor_manager_.DisableMouseEvents(); |
114 EXPECT_FALSE(cursor_manager_.IsMouseEventsEnabled()); | 114 EXPECT_FALSE(cursor_manager_.IsMouseEventsEnabled()); |
115 // The current cursor does not change even when the cursor is not shown. | 115 // The current cursor does not change even when the cursor is not shown. |
116 EXPECT_EQ(ui::kCursorCopy, cursor_manager_.GetCursor().native_type()); | 116 EXPECT_EQ(ui::CursorType::kCopy, cursor_manager_.GetCursor().native_type()); |
117 | 117 |
118 // Check if cursor enable state is locked. | 118 // Check if cursor enable state is locked. |
119 cursor_manager_.LockCursor(); | 119 cursor_manager_.LockCursor(); |
120 EXPECT_FALSE(cursor_manager_.IsMouseEventsEnabled()); | 120 EXPECT_FALSE(cursor_manager_.IsMouseEventsEnabled()); |
121 cursor_manager_.EnableMouseEvents(); | 121 cursor_manager_.EnableMouseEvents(); |
122 EXPECT_FALSE(cursor_manager_.IsMouseEventsEnabled()); | 122 EXPECT_FALSE(cursor_manager_.IsMouseEventsEnabled()); |
123 cursor_manager_.UnlockCursor(); | 123 cursor_manager_.UnlockCursor(); |
124 EXPECT_TRUE(cursor_manager_.IsMouseEventsEnabled()); | 124 EXPECT_TRUE(cursor_manager_.IsMouseEventsEnabled()); |
125 | 125 |
126 cursor_manager_.LockCursor(); | 126 cursor_manager_.LockCursor(); |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 // This block validates that the cursor is visible initially. It then | 353 // This block validates that the cursor is visible initially. It then |
354 // performs normal cursor visibility operations. | 354 // performs normal cursor visibility operations. |
355 { | 355 { |
356 wm::CursorManager cursor_manager3( | 356 wm::CursorManager cursor_manager3( |
357 base::WrapUnique(new TestingCursorManager)); | 357 base::WrapUnique(new TestingCursorManager)); |
358 EXPECT_TRUE(cursor_manager3.IsCursorVisible()); | 358 EXPECT_TRUE(cursor_manager3.IsCursorVisible()); |
359 cursor_manager3.HideCursor(); | 359 cursor_manager3.HideCursor(); |
360 EXPECT_FALSE(cursor_manager3.IsCursorVisible()); | 360 EXPECT_FALSE(cursor_manager3.IsCursorVisible()); |
361 } | 361 } |
362 } | 362 } |
OLD | NEW |