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 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 GOOGLE_APIS_GAIA_MOCK_URL_FETCHER_FACTORY_H_ | 8 #ifndef GOOGLE_APIS_GAIA_MOCK_URL_FETCHER_FACTORY_H_ |
9 #define GOOGLE_APIS_GAIA_MOCK_URL_FETCHER_FACTORY_H_ | 9 #define GOOGLE_APIS_GAIA_MOCK_URL_FETCHER_FACTORY_H_ |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 template<typename T> | 43 template<typename T> |
44 class MockURLFetcherFactory : public net::URLFetcherFactory, | 44 class MockURLFetcherFactory : public net::URLFetcherFactory, |
45 public net::ScopedURLFetcherFactory { | 45 public net::ScopedURLFetcherFactory { |
46 public: | 46 public: |
47 MockURLFetcherFactory() | 47 MockURLFetcherFactory() |
48 : net::ScopedURLFetcherFactory(this), | 48 : net::ScopedURLFetcherFactory(this), |
49 success_(true) { | 49 success_(true) { |
50 } | 50 } |
51 ~MockURLFetcherFactory() {} | 51 ~MockURLFetcherFactory() {} |
52 scoped_ptr<net::URLFetcher> CreateURLFetcher( | 52 std::unique_ptr<net::URLFetcher> CreateURLFetcher( |
53 int id, | 53 int id, |
54 const GURL& url, | 54 const GURL& url, |
55 net::URLFetcher::RequestType request_type, | 55 net::URLFetcher::RequestType request_type, |
56 net::URLFetcherDelegate* d) override { | 56 net::URLFetcherDelegate* d) override { |
57 return scoped_ptr<net::URLFetcher>( | 57 return std::unique_ptr<net::URLFetcher>( |
58 new T(success_, url, results_, request_type, d)); | 58 new T(success_, url, results_, request_type, d)); |
59 } | 59 } |
60 void set_success(bool success) { | 60 void set_success(bool success) { |
61 success_ = success; | 61 success_ = success; |
62 } | 62 } |
63 void set_results(const std::string& results) { | 63 void set_results(const std::string& results) { |
64 results_ = results; | 64 results_ = results; |
65 } | 65 } |
66 private: | 66 private: |
67 bool success_; | 67 bool success_; |
68 std::string results_; | 68 std::string results_; |
69 DISALLOW_COPY_AND_ASSIGN(MockURLFetcherFactory); | 69 DISALLOW_COPY_AND_ASSIGN(MockURLFetcherFactory); |
70 }; | 70 }; |
71 | 71 |
72 #endif // GOOGLE_APIS_GAIA_MOCK_URL_FETCHER_FACTORY_H_ | 72 #endif // GOOGLE_APIS_GAIA_MOCK_URL_FETCHER_FACTORY_H_ |
OLD | NEW |