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

Unified Diff: components/mus/public/cpp/tests/window_tree_client_impl_unittest.cc

Issue 1605773004: mus: Implement Window Server Capture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Create InFlightCaptureChange add tests Created 4 years, 11 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
Index: components/mus/public/cpp/tests/window_tree_client_impl_unittest.cc
diff --git a/components/mus/public/cpp/tests/window_tree_client_impl_unittest.cc b/components/mus/public/cpp/tests/window_tree_client_impl_unittest.cc
index 669baf9cde3a659bbd5e5ba9a7a782ab8236c59d..e75eb44fc9ce422de4bda4d32f51efdb4b147b2a 100644
--- a/components/mus/public/cpp/tests/window_tree_client_impl_unittest.cc
+++ b/components/mus/public/cpp/tests/window_tree_client_impl_unittest.cc
@@ -663,4 +663,39 @@ TEST_F(WindowTreeClientImplTest, MultipleUnOwnedWindowsDuringDestruction) {
EXPECT_TRUE(tracker.windows().empty());
}
+// Tests both SetCapture and ReleaseCapture, to ensure that Window is properly
+// updated on failures.
+TEST_F(WindowTreeClientImplTest, ExplicitCapture) {
+ WindowTreeSetup setup;
+ Window* root = setup.GetFirstRoot();
+ ASSERT_TRUE(root);
+
+ root->SetCapture();
+ EXPECT_TRUE(root->has_capture());
+ uint32_t change_id1;
+ ASSERT_TRUE(setup.window_tree()->GetAndClearChangeId(&change_id1));
+ setup.window_tree_client()->OnChangeCompleted(change_id1, false);
+ EXPECT_FALSE(root->has_capture());
+
+ root->SetCapture();
+ EXPECT_TRUE(root->has_capture());
+ uint32_t change_id2;
+ ASSERT_TRUE(setup.window_tree()->GetAndClearChangeId(&change_id2));
+ setup.window_tree_client()->OnChangeCompleted(change_id2, true);
+ EXPECT_TRUE(root->has_capture());
+
+ root->ReleaseCapture();
+ EXPECT_FALSE(root->has_capture());
+ uint32_t change_id3;
+ ASSERT_TRUE(setup.window_tree()->GetAndClearChangeId(&change_id3));
+ setup.window_tree_client()->OnChangeCompleted(change_id3, false);
+ EXPECT_TRUE(root->has_capture());
+
+ root->ReleaseCapture();
+ uint32_t change_id4;
+ ASSERT_TRUE(setup.window_tree()->GetAndClearChangeId(&change_id4));
+ setup.window_tree_client()->OnChangeCompleted(change_id4, true);
+ EXPECT_FALSE(root->has_capture());
+}
+
} // namespace mus

Powered by Google App Engine
This is Rietveld 408576698