Index: components/mus/ws/window_tree_apptest.cc |
diff --git a/components/mus/ws/window_tree_apptest.cc b/components/mus/ws/window_tree_apptest.cc |
index 9f063d07901c91dab7ac5048de4d3026a264aadd..c2e082884af9fb1c14ec6eacbf4c8f107e15b893 100644 |
--- a/components/mus/ws/window_tree_apptest.cc |
+++ b/components/mus/ws/window_tree_apptest.cc |
@@ -298,6 +298,9 @@ class TestWindowTreeClientImpl : public mojom::WindowTreeClient, |
tracker()->OnEmbeddedAppDisconnected(window_id); |
} |
void OnUnembed() override { tracker()->OnUnembed(); } |
+ void OnLostCapture(Id window_id) override { |
+ tracker()->OnLostCapture(window_id); |
+ } |
void OnWindowBoundsChanged(Id window_id, |
RectPtr old_bounds, |
RectPtr new_bounds) override { |
@@ -1763,6 +1766,26 @@ TEST_F(WindowTreeAppTest, TransientWindowTracksTransientParentLifetime) { |
ChangesToDescription1(*changes1())[1]); |
} |
+TEST_F(WindowTreeAppTest, ExplicitCapturePropagation) { |
+ Id window_1_1 = ws_client1()->NewWindow(1); |
+ Id window_1_2 = ws_client1()->NewWindow(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(); |
+ ws1()->ReleaseCapture(3, window_1_2); |
+ ws_client1_->WaitForChangeCount(1); |
+ |
+ EXPECT_EQ("OnLostCapture window=" + IdToString(window_1_2), |
+ SingleChangeToDescription(*changes1())); |
+} |
+ |
// 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. |