summaryrefslogtreecommitdiffstats
path: root/content/test
diff options
context:
space:
mode:
Diffstat (limited to 'content/test')
-rw-r--r--content/test/test_url_fetcher_factory.cc42
-rw-r--r--content/test/test_url_fetcher_factory.h2
2 files changed, 36 insertions, 8 deletions
diff --git a/content/test/test_url_fetcher_factory.cc b/content/test/test_url_fetcher_factory.cc
index d95fbf2..5062b46 100644
--- a/content/test/test_url_fetcher_factory.cc
+++ b/content/test/test_url_fetcher_factory.cc
@@ -125,17 +125,47 @@ class FakeURLFetcher : public URLFetcher {
url_(url),
response_data_(response_data),
success_(success),
+ status_(success ? net::URLRequestStatus::SUCCESS :
+ net::URLRequestStatus::FAILED, 0),
ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
}
// Start the request. This will call the given delegate asynchronously
// with the pre-baked response as parameter.
- virtual void Start() {
+ virtual void Start() OVERRIDE {
MessageLoop::current()->PostTask(
FROM_HERE,
method_factory_.NewRunnableMethod(&FakeURLFetcher::RunDelegate));
}
+ // These methods are overriden so we can use the version of
+ // OnURLFetchComplete that only has a single URLFetcher argument.
+ virtual const net::ResponseCookies& cookies() const OVERRIDE {
+ return cookies_;
+ }
+
+ virtual const std::string& GetResponseStringRef() const OVERRIDE {
+ return response_data_;
+ }
+
+ virtual bool GetResponseAsString(
+ std::string* out_response_string) const OVERRIDE {
+ *out_response_string = response_data_;
+ return true;
+ }
+
+ virtual int response_code() const OVERRIDE {
+ return success_ ? 200 : 500;
+ }
+
+ virtual const net::URLRequestStatus& status() const OVERRIDE {
+ return status_;
+ }
+
+ virtual const GURL& url() const OVERRIDE {
+ return url_;
+ }
+
private:
virtual ~FakeURLFetcher() {
}
@@ -143,11 +173,7 @@ class FakeURLFetcher : public URLFetcher {
// This is the method which actually calls the delegate that is passed in the
// constructor.
void RunDelegate() {
- net::URLRequestStatus status;
- status.set_status(success_ ? net::URLRequestStatus::SUCCESS :
- net::URLRequestStatus::FAILED);
- delegate()->OnURLFetchComplete(this, url_, status, success_ ? 200 : 500,
- net::ResponseCookies(), response_data_);
+ delegate()->OnURLFetchComplete(this);
}
// Pre-baked response data and flag which indicates whether the request should
@@ -155,6 +181,8 @@ class FakeURLFetcher : public URLFetcher {
GURL url_;
std::string response_data_;
bool success_;
+ net::URLRequestStatus status_;
+ net::ResponseCookies cookies_;
// Method factory used to run the delegate.
ScopedRunnableMethodFactory<FakeURLFetcher> method_factory_;
@@ -200,7 +228,7 @@ void FakeURLFetcherFactory::SetFakeResponse(const std::string& url,
fake_responses_[GURL(url)] = std::make_pair(response_data, success);
}
-void FakeURLFetcherFactory::ClearFakeReponses() {
+void FakeURLFetcherFactory::ClearFakeResponses() {
fake_responses_.clear();
}
diff --git a/content/test/test_url_fetcher_factory.h b/content/test/test_url_fetcher_factory.h
index 8b60fd7..a286bad 100644
--- a/content/test/test_url_fetcher_factory.h
+++ b/content/test/test_url_fetcher_factory.h
@@ -210,7 +210,7 @@ class FakeURLFetcherFactory : public URLFetcher::Factory,
// Clear all the fake responses that were previously set via
// SetFakeResponse().
- void ClearFakeReponses();
+ void ClearFakeResponses();
private:
typedef std::map<GURL, std::pair<std::string, bool> > FakeResponseMap;