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