OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef REMOTING_TEST_MOCK_ACCESS_TOKEN_FETCHER_H_ | |
6 #define REMOTING_TEST_MOCK_ACCESS_TOKEN_FETCHER_H_ | |
7 | |
8 #include "remoting/test/access_token_fetcher.h" | |
9 | |
10 #include "testing/gmock/include/gmock/gmock.h" | |
11 #include "testing/gtest/include/gtest/gtest.h" | |
12 | |
13 namespace remoting { | |
14 namespace test { | |
15 | |
16 const char kMockAccessTokenFetcherRefreshTokenValue[] = "mock_refresh_token"; | |
17 const char kMockAccessTokenFetcherAccessTokenValue[] = "mock_access_token"; | |
18 | |
19 // This class is used for testing classes which rely on the AccessTokenFetcher | |
20 // and want to simulate success and failure scenarios without using the actual | |
21 // class and network connection. | |
Wez
2015/02/13 03:01:54
See elsewhere re comment style.
joedow
2015/02/14 02:31:29
Done.
| |
22 class MockAccessTokenFetcher : public AccessTokenFetcher { | |
23 public: | |
24 MockAccessTokenFetcher(); | |
25 ~MockAccessTokenFetcher() override; | |
26 | |
27 MOCK_METHOD2(GetAccessTokenFromAuthCode, | |
28 void(const std::string& auth_code, | |
29 const AccessTokenCallback& callback)); | |
30 | |
31 MOCK_METHOD2(GetAccessTokenFromRefreshToken, | |
32 void(const std::string& refresh_token, | |
33 const AccessTokenCallback& callback)); | |
34 | |
35 void DelegateToCompleteCallbacks() { | |
Wez
2015/02/13 03:01:54
See elsewhere re naming of these methods!
joedow
2015/02/14 02:31:29
Done.
| |
36 ON_CALL(*this, GetAccessTokenFromAuthCode(testing::_, testing::_)) | |
37 .WillByDefault(testing::Invoke(this, | |
38 &MockAccessTokenFetcher::CompleteAuthCodeCallback)); | |
39 ON_CALL(*this, GetAccessTokenFromRefreshToken(testing::_, testing::_)) | |
40 .WillByDefault(testing::Invoke(this, | |
41 &MockAccessTokenFetcher::CompleteRefreshTokenCallback)); | |
42 } | |
43 | |
44 void DelegateToFailureCallbacks() { | |
45 ON_CALL(*this, GetAccessTokenFromAuthCode(testing::_, testing::_)) | |
46 .WillByDefault(testing::Invoke(this, | |
47 &MockAccessTokenFetcher::CompleteAuthCodeFailedCallback)); | |
48 ON_CALL(*this, GetAccessTokenFromRefreshToken(testing::_, testing::_)) | |
49 .WillByDefault(testing::Invoke(this, | |
50 &MockAccessTokenFetcher::CompleteRefreshTokenFailedCallback)); | |
51 } | |
52 | |
53 void DelegateToRefreshFailureCallback() { | |
54 ON_CALL(*this, GetAccessTokenFromAuthCode(testing::_, testing::_)) | |
55 .WillByDefault(testing::Invoke(this, | |
56 &MockAccessTokenFetcher::CompleteAuthCodeCallback)); | |
57 ON_CALL(*this, GetAccessTokenFromRefreshToken(testing::_, testing::_)) | |
58 .WillByDefault(testing::Invoke(this, | |
59 &MockAccessTokenFetcher::CompleteRefreshTokenFailedCallback)); | |
60 } | |
61 | |
62 void CompleteAuthCodeCallback( | |
63 const std::string& auth_code, | |
64 const AccessTokenCallback& callback); | |
65 | |
66 void CompleteAuthCodeFailedCallback( | |
67 const std::string& auth_code, | |
68 const AccessTokenCallback& callback); | |
69 | |
70 void CompleteRefreshTokenCallback( | |
71 const std::string& refresh_token, | |
72 const AccessTokenCallback& callback); | |
73 | |
74 void CompleteRefreshTokenFailedCallback( | |
75 const std::string& refresh_token, | |
76 const AccessTokenCallback& callback); | |
77 }; | |
78 | |
79 } // namespace test | |
80 } // namespace remoting | |
81 | |
82 #endif // REMOTING_TEST_MOCK_ACCESS_TOKEN_FETCHER_H_ | |
OLD | NEW |