Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Unified Diff: remoting/test/fake_access_token_fetcher.h

Issue 880273006: Adding the AccessTokenFetcher and Environment class to the app remoting test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing last round of CR feedback Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..b16f83f02a293a7c3dce7c9fa66f12ce10164826
--- /dev/null
+++ b/remoting/test/fake_access_token_fetcher.h
@@ -0,0 +1,56 @@
+// 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;
+
+ // AccessTokenFetcher interface.
+ void GetAccessTokenFromAuthCode(
+ const std::string& auth_code,
+ const AccessTokenCallback& callback) override;
+
+ void GetAccessTokenFromRefreshToken(
+ const std::string& refresh_token,
+ const AccessTokenCallback& callback) override;
+
+ void SetAuthCodeError(bool fail) {
Wez 2015/02/23 20:17:15 set_fail_access_token_from_auth_code(), to match t
joedow 2015/02/24 02:01:24 Done.
Wez 2015/02/24 03:10:19 No, I literally meant set_fail_access_token_from_a
joedow1 2015/02/24 05:17:40 Done.
+ fail_access_token_from_auth_code_ = fail;
+ }
+
+ void SetRefreshTokenError(bool fail) {
Wez 2015/02/23 20:17:15 See above.
joedow 2015/02/24 02:01:24 Done.
+ fail_access_token_from_refresh_token_ = fail;
+ }
+
+ private:
+ // True if GetAccessTokenFromAuthCode() should fail.
+ bool fail_access_token_from_auth_code_;
+
+ // True if GetAccessTokenFromRefreshToken() should fail.
+ bool fail_access_token_from_refresh_token_;
+
+ DISALLOW_COPY_AND_ASSIGN(FakeAccessTokenFetcher);
+};
+
+} // namespace test
+} // namespace remoting
+
+#endif // REMOTING_TEST_FAKE_ACCESS_TOKEN_FETCHER_H_

Powered by Google App Engine
This is Rietveld 408576698