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

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

Issue 741453002: Make sure that Content Handled application can be connected multiple times. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Follow review Created 6 years, 1 month 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/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "mojo/application_manager/application_loader.h" 9 #include "mojo/application_manager/application_loader.h"
10 #include "mojo/application_manager/application_manager.h" 10 #include "mojo/application_manager/application_manager.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 scoped_refptr<LoadCallbacks> callbacks) override { 118 ScopedMessagePipeHandle shell_handle,
119 LoadCallback callbacks) override {
Aaron Boodman 2014/11/19 16:09:57 here and elsewhere, can you change the param name
qsr 2014/11/19 16:37:22 Done.
119 ++num_loads_; 120 ++num_loads_;
120 test_app_.reset( 121 test_app_.reset(new ApplicationImpl(this, shell_handle.Pass()));
121 new ApplicationImpl(this, callbacks->RegisterApplication().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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 public InterfaceFactory<TestB>, 319 public InterfaceFactory<TestB>,
320 public InterfaceFactory<TestC> { 320 public InterfaceFactory<TestC> {
321 public: 321 public:
322 Tester(TesterContext* context, const std::string& requestor_url) 322 Tester(TesterContext* context, const std::string& requestor_url)
323 : context_(context), requestor_url_(requestor_url) {} 323 : context_(context), requestor_url_(requestor_url) {}
324 ~Tester() override {} 324 ~Tester() override {}
325 325
326 private: 326 private:
327 void Load(ApplicationManager* manager, 327 void Load(ApplicationManager* manager,
328 const GURL& url, 328 const GURL& url,
329 scoped_refptr<LoadCallbacks> callbacks) override { 329 ScopedMessagePipeHandle shell_handle,
330 app_.reset( 330 LoadCallback callbacks) override {
331 new ApplicationImpl(this, callbacks->RegisterApplication().Pass())); 331 app_.reset(new ApplicationImpl(this, shell_handle.Pass()));
332 } 332 }
333 333
334 void OnApplicationError(ApplicationManager* manager, 334 void OnApplicationError(ApplicationManager* manager,
335 const GURL& url) override {} 335 const GURL& url) override {}
336 336
337 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { 337 bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
338 if (!requestor_url_.empty() && 338 if (!requestor_url_.empty() &&
339 requestor_url_ != connection->GetRemoteApplicationURL()) { 339 requestor_url_ != connection->GetRemoteApplicationURL()) {
340 context_->set_tester_called_quit(); 340 context_->set_tester_called_quit();
341 context_->QuitSoon(); 341 context_->QuitSoon();
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 TestServicePtr test_service2; 713 TestServicePtr test_service2;
714 application_manager_->ConnectToService(GURL("foo:foo2"), &test_service2); 714 application_manager_->ConnectToService(GURL("foo:foo2"), &test_service2);
715 EXPECT_EQ(2, test_loader_->num_loads()); 715 EXPECT_EQ(2, test_loader_->num_loads());
716 716
717 TestServicePtr test_service3; 717 TestServicePtr test_service3;
718 application_manager_->ConnectToService(GURL("bar:bar"), &test_service2); 718 application_manager_->ConnectToService(GURL("bar:bar"), &test_service2);
719 EXPECT_EQ(3, test_loader_->num_loads()); 719 EXPECT_EQ(3, test_loader_->num_loads());
720 } 720 }
721 721
722 } // namespace mojo 722 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698