OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/services/gcm/gcm_profile_service.h" | 5 #include "components/gcm_driver/gcm_profile_service.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 14 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
| 15 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 16 #include "chrome/browser/signin/signin_manager_factory.h" |
| 17 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
| 18 #include "chrome/common/channel_info.h" |
15 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
16 #if defined(OS_CHROMEOS) | 20 #if defined(OS_CHROMEOS) |
17 #include "chromeos/dbus/dbus_thread_manager.h" | 21 #include "chromeos/dbus/dbus_thread_manager.h" |
18 #endif | 22 #endif |
19 #include "components/gcm_driver/fake_gcm_app_handler.h" | 23 #include "components/gcm_driver/fake_gcm_app_handler.h" |
20 #include "components/gcm_driver/fake_gcm_client.h" | 24 #include "components/gcm_driver/fake_gcm_client.h" |
21 #include "components/gcm_driver/fake_gcm_client_factory.h" | 25 #include "components/gcm_driver/fake_gcm_client_factory.h" |
22 #include "components/gcm_driver/gcm_client.h" | 26 #include "components/gcm_driver/gcm_client.h" |
23 #include "components/gcm_driver/gcm_client_factory.h" | 27 #include "components/gcm_driver/gcm_client_factory.h" |
24 #include "components/gcm_driver/gcm_driver.h" | 28 #include "components/gcm_driver/gcm_driver.h" |
25 #include "components/pref_registry/pref_registry_syncable.h" | 29 #include "components/pref_registry/pref_registry_syncable.h" |
| 30 #include "components/signin/core/browser/signin_manager.h" |
26 #include "content/public/browser/browser_context.h" | 31 #include "content/public/browser/browser_context.h" |
27 #include "content/public/browser/browser_thread.h" | 32 #include "content/public/browser/browser_thread.h" |
28 #include "content/public/test/test_browser_thread_bundle.h" | 33 #include "content/public/test/test_browser_thread_bundle.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 34 #include "testing/gtest/include/gtest/gtest.h" |
30 | 35 |
31 namespace gcm { | 36 namespace gcm { |
32 | 37 |
33 namespace { | 38 namespace { |
34 | 39 |
35 const char kTestAppID[] = "TestApp"; | 40 const char kTestAppID[] = "TestApp"; |
36 const char kUserID[] = "user"; | 41 const char kUserID[] = "user"; |
37 | 42 |
38 scoped_ptr<KeyedService> BuildGCMProfileService( | 43 scoped_ptr<KeyedService> BuildGCMProfileService( |
39 content::BrowserContext* context) { | 44 content::BrowserContext* context) { |
40 return make_scoped_ptr(new GCMProfileService( | 45 Profile* profile = Profile::FromBrowserContext(context); |
41 Profile::FromBrowserContext(context), | 46 base::SequencedWorkerPool* worker_pool = |
42 scoped_ptr<GCMClientFactory>(new FakeGCMClientFactory( | 47 content::BrowserThread::GetBlockingPool(); |
| 48 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner( |
| 49 worker_pool->GetSequencedTaskRunnerWithShutdownBehavior( |
| 50 worker_pool->GetSequenceToken(), |
| 51 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); |
| 52 return make_scoped_ptr(new gcm::GCMProfileService( |
| 53 profile->GetPrefs(), profile->GetPath(), profile->GetRequestContext(), |
| 54 chrome::GetChannel(), |
| 55 scoped_ptr<ProfileIdentityProvider>(new ProfileIdentityProvider( |
| 56 SigninManagerFactory::GetForProfile(profile), |
| 57 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
| 58 LoginUIServiceFactory::GetShowLoginPopupCallbackForProfile(profile))), |
| 59 scoped_ptr<gcm::GCMClientFactory>(new gcm::FakeGCMClientFactory( |
43 content::BrowserThread::GetMessageLoopProxyForThread( | 60 content::BrowserThread::GetMessageLoopProxyForThread( |
44 content::BrowserThread::UI), | 61 content::BrowserThread::UI), |
45 content::BrowserThread::GetMessageLoopProxyForThread( | 62 content::BrowserThread::GetMessageLoopProxyForThread( |
46 content::BrowserThread::IO))))); | 63 content::BrowserThread::IO))), |
| 64 content::BrowserThread::GetMessageLoopProxyForThread( |
| 65 content::BrowserThread::UI), |
| 66 content::BrowserThread::GetMessageLoopProxyForThread( |
| 67 content::BrowserThread::IO), |
| 68 blocking_task_runner)); |
47 } | 69 } |
48 | 70 |
49 } // namespace | 71 } // namespace |
50 | 72 |
51 class GCMProfileServiceTest : public testing::Test { | 73 class GCMProfileServiceTest : public testing::Test { |
52 protected: | 74 protected: |
53 GCMProfileServiceTest(); | 75 GCMProfileServiceTest(); |
54 ~GCMProfileServiceTest() override; | 76 ~GCMProfileServiceTest() override; |
55 | 77 |
56 // testing::Test: | 78 // testing::Test: |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 OutgoingMessage message; | 240 OutgoingMessage message; |
219 message.id = "1"; | 241 message.id = "1"; |
220 message.data["key1"] = "value1"; | 242 message.data["key1"] = "value1"; |
221 SendAndWaitForCompletion(message); | 243 SendAndWaitForCompletion(message); |
222 | 244 |
223 EXPECT_EQ(message.id, send_message_id()); | 245 EXPECT_EQ(message.id, send_message_id()); |
224 EXPECT_EQ(GCMClient::SUCCESS, send_result()); | 246 EXPECT_EQ(GCMClient::SUCCESS, send_result()); |
225 } | 247 } |
226 | 248 |
227 } // namespace gcm | 249 } // namespace gcm |
OLD | NEW |