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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_URL_FETCHERS_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_URL_FETCHERS_H_
10 #include "base/compiler_specific.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/message_loop/message_loop.h"
13 #include "net/url_request/test_url_fetcher_factory.h"
14 #include "net/url_request/url_request_status.h"
18 class URLFetcherDelegate
;
23 // Simulates a URL fetch by posting a delayed task. This fetch expects to be
24 // canceled, and fails the test if it is not
25 class ExpectCanceledFetcher
: public net::TestURLFetcher
{
27 ExpectCanceledFetcher(bool success
,
29 const std::string
& results
,
30 net::URLFetcher::RequestType request_type
,
31 net::URLFetcherDelegate
* d
);
32 virtual ~ExpectCanceledFetcher();
34 virtual void Start() OVERRIDE
;
39 base::WeakPtrFactory
<ExpectCanceledFetcher
> weak_factory_
;
40 DISALLOW_COPY_AND_ASSIGN(ExpectCanceledFetcher
);
43 class GotCanceledFetcher
: public net::TestURLFetcher
{
45 GotCanceledFetcher(bool success
,
47 const std::string
& results
,
48 net::URLFetcher::RequestType request_type
,
49 net::URLFetcherDelegate
* d
);
50 virtual ~GotCanceledFetcher();
52 virtual void Start() OVERRIDE
;
55 DISALLOW_COPY_AND_ASSIGN(GotCanceledFetcher
);
58 class SuccessFetcher
: public net::TestURLFetcher
{
60 SuccessFetcher(bool success
,
62 const std::string
& results
,
63 net::URLFetcher::RequestType request_type
,
64 net::URLFetcherDelegate
* d
);
65 virtual ~SuccessFetcher();
67 virtual void Start() OVERRIDE
;
70 DISALLOW_COPY_AND_ASSIGN(SuccessFetcher
);
73 class FailFetcher
: public net::TestURLFetcher
{
75 FailFetcher(bool success
,
77 const std::string
& results
,
78 net::URLFetcher::RequestType request_type
,
79 net::URLFetcherDelegate
* d
);
80 virtual ~FailFetcher();
82 virtual void Start() OVERRIDE
;
85 DISALLOW_COPY_AND_ASSIGN(FailFetcher
);
88 class CaptchaFetcher
: public net::TestURLFetcher
{
90 CaptchaFetcher(bool success
,
92 const std::string
& results
,
93 net::URLFetcher::RequestType request_type
,
94 net::URLFetcherDelegate
* d
);
95 virtual ~CaptchaFetcher();
97 static std::string
GetCaptchaToken();
98 static std::string
GetCaptchaUrl();
99 static std::string
GetUnlockUrl();
101 virtual void Start() OVERRIDE
;
104 static const char kCaptchaToken
[];
105 static const char kCaptchaUrlBase
[];
106 static const char kCaptchaUrlFragment
[];
107 static const char kUnlockUrl
[];
108 DISALLOW_COPY_AND_ASSIGN(CaptchaFetcher
);
111 class HostedFetcher
: public net::TestURLFetcher
{
113 HostedFetcher(bool success
,
115 const std::string
& results
,
116 net::URLFetcher::RequestType request_type
,
117 net::URLFetcherDelegate
* d
);
118 virtual ~HostedFetcher();
120 virtual void Start() OVERRIDE
;
123 DISALLOW_COPY_AND_ASSIGN(HostedFetcher
);
126 } // namespace chromeos
128 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_URL_FETCHERS_H_