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

Side by Side Diff: ui/wm/core/cursor_manager_unittest.cc

Issue 2071553002: Initial support of large mouse cursor on Exosphere (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 6 months 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
« components/exo/pointer.cc ('K') | « ui/wm/core/cursor_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 cursor_manager_(base::WrapUnique(delegate_)) {} 49 cursor_manager_(base::WrapUnique(delegate_)) {}
50 50
51 TestingCursorManager* delegate_; 51 TestingCursorManager* delegate_;
52 wm::CursorManager cursor_manager_; 52 wm::CursorManager cursor_manager_;
53 }; 53 };
54 54
55 class TestingCursorClientObserver : public aura::client::CursorClientObserver { 55 class TestingCursorClientObserver : public aura::client::CursorClientObserver {
56 public: 56 public:
57 TestingCursorClientObserver() 57 TestingCursorClientObserver()
58 : cursor_visibility_(false), 58 : cursor_visibility_(false),
59 did_visibility_change_(false) {} 59 did_visibility_change_(false),
60 cursor_set_(ui::CURSOR_SET_NORMAL) {}
60 void reset() { cursor_visibility_ = did_visibility_change_ = false; } 61 void reset() { cursor_visibility_ = did_visibility_change_ = false; }
61 bool is_cursor_visible() const { return cursor_visibility_; } 62 bool is_cursor_visible() const { return cursor_visibility_; }
63 ui::CursorSetType cursor_set() const { return cursor_set_; }
62 bool did_visibility_change() const { return did_visibility_change_; } 64 bool did_visibility_change() const { return did_visibility_change_; }
63 65
64 // Overridden from aura::client::CursorClientObserver: 66 // Overridden from aura::client::CursorClientObserver:
65 void OnCursorVisibilityChanged(bool is_visible) override { 67 void OnCursorVisibilityChanged(bool is_visible) override {
66 cursor_visibility_ = is_visible; 68 cursor_visibility_ = is_visible;
67 did_visibility_change_ = true; 69 did_visibility_change_ = true;
68 } 70 }
71 void OnCursorSetChanged(ui::CursorSetType cursor_set) override {
72 cursor_set_ = cursor_set;
73 }
69 74
70 private: 75 private:
71 bool cursor_visibility_; 76 bool cursor_visibility_;
72 bool did_visibility_change_; 77 bool did_visibility_change_;
78 ui::CursorSetType cursor_set_;
73 79
74 DISALLOW_COPY_AND_ASSIGN(TestingCursorClientObserver); 80 DISALLOW_COPY_AND_ASSIGN(TestingCursorClientObserver);
75 }; 81 };
76 82
77 TEST_F(CursorManagerTest, ShowHideCursor) { 83 TEST_F(CursorManagerTest, ShowHideCursor) {
78 cursor_manager_.SetCursor(ui::kCursorCopy); 84 cursor_manager_.SetCursor(ui::kCursorCopy);
79 EXPECT_EQ(ui::kCursorCopy, cursor_manager_.GetCursor().native_type()); 85 EXPECT_EQ(ui::kCursorCopy, cursor_manager_.GetCursor().native_type());
80 86
81 cursor_manager_.ShowCursor(); 87 cursor_manager_.ShowCursor();
82 EXPECT_TRUE(cursor_manager_.IsCursorVisible()); 88 EXPECT_TRUE(cursor_manager_.IsCursorVisible());
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 cursor_manager_.UnlockCursor(); 174 cursor_manager_.UnlockCursor();
169 EXPECT_TRUE(cursor_manager_.IsMouseEventsEnabled()); 175 EXPECT_TRUE(cursor_manager_.IsMouseEventsEnabled());
170 176
171 cursor_manager_.DisableMouseEvents(); 177 cursor_manager_.DisableMouseEvents();
172 cursor_manager_.LockCursor(); 178 cursor_manager_.LockCursor();
173 cursor_manager_.UnlockCursor(); 179 cursor_manager_.UnlockCursor();
174 EXPECT_FALSE(cursor_manager_.IsMouseEventsEnabled()); 180 EXPECT_FALSE(cursor_manager_.IsMouseEventsEnabled());
175 } 181 }
176 182
177 TEST_F(CursorManagerTest, SetCursorSet) { 183 TEST_F(CursorManagerTest, SetCursorSet) {
184 TestingCursorClientObserver observer;
185 cursor_manager_.AddObserver(&observer);
186
178 EXPECT_EQ(ui::CURSOR_SET_NORMAL, cursor_manager_.GetCursorSet()); 187 EXPECT_EQ(ui::CURSOR_SET_NORMAL, cursor_manager_.GetCursorSet());
188 EXPECT_EQ(ui::CURSOR_SET_NORMAL, observer.cursor_set());
179 189
180 cursor_manager_.SetCursorSet(ui::CURSOR_SET_NORMAL); 190 cursor_manager_.SetCursorSet(ui::CURSOR_SET_NORMAL);
181 EXPECT_EQ(ui::CURSOR_SET_NORMAL, cursor_manager_.GetCursorSet()); 191 EXPECT_EQ(ui::CURSOR_SET_NORMAL, cursor_manager_.GetCursorSet());
192 EXPECT_EQ(ui::CURSOR_SET_NORMAL, observer.cursor_set());
182 193
183 cursor_manager_.SetCursorSet(ui::CURSOR_SET_LARGE); 194 cursor_manager_.SetCursorSet(ui::CURSOR_SET_LARGE);
184 EXPECT_EQ(ui::CURSOR_SET_LARGE, cursor_manager_.GetCursorSet()); 195 EXPECT_EQ(ui::CURSOR_SET_LARGE, cursor_manager_.GetCursorSet());
196 EXPECT_EQ(ui::CURSOR_SET_LARGE, observer.cursor_set());
185 197
186 cursor_manager_.SetCursorSet(ui::CURSOR_SET_NORMAL); 198 cursor_manager_.SetCursorSet(ui::CURSOR_SET_NORMAL);
187 EXPECT_EQ(ui::CURSOR_SET_NORMAL, cursor_manager_.GetCursorSet()); 199 EXPECT_EQ(ui::CURSOR_SET_NORMAL, cursor_manager_.GetCursorSet());
200 EXPECT_EQ(ui::CURSOR_SET_NORMAL, observer.cursor_set());
188 } 201 }
189 202
190 TEST_F(CursorManagerTest, IsMouseEventsEnabled) { 203 TEST_F(CursorManagerTest, IsMouseEventsEnabled) {
191 cursor_manager_.EnableMouseEvents(); 204 cursor_manager_.EnableMouseEvents();
192 EXPECT_TRUE(cursor_manager_.IsMouseEventsEnabled()); 205 EXPECT_TRUE(cursor_manager_.IsMouseEventsEnabled());
193 cursor_manager_.DisableMouseEvents(); 206 cursor_manager_.DisableMouseEvents();
194 EXPECT_FALSE(cursor_manager_.IsMouseEventsEnabled()); 207 EXPECT_FALSE(cursor_manager_.IsMouseEventsEnabled());
195 } 208 }
196 209
197 // Verifies that the mouse events enable state changes correctly when 210 // Verifies that the mouse events enable state changes correctly when
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 // This block validates that the cursor is visible initially. It then 365 // This block validates that the cursor is visible initially. It then
353 // performs normal cursor visibility operations. 366 // performs normal cursor visibility operations.
354 { 367 {
355 wm::CursorManager cursor_manager3( 368 wm::CursorManager cursor_manager3(
356 base::WrapUnique(new TestingCursorManager)); 369 base::WrapUnique(new TestingCursorManager));
357 EXPECT_TRUE(cursor_manager3.IsCursorVisible()); 370 EXPECT_TRUE(cursor_manager3.IsCursorVisible());
358 cursor_manager3.HideCursor(); 371 cursor_manager3.HideCursor();
359 EXPECT_FALSE(cursor_manager3.IsCursorVisible()); 372 EXPECT_FALSE(cursor_manager3.IsCursorVisible());
360 } 373 }
361 } 374 }
OLDNEW
« components/exo/pointer.cc ('K') | « ui/wm/core/cursor_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698