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

Unified Diff: ash/wm/cursor_manager_unittest.cc

Issue 10965020: Fix cursor getting invisible after moving a window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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
« ash/wm/cursor_manager.h ('K') | « ash/wm/cursor_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/cursor_manager_unittest.cc
diff --git a/ash/wm/cursor_manager_unittest.cc b/ash/wm/cursor_manager_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d557e7d255e2176efafccd5e8a8d92abad85e775
--- /dev/null
+++ b/ash/wm/cursor_manager_unittest.cc
@@ -0,0 +1,67 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/wm/cursor_manager.h"
oshima 2012/09/20 20:19:03 new line
mazda 2012/09/20 20:29:31 Done.
+#include "ash/shell.h"
+#include "ash/test/ash_test_base.h"
+
+namespace ash {
+namespace test {
+
+typedef test::AshTestBase CursorManagerTest;
+
+TEST_F(CursorManagerTest, LockCursor) {
+ CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager();
+ CursorManager::TestApi test_api(cursor_manager);
+
+ cursor_manager->SetCursor(ui::kCursorCopy);
+ EXPECT_EQ(ui::kCursorCopy, test_api.current_cursor().native_type());
+ cursor_manager->SetDeviceScaleFactor(2.0f);
+ EXPECT_EQ(2.0f, test_api.GetDeviceScaleFactor());
+ EXPECT_NE(0UL, test_api.current_cursor().platform());
+
+ cursor_manager->LockCursor();
+ EXPECT_TRUE(cursor_manager->is_cursor_locked());
+
+ // Cursor type does not change while cursor is locked.
+ cursor_manager->SetCursor(ui::kCursorPointer);
+ EXPECT_EQ(ui::kCursorCopy, test_api.current_cursor().native_type());
+
+ // Device scale factor does change even while cursor is locked.
+ cursor_manager->SetDeviceScaleFactor(1.0f);
+ EXPECT_EQ(1.0f, test_api.GetDeviceScaleFactor());
+
+ cursor_manager->UnlockCursor();
+ EXPECT_FALSE(cursor_manager->is_cursor_locked());
+
+ // Cursor type changes to the one specified while cursor is locked.
+ EXPECT_EQ(ui::kCursorPointer, test_api.current_cursor().native_type());
+ EXPECT_EQ(1.0f, test_api.GetDeviceScaleFactor());
+ EXPECT_NE(0UL, test_api.current_cursor().platform());
+}
+
+TEST_F(CursorManagerTest, SetCursor) {
+ CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager();
+ CursorManager::TestApi test_api(cursor_manager);
+
+ cursor_manager->SetCursor(ui::kCursorCopy);
+ EXPECT_EQ(ui::kCursorCopy, test_api.current_cursor().native_type());
+ EXPECT_NE(0UL, test_api.current_cursor().platform());
+ cursor_manager->SetCursor(ui::kCursorPointer);
+ EXPECT_EQ(ui::kCursorPointer, test_api.current_cursor().native_type());
+ EXPECT_NE(0UL, test_api.current_cursor().platform());
+}
+
+TEST_F(CursorManagerTest, SetDeviceScaleFactor) {
+ CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager();
+ CursorManager::TestApi test_api(cursor_manager);
+
+ cursor_manager->SetDeviceScaleFactor(2.0f);
+ EXPECT_EQ(2.0f, test_api.GetDeviceScaleFactor());
+ cursor_manager->SetDeviceScaleFactor(1.0f);
+ EXPECT_EQ(1.0f, test_api.GetDeviceScaleFactor());
+}
+
+} // namespace test
+} // namespace ash
« ash/wm/cursor_manager.h ('K') | « ash/wm/cursor_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698