OLD | NEW |
| (Empty) |
1 // Copyright 2014 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 CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_TEST_HELPER_H_ | |
6 #define CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_TEST_HELPER_H_ | |
7 | |
8 #include <string> | |
9 #include "base/macros.h" | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "chrome/browser/services/gcm/gcm_client_factory.h" | |
12 #include "chrome/browser/services/gcm/gcm_client_mock.h" | |
13 #include "components/signin/core/browser/signin_manager.h" | |
14 | |
15 class KeyedService; | |
16 class Profile; | |
17 namespace base { | |
18 class RunLoop; | |
19 } | |
20 namespace content { | |
21 class BrowserContext; | |
22 } | |
23 | |
24 namespace gcm { | |
25 | |
26 // Helper class for asynchronous waiting. | |
27 class Waiter { | |
28 public: | |
29 Waiter(); | |
30 ~Waiter(); | |
31 | |
32 // Waits until the asynchrnous operation finishes. | |
33 void WaitUntilCompleted(); | |
34 | |
35 // Signals that the asynchronous operation finishes. | |
36 void SignalCompleted(); | |
37 | |
38 // Runs until UI loop becomes idle. | |
39 void PumpUILoop(); | |
40 | |
41 // Runs until IO loop becomes idle. | |
42 void PumpIOLoop(); | |
43 | |
44 private: | |
45 void PumpIOLoopCompleted(); | |
46 void OnIOLoopPump(); | |
47 void OnIOLoopPumpCompleted(); | |
48 | |
49 scoped_ptr<base::RunLoop> run_loop_; | |
50 | |
51 DISALLOW_COPY_AND_ASSIGN(Waiter); | |
52 }; | |
53 | |
54 #if defined(OS_CHROMEOS) | |
55 class FakeSigninManager : public SigninManagerBase { | |
56 #else | |
57 class FakeSigninManager : public SigninManager { | |
58 #endif | |
59 public: | |
60 static KeyedService* Build(content::BrowserContext* context); | |
61 | |
62 explicit FakeSigninManager(Profile* profile); | |
63 virtual ~FakeSigninManager(); | |
64 | |
65 void SignIn(const std::string& username); | |
66 #if defined(OS_CHROMEOS) | |
67 void SignOut(); | |
68 #else | |
69 virtual void SignOut() OVERRIDE; | |
70 #endif | |
71 | |
72 private: | |
73 Profile* profile_; | |
74 | |
75 DISALLOW_COPY_AND_ASSIGN(FakeSigninManager); | |
76 }; | |
77 | |
78 class FakeGCMClientFactory : public GCMClientFactory { | |
79 public: | |
80 explicit FakeGCMClientFactory( | |
81 GCMClientMock::LoadingDelay gcm_client_loading_delay); | |
82 virtual ~FakeGCMClientFactory(); | |
83 | |
84 virtual scoped_ptr<GCMClient> BuildInstance() OVERRIDE; | |
85 | |
86 private: | |
87 GCMClientMock::LoadingDelay gcm_client_loading_delay_; | |
88 | |
89 DISALLOW_COPY_AND_ASSIGN(FakeGCMClientFactory); | |
90 }; | |
91 | |
92 } // namespace gcm | |
93 | |
94 #endif // CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_TEST_HELPER_H_ | |
OLD | NEW |