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_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 Loading... |
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::COPY); |
63 EXPECT_EQ(ui::kCursorCopy, test_api.GetCurrentCursor().native_type()); | 63 EXPECT_EQ(ui::CursorType::COPY, 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::POINTER); |
84 EXPECT_EQ(ui::kCursorCopy, test_api.GetCurrentCursor().native_type()); | 84 EXPECT_EQ(ui::CursorType::COPY, 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::POINTER, test_api.GetCurrentCursor().native_type()); |
96 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); | 96 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); |
97 EXPECT_TRUE(test_api.GetCurrentCursor().platform()); | 97 EXPECT_TRUE(test_api.GetCurrentCursor().platform()); |
98 } | 98 } |
99 | 99 |
100 TEST_F(AshNativeCursorManagerTest, SetCursor) { | 100 TEST_F(AshNativeCursorManagerTest, SetCursor) { |
101 ::wm::CursorManager* cursor_manager = Shell::Get()->cursor_manager(); | 101 ::wm::CursorManager* cursor_manager = Shell::Get()->cursor_manager(); |
102 CursorManagerTestApi test_api(cursor_manager); | 102 CursorManagerTestApi test_api(cursor_manager); |
103 cursor_manager->SetCursor(ui::kCursorCopy); | 103 cursor_manager->SetCursor(ui::CursorType::COPY); |
104 EXPECT_EQ(ui::kCursorCopy, test_api.GetCurrentCursor().native_type()); | 104 EXPECT_EQ(ui::CursorType::COPY, test_api.GetCurrentCursor().native_type()); |
105 EXPECT_TRUE(test_api.GetCurrentCursor().platform()); | 105 EXPECT_TRUE(test_api.GetCurrentCursor().platform()); |
106 cursor_manager->SetCursor(ui::kCursorPointer); | 106 cursor_manager->SetCursor(ui::CursorType::POINTER); |
107 EXPECT_EQ(ui::kCursorPointer, test_api.GetCurrentCursor().native_type()); | 107 EXPECT_EQ(ui::CursorType::POINTER, test_api.GetCurrentCursor().native_type()); |
108 EXPECT_TRUE(test_api.GetCurrentCursor().platform()); | 108 EXPECT_TRUE(test_api.GetCurrentCursor().platform()); |
109 } | 109 } |
110 | 110 |
111 TEST_F(AshNativeCursorManagerTest, SetCursorSet) { | 111 TEST_F(AshNativeCursorManagerTest, SetCursorSet) { |
112 ::wm::CursorManager* cursor_manager = Shell::Get()->cursor_manager(); | 112 ::wm::CursorManager* cursor_manager = Shell::Get()->cursor_manager(); |
113 CursorManagerTestApi test_api(cursor_manager); | 113 CursorManagerTestApi test_api(cursor_manager); |
114 | 114 |
115 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet()); | 115 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet()); |
116 | 116 |
117 cursor_manager->SetCursorSet(ui::CURSOR_SET_NORMAL); | 117 cursor_manager->SetCursorSet(ui::CURSOR_SET_NORMAL); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 EXPECT_EQ( | 172 EXPECT_EQ( |
173 1.0f, | 173 1.0f, |
174 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 174 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
175 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); | 175 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); |
176 } | 176 } |
177 | 177 |
178 #if defined(USE_X11) | 178 #if defined(USE_X11) |
179 // This test is in ash_unittests because ui_base_unittests does not include | 179 // This test is in ash_unittests because ui_base_unittests does not include |
180 // 2x assets. crbug.com/372541. | 180 // 2x assets. crbug.com/372541. |
181 TEST_F(AshNativeCursorManagerTest, CursorLoaderX11Test) { | 181 TEST_F(AshNativeCursorManagerTest, CursorLoaderX11Test) { |
182 const int kCursorId = 1; | 182 const ui::CursorType kCursorId = ui::CursorType::POINTER; |
183 ui::CursorLoaderX11 loader; | 183 ui::CursorLoaderX11 loader; |
184 loader.set_scale(1.0f); | 184 loader.set_scale(1.0f); |
185 | 185 |
186 loader.LoadImageCursor(kCursorId, IDR_AURA_CURSOR_MOVE, gfx::Point()); | 186 loader.LoadImageCursor(kCursorId, IDR_AURA_CURSOR_MOVE, gfx::Point()); |
187 const XcursorImage* image = loader.GetXcursorImageForTest(kCursorId); | 187 const XcursorImage* image = loader.GetXcursorImageForTest(kCursorId); |
188 int height = image->height; | 188 int height = image->height; |
189 int width = image->width; | 189 int width = image->width; |
190 loader.UnloadAll(); | 190 loader.UnloadAll(); |
191 | 191 |
192 // Load 2x cursor and make sure its size is 2x of the 1x cusor. | 192 // Load 2x cursor and make sure its size is 2x of the 1x cusor. |
193 loader.set_scale(2.0f); | 193 loader.set_scale(2.0f); |
194 loader.LoadImageCursor(kCursorId, IDR_AURA_CURSOR_MOVE, gfx::Point()); | 194 loader.LoadImageCursor(kCursorId, IDR_AURA_CURSOR_MOVE, gfx::Point()); |
195 image = loader.GetXcursorImageForTest(kCursorId); | 195 image = loader.GetXcursorImageForTest(kCursorId); |
196 EXPECT_EQ(height * 2, static_cast<int>(image->height)); | 196 EXPECT_EQ(height * 2, static_cast<int>(image->height)); |
197 EXPECT_EQ(width * 2, static_cast<int>(image->width)); | 197 EXPECT_EQ(width * 2, static_cast<int>(image->width)); |
198 } | 198 } |
199 #endif | 199 #endif |
200 | 200 |
201 } // namespace test | 201 } // namespace test |
202 } // namespace ash | 202 } // namespace ash |
OLD | NEW |