| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // GaiaAuthenticator2. | 6 // GaiaAuthenticator2. |
| 7 | 7 |
| 8 #ifndef CHROME_COMMON_NET_GAIA_GAIA_AUTHENTICATOR2_UNITTEST_H_ | 8 #ifndef CHROME_COMMON_NET_GAIA_GAIA_AUTHENTICATOR2_UNITTEST_H_ |
| 9 #define CHROME_COMMON_NET_GAIA_GAIA_AUTHENTICATOR2_UNITTEST_H_ | 9 #define CHROME_COMMON_NET_GAIA_GAIA_AUTHENTICATOR2_UNITTEST_H_ |
| 10 #pragma once | 10 #pragma once |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 http_code, | 43 http_code, |
| 44 ResponseCookies(), | 44 ResponseCookies(), |
| 45 std::string()); | 45 std::string()); |
| 46 } | 46 } |
| 47 private: | 47 private: |
| 48 bool success_; | 48 bool success_; |
| 49 GURL url_; | 49 GURL url_; |
| 50 DISALLOW_COPY_AND_ASSIGN(MockFetcher); | 50 DISALLOW_COPY_AND_ASSIGN(MockFetcher); |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 template<typename T> |
| 53 class MockFactory : public URLFetcher::Factory { | 54 class MockFactory : public URLFetcher::Factory { |
| 54 public: | 55 public: |
| 55 MockFactory() | 56 MockFactory() |
| 56 : success_(true) {} | 57 : success_(true) {} |
| 57 ~MockFactory() {} | 58 ~MockFactory() {} |
| 58 URLFetcher* CreateURLFetcher(int id, | 59 URLFetcher* CreateURLFetcher(int id, |
| 59 const GURL& url, | 60 const GURL& url, |
| 60 URLFetcher::RequestType request_type, | 61 URLFetcher::RequestType request_type, |
| 61 URLFetcher::Delegate* d) { | 62 URLFetcher::Delegate* d) { |
| 62 return new MockFetcher(success_, url, request_type, d); | 63 return new T(success_, url, request_type, d); |
| 63 } | 64 } |
| 64 void set_success(bool success) { | 65 void set_success(bool success) { |
| 65 success_ = success; | 66 success_ = success; |
| 66 } | 67 } |
| 67 private: | 68 private: |
| 68 bool success_; | 69 bool success_; |
| 69 DISALLOW_COPY_AND_ASSIGN(MockFactory); | 70 DISALLOW_COPY_AND_ASSIGN(MockFactory); |
| 70 }; | 71 }; |
| 71 | 72 |
| 72 #endif // CHROME_COMMON_NET_GAIA_GAIA_AUTHENTICATOR2_UNITTEST_H_ | 73 #endif // CHROME_COMMON_NET_GAIA_GAIA_AUTHENTICATOR2_UNITTEST_H_ |
| OLD | NEW |