OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/mus/public/cpp/lib/window_tree_client_impl.h" | 5 #include "components/mus/public/cpp/lib/window_tree_client_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 ASSERT_TRUE(root2); | 656 ASSERT_TRUE(root2); |
657 root1->AddTransientWindow(root2); | 657 root1->AddTransientWindow(root2); |
658 | 658 |
659 WindowTracker tracker; | 659 WindowTracker tracker; |
660 tracker.Add(root1); | 660 tracker.Add(root1); |
661 tracker.Add(root2); | 661 tracker.Add(root2); |
662 setup.reset(); | 662 setup.reset(); |
663 EXPECT_TRUE(tracker.windows().empty()); | 663 EXPECT_TRUE(tracker.windows().empty()); |
664 } | 664 } |
665 | 665 |
| 666 // Tests both SetCapture and ReleaseCapture, to ensure that Window is properly |
| 667 // updated on failures. |
| 668 TEST_F(WindowTreeClientImplTest, ExplicitCapture) { |
| 669 WindowTreeSetup setup; |
| 670 Window* root = setup.GetFirstRoot(); |
| 671 ASSERT_TRUE(root); |
| 672 |
| 673 root->SetCapture(); |
| 674 EXPECT_TRUE(root->has_capture()); |
| 675 uint32_t change_id1; |
| 676 ASSERT_TRUE(setup.window_tree()->GetAndClearChangeId(&change_id1)); |
| 677 setup.window_tree_client()->OnChangeCompleted(change_id1, false); |
| 678 EXPECT_FALSE(root->has_capture()); |
| 679 |
| 680 root->SetCapture(); |
| 681 EXPECT_TRUE(root->has_capture()); |
| 682 uint32_t change_id2; |
| 683 ASSERT_TRUE(setup.window_tree()->GetAndClearChangeId(&change_id2)); |
| 684 setup.window_tree_client()->OnChangeCompleted(change_id2, true); |
| 685 EXPECT_TRUE(root->has_capture()); |
| 686 |
| 687 root->ReleaseCapture(); |
| 688 EXPECT_FALSE(root->has_capture()); |
| 689 uint32_t change_id3; |
| 690 ASSERT_TRUE(setup.window_tree()->GetAndClearChangeId(&change_id3)); |
| 691 setup.window_tree_client()->OnChangeCompleted(change_id3, false); |
| 692 EXPECT_TRUE(root->has_capture()); |
| 693 |
| 694 root->ReleaseCapture(); |
| 695 uint32_t change_id4; |
| 696 ASSERT_TRUE(setup.window_tree()->GetAndClearChangeId(&change_id4)); |
| 697 setup.window_tree_client()->OnChangeCompleted(change_id4, true); |
| 698 EXPECT_FALSE(root->has_capture()); |
| 699 } |
| 700 |
666 } // namespace mus | 701 } // namespace mus |
OLD | NEW |