OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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 CONTENT_BROWSER_GEOLOCATION_FAKE_ACCESS_TOKEN_STORE_H_ | |
6 #define CONTENT_BROWSER_GEOLOCATION_FAKE_ACCESS_TOKEN_STORE_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "base/memory/ref_counted.h" | |
10 #include "base/single_thread_task_runner.h" | |
11 #include "content/public/browser/access_token_store.h" | |
12 #include "testing/gmock/include/gmock/gmock.h" | |
13 #include "testing/gtest/include/gtest/gtest.h" | |
14 | |
15 namespace content { | |
16 | |
17 // A fake (non-persisted) access token store instance useful for testing. | |
18 class FakeAccessTokenStore : public AccessTokenStore { | |
19 public: | |
20 FakeAccessTokenStore(); | |
21 | |
22 void NotifyDelegateTokensLoaded(); | |
23 | |
24 // AccessTokenStore | |
25 MOCK_METHOD1(LoadAccessTokens, | |
26 void(const LoadAccessTokensCallback& callback)); | |
27 MOCK_METHOD2(SaveAccessToken, | |
28 void(const GURL& server_url, | |
29 const base::string16& access_token)); | |
30 | |
31 void DefaultLoadAccessTokens(const LoadAccessTokensCallback& callback); | |
32 | |
33 void DefaultSaveAccessToken(const GURL& server_url, | |
34 const base::string16& access_token); | |
35 | |
36 AccessTokenMap access_token_map_; | |
37 LoadAccessTokensCallback callback_; | |
38 | |
39 protected: | |
40 // Protected instead of private so we can have NiceMocks. | |
41 virtual ~FakeAccessTokenStore(); | |
42 | |
43 private: | |
44 // In some tests, NotifyDelegateTokensLoaded() is called on a thread | |
45 // other than the originating thread, in which case we must post | |
46 // back to it. | |
47 scoped_refptr<base::SingleThreadTaskRunner> originating_task_runner_; | |
48 | |
49 DISALLOW_COPY_AND_ASSIGN(FakeAccessTokenStore); | |
50 }; | |
51 | |
52 } // namespace content | |
53 | |
54 #endif // CONTENT_BROWSER_GEOLOCATION_FAKE_ACCESS_TOKEN_STORE_H_ | |
OLD | NEW |