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/display/display_manager.h" | 7 #include "ash/display/display_manager.h" |
8 #include "ash/display/display_util.h" | 8 #include "ash/display/display_util.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
11 #include "ash/test/cursor_manager_test_api.h" | 11 #include "ash/test/cursor_manager_test_api.h" |
| 12 #include "ash/test/display_manager_test_api.h" |
12 #include "ui/aura/test/aura_test_utils.h" | 13 #include "ui/aura/test/aura_test_utils.h" |
13 #include "ui/aura/test/test_window_delegate.h" | 14 #include "ui/aura/test/test_window_delegate.h" |
14 #include "ui/aura/test/test_windows.h" | 15 #include "ui/aura/test/test_windows.h" |
15 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
16 #include "ui/aura/window_event_dispatcher.h" | 17 #include "ui/aura/window_event_dispatcher.h" |
17 #include "ui/base/cursor/image_cursors.h" | 18 #include "ui/base/cursor/image_cursors.h" |
18 #include "ui/display/screen.h" | 19 #include "ui/display/screen.h" |
19 | 20 |
20 #if defined(OS_WIN) | 21 #if defined(OS_WIN) |
21 #include "base/win/windows_version.h" | 22 #include "base/win/windows_version.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 #else | 177 #else |
177 #define MAYBE_UIScaleShouldNotChangeCursor UIScaleShouldNotChangeCursor | 178 #define MAYBE_UIScaleShouldNotChangeCursor UIScaleShouldNotChangeCursor |
178 #endif | 179 #endif |
179 TEST_F(AshNativeCursorManagerTest, MAYBE_UIScaleShouldNotChangeCursor) { | 180 TEST_F(AshNativeCursorManagerTest, MAYBE_UIScaleShouldNotChangeCursor) { |
180 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 181 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
181 display::Display::SetInternalDisplayId(display_id); | 182 display::Display::SetInternalDisplayId(display_id); |
182 | 183 |
183 ::wm::CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager(); | 184 ::wm::CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager(); |
184 CursorManagerTestApi test_api(cursor_manager); | 185 CursorManagerTestApi test_api(cursor_manager); |
185 | 186 |
186 Shell::GetInstance()->display_manager()->SetDisplayUIScale(display_id, 0.5f); | 187 test::DisplayManagerTestApi(Shell::GetInstance()->display_manager()) |
| 188 .SetDisplayUIScale(display_id, 0.5f); |
187 EXPECT_EQ( | 189 EXPECT_EQ( |
188 1.0f, | 190 1.0f, |
189 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 191 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
190 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); | 192 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); |
191 | 193 |
192 Shell::GetInstance()->display_manager()->SetDisplayUIScale(display_id, 1.0f); | 194 test::DisplayManagerTestApi(Shell::GetInstance()->display_manager()) |
| 195 .SetDisplayUIScale(display_id, 1.0f); |
193 | 196 |
194 // 2x display should keep using 2x cursor regardless of the UI scale. | 197 // 2x display should keep using 2x cursor regardless of the UI scale. |
195 UpdateDisplay("800x800*2"); | 198 UpdateDisplay("800x800*2"); |
196 EXPECT_EQ( | 199 EXPECT_EQ( |
197 2.0f, | 200 2.0f, |
198 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 201 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
199 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); | 202 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); |
200 Shell::GetInstance()->display_manager()->SetDisplayUIScale(display_id, 2.0f); | 203 test::DisplayManagerTestApi(Shell::GetInstance()->display_manager()) |
| 204 .SetDisplayUIScale(display_id, 2.0f); |
201 EXPECT_EQ( | 205 EXPECT_EQ( |
202 1.0f, | 206 1.0f, |
203 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 207 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
204 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); | 208 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); |
205 } | 209 } |
206 | 210 |
207 #if defined(USE_X11) | 211 #if defined(USE_X11) |
208 // This test is in ash_unittests because ui_base_unittests does not include | 212 // This test is in ash_unittests because ui_base_unittests does not include |
209 // 2x assets. crbug.com/372541. | 213 // 2x assets. crbug.com/372541. |
210 TEST_F(AshNativeCursorManagerTest, CursorLoaderX11Test) { | 214 TEST_F(AshNativeCursorManagerTest, CursorLoaderX11Test) { |
(...skipping 11 matching lines...) Expand all Loading... |
222 loader.set_scale(2.0f); | 226 loader.set_scale(2.0f); |
223 loader.LoadImageCursor(kCursorId, IDR_AURA_CURSOR_MOVE, gfx::Point()); | 227 loader.LoadImageCursor(kCursorId, IDR_AURA_CURSOR_MOVE, gfx::Point()); |
224 image = loader.GetXcursorImageForTest(kCursorId); | 228 image = loader.GetXcursorImageForTest(kCursorId); |
225 EXPECT_EQ(height * 2, static_cast<int>(image->height)); | 229 EXPECT_EQ(height * 2, static_cast<int>(image->height)); |
226 EXPECT_EQ(width * 2, static_cast<int>(image->width)); | 230 EXPECT_EQ(width * 2, static_cast<int>(image->width)); |
227 } | 231 } |
228 #endif | 232 #endif |
229 | 233 |
230 } // namespace test | 234 } // namespace test |
231 } // namespace ash | 235 } // namespace ash |
OLD | NEW |