| 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 "chrome/browser/services/gcm/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/fake_gcm_client.h" | 14 #include "chrome/browser/services/gcm/fake_gcm_client.h" |
| 15 #include "chrome/browser/services/gcm/fake_gcm_client_factory.h" | 15 #include "chrome/browser/services/gcm/fake_gcm_client_factory.h" |
| 16 #include "chrome/browser/services/gcm/fake_signin_manager.h" | 16 #include "chrome/browser/services/gcm/fake_signin_manager.h" |
| 17 #include "chrome/browser/services/gcm/gcm_driver.h" | 17 #include "chrome/browser/services/gcm/gcm_driver.h" |
| 18 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 18 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
| 19 #include "chrome/browser/signin/signin_manager_factory.h" | 19 #include "chrome/browser/signin/signin_manager_factory.h" |
| 20 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
| 21 #include "components/gcm_driver/gcm_client_factory.h" | 21 #include "components/gcm_driver/gcm_client_factory.h" |
| 22 #include "components/pref_registry/pref_registry_syncable.h" | 22 #include "components/pref_registry/pref_registry_syncable.h" |
| 23 #include "content/public/browser/browser_context.h" | 23 #include "content/public/browser/browser_context.h" |
| 24 #include "content/public/browser/browser_thread.h" |
| 24 #include "content/public/test/test_browser_thread_bundle.h" | 25 #include "content/public/test/test_browser_thread_bundle.h" |
| 25 #include "google_apis/gcm/gcm_client.h" | 26 #include "google_apis/gcm/gcm_client.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 27 | 28 |
| 28 namespace gcm { | 29 namespace gcm { |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| 32 const char kTestAccountID[] = "user@example.com"; | 33 const char kTestAccountID[] = "user@example.com"; |
| 33 const char kTestAppID[] = "TestApp"; | 34 const char kTestAppID[] = "TestApp"; |
| 34 const char kUserID[] = "user"; | 35 const char kUserID[] = "user"; |
| 35 | 36 |
| 36 KeyedService* BuildGCMProfileService(content::BrowserContext* context) { | 37 KeyedService* BuildGCMProfileService(content::BrowserContext* context) { |
| 37 return new GCMProfileService( | 38 return new GCMProfileService( |
| 38 Profile::FromBrowserContext(context), | 39 Profile::FromBrowserContext(context), |
| 39 scoped_ptr<GCMClientFactory>( | 40 scoped_ptr<GCMClientFactory>(new FakeGCMClientFactory( |
| 40 new FakeGCMClientFactory(FakeGCMClient::NO_DELAY_START))); | 41 FakeGCMClient::NO_DELAY_START, |
| 42 content::BrowserThread::GetMessageLoopProxyForThread( |
| 43 content::BrowserThread::UI), |
| 44 content::BrowserThread::GetMessageLoopProxyForThread( |
| 45 content::BrowserThread::UI)))); |
| 41 } | 46 } |
| 42 | 47 |
| 43 } // namespace | 48 } // namespace |
| 44 | 49 |
| 45 class GCMProfileServiceTest : public testing::Test { | 50 class GCMProfileServiceTest : public testing::Test { |
| 46 protected: | 51 protected: |
| 47 GCMProfileServiceTest(); | 52 GCMProfileServiceTest(); |
| 48 virtual ~GCMProfileServiceTest(); | 53 virtual ~GCMProfileServiceTest(); |
| 49 | 54 |
| 50 // testing::Test: | 55 // testing::Test: |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 GCMClient::OutgoingMessage message; | 202 GCMClient::OutgoingMessage message; |
| 198 message.id = "1"; | 203 message.id = "1"; |
| 199 message.data["key1"] = "value1"; | 204 message.data["key1"] = "value1"; |
| 200 SendAndWaitForCompletion( message); | 205 SendAndWaitForCompletion( message); |
| 201 | 206 |
| 202 EXPECT_EQ(message.id, send_message_id()); | 207 EXPECT_EQ(message.id, send_message_id()); |
| 203 EXPECT_EQ(GCMClient::SUCCESS, send_result()); | 208 EXPECT_EQ(GCMClient::SUCCESS, send_result()); |
| 204 } | 209 } |
| 205 | 210 |
| 206 } // namespace gcm | 211 } // namespace gcm |
| OLD | NEW |