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" |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
12 #include "components/mus/common/util.h" | 12 #include "components/mus/common/util.h" |
13 #include "components/mus/public/cpp/tests/window_server_test_base.h" | 13 #include "components/mus/public/cpp/tests/window_server_test_base.h" |
14 #include "components/mus/public/cpp/window_observer.h" | 14 #include "components/mus/public/cpp/window_observer.h" |
15 #include "components/mus/public/cpp/window_tree_connection.h" | 15 #include "components/mus/public/cpp/window_tree_connection.h" |
16 #include "components/mus/public/cpp/window_tree_connection_observer.h" | 16 #include "components/mus/public/cpp/window_tree_connection_observer.h" |
17 #include "components/mus/public/cpp/window_tree_delegate.h" | 17 #include "components/mus/public/cpp/window_tree_delegate.h" |
18 #include "mojo/converters/geometry/geometry_type_converters.h" | 18 #include "mojo/converters/geometry/geometry_type_converters.h" |
19 #include "mojo/shell/public/cpp/application_connection.h" | 19 #include "mojo/shell/public/cpp/application_connection.h" |
20 #include "mojo/shell/public/cpp/application_impl.h" | |
21 #include "mojo/shell/public/cpp/application_test_base.h" | 20 #include "mojo/shell/public/cpp/application_test_base.h" |
22 #include "ui/gfx/geometry/rect.h" | 21 #include "ui/gfx/geometry/rect.h" |
23 #include "ui/mojo/geometry/geometry_util.h" | 22 #include "ui/mojo/geometry/geometry_util.h" |
24 | 23 |
25 namespace mus { | 24 namespace mus { |
26 namespace ws { | 25 namespace ws { |
27 | 26 |
28 namespace { | 27 namespace { |
29 | 28 |
30 int ValidIndexOf(const Window::Children& windows, Window* window) { | 29 int ValidIndexOf(const Window::Children& windows, Window* window) { |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 embed_details_->connection_id); | 270 embed_details_->connection_id); |
272 embed_details_.reset(); | 271 embed_details_.reset(); |
273 return result; | 272 return result; |
274 } | 273 } |
275 | 274 |
276 // Establishes a connection to this application and asks for a | 275 // Establishes a connection to this application and asks for a |
277 // WindowTreeClient. | 276 // WindowTreeClient. |
278 mus::mojom::WindowTreeClientPtr | 277 mus::mojom::WindowTreeClientPtr |
279 ConnectToApplicationAndGetWindowServerClient() { | 278 ConnectToApplicationAndGetWindowServerClient() { |
280 mus::mojom::WindowTreeClientPtr client; | 279 mus::mojom::WindowTreeClientPtr client; |
281 application_impl()->ConnectToService(application_impl()->url(), &client); | 280 shell()->ConnectToService(shell_url(), &client); |
282 return client; | 281 return client; |
283 } | 282 } |
284 | 283 |
285 // WindowServerTestBase: | 284 // WindowServerTestBase: |
286 void OnEmbed(Window* root) override { | 285 void OnEmbed(Window* root) override { |
287 if (!embed_details_) { | 286 if (!embed_details_) { |
288 WindowServerTestBase::OnEmbed(root); | 287 WindowServerTestBase::OnEmbed(root); |
289 return; | 288 return; |
290 } | 289 } |
291 | 290 |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1149 scoped_ptr<base::RunLoop> run_loop_; | 1148 scoped_ptr<base::RunLoop> run_loop_; |
1150 Window* created_window_; | 1149 Window* created_window_; |
1151 | 1150 |
1152 DISALLOW_COPY_AND_ASSIGN(EstablishConnectionViaFactoryDelegate); | 1151 DISALLOW_COPY_AND_ASSIGN(EstablishConnectionViaFactoryDelegate); |
1153 }; | 1152 }; |
1154 | 1153 |
1155 TEST_F(WindowServerTest, EstablishConnectionViaFactory) { | 1154 TEST_F(WindowServerTest, EstablishConnectionViaFactory) { |
1156 EstablishConnectionViaFactoryDelegate delegate(window_manager()); | 1155 EstablishConnectionViaFactoryDelegate delegate(window_manager()); |
1157 set_window_manager_delegate(&delegate); | 1156 set_window_manager_delegate(&delegate); |
1158 scoped_ptr<WindowTreeConnection> second_connection( | 1157 scoped_ptr<WindowTreeConnection> second_connection( |
1159 WindowTreeConnection::Create(this, application_impl())); | 1158 WindowTreeConnection::Create(this, shell())); |
1160 Window* window_in_second_connection = | 1159 Window* window_in_second_connection = |
1161 second_connection->NewTopLevelWindow(nullptr); | 1160 second_connection->NewTopLevelWindow(nullptr); |
1162 ASSERT_TRUE(window_in_second_connection); | 1161 ASSERT_TRUE(window_in_second_connection); |
1163 ASSERT_TRUE(second_connection->GetRoots().count(window_in_second_connection) > | 1162 ASSERT_TRUE(second_connection->GetRoots().count(window_in_second_connection) > |
1164 0); | 1163 0); |
1165 // Wait for the window to appear in the wm. | 1164 // Wait for the window to appear in the wm. |
1166 ASSERT_TRUE(delegate.QuitOnCreate()); | 1165 ASSERT_TRUE(delegate.QuitOnCreate()); |
1167 | 1166 |
1168 Window* window_in_wm = delegate.created_window(); | 1167 Window* window_in_wm = delegate.created_window(); |
1169 ASSERT_TRUE(window_in_wm); | 1168 ASSERT_TRUE(window_in_wm); |
1170 | 1169 |
1171 // Change the bounds in the wm, and make sure the child sees it. | 1170 // Change the bounds in the wm, and make sure the child sees it. |
1172 window_in_wm->SetBounds(gfx::Rect(1, 11, 12, 101)); | 1171 window_in_wm->SetBounds(gfx::Rect(1, 11, 12, 101)); |
1173 ASSERT_TRUE(WaitForBoundsToChange(window_in_second_connection)); | 1172 ASSERT_TRUE(WaitForBoundsToChange(window_in_second_connection)); |
1174 EXPECT_EQ(gfx::Rect(1, 11, 12, 101), window_in_second_connection->bounds()); | 1173 EXPECT_EQ(gfx::Rect(1, 11, 12, 101), window_in_second_connection->bounds()); |
1175 } | 1174 } |
1176 | 1175 |
1177 } // namespace ws | 1176 } // namespace ws |
1178 } // namespace mus | 1177 } // namespace mus |
OLD | NEW |