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

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

Issue 2949353003: Implement large cursors in Mushrome. (Closed)
Patch Set: Remove old cursor.h includes. Created 3 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
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 17 matching lines...) Expand all
28 wm::NativeCursorManagerDelegate* delegate) override { 28 wm::NativeCursorManagerDelegate* delegate) override {
29 delegate->CommitVisibility(visible); 29 delegate->CommitVisibility(visible);
30 } 30 }
31 31
32 void SetMouseEventsEnabled( 32 void SetMouseEventsEnabled(
33 bool enabled, 33 bool enabled,
34 wm::NativeCursorManagerDelegate* delegate) override { 34 wm::NativeCursorManagerDelegate* delegate) override {
35 delegate->CommitMouseEventsEnabled(enabled); 35 delegate->CommitMouseEventsEnabled(enabled);
36 } 36 }
37 37
38 void SetCursorSet(ui::CursorSetType cursor_set, 38 void SetCursorSet(ui::CursorSet cursor_set,
39 wm::NativeCursorManagerDelegate* delegate) override { 39 wm::NativeCursorManagerDelegate* delegate) override {
40 delegate->CommitCursorSet(cursor_set); 40 delegate->CommitCursorSet(cursor_set);
41 } 41 }
42 }; 42 };
43 43
44 } // namespace 44 } // namespace
45 45
46 class CursorManagerTest : public aura::test::AuraTestBase { 46 class CursorManagerTest : public aura::test::AuraTestBase {
47 protected: 47 protected:
48 CursorManagerTest() 48 CursorManagerTest()
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 cursor_manager_.DisableMouseEvents(); 150 cursor_manager_.DisableMouseEvents();
151 cursor_manager_.LockCursor(); 151 cursor_manager_.LockCursor();
152 cursor_manager_.UnlockCursor(); 152 cursor_manager_.UnlockCursor();
153 EXPECT_FALSE(cursor_manager_.IsMouseEventsEnabled()); 153 EXPECT_FALSE(cursor_manager_.IsMouseEventsEnabled());
154 } 154 }
155 155
156 TEST_F(CursorManagerTest, SetCursorSet) { 156 TEST_F(CursorManagerTest, SetCursorSet) {
157 wm::TestingCursorClientObserver observer; 157 wm::TestingCursorClientObserver observer;
158 cursor_manager_.AddObserver(&observer); 158 cursor_manager_.AddObserver(&observer);
159 159
160 EXPECT_EQ(ui::CURSOR_SET_NORMAL, cursor_manager_.GetCursorSet()); 160 EXPECT_EQ(ui::CursorSet::kNormal, cursor_manager_.GetCursorSet());
161 EXPECT_EQ(ui::CURSOR_SET_NORMAL, observer.cursor_set()); 161 EXPECT_EQ(ui::CursorSet::kNormal, observer.cursor_set());
162 162
163 cursor_manager_.SetCursorSet(ui::CURSOR_SET_NORMAL); 163 cursor_manager_.SetCursorSet(ui::CursorSet::kNormal);
164 EXPECT_EQ(ui::CURSOR_SET_NORMAL, cursor_manager_.GetCursorSet()); 164 EXPECT_EQ(ui::CursorSet::kNormal, cursor_manager_.GetCursorSet());
165 EXPECT_EQ(ui::CURSOR_SET_NORMAL, observer.cursor_set()); 165 EXPECT_EQ(ui::CursorSet::kNormal, observer.cursor_set());
166 166
167 cursor_manager_.SetCursorSet(ui::CURSOR_SET_LARGE); 167 cursor_manager_.SetCursorSet(ui::CursorSet::kLarge);
168 EXPECT_EQ(ui::CURSOR_SET_LARGE, cursor_manager_.GetCursorSet()); 168 EXPECT_EQ(ui::CursorSet::kLarge, cursor_manager_.GetCursorSet());
169 EXPECT_EQ(ui::CURSOR_SET_LARGE, observer.cursor_set()); 169 EXPECT_EQ(ui::CursorSet::kLarge, observer.cursor_set());
170 170
171 cursor_manager_.SetCursorSet(ui::CURSOR_SET_NORMAL); 171 cursor_manager_.SetCursorSet(ui::CursorSet::kNormal);
172 EXPECT_EQ(ui::CURSOR_SET_NORMAL, cursor_manager_.GetCursorSet()); 172 EXPECT_EQ(ui::CursorSet::kNormal, cursor_manager_.GetCursorSet());
173 EXPECT_EQ(ui::CURSOR_SET_NORMAL, observer.cursor_set()); 173 EXPECT_EQ(ui::CursorSet::kNormal, observer.cursor_set());
174 } 174 }
175 175
176 TEST_F(CursorManagerTest, IsMouseEventsEnabled) { 176 TEST_F(CursorManagerTest, IsMouseEventsEnabled) {
177 cursor_manager_.EnableMouseEvents(); 177 cursor_manager_.EnableMouseEvents();
178 EXPECT_TRUE(cursor_manager_.IsMouseEventsEnabled()); 178 EXPECT_TRUE(cursor_manager_.IsMouseEventsEnabled());
179 cursor_manager_.DisableMouseEvents(); 179 cursor_manager_.DisableMouseEvents();
180 EXPECT_FALSE(cursor_manager_.IsMouseEventsEnabled()); 180 EXPECT_FALSE(cursor_manager_.IsMouseEventsEnabled());
181 } 181 }
182 182
183 // Verifies that the mouse events enable state changes correctly when 183 // Verifies that the mouse events enable state changes correctly when
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 EXPECT_FALSE(observer_b.did_cursor_set_change()); 277 EXPECT_FALSE(observer_b.did_cursor_set_change());
278 278
279 // Hide the cursor using HideCursor(). 279 // Hide the cursor using HideCursor().
280 cursor_manager_.HideCursor(); 280 cursor_manager_.HideCursor();
281 EXPECT_TRUE(observer_a.did_visibility_change()); 281 EXPECT_TRUE(observer_a.did_visibility_change());
282 EXPECT_TRUE(observer_b.did_visibility_change()); 282 EXPECT_TRUE(observer_b.did_visibility_change());
283 EXPECT_FALSE(observer_a.is_cursor_visible()); 283 EXPECT_FALSE(observer_a.is_cursor_visible());
284 EXPECT_FALSE(observer_b.is_cursor_visible()); 284 EXPECT_FALSE(observer_b.is_cursor_visible());
285 285
286 // Set the cursor set. 286 // Set the cursor set.
287 cursor_manager_.SetCursorSet(ui::CURSOR_SET_LARGE); 287 cursor_manager_.SetCursorSet(ui::CursorSet::kLarge);
288 EXPECT_TRUE(observer_a.did_cursor_set_change()); 288 EXPECT_TRUE(observer_a.did_cursor_set_change());
289 EXPECT_EQ(ui::CURSOR_SET_LARGE, observer_a.cursor_set()); 289 EXPECT_EQ(ui::CursorSet::kLarge, observer_a.cursor_set());
290 EXPECT_TRUE(observer_b.did_cursor_set_change()); 290 EXPECT_TRUE(observer_b.did_cursor_set_change());
291 EXPECT_EQ(ui::CURSOR_SET_LARGE, observer_b.cursor_set()); 291 EXPECT_EQ(ui::CursorSet::kLarge, observer_b.cursor_set());
292 292
293 // Show the cursor using ShowCursor(). 293 // Show the cursor using ShowCursor().
294 observer_a.reset(); 294 observer_a.reset();
295 observer_b.reset(); 295 observer_b.reset();
296 cursor_manager_.ShowCursor(); 296 cursor_manager_.ShowCursor();
297 EXPECT_TRUE(observer_a.did_visibility_change()); 297 EXPECT_TRUE(observer_a.did_visibility_change());
298 EXPECT_TRUE(observer_b.did_visibility_change()); 298 EXPECT_TRUE(observer_b.did_visibility_change());
299 EXPECT_TRUE(observer_a.is_cursor_visible()); 299 EXPECT_TRUE(observer_a.is_cursor_visible());
300 EXPECT_TRUE(observer_b.is_cursor_visible()); 300 EXPECT_TRUE(observer_b.is_cursor_visible());
301 301
302 // Remove observer_b. Its OnCursorVisibilityChanged() should 302 // Remove observer_b. Its OnCursorVisibilityChanged() should
303 // not be invoked past this point. 303 // not be invoked past this point.
304 cursor_manager_.RemoveObserver(&observer_b); 304 cursor_manager_.RemoveObserver(&observer_b);
305 305
306 // Hide the cursor using HideCursor(). 306 // Hide the cursor using HideCursor().
307 observer_a.reset(); 307 observer_a.reset();
308 observer_b.reset(); 308 observer_b.reset();
309 cursor_manager_.HideCursor(); 309 cursor_manager_.HideCursor();
310 EXPECT_TRUE(observer_a.did_visibility_change()); 310 EXPECT_TRUE(observer_a.did_visibility_change());
311 EXPECT_FALSE(observer_b.did_visibility_change()); 311 EXPECT_FALSE(observer_b.did_visibility_change());
312 EXPECT_FALSE(observer_a.is_cursor_visible()); 312 EXPECT_FALSE(observer_a.is_cursor_visible());
313 313
314 // Set back the cursor set to normal. 314 // Set back the cursor set to normal.
315 cursor_manager_.SetCursorSet(ui::CURSOR_SET_NORMAL); 315 cursor_manager_.SetCursorSet(ui::CursorSet::kNormal);
316 EXPECT_TRUE(observer_a.did_cursor_set_change()); 316 EXPECT_TRUE(observer_a.did_cursor_set_change());
317 EXPECT_EQ(ui::CURSOR_SET_NORMAL, observer_a.cursor_set()); 317 EXPECT_EQ(ui::CursorSet::kNormal, observer_a.cursor_set());
318 EXPECT_FALSE(observer_b.did_cursor_set_change()); 318 EXPECT_FALSE(observer_b.did_cursor_set_change());
319 319
320 // Show the cursor using ShowCursor(). 320 // Show the cursor using ShowCursor().
321 observer_a.reset(); 321 observer_a.reset();
322 observer_b.reset(); 322 observer_b.reset();
323 cursor_manager_.ShowCursor(); 323 cursor_manager_.ShowCursor();
324 EXPECT_TRUE(observer_a.did_visibility_change()); 324 EXPECT_TRUE(observer_a.did_visibility_change());
325 EXPECT_FALSE(observer_b.did_visibility_change()); 325 EXPECT_FALSE(observer_b.did_visibility_change());
326 EXPECT_TRUE(observer_a.is_cursor_visible()); 326 EXPECT_TRUE(observer_a.is_cursor_visible());
327 } 327 }
(...skipping 25 matching lines...) Expand all
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698