Index: remoting/test/fake_access_token_fetcher.h |
diff --git a/remoting/test/fake_access_token_fetcher.h b/remoting/test/fake_access_token_fetcher.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..842db7ab9af57e3d0fec7e74675a2487dbcfbcf2 |
--- /dev/null |
+++ b/remoting/test/fake_access_token_fetcher.h |
@@ -0,0 +1,55 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef REMOTING_TEST_FAKE_ACCESS_TOKEN_FETCHER_H_ |
+#define REMOTING_TEST_FAKE_ACCESS_TOKEN_FETCHER_H_ |
+ |
+#include "remoting/test/access_token_fetcher.h" |
+ |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace remoting { |
+namespace test { |
+ |
+const char kFakeAccessTokenFetcherRefreshTokenValue[] = "fake_refresh_token"; |
+const char kFakeAccessTokenFetcherAccessTokenValue[] = "fake_access_token"; |
+ |
+// Used for testing classes which rely on the AccessTokenFetcher and want to |
+// simulate success and failure scenarios without using the actual class and |
+// network connection. |
+class FakeAccessTokenFetcher : public AccessTokenFetcher { |
+ public: |
+ FakeAccessTokenFetcher(); |
+ ~FakeAccessTokenFetcher() override; |
+ |
+ void GetAccessTokenFromAuthCode( |
Wez
2015/02/19 22:00:24
nit: Comment "// AccessTokenFetcher interface." be
joedow
2015/02/20 02:58:36
Done.
|
+ const std::string& auth_code, |
+ const AccessTokenCallback& callback) override; |
+ |
+ void GetAccessTokenFromRefreshToken( |
+ const std::string& refresh_token, |
+ const AccessTokenCallback& callback) override; |
+ |
+ // Flag passed in will cause the GetAccessTokenFromAuthCode callback to return |
+ // an error until the flag is reset by the caller. |
Wez
2015/02/19 22:00:24
Suggest changing this to an in-line setter set_fai
joedow
2015/02/20 02:58:36
Done.
|
+ void SetAuthCodeError(bool simulate_auth_code_error); |
+ |
+ // Flag passed in will cause the GetAccessTokenFromAuthCode callback to return |
+ // an error until the flag is reset by the caller. |
+ void SetRefreshTokenError(bool simulate_refresh_token_error); |
+ |
+ private: |
+ // Causes GetAccessTokenFromAuthCode() to simulate an error. |
Wez
2015/02/19 22:00:24
nit: This member doesn't cause anything; you might
joedow
2015/02/20 02:58:36
Done.
|
+ bool simulate_auth_code_error_; |
+ |
+ // Causes GetAccessTokenFromRefreshToken() to simulate an error. |
+ bool simulate_refresh_token_error_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(FakeAccessTokenFetcher); |
+}; |
+ |
+} // namespace test |
+} // namespace remoting |
+ |
+#endif // REMOTING_TEST_FAKE_ACCESS_TOKEN_FETCHER_H_ |