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

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

Issue 2016443003: mus: Don't allow SetEventObserver to monitor key events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 | « components/mus/ws/window_tree.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/mus/ws/window_tree_unittest.cc
diff --git a/components/mus/ws/window_tree_unittest.cc b/components/mus/ws/window_tree_unittest.cc
index 59974e80de9694d12fcb3feebfd279accb928be8..ab51cb4dd25d32dc93b2305431b49da717e88e7f 100644
--- a/components/mus/ws/window_tree_unittest.cc
+++ b/components/mus/ws/window_tree_unittest.cc
@@ -384,14 +384,19 @@ TEST_F(WindowTreeTest, SetEventObserverWrongUser) {
ASSERT_EQ(0u, other_binding->client()->tracker()->changes()->size());
}
-// Tests that an event observer can receive events that have no target window.
-TEST_F(WindowTreeTest, SetEventObserverNoTarget) {
James Cook 2016/05/25 20:59:41 I removed this test because the remaining event ty
+// Tests that an event observer cannot observe keystrokes.
+TEST_F(WindowTreeTest, SetEventObserverKeyEventsDisallowed) {
WindowTreeTestApi(wm_tree()).SetEventObserver(
- CreateEventMatcher(mojom::EventType::KEY_RELEASED), 111u);
- ui::KeyEvent key(ui::ET_KEY_RELEASED, ui::VKEY_A, ui::EF_NONE);
- DispatchEventAndAckImmediately(key);
- EXPECT_EQ("EventObserved event_action=2 event_observer_id=111",
- SingleChangeToDescription(*wm_client()->tracker()->changes()));
+ CreateEventMatcher(mojom::EventType::KEY_PRESSED), 111u);
+ ui::KeyEvent key_pressed(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE);
+ DispatchEventAndAckImmediately(key_pressed);
+ EXPECT_EQ(0u, wm_client()->tracker()->changes()->size());
+
+ WindowTreeTestApi(wm_tree()).SetEventObserver(
+ CreateEventMatcher(mojom::EventType::KEY_RELEASED), 222u);
+ ui::KeyEvent key_released(ui::ET_KEY_RELEASED, ui::VKEY_A, ui::EF_NONE);
+ DispatchEventAndAckImmediately(key_released);
+ EXPECT_EQ(0u, wm_client()->tracker()->changes()->size());
}
TEST_F(WindowTreeTest, CursorChangesWhenMouseOverWindowAndWindowSetsCursor) {
« no previous file with comments | « components/mus/ws/window_tree.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698