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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/wm/cursor_manager_chromeos.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/cursor_manager_chromeos_unittest.cc
diff --git a/ash/wm/cursor_manager_chromeos_unittest.cc b/ash/wm/cursor_manager_chromeos_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..44bdfa6575b99a214ca2dd7a4bd7fb7f84f069aa
--- /dev/null
+++ b/ash/wm/cursor_manager_chromeos_unittest.cc
@@ -0,0 +1,104 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
sadrul 2015/02/26 22:49:27 lol
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/wm/cursor_manager_chromeos.h"
+
+#include "base/memory/scoped_ptr.h"
+#include "ui/aura/client/cursor_client.h"
+#include "ui/aura/env.h"
+#include "ui/aura/test/aura_test_base.h"
+#include "ui/events/test/event_generator.h"
+#include "ui/wm/core/compound_event_filter.h"
+#include "ui/wm/core/native_cursor_manager.h"
+
+namespace ash {
+
+namespace {
+
+class TestNativeCursorManager : public wm::NativeCursorManager {
+ public:
+ TestNativeCursorManager() {}
+ ~TestNativeCursorManager() override {}
+
+ // wm::NativeCursorManager:
+ void SetDisplay(const gfx::Display& display,
+ wm::NativeCursorManagerDelegate* delegate) override {}
+
+ void SetCursor(gfx::NativeCursor cursor,
+ wm::NativeCursorManagerDelegate* delegate) override {
+ delegate->CommitCursor(cursor);
+ }
+
+ void SetVisibility(bool visible,
+ wm::NativeCursorManagerDelegate* delegate) override {
+ delegate->CommitVisibility(visible);
+ }
+
+ void SetMouseEventsEnabled(
+ bool enabled,
+ wm::NativeCursorManagerDelegate* delegate) override {
+ delegate->CommitMouseEventsEnabled(enabled);
+ }
+
+ void SetCursorSet(ui::CursorSetType cursor_set,
+ wm::NativeCursorManagerDelegate* delegate) override {
+ delegate->CommitCursorSet(cursor_set);
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TestNativeCursorManager);
+};
+
+} // namespace
+
+class CursorManagerChromeOSTest : public aura::test::AuraTestBase {
+ public:
+ CursorManagerChromeOSTest()
+ : delegate_(new TestNativeCursorManager),
+ cursor_manager_(scoped_ptr<wm::NativeCursorManager>(delegate_)) {
+ }
+
+ ~CursorManagerChromeOSTest() override {}
+
+ // aura::test::AuraTestBase:
+ void SetUp() override {
+ aura::test::AuraTestBase::SetUp();
+ aura::client::SetCursorClient(root_window(), &cursor_manager_);
+ }
+
+ protected:
+ TestNativeCursorManager* delegate_; // Not owned.
+ ash::CursorManager cursor_manager_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CursorManagerChromeOSTest);
+};
+
+// Test that pressing an accelerator does not hide the cursor.
+TEST_F(CursorManagerChromeOSTest, CursorDoesNotHideOnAccelerator) {
+ scoped_ptr<wm::CompoundEventFilter> compound_filter(
+ new wm::CompoundEventFilter);
+ aura::Env::GetInstance()->AddPreTargetHandler(compound_filter.get());
+ ui::test::EventGenerator generator(root_window());
+
+ ASSERT_TRUE(cursor_manager_.IsCursorVisible());
+
+ // Press Ctrl+A, release A first.
+ generator.PressKey(ui::VKEY_CONTROL, ui::EF_CONTROL_DOWN);
+ generator.PressKey(ui::VKEY_A, ui::EF_CONTROL_DOWN);
+ generator.ReleaseKey(ui::VKEY_A, ui::EF_CONTROL_DOWN);
+ generator.ReleaseKey(ui::VKEY_CONTROL, ui::EF_NONE);
+ EXPECT_TRUE(cursor_manager_.IsCursorVisible());
+
+ // Press Ctrl+A, release Ctrl first.
+ generator.PressKey(ui::VKEY_CONTROL, ui::EF_CONTROL_DOWN);
+ generator.PressKey(ui::VKEY_A, ui::EF_CONTROL_DOWN);
+ generator.ReleaseKey(ui::VKEY_CONTROL, ui::EF_NONE);
+ generator.ReleaseKey(ui::VKEY_A, ui::EF_NONE);
+ EXPECT_TRUE(cursor_manager_.IsCursorVisible());
+
+ aura::Env::GetInstance()->RemovePreTargetHandler(compound_filter.get());
+}
+
+} // namespace ash
« 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