| 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 "components/gcm_driver/gcm_driver_desktop.h" | 5 #include "components/gcm_driver/gcm_driver_desktop.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 return !driver_->app_handlers().empty(); | 231 return !driver_->app_handlers().empty(); |
| 232 } | 232 } |
| 233 | 233 |
| 234 FakeGCMClient* GCMDriverTest::GetGCMClient() { | 234 FakeGCMClient* GCMDriverTest::GetGCMClient() { |
| 235 return static_cast<FakeGCMClient*>(driver_->GetGCMClientForTesting()); | 235 return static_cast<FakeGCMClient*>(driver_->GetGCMClientForTesting()); |
| 236 } | 236 } |
| 237 | 237 |
| 238 void GCMDriverTest::CreateDriver() { | 238 void GCMDriverTest::CreateDriver() { |
| 239 scoped_refptr<net::URLRequestContextGetter> request_context = | 239 scoped_refptr<net::URLRequestContextGetter> request_context = |
| 240 new net::TestURLRequestContextGetter(io_thread_.task_runner()); | 240 new net::TestURLRequestContextGetter(io_thread_.task_runner()); |
| 241 GCMClient::ChromeBuildInfo chrome_build_info; |
| 242 chrome_build_info.product_category_for_subtypes = "com.chrome.stable.macosx"; |
| 241 driver_.reset(new GCMDriverDesktop( | 243 driver_.reset(new GCMDriverDesktop( |
| 242 std::unique_ptr<GCMClientFactory>(new FakeGCMClientFactory( | 244 std::unique_ptr<GCMClientFactory>(new FakeGCMClientFactory( |
| 243 base::ThreadTaskRunnerHandle::Get(), io_thread_.task_runner())), | 245 base::ThreadTaskRunnerHandle::Get(), io_thread_.task_runner())), |
| 244 GCMClient::ChromeBuildInfo(), "http://channel.status.request.url", | 246 chrome_build_info, "http://channel.status.request.url", |
| 245 "user-agent-string", &prefs_, temp_dir_.path(), request_context, | 247 "user-agent-string", &prefs_, temp_dir_.path(), request_context, |
| 246 base::ThreadTaskRunnerHandle::Get(), io_thread_.task_runner(), | 248 base::ThreadTaskRunnerHandle::Get(), io_thread_.task_runner(), |
| 247 message_loop_.task_runner())); | 249 message_loop_.task_runner())); |
| 248 | 250 |
| 249 gcm_app_handler_.reset(new FakeGCMAppHandler); | 251 gcm_app_handler_.reset(new FakeGCMAppHandler); |
| 250 gcm_connection_observer_.reset(new FakeGCMConnectionObserver); | 252 gcm_connection_observer_.reset(new FakeGCMConnectionObserver); |
| 251 | 253 |
| 252 driver_->AddConnectionObserver(gcm_connection_observer_.get()); | 254 driver_->AddConnectionObserver(gcm_connection_observer_.get()); |
| 253 } | 255 } |
| 254 | 256 |
| (...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 } | 1221 } |
| 1220 | 1222 |
| 1221 void GCMDriverInstanceIDTest::GetToken(const std::string& app_id, | 1223 void GCMDriverInstanceIDTest::GetToken(const std::string& app_id, |
| 1222 const std::string& authorized_entity, | 1224 const std::string& authorized_entity, |
| 1223 const std::string& scope, | 1225 const std::string& scope, |
| 1224 WaitToFinish wait_to_finish) { | 1226 WaitToFinish wait_to_finish) { |
| 1225 base::RunLoop run_loop; | 1227 base::RunLoop run_loop; |
| 1226 set_async_operation_completed_callback(run_loop.QuitClosure()); | 1228 set_async_operation_completed_callback(run_loop.QuitClosure()); |
| 1227 std::map<std::string, std::string> options; | 1229 std::map<std::string, std::string> options; |
| 1228 driver()->GetInstanceIDHandlerInternal()->GetToken( | 1230 driver()->GetInstanceIDHandlerInternal()->GetToken( |
| 1229 app_id, authorized_entity, scope, options, | 1231 app_id, false /* use_subtype */, authorized_entity, scope, options, |
| 1230 base::Bind(&GCMDriverTest::RegisterCompleted, base::Unretained(this))); | 1232 base::Bind(&GCMDriverTest::RegisterCompleted, base::Unretained(this))); |
| 1231 if (wait_to_finish == WAIT) | 1233 if (wait_to_finish == WAIT) |
| 1232 run_loop.Run(); | 1234 run_loop.Run(); |
| 1233 } | 1235 } |
| 1234 | 1236 |
| 1235 void GCMDriverInstanceIDTest::DeleteToken(const std::string& app_id, | 1237 void GCMDriverInstanceIDTest::DeleteToken(const std::string& app_id, |
| 1236 const std::string& authorized_entity, | 1238 const std::string& authorized_entity, |
| 1237 const std::string& scope, | 1239 const std::string& scope, |
| 1238 WaitToFinish wait_to_finish) { | 1240 WaitToFinish wait_to_finish) { |
| 1239 base::RunLoop run_loop; | 1241 base::RunLoop run_loop; |
| 1240 set_async_operation_completed_callback(run_loop.QuitClosure()); | 1242 set_async_operation_completed_callback(run_loop.QuitClosure()); |
| 1241 driver()->GetInstanceIDHandlerInternal()->DeleteToken( | 1243 driver()->GetInstanceIDHandlerInternal()->DeleteToken( |
| 1242 app_id, authorized_entity, scope, | 1244 app_id, false /* use_subtype */, authorized_entity, scope, |
| 1243 base::Bind(&GCMDriverTest::UnregisterCompleted, base::Unretained(this))); | 1245 base::Bind(&GCMDriverTest::UnregisterCompleted, base::Unretained(this))); |
| 1244 if (wait_to_finish == WAIT) | 1246 if (wait_to_finish == WAIT) |
| 1245 run_loop.Run(); | 1247 run_loop.Run(); |
| 1246 } | 1248 } |
| 1247 | 1249 |
| 1248 void GCMDriverInstanceIDTest::AddInstanceIDData(const std::string& app_id, | 1250 void GCMDriverInstanceIDTest::AddInstanceIDData(const std::string& app_id, |
| 1249 const std::string& instance_id, | 1251 const std::string& instance_id, |
| 1250 const std::string& extra_data) { | 1252 const std::string& extra_data) { |
| 1251 driver()->GetInstanceIDHandlerInternal()->AddInstanceIDData( | 1253 driver()->GetInstanceIDHandlerInternal()->AddInstanceIDData( |
| 1252 app_id, instance_id, extra_data); | 1254 app_id, instance_id, extra_data); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1376 PumpUILoop(); | 1378 PumpUILoop(); |
| 1377 EXPECT_EQ(GCMClient::UNKNOWN_ERROR, unregistration_result()); | 1379 EXPECT_EQ(GCMClient::UNKNOWN_ERROR, unregistration_result()); |
| 1378 | 1380 |
| 1379 // DeleteToken operation will be invoked after GCMClient becomes ready. | 1381 // DeleteToken operation will be invoked after GCMClient becomes ready. |
| 1380 GetGCMClient()->PerformDelayedStart(); | 1382 GetGCMClient()->PerformDelayedStart(); |
| 1381 WaitForAsyncOperation(); | 1383 WaitForAsyncOperation(); |
| 1382 EXPECT_EQ(GCMClient::SUCCESS, unregistration_result()); | 1384 EXPECT_EQ(GCMClient::SUCCESS, unregistration_result()); |
| 1383 } | 1385 } |
| 1384 | 1386 |
| 1385 } // namespace gcm | 1387 } // namespace gcm |
| OLD | NEW |