| 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_info.h" | 7 #include "ash/display/display_info.h" |
| 8 #include "ash/display/display_manager.h" | 8 #include "ash/display/display_manager.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 "ui/aura/test/aura_test_utils.h" | 12 #include "ui/aura/test/aura_test_utils.h" |
| 13 #include "ui/aura/test/test_window_delegate.h" | 13 #include "ui/aura/test/test_window_delegate.h" |
| 14 #include "ui/aura/test/test_windows.h" | 14 #include "ui/aura/test/test_windows.h" |
| 15 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
| 16 #include "ui/aura/window_event_dispatcher.h" | 16 #include "ui/aura/window_event_dispatcher.h" |
| 17 #include "ui/base/cursor/image_cursors.h" | 17 #include "ui/base/cursor/image_cursors.h" |
| 18 #include "ui/gfx/screen.h" | 18 #include "ui/gfx/screen.h" |
| 19 | 19 |
| 20 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
| 21 #include "base/win/windows_version.h" | 21 #include "base/win/windows_version.h" |
| 22 #include "ui/base/cursor/cursor_loader_win.h" | 22 #include "ui/base/cursor/cursor_loader_win.h" |
| 23 #endif | 23 #endif |
| 24 | 24 |
| 25 #if defined(USE_X11) |
| 26 #include "grit/ui_resources.h" |
| 27 #include "ui/base/cursor/cursor_loader_x11.h" |
| 28 #endif |
| 29 |
| 25 namespace ash { | 30 namespace ash { |
| 26 namespace test { | 31 namespace test { |
| 27 | 32 |
| 28 namespace { | 33 namespace { |
| 29 | 34 |
| 30 // A delegate for recording a mouse event location. | 35 // A delegate for recording a mouse event location. |
| 31 class MouseEventLocationDelegate : public aura::test::TestWindowDelegate { | 36 class MouseEventLocationDelegate : public aura::test::TestWindowDelegate { |
| 32 public: | 37 public: |
| 33 MouseEventLocationDelegate() {} | 38 MouseEventLocationDelegate() {} |
| 34 virtual ~MouseEventLocationDelegate() {} | 39 virtual ~MouseEventLocationDelegate() {} |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 UpdateDisplay("800x800*2"); | 173 UpdateDisplay("800x800*2"); |
| 169 EXPECT_EQ(2.0f, | 174 EXPECT_EQ(2.0f, |
| 170 Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 175 Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
| 171 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); | 176 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); |
| 172 display_manager->SetDisplayUIScale(display_id, 2.0f); | 177 display_manager->SetDisplayUIScale(display_id, 2.0f); |
| 173 EXPECT_EQ(1.0f, | 178 EXPECT_EQ(1.0f, |
| 174 Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 179 Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
| 175 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); | 180 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); |
| 176 } | 181 } |
| 177 | 182 |
| 183 #if defined(USE_X11) |
| 184 // This test is in ash_unittests becuase ui_unittests does not include |
| 185 // 2x assets. crbug.com/372541. |
| 186 TEST_F(AshNativeCursorManagerTest, CursorLoaderX11Test) { |
| 187 const int kCursorId = 1; |
| 188 ui::CursorLoaderX11 loader; |
| 189 loader.set_scale(1.0f); |
| 190 |
| 191 loader.LoadImageCursor(kCursorId, IDR_AURA_CURSOR_MOVE, gfx::Point()); |
| 192 const XcursorImage* image = loader.GetXcursorImageForTest(kCursorId); |
| 193 int height = image->height; |
| 194 int width = image->width; |
| 195 loader.UnloadAll(); |
| 196 |
| 197 // Load 2x cursor and make sure its size is 2x of the 1x cusor. |
| 198 loader.set_scale(2.0f); |
| 199 loader.LoadImageCursor(kCursorId, IDR_AURA_CURSOR_MOVE, gfx::Point()); |
| 200 image = loader.GetXcursorImageForTest(kCursorId); |
| 201 EXPECT_EQ(height * 2, static_cast<int>(image->height)); |
| 202 EXPECT_EQ(width * 2, static_cast<int>(image->width)); |
| 203 } |
| 204 #endif |
| 205 |
| 178 } // namespace test | 206 } // namespace test |
| 179 } // namespace ash | 207 } // namespace ash |
| OLD | NEW |