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
3 // found in the LICENSE file.
5 // A collection of classes that are useful when testing things that use a
8 #ifndef GOOGLE_APIS_GAIA_MOCK_URL_FETCHER_FACTORY_H_
9 #define GOOGLE_APIS_GAIA_MOCK_URL_FETCHER_FACTORY_H_
13 #include "google_apis/gaia/gaia_auth_fetcher.h"
14 #include "net/url_request/test_url_fetcher_factory.h"
15 #include "net/url_request/url_request_status.h"
17 // Responds as though ClientLogin returned from the server.
18 class MockFetcher
: public net::TestURLFetcher
{
20 MockFetcher(bool success
,
22 const std::string
& results
,
23 net::URLFetcher::RequestType request_type
,
24 net::URLFetcherDelegate
* d
);
26 MockFetcher(const GURL
& url
,
27 const net::URLRequestStatus
& status
,
29 const net::ResponseCookies
& cookies
,
30 const std::string
& results
,
31 net::URLFetcher::RequestType request_type
,
32 net::URLFetcherDelegate
* d
);
34 ~MockFetcher() override
;
36 void Start() override
;
39 DISALLOW_COPY_AND_ASSIGN(MockFetcher
);
43 class MockURLFetcherFactory
: public net::URLFetcherFactory
,
44 public net::ScopedURLFetcherFactory
{
46 MockURLFetcherFactory()
47 : net::ScopedURLFetcherFactory(this),
50 ~MockURLFetcherFactory() {}
51 scoped_ptr
<net::URLFetcher
> CreateURLFetcher(
54 net::URLFetcher::RequestType request_type
,
55 net::URLFetcherDelegate
* d
) override
{
56 return scoped_ptr
<net::URLFetcher
>(
57 new T(success_
, url
, results_
, request_type
, d
));
59 void set_success(bool success
) {
62 void set_results(const std::string
& results
) {
68 DISALLOW_COPY_AND_ASSIGN(MockURLFetcherFactory
);
71 #endif // GOOGLE_APIS_GAIA_MOCK_URL_FETCHER_FACTORY_H_