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

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

Issue 1121783003: Move navigations with POST or referrer to the shell. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 5 years, 7 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/fetcher.h » ('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 "mojo/application/public/cpp/application_connection.h" 10 #include "mojo/application/public/cpp/application_connection.h"
(...skipping 22 matching lines...) Expand all
33 public: 33 public:
34 explicit TestMimeTypeFetcher(const FetchCallback& fetch_callback) 34 explicit TestMimeTypeFetcher(const FetchCallback& fetch_callback)
35 : Fetcher(fetch_callback), url_("xxx") { 35 : Fetcher(fetch_callback), url_("xxx") {
36 loader_callback_.Run(make_scoped_ptr(this)); 36 loader_callback_.Run(make_scoped_ptr(this));
37 } 37 }
38 ~TestMimeTypeFetcher() override {} 38 ~TestMimeTypeFetcher() override {}
39 39
40 // Fetcher: 40 // Fetcher:
41 const GURL& GetURL() const override { return url_; } 41 const GURL& GetURL() const override { return url_; }
42 GURL GetRedirectURL() const override { return GURL("yyy"); } 42 GURL GetRedirectURL() const override { return GURL("yyy"); }
43 GURL GetRedirectReferer() const override { return GURL(); }
43 URLResponsePtr AsURLResponse(base::TaskRunner* task_runner, 44 URLResponsePtr AsURLResponse(base::TaskRunner* task_runner,
44 uint32_t skip) override { 45 uint32_t skip) override {
45 return URLResponse::New().Pass(); 46 return URLResponse::New().Pass();
46 } 47 }
47 void AsPath( 48 void AsPath(
48 base::TaskRunner* task_runner, 49 base::TaskRunner* task_runner,
49 base::Callback<void(const base::FilePath&, bool)> callback) override {} 50 base::Callback<void(const base::FilePath&, bool)> callback) override {}
50 std::string MimeType() override { return kTestMimeType; } 51 std::string MimeType() override { return kTestMimeType; }
51 bool HasMojoMagic() override { return false; } 52 bool HasMojoMagic() override { return false; }
52 bool PeekFirstLine(std::string* line) override { return false; } 53 bool PeekFirstLine(std::string* line) override { return false; }
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 base::MessageLoop* loop_; 279 base::MessageLoop* loop_;
279 }; 280 };
280 281
281 // Used to test that the requestor url will be correctly passed. 282 // Used to test that the requestor url will be correctly passed.
282 class TestAImpl : public TestA { 283 class TestAImpl : public TestA {
283 public: 284 public:
284 TestAImpl(ApplicationImpl* app_impl, 285 TestAImpl(ApplicationImpl* app_impl,
285 TesterContext* test_context, 286 TesterContext* test_context,
286 InterfaceRequest<TestA> request) 287 InterfaceRequest<TestA> request)
287 : test_context_(test_context), binding_(this, request.Pass()) { 288 : test_context_(test_context), binding_(this, request.Pass()) {
288 app_impl->ConnectToApplication(kTestBURLString)->ConnectToService(&b_); 289 mojo::URLRequestPtr request2(mojo::URLRequest::New());
290 request2->url = mojo::String::From(kTestBURLString);
291 app_impl->ConnectToApplication(request2.Pass())->ConnectToService(&b_);
289 } 292 }
290 293
291 ~TestAImpl() override { 294 ~TestAImpl() override {
292 test_context_->IncrementNumADeletes(); 295 test_context_->IncrementNumADeletes();
293 if (base::MessageLoop::current()->is_running()) 296 if (base::MessageLoop::current()->is_running())
294 Quit(); 297 Quit();
295 } 298 }
296 299
297 private: 300 private:
298 void CallB() override { 301 void CallB() override {
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 EXPECT_EQ(1, url_loader->num_loads()); 763 EXPECT_EQ(1, url_loader->num_loads());
761 EXPECT_EQ(1, scheme_loader->num_loads()); 764 EXPECT_EQ(1, scheme_loader->num_loads());
762 } 765 }
763 766
764 TEST_F(ApplicationManagerTest, TestEndApplicationClosure) { 767 TEST_F(ApplicationManagerTest, TestEndApplicationClosure) {
765 ClosingApplicationLoader* loader = new ClosingApplicationLoader(); 768 ClosingApplicationLoader* loader = new ClosingApplicationLoader();
766 application_manager_->SetLoaderForScheme( 769 application_manager_->SetLoaderForScheme(
767 scoped_ptr<ApplicationLoader>(loader), "test"); 770 scoped_ptr<ApplicationLoader>(loader), "test");
768 771
769 bool called = false; 772 bool called = false;
773 mojo::URLRequestPtr request(mojo::URLRequest::New());
774 request->url = mojo::String::From("test:test");
770 application_manager_->ConnectToApplication( 775 application_manager_->ConnectToApplication(
771 GURL("test:test"), GURL(), nullptr, nullptr, 776 request.Pass(), GURL(), nullptr, nullptr,
772 base::Bind(&QuitClosure, base::Unretained(&called))); 777 base::Bind(&QuitClosure, base::Unretained(&called)));
773 loop_.Run(); 778 loop_.Run();
774 EXPECT_TRUE(called); 779 EXPECT_TRUE(called);
775 } 780 }
776 781
777 TEST(ApplicationManagerTest2, ContentHandlerConnectionGetsRequestorURL) { 782 TEST(ApplicationManagerTest2, ContentHandlerConnectionGetsRequestorURL) {
778 const GURL content_handler_url("http://test.content.handler"); 783 const GURL content_handler_url("http://test.content.handler");
779 const GURL requestor_url("http://requestor.url"); 784 const GURL requestor_url("http://requestor.url");
780 TestContext test_context; 785 TestContext test_context;
781 base::MessageLoop loop; 786 base::MessageLoop loop;
782 TestDelegate test_delegate; 787 TestDelegate test_delegate;
783 test_delegate.set_create_test_fetcher(true); 788 test_delegate.set_create_test_fetcher(true);
784 ApplicationManager application_manager(&test_delegate); 789 ApplicationManager application_manager(&test_delegate);
785 application_manager.set_default_loader(nullptr); 790 application_manager.set_default_loader(nullptr);
786 application_manager.RegisterContentHandler(kTestMimeType, 791 application_manager.RegisterContentHandler(kTestMimeType,
787 content_handler_url); 792 content_handler_url);
788 793
789 TestApplicationLoader* loader = new TestApplicationLoader; 794 TestApplicationLoader* loader = new TestApplicationLoader;
790 loader->set_context(&test_context); 795 loader->set_context(&test_context);
791 application_manager.SetLoaderForURL(scoped_ptr<ApplicationLoader>(loader), 796 application_manager.SetLoaderForURL(scoped_ptr<ApplicationLoader>(loader),
792 content_handler_url); 797 content_handler_url);
793 798
794 bool called = false; 799 bool called = false;
800 mojo::URLRequestPtr request(mojo::URLRequest::New());
801 request->url = mojo::String::From("test:test");
795 application_manager.ConnectToApplication( 802 application_manager.ConnectToApplication(
796 GURL("test:test"), requestor_url, nullptr, nullptr, 803 request.Pass(), requestor_url, nullptr, nullptr,
797 base::Bind(&QuitClosure, base::Unretained(&called))); 804 base::Bind(&QuitClosure, base::Unretained(&called)));
798 loop.Run(); 805 loop.Run();
799 EXPECT_TRUE(called); 806 EXPECT_TRUE(called);
800 807
801 ASSERT_EQ(1, loader->num_loads()); 808 ASSERT_EQ(1, loader->num_loads());
802 EXPECT_EQ(requestor_url, loader->last_requestor_url()); 809 EXPECT_EQ(requestor_url, loader->last_requestor_url());
803 } 810 }
804 811
805 } // namespace 812 } // namespace
806 } // namespace shell 813 } // namespace shell
807 } // namespace mojo 814 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/application_manager.cc ('k') | mojo/shell/fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698