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

Unified Diff: components/mus/ws/event_dispatcher_unittest.cc

Issue 1487333004: mus: Notify the client whether adding an accelerator was successful. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years 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 | « components/mus/ws/event_dispatcher.cc ('k') | components/mus/ws/window_tree_host_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/mus/ws/event_dispatcher_unittest.cc
diff --git a/components/mus/ws/event_dispatcher_unittest.cc b/components/mus/ws/event_dispatcher_unittest.cc
index 00513d636d14bcf3f8df94d85fcf78b47ba16854..d837dbc3e729ee3637ed426b66db9b19a667c6c7 100644
--- a/components/mus/ws/event_dispatcher_unittest.cc
+++ b/components/mus/ws/event_dispatcher_unittest.cc
@@ -166,6 +166,42 @@ TEST(EventDispatcherTest, OnEvent) {
EXPECT_EQ(gfx::Point(10, 15), dispatched_mouse_event->location());
}
+TEST(EventDispatcherTest, AcceleratorBasic) {
+ TestEventDispatcherDelegate event_dispatcher_delegate(nullptr);
+ EventDispatcher dispatcher(&event_dispatcher_delegate);
+ uint32_t accelerator_1 = 1;
+ mojom::EventMatcherPtr matcher = mus::CreateKeyMatcher(
+ mus::mojom::KEYBOARD_CODE_W, mus::mojom::EVENT_FLAGS_CONTROL_DOWN);
+ EXPECT_TRUE(dispatcher.AddAccelerator(accelerator_1, matcher.Pass()));
+
+ uint32_t accelerator_2 = 2;
+ matcher = mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_N,
+ mus::mojom::EVENT_FLAGS_NONE);
+ EXPECT_TRUE(dispatcher.AddAccelerator(accelerator_2, matcher.Pass()));
+
+ // Attempting to add a new accelerator with the same id should fail.
+ matcher = mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_T,
+ mus::mojom::EVENT_FLAGS_NONE);
+ EXPECT_FALSE(dispatcher.AddAccelerator(accelerator_2, matcher.Pass()));
+
+ // Adding the accelerator with the same id should succeed once the existing
+ // accelerator is removed.
+ dispatcher.RemoveAccelerator(accelerator_2);
+ matcher = mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_T,
+ mus::mojom::EVENT_FLAGS_NONE);
+ EXPECT_TRUE(dispatcher.AddAccelerator(accelerator_2, matcher.Pass()));
+
+ // Attempting to add an accelerator with the same matcher should fail.
+ uint32_t accelerator_3 = 3;
+ matcher = mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_T,
+ mus::mojom::EVENT_FLAGS_NONE);
+ EXPECT_FALSE(dispatcher.AddAccelerator(accelerator_3, matcher.Pass()));
+
+ matcher = mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_T,
+ mus::mojom::EVENT_FLAGS_CONTROL_DOWN);
+ EXPECT_TRUE(dispatcher.AddAccelerator(accelerator_3, matcher.Pass()));
+}
+
TEST(EventDispatcherTest, EventMatching) {
TestServerWindowDelegate window_delegate;
ServerWindow root(&window_delegate, WindowId(1, 2));
« no previous file with comments | « components/mus/ws/event_dispatcher.cc ('k') | components/mus/ws/window_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698