summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormazda@chromium.org <mazda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-12 19:14:10 +0000
committermazda@chromium.org <mazda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-12 19:14:10 +0000
commitf8154111b29ffb108a491739a0222db25908d4c7 (patch)
tree6f406c067d912c5f894f97fe5b0092e24b3cf76f
parent24205f2964e0446eec51b91bcddfb709c16dd7c1 (diff)
downloadchromium_src-f8154111b29ffb108a491739a0222db25908d4c7.zip
chromium_src-f8154111b29ffb108a491739a0222db25908d4c7.tar.gz
chromium_src-f8154111b29ffb108a491739a0222db25908d4c7.tar.bz2
Fix the issue that causes the cursor disappears when CursorManager::DisableMouseEvents is called multiple times.
BUG=169404 TEST=CursorManagerTest.MultipleDisableMouseEvents Review URL: https://chromiumcodereview.appspot.com/11855004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176569 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/wm/cursor_manager.cc3
-rw-r--r--ash/wm/cursor_manager_unittest.cc25
2 files changed, 27 insertions, 1 deletions
diff --git a/ash/wm/cursor_manager.cc b/ash/wm/cursor_manager.cc
index f0475e0..a126ae3 100644
--- a/ash/wm/cursor_manager.cc
+++ b/ash/wm/cursor_manager.cc
@@ -70,6 +70,8 @@ class CursorState {
bool mouse_events_enabled() const { return mouse_events_enabled_; }
void SetMouseEventsEnabled(bool enabled) {
+ if (mouse_events_enabled_ == enabled)
+ return;
mouse_events_enabled_ = enabled;
// Restores the visibility when mouse events are enabled.
@@ -81,7 +83,6 @@ class CursorState {
}
}
-
private:
gfx::NativeCursor cursor_;
bool visible_;
diff --git a/ash/wm/cursor_manager_unittest.cc b/ash/wm/cursor_manager_unittest.cc
index e31f3e0..a290512 100644
--- a/ash/wm/cursor_manager_unittest.cc
+++ b/ash/wm/cursor_manager_unittest.cc
@@ -266,6 +266,31 @@ TEST_F(CursorManagerTest, ShowAndEnable) {
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