diff options
author | jonross <jonross@chromium.org> | 2016-02-10 17:29:47 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-11 01:31:06 +0000 |
commit | b72ed077b4cb7309c5e3ee6bb80944a3deab6250 (patch) | |
tree | f092f3ded604eaf81ca784f88c03d4a743e6c633 /components/mus/ws/window_tree_apptest.cc | |
parent | 1a50fa32b006698d5b5bdfc909c9d1470e12522a (diff) | |
download | chromium_src-b72ed077b4cb7309c5e3ee6bb80944a3deab6250.zip chromium_src-b72ed077b4cb7309c5e3ee6bb80944a3deab6250.tar.gz chromium_src-b72ed077b4cb7309c5e3ee6bb80944a3deab6250.tar.bz2 |
mus Window Server: implement event capture
This CL implements an explicit capture API that will be used for popups.
This is a split of the review: https://codereview.chromium.org/1605773004/
Where this review encompasses only the Window Server functionality. The client lib code is just stubs for compilation. Full implementation of the client will follow in a separate review.
TEST=EventDispatcherTest.SetExplicitCapture, EventDispatcherTest.ExplicitCaptureOverridesImplicitCapture, EventDispatcherTest.CaptureUpdatesActivePointerTargets, EventDispatcherTest.UpdatingCaptureStopsObservingPreviousCaputre, EventDispatcherTest.DestroyingCaptureWindowRemovesExplicitCapture
BUG=533161
Review URL: https://codereview.chromium.org/1677513002
Cr-Commit-Position: refs/heads/master@{#374824}
Diffstat (limited to 'components/mus/ws/window_tree_apptest.cc')
-rw-r--r-- | components/mus/ws/window_tree_apptest.cc | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/components/mus/ws/window_tree_apptest.cc b/components/mus/ws/window_tree_apptest.cc index 5bf6089..bc55a76 100644 --- a/components/mus/ws/window_tree_apptest.cc +++ b/components/mus/ws/window_tree_apptest.cc @@ -291,6 +291,9 @@ class TestWindowTreeClientImpl : public mojom::WindowTreeClient, tracker()->OnEmbeddedAppDisconnected(window_id); } void OnUnembed(Id window_id) override { tracker()->OnUnembed(window_id); } + void OnLostCapture(Id window_id) override { + tracker()->OnLostCapture(window_id); + } void OnTopLevelCreated(uint32_t change_id, mojom::WindowDataPtr data) override { tracker()->OnTopLevelCreated(change_id, std::move(data)); @@ -348,6 +351,10 @@ class TestWindowTreeClientImpl : public mojom::WindowTreeClient, void OnWindowInputEvent(uint32_t event_id, Id window_id, EventPtr event) override { + // Ack input events to clear the state on the server. These can be received + // during test startup. X11Window::DispatchEvent sends a synthetic move + // event to notify of entry. + tree()->OnWindowInputEventAck(event_id); // Don't log input events as none of the tests care about them and they // may come in at random points. } @@ -1859,6 +1866,57 @@ TEST_F(WindowTreeAppTest, Ids) { SingleChangeToDescription(*changes2())); } +// Tests that setting capture fails when no input event has occurred, and there +// is no notification of lost capture. +TEST_F(WindowTreeAppTest, ExplicitCaptureWithoutInput) { + Id window_1_1 = ws_client1()->NewWindow(1); + + // Add the window to the root, so that they have a WindowTreeHostImpl to + // handle input capture. + ASSERT_TRUE(ws_client1()->AddWindow(root_window_id(), window_1_1)); + changes1()->clear(); + + // Since there has been no input, capture should not succeed. No lost capture + // message is expected. + ws1()->SetCapture(1, window_1_1); + ws_client1_->WaitForAllMessages(); + EXPECT_TRUE(changes1()->empty()); + + // Since there is no window with capture, lost capture should not be notified. + ws1()->ReleaseCapture(3, window_1_1); + ws_client1_->WaitForAllMessages(); + EXPECT_TRUE(changes1()->empty()); +} + +// TODO(jonross): Enable this once apptests can send input events to the server. +// Enabling capture requires that the connection be processing events. +TEST_F(WindowTreeAppTest, DISABLED_ExplicitCapturePropagation) { + Id window_1_1 = ws_client1()->NewWindow(1); + Id window_1_2 = ws_client1()->NewWindow(2); + + // Add the windows to the root, so that they have a WindowTreeHostImpl to + // handle input capture. + ASSERT_TRUE(ws_client1()->AddWindow(root_window_id(), window_1_1)); + ASSERT_TRUE(ws_client1()->AddWindow(root_window_id(), window_1_2)); + + changes1()->clear(); + // Window 1 takes capture then Window 2 takes capture. + // Verify that window 1 has lost capture. + ws1()->SetCapture(1, window_1_1); + ws1()->SetCapture(2, window_1_2); + ws_client1_->WaitForChangeCount(1); + + EXPECT_EQ("OnLostCapture window=" + IdToString(window_1_1), + SingleChangeToDescription(*changes1())); + + changes1()->clear(); + // Explicitly releasing capture should not notify of lost capture. + ws1()->ReleaseCapture(3, window_1_2); + ws_client1_->WaitForAllMessages(); + + EXPECT_TRUE(changes1()->empty()); +} + // TODO(sky): need to better track changes to initial connection. For example, // that SetBounsdWindows/AddWindow and the like don't result in messages to the // originating connection. |