Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
|
sadrul
2015/02/26 22:49:27
lol
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ash/wm/cursor_manager_chromeos.h" | |
| 6 | |
| 7 #include "base/memory/scoped_ptr.h" | |
| 8 #include "ui/aura/client/cursor_client.h" | |
| 9 #include "ui/aura/env.h" | |
| 10 #include "ui/aura/test/aura_test_base.h" | |
| 11 #include "ui/events/test/event_generator.h" | |
| 12 #include "ui/wm/core/compound_event_filter.h" | |
| 13 #include "ui/wm/core/native_cursor_manager.h" | |
| 14 | |
| 15 namespace ash { | |
| 16 | |
| 17 namespace { | |
| 18 | |
| 19 class TestNativeCursorManager : public wm::NativeCursorManager { | |
| 20 public: | |
| 21 TestNativeCursorManager() {} | |
| 22 ~TestNativeCursorManager() override {} | |
| 23 | |
| 24 // wm::NativeCursorManager: | |
| 25 void SetDisplay(const gfx::Display& display, | |
| 26 wm::NativeCursorManagerDelegate* delegate) override {} | |
| 27 | |
| 28 void SetCursor(gfx::NativeCursor cursor, | |
| 29 wm::NativeCursorManagerDelegate* delegate) override { | |
| 30 delegate->CommitCursor(cursor); | |
| 31 } | |
| 32 | |
| 33 void SetVisibility(bool visible, | |
| 34 wm::NativeCursorManagerDelegate* delegate) override { | |
| 35 delegate->CommitVisibility(visible); | |
| 36 } | |
| 37 | |
| 38 void SetMouseEventsEnabled( | |
| 39 bool enabled, | |
| 40 wm::NativeCursorManagerDelegate* delegate) override { | |
| 41 delegate->CommitMouseEventsEnabled(enabled); | |
| 42 } | |
| 43 | |
| 44 void SetCursorSet(ui::CursorSetType cursor_set, | |
| 45 wm::NativeCursorManagerDelegate* delegate) override { | |
| 46 delegate->CommitCursorSet(cursor_set); | |
| 47 } | |
| 48 | |
| 49 private: | |
| 50 DISALLOW_COPY_AND_ASSIGN(TestNativeCursorManager); | |
| 51 }; | |
| 52 | |
| 53 } // namespace | |
| 54 | |
| 55 class CursorManagerChromeOSTest : public aura::test::AuraTestBase { | |
| 56 public: | |
| 57 CursorManagerChromeOSTest() | |
| 58 : delegate_(new TestNativeCursorManager), | |
| 59 cursor_manager_(scoped_ptr<wm::NativeCursorManager>(delegate_)) { | |
| 60 } | |
| 61 | |
| 62 ~CursorManagerChromeOSTest() override {} | |
| 63 | |
| 64 // aura::test::AuraTestBase: | |
| 65 void SetUp() override { | |
| 66 aura::test::AuraTestBase::SetUp(); | |
| 67 aura::client::SetCursorClient(root_window(), &cursor_manager_); | |
| 68 } | |
| 69 | |
| 70 protected: | |
| 71 TestNativeCursorManager* delegate_; // Not owned. | |
| 72 ash::CursorManager cursor_manager_; | |
| 73 | |
| 74 private: | |
| 75 DISALLOW_COPY_AND_ASSIGN(CursorManagerChromeOSTest); | |
| 76 }; | |
| 77 | |
| 78 // Test that pressing an accelerator does not hide the cursor. | |
| 79 TEST_F(CursorManagerChromeOSTest, CursorDoesNotHideOnAccelerator) { | |
| 80 scoped_ptr<wm::CompoundEventFilter> compound_filter( | |
| 81 new wm::CompoundEventFilter); | |
| 82 aura::Env::GetInstance()->AddPreTargetHandler(compound_filter.get()); | |
| 83 ui::test::EventGenerator generator(root_window()); | |
| 84 | |
| 85 ASSERT_TRUE(cursor_manager_.IsCursorVisible()); | |
| 86 | |
| 87 // Press Ctrl+A, release A first. | |
| 88 generator.PressKey(ui::VKEY_CONTROL, ui::EF_CONTROL_DOWN); | |
| 89 generator.PressKey(ui::VKEY_A, ui::EF_CONTROL_DOWN); | |
| 90 generator.ReleaseKey(ui::VKEY_A, ui::EF_CONTROL_DOWN); | |
| 91 generator.ReleaseKey(ui::VKEY_CONTROL, ui::EF_NONE); | |
| 92 EXPECT_TRUE(cursor_manager_.IsCursorVisible()); | |
| 93 | |
| 94 // Press Ctrl+A, release Ctrl first. | |
| 95 generator.PressKey(ui::VKEY_CONTROL, ui::EF_CONTROL_DOWN); | |
| 96 generator.PressKey(ui::VKEY_A, ui::EF_CONTROL_DOWN); | |
| 97 generator.ReleaseKey(ui::VKEY_CONTROL, ui::EF_NONE); | |
| 98 generator.ReleaseKey(ui::VKEY_A, ui::EF_NONE); | |
| 99 EXPECT_TRUE(cursor_manager_.IsCursorVisible()); | |
| 100 | |
| 101 aura::Env::GetInstance()->RemovePreTargetHandler(compound_filter.get()); | |
| 102 } | |
| 103 | |
| 104 } // namespace ash | |
| OLD | NEW |