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

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

Issue 943053003: Simple multi-url support for mojo apps (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: hate Created 5 years, 9 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 void Load(const GURL& url, 115 void Load(const GURL& url,
116 InterfaceRequest<Application> application_request) override { 116 InterfaceRequest<Application> application_request) override {
117 ++num_loads_; 117 ++num_loads_;
118 test_app_.reset(new ApplicationImpl(this, application_request.Pass())); 118 test_app_.reset(new ApplicationImpl(this, application_request.Pass()));
119 } 119 }
120 120
121 void OnApplicationError(ApplicationManager* manager, 121 void OnApplicationError(ApplicationManager* manager,
122 const GURL& url) override {} 122 const GURL& url) override {}
123 123
124 // ApplicationDelegate implementation. 124 // ApplicationDelegate implementation.
125 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { 125 bool ConfigureIncomingConnection(ApplicationConnection* connection, const std: :string& url) override {
126 connection->AddService(this); 126 connection->AddService(this);
127 return true; 127 return true;
128 } 128 }
129 129
130 // InterfaceFactory implementation. 130 // InterfaceFactory implementation.
131 void Create(ApplicationConnection* connection, 131 void Create(ApplicationConnection* connection,
132 InterfaceRequest<TestService> request) override { 132 InterfaceRequest<TestService> request) override {
133 new TestServiceImpl(context_, request.Pass()); 133 new TestServiceImpl(context_, request.Pass());
134 } 134 }
135 135
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 333
334 private: 334 private:
335 void Load(const GURL& url, 335 void Load(const GURL& url,
336 InterfaceRequest<Application> application_request) override { 336 InterfaceRequest<Application> application_request) override {
337 app_.reset(new ApplicationImpl(this, application_request.Pass())); 337 app_.reset(new ApplicationImpl(this, application_request.Pass()));
338 } 338 }
339 339
340 void OnApplicationError(ApplicationManager* manager, 340 void OnApplicationError(ApplicationManager* manager,
341 const GURL& url) override {} 341 const GURL& url) override {}
342 342
343 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { 343 bool ConfigureIncomingConnection(ApplicationConnection* connection, const std: :string& url) override {
344 if (!requestor_url_.empty() && 344 if (!requestor_url_.empty() &&
345 requestor_url_ != connection->GetRemoteApplicationURL()) { 345 requestor_url_ != connection->GetRemoteApplicationURL()) {
346 context_->set_tester_called_quit(); 346 context_->set_tester_called_quit();
347 context_->QuitSoon(); 347 context_->QuitSoon();
348 base::MessageLoop::current()->Quit(); 348 base::MessageLoop::current()->Quit();
349 return false; 349 return false;
350 } 350 }
351 // If we're coming from A, then add B, otherwise A. 351 // If we're coming from A, then add B, otherwise A.
352 if (connection->GetRemoteApplicationURL() == kTestAURLString) 352 if (connection->GetRemoteApplicationURL() == kTestAURLString)
353 connection->AddService<TestB>(this); 353 connection->AddService<TestB>(this);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 416
417 class TestExternal : public ApplicationDelegate { 417 class TestExternal : public ApplicationDelegate {
418 public: 418 public:
419 TestExternal() : configure_incoming_connection_called_(false) {} 419 TestExternal() : configure_incoming_connection_called_(false) {}
420 420
421 void Initialize(ApplicationImpl* app) override { 421 void Initialize(ApplicationImpl* app) override {
422 initialize_args_ = app->args(); 422 initialize_args_ = app->args();
423 base::MessageLoop::current()->Quit(); 423 base::MessageLoop::current()->Quit();
424 } 424 }
425 425
426 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { 426 bool ConfigureIncomingConnection(ApplicationConnection* connection, const std: :string& url) override {
427 configure_incoming_connection_called_ = true; 427 configure_incoming_connection_called_ = true;
428 base::MessageLoop::current()->Quit(); 428 base::MessageLoop::current()->Quit();
429 return true; 429 return true;
430 } 430 }
431 431
432 const std::vector<std::string>& initialize_args() const { 432 const std::vector<std::string>& initialize_args() const {
433 return initialize_args_; 433 return initialize_args_;
434 } 434 }
435 435
436 bool configure_incoming_connection_called() const { 436 bool configure_incoming_connection_called() const {
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 // ApplicationManager, so this cannot succeed (but also shouldn't crash). 684 // ApplicationManager, so this cannot succeed (but also shouldn't crash).
685 TestCPtr c; 685 TestCPtr c;
686 application_manager_->ConnectToService(GURL(kTestAURLString), &c); 686 application_manager_->ConnectToService(GURL(kTestAURLString), &c);
687 QuitMessageLoopErrorHandler quitter; 687 QuitMessageLoopErrorHandler quitter;
688 c.set_error_handler(&quitter); 688 c.set_error_handler(&quitter);
689 689
690 loop_.Run(); 690 loop_.Run();
691 EXPECT_TRUE(c.encountered_error()); 691 EXPECT_TRUE(c.encountered_error());
692 } 692 }
693 693
694 TEST_F(ApplicationManagerTest, MappedURLsShouldNotCauseDuplicateLoad) { 694 TEST_F(ApplicationManagerTest, MappedURLsShouldNotCauseDuplicateLoad) {
qsr 2015/02/27 17:15:58 Don't you want to add test, checking that url with
Aaron Boodman 2015/02/28 19:08:23 I did test that in the apptest. This file is reall
695 test_delegate_.AddMapping(GURL("foo:foo2"), GURL("foo:foo")); 695 test_delegate_.AddMapping(GURL("foo:foo2"), GURL("foo:foo"));
696 // 1 because ApplicationManagerTest connects once at startup. 696 // 1 because ApplicationManagerTest connects once at startup.
697 EXPECT_EQ(1, test_loader_->num_loads()); 697 EXPECT_EQ(1, test_loader_->num_loads());
698 698
699 TestServicePtr test_service; 699 TestServicePtr test_service;
700 application_manager_->ConnectToService(GURL("foo:foo"), &test_service); 700 application_manager_->ConnectToService(GURL("foo:foo"), &test_service);
701 EXPECT_EQ(2, test_loader_->num_loads()); 701 EXPECT_EQ(2, test_loader_->num_loads());
702 702
703 TestServicePtr test_service2; 703 TestServicePtr test_service2;
704 application_manager_->ConnectToService(GURL("foo:foo2"), &test_service2); 704 application_manager_->ConnectToService(GURL("foo:foo2"), &test_service2);
(...skipping 28 matching lines...) Expand all
733 application.Pass()); 733 application.Pass());
734 loop_.Run(); 734 loop_.Run();
735 EXPECT_EQ(args, external.initialize_args()); 735 EXPECT_EQ(args, external.initialize_args());
736 application_manager_->ConnectToServiceByName(GURL("mojo:test"), 736 application_manager_->ConnectToServiceByName(GURL("mojo:test"),
737 std::string()); 737 std::string());
738 loop_.Run(); 738 loop_.Run();
739 EXPECT_TRUE(external.configure_incoming_connection_called()); 739 EXPECT_TRUE(external.configure_incoming_connection_called());
740 }; 740 };
741 741
742 } // namespace mojo 742 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698