| 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(), SigninManagerFactory::GetForProfile(profile), |
| 55 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
| 56 LoginUIServiceFactory::GetShowLoginPopupCallbackForProfile(profile), |
| 57 scoped_ptr<gcm::GCMClientFactory>(new gcm::FakeGCMClientFactory( |
| 43 content::BrowserThread::GetMessageLoopProxyForThread( | 58 content::BrowserThread::GetMessageLoopProxyForThread( |
| 44 content::BrowserThread::UI), | 59 content::BrowserThread::UI), |
| 45 content::BrowserThread::GetMessageLoopProxyForThread( | 60 content::BrowserThread::GetMessageLoopProxyForThread( |
| 46 content::BrowserThread::IO))))); | 61 content::BrowserThread::IO))), |
| 62 content::BrowserThread::GetMessageLoopProxyForThread( |
| 63 content::BrowserThread::UI), |
| 64 content::BrowserThread::GetMessageLoopProxyForThread( |
| 65 content::BrowserThread::IO), |
| 66 blocking_task_runner)); |
| 47 } | 67 } |
| 48 | 68 |
| 49 } // namespace | 69 } // namespace |
| 50 | 70 |
| 51 class GCMProfileServiceTest : public testing::Test { | 71 class GCMProfileServiceTest : public testing::Test { |
| 52 protected: | 72 protected: |
| 53 GCMProfileServiceTest(); | 73 GCMProfileServiceTest(); |
| 54 ~GCMProfileServiceTest() override; | 74 ~GCMProfileServiceTest() override; |
| 55 | 75 |
| 56 // testing::Test: | 76 // testing::Test: |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 OutgoingMessage message; | 238 OutgoingMessage message; |
| 219 message.id = "1"; | 239 message.id = "1"; |
| 220 message.data["key1"] = "value1"; | 240 message.data["key1"] = "value1"; |
| 221 SendAndWaitForCompletion(message); | 241 SendAndWaitForCompletion(message); |
| 222 | 242 |
| 223 EXPECT_EQ(message.id, send_message_id()); | 243 EXPECT_EQ(message.id, send_message_id()); |
| 224 EXPECT_EQ(GCMClient::SUCCESS, send_result()); | 244 EXPECT_EQ(GCMClient::SUCCESS, send_result()); |
| 225 } | 245 } |
| 226 | 246 |
| 227 } // namespace gcm | 247 } // namespace gcm |
| OLD | NEW |