Roll src/third_party/WebKit abe9e39c:3d349bd (svn 182659:182669)
[chromium-blink-merge.git] / chromeos / login / auth / mock_url_fetchers.h
blob703c4667b82bd609efb3da0301e01d312c75f8f0
1 // Copyright 2014 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 CHROMEOS_LOGIN_AUTH_MOCK_URL_FETCHERS_H_
6 #define CHROMEOS_LOGIN_AUTH_MOCK_URL_FETCHERS_H_
8 #include <string>
10 #include "base/compiler_specific.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/message_loop/message_loop.h"
13 #include "chromeos/chromeos_export.h"
14 #include "net/url_request/test_url_fetcher_factory.h"
15 #include "net/url_request/url_request_status.h"
16 #include "url/gurl.h"
18 namespace net {
19 class URLFetcherDelegate;
22 namespace chromeos {
24 // Simulates a URL fetch by posting a delayed task. This fetch expects to be
25 // canceled, and fails the test if it is not
26 class ExpectCanceledFetcher : public net::TestURLFetcher {
27 public:
28 ExpectCanceledFetcher(bool success,
29 const GURL& url,
30 const std::string& results,
31 net::URLFetcher::RequestType request_type,
32 net::URLFetcherDelegate* d);
33 virtual ~ExpectCanceledFetcher();
35 virtual void Start() OVERRIDE;
37 void CompleteFetch();
39 private:
40 base::WeakPtrFactory<ExpectCanceledFetcher> weak_factory_;
41 DISALLOW_COPY_AND_ASSIGN(ExpectCanceledFetcher);
44 class GotCanceledFetcher : public net::TestURLFetcher {
45 public:
46 GotCanceledFetcher(bool success,
47 const GURL& url,
48 const std::string& results,
49 net::URLFetcher::RequestType request_type,
50 net::URLFetcherDelegate* d);
51 virtual ~GotCanceledFetcher();
53 virtual void Start() OVERRIDE;
55 private:
56 DISALLOW_COPY_AND_ASSIGN(GotCanceledFetcher);
59 class SuccessFetcher : public net::TestURLFetcher {
60 public:
61 SuccessFetcher(bool success,
62 const GURL& url,
63 const std::string& results,
64 net::URLFetcher::RequestType request_type,
65 net::URLFetcherDelegate* d);
66 virtual ~SuccessFetcher();
68 virtual void Start() OVERRIDE;
70 private:
71 DISALLOW_COPY_AND_ASSIGN(SuccessFetcher);
74 class FailFetcher : public net::TestURLFetcher {
75 public:
76 FailFetcher(bool success,
77 const GURL& url,
78 const std::string& results,
79 net::URLFetcher::RequestType request_type,
80 net::URLFetcherDelegate* d);
81 virtual ~FailFetcher();
83 virtual void Start() OVERRIDE;
85 private:
86 DISALLOW_COPY_AND_ASSIGN(FailFetcher);
89 class CaptchaFetcher : public net::TestURLFetcher {
90 public:
91 CaptchaFetcher(bool success,
92 const GURL& url,
93 const std::string& results,
94 net::URLFetcher::RequestType request_type,
95 net::URLFetcherDelegate* d);
96 virtual ~CaptchaFetcher();
98 static std::string GetCaptchaToken();
99 static std::string GetCaptchaUrl();
100 static std::string GetUnlockUrl();
102 virtual void Start() OVERRIDE;
104 private:
105 static const char kCaptchaToken[];
106 static const char kCaptchaUrlBase[];
107 static const char kCaptchaUrlFragment[];
108 static const char kUnlockUrl[];
109 DISALLOW_COPY_AND_ASSIGN(CaptchaFetcher);
112 class HostedFetcher : public net::TestURLFetcher {
113 public:
114 HostedFetcher(bool success,
115 const GURL& url,
116 const std::string& results,
117 net::URLFetcher::RequestType request_type,
118 net::URLFetcherDelegate* d);
119 virtual ~HostedFetcher();
121 virtual void Start() OVERRIDE;
123 private:
124 DISALLOW_COPY_AND_ASSIGN(HostedFetcher);
127 } // namespace chromeos
129 #endif // CHROMEOS_LOGIN_AUTH_MOCK_URL_FETCHERS_H_