Chromium Code Reviews| 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 "ui/aura/mus/window_tree_client.h" | 5 #include "ui/aura/mus/window_tree_client.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 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 899 server_id(&transient)); | 899 server_id(&transient)); |
| 900 EXPECT_EQ(&parent, transient_client->GetTransientParent(&transient)); | 900 EXPECT_EQ(&parent, transient_client->GetTransientParent(&transient)); |
| 901 | 901 |
| 902 // Remove locally. | 902 // Remove locally. |
| 903 transient_client->RemoveTransientChild(&parent, &transient); | 903 transient_client->RemoveTransientChild(&parent, &transient); |
| 904 ASSERT_EQ(1u, window_tree()->GetChangeCountForType( | 904 ASSERT_EQ(1u, window_tree()->GetChangeCountForType( |
| 905 WindowTreeChangeType::REMOVE_TRANSIENT)); | 905 WindowTreeChangeType::REMOVE_TRANSIENT)); |
| 906 EXPECT_EQ(server_id(&transient), window_tree()->transient_data().child_id); | 906 EXPECT_EQ(server_id(&transient), window_tree()->transient_data().child_id); |
| 907 } | 907 } |
| 908 | 908 |
| 909 // Verifies adding/removing a transient child doesn't notify the server of the | |
| 910 // restack when the change originates from the server. | |
| 911 TEST_F(WindowTreeClientClientTest, | |
| 912 TransientChildServerMutateDoesntNotifyOfRestack) { | |
| 913 Window* w1 = new Window(nullptr); | |
| 914 w1->Init(ui::LAYER_NOT_DRAWN); | |
| 915 root_window()->AddChild(w1); | |
| 916 Window* w2 = new Window(nullptr); | |
| 917 w2->Init(ui::LAYER_NOT_DRAWN); | |
| 918 root_window()->AddChild(w2); | |
| 919 Window* w3 = new Window(nullptr); | |
| 920 w3->Init(ui::LAYER_NOT_DRAWN); | |
| 921 root_window()->AddChild(w3); | |
| 922 // Three children of root: |w1|, |w2| and |w3| (in that order). Make |w1| a | |
| 923 // transient child of |w2|. Should trigger moving |w1| on top of |w2|, but not | |
| 924 // notify the server of the reorder. | |
| 925 window_tree()->AckAllChanges(); | |
| 926 window_tree_client()->OnTransientWindowAdded(server_id(w2), server_id(w1)); | |
| 927 EXPECT_EQ(w2, root_window()->children()[0]); | |
| 928 EXPECT_EQ(w1, root_window()->children()[1]); | |
| 929 EXPECT_EQ(w3, root_window()->children()[2]); | |
| 930 // No changes should be scheduled. | |
| 931 EXPECT_EQ(0u, window_tree()->number_of_changes()); | |
| 932 | |
| 933 // Make |w3| also a transient child of |w2|. Order shouldn't change. | |
| 934 window_tree_client()->OnTransientWindowAdded(server_id(w2), server_id(w3)); | |
| 935 EXPECT_EQ(w2, root_window()->children()[0]); | |
| 936 EXPECT_EQ(w1, root_window()->children()[1]); | |
| 937 EXPECT_EQ(w3, root_window()->children()[2]); | |
| 938 EXPECT_EQ(0u, window_tree()->number_of_changes()); | |
| 939 | |
| 940 // Remove |w1| as a transient child, this should move |w3| on top of |w2|. | |
| 941 window_tree_client()->OnTransientWindowRemoved(server_id(w2), server_id(w1)); | |
| 942 EXPECT_EQ(w2, root_window()->children()[0]); | |
| 943 EXPECT_EQ(w3, root_window()->children()[1]); | |
| 944 EXPECT_EQ(w1, root_window()->children()[2]); | |
| 945 EXPECT_EQ(0u, window_tree()->number_of_changes()); | |
| 946 } | |
| 947 | |
| 948 // Verifies adding/removing a transient child doesn't notify the server of the | |
|
msw
2016/11/21 19:56:34
When is the server notified of restack? Add a test
sky
2016/11/21 21:31:43
For a transient? Never. The assertions on 971/974
msw
2016/11/21 22:34:49
Okay, maybe I get it now. The server gets the call
sky
2016/11/21 22:41:10
You got it. If a reorder needs to happen, the serv
| |
| 949 // restack when the change originates from the client. | |
| 950 TEST_F(WindowTreeClientClientTest, | |
| 951 TransientChildClientMutateDoesntNotifyOfRestack) { | |
| 952 client::TransientWindowClient* transient_client = | |
| 953 client::GetTransientWindowClient(); | |
| 954 Window* w1 = new Window(nullptr); | |
| 955 w1->Init(ui::LAYER_NOT_DRAWN); | |
| 956 root_window()->AddChild(w1); | |
| 957 Window* w2 = new Window(nullptr); | |
| 958 w2->Init(ui::LAYER_NOT_DRAWN); | |
| 959 root_window()->AddChild(w2); | |
| 960 Window* w3 = new Window(nullptr); | |
| 961 w3->Init(ui::LAYER_NOT_DRAWN); | |
| 962 root_window()->AddChild(w3); | |
| 963 // Three children of root: |w1|, |w2| and |w3| (in that order). Make |w1| a | |
| 964 // transient child of |w2|. Should trigger moving |w1| on top of |w2|, but not | |
| 965 // notify the server of the reorder. | |
| 966 window_tree()->AckAllChanges(); | |
| 967 transient_client->AddTransientChild(w2, w1); | |
| 968 EXPECT_EQ(w2, root_window()->children()[0]); | |
| 969 EXPECT_EQ(w1, root_window()->children()[1]); | |
| 970 EXPECT_EQ(w3, root_window()->children()[2]); | |
| 971 // Only a single add transient change should be added. | |
| 972 EXPECT_TRUE(window_tree()->AckSingleChangeOfType( | |
| 973 WindowTreeChangeType::ADD_TRANSIENT, true)); | |
| 974 EXPECT_EQ(0u, window_tree()->number_of_changes()); | |
| 975 | |
| 976 // Make |w3| also a transient child of |w2|. Order shouldn't change. | |
| 977 window_tree_client()->OnTransientWindowAdded(server_id(w2), server_id(w3)); | |
|
msw
2016/11/21 19:56:34
Did you mean to use transient_client here and belo
sky
2016/11/21 21:31:43
Done.
| |
| 978 EXPECT_EQ(w2, root_window()->children()[0]); | |
| 979 EXPECT_EQ(w1, root_window()->children()[1]); | |
| 980 EXPECT_EQ(w3, root_window()->children()[2]); | |
| 981 EXPECT_EQ(0u, window_tree()->number_of_changes()); | |
| 982 | |
| 983 // Remove |w1| as a transient child, this should move |w3| on top of |w2|. | |
| 984 window_tree_client()->OnTransientWindowRemoved(server_id(w2), server_id(w1)); | |
| 985 EXPECT_EQ(w2, root_window()->children()[0]); | |
| 986 EXPECT_EQ(w3, root_window()->children()[1]); | |
| 987 EXPECT_EQ(w1, root_window()->children()[2]); | |
| 988 EXPECT_EQ(0u, window_tree()->number_of_changes()); | |
| 989 | |
| 990 // Make |w1| the first child and ensure a REORDER was scheduled. | |
| 991 root_window()->StackChildAtBottom(w1); | |
|
msw
2016/11/21 19:56:34
Should we test some bad behavior, like StackChildA
sky
2016/11/21 21:31:43
Ugh. This uncovered a bug in aura 667460.
| |
| 992 EXPECT_EQ(w1, root_window()->children()[0]); | |
| 993 EXPECT_EQ(w2, root_window()->children()[1]); | |
| 994 EXPECT_EQ(w3, root_window()->children()[2]); | |
| 995 EXPECT_TRUE(window_tree()->AckSingleChangeOfType( | |
| 996 WindowTreeChangeType::REORDER, true)); | |
| 997 EXPECT_EQ(0u, window_tree()->number_of_changes()); | |
| 998 } | |
| 999 | |
| 909 TEST_F(WindowTreeClientClientTest, | 1000 TEST_F(WindowTreeClientClientTest, |
| 910 TopLevelWindowDestroyedBeforeCreateComplete) { | 1001 TopLevelWindowDestroyedBeforeCreateComplete) { |
| 911 const size_t initial_root_count = | 1002 const size_t initial_root_count = |
| 912 window_tree_client_impl()->GetRoots().size(); | 1003 window_tree_client_impl()->GetRoots().size(); |
| 913 std::unique_ptr<WindowTreeHostMus> window_tree_host = | 1004 std::unique_ptr<WindowTreeHostMus> window_tree_host = |
| 914 base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl()); | 1005 base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl()); |
| 915 EXPECT_EQ(initial_root_count + 1, | 1006 EXPECT_EQ(initial_root_count + 1, |
| 916 window_tree_client_impl()->GetRoots().size()); | 1007 window_tree_client_impl()->GetRoots().size()); |
| 917 | 1008 |
| 918 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); | 1009 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1233 window1.Init(ui::LAYER_NOT_DRAWN); | 1324 window1.Init(ui::LAYER_NOT_DRAWN); |
| 1234 Window* window2 = new Window(nullptr); | 1325 Window* window2 = new Window(nullptr); |
| 1235 window2->Init(ui::LAYER_NOT_DRAWN); | 1326 window2->Init(ui::LAYER_NOT_DRAWN); |
| 1236 window1.AddChild(window2); | 1327 window1.AddChild(window2); |
| 1237 window_tree()->AckAllChanges(); | 1328 window_tree()->AckAllChanges(); |
| 1238 window_tree_client()->OnWindowDeleted(server_id(window2)); | 1329 window_tree_client()->OnWindowDeleted(server_id(window2)); |
| 1239 EXPECT_FALSE(window_tree()->has_change()); | 1330 EXPECT_FALSE(window_tree()->has_change()); |
| 1240 } | 1331 } |
| 1241 | 1332 |
| 1242 } // namespace aura | 1333 } // namespace aura |
| OLD | NEW |