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/native_cursor_manager_ash.h" | 5 #include "ash/wm/native_cursor_manager_ash.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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 using NativeCursorManagerAshTest = test::AshTestBase; | 56 using NativeCursorManagerAshTest = test::AshTestBase; |
57 | 57 |
58 TEST_F(NativeCursorManagerAshTest, LockCursor) { | 58 TEST_F(NativeCursorManagerAshTest, 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::CursorType::kCopy); | 62 cursor_manager->SetCursor(ui::CursorType::kCopy); |
63 EXPECT_EQ(ui::CursorType::kCopy, 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::CursorSize::kNormal, test_api.GetCurrentCursorSize()); |
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::CursorSize::kNormal, test_api.GetCurrentCursorSize()); |
75 cursor_manager->SetCursorSet(ui::CURSOR_SET_NORMAL); | 75 cursor_manager->SetCursorSize(ui::CursorSize::kNormal); |
76 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet()); | 76 EXPECT_EQ(ui::CursorSize::kNormal, test_api.GetCurrentCursorSize()); |
77 cursor_manager->SetCursorSet(ui::CURSOR_SET_LARGE); | 77 cursor_manager->SetCursorSize(ui::CursorSize::kLarge); |
78 EXPECT_EQ(ui::CURSOR_SET_LARGE, test_api.GetCurrentCursorSet()); | 78 EXPECT_EQ(ui::CursorSize::kLarge, test_api.GetCurrentCursorSize()); |
79 cursor_manager->SetCursorSet(ui::CURSOR_SET_NORMAL); | 79 cursor_manager->SetCursorSize(ui::CursorSize::kNormal); |
80 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet()); | 80 EXPECT_EQ(ui::CursorSize::kNormal, test_api.GetCurrentCursorSize()); |
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::CursorType::kPointer); | 83 cursor_manager->SetCursor(ui::CursorType::kPointer); |
84 EXPECT_EQ(ui::CursorType::kCopy, 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 |
(...skipping 12 matching lines...) Expand all Loading... |
103 CursorManagerTestApi test_api(cursor_manager); | 103 CursorManagerTestApi test_api(cursor_manager); |
104 cursor_manager->SetCursor(ui::CursorType::kCopy); | 104 cursor_manager->SetCursor(ui::CursorType::kCopy); |
105 EXPECT_EQ(ui::CursorType::kCopy, test_api.GetCurrentCursor().native_type()); | 105 EXPECT_EQ(ui::CursorType::kCopy, test_api.GetCurrentCursor().native_type()); |
106 EXPECT_TRUE(test_api.GetCurrentCursor().platform()); | 106 EXPECT_TRUE(test_api.GetCurrentCursor().platform()); |
107 cursor_manager->SetCursor(ui::CursorType::kPointer); | 107 cursor_manager->SetCursor(ui::CursorType::kPointer); |
108 EXPECT_EQ(ui::CursorType::kPointer, | 108 EXPECT_EQ(ui::CursorType::kPointer, |
109 test_api.GetCurrentCursor().native_type()); | 109 test_api.GetCurrentCursor().native_type()); |
110 EXPECT_TRUE(test_api.GetCurrentCursor().platform()); | 110 EXPECT_TRUE(test_api.GetCurrentCursor().platform()); |
111 } | 111 } |
112 | 112 |
113 TEST_F(NativeCursorManagerAshTest, SetCursorSet) { | 113 TEST_F(NativeCursorManagerAshTest, SetCursorSize) { |
114 ::wm::CursorManager* cursor_manager = Shell::Get()->cursor_manager(); | 114 ::wm::CursorManager* cursor_manager = Shell::Get()->cursor_manager(); |
115 CursorManagerTestApi test_api(cursor_manager); | 115 CursorManagerTestApi test_api(cursor_manager); |
116 | 116 |
117 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet()); | 117 EXPECT_EQ(ui::CursorSize::kNormal, test_api.GetCurrentCursorSize()); |
118 | 118 |
119 cursor_manager->SetCursorSet(ui::CURSOR_SET_NORMAL); | 119 cursor_manager->SetCursorSize(ui::CursorSize::kNormal); |
120 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet()); | 120 EXPECT_EQ(ui::CursorSize::kNormal, test_api.GetCurrentCursorSize()); |
121 | 121 |
122 cursor_manager->SetCursorSet(ui::CURSOR_SET_LARGE); | 122 cursor_manager->SetCursorSize(ui::CursorSize::kLarge); |
123 EXPECT_EQ(ui::CURSOR_SET_LARGE, test_api.GetCurrentCursorSet()); | 123 EXPECT_EQ(ui::CursorSize::kLarge, test_api.GetCurrentCursorSize()); |
124 | 124 |
125 cursor_manager->SetCursorSet(ui::CURSOR_SET_NORMAL); | 125 cursor_manager->SetCursorSize(ui::CursorSize::kNormal); |
126 EXPECT_EQ(ui::CURSOR_SET_NORMAL, test_api.GetCurrentCursorSet()); | 126 EXPECT_EQ(ui::CursorSize::kNormal, test_api.GetCurrentCursorSize()); |
127 } | 127 } |
128 | 128 |
129 TEST_F(NativeCursorManagerAshTest, SetDeviceScaleFactorAndRotation) { | 129 TEST_F(NativeCursorManagerAshTest, SetDeviceScaleFactorAndRotation) { |
130 ::wm::CursorManager* cursor_manager = Shell::Get()->cursor_manager(); | 130 ::wm::CursorManager* cursor_manager = Shell::Get()->cursor_manager(); |
131 CursorManagerTestApi test_api(cursor_manager); | 131 CursorManagerTestApi test_api(cursor_manager); |
132 UpdateDisplay("800x100*2"); | 132 UpdateDisplay("800x100*2"); |
133 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); | 133 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); |
134 EXPECT_EQ(display::Display::ROTATE_0, test_api.GetCurrentCursorRotation()); | 134 EXPECT_EQ(display::Display::ROTATE_0, test_api.GetCurrentCursorRotation()); |
135 | 135 |
136 UpdateDisplay("800x100/l"); | 136 UpdateDisplay("800x100/l"); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 loader.set_scale(2.0f); | 195 loader.set_scale(2.0f); |
196 loader.LoadImageCursor(kCursorId, IDR_AURA_CURSOR_MOVE, gfx::Point()); | 196 loader.LoadImageCursor(kCursorId, IDR_AURA_CURSOR_MOVE, gfx::Point()); |
197 image = loader.GetXcursorImageForTest(kCursorId); | 197 image = loader.GetXcursorImageForTest(kCursorId); |
198 EXPECT_EQ(height * 2, static_cast<int>(image->height)); | 198 EXPECT_EQ(height * 2, static_cast<int>(image->height)); |
199 EXPECT_EQ(width * 2, static_cast<int>(image->width)); | 199 EXPECT_EQ(width * 2, static_cast<int>(image->width)); |
200 } | 200 } |
201 #endif | 201 #endif |
202 | 202 |
203 } // namespace test | 203 } // namespace test |
204 } // namespace ash | 204 } // namespace ash |
OLD | NEW |