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

Side by Side Diff: ash/wm/cursor_manager_unittest.cc

Issue 11035050: Enable CursorManager::LockCursor to lock cursor visibility. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/wm/cursor_manager.h" 5 #include "ash/wm/cursor_manager.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/test/ash_test_base.h" 8 #include "ash/test/ash_test_base.h"
9 #include "ash/test/cursor_manager_test_api.h" 9 #include "ash/test/cursor_manager_test_api.h"
10 #include "ash/wm/image_cursors.h" 10 #include "ash/wm/image_cursors.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 CursorManagerTestApi test_api(cursor_manager); 49 CursorManagerTestApi test_api(cursor_manager);
50 50
51 cursor_manager->SetCursor(ui::kCursorCopy); 51 cursor_manager->SetCursor(ui::kCursorCopy);
52 EXPECT_EQ(ui::kCursorCopy, test_api.GetCurrentCursor().native_type()); 52 EXPECT_EQ(ui::kCursorCopy, test_api.GetCurrentCursor().native_type());
53 EXPECT_TRUE(test_api.GetCurrentCursor().platform()); 53 EXPECT_TRUE(test_api.GetCurrentCursor().platform());
54 cursor_manager->SetCursor(ui::kCursorPointer); 54 cursor_manager->SetCursor(ui::kCursorPointer);
55 EXPECT_EQ(ui::kCursorPointer, test_api.GetCurrentCursor().native_type()); 55 EXPECT_EQ(ui::kCursorPointer, test_api.GetCurrentCursor().native_type());
56 EXPECT_TRUE(test_api.GetCurrentCursor().platform()); 56 EXPECT_TRUE(test_api.GetCurrentCursor().platform());
57 } 57 }
58 58
59 TEST_F(CursorManagerTest, ShowCursor) {
60 CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager();
61 CursorManagerTestApi test_api(cursor_manager);
62
63 cursor_manager->SetCursor(ui::kCursorCopy);
64 EXPECT_EQ(ui::kCursorCopy, test_api.GetCurrentCursor().native_type());
65
66 cursor_manager->ShowCursor(true);
67 EXPECT_TRUE(cursor_manager->cursor_visible());
68 cursor_manager->ShowCursor(false);
69 EXPECT_FALSE(cursor_manager->cursor_visible());
70 // The current cursor does not change even when the cursor is not shown.
71 EXPECT_EQ(ui::kCursorCopy, test_api.GetCurrentCursor().native_type());
72
73 // Check if cursor visibility is locked.
74 cursor_manager->LockCursor();
75 EXPECT_FALSE(cursor_manager->cursor_visible());
76 cursor_manager->ShowCursor(true);
77 EXPECT_FALSE(cursor_manager->cursor_visible());
78 cursor_manager->UnlockCursor();
79 EXPECT_TRUE(cursor_manager->cursor_visible());
80
81 cursor_manager->LockCursor();
82 EXPECT_TRUE(cursor_manager->cursor_visible());
83 cursor_manager->ShowCursor(false);
84 EXPECT_TRUE(cursor_manager->cursor_visible());
85 cursor_manager->UnlockCursor();
86 EXPECT_FALSE(cursor_manager->cursor_visible());
87
88 // Checks setting visiblity while cursor is locked does not affect the
89 // subsequent uses of UnlockCursor.
90 cursor_manager->LockCursor();
91 cursor_manager->ShowCursor(false);
92 cursor_manager->UnlockCursor();
93 EXPECT_FALSE(cursor_manager->cursor_visible());
94
95 cursor_manager->ShowCursor(true);
96 cursor_manager->LockCursor();
97 cursor_manager->UnlockCursor();
98 EXPECT_TRUE(cursor_manager->cursor_visible());
99
100 cursor_manager->LockCursor();
101 cursor_manager->ShowCursor(true);
102 cursor_manager->UnlockCursor();
103 EXPECT_TRUE(cursor_manager->cursor_visible());
104
105 cursor_manager->ShowCursor(false);
106 cursor_manager->LockCursor();
107 cursor_manager->UnlockCursor();
108 EXPECT_FALSE(cursor_manager->cursor_visible());
109 }
110
59 TEST_F(CursorManagerTest, SetDeviceScaleFactor) { 111 TEST_F(CursorManagerTest, SetDeviceScaleFactor) {
60 CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager(); 112 CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager();
61 CursorManagerTestApi test_api(cursor_manager); 113 CursorManagerTestApi test_api(cursor_manager);
62 114
63 cursor_manager->SetDeviceScaleFactor(2.0f); 115 cursor_manager->SetDeviceScaleFactor(2.0f);
64 EXPECT_EQ(2.0f, test_api.GetDeviceScaleFactor()); 116 EXPECT_EQ(2.0f, test_api.GetDeviceScaleFactor());
65 cursor_manager->SetDeviceScaleFactor(1.0f); 117 cursor_manager->SetDeviceScaleFactor(1.0f);
66 EXPECT_EQ(1.0f, test_api.GetDeviceScaleFactor()); 118 EXPECT_EQ(1.0f, test_api.GetDeviceScaleFactor());
67 } 119 }
68 120
69 } // namespace test 121 } // namespace test
70 } // namespace ash 122 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698