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

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

Issue 2833163002: Change ui cursor identifiers to an enum class. (Closed)
Patch Set: OK, it can't be explicit for mac. Created 3 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/resize_shadow_and_cursor_unittest.cc » ('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_util.h" 7 #include "ash/display/display_util.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/test/ash_test_base.h" 9 #include "ash/test/ash_test_base.h"
10 #include "ash/test/cursor_manager_test_api.h" 10 #include "ash/test/cursor_manager_test_api.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 }; 52 };
53 53
54 } // namespace 54 } // namespace
55 55
56 typedef test::AshTestBase AshNativeCursorManagerTest; 56 typedef test::AshTestBase AshNativeCursorManagerTest;
57 57
58 TEST_F(AshNativeCursorManagerTest, LockCursor) { 58 TEST_F(AshNativeCursorManagerTest, LockCursor) {
59 ::wm::CursorManager* cursor_manager = Shell::Get()->cursor_manager(); 59 ::wm::CursorManager* cursor_manager = Shell::Get()->cursor_manager();
60 CursorManagerTestApi test_api(cursor_manager); 60 CursorManagerTestApi test_api(cursor_manager);
61 61
62 cursor_manager->SetCursor(ui::kCursorCopy); 62 cursor_manager->SetCursor(ui::CursorType::kCopy);
63 EXPECT_EQ(ui::kCursorCopy, test_api.GetCurrentCursor().native_type()); 63 EXPECT_EQ(ui::CursorType::kCopy, test_api.GetCurrentCursor().native_type());
64 UpdateDisplay("800x800*2/r"); 64 UpdateDisplay("800x800*2/r");
65 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); 65 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor());
66 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet()); 66 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet());
67 EXPECT_EQ(display::Display::ROTATE_90, test_api.GetCurrentCursorRotation()); 67 EXPECT_EQ(display::Display::ROTATE_90, test_api.GetCurrentCursorRotation());
68 EXPECT_TRUE(test_api.GetCurrentCursor().platform()); 68 EXPECT_TRUE(test_api.GetCurrentCursor().platform());
69 69
70 cursor_manager->LockCursor(); 70 cursor_manager->LockCursor();
71 EXPECT_TRUE(cursor_manager->IsCursorLocked()); 71 EXPECT_TRUE(cursor_manager->IsCursorLocked());
72 72
73 // Cursor type does not change while cursor is locked. 73 // Cursor type does not change while cursor is locked.
74 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet()); 74 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet());
75 cursor_manager->SetCursorSet(ui::CURSOR_SET_NORMAL); 75 cursor_manager->SetCursorSet(ui::CURSOR_SET_NORMAL);
76 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet()); 76 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet());
77 cursor_manager->SetCursorSet(ui::CURSOR_SET_LARGE); 77 cursor_manager->SetCursorSet(ui::CURSOR_SET_LARGE);
78 EXPECT_EQ(ui::CURSOR_SET_LARGE, test_api.GetCurrentCursorSet()); 78 EXPECT_EQ(ui::CURSOR_SET_LARGE, test_api.GetCurrentCursorSet());
79 cursor_manager->SetCursorSet(ui::CURSOR_SET_NORMAL); 79 cursor_manager->SetCursorSet(ui::CURSOR_SET_NORMAL);
80 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet()); 80 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet());
81 81
82 // Cursor type does not change while cursor is locked. 82 // Cursor type does not change while cursor is locked.
83 cursor_manager->SetCursor(ui::kCursorPointer); 83 cursor_manager->SetCursor(ui::CursorType::kPointer);
84 EXPECT_EQ(ui::kCursorCopy, test_api.GetCurrentCursor().native_type()); 84 EXPECT_EQ(ui::CursorType::kCopy, test_api.GetCurrentCursor().native_type());
85 85
86 // Device scale factor and rotation do change even while cursor is locked. 86 // Device scale factor and rotation do change even while cursor is locked.
87 UpdateDisplay("800x800/u"); 87 UpdateDisplay("800x800/u");
88 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); 88 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor());
89 EXPECT_EQ(display::Display::ROTATE_180, test_api.GetCurrentCursorRotation()); 89 EXPECT_EQ(display::Display::ROTATE_180, test_api.GetCurrentCursorRotation());
90 90
91 cursor_manager->UnlockCursor(); 91 cursor_manager->UnlockCursor();
92 EXPECT_FALSE(cursor_manager->IsCursorLocked()); 92 EXPECT_FALSE(cursor_manager->IsCursorLocked());
93 93
94 // Cursor type changes to the one specified while cursor is locked. 94 // Cursor type changes to the one specified while cursor is locked.
95 EXPECT_EQ(ui::kCursorPointer, test_api.GetCurrentCursor().native_type()); 95 EXPECT_EQ(ui::CursorType::kPointer,
96 test_api.GetCurrentCursor().native_type());
96 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); 97 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor());
97 EXPECT_TRUE(test_api.GetCurrentCursor().platform()); 98 EXPECT_TRUE(test_api.GetCurrentCursor().platform());
98 } 99 }
99 100
100 TEST_F(AshNativeCursorManagerTest, SetCursor) { 101 TEST_F(AshNativeCursorManagerTest, SetCursor) {
101 ::wm::CursorManager* cursor_manager = Shell::Get()->cursor_manager(); 102 ::wm::CursorManager* cursor_manager = Shell::Get()->cursor_manager();
102 CursorManagerTestApi test_api(cursor_manager); 103 CursorManagerTestApi test_api(cursor_manager);
103 cursor_manager->SetCursor(ui::kCursorCopy); 104 cursor_manager->SetCursor(ui::CursorType::kCopy);
104 EXPECT_EQ(ui::kCursorCopy, test_api.GetCurrentCursor().native_type()); 105 EXPECT_EQ(ui::CursorType::kCopy, test_api.GetCurrentCursor().native_type());
105 EXPECT_TRUE(test_api.GetCurrentCursor().platform()); 106 EXPECT_TRUE(test_api.GetCurrentCursor().platform());
106 cursor_manager->SetCursor(ui::kCursorPointer); 107 cursor_manager->SetCursor(ui::CursorType::kPointer);
107 EXPECT_EQ(ui::kCursorPointer, test_api.GetCurrentCursor().native_type()); 108 EXPECT_EQ(ui::CursorType::kPointer,
109 test_api.GetCurrentCursor().native_type());
108 EXPECT_TRUE(test_api.GetCurrentCursor().platform()); 110 EXPECT_TRUE(test_api.GetCurrentCursor().platform());
109 } 111 }
110 112
111 TEST_F(AshNativeCursorManagerTest, SetCursorSet) { 113 TEST_F(AshNativeCursorManagerTest, SetCursorSet) {
112 ::wm::CursorManager* cursor_manager = Shell::Get()->cursor_manager(); 114 ::wm::CursorManager* cursor_manager = Shell::Get()->cursor_manager();
113 CursorManagerTestApi test_api(cursor_manager); 115 CursorManagerTestApi test_api(cursor_manager);
114 116
115 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet()); 117 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet());
116 118
117 cursor_manager->SetCursorSet(ui::CURSOR_SET_NORMAL); 119 cursor_manager->SetCursorSet(ui::CURSOR_SET_NORMAL);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 EXPECT_EQ( 174 EXPECT_EQ(
173 1.0f, 175 1.0f,
174 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 176 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
175 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); 177 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor());
176 } 178 }
177 179
178 #if defined(USE_X11) 180 #if defined(USE_X11)
179 // This test is in ash_unittests because ui_base_unittests does not include 181 // This test is in ash_unittests because ui_base_unittests does not include
180 // 2x assets. crbug.com/372541. 182 // 2x assets. crbug.com/372541.
181 TEST_F(AshNativeCursorManagerTest, CursorLoaderX11Test) { 183 TEST_F(AshNativeCursorManagerTest, CursorLoaderX11Test) {
182 const int kCursorId = 1; 184 const ui::CursorType kCursorId = ui::CursorType::kPointer;
183 ui::CursorLoaderX11 loader; 185 ui::CursorLoaderX11 loader;
184 loader.set_scale(1.0f); 186 loader.set_scale(1.0f);
185 187
186 loader.LoadImageCursor(kCursorId, IDR_AURA_CURSOR_MOVE, gfx::Point()); 188 loader.LoadImageCursor(kCursorId, IDR_AURA_CURSOR_MOVE, gfx::Point());
187 const XcursorImage* image = loader.GetXcursorImageForTest(kCursorId); 189 const XcursorImage* image = loader.GetXcursorImageForTest(kCursorId);
188 int height = image->height; 190 int height = image->height;
189 int width = image->width; 191 int width = image->width;
190 loader.UnloadAll(); 192 loader.UnloadAll();
191 193
192 // Load 2x cursor and make sure its size is 2x of the 1x cusor. 194 // Load 2x cursor and make sure its size is 2x of the 1x cusor.
193 loader.set_scale(2.0f); 195 loader.set_scale(2.0f);
194 loader.LoadImageCursor(kCursorId, IDR_AURA_CURSOR_MOVE, gfx::Point()); 196 loader.LoadImageCursor(kCursorId, IDR_AURA_CURSOR_MOVE, gfx::Point());
195 image = loader.GetXcursorImageForTest(kCursorId); 197 image = loader.GetXcursorImageForTest(kCursorId);
196 EXPECT_EQ(height * 2, static_cast<int>(image->height)); 198 EXPECT_EQ(height * 2, static_cast<int>(image->height));
197 EXPECT_EQ(width * 2, static_cast<int>(image->width)); 199 EXPECT_EQ(width * 2, static_cast<int>(image->width));
198 } 200 }
199 #endif 201 #endif
200 202
201 } // namespace test 203 } // namespace test
202 } // namespace ash 204 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/ash_native_cursor_manager.cc ('k') | ash/wm/resize_shadow_and_cursor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698