| 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
|
|
|