OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // A complete set of unit tests for GaiaOAuthClient. | 5 // A complete set of unit tests for GaiaOAuthClient. |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 } | 49 } |
50 | 50 |
51 ~MockOAuthFetcher() override {} | 51 ~MockOAuthFetcher() override {} |
52 | 52 |
53 void Start() override { | 53 void Start() override { |
54 if ((GetResponseCode() != net::HTTP_OK) && (max_failure_count_ != -1) && | 54 if ((GetResponseCode() != net::HTTP_OK) && (max_failure_count_ != -1) && |
55 (current_failure_count_ == max_failure_count_)) { | 55 (current_failure_count_ == max_failure_count_)) { |
56 set_response_code(net::HTTP_OK); | 56 set_response_code(net::HTTP_OK); |
57 } | 57 } |
58 | 58 |
59 net::URLRequestStatus::Status code = net::URLRequestStatus::SUCCESS; | 59 net::Error error = net::OK; |
60 if (GetResponseCode() != net::HTTP_OK) { | 60 if (GetResponseCode() != net::HTTP_OK) { |
61 code = net::URLRequestStatus::FAILED; | 61 error = net::ERR_FAILED; |
62 current_failure_count_++; | 62 current_failure_count_++; |
63 } | 63 } |
64 set_status(net::URLRequestStatus(code, 0)); | 64 set_status(net::URLRequestStatus::FromError(error)); |
65 | 65 |
66 if (complete_immediately_) | 66 if (complete_immediately_) |
67 delegate()->OnURLFetchComplete(this); | 67 delegate()->OnURLFetchComplete(this); |
68 } | 68 } |
69 | 69 |
70 void Finish() { | 70 void Finish() { |
71 ASSERT_FALSE(complete_immediately_); | 71 ASSERT_FALSE(complete_immediately_); |
72 delegate()->OnURLFetchComplete(this); | 72 delegate()->OnURLFetchComplete(this); |
73 } | 73 } |
74 | 74 |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 | 407 |
408 GaiaOAuthClient auth(GetRequestContext()); | 408 GaiaOAuthClient auth(GetRequestContext()); |
409 auth.GetTokenHandleInfo("some_handle", 1, &delegate); | 409 auth.GetTokenHandleInfo("some_handle", 1, &delegate); |
410 | 410 |
411 std::string audience; | 411 std::string audience; |
412 ASSERT_TRUE(captured_result->GetString("audience", &audience)); | 412 ASSERT_TRUE(captured_result->GetString("audience", &audience)); |
413 ASSERT_EQ("1234567890.apps.googleusercontent.com", audience); | 413 ASSERT_EQ("1234567890.apps.googleusercontent.com", audience); |
414 } | 414 } |
415 | 415 |
416 } // namespace gaia | 416 } // namespace gaia |
OLD | NEW |