| 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/display/display_util.h" | 9 #include "ash/display/display_util.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 TEST_F(AshNativeCursorManagerTest, FractionalScale) { | 152 TEST_F(AshNativeCursorManagerTest, FractionalScale) { |
| 153 ::wm::CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager(); | 153 ::wm::CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager(); |
| 154 CursorManagerTestApi test_api(cursor_manager); | 154 CursorManagerTestApi test_api(cursor_manager); |
| 155 // Cursor should use the resource scale factor. | 155 // Cursor should use the resource scale factor. |
| 156 UpdateDisplay("800x100*1.25"); | 156 UpdateDisplay("800x100*1.25"); |
| 157 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); | 157 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); |
| 158 } | 158 } |
| 159 #endif | 159 #endif |
| 160 | 160 |
| 161 TEST_F(AshNativeCursorManagerTest, UIScaleShouldNotChangeCursor) { | 161 TEST_F(AshNativeCursorManagerTest, UIScaleShouldNotChangeCursor) { |
| 162 int64_t display_id = Shell::GetScreen()->GetPrimaryDisplay().id(); | 162 int64_t display_id = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 163 gfx::Display::SetInternalDisplayId(display_id); | 163 gfx::Display::SetInternalDisplayId(display_id); |
| 164 | 164 |
| 165 ::wm::CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager(); | 165 ::wm::CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager(); |
| 166 CursorManagerTestApi test_api(cursor_manager); | 166 CursorManagerTestApi test_api(cursor_manager); |
| 167 | 167 |
| 168 SetDisplayUIScale(display_id, 0.5f); | 168 SetDisplayUIScale(display_id, 0.5f); |
| 169 EXPECT_EQ(1.0f, | 169 EXPECT_EQ( |
| 170 Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 170 1.0f, |
| 171 gfx::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
| 171 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); | 172 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); |
| 172 | 173 |
| 173 SetDisplayUIScale(display_id, 1.0f); | 174 SetDisplayUIScale(display_id, 1.0f); |
| 174 | 175 |
| 175 // 2x display should keep using 2x cursor regardless of the UI scale. | 176 // 2x display should keep using 2x cursor regardless of the UI scale. |
| 176 UpdateDisplay("800x800*2"); | 177 UpdateDisplay("800x800*2"); |
| 177 EXPECT_EQ(2.0f, | 178 EXPECT_EQ( |
| 178 Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 179 2.0f, |
| 180 gfx::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
| 179 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); | 181 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); |
| 180 SetDisplayUIScale(display_id, 2.0f); | 182 SetDisplayUIScale(display_id, 2.0f); |
| 181 EXPECT_EQ(1.0f, | 183 EXPECT_EQ( |
| 182 Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 184 1.0f, |
| 185 gfx::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
| 183 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); | 186 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); |
| 184 } | 187 } |
| 185 | 188 |
| 186 #if defined(USE_X11) | 189 #if defined(USE_X11) |
| 187 // This test is in ash_unittests because ui_base_unittests does not include | 190 // This test is in ash_unittests because ui_base_unittests does not include |
| 188 // 2x assets. crbug.com/372541. | 191 // 2x assets. crbug.com/372541. |
| 189 TEST_F(AshNativeCursorManagerTest, CursorLoaderX11Test) { | 192 TEST_F(AshNativeCursorManagerTest, CursorLoaderX11Test) { |
| 190 const int kCursorId = 1; | 193 const int kCursorId = 1; |
| 191 ui::CursorLoaderX11 loader; | 194 ui::CursorLoaderX11 loader; |
| 192 loader.set_scale(1.0f); | 195 loader.set_scale(1.0f); |
| 193 | 196 |
| 194 loader.LoadImageCursor(kCursorId, IDR_AURA_CURSOR_MOVE, gfx::Point()); | 197 loader.LoadImageCursor(kCursorId, IDR_AURA_CURSOR_MOVE, gfx::Point()); |
| 195 const XcursorImage* image = loader.GetXcursorImageForTest(kCursorId); | 198 const XcursorImage* image = loader.GetXcursorImageForTest(kCursorId); |
| 196 int height = image->height; | 199 int height = image->height; |
| 197 int width = image->width; | 200 int width = image->width; |
| 198 loader.UnloadAll(); | 201 loader.UnloadAll(); |
| 199 | 202 |
| 200 // Load 2x cursor and make sure its size is 2x of the 1x cusor. | 203 // Load 2x cursor and make sure its size is 2x of the 1x cusor. |
| 201 loader.set_scale(2.0f); | 204 loader.set_scale(2.0f); |
| 202 loader.LoadImageCursor(kCursorId, IDR_AURA_CURSOR_MOVE, gfx::Point()); | 205 loader.LoadImageCursor(kCursorId, IDR_AURA_CURSOR_MOVE, gfx::Point()); |
| 203 image = loader.GetXcursorImageForTest(kCursorId); | 206 image = loader.GetXcursorImageForTest(kCursorId); |
| 204 EXPECT_EQ(height * 2, static_cast<int>(image->height)); | 207 EXPECT_EQ(height * 2, static_cast<int>(image->height)); |
| 205 EXPECT_EQ(width * 2, static_cast<int>(image->width)); | 208 EXPECT_EQ(width * 2, static_cast<int>(image->width)); |
| 206 } | 209 } |
| 207 #endif | 210 #endif |
| 208 | 211 |
| 209 } // namespace test | 212 } // namespace test |
| 210 } // namespace ash | 213 } // namespace ash |
| OLD | NEW |