| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROMEOS_LOGIN_AUTH_MOCK_URL_FETCHERS_H_ | 5 #ifndef CHROMEOS_LOGIN_AUTH_MOCK_URL_FETCHERS_H_ |
| 6 #define CHROMEOS_LOGIN_AUTH_MOCK_URL_FETCHERS_H_ | 6 #define CHROMEOS_LOGIN_AUTH_MOCK_URL_FETCHERS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 // Simulates a URL fetch by posting a delayed task. This fetch expects to be | 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 | 25 // canceled, and fails the test if it is not |
| 26 class ExpectCanceledFetcher : public net::TestURLFetcher { | 26 class ExpectCanceledFetcher : public net::TestURLFetcher { |
| 27 public: | 27 public: |
| 28 ExpectCanceledFetcher(bool success, | 28 ExpectCanceledFetcher(bool success, |
| 29 const GURL& url, | 29 const GURL& url, |
| 30 const std::string& results, | 30 const std::string& results, |
| 31 net::URLFetcher::RequestType request_type, | 31 net::URLFetcher::RequestType request_type, |
| 32 net::URLFetcherDelegate* d); | 32 net::URLFetcherDelegate* d); |
| 33 virtual ~ExpectCanceledFetcher(); | 33 ~ExpectCanceledFetcher() override; |
| 34 | 34 |
| 35 virtual void Start() override; | 35 void Start() override; |
| 36 | 36 |
| 37 void CompleteFetch(); | 37 void CompleteFetch(); |
| 38 | 38 |
| 39 private: | 39 private: |
| 40 base::WeakPtrFactory<ExpectCanceledFetcher> weak_factory_; | 40 base::WeakPtrFactory<ExpectCanceledFetcher> weak_factory_; |
| 41 DISALLOW_COPY_AND_ASSIGN(ExpectCanceledFetcher); | 41 DISALLOW_COPY_AND_ASSIGN(ExpectCanceledFetcher); |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 class GotCanceledFetcher : public net::TestURLFetcher { | 44 class GotCanceledFetcher : public net::TestURLFetcher { |
| 45 public: | 45 public: |
| 46 GotCanceledFetcher(bool success, | 46 GotCanceledFetcher(bool success, |
| 47 const GURL& url, | 47 const GURL& url, |
| 48 const std::string& results, | 48 const std::string& results, |
| 49 net::URLFetcher::RequestType request_type, | 49 net::URLFetcher::RequestType request_type, |
| 50 net::URLFetcherDelegate* d); | 50 net::URLFetcherDelegate* d); |
| 51 virtual ~GotCanceledFetcher(); | 51 ~GotCanceledFetcher() override; |
| 52 | 52 |
| 53 virtual void Start() override; | 53 void Start() override; |
| 54 | 54 |
| 55 private: | 55 private: |
| 56 DISALLOW_COPY_AND_ASSIGN(GotCanceledFetcher); | 56 DISALLOW_COPY_AND_ASSIGN(GotCanceledFetcher); |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 class SuccessFetcher : public net::TestURLFetcher { | 59 class SuccessFetcher : public net::TestURLFetcher { |
| 60 public: | 60 public: |
| 61 SuccessFetcher(bool success, | 61 SuccessFetcher(bool success, |
| 62 const GURL& url, | 62 const GURL& url, |
| 63 const std::string& results, | 63 const std::string& results, |
| 64 net::URLFetcher::RequestType request_type, | 64 net::URLFetcher::RequestType request_type, |
| 65 net::URLFetcherDelegate* d); | 65 net::URLFetcherDelegate* d); |
| 66 virtual ~SuccessFetcher(); | 66 ~SuccessFetcher() override; |
| 67 | 67 |
| 68 virtual void Start() override; | 68 void Start() override; |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 DISALLOW_COPY_AND_ASSIGN(SuccessFetcher); | 71 DISALLOW_COPY_AND_ASSIGN(SuccessFetcher); |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 class FailFetcher : public net::TestURLFetcher { | 74 class FailFetcher : public net::TestURLFetcher { |
| 75 public: | 75 public: |
| 76 FailFetcher(bool success, | 76 FailFetcher(bool success, |
| 77 const GURL& url, | 77 const GURL& url, |
| 78 const std::string& results, | 78 const std::string& results, |
| 79 net::URLFetcher::RequestType request_type, | 79 net::URLFetcher::RequestType request_type, |
| 80 net::URLFetcherDelegate* d); | 80 net::URLFetcherDelegate* d); |
| 81 virtual ~FailFetcher(); | 81 ~FailFetcher() override; |
| 82 | 82 |
| 83 virtual void Start() override; | 83 void Start() override; |
| 84 | 84 |
| 85 private: | 85 private: |
| 86 DISALLOW_COPY_AND_ASSIGN(FailFetcher); | 86 DISALLOW_COPY_AND_ASSIGN(FailFetcher); |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 class CaptchaFetcher : public net::TestURLFetcher { | 89 class CaptchaFetcher : public net::TestURLFetcher { |
| 90 public: | 90 public: |
| 91 CaptchaFetcher(bool success, | 91 CaptchaFetcher(bool success, |
| 92 const GURL& url, | 92 const GURL& url, |
| 93 const std::string& results, | 93 const std::string& results, |
| 94 net::URLFetcher::RequestType request_type, | 94 net::URLFetcher::RequestType request_type, |
| 95 net::URLFetcherDelegate* d); | 95 net::URLFetcherDelegate* d); |
| 96 virtual ~CaptchaFetcher(); | 96 ~CaptchaFetcher() override; |
| 97 | 97 |
| 98 static std::string GetCaptchaToken(); | 98 static std::string GetCaptchaToken(); |
| 99 static std::string GetCaptchaUrl(); | 99 static std::string GetCaptchaUrl(); |
| 100 static std::string GetUnlockUrl(); | 100 static std::string GetUnlockUrl(); |
| 101 | 101 |
| 102 virtual void Start() override; | 102 void Start() override; |
| 103 | 103 |
| 104 private: | 104 private: |
| 105 static const char kCaptchaToken[]; | 105 static const char kCaptchaToken[]; |
| 106 static const char kCaptchaUrlBase[]; | 106 static const char kCaptchaUrlBase[]; |
| 107 static const char kCaptchaUrlFragment[]; | 107 static const char kCaptchaUrlFragment[]; |
| 108 static const char kUnlockUrl[]; | 108 static const char kUnlockUrl[]; |
| 109 DISALLOW_COPY_AND_ASSIGN(CaptchaFetcher); | 109 DISALLOW_COPY_AND_ASSIGN(CaptchaFetcher); |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 class HostedFetcher : public net::TestURLFetcher { | 112 class HostedFetcher : public net::TestURLFetcher { |
| 113 public: | 113 public: |
| 114 HostedFetcher(bool success, | 114 HostedFetcher(bool success, |
| 115 const GURL& url, | 115 const GURL& url, |
| 116 const std::string& results, | 116 const std::string& results, |
| 117 net::URLFetcher::RequestType request_type, | 117 net::URLFetcher::RequestType request_type, |
| 118 net::URLFetcherDelegate* d); | 118 net::URLFetcherDelegate* d); |
| 119 virtual ~HostedFetcher(); | 119 ~HostedFetcher() override; |
| 120 | 120 |
| 121 virtual void Start() override; | 121 void Start() override; |
| 122 | 122 |
| 123 private: | 123 private: |
| 124 DISALLOW_COPY_AND_ASSIGN(HostedFetcher); | 124 DISALLOW_COPY_AND_ASSIGN(HostedFetcher); |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 } // namespace chromeos | 127 } // namespace chromeos |
| 128 | 128 |
| 129 #endif // CHROMEOS_LOGIN_AUTH_MOCK_URL_FETCHERS_H_ | 129 #endif // CHROMEOS_LOGIN_AUTH_MOCK_URL_FETCHERS_H_ |
| OLD | NEW |