Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: chrome/common/net/gaia/mock_url_fetcher_factory.h

Issue 10412050: Change most content::URLFetcher references to net::URLFetcher (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ChromeOS, address comments Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 CHROME_COMMON_NET_GAIA_MOCK_URL_FETCHER_FACTORY_H_ 8 #ifndef CHROME_COMMON_NET_GAIA_MOCK_URL_FETCHER_FACTORY_H_
9 #define CHROME_COMMON_NET_GAIA_MOCK_URL_FETCHER_FACTORY_H_ 9 #define CHROME_COMMON_NET_GAIA_MOCK_URL_FETCHER_FACTORY_H_
10 #pragma once 10 #pragma once
11 11
12 #include <string> 12 #include <string>
13 13
14 #include "chrome/common/net/gaia/gaia_auth_fetcher.h" 14 #include "chrome/common/net/gaia/gaia_auth_fetcher.h"
15 #include "content/test/test_url_fetcher_factory.h" 15 #include "content/test/test_url_fetcher_factory.h"
16 #include "net/url_request/url_request_status.h" 16 #include "net/url_request/url_request_status.h"
17 17
18 // Responds as though ClientLogin returned from the server. 18 // Responds as though ClientLogin returned from the server.
19 class MockFetcher : public TestURLFetcher { 19 class MockFetcher : public TestURLFetcher {
20 public: 20 public:
21 MockFetcher(bool success, 21 MockFetcher(bool success,
22 const GURL& url, 22 const GURL& url,
23 const std::string& results, 23 const std::string& results,
24 content::URLFetcher::RequestType request_type, 24 net::URLFetcher::RequestType request_type,
25 net::URLFetcherDelegate* d); 25 net::URLFetcherDelegate* d);
26 26
27 MockFetcher(const GURL& url, 27 MockFetcher(const GURL& url,
28 const net::URLRequestStatus& status, 28 const net::URLRequestStatus& status,
29 int response_code, 29 int response_code,
30 const net::ResponseCookies& cookies, 30 const net::ResponseCookies& cookies,
31 const std::string& results, 31 const std::string& results,
32 content::URLFetcher::RequestType request_type, 32 net::URLFetcher::RequestType request_type,
33 net::URLFetcherDelegate* d); 33 net::URLFetcherDelegate* d);
34 34
35 virtual ~MockFetcher(); 35 virtual ~MockFetcher();
36 36
37 virtual void Start() OVERRIDE; 37 virtual void Start() OVERRIDE;
38 38
39 private: 39 private:
40 DISALLOW_COPY_AND_ASSIGN(MockFetcher); 40 DISALLOW_COPY_AND_ASSIGN(MockFetcher);
41 }; 41 };
42 42
43 template<typename T> 43 template<typename T>
44 class MockURLFetcherFactory : public content::URLFetcherFactory, 44 class MockURLFetcherFactory : public content::URLFetcherFactory,
45 public ScopedURLFetcherFactory { 45 public ScopedURLFetcherFactory {
46 public: 46 public:
47 MockURLFetcherFactory() 47 MockURLFetcherFactory()
48 : ScopedURLFetcherFactory(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 48 : ScopedURLFetcherFactory(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
49 success_(true) { 49 success_(true) {
50 } 50 }
51 ~MockURLFetcherFactory() {} 51 ~MockURLFetcherFactory() {}
52 content::URLFetcher* CreateURLFetcher( 52 net::URLFetcher* CreateURLFetcher(
53 int id, 53 int id,
54 const GURL& url, 54 const GURL& url,
55 content::URLFetcher::RequestType request_type, 55 net::URLFetcher::RequestType request_type,
56 net::URLFetcherDelegate* d) OVERRIDE { 56 net::URLFetcherDelegate* d) OVERRIDE {
57 return new T(success_, url, results_, request_type, d); 57 return new T(success_, url, results_, request_type, d);
58 } 58 }
59 void set_success(bool success) { 59 void set_success(bool success) {
60 success_ = success; 60 success_ = success;
61 } 61 }
62 void set_results(const std::string& results) { 62 void set_results(const std::string& results) {
63 results_ = results; 63 results_ = results;
64 } 64 }
65 private: 65 private:
66 bool success_; 66 bool success_;
67 std::string results_; 67 std::string results_;
68 DISALLOW_COPY_AND_ASSIGN(MockURLFetcherFactory); 68 DISALLOW_COPY_AND_ASSIGN(MockURLFetcherFactory);
69 }; 69 };
70 70
71 #endif // CHROME_COMMON_NET_GAIA_MOCK_URL_FETCHER_FACTORY_H_ 71 #endif // CHROME_COMMON_NET_GAIA_MOCK_URL_FETCHER_FACTORY_H_
OLDNEW
« no previous file with comments | « chrome/common/net/gaia/gaia_oauth_client_unittest.cc ('k') | chrome/common/net/gaia/oauth2_access_token_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698