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

Unified Diff: services/ui/ws/window_manager_state_unittest.cc

Issue 2184613005: Fixes bug in accelerator handling in mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweak Created 4 years, 5 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 | « services/ui/ws/window_manager_state.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/ws/window_manager_state_unittest.cc
diff --git a/services/ui/ws/window_manager_state_unittest.cc b/services/ui/ws/window_manager_state_unittest.cc
index 186f55f9d337517df6f38c0ed52f76bfadc23bf6..e83fa3522efff1876589e982256ac2423ca4011e 100644
--- a/services/ui/ws/window_manager_state_unittest.cc
+++ b/services/ui/ws/window_manager_state_unittest.cc
@@ -481,6 +481,35 @@ TEST_F(WindowManagerStateTest, InterceptingEmbedderReceivesEvents) {
}
}
+// Ensures accelerators are forgotten between events.
+TEST_F(WindowManagerStateTest, PostAcceleratorForgotten) {
+ // Send an event that matches the accelerator and have the target respond
+ // that it handled the event so that the accelerator isn't called.
+ ui::KeyEvent accelerator_key(ui::ET_KEY_PRESSED, ui::VKEY_W,
+ ui::EF_CONTROL_DOWN);
+ std::unique_ptr<Accelerator> accelerator = CreateAccelerator();
+ ServerWindow* target = window();
+ DispatchInputEventToWindow(target, accelerator_key, accelerator.get());
+ TestChangeTracker* tracker = window_tree_client()->tracker();
+ ASSERT_EQ(1u, tracker->changes()->size());
+ EXPECT_EQ("InputEvent window=1,1 event_action=7",
+ ChangesToDescription1(*tracker->changes())[0]);
+ tracker->changes()->clear();
+ WindowTreeTestApi(window_tree()).AckLastEvent(mojom::EventResult::HANDLED);
+ EXPECT_FALSE(window_manager()->on_accelerator_called());
+
+ // Send another event that doesn't match the accelerator, the accelerator
+ // shouldn't be called.
+ ui::KeyEvent non_accelerator_key(ui::ET_KEY_PRESSED, ui::VKEY_T,
+ ui::EF_CONTROL_DOWN);
+ DispatchInputEventToWindow(target, non_accelerator_key, nullptr);
+ ASSERT_EQ(1u, tracker->changes()->size());
+ EXPECT_EQ("InputEvent window=1,1 event_action=7",
+ ChangesToDescription1(*tracker->changes())[0]);
+ WindowTreeTestApi(window_tree()).AckLastEvent(mojom::EventResult::UNHANDLED);
+ EXPECT_FALSE(window_manager()->on_accelerator_called());
+}
+
} // namespace test
} // namespace ws
} // namespace ui
« no previous file with comments | « services/ui/ws/window_manager_state.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698