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 "google_apis/gcm/gcm_client_impl.h" | 5 #include "google_apis/gcm/gcm_client_impl.h" |
6 | 6 |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/test/simple_test_clock.h" | 10 #include "base/test/simple_test_clock.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 connection_factory_.reset(new FakeConnectionFactory()); | 276 connection_factory_.reset(new FakeConnectionFactory()); |
277 gcm_client_->SetMCSClientForTesting(scoped_ptr<MCSClient>( | 277 gcm_client_->SetMCSClientForTesting(scoped_ptr<MCSClient>( |
278 new FakeMCSClient(clock(), connection_factory_.get())).Pass()); | 278 new FakeMCSClient(clock(), connection_factory_.get())).Pass()); |
279 // Actual initialization. | 279 // Actual initialization. |
280 checkin_proto::ChromeBuildProto chrome_build_proto; | 280 checkin_proto::ChromeBuildProto chrome_build_proto; |
281 gcm_client_->Initialize(chrome_build_proto, | 281 gcm_client_->Initialize(chrome_build_proto, |
282 temp_directory_.path(), | 282 temp_directory_.path(), |
283 message_loop_.message_loop_proxy(), | 283 message_loop_.message_loop_proxy(), |
284 url_request_context_getter_, | 284 url_request_context_getter_, |
285 this); | 285 this); |
| 286 |
286 #if defined(OS_MACOSX) | 287 #if defined(OS_MACOSX) |
287 // On OSX, prevent the Keychain permissions popup during unit tests. | 288 // On OSX, prevent the Keychain permissions popup during unit tests. |
288 Encryptor::UseMockKeychain(true); // Must be after Initialize. | 289 Encryptor::UseMockKeychain(true); // Must be after Initialize. |
289 #endif | 290 #endif |
| 291 |
| 292 // Starting loading and check-in. |
| 293 gcm_client_->Load(); |
| 294 |
290 // Ensuring that mcs_client is using the same gcm_store as gcm_client. | 295 // Ensuring that mcs_client is using the same gcm_store as gcm_client. |
291 mcs_client()->set_gcm_store(gcm_client_->gcm_store_.get()); | 296 mcs_client()->set_gcm_store(gcm_client_->gcm_store_.get()); |
292 PumpLoopUntilIdle(); | 297 PumpLoopUntilIdle(); |
293 CompleteCheckin(kDeviceAndroidId, kDeviceSecurityToken); | 298 CompleteCheckin(kDeviceAndroidId, kDeviceSecurityToken); |
294 } | 299 } |
295 | 300 |
296 void GCMClientImplTest::ReceiveMessageFromMCS(const MCSMessage& message) { | 301 void GCMClientImplTest::ReceiveMessageFromMCS(const MCSMessage& message) { |
297 gcm_client_->OnMessageReceivedFromMCS(message); | 302 gcm_client_->OnMessageReceivedFromMCS(message); |
298 } | 303 } |
299 | 304 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 EXPECT_EQ(CurrentTime(), mcs_client()->last_data_message_stanza().sent()); | 443 EXPECT_EQ(CurrentTime(), mcs_client()->last_data_message_stanza().sent()); |
439 EXPECT_EQ("007", mcs_client()->last_data_message_stanza().id()); | 444 EXPECT_EQ("007", mcs_client()->last_data_message_stanza().id()); |
440 EXPECT_EQ("gcm@chrome.com", mcs_client()->last_data_message_stanza().from()); | 445 EXPECT_EQ("gcm@chrome.com", mcs_client()->last_data_message_stanza().from()); |
441 EXPECT_EQ("project_id", mcs_client()->last_data_message_stanza().to()); | 446 EXPECT_EQ("project_id", mcs_client()->last_data_message_stanza().to()); |
442 EXPECT_EQ("key", mcs_client()->last_data_message_stanza().app_data(0).key()); | 447 EXPECT_EQ("key", mcs_client()->last_data_message_stanza().app_data(0).key()); |
443 EXPECT_EQ("value", | 448 EXPECT_EQ("value", |
444 mcs_client()->last_data_message_stanza().app_data(0).value()); | 449 mcs_client()->last_data_message_stanza().app_data(0).value()); |
445 } | 450 } |
446 | 451 |
447 } // namespace gcm | 452 } // namespace gcm |
OLD | NEW |