Chromium Code Reviews| 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..14864821e920aeb06377c2d060a80d10f78fbe85 |
| --- /dev/null |
| +++ b/remoting/test/mock_access_token_fetcher.h |
| @@ -0,0 +1,82 @@ |
| +// 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 { |
| + |
| +const char kMockAccessTokenFetcherRefreshTokenValue[] = "mock_refresh_token"; |
| +const char kMockAccessTokenFetcherAccessTokenValue[] = "mock_access_token"; |
| + |
| +// This class is 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. |
|
Wez
2015/02/13 03:01:54
See elsewhere re comment style.
joedow
2015/02/14 02:31:29
Done.
|
| +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)); |
| + |
| + void DelegateToCompleteCallbacks() { |
|
Wez
2015/02/13 03:01:54
See elsewhere re naming of these methods!
joedow
2015/02/14 02:31:29
Done.
|
| + ON_CALL(*this, GetAccessTokenFromAuthCode(testing::_, testing::_)) |
| + .WillByDefault(testing::Invoke(this, |
| + &MockAccessTokenFetcher::CompleteAuthCodeCallback)); |
| + ON_CALL(*this, GetAccessTokenFromRefreshToken(testing::_, testing::_)) |
| + .WillByDefault(testing::Invoke(this, |
| + &MockAccessTokenFetcher::CompleteRefreshTokenCallback)); |
| + } |
| + |
| + void DelegateToFailureCallbacks() { |
| + ON_CALL(*this, GetAccessTokenFromAuthCode(testing::_, testing::_)) |
| + .WillByDefault(testing::Invoke(this, |
| + &MockAccessTokenFetcher::CompleteAuthCodeFailedCallback)); |
| + ON_CALL(*this, GetAccessTokenFromRefreshToken(testing::_, testing::_)) |
| + .WillByDefault(testing::Invoke(this, |
| + &MockAccessTokenFetcher::CompleteRefreshTokenFailedCallback)); |
| + } |
| + |
| + void DelegateToRefreshFailureCallback() { |
| + ON_CALL(*this, GetAccessTokenFromAuthCode(testing::_, testing::_)) |
| + .WillByDefault(testing::Invoke(this, |
| + &MockAccessTokenFetcher::CompleteAuthCodeCallback)); |
| + ON_CALL(*this, GetAccessTokenFromRefreshToken(testing::_, testing::_)) |
| + .WillByDefault(testing::Invoke(this, |
| + &MockAccessTokenFetcher::CompleteRefreshTokenFailedCallback)); |
| + } |
| + |
| + void CompleteAuthCodeCallback( |
| + const std::string& auth_code, |
| + const AccessTokenCallback& callback); |
| + |
| + void CompleteAuthCodeFailedCallback( |
| + const std::string& auth_code, |
| + const AccessTokenCallback& callback); |
| + |
| + void CompleteRefreshTokenCallback( |
| + const std::string& refresh_token, |
| + const AccessTokenCallback& callback); |
| + |
| + void CompleteRefreshTokenFailedCallback( |
| + const std::string& refresh_token, |
| + const AccessTokenCallback& callback); |
| +}; |
| + |
| +} // namespace test |
| +} // namespace remoting |
| + |
| +#endif // REMOTING_TEST_MOCK_ACCESS_TOKEN_FETCHER_H_ |