| 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 |
| 11 namespace { | 11 namespace { |
| 12 | 12 |
| 13 class TestingCursorManager : public views::corewm::NativeCursorManager { | 13 class TestingCursorManager : public wm::NativeCursorManager { |
| 14 public: | 14 public: |
| 15 // Overridden from views::corewm::NativeCursorManager: | 15 // Overridden from wm::NativeCursorManager: |
| 16 virtual void SetDisplay( | 16 virtual void SetDisplay( |
| 17 const gfx::Display& display, | 17 const gfx::Display& display, |
| 18 views::corewm::NativeCursorManagerDelegate* delegate) OVERRIDE {} | 18 wm::NativeCursorManagerDelegate* delegate) OVERRIDE {} |
| 19 | 19 |
| 20 virtual void SetCursor( | 20 virtual void SetCursor( |
| 21 gfx::NativeCursor cursor, | 21 gfx::NativeCursor cursor, |
| 22 views::corewm::NativeCursorManagerDelegate* delegate) OVERRIDE { | 22 wm::NativeCursorManagerDelegate* delegate) OVERRIDE { |
| 23 delegate->CommitCursor(cursor); | 23 delegate->CommitCursor(cursor); |
| 24 } | 24 } |
| 25 | 25 |
| 26 virtual void SetVisibility( | 26 virtual void SetVisibility( |
| 27 bool visible, | 27 bool visible, |
| 28 views::corewm::NativeCursorManagerDelegate* delegate) OVERRIDE { | 28 wm::NativeCursorManagerDelegate* delegate) OVERRIDE { |
| 29 delegate->CommitVisibility(visible); | 29 delegate->CommitVisibility(visible); |
| 30 } | 30 } |
| 31 | 31 |
| 32 virtual void SetMouseEventsEnabled( | 32 virtual void SetMouseEventsEnabled( |
| 33 bool enabled, | 33 bool enabled, |
| 34 views::corewm::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 views::corewm::NativeCursorManagerDelegate* delegate) OVERRIDE { | 40 wm::NativeCursorManagerDelegate* delegate) OVERRIDE { |
| 41 delegate->CommitCursorSet(cursor_set); | 41 delegate->CommitCursorSet(cursor_set); |
| 42 } | 42 } |
| 43 | 43 |
| 44 virtual void SetScale( | 44 virtual void SetScale( |
| 45 float scale, | 45 float scale, |
| 46 views::corewm::NativeCursorManagerDelegate* delegate) OVERRIDE { | 46 wm::NativeCursorManagerDelegate* delegate) OVERRIDE { |
| 47 delegate->CommitScale(scale); | 47 delegate->CommitScale(scale); |
| 48 } | 48 } |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 } // namespace | 51 } // namespace |
| 52 | 52 |
| 53 class CursorManagerTest : public aura::test::AuraTestBase { | 53 class CursorManagerTest : public aura::test::AuraTestBase { |
| 54 protected: | 54 protected: |
| 55 CursorManagerTest() | 55 CursorManagerTest() |
| 56 : delegate_(new TestingCursorManager), | 56 : delegate_(new TestingCursorManager), |
| 57 cursor_manager_(scoped_ptr<views::corewm::NativeCursorManager>( | 57 cursor_manager_(scoped_ptr<wm::NativeCursorManager>( |
| 58 delegate_)) { | 58 delegate_)) { |
| 59 } | 59 } |
| 60 | 60 |
| 61 TestingCursorManager* delegate_; | 61 TestingCursorManager* delegate_; |
| 62 views::corewm::CursorManager cursor_manager_; | 62 wm::CursorManager cursor_manager_; |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 class TestingCursorClientObserver : public aura::client::CursorClientObserver { | 65 class TestingCursorClientObserver : public aura::client::CursorClientObserver { |
| 66 public: | 66 public: |
| 67 TestingCursorClientObserver() | 67 TestingCursorClientObserver() |
| 68 : cursor_visibility_(false), | 68 : cursor_visibility_(false), |
| 69 did_visibility_change_(false) {} | 69 did_visibility_change_(false) {} |
| 70 void reset() { cursor_visibility_ = did_visibility_change_ = false; } | 70 void reset() { cursor_visibility_ = did_visibility_change_ = false; } |
| 71 bool is_cursor_visible() const { return cursor_visibility_; } | 71 bool is_cursor_visible() const { return cursor_visibility_; } |
| 72 bool did_visibility_change() const { return did_visibility_change_; } | 72 bool did_visibility_change() const { return did_visibility_change_; } |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 EXPECT_FALSE(observer_a.is_cursor_visible()); | 344 EXPECT_FALSE(observer_a.is_cursor_visible()); |
| 345 | 345 |
| 346 // Show the cursor using ShowCursor(). | 346 // Show the cursor using ShowCursor(). |
| 347 observer_a.reset(); | 347 observer_a.reset(); |
| 348 observer_b.reset(); | 348 observer_b.reset(); |
| 349 cursor_manager_.ShowCursor(); | 349 cursor_manager_.ShowCursor(); |
| 350 EXPECT_TRUE(observer_a.did_visibility_change()); | 350 EXPECT_TRUE(observer_a.did_visibility_change()); |
| 351 EXPECT_FALSE(observer_b.did_visibility_change()); | 351 EXPECT_FALSE(observer_b.did_visibility_change()); |
| 352 EXPECT_TRUE(observer_a.is_cursor_visible()); | 352 EXPECT_TRUE(observer_a.is_cursor_visible()); |
| 353 } | 353 } |
| OLD | NEW |