| 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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 Window* window = connection->NewWindow(); | 216 Window* window = connection->NewWindow(); |
| 217 window->SetVisible(true); | 217 window->SetVisible(true); |
| 218 parent->AddChild(window); | 218 parent->AddChild(window); |
| 219 return window; | 219 return window; |
| 220 } | 220 } |
| 221 | 221 |
| 222 // Embeds another version of the test app @ window. This runs a run loop until | 222 // Embeds another version of the test app @ window. This runs a run loop until |
| 223 // a response is received, or a timeout. On success the new WindowServer is | 223 // a response is received, or a timeout. On success the new WindowServer is |
| 224 // returned. | 224 // returned. |
| 225 EmbedResult Embed(Window* window) { | 225 EmbedResult Embed(Window* window) { |
| 226 return Embed(window, mus::mojom::WindowTree::ACCESS_POLICY_DEFAULT); | 226 return Embed(window, mus::mojom::WindowTree::kAccessPolicyDefault); |
| 227 } | 227 } |
| 228 | 228 |
| 229 EmbedResult Embed(Window* window, uint32_t access_policy_bitmask) { | 229 EmbedResult Embed(Window* window, uint32_t access_policy_bitmask) { |
| 230 DCHECK(!embed_details_); | 230 DCHECK(!embed_details_); |
| 231 embed_details_.reset(new EmbedDetails); | 231 embed_details_.reset(new EmbedDetails); |
| 232 window->Embed(ConnectToApplicationAndGetWindowServerClient(), | 232 window->Embed(ConnectToApplicationAndGetWindowServerClient(), |
| 233 access_policy_bitmask, | 233 access_policy_bitmask, |
| 234 base::Bind(&WindowServerTest::EmbedCallbackImpl, | 234 base::Bind(&WindowServerTest::EmbedCallbackImpl, |
| 235 base::Unretained(this))); | 235 base::Unretained(this))); |
| 236 embed_details_->waiting = true; | 236 embed_details_->waiting = true; |
| (...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 984 EXPECT_TRUE(got_destroy); | 984 EXPECT_TRUE(got_destroy); |
| 985 } | 985 } |
| 986 | 986 |
| 987 // Verifies an embed root sees windows created beneath it from another | 987 // Verifies an embed root sees windows created beneath it from another |
| 988 // connection. | 988 // connection. |
| 989 TEST_F(WindowServerTest, EmbedRootSeesHierarchyChanged) { | 989 TEST_F(WindowServerTest, EmbedRootSeesHierarchyChanged) { |
| 990 Window* embed_window = window_manager()->NewWindow(); | 990 Window* embed_window = window_manager()->NewWindow(); |
| 991 window_manager()->GetRoot()->AddChild(embed_window); | 991 window_manager()->GetRoot()->AddChild(embed_window); |
| 992 | 992 |
| 993 WindowTreeConnection* vm2 = | 993 WindowTreeConnection* vm2 = |
| 994 Embed(embed_window, mus::mojom::WindowTree::ACCESS_POLICY_EMBED_ROOT) | 994 Embed(embed_window, mus::mojom::WindowTree::kAccessPolicyEmbedRoot) |
| 995 .connection; | 995 .connection; |
| 996 Window* vm2_v1 = vm2->NewWindow(); | 996 Window* vm2_v1 = vm2->NewWindow(); |
| 997 vm2->GetRoot()->AddChild(vm2_v1); | 997 vm2->GetRoot()->AddChild(vm2_v1); |
| 998 | 998 |
| 999 WindowTreeConnection* vm3 = Embed(vm2_v1).connection; | 999 WindowTreeConnection* vm3 = Embed(vm2_v1).connection; |
| 1000 Window* vm3_v1 = vm3->NewWindow(); | 1000 Window* vm3_v1 = vm3->NewWindow(); |
| 1001 vm3->GetRoot()->AddChild(vm3_v1); | 1001 vm3->GetRoot()->AddChild(vm3_v1); |
| 1002 | 1002 |
| 1003 // As |vm2| is an embed root it should get notified about |vm3_v1|. | 1003 // As |vm2| is an embed root it should get notified about |vm3_v1|. |
| 1004 ASSERT_TRUE(WaitForTreeSizeToMatch(vm2_v1, 2)); | 1004 ASSERT_TRUE(WaitForTreeSizeToMatch(vm2_v1, 2)); |
| 1005 } | 1005 } |
| 1006 | 1006 |
| 1007 TEST_F(WindowServerTest, EmbedFromEmbedRoot) { | 1007 TEST_F(WindowServerTest, EmbedFromEmbedRoot) { |
| 1008 Window* embed_window = window_manager()->NewWindow(); | 1008 Window* embed_window = window_manager()->NewWindow(); |
| 1009 window_manager()->GetRoot()->AddChild(embed_window); | 1009 window_manager()->GetRoot()->AddChild(embed_window); |
| 1010 | 1010 |
| 1011 // Give the connection embedded at |embed_window| embed root powers. | 1011 // Give the connection embedded at |embed_window| embed root powers. |
| 1012 const EmbedResult result1 = | 1012 const EmbedResult result1 = |
| 1013 Embed(embed_window, mus::mojom::WindowTree::ACCESS_POLICY_EMBED_ROOT); | 1013 Embed(embed_window, mus::mojom::WindowTree::kAccessPolicyEmbedRoot); |
| 1014 WindowTreeConnection* vm2 = result1.connection; | 1014 WindowTreeConnection* vm2 = result1.connection; |
| 1015 EXPECT_EQ(result1.connection_id, vm2->GetConnectionId()); | 1015 EXPECT_EQ(result1.connection_id, vm2->GetConnectionId()); |
| 1016 Window* vm2_v1 = vm2->NewWindow(); | 1016 Window* vm2_v1 = vm2->NewWindow(); |
| 1017 vm2->GetRoot()->AddChild(vm2_v1); | 1017 vm2->GetRoot()->AddChild(vm2_v1); |
| 1018 | 1018 |
| 1019 const EmbedResult result2 = Embed(vm2_v1); | 1019 const EmbedResult result2 = Embed(vm2_v1); |
| 1020 WindowTreeConnection* vm3 = result2.connection; | 1020 WindowTreeConnection* vm3 = result2.connection; |
| 1021 EXPECT_EQ(result2.connection_id, vm3->GetConnectionId()); | 1021 EXPECT_EQ(result2.connection_id, vm3->GetConnectionId()); |
| 1022 Window* vm3_v1 = vm3->NewWindow(); | 1022 Window* vm3_v1 = vm3->NewWindow(); |
| 1023 vm3->GetRoot()->AddChild(vm3_v1); | 1023 vm3->GetRoot()->AddChild(vm3_v1); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 WaitForBoundsToChange(embedded_connection->GetRoot()); | 1056 WaitForBoundsToChange(embedded_connection->GetRoot()); |
| 1057 EXPECT_TRUE(gfx::Rect(21, 22, 23, 24) == | 1057 EXPECT_TRUE(gfx::Rect(21, 22, 23, 24) == |
| 1058 embedded_connection->GetRoot()->bounds()); | 1058 embedded_connection->GetRoot()->bounds()); |
| 1059 EXPECT_TRUE(gfx::Insets(1, 2, 3, 4) == | 1059 EXPECT_TRUE(gfx::Insets(1, 2, 3, 4) == |
| 1060 embedded_connection->GetRoot()->client_area()); | 1060 embedded_connection->GetRoot()->client_area()); |
| 1061 } | 1061 } |
| 1062 | 1062 |
| 1063 } // namespace ws | 1063 } // namespace ws |
| 1064 | 1064 |
| 1065 } // namespace mus | 1065 } // namespace mus |
| OLD | NEW |