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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « components/mus/ws/window_tree.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/mus/ws/window_tree.h" 5 #include "components/mus/ws/window_tree.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 .SetEventObserver(CreateEventMatcher(mojom::EventType::POINTER_UP), 222u); 377 .SetEventObserver(CreateEventMatcher(mojom::EventType::POINTER_UP), 222u);
378 378
379 // An event is observed by the wm tree, but not by the other user's tree. 379 // An event is observed by the wm tree, but not by the other user's tree.
380 DispatchEventAndAckImmediately(CreatePointerUpEvent(5, 5)); 380 DispatchEventAndAckImmediately(CreatePointerUpEvent(5, 5));
381 ASSERT_EQ(1u, wm_client()->tracker()->changes()->size()); 381 ASSERT_EQ(1u, wm_client()->tracker()->changes()->size());
382 EXPECT_EQ("InputEvent window=0,3 event_action=6 event_observer_id=111", 382 EXPECT_EQ("InputEvent window=0,3 event_action=6 event_observer_id=111",
383 SingleChangeToDescription(*wm_client()->tracker()->changes())); 383 SingleChangeToDescription(*wm_client()->tracker()->changes()));
384 ASSERT_EQ(0u, other_binding->client()->tracker()->changes()->size()); 384 ASSERT_EQ(0u, other_binding->client()->tracker()->changes()->size());
385 } 385 }
386 386
387 // Tests that an event observer can receive events that have no target window. 387 // Tests that an event observer cannot observe keystrokes.
388 TEST_F(WindowTreeTest, SetEventObserverNoTarget) { 388 TEST_F(WindowTreeTest, SetEventObserverKeyEventsDisallowed) {
James Cook 2016/05/25 20:59:41 I removed this test because the remaining event ty
389 WindowTreeTestApi(wm_tree()).SetEventObserver( 389 WindowTreeTestApi(wm_tree()).SetEventObserver(
390 CreateEventMatcher(mojom::EventType::KEY_RELEASED), 111u); 390 CreateEventMatcher(mojom::EventType::KEY_PRESSED), 111u);
391 ui::KeyEvent key(ui::ET_KEY_RELEASED, ui::VKEY_A, ui::EF_NONE); 391 ui::KeyEvent key_pressed(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE);
392 DispatchEventAndAckImmediately(key); 392 DispatchEventAndAckImmediately(key_pressed);
393 EXPECT_EQ("EventObserved event_action=2 event_observer_id=111", 393 EXPECT_EQ(0u, wm_client()->tracker()->changes()->size());
394 SingleChangeToDescription(*wm_client()->tracker()->changes())); 394
395 WindowTreeTestApi(wm_tree()).SetEventObserver(
396 CreateEventMatcher(mojom::EventType::KEY_RELEASED), 222u);
397 ui::KeyEvent key_released(ui::ET_KEY_RELEASED, ui::VKEY_A, ui::EF_NONE);
398 DispatchEventAndAckImmediately(key_released);
399 EXPECT_EQ(0u, wm_client()->tracker()->changes()->size());
395 } 400 }
396 401
397 TEST_F(WindowTreeTest, CursorChangesWhenMouseOverWindowAndWindowSetsCursor) { 402 TEST_F(WindowTreeTest, CursorChangesWhenMouseOverWindowAndWindowSetsCursor) {
398 TestWindowTreeClient* embed_connection = nullptr; 403 TestWindowTreeClient* embed_connection = nullptr;
399 WindowTree* tree = nullptr; 404 WindowTree* tree = nullptr;
400 ServerWindow* window = nullptr; 405 ServerWindow* window = nullptr;
401 EXPECT_NO_FATAL_FAILURE( 406 EXPECT_NO_FATAL_FAILURE(
402 SetupEventTargeting(&embed_connection, &tree, &window)); 407 SetupEventTargeting(&embed_connection, &tree, &window));
403 408
404 // Like in BasicInputEventTarget, we send a pointer down event to be 409 // Like in BasicInputEventTarget, we send a pointer down event to be
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 ASSERT_NE(new_opacity, unknown_window.opacity()); 1006 ASSERT_NE(new_opacity, unknown_window.opacity());
1002 1007
1003 EXPECT_FALSE(tree->SetWindowOpacity( 1008 EXPECT_FALSE(tree->SetWindowOpacity(
1004 ClientWindowId(WindowIdToTransportId(window_id)), new_opacity)); 1009 ClientWindowId(WindowIdToTransportId(window_id)), new_opacity));
1005 EXPECT_NE(new_opacity, unknown_window.opacity()); 1010 EXPECT_NE(new_opacity, unknown_window.opacity());
1006 } 1011 }
1007 1012
1008 } // namespace test 1013 } // namespace test
1009 } // namespace ws 1014 } // namespace ws
1010 } // namespace mus 1015 } // namespace mus
OLDNEW
« 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