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 #include "chromeos/dbus/dbus_thread_manager.h" | |
19 #include "chromeos/dbus/fake_shill_manager_client.h" | |
18 #include "components/gcm_driver/fake_gcm_app_handler.h" | 20 #include "components/gcm_driver/fake_gcm_app_handler.h" |
19 #include "components/gcm_driver/fake_gcm_client.h" | 21 #include "components/gcm_driver/fake_gcm_client.h" |
20 #include "components/gcm_driver/fake_gcm_client_factory.h" | 22 #include "components/gcm_driver/fake_gcm_client_factory.h" |
21 #include "components/gcm_driver/gcm_client.h" | 23 #include "components/gcm_driver/gcm_client.h" |
22 #include "components/gcm_driver/gcm_client_factory.h" | 24 #include "components/gcm_driver/gcm_client_factory.h" |
23 #include "components/gcm_driver/gcm_driver.h" | 25 #include "components/gcm_driver/gcm_driver.h" |
24 #include "components/pref_registry/pref_registry_syncable.h" | 26 #include "components/pref_registry/pref_registry_syncable.h" |
25 #include "content/public/browser/browser_context.h" | 27 #include "content/public/browser/browser_context.h" |
26 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
27 #include "content/public/test/test_browser_thread_bundle.h" | 29 #include "content/public/test/test_browser_thread_bundle.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
113 FakeGCMClient* GCMProfileServiceTest::GetGCMClient() const { | 115 FakeGCMClient* GCMProfileServiceTest::GetGCMClient() const { |
114 return static_cast<FakeGCMClient*>( | 116 return static_cast<FakeGCMClient*>( |
115 gcm_profile_service_->driver()->GetGCMClientForTesting()); | 117 gcm_profile_service_->driver()->GetGCMClientForTesting()); |
116 } | 118 } |
117 | 119 |
118 void GCMProfileServiceTest::SetUp() { | 120 void GCMProfileServiceTest::SetUp() { |
119 TestingProfile::Builder builder; | 121 TestingProfile::Builder builder; |
120 builder.AddTestingFactory(SigninManagerFactory::GetInstance(), | 122 builder.AddTestingFactory(SigninManagerFactory::GetInstance(), |
121 FakeSigninManager::Build); | 123 FakeSigninManager::Build); |
122 profile_ = builder.Build(); | 124 profile_ = builder.Build(); |
125 // Create a DBus thread manager setter for its side effect. | |
126 (void) chromeos::DBusThreadManager::GetSetterForTesting(); | |
Chirantan Ekbote
2014/09/12 00:52:16
This is causing the build to fail on non-chrome os
Luigi Semenzato
2014/09/12 01:24:21
Thank you Chirantan. I am tempted to use #ifdef O
| |
123 } | 127 } |
124 | 128 |
125 void GCMProfileServiceTest::TearDown() { | 129 void GCMProfileServiceTest::TearDown() { |
126 gcm_profile_service_->driver()->RemoveAppHandler(kTestAppID); | 130 gcm_profile_service_->driver()->RemoveAppHandler(kTestAppID); |
127 } | 131 } |
128 | 132 |
129 void GCMProfileServiceTest::CreateGCMProfileService() { | 133 void GCMProfileServiceTest::CreateGCMProfileService() { |
130 gcm_profile_service_ = static_cast<GCMProfileService*>( | 134 gcm_profile_service_ = static_cast<GCMProfileService*>( |
131 GCMProfileServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 135 GCMProfileServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
132 profile_.get(), | 136 profile_.get(), |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
262 GCMClient::OutgoingMessage message; | 266 GCMClient::OutgoingMessage message; |
263 message.id = "1"; | 267 message.id = "1"; |
264 message.data["key1"] = "value1"; | 268 message.data["key1"] = "value1"; |
265 SendAndWaitForCompletion( message); | 269 SendAndWaitForCompletion( message); |
266 | 270 |
267 EXPECT_EQ(message.id, send_message_id()); | 271 EXPECT_EQ(message.id, send_message_id()); |
268 EXPECT_EQ(GCMClient::SUCCESS, send_result()); | 272 EXPECT_EQ(GCMClient::SUCCESS, send_result()); |
269 } | 273 } |
270 | 274 |
271 } // namespace gcm | 275 } // namespace gcm |
OLD | NEW |