OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 REMOTING_TEST_FAKE_ACCESS_TOKEN_FETCHER_H_ | 5 #ifndef REMOTING_TEST_FAKE_ACCESS_TOKEN_FETCHER_H_ |
6 #define REMOTING_TEST_FAKE_ACCESS_TOKEN_FETCHER_H_ | 6 #define REMOTING_TEST_FAKE_ACCESS_TOKEN_FETCHER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "remoting/test/access_token_fetcher.h" | 10 #include "remoting/test/access_token_fetcher.h" |
11 | 11 |
12 namespace remoting { | 12 namespace remoting { |
13 namespace test { | 13 namespace test { |
14 | 14 |
15 const char kFakeAccessTokenFetcherRefreshTokenValue[] = "fake_refresh_token"; | 15 const char kFakeAccessTokenFetcherRefreshTokenValue[] = "fake_refresh_token"; |
16 const char kFakeAccessTokenFetcherAccessTokenValue[] = "fake_access_token"; | 16 const char kFakeAccessTokenFetcherAccessTokenValue[] = "fake_access_token"; |
17 | 17 |
18 // Used for testing classes which rely on the AccessTokenFetcher and want to | 18 // Used for testing classes which rely on the AccessTokenFetcher and want to |
19 // simulate success and failure scenarios without using the actual class and | 19 // simulate success and failure scenarios without using the actual class and |
20 // network connection. | 20 // network connection. |
21 class FakeAccessTokenFetcher : public AccessTokenFetcher { | 21 class FakeAccessTokenFetcher : public AccessTokenFetcher { |
22 public: | 22 public: |
23 FakeAccessTokenFetcher(); | 23 FakeAccessTokenFetcher(); |
24 ~FakeAccessTokenFetcher() override; | 24 ~FakeAccessTokenFetcher() override; |
25 | 25 |
26 // AccessTokenFetcher interface. | 26 // AccessTokenFetcher interface. |
27 void GetAccessTokenFromAuthCode( | 27 void GetAccessTokenFromAuthCode(const std::string& auth_code, |
28 const std::string& auth_code, | 28 const AccessTokenCallback& callback) override; |
29 const AccessTokenCallback& callback) override; | |
30 void GetAccessTokenFromRefreshToken( | 29 void GetAccessTokenFromRefreshToken( |
31 const std::string& refresh_token, | 30 const std::string& refresh_token, |
32 const AccessTokenCallback& callback) override; | 31 const AccessTokenCallback& callback) override; |
33 | 32 |
34 void set_fail_access_token_from_auth_code(bool fail) { | 33 void set_fail_access_token_from_auth_code(bool fail) { |
35 fail_access_token_from_auth_code_ = fail; | 34 fail_access_token_from_auth_code_ = fail; |
36 } | 35 } |
37 | 36 |
38 void set_fail_access_token_from_refresh_token(bool fail) { | 37 void set_fail_access_token_from_refresh_token(bool fail) { |
39 fail_access_token_from_refresh_token_ = fail; | 38 fail_access_token_from_refresh_token_ = fail; |
40 } | 39 } |
41 | 40 |
42 private: | 41 private: |
43 // True if GetAccessTokenFromAuthCode() should fail. | 42 // True if GetAccessTokenFromAuthCode() should fail. |
44 bool fail_access_token_from_auth_code_; | 43 bool fail_access_token_from_auth_code_; |
45 | 44 |
46 // True if GetAccessTokenFromRefreshToken() should fail. | 45 // True if GetAccessTokenFromRefreshToken() should fail. |
47 bool fail_access_token_from_refresh_token_; | 46 bool fail_access_token_from_refresh_token_; |
48 | 47 |
49 DISALLOW_COPY_AND_ASSIGN(FakeAccessTokenFetcher); | 48 DISALLOW_COPY_AND_ASSIGN(FakeAccessTokenFetcher); |
50 }; | 49 }; |
51 | 50 |
52 } // namespace test | 51 } // namespace test |
53 } // namespace remoting | 52 } // namespace remoting |
54 | 53 |
55 #endif // REMOTING_TEST_FAKE_ACCESS_TOKEN_FETCHER_H_ | 54 #endif // REMOTING_TEST_FAKE_ACCESS_TOKEN_FETCHER_H_ |
OLD | NEW |