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

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

Issue 1343823002: Revert of Move fetching logic out of ApplicationManager, eliminate url mappings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « mojo/shell/application_manager.cc ('k') | mojo/shell/capability_filter_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "mojo/application/public/cpp/application_connection.h" 11 #include "mojo/application/public/cpp/application_connection.h"
12 #include "mojo/application/public/cpp/application_delegate.h" 12 #include "mojo/application/public/cpp/application_delegate.h"
13 #include "mojo/application/public/cpp/application_impl.h" 13 #include "mojo/application/public/cpp/application_impl.h"
14 #include "mojo/application/public/cpp/interface_factory.h" 14 #include "mojo/application/public/cpp/interface_factory.h"
15 #include "mojo/application/public/interfaces/content_handler.mojom.h" 15 #include "mojo/application/public/interfaces/content_handler.mojom.h"
16 #include "mojo/application/public/interfaces/service_provider.mojom.h" 16 #include "mojo/application/public/interfaces/service_provider.mojom.h"
17 #include "mojo/public/cpp/bindings/strong_binding.h" 17 #include "mojo/public/cpp/bindings/strong_binding.h"
18 #include "mojo/shell/application_fetcher.h"
19 #include "mojo/shell/application_loader.h" 18 #include "mojo/shell/application_loader.h"
20 #include "mojo/shell/application_manager.h" 19 #include "mojo/shell/application_manager.h"
21 #include "mojo/shell/fetcher.h" 20 #include "mojo/shell/fetcher.h"
22 #include "mojo/shell/test.mojom.h" 21 #include "mojo/shell/test.mojom.h"
23 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
24 23
25 namespace mojo { 24 namespace mojo {
26 namespace shell { 25 namespace shell {
27 namespace { 26 namespace {
28 27
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 InterfaceRequest<TestC> request) override { 448 InterfaceRequest<TestC> request) override {
450 new TestCImpl(connection, context_, request.Pass()); 449 new TestCImpl(connection, context_, request.Pass());
451 } 450 }
452 451
453 TesterContext* context_; 452 TesterContext* context_;
454 scoped_ptr<ApplicationImpl> app_; 453 scoped_ptr<ApplicationImpl> app_;
455 std::string requestor_url_; 454 std::string requestor_url_;
456 ScopedVector<TestAImpl> a_bindings_; 455 ScopedVector<TestAImpl> a_bindings_;
457 }; 456 };
458 457
459 class TestApplicationFetcher : public ApplicationFetcher { 458 class TestDelegate : public ApplicationManager::Delegate {
460 public: 459 public:
461 TestApplicationFetcher() 460 TestDelegate()
462 : create_test_fetcher_(false), 461 : create_test_fetcher_(false),
463 fetcher_url_("xxx"), 462 fetcher_url_("xxx"),
464 mime_type_(kTestMimeType) {} 463 mime_type_(kTestMimeType) {}
465 ~TestApplicationFetcher() override {} 464 ~TestDelegate() override {}
465
466 void AddMapping(const GURL& from, const GURL& to) { mappings_[from] = to; }
466 467
467 void set_create_test_fetcher(bool create_test_fetcher) { 468 void set_create_test_fetcher(bool create_test_fetcher) {
468 create_test_fetcher_ = create_test_fetcher; 469 create_test_fetcher_ = create_test_fetcher;
469 } 470 }
470 471
471 void set_fetcher_url(const GURL& url) { fetcher_url_ = url; } 472 void set_fetcher_url(const GURL& url) { fetcher_url_ = url; }
472 473
473 void set_mime_type(const std::string& mime_type) { mime_type_ = mime_type; } 474 void set_mime_type(const std::string& mime_type) { mime_type_ = mime_type; }
474 475
475 // ApplicationManager::Delegate 476 // ApplicationManager::Delegate
476 void SetApplicationManager(ApplicationManager* manager) override {} 477 GURL ResolveMappings(const GURL& url) override {
477 GURL ResolveURL(const GURL& url) override { 478 auto it = mappings_.find(url);
478 GURL resolved_url = url; 479 if (it != mappings_.end())
480 return it->second;
481 return url;
482 }
483 GURL ResolveMojoURL(const GURL& url) override {
484 GURL mapped_url = ResolveMappings(url);
479 // The shell automatically map mojo URLs. 485 // The shell automatically map mojo URLs.
480 if (resolved_url.scheme() == "mojo") { 486 if (mapped_url.scheme() == "mojo") {
481 url::Replacements<char> replacements; 487 url::Replacements<char> replacements;
482 replacements.SetScheme("file", url::Component(0, 4)); 488 replacements.SetScheme("file", url::Component(0, 4));
483 resolved_url = resolved_url.ReplaceComponents(replacements); 489 mapped_url = mapped_url.ReplaceComponents(replacements);
484 } 490 }
485 return resolved_url; 491 return mapped_url;
486 } 492 }
487 void FetchRequest(URLRequestPtr request, 493 bool CreateFetcher(const GURL& url,
488 const Fetcher::FetchCallback& loader_callback) override { 494 const Fetcher::FetchCallback& loader_callback) override {
489 if (create_test_fetcher_) 495 if (!create_test_fetcher_)
490 new TestMimeTypeFetcher(loader_callback, fetcher_url_, mime_type_); 496 return false;
497 new TestMimeTypeFetcher(loader_callback, fetcher_url_, mime_type_);
498 return true;
491 } 499 }
492 500
493 private: 501 private:
502 std::map<GURL, GURL> mappings_;
494 bool create_test_fetcher_; 503 bool create_test_fetcher_;
495 GURL fetcher_url_; 504 GURL fetcher_url_;
496 std::string mime_type_; 505 std::string mime_type_;
497 506
498 DISALLOW_COPY_AND_ASSIGN(TestApplicationFetcher); 507 DISALLOW_COPY_AND_ASSIGN(TestDelegate);
499 }; 508 };
500 509
501 class ApplicationManagerTest : public testing::Test { 510 class ApplicationManagerTest : public testing::Test {
502 public: 511 public:
503 ApplicationManagerTest() : tester_context_(&loop_) {} 512 ApplicationManagerTest() : tester_context_(&loop_) {}
504 513
505 ~ApplicationManagerTest() override {} 514 ~ApplicationManagerTest() override {}
506 515
507 void SetUp() override { 516 void SetUp() override {
508 application_manager_.reset(new ApplicationManager( 517 application_manager_.reset(new ApplicationManager(&test_delegate_));
509 make_scoped_ptr(new TestApplicationFetcher)));
510 test_loader_ = new TestApplicationLoader; 518 test_loader_ = new TestApplicationLoader;
511 test_loader_->set_context(&context_); 519 test_loader_->set_context(&context_);
512 application_manager_->set_default_loader( 520 application_manager_->set_default_loader(
513 scoped_ptr<ApplicationLoader>(test_loader_)); 521 scoped_ptr<ApplicationLoader>(test_loader_));
514 522
515 TestServicePtr service_proxy; 523 TestServicePtr service_proxy;
516 application_manager_->ConnectToService(GURL(kTestURLString), 524 application_manager_->ConnectToService(GURL(kTestURLString),
517 &service_proxy); 525 &service_proxy);
518 test_client_.reset(new TestClient(service_proxy.Pass())); 526 test_client_.reset(new TestClient(service_proxy.Pass()));
519 } 527 }
520 528
521 void TearDown() override { 529 void TearDown() override {
522 test_client_.reset(); 530 test_client_.reset();
523 application_manager_.reset(); 531 application_manager_.reset();
524 } 532 }
525 533
526 void AddLoaderForURL(const GURL& url, const std::string& requestor_url) { 534 void AddLoaderForURL(const GURL& url, const std::string& requestor_url) {
527 application_manager_->SetLoaderForURL( 535 application_manager_->SetLoaderForURL(
528 make_scoped_ptr(new Tester(&tester_context_, requestor_url)), url); 536 make_scoped_ptr(new Tester(&tester_context_, requestor_url)), url);
529 } 537 }
530 538
531 bool HasRunningInstanceForURL(const GURL& url) { 539 bool HasRunningInstanceForURL(const GURL& url) {
532 ApplicationManager::TestAPI manager_test_api(application_manager_.get()); 540 ApplicationManager::TestAPI manager_test_api(application_manager_.get());
533 return manager_test_api.HasRunningInstanceForURL(url); 541 return manager_test_api.HasRunningInstanceForURL(url);
534 } 542 }
535 543
536 protected: 544 protected:
537 base::ShadowingAtExitManager at_exit_; 545 base::ShadowingAtExitManager at_exit_;
546 TestDelegate test_delegate_;
538 TestApplicationLoader* test_loader_; 547 TestApplicationLoader* test_loader_;
539 TesterContext tester_context_; 548 TesterContext tester_context_;
540 TestContext context_; 549 TestContext context_;
541 base::MessageLoop loop_; 550 base::MessageLoop loop_;
542 scoped_ptr<TestClient> test_client_; 551 scoped_ptr<TestClient> test_client_;
543 scoped_ptr<ApplicationManager> application_manager_; 552 scoped_ptr<ApplicationManager> application_manager_;
544 DISALLOW_COPY_AND_ASSIGN(ApplicationManagerTest); 553 DISALLOW_COPY_AND_ASSIGN(ApplicationManagerTest);
545 }; 554 };
546 555
547 TEST_F(ApplicationManagerTest, Basic) { 556 TEST_F(ApplicationManagerTest, Basic) {
548 test_client_->Test("test"); 557 test_client_->Test("test");
549 loop_.Run(); 558 loop_.Run();
550 EXPECT_EQ(std::string("test"), context_.last_test_string); 559 EXPECT_EQ(std::string("test"), context_.last_test_string);
551 } 560 }
552 561
562 // Confirm that url mappings are respected.
563 TEST_F(ApplicationManagerTest, URLMapping) {
564 ApplicationManager am(&test_delegate_);
565 GURL test_url("test:test");
566 GURL test_url2("test:test2");
567 test_delegate_.AddMapping(test_url, test_url2);
568 TestApplicationLoader* loader = new TestApplicationLoader;
569 loader->set_context(&context_);
570 am.SetLoaderForURL(scoped_ptr<ApplicationLoader>(loader), test_url2);
571 {
572 // Connect to the mapped url
573 TestServicePtr test_service;
574 am.ConnectToService(test_url, &test_service);
575 TestClient test_client(test_service.Pass());
576 test_client.Test("test");
577 loop_.Run();
578 }
579 {
580 // Connect to the target url
581 TestServicePtr test_service;
582 am.ConnectToService(test_url2, &test_service);
583 TestClient test_client(test_service.Pass());
584 test_client.Test("test");
585 loop_.Run();
586 }
587 }
588
553 TEST_F(ApplicationManagerTest, ClientError) { 589 TEST_F(ApplicationManagerTest, ClientError) {
554 test_client_->Test("test"); 590 test_client_->Test("test");
555 EXPECT_TRUE(HasRunningInstanceForURL(GURL(kTestURLString))); 591 EXPECT_TRUE(HasRunningInstanceForURL(GURL(kTestURLString)));
556 loop_.Run(); 592 loop_.Run();
557 EXPECT_EQ(1, context_.num_impls); 593 EXPECT_EQ(1, context_.num_impls);
558 test_client_.reset(); 594 test_client_.reset();
559 loop_.Run(); 595 loop_.Run();
560 EXPECT_EQ(0, context_.num_impls); 596 EXPECT_EQ(0, context_.num_impls);
561 EXPECT_TRUE(HasRunningInstanceForURL(GURL(kTestURLString))); 597 EXPECT_TRUE(HasRunningInstanceForURL(GURL(kTestURLString)));
562 } 598 }
563 599
564 TEST_F(ApplicationManagerTest, Deletes) { 600 TEST_F(ApplicationManagerTest, Deletes) {
565 { 601 {
566 ApplicationManager am(make_scoped_ptr(new TestApplicationFetcher)); 602 ApplicationManager am(&test_delegate_);
567 TestApplicationLoader* default_loader = new TestApplicationLoader; 603 TestApplicationLoader* default_loader = new TestApplicationLoader;
568 default_loader->set_context(&context_); 604 default_loader->set_context(&context_);
569 TestApplicationLoader* url_loader1 = new TestApplicationLoader; 605 TestApplicationLoader* url_loader1 = new TestApplicationLoader;
570 TestApplicationLoader* url_loader2 = new TestApplicationLoader; 606 TestApplicationLoader* url_loader2 = new TestApplicationLoader;
571 url_loader1->set_context(&context_); 607 url_loader1->set_context(&context_);
572 url_loader2->set_context(&context_); 608 url_loader2->set_context(&context_);
573 TestApplicationLoader* scheme_loader1 = new TestApplicationLoader; 609 TestApplicationLoader* scheme_loader1 = new TestApplicationLoader;
574 TestApplicationLoader* scheme_loader2 = new TestApplicationLoader; 610 TestApplicationLoader* scheme_loader2 = new TestApplicationLoader;
575 scheme_loader1->set_context(&context_); 611 scheme_loader1->set_context(&context_);
576 scheme_loader2->set_context(&context_); 612 scheme_loader2->set_context(&context_);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 // ApplicationManager, so this cannot succeed (but also shouldn't crash). 736 // ApplicationManager, so this cannot succeed (but also shouldn't crash).
701 TestCPtr c; 737 TestCPtr c;
702 application_manager_->ConnectToService(GURL(kTestAURLString), &c); 738 application_manager_->ConnectToService(GURL(kTestAURLString), &c);
703 c.set_connection_error_handler( 739 c.set_connection_error_handler(
704 []() { base::MessageLoop::current()->QuitWhenIdle(); }); 740 []() { base::MessageLoop::current()->QuitWhenIdle(); });
705 741
706 loop_.Run(); 742 loop_.Run();
707 EXPECT_TRUE(c.encountered_error()); 743 EXPECT_TRUE(c.encountered_error());
708 } 744 }
709 745
746 TEST_F(ApplicationManagerTest, MappedURLsShouldNotCauseDuplicateLoad) {
747 test_delegate_.AddMapping(GURL("foo:foo2"), GURL("foo:foo"));
748 // 1 because ApplicationManagerTest connects once at startup.
749 EXPECT_EQ(1, test_loader_->num_loads());
750
751 TestServicePtr test_service;
752 application_manager_->ConnectToService(GURL("foo:foo"), &test_service);
753 EXPECT_EQ(2, test_loader_->num_loads());
754
755 TestServicePtr test_service2;
756 application_manager_->ConnectToService(GURL("foo:foo2"), &test_service2);
757 EXPECT_EQ(2, test_loader_->num_loads());
758
759 TestServicePtr test_service3;
760 application_manager_->ConnectToService(GURL("bar:bar"), &test_service2);
761 EXPECT_EQ(3, test_loader_->num_loads());
762 }
763
764 TEST_F(ApplicationManagerTest, MappedURLsShouldWorkWithLoaders) {
765 TestApplicationLoader* custom_loader = new TestApplicationLoader;
766 TestContext context;
767 custom_loader->set_context(&context);
768 application_manager_->SetLoaderForURL(make_scoped_ptr(custom_loader),
769 GURL("mojo:foo"));
770 test_delegate_.AddMapping(GURL("mojo:foo2"), GURL("mojo:foo"));
771
772 TestServicePtr test_service;
773 application_manager_->ConnectToService(GURL("mojo:foo2"), &test_service);
774 EXPECT_EQ(1, custom_loader->num_loads());
775 custom_loader->set_context(nullptr);
776
777 EXPECT_TRUE(HasRunningInstanceForURL(GURL("mojo:foo2")));
778 EXPECT_FALSE(HasRunningInstanceForURL(GURL("mojo:foo")));
779 }
780
710 TEST_F(ApplicationManagerTest, TestQueryWithLoaders) { 781 TEST_F(ApplicationManagerTest, TestQueryWithLoaders) {
711 TestApplicationLoader* url_loader = new TestApplicationLoader; 782 TestApplicationLoader* url_loader = new TestApplicationLoader;
712 TestApplicationLoader* scheme_loader = new TestApplicationLoader; 783 TestApplicationLoader* scheme_loader = new TestApplicationLoader;
713 application_manager_->SetLoaderForURL( 784 application_manager_->SetLoaderForURL(
714 scoped_ptr<ApplicationLoader>(url_loader), GURL("test:test1")); 785 scoped_ptr<ApplicationLoader>(url_loader), GURL("test:test1"));
715 application_manager_->SetLoaderForScheme( 786 application_manager_->SetLoaderForScheme(
716 scoped_ptr<ApplicationLoader>(scheme_loader), "test"); 787 scoped_ptr<ApplicationLoader>(scheme_loader), "test");
717 788
718 // test::test1 should go to url_loader. 789 // test::test1 should go to url_loader.
719 TestServicePtr test_service; 790 TestServicePtr test_service;
(...skipping 23 matching lines...) Expand all
743 application_manager_->ConnectToApplication(params.Pass()); 814 application_manager_->ConnectToApplication(params.Pass());
744 loop_.Run(); 815 loop_.Run();
745 EXPECT_TRUE(called); 816 EXPECT_TRUE(called);
746 } 817 }
747 818
748 TEST(ApplicationManagerTest2, ContentHandlerConnectionGetsRequestorURL) { 819 TEST(ApplicationManagerTest2, ContentHandlerConnectionGetsRequestorURL) {
749 const GURL content_handler_url("http://test.content.handler"); 820 const GURL content_handler_url("http://test.content.handler");
750 const GURL requestor_url("http://requestor.url"); 821 const GURL requestor_url("http://requestor.url");
751 TestContext test_context; 822 TestContext test_context;
752 base::MessageLoop loop; 823 base::MessageLoop loop;
753 scoped_ptr<TestApplicationFetcher> test_application_fetcher( 824 TestDelegate test_delegate;
754 new TestApplicationFetcher); 825 test_delegate.set_create_test_fetcher(true);
755 test_application_fetcher->set_create_test_fetcher(true); 826 ApplicationManager application_manager(&test_delegate);
756 ApplicationManager application_manager(test_application_fetcher.Pass());
757 application_manager.set_default_loader(nullptr); 827 application_manager.set_default_loader(nullptr);
758 application_manager.RegisterContentHandler(kTestMimeType, 828 application_manager.RegisterContentHandler(kTestMimeType,
759 content_handler_url); 829 content_handler_url);
760 830
761 TestApplicationLoader* loader = new TestApplicationLoader; 831 TestApplicationLoader* loader = new TestApplicationLoader;
762 loader->set_context(&test_context); 832 loader->set_context(&test_context);
763 application_manager.SetLoaderForURL(scoped_ptr<ApplicationLoader>(loader), 833 application_manager.SetLoaderForURL(scoped_ptr<ApplicationLoader>(loader),
764 content_handler_url); 834 content_handler_url);
765 835
766 bool called = false; 836 bool called = false;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 GURL("http://www.another_domain.org/abc"), &test_service); 879 GURL("http://www.another_domain.org/abc"), &test_service);
810 EXPECT_EQ(4, test_loader_->num_loads()); 880 EXPECT_EQ(4, test_loader_->num_loads());
811 } 881 }
812 882
813 TEST(ApplicationManagerTest2, 883 TEST(ApplicationManagerTest2,
814 MultipleConnectionsToContentHandlerGetSameContentHandlerId) { 884 MultipleConnectionsToContentHandlerGetSameContentHandlerId) {
815 base::MessageLoop loop; 885 base::MessageLoop loop;
816 const GURL content_handler_url("http://test.content.handler"); 886 const GURL content_handler_url("http://test.content.handler");
817 const GURL requestor_url("http://requestor.url"); 887 const GURL requestor_url("http://requestor.url");
818 TestContext test_context; 888 TestContext test_context;
819 scoped_ptr<TestApplicationFetcher> test_application_fetcher( 889 TestDelegate test_delegate;
820 new TestApplicationFetcher); 890 test_delegate.set_fetcher_url(GURL("test:test"));
821 test_application_fetcher->set_fetcher_url(GURL("test:test")); 891 test_delegate.set_create_test_fetcher(true);
822 test_application_fetcher->set_create_test_fetcher(true); 892 ApplicationManager application_manager(&test_delegate);
823 ApplicationManager application_manager(test_application_fetcher.Pass());
824 application_manager.set_default_loader(nullptr); 893 application_manager.set_default_loader(nullptr);
825 application_manager.RegisterContentHandler(kTestMimeType, 894 application_manager.RegisterContentHandler(kTestMimeType,
826 content_handler_url); 895 content_handler_url);
827 896
828 TestApplicationLoader* content_handler_loader = new TestApplicationLoader; 897 TestApplicationLoader* content_handler_loader = new TestApplicationLoader;
829 content_handler_loader->set_create_content_handler(true); 898 content_handler_loader->set_create_content_handler(true);
830 content_handler_loader->set_context(&test_context); 899 content_handler_loader->set_context(&test_context);
831 application_manager.SetLoaderForURL( 900 application_manager.SetLoaderForURL(
832 scoped_ptr<ApplicationLoader>(content_handler_loader), 901 scoped_ptr<ApplicationLoader>(content_handler_loader),
833 content_handler_url); 902 content_handler_url);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 EXPECT_NE(Shell::kInvalidContentHandlerID, content_handler_id2); 937 EXPECT_NE(Shell::kInvalidContentHandlerID, content_handler_id2);
869 } 938 }
870 EXPECT_EQ(content_handler_id, content_handler_id2); 939 EXPECT_EQ(content_handler_id, content_handler_id2);
871 } 940 }
872 941
873 TEST(ApplicationManagerTest2, DifferedContentHandlersGetDifferentIDs) { 942 TEST(ApplicationManagerTest2, DifferedContentHandlersGetDifferentIDs) {
874 base::MessageLoop loop; 943 base::MessageLoop loop;
875 const GURL content_handler_url("http://test.content.handler"); 944 const GURL content_handler_url("http://test.content.handler");
876 const GURL requestor_url("http://requestor.url"); 945 const GURL requestor_url("http://requestor.url");
877 TestContext test_context; 946 TestContext test_context;
878 TestApplicationFetcher* test_application_fetcher = new TestApplicationFetcher; 947 TestDelegate test_delegate;
879 test_application_fetcher->set_fetcher_url(GURL("test:test")); 948 test_delegate.set_fetcher_url(GURL("test:test"));
880 test_application_fetcher->set_create_test_fetcher(true); 949 test_delegate.set_create_test_fetcher(true);
881 ApplicationManager application_manager( 950 ApplicationManager application_manager(&test_delegate);
882 make_scoped_ptr(test_application_fetcher));
883 application_manager.set_default_loader(nullptr); 951 application_manager.set_default_loader(nullptr);
884 application_manager.RegisterContentHandler(kTestMimeType, 952 application_manager.RegisterContentHandler(kTestMimeType,
885 content_handler_url); 953 content_handler_url);
886 954
887 TestApplicationLoader* content_handler_loader = new TestApplicationLoader; 955 TestApplicationLoader* content_handler_loader = new TestApplicationLoader;
888 content_handler_loader->set_create_content_handler(true); 956 content_handler_loader->set_create_content_handler(true);
889 content_handler_loader->set_context(&test_context); 957 content_handler_loader->set_context(&test_context);
890 application_manager.SetLoaderForURL( 958 application_manager.SetLoaderForURL(
891 scoped_ptr<ApplicationLoader>(content_handler_loader), 959 scoped_ptr<ApplicationLoader>(content_handler_loader),
892 content_handler_url); 960 content_handler_url);
(...skipping 11 matching lines...) Expand all
904 content_handler_id = t; 972 content_handler_id = t;
905 run_loop.Quit(); 973 run_loop.Quit();
906 }); 974 });
907 application_manager.ConnectToApplication(params.Pass()); 975 application_manager.ConnectToApplication(params.Pass());
908 run_loop.Run(); 976 run_loop.Run();
909 EXPECT_NE(Shell::kInvalidContentHandlerID, content_handler_id); 977 EXPECT_NE(Shell::kInvalidContentHandlerID, content_handler_id);
910 } 978 }
911 979
912 const std::string mime_type2("test/mime-type2"); 980 const std::string mime_type2("test/mime-type2");
913 const GURL content_handler_url2("http://test.content2.handler"); 981 const GURL content_handler_url2("http://test.content2.handler");
914 test_application_fetcher->set_fetcher_url(GURL("test2:test2")); 982 test_delegate.set_fetcher_url(GURL("test2:test2"));
915 test_application_fetcher->set_mime_type(mime_type2); 983 test_delegate.set_mime_type(mime_type2);
916 application_manager.RegisterContentHandler(mime_type2, content_handler_url2); 984 application_manager.RegisterContentHandler(mime_type2, content_handler_url2);
917 985
918 TestApplicationLoader* content_handler_loader2 = new TestApplicationLoader; 986 TestApplicationLoader* content_handler_loader2 = new TestApplicationLoader;
919 content_handler_loader->set_create_content_handler(true); 987 content_handler_loader->set_create_content_handler(true);
920 content_handler_loader->set_context(&test_context); 988 content_handler_loader->set_context(&test_context);
921 application_manager.SetLoaderForURL( 989 application_manager.SetLoaderForURL(
922 scoped_ptr<ApplicationLoader>(content_handler_loader2), 990 scoped_ptr<ApplicationLoader>(content_handler_loader2),
923 content_handler_url2); 991 content_handler_url2);
924 992
925 uint32_t content_handler_id2; 993 uint32_t content_handler_id2;
(...skipping 27 matching lines...) Expand all
953 params->set_filter(GetPermissiveCapabilityFilter()); 1021 params->set_filter(GetPermissiveCapabilityFilter());
954 params->set_connect_callback( 1022 params->set_connect_callback(
955 [&content_handler_id](uint32_t t) { content_handler_id = t; }); 1023 [&content_handler_id](uint32_t t) { content_handler_id = t; });
956 application_manager_->ConnectToApplication(params.Pass()); 1024 application_manager_->ConnectToApplication(params.Pass());
957 EXPECT_EQ(0u, content_handler_id); 1025 EXPECT_EQ(0u, content_handler_id);
958 } 1026 }
959 1027
960 } // namespace 1028 } // namespace
961 } // namespace shell 1029 } // namespace shell
962 } // namespace mojo 1030 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/application_manager.cc ('k') | mojo/shell/capability_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698