Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: ash/wm/ash_native_cursor_manager_unittest.cc

Issue 1924703002: Rename gfx::Display/Screen to display::Display/Screen in ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/wm/ash_native_cursor_manager.cc ('k') | ash/wm/aura/wm_window_aura.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "ash/test/ash_test_base.h" 11 #include "ash/test/ash_test_base.h"
12 #include "ash/test/cursor_manager_test_api.h" 12 #include "ash/test/cursor_manager_test_api.h"
13 #include "ui/aura/test/aura_test_utils.h" 13 #include "ui/aura/test/aura_test_utils.h"
14 #include "ui/aura/test/test_window_delegate.h" 14 #include "ui/aura/test/test_window_delegate.h"
15 #include "ui/aura/test/test_windows.h" 15 #include "ui/aura/test/test_windows.h"
16 #include "ui/aura/window.h" 16 #include "ui/aura/window.h"
17 #include "ui/aura/window_event_dispatcher.h" 17 #include "ui/aura/window_event_dispatcher.h"
18 #include "ui/base/cursor/image_cursors.h" 18 #include "ui/base/cursor/image_cursors.h"
19 #include "ui/gfx/screen.h" 19 #include "ui/display/screen.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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 CursorManagerTestApi test_api(cursor_manager); 71 CursorManagerTestApi test_api(cursor_manager);
72 72
73 #if defined(OS_WIN) 73 #if defined(OS_WIN)
74 ui::CursorLoaderWin::SetCursorResourceModule(L"ash_unittests.exe"); 74 ui::CursorLoaderWin::SetCursorResourceModule(L"ash_unittests.exe");
75 #endif 75 #endif
76 cursor_manager->SetCursor(ui::kCursorCopy); 76 cursor_manager->SetCursor(ui::kCursorCopy);
77 EXPECT_EQ(ui::kCursorCopy, test_api.GetCurrentCursor().native_type()); 77 EXPECT_EQ(ui::kCursorCopy, test_api.GetCurrentCursor().native_type());
78 UpdateDisplay("800x800*2/r"); 78 UpdateDisplay("800x800*2/r");
79 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); 79 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor());
80 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet()); 80 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet());
81 EXPECT_EQ(gfx::Display::ROTATE_90, test_api.GetCurrentCursorRotation()); 81 EXPECT_EQ(display::Display::ROTATE_90, test_api.GetCurrentCursorRotation());
82 EXPECT_TRUE(test_api.GetCurrentCursor().platform()); 82 EXPECT_TRUE(test_api.GetCurrentCursor().platform());
83 83
84 cursor_manager->LockCursor(); 84 cursor_manager->LockCursor();
85 EXPECT_TRUE(cursor_manager->IsCursorLocked()); 85 EXPECT_TRUE(cursor_manager->IsCursorLocked());
86 86
87 // Cursor type does not change while cursor is locked. 87 // Cursor type does not change while cursor is locked.
88 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet()); 88 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet());
89 cursor_manager->SetCursorSet(ui::CURSOR_SET_NORMAL); 89 cursor_manager->SetCursorSet(ui::CURSOR_SET_NORMAL);
90 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet()); 90 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet());
91 cursor_manager->SetCursorSet(ui::CURSOR_SET_LARGE); 91 cursor_manager->SetCursorSet(ui::CURSOR_SET_LARGE);
92 EXPECT_EQ(ui::CURSOR_SET_LARGE, test_api.GetCurrentCursorSet()); 92 EXPECT_EQ(ui::CURSOR_SET_LARGE, test_api.GetCurrentCursorSet());
93 cursor_manager->SetCursorSet(ui::CURSOR_SET_NORMAL); 93 cursor_manager->SetCursorSet(ui::CURSOR_SET_NORMAL);
94 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet()); 94 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet());
95 95
96 // Cursor type does not change while cursor is locked. 96 // Cursor type does not change while cursor is locked.
97 cursor_manager->SetCursor(ui::kCursorPointer); 97 cursor_manager->SetCursor(ui::kCursorPointer);
98 EXPECT_EQ(ui::kCursorCopy, test_api.GetCurrentCursor().native_type()); 98 EXPECT_EQ(ui::kCursorCopy, test_api.GetCurrentCursor().native_type());
99 99
100 // Device scale factor and rotation do change even while cursor is locked. 100 // Device scale factor and rotation do change even while cursor is locked.
101 UpdateDisplay("800x800/u"); 101 UpdateDisplay("800x800/u");
102 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); 102 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor());
103 EXPECT_EQ(gfx::Display::ROTATE_180, test_api.GetCurrentCursorRotation()); 103 EXPECT_EQ(display::Display::ROTATE_180, test_api.GetCurrentCursorRotation());
104 104
105 cursor_manager->UnlockCursor(); 105 cursor_manager->UnlockCursor();
106 EXPECT_FALSE(cursor_manager->IsCursorLocked()); 106 EXPECT_FALSE(cursor_manager->IsCursorLocked());
107 107
108 // Cursor type changes to the one specified while cursor is locked. 108 // Cursor type changes to the one specified while cursor is locked.
109 EXPECT_EQ(ui::kCursorPointer, test_api.GetCurrentCursor().native_type()); 109 EXPECT_EQ(ui::kCursorPointer, test_api.GetCurrentCursor().native_type());
110 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); 110 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor());
111 EXPECT_TRUE(test_api.GetCurrentCursor().platform()); 111 EXPECT_TRUE(test_api.GetCurrentCursor().platform());
112 } 112 }
113 113
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 #define MAYBE_SetDeviceScaleFactorAndRotation \ 146 #define MAYBE_SetDeviceScaleFactorAndRotation \
147 DISABLED_SetDeviceScaleFactorAndRotation 147 DISABLED_SetDeviceScaleFactorAndRotation
148 #else 148 #else
149 #define MAYBE_SetDeviceScaleFactorAndRotation SetDeviceScaleFactorAndRotation 149 #define MAYBE_SetDeviceScaleFactorAndRotation SetDeviceScaleFactorAndRotation
150 #endif 150 #endif
151 TEST_F(AshNativeCursorManagerTest, MAYBE_SetDeviceScaleFactorAndRotation) { 151 TEST_F(AshNativeCursorManagerTest, MAYBE_SetDeviceScaleFactorAndRotation) {
152 ::wm::CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager(); 152 ::wm::CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager();
153 CursorManagerTestApi test_api(cursor_manager); 153 CursorManagerTestApi test_api(cursor_manager);
154 UpdateDisplay("800x100*2"); 154 UpdateDisplay("800x100*2");
155 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); 155 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor());
156 EXPECT_EQ(gfx::Display::ROTATE_0, test_api.GetCurrentCursorRotation()); 156 EXPECT_EQ(display::Display::ROTATE_0, test_api.GetCurrentCursorRotation());
157 157
158 UpdateDisplay("800x100/l"); 158 UpdateDisplay("800x100/l");
159 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); 159 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor());
160 EXPECT_EQ(gfx::Display::ROTATE_270, test_api.GetCurrentCursorRotation()); 160 EXPECT_EQ(display::Display::ROTATE_270, test_api.GetCurrentCursorRotation());
161 } 161 }
162 162
163 #if defined(OS_CHROMEOS) 163 #if defined(OS_CHROMEOS)
164 // TODO(oshima): crbug.com/143619 164 // TODO(oshima): crbug.com/143619
165 TEST_F(AshNativeCursorManagerTest, FractionalScale) { 165 TEST_F(AshNativeCursorManagerTest, FractionalScale) {
166 ::wm::CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager(); 166 ::wm::CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager();
167 CursorManagerTestApi test_api(cursor_manager); 167 CursorManagerTestApi test_api(cursor_manager);
168 // Cursor should use the resource scale factor. 168 // Cursor should use the resource scale factor.
169 UpdateDisplay("800x100*1.25"); 169 UpdateDisplay("800x100*1.25");
170 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); 170 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor());
171 } 171 }
172 #endif 172 #endif
173 173
174 #if defined(OS_WIN) && !defined(USE_ASH) 174 #if defined(OS_WIN) && !defined(USE_ASH)
175 // TODO(msw): Times out on Windows. http://crbug.com/584038 175 // TODO(msw): Times out on Windows. http://crbug.com/584038
176 #define MAYBE_UIScaleShouldNotChangeCursor DISABLED_UIScaleShouldNotChangeCursor 176 #define MAYBE_UIScaleShouldNotChangeCursor DISABLED_UIScaleShouldNotChangeCursor
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 = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); 181 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
182 gfx::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 SetDisplayUIScale(display_id, 0.5f); 187 SetDisplayUIScale(display_id, 0.5f);
188 EXPECT_EQ( 188 EXPECT_EQ(
189 1.0f, 189 1.0f,
190 gfx::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 190 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
191 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); 191 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor());
192 192
193 SetDisplayUIScale(display_id, 1.0f); 193 SetDisplayUIScale(display_id, 1.0f);
194 194
195 // 2x display should keep using 2x cursor regardless of the UI scale. 195 // 2x display should keep using 2x cursor regardless of the UI scale.
196 UpdateDisplay("800x800*2"); 196 UpdateDisplay("800x800*2");
197 EXPECT_EQ( 197 EXPECT_EQ(
198 2.0f, 198 2.0f,
199 gfx::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 199 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
200 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); 200 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor());
201 SetDisplayUIScale(display_id, 2.0f); 201 SetDisplayUIScale(display_id, 2.0f);
202 EXPECT_EQ( 202 EXPECT_EQ(
203 1.0f, 203 1.0f,
204 gfx::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 204 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
205 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); 205 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor());
206 } 206 }
207 207
208 #if defined(USE_X11) 208 #if defined(USE_X11)
209 // This test is in ash_unittests because ui_base_unittests does not include 209 // This test is in ash_unittests because ui_base_unittests does not include
210 // 2x assets. crbug.com/372541. 210 // 2x assets. crbug.com/372541.
211 TEST_F(AshNativeCursorManagerTest, CursorLoaderX11Test) { 211 TEST_F(AshNativeCursorManagerTest, CursorLoaderX11Test) {
212 const int kCursorId = 1; 212 const int kCursorId = 1;
213 ui::CursorLoaderX11 loader; 213 ui::CursorLoaderX11 loader;
214 loader.set_scale(1.0f); 214 loader.set_scale(1.0f);
215 215
216 loader.LoadImageCursor(kCursorId, IDR_AURA_CURSOR_MOVE, gfx::Point()); 216 loader.LoadImageCursor(kCursorId, IDR_AURA_CURSOR_MOVE, gfx::Point());
217 const XcursorImage* image = loader.GetXcursorImageForTest(kCursorId); 217 const XcursorImage* image = loader.GetXcursorImageForTest(kCursorId);
218 int height = image->height; 218 int height = image->height;
219 int width = image->width; 219 int width = image->width;
220 loader.UnloadAll(); 220 loader.UnloadAll();
221 221
222 // Load 2x cursor and make sure its size is 2x of the 1x cusor. 222 // Load 2x cursor and make sure its size is 2x of the 1x cusor.
223 loader.set_scale(2.0f); 223 loader.set_scale(2.0f);
224 loader.LoadImageCursor(kCursorId, IDR_AURA_CURSOR_MOVE, gfx::Point()); 224 loader.LoadImageCursor(kCursorId, IDR_AURA_CURSOR_MOVE, gfx::Point());
225 image = loader.GetXcursorImageForTest(kCursorId); 225 image = loader.GetXcursorImageForTest(kCursorId);
226 EXPECT_EQ(height * 2, static_cast<int>(image->height)); 226 EXPECT_EQ(height * 2, static_cast<int>(image->height));
227 EXPECT_EQ(width * 2, static_cast<int>(image->width)); 227 EXPECT_EQ(width * 2, static_cast<int>(image->width));
228 } 228 }
229 #endif 229 #endif
230 230
231 } // namespace test 231 } // namespace test
232 } // namespace ash 232 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/ash_native_cursor_manager.cc ('k') | ash/wm/aura/wm_window_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698