| 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 "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "ui/aura/client/cursor_client_observer.h" | 8 #include "ui/aura/client/cursor_client_observer.h" |
| 9 #include "ui/aura/test/aura_test_base.h" | 9 #include "ui/aura/test/aura_test_base.h" |
| 10 #include "ui/wm/core/native_cursor_manager.h" | 10 #include "ui/wm/core/native_cursor_manager.h" |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 EXPECT_FALSE(observer_a.is_cursor_visible()); | 318 EXPECT_FALSE(observer_a.is_cursor_visible()); |
| 319 | 319 |
| 320 // Show the cursor using ShowCursor(). | 320 // Show the cursor using ShowCursor(). |
| 321 observer_a.reset(); | 321 observer_a.reset(); |
| 322 observer_b.reset(); | 322 observer_b.reset(); |
| 323 cursor_manager_.ShowCursor(); | 323 cursor_manager_.ShowCursor(); |
| 324 EXPECT_TRUE(observer_a.did_visibility_change()); | 324 EXPECT_TRUE(observer_a.did_visibility_change()); |
| 325 EXPECT_FALSE(observer_b.did_visibility_change()); | 325 EXPECT_FALSE(observer_b.did_visibility_change()); |
| 326 EXPECT_TRUE(observer_a.is_cursor_visible()); | 326 EXPECT_TRUE(observer_a.is_cursor_visible()); |
| 327 } | 327 } |
| 328 |
| 329 // This test validates that the cursor visiblity state is restored when a |
| 330 // CursorManager instance is destroyed and recreated. |
| 331 TEST(CursorManagerCreateDestroyTest, VisibilityTest) { |
| 332 // This block ensures that the cursor is hidden when the CursorManager |
| 333 // instance is destroyed. |
| 334 { |
| 335 wm::CursorManager cursor_manager1( |
| 336 scoped_ptr<wm::NativeCursorManager>(new TestingCursorManager)); |
| 337 cursor_manager1.ShowCursor(); |
| 338 EXPECT_TRUE(cursor_manager1.IsCursorVisible()); |
| 339 cursor_manager1.HideCursor(); |
| 340 EXPECT_FALSE(cursor_manager1.IsCursorVisible()); |
| 341 } |
| 342 |
| 343 // This block validates that the cursor is hidden initially. It ensures that |
| 344 // the cursor is visible when the CursorManager instance is destroyed. |
| 345 { |
| 346 wm::CursorManager cursor_manager2( |
| 347 scoped_ptr<wm::NativeCursorManager>(new TestingCursorManager)); |
| 348 EXPECT_FALSE(cursor_manager2.IsCursorVisible()); |
| 349 cursor_manager2.ShowCursor(); |
| 350 EXPECT_TRUE(cursor_manager2.IsCursorVisible()); |
| 351 } |
| 352 |
| 353 // This block validates that the cursor is visible initially. It then |
| 354 // performs normal cursor visibility operations. |
| 355 { |
| 356 wm::CursorManager cursor_manager3( |
| 357 scoped_ptr<wm::NativeCursorManager>(new TestingCursorManager)); |
| 358 EXPECT_TRUE(cursor_manager3.IsCursorVisible()); |
| 359 cursor_manager3.HideCursor(); |
| 360 EXPECT_FALSE(cursor_manager3.IsCursorVisible()); |
| 361 } |
| 362 } |
| OLD | NEW |