OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/wm/ash_native_cursor_manager.h" | 5 #include "ash/wm/ash_native_cursor_manager.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
9 #include "ash/test/cursor_manager_test_api.h" | 9 #include "ash/test/cursor_manager_test_api.h" |
10 #include "ash/wm/image_cursors.h" | 10 #include "ash/wm/image_cursors.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 ::wm::CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager(); | 55 ::wm::CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager(); |
56 CursorManagerTestApi test_api(cursor_manager); | 56 CursorManagerTestApi test_api(cursor_manager); |
57 gfx::Display display(0); | 57 gfx::Display display(0); |
58 #if defined(OS_WIN) | 58 #if defined(OS_WIN) |
59 ui::CursorLoaderWin::SetCursorResourceModule(L"ash_unittests.exe"); | 59 ui::CursorLoaderWin::SetCursorResourceModule(L"ash_unittests.exe"); |
60 #endif | 60 #endif |
61 cursor_manager->SetCursor(ui::kCursorCopy); | 61 cursor_manager->SetCursor(ui::kCursorCopy); |
62 EXPECT_EQ(ui::kCursorCopy, test_api.GetCurrentCursor().native_type()); | 62 EXPECT_EQ(ui::kCursorCopy, test_api.GetCurrentCursor().native_type()); |
63 display.set_device_scale_factor(2.0f); | 63 display.set_device_scale_factor(2.0f); |
64 display.set_rotation(gfx::Display::ROTATE_90); | 64 display.set_rotation(gfx::Display::ROTATE_90); |
| 65 cursor_manager->SetScale(2.5f); |
65 cursor_manager->SetDisplay(display); | 66 cursor_manager->SetDisplay(display); |
| 67 EXPECT_EQ(2.5f, test_api.GetCurrentScale()); |
66 EXPECT_EQ(2.0f, test_api.GetDisplay().device_scale_factor()); | 68 EXPECT_EQ(2.0f, test_api.GetDisplay().device_scale_factor()); |
67 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet()); | 69 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet()); |
68 EXPECT_EQ(gfx::Display::ROTATE_90, test_api.GetDisplay().rotation()); | 70 EXPECT_EQ(gfx::Display::ROTATE_90, test_api.GetDisplay().rotation()); |
69 EXPECT_TRUE(test_api.GetCurrentCursor().platform()); | 71 EXPECT_TRUE(test_api.GetCurrentCursor().platform()); |
70 | 72 |
71 cursor_manager->LockCursor(); | 73 cursor_manager->LockCursor(); |
72 EXPECT_TRUE(cursor_manager->IsCursorLocked()); | 74 EXPECT_TRUE(cursor_manager->IsCursorLocked()); |
73 | 75 |
74 // Cursor type does not change while cursor is locked. | 76 // Cursor type does not change while cursor is locked. |
75 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet()); | 77 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet()); |
76 cursor_manager->SetCursorSet(ui::CURSOR_SET_NORMAL); | 78 cursor_manager->SetCursorSet(ui::CURSOR_SET_NORMAL); |
77 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet()); | 79 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet()); |
78 cursor_manager->SetCursorSet(ui::CURSOR_SET_LARGE); | 80 cursor_manager->SetCursorSet(ui::CURSOR_SET_LARGE); |
79 EXPECT_EQ(ui::CURSOR_SET_LARGE, test_api.GetCurrentCursorSet()); | 81 EXPECT_EQ(ui::CURSOR_SET_LARGE, test_api.GetCurrentCursorSet()); |
80 cursor_manager->SetCursorSet(ui::CURSOR_SET_NORMAL); | 82 cursor_manager->SetCursorSet(ui::CURSOR_SET_NORMAL); |
81 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet()); | 83 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet()); |
82 | 84 |
| 85 // Cusror scale does change even while cursor is locked. |
| 86 EXPECT_EQ(2.5f, test_api.GetCurrentScale()); |
| 87 cursor_manager->SetScale(1.f); |
| 88 EXPECT_EQ(1.f, test_api.GetCurrentScale()); |
| 89 cursor_manager->SetScale(1.5f); |
| 90 EXPECT_EQ(1.5f, test_api.GetCurrentScale()); |
| 91 |
83 // Cursor type does not change while cursor is locked. | 92 // Cursor type does not change while cursor is locked. |
84 cursor_manager->SetCursor(ui::kCursorPointer); | 93 cursor_manager->SetCursor(ui::kCursorPointer); |
85 EXPECT_EQ(ui::kCursorCopy, test_api.GetCurrentCursor().native_type()); | 94 EXPECT_EQ(ui::kCursorCopy, test_api.GetCurrentCursor().native_type()); |
86 | 95 |
87 // Device scale factor and rotation do change even while cursor is locked. | 96 // Device scale factor and rotation do change even while cursor is locked. |
88 display.set_device_scale_factor(1.0f); | 97 display.set_device_scale_factor(1.0f); |
89 display.set_rotation(gfx::Display::ROTATE_180); | 98 display.set_rotation(gfx::Display::ROTATE_180); |
90 cursor_manager->SetDisplay(display); | 99 cursor_manager->SetDisplay(display); |
91 EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor()); | 100 EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor()); |
92 EXPECT_EQ(gfx::Display::ROTATE_180, test_api.GetDisplay().rotation()); | 101 EXPECT_EQ(gfx::Display::ROTATE_180, test_api.GetDisplay().rotation()); |
93 | 102 |
94 cursor_manager->UnlockCursor(); | 103 cursor_manager->UnlockCursor(); |
95 EXPECT_FALSE(cursor_manager->IsCursorLocked()); | 104 EXPECT_FALSE(cursor_manager->IsCursorLocked()); |
96 | 105 |
97 // Cursor type changes to the one specified while cursor is locked. | 106 // Cursor type changes to the one specified while cursor is locked. |
| 107 EXPECT_EQ(1.5f, test_api.GetCurrentScale()); |
98 EXPECT_EQ(ui::kCursorPointer, test_api.GetCurrentCursor().native_type()); | 108 EXPECT_EQ(ui::kCursorPointer, test_api.GetCurrentCursor().native_type()); |
99 EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor()); | 109 EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor()); |
100 EXPECT_TRUE(test_api.GetCurrentCursor().platform()); | 110 EXPECT_TRUE(test_api.GetCurrentCursor().platform()); |
101 } | 111 } |
102 | 112 |
103 TEST_F(AshNativeCursorManagerTest, SetCursor) { | 113 TEST_F(AshNativeCursorManagerTest, SetCursor) { |
104 ::wm::CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager(); | 114 ::wm::CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager(); |
105 CursorManagerTestApi test_api(cursor_manager); | 115 CursorManagerTestApi test_api(cursor_manager); |
106 #if defined(OS_WIN) | 116 #if defined(OS_WIN) |
107 ui::CursorLoaderWin::SetCursorResourceModule(L"ash_unittests.exe"); | 117 ui::CursorLoaderWin::SetCursorResourceModule(L"ash_unittests.exe"); |
(...skipping 15 matching lines...) Expand all Loading... |
123 cursor_manager->SetCursorSet(ui::CURSOR_SET_NORMAL); | 133 cursor_manager->SetCursorSet(ui::CURSOR_SET_NORMAL); |
124 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet()); | 134 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet()); |
125 | 135 |
126 cursor_manager->SetCursorSet(ui::CURSOR_SET_LARGE); | 136 cursor_manager->SetCursorSet(ui::CURSOR_SET_LARGE); |
127 EXPECT_EQ(ui::CURSOR_SET_LARGE, test_api.GetCurrentCursorSet()); | 137 EXPECT_EQ(ui::CURSOR_SET_LARGE, test_api.GetCurrentCursorSet()); |
128 | 138 |
129 cursor_manager->SetCursorSet(ui::CURSOR_SET_NORMAL); | 139 cursor_manager->SetCursorSet(ui::CURSOR_SET_NORMAL); |
130 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet()); | 140 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet()); |
131 } | 141 } |
132 | 142 |
| 143 TEST_F(AshNativeCursorManagerTest, SetScale) { |
| 144 ::wm::CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager(); |
| 145 CursorManagerTestApi test_api(cursor_manager); |
| 146 |
| 147 EXPECT_EQ(1.f, test_api.GetCurrentScale()); |
| 148 |
| 149 cursor_manager->SetScale(2.5f); |
| 150 EXPECT_EQ(2.5f, test_api.GetCurrentScale()); |
| 151 |
| 152 cursor_manager->SetScale(1.f); |
| 153 EXPECT_EQ(1.f, test_api.GetCurrentScale()); |
| 154 } |
| 155 |
133 TEST_F(AshNativeCursorManagerTest, SetDeviceScaleFactorAndRotation) { | 156 TEST_F(AshNativeCursorManagerTest, SetDeviceScaleFactorAndRotation) { |
134 ::wm::CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager(); | 157 ::wm::CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager(); |
135 CursorManagerTestApi test_api(cursor_manager); | 158 CursorManagerTestApi test_api(cursor_manager); |
136 | 159 |
137 gfx::Display display(0); | 160 gfx::Display display(0); |
138 display.set_device_scale_factor(2.0f); | 161 display.set_device_scale_factor(2.0f); |
139 cursor_manager->SetDisplay(display); | 162 cursor_manager->SetDisplay(display); |
140 EXPECT_EQ(2.0f, test_api.GetDisplay().device_scale_factor()); | 163 EXPECT_EQ(2.0f, test_api.GetDisplay().device_scale_factor()); |
141 EXPECT_EQ(gfx::Display::ROTATE_0, test_api.GetDisplay().rotation()); | 164 EXPECT_EQ(gfx::Display::ROTATE_0, test_api.GetDisplay().rotation()); |
142 | 165 |
(...skipping 29 matching lines...) Expand all Loading... |
172 gfx::Point mouse_location; | 195 gfx::Point mouse_location; |
173 EXPECT_TRUE(host->QueryMouseLocation(&mouse_location)); | 196 EXPECT_TRUE(host->QueryMouseLocation(&mouse_location)); |
174 EXPECT_EQ("10,10", mouse_location.ToString()); | 197 EXPECT_EQ("10,10", mouse_location.ToString()); |
175 Shell::GetInstance()->cursor_manager()->DisableMouseEvents(); | 198 Shell::GetInstance()->cursor_manager()->DisableMouseEvents(); |
176 EXPECT_FALSE(host->QueryMouseLocation(&mouse_location)); | 199 EXPECT_FALSE(host->QueryMouseLocation(&mouse_location)); |
177 EXPECT_EQ("0,0", mouse_location.ToString()); | 200 EXPECT_EQ("0,0", mouse_location.ToString()); |
178 } | 201 } |
179 | 202 |
180 } // namespace test | 203 } // namespace test |
181 } // namespace ash | 204 } // namespace ash |
OLD | NEW |