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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ash/wm/cursor_manager_unittest.cc
diff --git a/ash/wm/cursor_manager_unittest.cc b/ash/wm/cursor_manager_unittest.cc
index 79b2aea83bdce11ef57c6efad6ae2ded6f749dd9..d997b30f80022bff27ce5bd41edbb3cec165d0c9 100644
--- a/ash/wm/cursor_manager_unittest.cc
+++ b/ash/wm/cursor_manager_unittest.cc
@@ -56,6 +56,58 @@ TEST_F(CursorManagerTest, SetCursor) {
EXPECT_TRUE(test_api.GetCurrentCursor().platform());
}
+TEST_F(CursorManagerTest, ShowCursor) {
+ CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager();
+ CursorManagerTestApi test_api(cursor_manager);
+
+ cursor_manager->SetCursor(ui::kCursorCopy);
+ EXPECT_EQ(ui::kCursorCopy, test_api.GetCurrentCursor().native_type());
+
+ cursor_manager->ShowCursor(true);
+ EXPECT_TRUE(cursor_manager->cursor_visible());
+ cursor_manager->ShowCursor(false);
+ EXPECT_FALSE(cursor_manager->cursor_visible());
+ // The current cursor does not change even when the cursor is not shown.
+ EXPECT_EQ(ui::kCursorCopy, test_api.GetCurrentCursor().native_type());
+
+ // Check if cursor visibility is locked.
+ cursor_manager->LockCursor();
+ EXPECT_FALSE(cursor_manager->cursor_visible());
+ cursor_manager->ShowCursor(true);
+ EXPECT_FALSE(cursor_manager->cursor_visible());
+ cursor_manager->UnlockCursor();
+ EXPECT_TRUE(cursor_manager->cursor_visible());
+
+ cursor_manager->LockCursor();
+ EXPECT_TRUE(cursor_manager->cursor_visible());
+ cursor_manager->ShowCursor(false);
+ EXPECT_TRUE(cursor_manager->cursor_visible());
+ cursor_manager->UnlockCursor();
+ EXPECT_FALSE(cursor_manager->cursor_visible());
+
+ // Checks setting visiblity while cursor is locked does not affect the
+ // subsequent uses of UnlockCursor.
+ cursor_manager->LockCursor();
+ cursor_manager->ShowCursor(false);
+ cursor_manager->UnlockCursor();
+ EXPECT_FALSE(cursor_manager->cursor_visible());
+
+ cursor_manager->ShowCursor(true);
+ cursor_manager->LockCursor();
+ cursor_manager->UnlockCursor();
+ EXPECT_TRUE(cursor_manager->cursor_visible());
+
+ cursor_manager->LockCursor();
+ cursor_manager->ShowCursor(true);
+ cursor_manager->UnlockCursor();
+ EXPECT_TRUE(cursor_manager->cursor_visible());
+
+ cursor_manager->ShowCursor(false);
+ cursor_manager->LockCursor();
+ cursor_manager->UnlockCursor();
+ EXPECT_FALSE(cursor_manager->cursor_visible());
+}
+
TEST_F(CursorManagerTest, SetDeviceScaleFactor) {
CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager();
CursorManagerTestApi test_api(cursor_manager);

Powered by Google App Engine
This is Rietveld 408576698