Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: shell/application_manager/application_manager_unittest.cc

Issue 868463008: Remove Client relationship between mojo.Shell/mojo.Application (Closed) Base URL: git@github.com:domokit/mojo.git@app_impl_init
Patch Set: fix android Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/at_exit.h" 5 #include "base/at_exit.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/scoped_vector.h" 8 #include "base/memory/scoped_vector.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "mojo/public/cpp/application/application_connection.h" 10 #include "mojo/public/cpp/application/application_connection.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 108 }
109 109
110 void set_context(TestContext* context) { context_ = context; } 110 void set_context(TestContext* context) { context_ = context; }
111 int num_loads() const { return num_loads_; } 111 int num_loads() const { return num_loads_; }
112 const std::vector<std::string>& GetArgs() const { return test_app_->args(); } 112 const std::vector<std::string>& GetArgs() const { return test_app_->args(); }
113 113
114 private: 114 private:
115 // ApplicationLoader implementation. 115 // ApplicationLoader implementation.
116 void Load(ApplicationManager* manager, 116 void Load(ApplicationManager* manager,
117 const GURL& url, 117 const GURL& url,
118 ShellPtr shell, 118 InterfaceRequest<Application> application_request,
119 LoadCallback callback) override { 119 LoadCallback callback) override {
120 ++num_loads_; 120 ++num_loads_;
121 test_app_.reset(new ApplicationImpl(this, shell.Pass())); 121 test_app_.reset(new ApplicationImpl(this, application_request.Pass()));
122 } 122 }
123 123
124 void OnApplicationError(ApplicationManager* manager, 124 void OnApplicationError(ApplicationManager* manager,
125 const GURL& url) override {} 125 const GURL& url) override {}
126 126
127 // ApplicationDelegate implementation. 127 // ApplicationDelegate implementation.
128 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { 128 bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
129 connection->AddService(this); 129 connection->AddService(this);
130 return true; 130 return true;
131 } 131 }
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 public InterfaceFactory<TestB>, 323 public InterfaceFactory<TestB>,
324 public InterfaceFactory<TestC> { 324 public InterfaceFactory<TestC> {
325 public: 325 public:
326 Tester(TesterContext* context, const std::string& requestor_url) 326 Tester(TesterContext* context, const std::string& requestor_url)
327 : context_(context), requestor_url_(requestor_url) {} 327 : context_(context), requestor_url_(requestor_url) {}
328 ~Tester() override {} 328 ~Tester() override {}
329 329
330 private: 330 private:
331 void Load(ApplicationManager* manager, 331 void Load(ApplicationManager* manager,
332 const GURL& url, 332 const GURL& url,
333 ShellPtr shell, 333 InterfaceRequest<Application> application_request,
334 LoadCallback callback) override { 334 LoadCallback callback) override {
335 app_.reset(new ApplicationImpl(this, shell.Pass())); 335 app_.reset(new ApplicationImpl(this, application_request.Pass()));
336 } 336 }
337 337
338 void OnApplicationError(ApplicationManager* manager, 338 void OnApplicationError(ApplicationManager* manager,
339 const GURL& url) override {} 339 const GURL& url) override {}
340 340
341 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { 341 bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
342 if (!requestor_url_.empty() && 342 if (!requestor_url_.empty() &&
343 requestor_url_ != connection->GetRemoteApplicationURL()) { 343 requestor_url_ != connection->GetRemoteApplicationURL()) {
344 context_->set_tester_called_quit(); 344 context_->set_tester_called_quit();
345 context_->QuitSoon(); 345 context_->QuitSoon();
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 GURL("mojo:foo")); 719 GURL("mojo:foo"));
720 test_delegate_.AddMapping(GURL("mojo:foo2"), GURL("mojo:foo")); 720 test_delegate_.AddMapping(GURL("mojo:foo2"), GURL("mojo:foo"));
721 721
722 TestServicePtr test_service; 722 TestServicePtr test_service;
723 application_manager_->ConnectToService(GURL("mojo:foo2"), &test_service); 723 application_manager_->ConnectToService(GURL("mojo:foo2"), &test_service);
724 EXPECT_EQ(1, custom_loader->num_loads()); 724 EXPECT_EQ(1, custom_loader->num_loads());
725 custom_loader->set_context(nullptr); 725 custom_loader->set_context(nullptr);
726 } 726 }
727 727
728 TEST_F(ApplicationManagerTest, ExternalApp) { 728 TEST_F(ApplicationManagerTest, ExternalApp) {
729 MessagePipe shell_pipe; 729 ApplicationPtr application;
730 ShellPtr shell;
731 shell.Bind(shell_pipe.handle0.Pass());
732 TestExternal external; 730 TestExternal external;
733 std::vector<std::string> args; 731 std::vector<std::string> args;
734 args.push_back("test"); 732 args.push_back("test");
735 ApplicationImpl app(&external, shell.Pass()); 733 ApplicationImpl app(&external, GetProxy(&application));
736 application_manager_->RegisterExternalApplication(GURL("mojo:test"), args, 734 application_manager_->RegisterExternalApplication(GURL("mojo:test"), args,
737 shell_pipe.handle1.Pass()); 735 application.Pass());
738 loop_.Run(); 736 loop_.Run();
739 EXPECT_EQ(args, external.initialize_args()); 737 EXPECT_EQ(args, external.initialize_args());
740 application_manager_->ConnectToServiceByName( 738 application_manager_->ConnectToServiceByName(
741 GURL("mojo:test"), std::string()); 739 GURL("mojo:test"), std::string());
742 loop_.Run(); 740 loop_.Run();
743 EXPECT_TRUE(external.configure_incoming_connection_called()); 741 EXPECT_TRUE(external.configure_incoming_connection_called());
744 }; 742 };
745 743
746 } // namespace mojo 744 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698