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

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

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