| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "components/mus/public/interfaces/window_tree.mojom.h" | 9 #include "components/mus/public/interfaces/window_tree.mojom.h" |
| 10 #include "components/mus/public/interfaces/window_tree_host.mojom.h" | 10 #include "components/mus/public/interfaces/window_tree_host.mojom.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 // ----------------------------------------------------------------------------- | 69 // ----------------------------------------------------------------------------- |
| 70 | 70 |
| 71 bool EmbedUrl(mojo::ApplicationImpl* app, | 71 bool EmbedUrl(mojo::ApplicationImpl* app, |
| 72 WindowTree* ws, | 72 WindowTree* ws, |
| 73 const String& url, | 73 const String& url, |
| 74 Id root_id) { | 74 Id root_id) { |
| 75 bool result = false; | 75 bool result = false; |
| 76 base::RunLoop run_loop; | 76 base::RunLoop run_loop; |
| 77 { | 77 { |
| 78 mojo::URLRequestPtr request(mojo::URLRequest::New()); | |
| 79 request->url = mojo::String::From(url); | |
| 80 scoped_ptr<ApplicationConnection> connection = | |
| 81 app->ConnectToApplication(request.Pass()); | |
| 82 mojom::WindowTreeClientPtr client; | 78 mojom::WindowTreeClientPtr client; |
| 83 connection->ConnectToService(&client); | 79 app->ConnectToService(url.get(), &client); |
| 84 ws->Embed(root_id, client.Pass(), mojom::WindowTree::ACCESS_POLICY_DEFAULT, | 80 ws->Embed(root_id, client.Pass(), mojom::WindowTree::ACCESS_POLICY_DEFAULT, |
| 85 base::Bind(&EmbedCallbackImpl, &run_loop, &result)); | 81 base::Bind(&EmbedCallbackImpl, &run_loop, &result)); |
| 86 } | 82 } |
| 87 run_loop.Run(); | 83 run_loop.Run(); |
| 88 return result; | 84 return result; |
| 89 } | 85 } |
| 90 | 86 |
| 91 bool Embed(WindowTree* ws, Id root_id, mojom::WindowTreeClientPtr client) { | 87 bool Embed(WindowTree* ws, Id root_id, mojom::WindowTreeClientPtr client) { |
| 92 bool result = false; | 88 bool result = false; |
| 93 base::RunLoop run_loop; | 89 base::RunLoop run_loop; |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 if (connection_id) | 529 if (connection_id) |
| 534 *connection_id = (*client->tracker()->changes())[0].connection_id; | 530 *connection_id = (*client->tracker()->changes())[0].connection_id; |
| 535 return client.Pass(); | 531 return client.Pass(); |
| 536 } | 532 } |
| 537 | 533 |
| 538 // ApplicationTestBase: | 534 // ApplicationTestBase: |
| 539 ApplicationDelegate* GetApplicationDelegate() override { return this; } | 535 ApplicationDelegate* GetApplicationDelegate() override { return this; } |
| 540 void SetUp() override { | 536 void SetUp() override { |
| 541 ApplicationTestBase::SetUp(); | 537 ApplicationTestBase::SetUp(); |
| 542 client_factory_.reset(new WindowTreeClientFactory(application_impl())); | 538 client_factory_.reset(new WindowTreeClientFactory(application_impl())); |
| 543 mojo::URLRequestPtr request(mojo::URLRequest::New()); | |
| 544 request->url = mojo::String::From("mojo:mus"); | |
| 545 | 539 |
| 546 mojom::WindowTreeHostFactoryPtr factory; | 540 mojom::WindowTreeHostFactoryPtr factory; |
| 547 application_impl()->ConnectToService(request.Pass(), &factory); | 541 application_impl()->ConnectToService("mojo:mus", &factory); |
| 548 | 542 |
| 549 mojom::WindowTreeClientPtr tree_client_ptr; | 543 mojom::WindowTreeClientPtr tree_client_ptr; |
| 550 ws_client1_.reset(new TestWindowTreeClientImpl(application_impl())); | 544 ws_client1_.reset(new TestWindowTreeClientImpl(application_impl())); |
| 551 ws_client1_->Bind(GetProxy(&tree_client_ptr)); | 545 ws_client1_->Bind(GetProxy(&tree_client_ptr)); |
| 552 | 546 |
| 553 factory->CreateWindowTreeHost(GetProxy(&host_), | 547 factory->CreateWindowTreeHost(GetProxy(&host_), |
| 554 mojom::WindowTreeHostClientPtr(), | 548 mojom::WindowTreeHostClientPtr(), |
| 555 tree_client_ptr.Pass(), nullptr); | 549 tree_client_ptr.Pass(), nullptr); |
| 556 | 550 |
| 557 // Next we should get an embed call on the "window manager" client. | 551 // Next we should get an embed call on the "window manager" client. |
| (...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1768 // originating connection. | 1762 // originating connection. |
| 1769 | 1763 |
| 1770 // TODO(sky): make sure coverage of what was | 1764 // TODO(sky): make sure coverage of what was |
| 1771 // WindowManagerTest.SecondEmbedRoot_InitService and | 1765 // WindowManagerTest.SecondEmbedRoot_InitService and |
| 1772 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window | 1766 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window |
| 1773 // manager | 1767 // manager |
| 1774 // tests. | 1768 // tests. |
| 1775 | 1769 |
| 1776 } // namespace ws | 1770 } // namespace ws |
| 1777 } // namespace mus | 1771 } // namespace mus |
| OLD | NEW |