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

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

Issue 930243006: Simplify the ApplicationLoader interface in preparation for changes. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: trybot debugging ftw 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 ++context_->num_loader_deletes; 105 ++context_->num_loader_deletes;
106 test_app_.reset(NULL); 106 test_app_.reset(NULL);
107 } 107 }
108 108
109 void set_context(TestContext* context) { context_ = context; } 109 void set_context(TestContext* context) { context_ = context; }
110 int num_loads() const { return num_loads_; } 110 int num_loads() const { return num_loads_; }
111 const std::vector<std::string>& GetArgs() const { return test_app_->args(); } 111 const std::vector<std::string>& GetArgs() const { return test_app_->args(); }
112 112
113 private: 113 private:
114 // ApplicationLoader implementation. 114 // ApplicationLoader implementation.
115 void Load(ApplicationManager* manager, 115 void Load(const GURL& url,
116 const GURL& url, 116 InterfaceRequest<Application> application_request) override {
117 InterfaceRequest<Application> application_request,
118 LoadCallback callback) override {
119 ++num_loads_; 117 ++num_loads_;
120 test_app_.reset(new ApplicationImpl(this, application_request.Pass())); 118 test_app_.reset(new ApplicationImpl(this, application_request.Pass()));
121 } 119 }
122 120
123 void OnApplicationError(ApplicationManager* manager, 121 void OnApplicationError(ApplicationManager* manager,
124 const GURL& url) override {} 122 const GURL& url) override {}
125 123
126 // ApplicationDelegate implementation. 124 // ApplicationDelegate implementation.
127 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { 125 bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
128 connection->AddService(this); 126 connection->AddService(this);
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 public ApplicationLoader, 325 public ApplicationLoader,
328 public InterfaceFactory<TestA>, 326 public InterfaceFactory<TestA>,
329 public InterfaceFactory<TestB>, 327 public InterfaceFactory<TestB>,
330 public InterfaceFactory<TestC> { 328 public InterfaceFactory<TestC> {
331 public: 329 public:
332 Tester(TesterContext* context, const std::string& requestor_url) 330 Tester(TesterContext* context, const std::string& requestor_url)
333 : context_(context), requestor_url_(requestor_url) {} 331 : context_(context), requestor_url_(requestor_url) {}
334 ~Tester() override {} 332 ~Tester() override {}
335 333
336 private: 334 private:
337 void Load(ApplicationManager* manager, 335 void Load(const GURL& url,
338 const GURL& url, 336 InterfaceRequest<Application> application_request) override {
339 InterfaceRequest<Application> application_request,
340 LoadCallback callback) override {
341 app_.reset(new ApplicationImpl(this, application_request.Pass())); 337 app_.reset(new ApplicationImpl(this, application_request.Pass()));
342 } 338 }
343 339
344 void OnApplicationError(ApplicationManager* manager, 340 void OnApplicationError(ApplicationManager* manager,
345 const GURL& url) override {} 341 const GURL& url) override {}
346 342
347 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { 343 bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
348 if (!requestor_url_.empty() && 344 if (!requestor_url_.empty() &&
349 requestor_url_ != connection->GetRemoteApplicationURL()) { 345 requestor_url_ != connection->GetRemoteApplicationURL()) {
350 context_->set_tester_called_quit(); 346 context_->set_tester_called_quit();
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 application.Pass()); 733 application.Pass());
738 loop_.Run(); 734 loop_.Run();
739 EXPECT_EQ(args, external.initialize_args()); 735 EXPECT_EQ(args, external.initialize_args());
740 application_manager_->ConnectToServiceByName(GURL("mojo:test"), 736 application_manager_->ConnectToServiceByName(GURL("mojo:test"),
741 std::string()); 737 std::string());
742 loop_.Run(); 738 loop_.Run();
743 EXPECT_TRUE(external.configure_incoming_connection_called()); 739 EXPECT_TRUE(external.configure_incoming_connection_called());
744 }; 740 };
745 741
746 } // namespace mojo 742 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698