Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: ash/wm/cursor_manager_chromeos_unittest.cc

Issue 960073002: Do not hide the cursor on a key up (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/wm/cursor_manager_chromeos.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « ash/wm/cursor_manager_chromeos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698