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

Unified Diff: ash/wm/window_cycle_controller_unittest.cc

Issue 1083093006: Prevent delivery of tab release key events while alt tabbing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Handle all key events during alt tab window cycling. Created 4 years, 7 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/window_cycle_controller.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/window_cycle_controller_unittest.cc
diff --git a/ash/wm/window_cycle_controller_unittest.cc b/ash/wm/window_cycle_controller_unittest.cc
index 7857fad003a11e6c4d72f5e221618ea4ac48dbd4..a5512e892533d0918416dd3e8cf913eae2aaf7e2 100644
--- a/ash/wm/window_cycle_controller_unittest.cc
+++ b/ash/wm/window_cycle_controller_unittest.cc
@@ -27,10 +27,36 @@
#include "ui/aura/test/test_windows.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
+#include "ui/events/event_handler.h"
+#include "ui/events/test/event_generator.h"
#include "ui/gfx/geometry/rect.h"
namespace ash {
+namespace {
+
+class KeyEventCounter : public ui::EventHandler {
+ public:
+ KeyEventCounter() : key_events_(0) {}
+ ~KeyEventCounter() override {}
+
+ size_t GetCountAndReset() {
+ size_t count = key_events_;
+ key_events_ = 0;
+ return count;
+ }
+
+ // ui::EventHandler:
+ void OnKeyEvent(ui::KeyEvent* event) override { key_events_++; }
+
+ private:
+ size_t key_events_;
+
+ DISALLOW_COPY_AND_ASSIGN(KeyEventCounter);
+};
+
+} // namespace
+
using aura::test::CreateTestWindowWithId;
using aura::test::TestWindowDelegate;
using aura::Window;
@@ -590,4 +616,24 @@ TEST_F(WindowCycleControllerTest, CycleMruPanelDestroyed) {
EXPECT_TRUE(wm::IsActiveWindow(panel1.get()));
}
+// Tests that the tab key events are not sent to the window.
+TEST_F(WindowCycleControllerTest, TabKeyNotLeaked) {
+ std::unique_ptr<Window> w0(CreateTestWindowInShellWithId(0));
+ std::unique_ptr<Window> w1(CreateTestWindowInShellWithId(1));
+ KeyEventCounter key_count;
+ w0->AddPreTargetHandler(&key_count);
+ w1->AddPreTargetHandler(&key_count);
+ ui::test::EventGenerator& generator = GetEventGenerator();
+ wm::GetWindowState(w0.get())->Activate();
+ generator.PressKey(ui::VKEY_MENU, ui::EF_NONE);
+ EXPECT_EQ(1u, key_count.GetCountAndReset());
+ generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN);
+ EXPECT_EQ(0u, key_count.GetCountAndReset());
+ generator.ReleaseKey(ui::VKEY_TAB, ui::EF_ALT_DOWN);
+ EXPECT_EQ(0u, key_count.GetCountAndReset());
+ generator.ReleaseKey(ui::VKEY_MENU, ui::EF_NONE);
+ EXPECT_TRUE(wm::GetWindowState(w1.get())->IsActive());
+ EXPECT_EQ(0u, key_count.GetCountAndReset());
+}
+
} // namespace ash
« no previous file with comments | « ash/wm/window_cycle_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698