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/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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
383 } | 383 } |
384 | 384 |
385 TesterContext* context_; | 385 TesterContext* context_; |
386 scoped_ptr<ApplicationImpl> app_; | 386 scoped_ptr<ApplicationImpl> app_; |
387 std::string requestor_url_; | 387 std::string requestor_url_; |
388 ScopedVector<TestAImpl> a_bindings_; | 388 ScopedVector<TestAImpl> a_bindings_; |
389 }; | 389 }; |
390 | 390 |
391 class TestDelegate : public ApplicationManager::Delegate { | 391 class TestDelegate : public ApplicationManager::Delegate { |
392 public: | 392 public: |
393 void AddMapping(const GURL& from, const GURL& to) { | 393 void AddMapping(const GURL& from, const GURL& to) { mappings_[from] = to; } |
394 mappings_[from] = to; | |
395 } | |
396 | 394 |
397 // ApplicationManager::Delegate | 395 // ApplicationManager::Delegate |
398 virtual GURL ResolveMappings(const GURL& url) override { | 396 virtual GURL ResolveMappings(const GURL& url) override { |
399 auto it = mappings_.find(url); | 397 auto it = mappings_.find(url); |
400 if (it != mappings_.end()) | 398 if (it != mappings_.end()) |
401 return it->second; | 399 return it->second; |
402 return url; | 400 return url; |
403 } | 401 } |
404 | 402 |
405 // ApplicationManager::Delegate | 403 // ApplicationManager::Delegate |
406 virtual GURL ResolveURL(const GURL& url) override { | 404 virtual GURL ResolveURL(const GURL& url) override { |
407 GURL mapped_url = ResolveMappings(url); | 405 GURL mapped_url = ResolveMappings(url); |
408 // The shell automatically map mojo URLs. | 406 // The shell automatically map mojo URLs. |
409 if (mapped_url.scheme() == "mojo") { | 407 if (mapped_url.scheme() == "mojo") { |
410 url::Replacements<char> replacements; | 408 url::Replacements<char> replacements; |
411 replacements.SetScheme("file", url::Component(0, 4)); | 409 replacements.SetScheme("file", url::Component(0, 4)); |
412 mapped_url = mapped_url.ReplaceComponents(replacements); | 410 mapped_url = mapped_url.ReplaceComponents(replacements); |
413 } | 411 } |
414 return mapped_url; | 412 return mapped_url; |
415 } | 413 } |
416 | 414 |
417 virtual void OnApplicationError(const GURL& url) override { | 415 virtual void OnApplicationError(const GURL& url) override {} |
jamesr
2015/02/11 23:44:48
while you're here, this shouldn't have both "virtu
viettrungluu
2015/02/11 23:59:03
Fixed. I wonder where else we make that mistake.
| |
418 } | |
419 | 416 |
420 private: | 417 private: |
421 std::map<GURL, GURL> mappings_; | 418 std::map<GURL, GURL> mappings_; |
422 }; | 419 }; |
423 | 420 |
424 class TestExternal : public ApplicationDelegate { | 421 class TestExternal : public ApplicationDelegate { |
425 public: | 422 public: |
426 TestExternal() : configure_incoming_connection_called_(false) {} | 423 TestExternal() : configure_incoming_connection_called_(false) {} |
427 | 424 |
428 virtual void Initialize(ApplicationImpl* app) override { | 425 virtual void Initialize(ApplicationImpl* app) override { |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
734 TEST_F(ApplicationManagerTest, ExternalApp) { | 731 TEST_F(ApplicationManagerTest, ExternalApp) { |
735 ApplicationPtr application; | 732 ApplicationPtr application; |
736 TestExternal external; | 733 TestExternal external; |
737 std::vector<std::string> args; | 734 std::vector<std::string> args; |
738 args.push_back("test"); | 735 args.push_back("test"); |
739 ApplicationImpl app(&external, GetProxy(&application)); | 736 ApplicationImpl app(&external, GetProxy(&application)); |
740 application_manager_->RegisterExternalApplication(GURL("mojo:test"), args, | 737 application_manager_->RegisterExternalApplication(GURL("mojo:test"), args, |
741 application.Pass()); | 738 application.Pass()); |
742 loop_.Run(); | 739 loop_.Run(); |
743 EXPECT_EQ(args, external.initialize_args()); | 740 EXPECT_EQ(args, external.initialize_args()); |
744 application_manager_->ConnectToServiceByName( | 741 application_manager_->ConnectToServiceByName(GURL("mojo:test"), |
745 GURL("mojo:test"), std::string()); | 742 std::string()); |
746 loop_.Run(); | 743 loop_.Run(); |
747 EXPECT_TRUE(external.configure_incoming_connection_called()); | 744 EXPECT_TRUE(external.configure_incoming_connection_called()); |
748 }; | 745 }; |
749 | 746 |
750 } // namespace mojo | 747 } // namespace mojo |
OLD | NEW |