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/drive/drive_url_request_job.h" | 5 #include "chrome/browser/chromeos/drive/drive_url_request_job.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 new test_util::FakeFileSystem(fake_drive_service_.get())); | 115 new test_util::FakeFileSystem(fake_drive_service_.get())); |
116 ASSERT_TRUE(fake_file_system_->InitializeForTesting()); | 116 ASSERT_TRUE(fake_file_system_->InitializeForTesting()); |
117 | 117 |
118 scoped_refptr<base::SequencedWorkerPool> blocking_pool = | 118 scoped_refptr<base::SequencedWorkerPool> blocking_pool = |
119 content::BrowserThread::GetBlockingPool(); | 119 content::BrowserThread::GetBlockingPool(); |
120 test_network_delegate_.reset(new net::TestNetworkDelegate); | 120 test_network_delegate_.reset(new net::TestNetworkDelegate); |
121 test_url_request_job_factory_.reset(new TestURLRequestJobFactory( | 121 test_url_request_job_factory_.reset(new TestURLRequestJobFactory( |
122 base::Bind(&DriveURLRequestJobTest::GetFileSystem, | 122 base::Bind(&DriveURLRequestJobTest::GetFileSystem, |
123 base::Unretained(this)), | 123 base::Unretained(this)), |
124 blocking_pool->GetSequencedTaskRunner( | 124 blocking_pool->GetSequencedTaskRunner( |
125 blocking_pool->GetSequenceToken()))); | 125 blocking_pool->GetSequenceToken()).get())); |
126 url_request_context_.reset(new net::URLRequestContext()); | 126 url_request_context_.reset(new net::URLRequestContext()); |
127 url_request_context_->set_job_factory(test_url_request_job_factory_.get()); | 127 url_request_context_->set_job_factory(test_url_request_job_factory_.get()); |
128 url_request_context_->set_network_delegate(test_network_delegate_.get()); | 128 url_request_context_->set_network_delegate(test_network_delegate_.get()); |
129 test_delegate_.reset(new TestDelegate); | 129 test_delegate_.reset(new TestDelegate); |
130 } | 130 } |
131 | 131 |
132 FileSystemInterface* GetFileSystem() { | 132 FileSystemInterface* GetFileSystem() { |
133 return fake_file_system_.get(); | 133 return fake_file_system_.get(); |
134 } | 134 } |
135 | 135 |
136 bool ReadDriveFileSync( | 136 bool ReadDriveFileSync( |
137 const base::FilePath& file_path, std::string* out_content) { | 137 const base::FilePath& file_path, std::string* out_content) { |
138 scoped_ptr<base::Thread> worker_thread( | 138 scoped_ptr<base::Thread> worker_thread( |
139 new base::Thread("ReadDriveFileSync")); | 139 new base::Thread("ReadDriveFileSync")); |
140 if (!worker_thread->Start()) | 140 if (!worker_thread->Start()) |
141 return false; | 141 return false; |
142 | 142 |
143 scoped_ptr<DriveFileStreamReader> reader(new DriveFileStreamReader( | 143 scoped_ptr<DriveFileStreamReader> reader(new DriveFileStreamReader( |
144 base::Bind(&DriveURLRequestJobTest::GetFileSystem, | 144 base::Bind(&DriveURLRequestJobTest::GetFileSystem, |
145 base::Unretained(this)), | 145 base::Unretained(this)), |
146 worker_thread->message_loop_proxy())); | 146 worker_thread->message_loop_proxy().get())); |
147 int error = net::ERR_FAILED; | 147 int error = net::ERR_FAILED; |
148 scoped_ptr<ResourceEntry> entry; | 148 scoped_ptr<ResourceEntry> entry; |
149 { | 149 { |
150 base::RunLoop run_loop; | 150 base::RunLoop run_loop; |
151 reader->Initialize( | 151 reader->Initialize( |
152 file_path, | 152 file_path, |
153 net::HttpByteRange(), | 153 net::HttpByteRange(), |
154 google_apis::test_util::CreateQuitCallback( | 154 google_apis::test_util::CreateQuitCallback( |
155 &run_loop, | 155 &run_loop, |
156 google_apis::test_util::CreateCopyResultCallback( | 156 google_apis::test_util::CreateCopyResultCallback( |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 "Range", "Wrong Range Header Value", false /* overwrite */); | 361 "Range", "Wrong Range Header Value", false /* overwrite */); |
362 request.Start(); | 362 request.Start(); |
363 | 363 |
364 base::RunLoop().Run(); | 364 base::RunLoop().Run(); |
365 | 365 |
366 EXPECT_EQ(net::URLRequestStatus::FAILED, request.status().status()); | 366 EXPECT_EQ(net::URLRequestStatus::FAILED, request.status().status()); |
367 EXPECT_EQ(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE, request.status().error()); | 367 EXPECT_EQ(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE, request.status().error()); |
368 } | 368 } |
369 | 369 |
370 } // namespace drive | 370 } // namespace drive |
OLD | NEW |