| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 // And window 4 should not be visible to connection 3. | 683 // And window 4 should not be visible to connection 3. |
| 684 { | 684 { |
| 685 std::vector<TestWindow> windows; | 685 std::vector<TestWindow> windows; |
| 686 GetWindowTree(wt3(), window_2_3, &windows); | 686 GetWindowTree(wt3(), window_2_3, &windows); |
| 687 EXPECT_EQ("no windows", SingleWindowDescription(windows)); | 687 EXPECT_EQ("no windows", SingleWindowDescription(windows)); |
| 688 } | 688 } |
| 689 } | 689 } |
| 690 | 690 |
| 691 // Verifies once Embed() has been invoked the parent connection can't see any | 691 // Verifies once Embed() has been invoked the parent connection can't see any |
| 692 // children. | 692 // children. |
| 693 TEST_F(WindowTreeClientTest, DISABLED_CantAccessChildrenOfEmbeddedWindow) { | 693 TEST_F(WindowTreeClientTest, CantAccessChildrenOfEmbeddedWindow) { |
| 694 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); | 694 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); |
| 695 | 695 |
| 696 Id window_1_1 = BuildWindowId(connection_id_1(), 1); | 696 Id window_1_1 = BuildWindowId(connection_id_1(), 1); |
| 697 Id window_2_2 = wt_client2()->NewWindow(2); | 697 Id window_2_2 = wt_client2()->NewWindow(2); |
| 698 ASSERT_TRUE(window_2_2); | 698 ASSERT_TRUE(window_2_2); |
| 699 ASSERT_TRUE(wt_client2()->AddWindow(window_1_1, window_2_2)); | 699 ASSERT_TRUE(wt_client2()->AddWindow(window_1_1, window_2_2)); |
| 700 | 700 |
| 701 ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(wt2(), window_2_2)); | 701 ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(wt2(), window_2_2)); |
| 702 | 702 |
| 703 Id window_3_3 = wt_client3()->NewWindow(3); | 703 Id window_3_3 = wt_client3()->NewWindow(3); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 732 // but the ids are in the id space of client2, which is not the same as | 732 // but the ids are in the id space of client2, which is not the same as |
| 733 // the id space of wt1(). | 733 // the id space of wt1(). |
| 734 EXPECT_EQ("window=2,1 parent=1,1", windows[1].ToString()); | 734 EXPECT_EQ("window=2,1 parent=1,1", windows[1].ToString()); |
| 735 // Same thing here, we really want to test for | 735 // Same thing here, we really want to test for |
| 736 // WindowParentToString(window_3_3, window_2_2). | 736 // WindowParentToString(window_3_3, window_2_2). |
| 737 EXPECT_EQ("window=3,1 parent=2,1", windows[2].ToString()); | 737 EXPECT_EQ("window=3,1 parent=2,1", windows[2].ToString()); |
| 738 } | 738 } |
| 739 } | 739 } |
| 740 | 740 |
| 741 // Verifies once Embed() has been invoked the parent can't mutate the children. | 741 // Verifies once Embed() has been invoked the parent can't mutate the children. |
| 742 TEST_F(WindowTreeClientTest, DISABLED_CantModifyChildrenOfEmbeddedWindow) { | 742 TEST_F(WindowTreeClientTest, CantModifyChildrenOfEmbeddedWindow) { |
| 743 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); | 743 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); |
| 744 | 744 |
| 745 Id window_1_1 = BuildWindowId(connection_id_1(), 1); | 745 Id window_1_1 = BuildWindowId(connection_id_1(), 1); |
| 746 Id window_2_1 = wt_client2()->NewWindow(1); | 746 Id window_2_1 = wt_client2()->NewWindow(1); |
| 747 ASSERT_TRUE(window_2_1); | 747 ASSERT_TRUE(window_2_1); |
| 748 ASSERT_TRUE(wt_client2()->AddWindow(window_1_1, window_2_1)); | 748 ASSERT_TRUE(wt_client2()->AddWindow(window_1_1, window_2_1)); |
| 749 | 749 |
| 750 ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(wt2(), window_2_1)); | 750 ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(wt2(), window_2_1)); |
| 751 | 751 |
| 752 Id window_2_2 = wt_client2()->NewWindow(2); | 752 Id window_2_2 = wt_client2()->NewWindow(2); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); | 809 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); |
| 810 | 810 |
| 811 // Make 3 a child of 2. | 811 // Make 3 a child of 2. |
| 812 ASSERT_TRUE(wt_client1()->AddWindow(window_1_2, window_1_3)); | 812 ASSERT_TRUE(wt_client1()->AddWindow(window_1_2, window_1_3)); |
| 813 | 813 |
| 814 // Try to make 2 a child of 3, this should fail since 2 is an ancestor of 3. | 814 // Try to make 2 a child of 3, this should fail since 2 is an ancestor of 3. |
| 815 EXPECT_FALSE(wt_client1()->AddWindow(window_1_3, window_1_2)); | 815 EXPECT_FALSE(wt_client1()->AddWindow(window_1_3, window_1_2)); |
| 816 } | 816 } |
| 817 | 817 |
| 818 // Verifies adding to root sends right notifications. | 818 // Verifies adding to root sends right notifications. |
| 819 TEST_F(WindowTreeClientTest, DISABLED_AddToRoot) { | 819 TEST_F(WindowTreeClientTest, AddToRoot) { |
| 820 // Create the embed point now so that the ids line up. | 820 // Create the embed point now so that the ids line up. |
| 821 Id window_1_1 = wt_client1()->NewWindow(1); | 821 Id window_1_1 = wt_client1()->NewWindow(1); |
| 822 ASSERT_TRUE(window_1_1); | 822 ASSERT_TRUE(window_1_1); |
| 823 Id window_1_21 = wt_client1()->NewWindow(21); | 823 Id window_1_21 = wt_client1()->NewWindow(21); |
| 824 Id window_1_3 = wt_client1()->NewWindow(3); | 824 Id window_1_3 = wt_client1()->NewWindow(3); |
| 825 ASSERT_TRUE(window_1_21); | 825 ASSERT_TRUE(window_1_21); |
| 826 ASSERT_TRUE(window_1_3); | 826 ASSERT_TRUE(window_1_3); |
| 827 | 827 |
| 828 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); | 828 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); |
| 829 changes2()->clear(); | 829 changes2()->clear(); |
| 830 | 830 |
| 831 // Make 3 a child of 21. | 831 // Make 3 a child of 21. |
| 832 ASSERT_TRUE(wt_client1()->AddWindow(window_1_21, window_1_3)); | 832 ASSERT_TRUE(wt_client1()->AddWindow(window_1_21, window_1_3)); |
| 833 | 833 |
| 834 // Make 21 a child of 1. | 834 // Make 21 a child of 1. |
| 835 ASSERT_TRUE(wt_client1()->AddWindow(window_1_1, window_1_21)); | 835 ASSERT_TRUE(wt_client1()->AddWindow(window_1_1, window_1_21)); |
| 836 | 836 |
| 837 // Connection 2 should not be told anything (because the window is from a | 837 // Connection 2 should not be told anything (because the window is from a |
| 838 // different connection). Create a window to ensure we got a response from | 838 // different connection). Create a window to ensure we got a response from |
| 839 // the server. | 839 // the server. |
| 840 ASSERT_TRUE(wt_client2()->NewWindow(100)); | 840 ASSERT_TRUE(wt_client2()->NewWindow(100)); |
| 841 EXPECT_TRUE(changes2()->empty()); | 841 EXPECT_TRUE(changes2()->empty()); |
| 842 } | 842 } |
| 843 | 843 |
| 844 // Verifies HierarchyChanged is correctly sent for various adds/removes. | 844 // Verifies HierarchyChanged is correctly sent for various adds/removes. |
| 845 TEST_F(WindowTreeClientTest, DISABLED_WindowHierarchyChangedWindows) { | 845 TEST_F(WindowTreeClientTest, WindowHierarchyChangedWindows) { |
| 846 // Create the embed point now so that the ids line up. | 846 // Create the embed point now so that the ids line up. |
| 847 Id window_1_1 = wt_client1()->NewWindow(1); | 847 Id window_1_1 = wt_client1()->NewWindow(1); |
| 848 // 1,2->1,11. | 848 // 1,2->1,11. |
| 849 Id window_1_2 = wt_client1()->NewWindow(2); | 849 Id window_1_2 = wt_client1()->NewWindow(2); |
| 850 ASSERT_TRUE(window_1_2); | 850 ASSERT_TRUE(window_1_2); |
| 851 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_2, true)); | 851 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_2, true)); |
| 852 Id window_1_11 = wt_client1()->NewWindow(11); | 852 Id window_1_11 = wt_client1()->NewWindow(11); |
| 853 ASSERT_TRUE(window_1_11); | 853 ASSERT_TRUE(window_1_11); |
| 854 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_11, true)); | 854 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_11, true)); |
| 855 ASSERT_TRUE(wt_client1()->AddWindow(window_1_2, window_1_11)); | 855 ASSERT_TRUE(wt_client1()->AddWindow(window_1_2, window_1_11)); |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1109 wt_client1_->WaitForChangeCount(1); | 1109 wt_client1_->WaitForChangeCount(1); |
| 1110 EXPECT_EQ("HierarchyChanged window=" + IdToString(window_2_1) + | 1110 EXPECT_EQ("HierarchyChanged window=" + IdToString(window_2_1) + |
| 1111 " new_parent=" + IdToString(window_1_1) + " old_parent=null", | 1111 " new_parent=" + IdToString(window_1_1) + " old_parent=null", |
| 1112 SingleChangeToDescription(*changes1())); | 1112 SingleChangeToDescription(*changes1())); |
| 1113 EXPECT_EQ("[" + WindowParentToString(window_2_1, window_1_1) + "]", | 1113 EXPECT_EQ("[" + WindowParentToString(window_2_1, window_1_1) + "]", |
| 1114 ChangeWindowDescription(*changes1())); | 1114 ChangeWindowDescription(*changes1())); |
| 1115 } | 1115 } |
| 1116 } | 1116 } |
| 1117 | 1117 |
| 1118 // Assertions for GetWindowTree. | 1118 // Assertions for GetWindowTree. |
| 1119 TEST_F(WindowTreeClientTest, DISABLED_GetWindowTree) { | 1119 TEST_F(WindowTreeClientTest, GetWindowTree) { |
| 1120 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); | 1120 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); |
| 1121 Id window_1_1 = BuildWindowId(connection_id_1(), 1); | 1121 Id window_1_1 = BuildWindowId(connection_id_1(), 1); |
| 1122 | 1122 |
| 1123 // Create 11 in first connection and make it a child of 1. | 1123 // Create 11 in first connection and make it a child of 1. |
| 1124 Id window_1_11 = wt_client1()->NewWindow(11); | 1124 Id window_1_11 = wt_client1()->NewWindow(11); |
| 1125 ASSERT_TRUE(window_1_11); | 1125 ASSERT_TRUE(window_1_11); |
| 1126 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1)); | 1126 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1)); |
| 1127 ASSERT_TRUE(wt_client1()->AddWindow(window_1_1, window_1_11)); | 1127 ASSERT_TRUE(wt_client1()->AddWindow(window_1_1, window_1_11)); |
| 1128 | 1128 |
| 1129 // Create two windows in second connection, 2 and 3, both children of 1. | 1129 // Create two windows in second connection, 2 and 3, both children of 1. |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1693 TestWindowTreeClientImpl client2; | 1693 TestWindowTreeClientImpl client2; |
| 1694 mojom::WindowTreeClientPtr client2_ptr; | 1694 mojom::WindowTreeClientPtr client2_ptr; |
| 1695 mojo::Binding<WindowTreeClient> client2_binding(&client2, &client2_ptr); | 1695 mojo::Binding<WindowTreeClient> client2_binding(&client2, &client2_ptr); |
| 1696 ASSERT_TRUE(Embed(wt1(), BuildWindowId(connection_id_1(), 1), | 1696 ASSERT_TRUE(Embed(wt1(), BuildWindowId(connection_id_1(), 1), |
| 1697 std::move(client2_ptr))); | 1697 std::move(client2_ptr))); |
| 1698 client2.WaitForOnEmbed(); | 1698 client2.WaitForOnEmbed(); |
| 1699 EXPECT_EQ("OnEmbed", | 1699 EXPECT_EQ("OnEmbed", |
| 1700 SingleChangeToDescription(*client2.tracker()->changes())); | 1700 SingleChangeToDescription(*client2.tracker()->changes())); |
| 1701 } | 1701 } |
| 1702 | 1702 |
| 1703 TEST_F(WindowTreeClientTest, DISABLED_EmbedFailsFromOtherConnection) { | 1703 TEST_F(WindowTreeClientTest, EmbedFailsFromOtherConnection) { |
| 1704 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); | 1704 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); |
| 1705 | 1705 |
| 1706 Id window_1_1 = BuildWindowId(connection_id_1(), 1); | 1706 Id window_1_1 = BuildWindowId(connection_id_1(), 1); |
| 1707 Id window_2_1 = wt_client2()->NewWindow(1); | 1707 Id window_2_1 = wt_client2()->NewWindow(1); |
| 1708 ASSERT_TRUE(window_2_1); | 1708 ASSERT_TRUE(window_2_1); |
| 1709 ASSERT_TRUE(wt_client2()->AddWindow(window_1_1, window_2_1)); | 1709 ASSERT_TRUE(wt_client2()->AddWindow(window_1_1, window_2_1)); |
| 1710 ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(wt2(), window_2_1)); | 1710 ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(wt2(), window_2_1)); |
| 1711 | 1711 |
| 1712 Id window_3_3 = wt_client3()->NewWindow(3); | 1712 Id window_3_3 = wt_client3()->NewWindow(3); |
| 1713 ASSERT_TRUE(window_3_3); | 1713 ASSERT_TRUE(window_3_3); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1730 | 1730 |
| 1731 changes2()->clear(); | 1731 changes2()->clear(); |
| 1732 | 1732 |
| 1733 // Establish a third connection in window_2_1. | 1733 // Establish a third connection in window_2_1. |
| 1734 ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(wt1(), window_2_1)); | 1734 ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(wt1(), window_2_1)); |
| 1735 | 1735 |
| 1736 ASSERT_TRUE(wt_client2()->WaitForAllMessages()); | 1736 ASSERT_TRUE(wt_client2()->WaitForAllMessages()); |
| 1737 EXPECT_EQ(std::string(), SingleChangeToDescription(*changes2())); | 1737 EXPECT_EQ(std::string(), SingleChangeToDescription(*changes2())); |
| 1738 } | 1738 } |
| 1739 | 1739 |
| 1740 TEST_F(WindowTreeClientTest, DISABLED_CantEmbedFromConnectionRoot) { | 1740 TEST_F(WindowTreeClientTest, CantEmbedFromConnectionRoot) { |
| 1741 // Shouldn't be able to embed into the root. | 1741 // Shouldn't be able to embed into the root. |
| 1742 ASSERT_FALSE(EmbedUrl(connector(), wt1(), test_name(), root_window_id())); | 1742 ASSERT_FALSE(EmbedUrl(connector(), wt1(), test_name(), root_window_id())); |
| 1743 | 1743 |
| 1744 // Even though the call above failed a WindowTreeClient was obtained. We need | 1744 // Even though the call above failed a WindowTreeClient was obtained. We need |
| 1745 // to | 1745 // to |
| 1746 // wait for it else we throw off the next connect. | 1746 // wait for it else we throw off the next connect. |
| 1747 WaitForWindowTreeClient(); | 1747 WaitForWindowTreeClient(); |
| 1748 | 1748 |
| 1749 // Don't allow a connection to embed into its own root. | 1749 // Don't allow a connection to embed into its own root. |
| 1750 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); | 1750 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1915 | 1915 |
| 1916 // TODO(sky): make sure coverage of what was | 1916 // TODO(sky): make sure coverage of what was |
| 1917 // WindowManagerTest.SecondEmbedRoot_InitService and | 1917 // WindowManagerTest.SecondEmbedRoot_InitService and |
| 1918 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window | 1918 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window |
| 1919 // manager | 1919 // manager |
| 1920 // tests. | 1920 // tests. |
| 1921 | 1921 |
| 1922 } // namespace test | 1922 } // namespace test |
| 1923 } // namespace ws | 1923 } // namespace ws |
| 1924 } // namespace mus | 1924 } // namespace mus |
| OLD | NEW |