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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 81 |
82 class MockOAuthFetcherFactory : public net::URLFetcherFactory, | 82 class MockOAuthFetcherFactory : public net::URLFetcherFactory, |
83 public net::ScopedURLFetcherFactory { | 83 public net::ScopedURLFetcherFactory { |
84 public: | 84 public: |
85 MockOAuthFetcherFactory() | 85 MockOAuthFetcherFactory() |
86 : net::ScopedURLFetcherFactory(this), | 86 : net::ScopedURLFetcherFactory(this), |
87 response_code_(net::HTTP_OK), | 87 response_code_(net::HTTP_OK), |
88 complete_immediately_(true) { | 88 complete_immediately_(true) { |
89 } | 89 } |
90 ~MockOAuthFetcherFactory() override {} | 90 ~MockOAuthFetcherFactory() override {} |
91 net::URLFetcher* CreateURLFetcher(int id, | 91 scoped_ptr<net::URLFetcher> CreateURLFetcher( |
92 const GURL& url, | 92 int id, |
93 net::URLFetcher::RequestType request_type, | 93 const GURL& url, |
94 net::URLFetcherDelegate* d) override { | 94 net::URLFetcher::RequestType request_type, |
| 95 net::URLFetcherDelegate* d) override { |
95 url_fetcher_ = new MockOAuthFetcher( | 96 url_fetcher_ = new MockOAuthFetcher( |
96 response_code_, | 97 response_code_, |
97 max_failure_count_, | 98 max_failure_count_, |
98 complete_immediately_, | 99 complete_immediately_, |
99 url, | 100 url, |
100 results_, | 101 results_, |
101 request_type, | 102 request_type, |
102 d); | 103 d); |
103 return url_fetcher_; | 104 return scoped_ptr<net::URLFetcher>(url_fetcher_); |
104 } | 105 } |
105 void set_response_code(int response_code) { | 106 void set_response_code(int response_code) { |
106 response_code_ = response_code; | 107 response_code_ = response_code; |
107 } | 108 } |
108 void set_max_failure_count(int count) { | 109 void set_max_failure_count(int count) { |
109 max_failure_count_ = count; | 110 max_failure_count_ = count; |
110 } | 111 } |
111 void set_results(const std::string& results) { | 112 void set_results(const std::string& results) { |
112 results_ = results; | 113 results_ = results; |
113 } | 114 } |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 | 407 |
407 GaiaOAuthClient auth(GetRequestContext()); | 408 GaiaOAuthClient auth(GetRequestContext()); |
408 auth.GetTokenHandleInfo("some_handle", 1, &delegate); | 409 auth.GetTokenHandleInfo("some_handle", 1, &delegate); |
409 | 410 |
410 std::string audience; | 411 std::string audience; |
411 ASSERT_TRUE(captured_result->GetString("audience", &audience)); | 412 ASSERT_TRUE(captured_result->GetString("audience", &audience)); |
412 ASSERT_EQ("1234567890.apps.googleusercontent.com", audience); | 413 ASSERT_EQ("1234567890.apps.googleusercontent.com", audience); |
413 } | 414 } |
414 | 415 |
415 } // namespace gaia | 416 } // namespace gaia |
OLD | NEW |