| 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 "components/view_manager/ids.h" | 8 #include "components/view_manager/ids.h" |
| 9 #include "components/view_manager/public/interfaces/view_manager.mojom.h" | 9 #include "components/view_manager/public/interfaces/view_manager.mojom.h" |
| 10 #include "components/view_manager/public/interfaces/view_manager_root.mojom.h" | 10 #include "components/view_manager/public/interfaces/view_manager_root.mojom.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 vm->CreateView(view_id, | 76 vm->CreateView(view_id, |
| 77 base::Bind(&ErrorCodeResultCallback, &run_loop, &result)); | 77 base::Bind(&ErrorCodeResultCallback, &run_loop, &result)); |
| 78 run_loop.Run(); | 78 run_loop.Run(); |
| 79 return result == ERROR_CODE_NONE; | 79 return result == ERROR_CODE_NONE; |
| 80 } | 80 } |
| 81 | 81 |
| 82 bool EmbedUrl(ViewManagerService* vm, const String& url, Id root_id) { | 82 bool EmbedUrl(ViewManagerService* vm, const String& url, Id root_id) { |
| 83 bool result = false; | 83 bool result = false; |
| 84 base::RunLoop run_loop; | 84 base::RunLoop run_loop; |
| 85 { | 85 { |
| 86 vm->EmbedUrl(url, root_id, nullptr, nullptr, | 86 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 87 base::Bind(&BoolResultCallback, &run_loop, &result)); | 87 request->url = mojo::String::From(url); |
| 88 vm->EmbedRequest(request.Pass(), root_id, nullptr, nullptr, |
| 89 base::Bind(&BoolResultCallback, &run_loop, &result)); |
| 88 } | 90 } |
| 89 run_loop.Run(); | 91 run_loop.Run(); |
| 90 return result; | 92 return result; |
| 91 } | 93 } |
| 92 | 94 |
| 93 bool Embed(ViewManagerService* vm, | 95 bool Embed(ViewManagerService* vm, |
| 94 Id root_id, | 96 Id root_id, |
| 95 mojo::ViewManagerClientPtr client) { | 97 mojo::ViewManagerClientPtr client) { |
| 96 bool result = false; | 98 bool result = false; |
| 97 base::RunLoop run_loop; | 99 base::RunLoop run_loop; |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 | 455 |
| 454 EXPECT_EQ("OnEmbed creator=" + application_impl()->url(), | 456 EXPECT_EQ("OnEmbed creator=" + application_impl()->url(), |
| 455 SingleChangeToDescription(*client->tracker()->changes())); | 457 SingleChangeToDescription(*client->tracker()->changes())); |
| 456 return client.Pass(); | 458 return client.Pass(); |
| 457 } | 459 } |
| 458 | 460 |
| 459 // ApplicationTestBase: | 461 // ApplicationTestBase: |
| 460 ApplicationDelegate* GetApplicationDelegate() override { return this; } | 462 ApplicationDelegate* GetApplicationDelegate() override { return this; } |
| 461 void SetUp() override { | 463 void SetUp() override { |
| 462 ApplicationTestBase::SetUp(); | 464 ApplicationTestBase::SetUp(); |
| 465 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 466 request->url = mojo::String::From("mojo:view_manager"); |
| 463 ApplicationConnection* vm_connection = | 467 ApplicationConnection* vm_connection = |
| 464 application_impl()->ConnectToApplication("mojo:view_manager"); | 468 application_impl()->ConnectToApplication(request.Pass()); |
| 465 vm_connection->ConnectToService(&vm1_); | 469 vm_connection->ConnectToService(&vm1_); |
| 466 vm_connection->ConnectToService(&view_manager_root_); | 470 vm_connection->ConnectToService(&view_manager_root_); |
| 467 vm_connection->AddService(&client_factory_); | 471 vm_connection->AddService(&client_factory_); |
| 468 vm_client1_ = client_factory_.WaitForInstance(); | 472 vm_client1_ = client_factory_.WaitForInstance(); |
| 469 ASSERT_TRUE(vm_client1_); | 473 ASSERT_TRUE(vm_client1_); |
| 470 // Next we should get an embed call on the "window manager" client. | 474 // Next we should get an embed call on the "window manager" client. |
| 471 vm_client1_->WaitForIncomingMethodCall(); | 475 vm_client1_->WaitForIncomingMethodCall(); |
| 472 ASSERT_EQ(1u, changes1()->size()); | 476 ASSERT_EQ(1u, changes1()->size()); |
| 473 EXPECT_EQ(CHANGE_TYPE_EMBED, (*changes1())[0].type); | 477 EXPECT_EQ(CHANGE_TYPE_EMBED, (*changes1())[0].type); |
| 474 // All these tests assume 1 for the client id. The only real assertion here | 478 // All these tests assume 1 for the client id. The only real assertion here |
| (...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1444 // TODO(sky): need to better track changes to initial connection. For example, | 1448 // TODO(sky): need to better track changes to initial connection. For example, |
| 1445 // that SetBounsdViews/AddView and the like don't result in messages to the | 1449 // that SetBounsdViews/AddView and the like don't result in messages to the |
| 1446 // originating connection. | 1450 // originating connection. |
| 1447 | 1451 |
| 1448 // TODO(sky): make sure coverage of what was | 1452 // TODO(sky): make sure coverage of what was |
| 1449 // ViewManagerTest.SecondEmbedRoot_InitService and | 1453 // ViewManagerTest.SecondEmbedRoot_InitService and |
| 1450 // ViewManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window manager | 1454 // ViewManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window manager |
| 1451 // tests. | 1455 // tests. |
| 1452 | 1456 |
| 1453 } // namespace view_manager | 1457 } // namespace view_manager |
| OLD | NEW |