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 // Used for testing classes which rely on the AccessTokenFetcher and want to | |
17 // simulate success and failure scenarios without using the actual class and | |
18 // network connection. | |
19 class MockAccessTokenFetcher : public AccessTokenFetcher { | |
20 public: | |
21 MockAccessTokenFetcher(); | |
22 ~MockAccessTokenFetcher() override; | |
23 | |
24 MOCK_METHOD2(GetAccessTokenFromAuthCode, | |
25 void(const std::string& auth_code, | |
26 const AccessTokenCallback& callback)); | |
27 | |
28 MOCK_METHOD2(GetAccessTokenFromRefreshToken, | |
29 void(const std::string& refresh_token, | |
30 const AccessTokenCallback& callback)); | |
31 | |
32 // Stores a fake object and wires up the mock methods to call through to the | |
33 // appropriate method on the fake object. | |
34 void SetFakeAccessTokenFetcher(scoped_ptr<AccessTokenFetcher> fake); | |
Wez
2015/02/23 20:17:15
This accepts any AccessTokenFetcher, so you should
joedow
2015/02/24 02:01:24
Done.
| |
35 | |
36 private: | |
37 // Delegates the default actions of the methods to a fake object. | |
38 // This must be called *before* the custom ON_CALL() statements. | |
Wez
2015/02/23 20:17:15
This comment doesn't make sense - the method is pr
joedow
2015/02/24 02:01:24
Done.
| |
39 void DelegateMethodCallsToFake(); | |
40 | |
41 scoped_ptr<AccessTokenFetcher> fake_; | |
42 | |
43 DISALLOW_COPY_AND_ASSIGN(MockAccessTokenFetcher); | |
44 }; | |
45 | |
46 } // namespace test | |
47 } // namespace remoting | |
48 | |
49 #endif // REMOTING_TEST_MOCK_ACCESS_TOKEN_FETCHER_H_ | |
OLD | NEW |