| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ash/wm/cursor_manager.h" |
| 6 |
| 7 #include "ash/shell.h" |
| 8 #include "ash/test/ash_test_base.h" |
| 9 |
| 10 namespace ash { |
| 11 namespace test { |
| 12 |
| 13 typedef test::AshTestBase CursorManagerTest; |
| 14 |
| 15 TEST_F(CursorManagerTest, LockCursor) { |
| 16 CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager(); |
| 17 CursorManager::TestApi test_api(cursor_manager); |
| 18 |
| 19 cursor_manager->SetCursor(ui::kCursorCopy); |
| 20 EXPECT_EQ(ui::kCursorCopy, test_api.GetCurrentCursor().native_type()); |
| 21 cursor_manager->SetDeviceScaleFactor(2.0f); |
| 22 EXPECT_EQ(2.0f, test_api.GetDeviceScaleFactor()); |
| 23 EXPECT_NE(0UL, test_api.GetCurrentCursor().platform()); |
| 24 |
| 25 cursor_manager->LockCursor(); |
| 26 EXPECT_TRUE(cursor_manager->is_cursor_locked()); |
| 27 |
| 28 // Cursor type does not change while cursor is locked. |
| 29 cursor_manager->SetCursor(ui::kCursorPointer); |
| 30 EXPECT_EQ(ui::kCursorCopy, test_api.GetCurrentCursor().native_type()); |
| 31 |
| 32 // Device scale factor does change even while cursor is locked. |
| 33 cursor_manager->SetDeviceScaleFactor(1.0f); |
| 34 EXPECT_EQ(1.0f, test_api.GetDeviceScaleFactor()); |
| 35 |
| 36 cursor_manager->UnlockCursor(); |
| 37 EXPECT_FALSE(cursor_manager->is_cursor_locked()); |
| 38 |
| 39 // Cursor type changes to the one specified while cursor is locked. |
| 40 EXPECT_EQ(ui::kCursorPointer, test_api.GetCurrentCursor().native_type()); |
| 41 EXPECT_EQ(1.0f, test_api.GetDeviceScaleFactor()); |
| 42 EXPECT_NE(0UL, test_api.GetCurrentCursor().platform()); |
| 43 } |
| 44 |
| 45 TEST_F(CursorManagerTest, SetCursor) { |
| 46 CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager(); |
| 47 CursorManager::TestApi test_api(cursor_manager); |
| 48 |
| 49 cursor_manager->SetCursor(ui::kCursorCopy); |
| 50 EXPECT_EQ(ui::kCursorCopy, test_api.GetCurrentCursor().native_type()); |
| 51 EXPECT_NE(0UL, test_api.GetCurrentCursor().platform()); |
| 52 cursor_manager->SetCursor(ui::kCursorPointer); |
| 53 EXPECT_EQ(ui::kCursorPointer, test_api.GetCurrentCursor().native_type()); |
| 54 EXPECT_NE(0UL, test_api.GetCurrentCursor().platform()); |
| 55 } |
| 56 |
| 57 TEST_F(CursorManagerTest, SetDeviceScaleFactor) { |
| 58 CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager(); |
| 59 CursorManager::TestApi test_api(cursor_manager); |
| 60 |
| 61 cursor_manager->SetDeviceScaleFactor(2.0f); |
| 62 EXPECT_EQ(2.0f, test_api.GetDeviceScaleFactor()); |
| 63 cursor_manager->SetDeviceScaleFactor(1.0f); |
| 64 EXPECT_EQ(1.0f, test_api.GetDeviceScaleFactor()); |
| 65 } |
| 66 |
| 67 } // namespace test |
| 68 } // namespace ash |
| OLD | NEW |