OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 collection of classes that are useful when testing things that use a | 5 // A collection of classes that are useful when testing things that use a |
6 // GaiaAuthFetcher. | 6 // GaiaAuthFetcher. |
7 | 7 |
8 #ifndef CHROME_COMMON_NET_GAIA_GAIA_AUTH_FETCHER_UNITTEST_H_ | 8 #ifndef CHROME_COMMON_NET_GAIA_GAIA_AUTH_FETCHER_UNITTEST_H_ |
9 #define CHROME_COMMON_NET_GAIA_GAIA_AUTH_FETCHER_UNITTEST_H_ | 9 #define CHROME_COMMON_NET_GAIA_GAIA_AUTH_FETCHER_UNITTEST_H_ |
10 #pragma once | 10 #pragma once |
11 | 11 |
(...skipping 13 matching lines...) Expand all Loading... |
25 URLFetcher::RequestType request_type, | 25 URLFetcher::RequestType request_type, |
26 URLFetcher::Delegate* d) | 26 URLFetcher::Delegate* d) |
27 : URLFetcher(url, request_type, d), | 27 : URLFetcher(url, request_type, d), |
28 success_(success), | 28 success_(success), |
29 url_(url), | 29 url_(url), |
30 results_(results) {} | 30 results_(results) {} |
31 | 31 |
32 ~MockFetcher() {} | 32 ~MockFetcher() {} |
33 | 33 |
34 void Start() { | 34 void Start() { |
35 URLRequestStatus::Status code; | 35 net::URLRequestStatus::Status code; |
36 int http_code; | 36 int http_code; |
37 if (success_) { | 37 if (success_) { |
38 http_code = RC_REQUEST_OK; | 38 http_code = RC_REQUEST_OK; |
39 code = URLRequestStatus::SUCCESS; | 39 code = net::URLRequestStatus::SUCCESS; |
40 } else { | 40 } else { |
41 http_code = RC_FORBIDDEN; | 41 http_code = RC_FORBIDDEN; |
42 code = URLRequestStatus::FAILED; | 42 code = net::URLRequestStatus::FAILED; |
43 } | 43 } |
44 | 44 |
45 URLRequestStatus status(code, 0); | 45 net::URLRequestStatus status(code, 0); |
46 delegate()->OnURLFetchComplete(NULL, | 46 delegate()->OnURLFetchComplete(NULL, |
47 url_, | 47 url_, |
48 status, | 48 status, |
49 http_code, | 49 http_code, |
50 ResponseCookies(), | 50 ResponseCookies(), |
51 results_); | 51 results_); |
52 } | 52 } |
53 private: | 53 private: |
54 bool success_; | 54 bool success_; |
55 GURL url_; | 55 GURL url_; |
(...skipping 19 matching lines...) Expand all Loading... |
75 void set_results(const std::string& results) { | 75 void set_results(const std::string& results) { |
76 results_ = results; | 76 results_ = results; |
77 } | 77 } |
78 private: | 78 private: |
79 bool success_; | 79 bool success_; |
80 std::string results_; | 80 std::string results_; |
81 DISALLOW_COPY_AND_ASSIGN(MockFactory); | 81 DISALLOW_COPY_AND_ASSIGN(MockFactory); |
82 }; | 82 }; |
83 | 83 |
84 #endif // CHROME_COMMON_NET_GAIA_GAIA_AUTH_FETCHER_UNITTEST_H_ | 84 #endif // CHROME_COMMON_NET_GAIA_GAIA_AUTH_FETCHER_UNITTEST_H_ |
OLD | NEW |