| 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" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 #endif | 158 #endif |
| 159 | 159 |
| 160 TEST_F(AshNativeCursorManagerTest, UIScaleShouldNotChangeCursor) { | 160 TEST_F(AshNativeCursorManagerTest, UIScaleShouldNotChangeCursor) { |
| 161 int64 display_id = Shell::GetScreen()->GetPrimaryDisplay().id(); | 161 int64 display_id = Shell::GetScreen()->GetPrimaryDisplay().id(); |
| 162 gfx::Display::SetInternalDisplayId(display_id); | 162 gfx::Display::SetInternalDisplayId(display_id); |
| 163 | 163 |
| 164 ::wm::CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager(); | 164 ::wm::CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager(); |
| 165 CursorManagerTestApi test_api(cursor_manager); | 165 CursorManagerTestApi test_api(cursor_manager); |
| 166 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 166 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 167 | 167 |
| 168 DisplayInfo::SetAllowUpgradeToHighDPI(false); | |
| 169 display_manager->SetDisplayUIScale(display_id, 0.5f); | 168 display_manager->SetDisplayUIScale(display_id, 0.5f); |
| 170 EXPECT_EQ(1.0f, | 169 EXPECT_EQ(1.0f, |
| 171 Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 170 Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
| 172 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); | 171 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); |
| 173 | 172 |
| 174 display_manager->SetDisplayUIScale(display_id, 1.0f); | 173 display_manager->SetDisplayUIScale(display_id, 1.0f); |
| 175 | 174 |
| 176 DisplayInfo::SetAllowUpgradeToHighDPI(true); | |
| 177 // 1x display should keep using 1x cursor even if the DSF is upgraded to 2x. | |
| 178 display_manager->SetDisplayUIScale(display_id, 0.5f); | |
| 179 EXPECT_EQ(2.0f, | |
| 180 Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | |
| 181 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); | |
| 182 | |
| 183 // 2x display should keep using 2x cursor regardless of the UI scale. | 175 // 2x display should keep using 2x cursor regardless of the UI scale. |
| 184 UpdateDisplay("800x800*2"); | 176 UpdateDisplay("800x800*2"); |
| 185 EXPECT_EQ(2.0f, | 177 EXPECT_EQ(2.0f, |
| 186 Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 178 Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
| 187 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); | 179 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); |
| 188 display_manager->SetDisplayUIScale(display_id, 2.0f); | 180 display_manager->SetDisplayUIScale(display_id, 2.0f); |
| 189 EXPECT_EQ(1.0f, | 181 EXPECT_EQ(1.0f, |
| 190 Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 182 Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
| 191 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); | 183 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); |
| 192 } | 184 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 209 loader.set_scale(2.0f); | 201 loader.set_scale(2.0f); |
| 210 loader.LoadImageCursor(kCursorId, IDR_AURA_CURSOR_MOVE, gfx::Point()); | 202 loader.LoadImageCursor(kCursorId, IDR_AURA_CURSOR_MOVE, gfx::Point()); |
| 211 image = loader.GetXcursorImageForTest(kCursorId); | 203 image = loader.GetXcursorImageForTest(kCursorId); |
| 212 EXPECT_EQ(height * 2, static_cast<int>(image->height)); | 204 EXPECT_EQ(height * 2, static_cast<int>(image->height)); |
| 213 EXPECT_EQ(width * 2, static_cast<int>(image->width)); | 205 EXPECT_EQ(width * 2, static_cast<int>(image->width)); |
| 214 } | 206 } |
| 215 #endif | 207 #endif |
| 216 | 208 |
| 217 } // namespace test | 209 } // namespace test |
| 218 } // namespace ash | 210 } // namespace ash |
| OLD | NEW |