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

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

Issue 8373021: Convert URLFetcher::Delegates to use an interface in content/public/common. Also remove the old U... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync and remove unncessary forward declares Created 9 years, 2 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) 2011 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
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 "chrome/common/net/http_return.h" 15 #include "chrome/common/net/http_return.h"
16 #include "content/common/net/url_fetcher.h" 16 #include "content/common/net/url_fetcher.h"
17 #include "content/test/test_url_fetcher_factory.h" 17 #include "content/test/test_url_fetcher_factory.h"
18 #include "net/url_request/url_request_status.h" 18 #include "net/url_request/url_request_status.h"
19 19
20 namespace content {
21 class URLFetcherDelegate;
22 }
23
20 // Responds as though ClientLogin returned from the server. 24 // Responds as though ClientLogin returned from the server.
21 class MockFetcher : public URLFetcher { 25 class MockFetcher : public URLFetcher {
22 public: 26 public:
23 MockFetcher(bool success, 27 MockFetcher(bool success,
24 const GURL& url, 28 const GURL& url,
25 const std::string& results, 29 const std::string& results,
26 URLFetcher::RequestType request_type, 30 URLFetcher::RequestType request_type,
27 URLFetcher::Delegate* d); 31 content::URLFetcherDelegate* d);
32
33 MockFetcher(const GURL& url,
34 const net::URLRequestStatus& status,
35 int response_code,
36 const net::ResponseCookies& cookies,
37 const std::string& results,
38 URLFetcher::RequestType request_type,
39 content::URLFetcherDelegate* d);
28 40
29 virtual ~MockFetcher(); 41 virtual ~MockFetcher();
30 42
31 virtual void Start(); 43 virtual void Start();
32 44
45 virtual const GURL& url() const;
46 virtual const net::URLRequestStatus& status() const;
47 virtual int response_code() const;
48 virtual const net::ResponseCookies& cookies() const;
49 virtual bool GetResponseAsString(std::string* out_response_string) const;
50
33 private: 51 private:
34 bool success_;
35 GURL url_; 52 GURL url_;
53 net::URLRequestStatus status_;
54 int response_code_;
55 net::ResponseCookies cookies_;
36 std::string results_; 56 std::string results_;
37 DISALLOW_COPY_AND_ASSIGN(MockFetcher); 57 DISALLOW_COPY_AND_ASSIGN(MockFetcher);
38 }; 58 };
39 59
40 template<typename T> 60 template<typename T>
41 class MockFactory : public URLFetcher::Factory, 61 class MockFactory : public URLFetcher::Factory,
42 public ScopedURLFetcherFactory { 62 public ScopedURLFetcherFactory {
43 public: 63 public:
44 MockFactory() 64 MockFactory()
45 : ScopedURLFetcherFactory(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 65 : ScopedURLFetcherFactory(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
46 success_(true) { 66 success_(true) {
47 } 67 }
48 ~MockFactory() {} 68 ~MockFactory() {}
49 URLFetcher* CreateURLFetcher(int id, 69 URLFetcher* CreateURLFetcher(int id,
50 const GURL& url, 70 const GURL& url,
51 URLFetcher::RequestType request_type, 71 URLFetcher::RequestType request_type,
52 URLFetcher::Delegate* d) { 72 content::URLFetcherDelegate* d) {
53 return new T(success_, url, results_, request_type, d); 73 return new T(success_, url, results_, request_type, d);
54 } 74 }
55 void set_success(bool success) { 75 void set_success(bool success) {
56 success_ = success; 76 success_ = success;
57 } 77 }
58 void set_results(const std::string& results) { 78 void set_results(const std::string& results) {
59 results_ = results; 79 results_ = results;
60 } 80 }
61 private: 81 private:
62 bool success_; 82 bool success_;
63 std::string results_; 83 std::string results_;
64 DISALLOW_COPY_AND_ASSIGN(MockFactory); 84 DISALLOW_COPY_AND_ASSIGN(MockFactory);
65 }; 85 };
66 86
67 #endif // CHROME_COMMON_NET_GAIA_GAIA_AUTH_FETCHER_UNITTEST_H_ 87 #endif // CHROME_COMMON_NET_GAIA_GAIA_AUTH_FETCHER_UNITTEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698