OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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/policy/upload_job.h" | 5 #include "chrome/browser/chromeos/policy/upload_job.h" |
6 | 6 |
7 #include <queue> | 7 #include <queue> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 171 |
172 void SetExpectedError(scoped_ptr<UploadJob::ErrorCode> expected_error) { | 172 void SetExpectedError(scoped_ptr<UploadJob::ErrorCode> expected_error) { |
173 expected_error_ = expected_error.Pass(); | 173 expected_error_ = expected_error.Pass(); |
174 } | 174 } |
175 | 175 |
176 // testing::Test: | 176 // testing::Test: |
177 void SetUp() override { | 177 void SetUp() override { |
178 request_context_getter_ = new net::TestURLRequestContextGetter( | 178 request_context_getter_ = new net::TestURLRequestContextGetter( |
179 base::ThreadTaskRunnerHandle::Get()); | 179 base::ThreadTaskRunnerHandle::Get()); |
180 oauth2_service_.AddAccount("robot@gmail.com"); | 180 oauth2_service_.AddAccount("robot@gmail.com"); |
181 ASSERT_TRUE(test_server_.InitializeAndWaitUntilReady()); | 181 ASSERT_TRUE(test_server_.Start()); |
182 } | 182 } |
183 | 183 |
184 // testing::Test: | 184 // testing::Test: |
185 void TearDown() override { | 185 void TearDown() override { |
186 ASSERT_TRUE(test_server_.ShutdownAndWaitUntilComplete()); | 186 ASSERT_TRUE(test_server_.ShutdownAndWaitUntilComplete()); |
187 } | 187 } |
188 | 188 |
189 protected: | 189 protected: |
190 scoped_ptr<UploadJob> PrepareUploadJob(scoped_ptr< | 190 scoped_ptr<UploadJob> PrepareUploadJob(scoped_ptr< |
191 UploadJobImpl::MimeBoundaryGenerator> mime_boundary_generator) { | 191 UploadJobImpl::MimeBoundaryGenerator> mime_boundary_generator) { |
192 scoped_ptr<UploadJob> upload_job(new UploadJobImpl( | 192 scoped_ptr<UploadJob> upload_job(new UploadJobImpl( |
193 GetServerURL(), kRobotAccountId, &oauth2_service_, | 193 GetServerURL(), kRobotAccountId, &oauth2_service_, |
194 request_context_getter_.get(), this, mime_boundary_generator.Pass())); | 194 request_context_getter_.get(), this, mime_boundary_generator.Pass())); |
195 | 195 |
196 std::map<std::string, std::string> header_entries; | 196 std::map<std::string, std::string> header_entries; |
197 header_entries.insert(std::make_pair(kCustomField1, "CUSTOM1")); | 197 header_entries.insert(std::make_pair(kCustomField1, "CUSTOM1")); |
198 scoped_ptr<std::string> data(new std::string(kTestPayload1)); | 198 scoped_ptr<std::string> data(new std::string(kTestPayload1)); |
199 upload_job->AddDataSegment("Name1", "file1.ext", header_entries, | 199 upload_job->AddDataSegment("Name1", "file1.ext", header_entries, |
200 data.Pass()); | 200 data.Pass()); |
201 | 201 |
202 header_entries.insert(std::make_pair(kCustomField2, "CUSTOM2")); | 202 header_entries.insert(std::make_pair(kCustomField2, "CUSTOM2")); |
203 scoped_ptr<std::string> data2(new std::string(kTestPayload2)); | 203 scoped_ptr<std::string> data2(new std::string(kTestPayload2)); |
204 upload_job->AddDataSegment("Name2", "", header_entries, data2.Pass()); | 204 upload_job->AddDataSegment("Name2", "", header_entries, data2.Pass()); |
205 return upload_job.Pass(); | 205 return upload_job.Pass(); |
206 } | 206 } |
207 | 207 |
208 content::TestBrowserThreadBundle test_browser_thread_bundle_; | 208 content::TestBrowserThreadBundle test_browser_thread_bundle_; |
209 base::RunLoop run_loop_; | 209 base::RunLoop run_loop_; |
210 net::test_server::EmbeddedTestServer test_server_; | 210 net::EmbeddedTestServer test_server_; |
211 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; | 211 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; |
212 MockOAuth2TokenService oauth2_service_; | 212 MockOAuth2TokenService oauth2_service_; |
213 | 213 |
214 scoped_ptr<UploadJob::ErrorCode> expected_error_; | 214 scoped_ptr<UploadJob::ErrorCode> expected_error_; |
215 }; | 215 }; |
216 | 216 |
217 class UploadFlowTest : public UploadJobTestBase { | 217 class UploadFlowTest : public UploadJobTestBase { |
218 public: | 218 public: |
219 UploadFlowTest() {} | 219 UploadFlowTest() {} |
220 | 220 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 "customfield2: CUSTOM2\r\n" | 333 "customfield2: CUSTOM2\r\n" |
334 "\r\n" | 334 "\r\n" |
335 "**||--||PAYLOAD2||--||**\r\n--" | 335 "**||--||PAYLOAD2||--||**\r\n--" |
336 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA--\r\n"); | 336 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA--\r\n"); |
337 | 337 |
338 upload_job->Start(); | 338 upload_job->Start(); |
339 run_loop_.Run(); | 339 run_loop_.Run(); |
340 } | 340 } |
341 | 341 |
342 } // namespace policy | 342 } // namespace policy |
OLD | NEW |