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