| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/chromeos/fileapi/external_file_url_request_job.h" | 5 #include "chrome/browser/chromeos/fileapi/external_file_url_request_job.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 public: | 51 public: |
| 52 explicit TestURLRequestJobFactory(void* profile_id) | 52 explicit TestURLRequestJobFactory(void* profile_id) |
| 53 : profile_id_(profile_id) {} | 53 : profile_id_(profile_id) {} |
| 54 | 54 |
| 55 virtual ~TestURLRequestJobFactory() {} | 55 virtual ~TestURLRequestJobFactory() {} |
| 56 | 56 |
| 57 // net::URLRequestJobFactory override: | 57 // net::URLRequestJobFactory override: |
| 58 virtual net::URLRequestJob* MaybeCreateJobWithProtocolHandler( | 58 virtual net::URLRequestJob* MaybeCreateJobWithProtocolHandler( |
| 59 const std::string& scheme, | 59 const std::string& scheme, |
| 60 net::URLRequest* request, | 60 net::URLRequest* request, |
| 61 net::NetworkDelegate* network_delegate) const OVERRIDE { | 61 net::NetworkDelegate* network_delegate) const override { |
| 62 return new ExternalFileURLRequestJob( | 62 return new ExternalFileURLRequestJob( |
| 63 profile_id_, request, network_delegate); | 63 profile_id_, request, network_delegate); |
| 64 } | 64 } |
| 65 | 65 |
| 66 virtual bool IsHandledProtocol(const std::string& scheme) const OVERRIDE { | 66 virtual bool IsHandledProtocol(const std::string& scheme) const override { |
| 67 return scheme == chrome::kExternalFileScheme; | 67 return scheme == chrome::kExternalFileScheme; |
| 68 } | 68 } |
| 69 | 69 |
| 70 virtual bool IsHandledURL(const GURL& url) const OVERRIDE { | 70 virtual bool IsHandledURL(const GURL& url) const override { |
| 71 return url.is_valid() && IsHandledProtocol(url.scheme()); | 71 return url.is_valid() && IsHandledProtocol(url.scheme()); |
| 72 } | 72 } |
| 73 | 73 |
| 74 virtual bool IsSafeRedirectTarget(const GURL& location) const OVERRIDE { | 74 virtual bool IsSafeRedirectTarget(const GURL& location) const override { |
| 75 return true; | 75 return true; |
| 76 } | 76 } |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 void* const profile_id_; | 79 void* const profile_id_; |
| 80 DISALLOW_COPY_AND_ASSIGN(TestURLRequestJobFactory); | 80 DISALLOW_COPY_AND_ASSIGN(TestURLRequestJobFactory); |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 class TestDelegate : public net::TestDelegate { | 83 class TestDelegate : public net::TestDelegate { |
| 84 public: | 84 public: |
| 85 TestDelegate() {} | 85 TestDelegate() {} |
| 86 | 86 |
| 87 const GURL& redirect_url() const { return redirect_url_; } | 87 const GURL& redirect_url() const { return redirect_url_; } |
| 88 | 88 |
| 89 // net::TestDelegate override. | 89 // net::TestDelegate override. |
| 90 virtual void OnReceivedRedirect(net::URLRequest* request, | 90 virtual void OnReceivedRedirect(net::URLRequest* request, |
| 91 const net::RedirectInfo& redirect_info, | 91 const net::RedirectInfo& redirect_info, |
| 92 bool* defer_redirect) OVERRIDE { | 92 bool* defer_redirect) override { |
| 93 redirect_url_ = redirect_info.new_url; | 93 redirect_url_ = redirect_info.new_url; |
| 94 net::TestDelegate::OnReceivedRedirect( | 94 net::TestDelegate::OnReceivedRedirect( |
| 95 request, redirect_info, defer_redirect); | 95 request, redirect_info, defer_redirect); |
| 96 } | 96 } |
| 97 | 97 |
| 98 private: | 98 private: |
| 99 GURL redirect_url_; | 99 GURL redirect_url_; |
| 100 | 100 |
| 101 DISALLOW_COPY_AND_ASSIGN(TestDelegate); | 101 DISALLOW_COPY_AND_ASSIGN(TestDelegate); |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 } // namespace | 104 } // namespace |
| 105 | 105 |
| 106 class ExternalFileURLRequestJobTest : public testing::Test { | 106 class ExternalFileURLRequestJobTest : public testing::Test { |
| 107 protected: | 107 protected: |
| 108 ExternalFileURLRequestJobTest() | 108 ExternalFileURLRequestJobTest() |
| 109 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), | 109 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), |
| 110 integration_service_factory_callback_(base::Bind( | 110 integration_service_factory_callback_(base::Bind( |
| 111 &ExternalFileURLRequestJobTest::CreateDriveIntegrationService, | 111 &ExternalFileURLRequestJobTest::CreateDriveIntegrationService, |
| 112 base::Unretained(this))), | 112 base::Unretained(this))), |
| 113 fake_file_system_(NULL) {} | 113 fake_file_system_(NULL) {} |
| 114 | 114 |
| 115 virtual ~ExternalFileURLRequestJobTest() {} | 115 virtual ~ExternalFileURLRequestJobTest() {} |
| 116 | 116 |
| 117 virtual void SetUp() OVERRIDE { | 117 virtual void SetUp() override { |
| 118 // Create a testing profile. | 118 // Create a testing profile. |
| 119 profile_manager_.reset( | 119 profile_manager_.reset( |
| 120 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); | 120 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); |
| 121 ASSERT_TRUE(profile_manager_->SetUp()); | 121 ASSERT_TRUE(profile_manager_->SetUp()); |
| 122 Profile* const profile = | 122 Profile* const profile = |
| 123 profile_manager_->CreateTestingProfile("test-user"); | 123 profile_manager_->CreateTestingProfile("test-user"); |
| 124 | 124 |
| 125 // Create the drive integration service for the profile. | 125 // Create the drive integration service for the profile. |
| 126 integration_service_factory_scope_.reset( | 126 integration_service_factory_scope_.reset( |
| 127 new drive::DriveIntegrationServiceFactory::ScopedFactoryForTest( | 127 new drive::DriveIntegrationServiceFactory::ScopedFactoryForTest( |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 "Range", "Wrong Range Header Value", false /* overwrite */); | 417 "Range", "Wrong Range Header Value", false /* overwrite */); |
| 418 request->Start(); | 418 request->Start(); |
| 419 | 419 |
| 420 base::RunLoop().Run(); | 420 base::RunLoop().Run(); |
| 421 | 421 |
| 422 EXPECT_EQ(net::URLRequestStatus::FAILED, request->status().status()); | 422 EXPECT_EQ(net::URLRequestStatus::FAILED, request->status().status()); |
| 423 EXPECT_EQ(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE, request->status().error()); | 423 EXPECT_EQ(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE, request->status().error()); |
| 424 } | 424 } |
| 425 | 425 |
| 426 } // namespace chromeos | 426 } // namespace chromeos |
| OLD | NEW |