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

Unified Diff: chrome/common/net/gaia/gaia_oauth_client_unittest.cc

Issue 8395038: Make test URLFetcher implementations not derive from the URLFetcher implementation, since we want... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: move factory to its own file and remove Create function from URLFetcher impl 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/net/gaia/gaia_oauth_client_unittest.cc
===================================================================
--- chrome/common/net/gaia/gaia_oauth_client_unittest.cc (revision 107268)
+++ chrome/common/net/gaia/gaia_oauth_client_unittest.cc (working copy)
@@ -25,67 +25,47 @@
namespace {
// Responds as though OAuth returned from the server.
-class MockOAuthFetcher : public URLFetcher {
+class MockOAuthFetcher : public TestURLFetcher {
public:
MockOAuthFetcher(int response_code,
int max_failure_count,
const GURL& url,
const std::string& results,
- URLFetcher::RequestType request_type,
+ content::URLFetcher::RequestType request_type,
content::URLFetcherDelegate* d)
- : URLFetcher(url, request_type, d),
- response_code_(response_code),
+ : TestURLFetcher(0, url, request_type, d),
max_failure_count_(max_failure_count),
- current_failure_count_(0),
- url_(url),
- results_(results) { }
+ current_failure_count_(0) {
+ set_url(url);
+ set_response_code(response_code);
+ SetResponseString(results);
+ }
+
virtual ~MockOAuthFetcher() { }
virtual void Start() {
- if ((response_code_ != RC_REQUEST_OK) && (max_failure_count_ != -1) &&
+ if ((GetResponseCode() != RC_REQUEST_OK) && (max_failure_count_ != -1) &&
(current_failure_count_ == max_failure_count_)) {
- response_code_ = RC_REQUEST_OK;
+ set_response_code(RC_REQUEST_OK);
}
net::URLRequestStatus::Status code = net::URLRequestStatus::SUCCESS;
- if (response_code_ != RC_REQUEST_OK) {
+ if (GetResponseCode() != RC_REQUEST_OK) {
code = net::URLRequestStatus::FAILED;
current_failure_count_++;
}
- status_ = net::URLRequestStatus(code, 0);
+ set_status(net::URLRequestStatus(code, 0));
delegate()->OnURLFetchComplete(this);
}
- virtual const GURL& GetUrl() const OVERRIDE {
- return url_;
- }
-
- virtual const net::URLRequestStatus& GetStatus() const OVERRIDE {
- return status_;
- }
-
- virtual int GetResponseCode() const OVERRIDE {
- return response_code_;
- }
-
- virtual bool GetResponseAsString(
- std::string* out_response_string) const OVERRIDE {
- *out_response_string = results_;
- return true;
- }
-
private:
- net::URLRequestStatus status_;
- int response_code_;
int max_failure_count_;
int current_failure_count_;
- GURL url_;
- std::string results_;
DISALLOW_COPY_AND_ASSIGN(MockOAuthFetcher);
};
-class MockOAuthFetcherFactory : public URLFetcher::Factory,
+class MockOAuthFetcherFactory : public content::URLFetcherFactory,
public ScopedURLFetcherFactory {
public:
MockOAuthFetcherFactory()
@@ -93,10 +73,10 @@
response_code_(RC_REQUEST_OK) {
}
~MockOAuthFetcherFactory() {}
- virtual URLFetcher* CreateURLFetcher(
+ virtual content::URLFetcher* CreateURLFetcher(
int id,
const GURL& url,
- URLFetcher::RequestType request_type,
+ content::URLFetcher::RequestType request_type,
content::URLFetcherDelegate* d) {
return new MockOAuthFetcher(
response_code_,

Powered by Google App Engine
This is Rietveld 408576698