OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ui/wm/core/cursor_manager.h" | 5 #include "ui/wm/core/cursor_manager.h" |
6 | 6 |
7 #include "ui/aura/client/cursor_client_observer.h" | 7 #include "ui/aura/client/cursor_client_observer.h" |
8 #include "ui/aura/test/aura_test_base.h" | 8 #include "ui/aura/test/aura_test_base.h" |
9 #include "ui/wm/core/native_cursor_manager.h" | 9 #include "ui/wm/core/native_cursor_manager.h" |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 bool enabled, | 33 bool enabled, |
34 wm::NativeCursorManagerDelegate* delegate) OVERRIDE { | 34 wm::NativeCursorManagerDelegate* delegate) OVERRIDE { |
35 delegate->CommitMouseEventsEnabled(enabled); | 35 delegate->CommitMouseEventsEnabled(enabled); |
36 } | 36 } |
37 | 37 |
38 virtual void SetCursorSet( | 38 virtual void SetCursorSet( |
39 ui::CursorSetType cursor_set, | 39 ui::CursorSetType cursor_set, |
40 wm::NativeCursorManagerDelegate* delegate) OVERRIDE { | 40 wm::NativeCursorManagerDelegate* delegate) OVERRIDE { |
41 delegate->CommitCursorSet(cursor_set); | 41 delegate->CommitCursorSet(cursor_set); |
42 } | 42 } |
43 | |
44 virtual void SetScale( | |
45 float scale, | |
46 wm::NativeCursorManagerDelegate* delegate) OVERRIDE { | |
47 delegate->CommitScale(scale); | |
48 } | |
49 }; | 43 }; |
50 | 44 |
51 } // namespace | 45 } // namespace |
52 | 46 |
53 class CursorManagerTest : public aura::test::AuraTestBase { | 47 class CursorManagerTest : public aura::test::AuraTestBase { |
54 protected: | 48 protected: |
55 CursorManagerTest() | 49 CursorManagerTest() |
56 : delegate_(new TestingCursorManager), | 50 : delegate_(new TestingCursorManager), |
57 cursor_manager_(scoped_ptr<wm::NativeCursorManager>( | 51 cursor_manager_(scoped_ptr<wm::NativeCursorManager>( |
58 delegate_)) { | 52 delegate_)) { |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 cursor_manager_.SetCursorSet(ui::CURSOR_SET_NORMAL); | 184 cursor_manager_.SetCursorSet(ui::CURSOR_SET_NORMAL); |
191 EXPECT_EQ(ui::CURSOR_SET_NORMAL, cursor_manager_.GetCursorSet()); | 185 EXPECT_EQ(ui::CURSOR_SET_NORMAL, cursor_manager_.GetCursorSet()); |
192 | 186 |
193 cursor_manager_.SetCursorSet(ui::CURSOR_SET_LARGE); | 187 cursor_manager_.SetCursorSet(ui::CURSOR_SET_LARGE); |
194 EXPECT_EQ(ui::CURSOR_SET_LARGE, cursor_manager_.GetCursorSet()); | 188 EXPECT_EQ(ui::CURSOR_SET_LARGE, cursor_manager_.GetCursorSet()); |
195 | 189 |
196 cursor_manager_.SetCursorSet(ui::CURSOR_SET_NORMAL); | 190 cursor_manager_.SetCursorSet(ui::CURSOR_SET_NORMAL); |
197 EXPECT_EQ(ui::CURSOR_SET_NORMAL, cursor_manager_.GetCursorSet()); | 191 EXPECT_EQ(ui::CURSOR_SET_NORMAL, cursor_manager_.GetCursorSet()); |
198 } | 192 } |
199 | 193 |
200 TEST_F(CursorManagerTest, SetScale) { | |
201 EXPECT_EQ(1.f, cursor_manager_.GetScale()); | |
202 cursor_manager_.SetScale(2.f); | |
203 EXPECT_EQ(2.f, cursor_manager_.GetScale()); | |
204 | |
205 // Cusror scale does change even while cursor is locked. | |
206 cursor_manager_.LockCursor(); | |
207 EXPECT_EQ(2.f, cursor_manager_.GetScale()); | |
208 cursor_manager_.SetScale(2.5f); | |
209 EXPECT_EQ(2.5f, cursor_manager_.GetScale()); | |
210 cursor_manager_.UnlockCursor(); | |
211 | |
212 EXPECT_EQ(2.5f, cursor_manager_.GetScale()); | |
213 cursor_manager_.SetScale(1.f); | |
214 EXPECT_EQ(1.f, cursor_manager_.GetScale()); | |
215 } | |
216 | |
217 TEST_F(CursorManagerTest, IsMouseEventsEnabled) { | 194 TEST_F(CursorManagerTest, IsMouseEventsEnabled) { |
218 cursor_manager_.EnableMouseEvents(); | 195 cursor_manager_.EnableMouseEvents(); |
219 EXPECT_TRUE(cursor_manager_.IsMouseEventsEnabled()); | 196 EXPECT_TRUE(cursor_manager_.IsMouseEventsEnabled()); |
220 cursor_manager_.DisableMouseEvents(); | 197 cursor_manager_.DisableMouseEvents(); |
221 EXPECT_FALSE(cursor_manager_.IsMouseEventsEnabled()); | 198 EXPECT_FALSE(cursor_manager_.IsMouseEventsEnabled()); |
222 } | 199 } |
223 | 200 |
224 // Verifies that the mouse events enable state changes correctly when | 201 // Verifies that the mouse events enable state changes correctly when |
225 // ShowCursor/HideCursor and EnableMouseEvents/DisableMouseEvents are used | 202 // ShowCursor/HideCursor and EnableMouseEvents/DisableMouseEvents are used |
226 // together. | 203 // together. |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 EXPECT_FALSE(observer_a.is_cursor_visible()); | 321 EXPECT_FALSE(observer_a.is_cursor_visible()); |
345 | 322 |
346 // Show the cursor using ShowCursor(). | 323 // Show the cursor using ShowCursor(). |
347 observer_a.reset(); | 324 observer_a.reset(); |
348 observer_b.reset(); | 325 observer_b.reset(); |
349 cursor_manager_.ShowCursor(); | 326 cursor_manager_.ShowCursor(); |
350 EXPECT_TRUE(observer_a.did_visibility_change()); | 327 EXPECT_TRUE(observer_a.did_visibility_change()); |
351 EXPECT_FALSE(observer_b.did_visibility_change()); | 328 EXPECT_FALSE(observer_b.did_visibility_change()); |
352 EXPECT_TRUE(observer_a.is_cursor_visible()); | 329 EXPECT_TRUE(observer_a.is_cursor_visible()); |
353 } | 330 } |
OLD | NEW |