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_signin_manager.h" | 14 #include "chrome/browser/services/gcm/fake_signin_manager.h" |
15 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 15 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
16 #include "chrome/browser/signin/signin_manager_factory.h" | 16 #include "chrome/browser/signin/signin_manager_factory.h" |
17 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
| 18 #if defined(OS_CHROMEOS) |
| 19 #include "chromeos/dbus/dbus_thread_manager.h" |
| 20 #endif |
18 #include "components/gcm_driver/fake_gcm_app_handler.h" | 21 #include "components/gcm_driver/fake_gcm_app_handler.h" |
19 #include "components/gcm_driver/fake_gcm_client.h" | 22 #include "components/gcm_driver/fake_gcm_client.h" |
20 #include "components/gcm_driver/fake_gcm_client_factory.h" | 23 #include "components/gcm_driver/fake_gcm_client_factory.h" |
21 #include "components/gcm_driver/gcm_client.h" | 24 #include "components/gcm_driver/gcm_client.h" |
22 #include "components/gcm_driver/gcm_client_factory.h" | 25 #include "components/gcm_driver/gcm_client_factory.h" |
23 #include "components/gcm_driver/gcm_driver.h" | 26 #include "components/gcm_driver/gcm_driver.h" |
24 #include "components/pref_registry/pref_registry_syncable.h" | 27 #include "components/pref_registry/pref_registry_syncable.h" |
25 #include "content/public/browser/browser_context.h" | 28 #include "content/public/browser/browser_context.h" |
26 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
27 #include "content/public/test/test_browser_thread_bundle.h" | 30 #include "content/public/test/test_browser_thread_bundle.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 112 |
110 GCMProfileServiceTest::~GCMProfileServiceTest() { | 113 GCMProfileServiceTest::~GCMProfileServiceTest() { |
111 } | 114 } |
112 | 115 |
113 FakeGCMClient* GCMProfileServiceTest::GetGCMClient() const { | 116 FakeGCMClient* GCMProfileServiceTest::GetGCMClient() const { |
114 return static_cast<FakeGCMClient*>( | 117 return static_cast<FakeGCMClient*>( |
115 gcm_profile_service_->driver()->GetGCMClientForTesting()); | 118 gcm_profile_service_->driver()->GetGCMClientForTesting()); |
116 } | 119 } |
117 | 120 |
118 void GCMProfileServiceTest::SetUp() { | 121 void GCMProfileServiceTest::SetUp() { |
| 122 #if defined(OS_CHROMEOS) |
| 123 // Create a DBus thread manager setter for its side effect. |
| 124 // Ignore the return value. |
| 125 chromeos::DBusThreadManager::GetSetterForTesting(); |
| 126 #endif |
119 TestingProfile::Builder builder; | 127 TestingProfile::Builder builder; |
120 builder.AddTestingFactory(SigninManagerFactory::GetInstance(), | 128 builder.AddTestingFactory(SigninManagerFactory::GetInstance(), |
121 FakeSigninManager::Build); | 129 FakeSigninManager::Build); |
122 profile_ = builder.Build(); | 130 profile_ = builder.Build(); |
123 } | 131 } |
124 | 132 |
125 void GCMProfileServiceTest::TearDown() { | 133 void GCMProfileServiceTest::TearDown() { |
126 gcm_profile_service_->driver()->RemoveAppHandler(kTestAppID); | 134 gcm_profile_service_->driver()->RemoveAppHandler(kTestAppID); |
127 } | 135 } |
128 | 136 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 GCMClient::OutgoingMessage message; | 270 GCMClient::OutgoingMessage message; |
263 message.id = "1"; | 271 message.id = "1"; |
264 message.data["key1"] = "value1"; | 272 message.data["key1"] = "value1"; |
265 SendAndWaitForCompletion( message); | 273 SendAndWaitForCompletion( message); |
266 | 274 |
267 EXPECT_EQ(message.id, send_message_id()); | 275 EXPECT_EQ(message.id, send_message_id()); |
268 EXPECT_EQ(GCMClient::SUCCESS, send_result()); | 276 EXPECT_EQ(GCMClient::SUCCESS, send_result()); |
269 } | 277 } |
270 | 278 |
271 } // namespace gcm | 279 } // namespace gcm |
OLD | NEW |