| OLD | NEW |
| 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 "services/ui/ws/window_tree.h" | 5 #include "services/ui/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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 // An event is watched by the wm tree, but not by the other user's tree. | 447 // An event is watched by the wm tree, but not by the other user's tree. |
| 448 DispatchEventAndAckImmediately(CreatePointerUpEvent(5, 5)); | 448 DispatchEventAndAckImmediately(CreatePointerUpEvent(5, 5)); |
| 449 ASSERT_EQ(1u, wm_client()->tracker()->changes()->size()); | 449 ASSERT_EQ(1u, wm_client()->tracker()->changes()->size()); |
| 450 EXPECT_EQ("PointerWatcherEvent event_action=18 window=null", | 450 EXPECT_EQ("PointerWatcherEvent event_action=18 window=null", |
| 451 SingleChangeToDescription(*wm_client()->tracker()->changes())); | 451 SingleChangeToDescription(*wm_client()->tracker()->changes())); |
| 452 ASSERT_EQ(0u, other_binding->client()->tracker()->changes()->size()); | 452 ASSERT_EQ(0u, other_binding->client()->tracker()->changes()->size()); |
| 453 } | 453 } |
| 454 | 454 |
| 455 // Tests that a pointer watcher cannot watch keystrokes. | 455 // Tests that a pointer watcher cannot watch keystrokes. |
| 456 TEST_F(WindowTreeTest, StartPointerWatcherKeyEventsDisallowed) { | 456 TEST_F(WindowTreeTest, StartPointerWatcherKeyEventsDisallowed) { |
| 457 WindowTreeTestApi(wm_tree()).StartPointerWatcher(false); | 457 TestWindowTreeBinding* other_binding; |
| 458 WindowTree* other_tree = CreateNewTree("other_user", &other_binding); |
| 459 other_binding->client()->tracker()->changes()->clear(); |
| 460 |
| 461 WindowTreeTestApi(other_tree).StartPointerWatcher(false); |
| 458 ui::KeyEvent key_pressed(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE); | 462 ui::KeyEvent key_pressed(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE); |
| 459 DispatchEventAndAckImmediately(key_pressed); | 463 DispatchEventAndAckImmediately(key_pressed); |
| 460 EXPECT_EQ(0u, wm_client()->tracker()->changes()->size()); | 464 EXPECT_EQ(0u, other_binding->client()->tracker()->changes()->size()); |
| 465 EXPECT_EQ("InputEvent window=0,3 event_action=7", |
| 466 SingleChangeToDescription(*wm_client()->tracker()->changes())); |
| 461 | 467 |
| 462 WindowTreeTestApi(wm_tree()).StartPointerWatcher(false); | 468 WindowTreeTestApi(wm_tree()).StartPointerWatcher(false); |
| 463 ui::KeyEvent key_released(ui::ET_KEY_RELEASED, ui::VKEY_A, ui::EF_NONE); | 469 ui::KeyEvent key_released(ui::ET_KEY_RELEASED, ui::VKEY_A, ui::EF_NONE); |
| 464 DispatchEventAndAckImmediately(key_released); | 470 DispatchEventAndAckImmediately(key_released); |
| 465 EXPECT_EQ(0u, wm_client()->tracker()->changes()->size()); | 471 EXPECT_EQ(0u, other_binding->client()->tracker()->changes()->size()); |
| 472 } |
| 473 |
| 474 TEST_F(WindowTreeTest, KeyEventSentToWindowManagerWhenNothingFocused) { |
| 475 ui::KeyEvent key_pressed(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE); |
| 476 DispatchEventAndAckImmediately(key_pressed); |
| 477 EXPECT_EQ("InputEvent window=0,3 event_action=7", |
| 478 SingleChangeToDescription(*wm_client()->tracker()->changes())); |
| 466 } | 479 } |
| 467 | 480 |
| 468 TEST_F(WindowTreeTest, CursorChangesWhenMouseOverWindowAndWindowSetsCursor) { | 481 TEST_F(WindowTreeTest, CursorChangesWhenMouseOverWindowAndWindowSetsCursor) { |
| 469 TestWindowTreeClient* embed_client = nullptr; | 482 TestWindowTreeClient* embed_client = nullptr; |
| 470 WindowTree* tree = nullptr; | 483 WindowTree* tree = nullptr; |
| 471 ServerWindow* window = nullptr; | 484 ServerWindow* window = nullptr; |
| 472 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_client, &tree, &window)); | 485 EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_client, &tree, &window)); |
| 473 | 486 |
| 474 // Like in BasicInputEventTarget, we send a pointer down event to be | 487 // Like in BasicInputEventTarget, we send a pointer down event to be |
| 475 // dispatched. This is only to place the mouse cursor over that window though. | 488 // dispatched. This is only to place the mouse cursor over that window though. |
| (...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1580 EXPECT_TRUE(window_manager_tree->DeleteWindow(display_root_id)); | 1593 EXPECT_TRUE(window_manager_tree->DeleteWindow(display_root_id)); |
| 1581 EXPECT_TRUE(window_manager_tree->roots().empty()); | 1594 EXPECT_TRUE(window_manager_tree->roots().empty()); |
| 1582 EXPECT_TRUE(WindowManagerStateTestApi(window_manager_state) | 1595 EXPECT_TRUE(WindowManagerStateTestApi(window_manager_state) |
| 1583 .window_manager_display_roots() | 1596 .window_manager_display_roots() |
| 1584 .empty()); | 1597 .empty()); |
| 1585 } | 1598 } |
| 1586 | 1599 |
| 1587 } // namespace test | 1600 } // namespace test |
| 1588 } // namespace ws | 1601 } // namespace ws |
| 1589 } // namespace ui | 1602 } // namespace ui |
| OLD | NEW |