| 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/view_manager/ids.h" | 9 #include "components/view_manager/ids.h" | 
| 10 #include "components/view_manager/public/interfaces/view_manager.mojom.h" | 10 #include "components/view_manager/public/interfaces/view_manager.mojom.h" | 
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 71 | 71 | 
| 72 bool EmbedUrl(mojo::ApplicationImpl* app, | 72 bool EmbedUrl(mojo::ApplicationImpl* app, | 
| 73               ViewManagerService* vm, | 73               ViewManagerService* vm, | 
| 74               const String& url, | 74               const String& url, | 
| 75               Id root_id) { | 75               Id root_id) { | 
| 76   bool result = false; | 76   bool result = false; | 
| 77   base::RunLoop run_loop; | 77   base::RunLoop run_loop; | 
| 78   { | 78   { | 
| 79     mojo::URLRequestPtr request(mojo::URLRequest::New()); | 79     mojo::URLRequestPtr request(mojo::URLRequest::New()); | 
| 80     request->url = mojo::String::From(url); | 80     request->url = mojo::String::From(url); | 
| 81     ApplicationConnection* connection = | 81     scoped_ptr<ApplicationConnection> connection = | 
| 82         app->ConnectToApplication(request.Pass()); | 82         app->ConnectToApplication(request.Pass()); | 
| 83     mojo::ViewManagerClientPtr client; | 83     mojo::ViewManagerClientPtr client; | 
| 84     connection->ConnectToService(&client); | 84     connection->ConnectToService(&client); | 
| 85     vm->Embed(root_id, client.Pass(), | 85     vm->Embed(root_id, client.Pass(), | 
| 86               base::Bind(&BoolResultCallback, &run_loop, &result)); | 86               base::Bind(&BoolResultCallback, &run_loop, &result)); | 
| 87   } | 87   } | 
| 88   run_loop.Run(); | 88   run_loop.Run(); | 
| 89   return result; | 89   return result; | 
| 90 } | 90 } | 
| 91 | 91 | 
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 336     tracker()->OnEmbed(connection_id, root.Pass()); | 336     tracker()->OnEmbed(connection_id, root.Pass()); | 
| 337     if (embed_run_loop_) | 337     if (embed_run_loop_) | 
| 338       embed_run_loop_->Quit(); | 338       embed_run_loop_->Quit(); | 
| 339   } | 339   } | 
| 340   void OnEmbedForDescendant( | 340   void OnEmbedForDescendant( | 
| 341       uint32_t view, | 341       uint32_t view, | 
| 342       mojo::URLRequestPtr request, | 342       mojo::URLRequestPtr request, | 
| 343       const OnEmbedForDescendantCallback& callback) override { | 343       const OnEmbedForDescendantCallback& callback) override { | 
| 344     tracker()->OnEmbedForDescendant(view); | 344     tracker()->OnEmbedForDescendant(view); | 
| 345     mojo::ViewManagerClientPtr client; | 345     mojo::ViewManagerClientPtr client; | 
| 346     ApplicationConnection* connection = | 346     scoped_ptr<ApplicationConnection> connection = | 
| 347         app_->ConnectToApplication(request.Pass()); | 347         app_->ConnectToApplication(request.Pass()); | 
| 348     connection->ConnectToService(&client); | 348     connection->ConnectToService(&client); | 
| 349     callback.Run(client.Pass()); | 349     callback.Run(client.Pass()); | 
| 350   } | 350   } | 
| 351   void OnEmbeddedAppDisconnected(Id view_id) override { | 351   void OnEmbeddedAppDisconnected(Id view_id) override { | 
| 352     tracker()->OnEmbeddedAppDisconnected(view_id); | 352     tracker()->OnEmbeddedAppDisconnected(view_id); | 
| 353   } | 353   } | 
| 354   void OnUnembed() override { tracker()->OnUnembed(); } | 354   void OnUnembed() override { tracker()->OnUnembed(); } | 
| 355   void OnViewBoundsChanged(Id view_id, | 355   void OnViewBoundsChanged(Id view_id, | 
| 356                            RectPtr old_bounds, | 356                            RectPtr old_bounds, | 
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 555     return client.Pass(); | 555     return client.Pass(); | 
| 556   } | 556   } | 
| 557 | 557 | 
| 558   // ApplicationTestBase: | 558   // ApplicationTestBase: | 
| 559   ApplicationDelegate* GetApplicationDelegate() override { return this; } | 559   ApplicationDelegate* GetApplicationDelegate() override { return this; } | 
| 560   void SetUp() override { | 560   void SetUp() override { | 
| 561     ApplicationTestBase::SetUp(); | 561     ApplicationTestBase::SetUp(); | 
| 562     client_factory_.reset(new ViewManagerClientFactory(application_impl())); | 562     client_factory_.reset(new ViewManagerClientFactory(application_impl())); | 
| 563     mojo::URLRequestPtr request(mojo::URLRequest::New()); | 563     mojo::URLRequestPtr request(mojo::URLRequest::New()); | 
| 564     request->url = mojo::String::From("mojo:view_manager"); | 564     request->url = mojo::String::From("mojo:view_manager"); | 
| 565     ApplicationConnection* vm_connection = | 565     scoped_ptr<ApplicationConnection> vm_connection = | 
| 566         application_impl()->ConnectToApplication(request.Pass()); | 566         application_impl()->ConnectToApplication(request.Pass()); | 
| 567     vm_connection->AddService(client_factory_.get()); | 567     vm_connection->AddService(client_factory_.get()); | 
| 568     vm_connection->ConnectToService(&view_manager_root_); | 568     vm_connection->ConnectToService(&view_manager_root_); | 
| 569     vm_client1_ = client_factory_->WaitForInstance(); | 569     vm_client1_ = client_factory_->WaitForInstance(); | 
| 570     ASSERT_TRUE(vm_client1_); | 570     ASSERT_TRUE(vm_client1_); | 
| 571     // Next we should get an embed call on the "window manager" client. | 571     // Next we should get an embed call on the "window manager" client. | 
| 572     vm_client1_->WaitForIncomingMethodCall(); | 572     vm_client1_->WaitForIncomingMethodCall(); | 
| 573     ASSERT_EQ(1u, changes1()->size()); | 573     ASSERT_EQ(1u, changes1()->size()); | 
| 574     EXPECT_EQ(CHANGE_TYPE_EMBED, (*changes1())[0].type); | 574     EXPECT_EQ(CHANGE_TYPE_EMBED, (*changes1())[0].type); | 
| 575     // All these tests assume 1 for the client id. The only real assertion here | 575     // All these tests assume 1 for the client id. The only real assertion here | 
| (...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1703 // TODO(sky): need to better track changes to initial connection. For example, | 1703 // TODO(sky): need to better track changes to initial connection. For example, | 
| 1704 // that SetBounsdViews/AddView and the like don't result in messages to the | 1704 // that SetBounsdViews/AddView and the like don't result in messages to the | 
| 1705 // originating connection. | 1705 // originating connection. | 
| 1706 | 1706 | 
| 1707 // TODO(sky): make sure coverage of what was | 1707 // TODO(sky): make sure coverage of what was | 
| 1708 // ViewManagerTest.SecondEmbedRoot_InitService and | 1708 // ViewManagerTest.SecondEmbedRoot_InitService and | 
| 1709 // ViewManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window manager | 1709 // ViewManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window manager | 
| 1710 // tests. | 1710 // tests. | 
| 1711 | 1711 | 
| 1712 }  // namespace view_manager | 1712 }  // namespace view_manager | 
| OLD | NEW | 
|---|