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

Unified Diff: ash/wm/cursor_manager_unittest.cc

Issue 12263050: Rework ash::CursorManager into a corewm object, to share code with desktop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Lables Created 7 years, 10 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 a29051290d060d1efd2b4397a60b028e163e7166..7f7c3ebcb4f06d1075562c24d60c97c1aac32d15 100644
--- a/ash/wm/cursor_manager_unittest.cc
+++ b/ash/wm/cursor_manager_unittest.cc
@@ -85,58 +85,6 @@ TEST_F(CursorManagerTest, SetCursor) {
EXPECT_TRUE(test_api.GetCurrentCursor().platform());
}
-TEST_F(CursorManagerTest, ShowHideCursor) {
- 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();
- EXPECT_TRUE(cursor_manager->IsCursorVisible());
- cursor_manager->HideCursor();
- EXPECT_FALSE(cursor_manager->IsCursorVisible());
- // 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->IsCursorVisible());
- cursor_manager->ShowCursor();
- EXPECT_FALSE(cursor_manager->IsCursorVisible());
- cursor_manager->UnlockCursor();
- EXPECT_TRUE(cursor_manager->IsCursorVisible());
-
- cursor_manager->LockCursor();
- EXPECT_TRUE(cursor_manager->IsCursorVisible());
- cursor_manager->HideCursor();
- EXPECT_TRUE(cursor_manager->IsCursorVisible());
- cursor_manager->UnlockCursor();
- EXPECT_FALSE(cursor_manager->IsCursorVisible());
-
- // Checks setting visiblity while cursor is locked does not affect the
- // subsequent uses of UnlockCursor.
- cursor_manager->LockCursor();
- cursor_manager->HideCursor();
- cursor_manager->UnlockCursor();
- EXPECT_FALSE(cursor_manager->IsCursorVisible());
-
- cursor_manager->ShowCursor();
- cursor_manager->LockCursor();
- cursor_manager->UnlockCursor();
- EXPECT_TRUE(cursor_manager->IsCursorVisible());
-
- cursor_manager->LockCursor();
- cursor_manager->ShowCursor();
- cursor_manager->UnlockCursor();
- EXPECT_TRUE(cursor_manager->IsCursorVisible());
-
- cursor_manager->HideCursor();
- cursor_manager->LockCursor();
- cursor_manager->UnlockCursor();
- EXPECT_FALSE(cursor_manager->IsCursorVisible());
-}
-
TEST_F(CursorManagerTest, SetDeviceScaleFactor) {
CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager();
CursorManagerTestApi test_api(cursor_manager);
@@ -147,150 +95,6 @@ TEST_F(CursorManagerTest, SetDeviceScaleFactor) {
EXPECT_EQ(1.0f, test_api.GetDeviceScaleFactor());
}
-// Verifies that LockCursor/UnlockCursor work correctly with
-// EnableMouseEvents and DisableMouseEvents
-TEST_F(CursorManagerTest, EnableDisableMouseEvents) {
- 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->EnableMouseEvents();
- EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
- cursor_manager->DisableMouseEvents();
- EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled());
- // 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 enable state is locked.
- cursor_manager->LockCursor();
- EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled());
- cursor_manager->EnableMouseEvents();
- EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled());
- cursor_manager->UnlockCursor();
- EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
-
- cursor_manager->LockCursor();
- EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
- cursor_manager->DisableMouseEvents();
- EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
- cursor_manager->UnlockCursor();
- EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled());
-
- // Checks enabling cursor while cursor is locked does not affect the
- // subsequent uses of UnlockCursor.
- cursor_manager->LockCursor();
- cursor_manager->DisableMouseEvents();
- cursor_manager->UnlockCursor();
- EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled());
-
- cursor_manager->EnableMouseEvents();
- cursor_manager->LockCursor();
- cursor_manager->UnlockCursor();
- EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
-
- cursor_manager->LockCursor();
- cursor_manager->EnableMouseEvents();
- cursor_manager->UnlockCursor();
- EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
-
- cursor_manager->DisableMouseEvents();
- cursor_manager->LockCursor();
- cursor_manager->UnlockCursor();
- EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled());
-}
-
-TEST_F(CursorManagerTest, IsMouseEventsEnabled) {
- CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager();
- cursor_manager->EnableMouseEvents();
- EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
- cursor_manager->DisableMouseEvents();
- EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled());
-}
-
-// Verifies that the mouse events enable state changes correctly when
-// ShowCursor/HideCursor and EnableMouseEvents/DisableMouseEvents are used
-// together.
-TEST_F(CursorManagerTest, ShowAndEnable) {
- CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager();
-
- // Changing the visibility of the cursor does not affect the enable state.
- cursor_manager->EnableMouseEvents();
- cursor_manager->ShowCursor();
- EXPECT_TRUE(cursor_manager->IsCursorVisible());
- EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
- cursor_manager->HideCursor();
- EXPECT_FALSE(cursor_manager->IsCursorVisible());
- EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
- cursor_manager->ShowCursor();
- EXPECT_TRUE(cursor_manager->IsCursorVisible());
- EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
-
- // When mouse events are disabled, it also gets invisible.
- EXPECT_TRUE(cursor_manager->IsCursorVisible());
- cursor_manager->DisableMouseEvents();
- EXPECT_FALSE(cursor_manager->IsCursorVisible());
- EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled());
-
- // When mouse events are enabled, it restores the visibility state.
- cursor_manager->EnableMouseEvents();
- EXPECT_TRUE(cursor_manager->IsCursorVisible());
- EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
-
- cursor_manager->ShowCursor();
- cursor_manager->DisableMouseEvents();
- EXPECT_FALSE(cursor_manager->IsCursorVisible());
- EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled());
- cursor_manager->EnableMouseEvents();
- EXPECT_TRUE(cursor_manager->IsCursorVisible());
- EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
-
- cursor_manager->HideCursor();
- cursor_manager->DisableMouseEvents();
- EXPECT_FALSE(cursor_manager->IsCursorVisible());
- EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled());
- cursor_manager->EnableMouseEvents();
- EXPECT_FALSE(cursor_manager->IsCursorVisible());
- EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
-
- // When mouse events are disabled, ShowCursor is ignored.
- cursor_manager->DisableMouseEvents();
- EXPECT_FALSE(cursor_manager->IsCursorVisible());
- EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled());
- cursor_manager->ShowCursor();
- EXPECT_FALSE(cursor_manager->IsCursorVisible());
- EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled());
- cursor_manager->DisableMouseEvents();
- EXPECT_FALSE(cursor_manager->IsCursorVisible());
- EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled());
-}
-
-// Verifies that calling DisableMouseEvents multiple times in a row makes no
-// difference compared with calling it once.
-// This is a regression test for http://crbug.com/169404.
-TEST_F(CursorManagerTest, MultipleDisableMouseEvents) {
- CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager();
- cursor_manager->DisableMouseEvents();
- cursor_manager->DisableMouseEvents();
- cursor_manager->EnableMouseEvents();
- cursor_manager->LockCursor();
- cursor_manager->UnlockCursor();
- EXPECT_TRUE(cursor_manager->IsCursorVisible());
-}
-
-// Verifies that calling EnableMouseEvents multiple times in a row makes no
-// difference compared with calling it once.
-TEST_F(CursorManagerTest, MultipleEnableMouseEvents) {
- CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager();
- cursor_manager->DisableMouseEvents();
- cursor_manager->EnableMouseEvents();
- cursor_manager->EnableMouseEvents();
- cursor_manager->LockCursor();
- cursor_manager->UnlockCursor();
- EXPECT_TRUE(cursor_manager->IsCursorVisible());
-}
-
#if defined(OS_WIN)
// Temporarily disabled for windows. See crbug.com/112222.
#define MAYBE_DisabledMouseEventsLocation DISABLED_DisabledMouseEventsLocation

Powered by Google App Engine
This is Rietveld 408576698