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

Side by Side Diff: chrome/browser/chromeos/policy/upload_job_unittest.cc

Issue 2522283002: Correct EmbeddedTestServer usage in chromeos tests. (Closed)
Patch Set: Correct EmbeddedTestServer usage in chromeos tests. Created 4 years 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
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <queue> 9 #include <queue>
10 #include <set> 10 #include <set>
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 221
222 std::unique_ptr<UploadJob::ErrorCode> expected_error_; 222 std::unique_ptr<UploadJob::ErrorCode> expected_error_;
223 }; 223 };
224 224
225 class UploadFlowTest : public UploadJobTestBase { 225 class UploadFlowTest : public UploadJobTestBase {
226 public: 226 public:
227 UploadFlowTest() {} 227 UploadFlowTest() {}
228 228
229 // UploadJobTestBase: 229 // UploadJobTestBase:
230 void SetUp() override { 230 void SetUp() override {
231 UploadJobTestBase::SetUp();
232 test_server_.RegisterRequestHandler( 231 test_server_.RegisterRequestHandler(
233 base::Bind(&UploadFlowTest::HandlePostRequest, base::Unretained(this))); 232 base::Bind(&UploadFlowTest::HandlePostRequest, base::Unretained(this)));
233 UploadJobTestBase::SetUp();
234 upload_attempt_count_ = 0; 234 upload_attempt_count_ = 0;
235 } 235 }
236 236
237 // Sets the response code which will be returned when no other problems occur. 237 // Sets the response code which will be returned when no other problems occur.
238 // Default is |net::HTTP_OK| 238 // Default is |net::HTTP_OK|
239 void SetResponseDefaultStatusCode(net::HttpStatusCode code) { 239 void SetResponseDefaultStatusCode(net::HttpStatusCode code) {
240 default_status_code_ = code; 240 default_status_code_ = code;
241 } 241 }
242 242
243 std::unique_ptr<net::test_server::HttpResponse> HandlePostRequest( 243 std::unique_ptr<net::test_server::HttpResponse> HandlePostRequest(
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 // kMaxAttempts 342 // kMaxAttempts
343 ASSERT_EQ(4, upload_attempt_count_); 343 ASSERT_EQ(4, upload_attempt_count_);
344 } 344 }
345 345
346 class UploadRequestTest : public UploadJobTestBase { 346 class UploadRequestTest : public UploadJobTestBase {
347 public: 347 public:
348 UploadRequestTest() {} 348 UploadRequestTest() {}
349 349
350 // UploadJobTestBase: 350 // UploadJobTestBase:
351 void SetUp() override { 351 void SetUp() override {
352 UploadJobTestBase::SetUp();
353 test_server_.RegisterRequestHandler(base::Bind( 352 test_server_.RegisterRequestHandler(base::Bind(
354 &UploadRequestTest::HandlePostRequest, base::Unretained(this))); 353 &UploadRequestTest::HandlePostRequest, base::Unretained(this)));
354 UploadJobTestBase::SetUp();
355 } 355 }
356 356
357 std::unique_ptr<net::test_server::HttpResponse> HandlePostRequest( 357 std::unique_ptr<net::test_server::HttpResponse> HandlePostRequest(
358 const net::test_server::HttpRequest& request) { 358 const net::test_server::HttpRequest& request) {
359 std::unique_ptr<net::test_server::BasicHttpResponse> response( 359 std::unique_ptr<net::test_server::BasicHttpResponse> response(
360 new net::test_server::BasicHttpResponse); 360 new net::test_server::BasicHttpResponse);
361 response->set_code(net::HTTP_OK); 361 response->set_code(net::HTTP_OK);
362 EXPECT_EQ(expected_content_, request.content); 362 EXPECT_EQ(expected_content_, request.content);
363 return std::move(response); 363 return std::move(response);
364 } 364 }
(...skipping 24 matching lines...) Expand all
389 "customfield2: CUSTOM2\r\n" 389 "customfield2: CUSTOM2\r\n"
390 "\r\n" 390 "\r\n"
391 "**||--||PAYLOAD2||--||**\r\n--" 391 "**||--||PAYLOAD2||--||**\r\n--"
392 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA--\r\n"); 392 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA--\r\n");
393 393
394 upload_job->Start(); 394 upload_job->Start();
395 run_loop_.Run(); 395 run_loop_.Run();
396 } 396 }
397 397
398 } // namespace policy 398 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698