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

Unified Diff: remoting/test/mock_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: Updating AccessTokenFetcher Unittests to use the FakeURLFetcherFactory 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/mock_access_token_fetcher.h
diff --git a/remoting/test/mock_access_token_fetcher.h b/remoting/test/mock_access_token_fetcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..0d45431a0c7e26c95bf367bf7a6e1e8e11059aa6
--- /dev/null
+++ b/remoting/test/mock_access_token_fetcher.h
@@ -0,0 +1,49 @@
+// 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_MOCK_ACCESS_TOKEN_FETCHER_H_
+#define REMOTING_TEST_MOCK_ACCESS_TOKEN_FETCHER_H_
+
+#include "remoting/test/access_token_fetcher.h"
+
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace remoting {
+namespace test {
+
+// 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 MockAccessTokenFetcher : public AccessTokenFetcher {
+ public:
+ MockAccessTokenFetcher();
+ ~MockAccessTokenFetcher() override;
+
+ MOCK_METHOD2(GetAccessTokenFromAuthCode,
+ void(const std::string& auth_code,
+ const AccessTokenCallback& callback));
+
+ MOCK_METHOD2(GetAccessTokenFromRefreshToken,
+ void(const std::string& refresh_token,
+ const AccessTokenCallback& callback));
+
+ // Stores a fake object and wires up the mock methods to call through to the
+ // appropriate method on the fake object.
Wez 2015/02/19 22:00:24 So the idea is that by default the supplied fake w
joedow 2015/02/20 02:58:36 It depends on the class that uses it, if the class
Wez 2015/02/23 20:17:14 I understand breaking the two classes apart; it's
+ void SetFakeAccessTokenFetcher(scoped_ptr<AccessTokenFetcher> fake);
+
+ private:
+ // Delegates the default actions of the methods to a fake object.
+ // This must be called *before* the custom ON_CALL() statements.
+ void DelegateMethodCallsToFake();
+
+ scoped_ptr<AccessTokenFetcher> fake_;
+
+ DISALLOW_COPY_AND_ASSIGN(MockAccessTokenFetcher);
+};
+
+} // namespace test
+} // namespace remoting
+
+#endif // REMOTING_TEST_MOCK_ACCESS_TOKEN_FETCHER_H_

Powered by Google App Engine
This is Rietveld 408576698