| 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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 int64 GCMClientImplTest::CurrentTime() { | 322 int64 GCMClientImplTest::CurrentTime() { |
| 323 return clock()->Now().ToInternalValue() / base::Time::kMicrosecondsPerSecond; | 323 return clock()->Now().ToInternalValue() / base::Time::kMicrosecondsPerSecond; |
| 324 } | 324 } |
| 325 | 325 |
| 326 TEST_F(GCMClientImplTest, LoadingCompleted) { | 326 TEST_F(GCMClientImplTest, LoadingCompleted) { |
| 327 EXPECT_EQ(LOADING_COMPLETED, last_event()); | 327 EXPECT_EQ(LOADING_COMPLETED, last_event()); |
| 328 EXPECT_EQ(kDeviceAndroidId, mcs_client()->last_android_id()); | 328 EXPECT_EQ(kDeviceAndroidId, mcs_client()->last_android_id()); |
| 329 EXPECT_EQ(kDeviceSecurityToken, mcs_client()->last_security_token()); | 329 EXPECT_EQ(kDeviceSecurityToken, mcs_client()->last_security_token()); |
| 330 } | 330 } |
| 331 | 331 |
| 332 TEST_F(GCMClientImplTest, CheckOut) { |
| 333 EXPECT_TRUE(mcs_client()); |
| 334 gcm_client()->CheckOut(); |
| 335 EXPECT_FALSE(mcs_client()); |
| 336 } |
| 337 |
| 332 TEST_F(GCMClientImplTest, RegisterApp) { | 338 TEST_F(GCMClientImplTest, RegisterApp) { |
| 333 std::vector<std::string> senders; | 339 std::vector<std::string> senders; |
| 334 senders.push_back("sender"); | 340 senders.push_back("sender"); |
| 335 gcm_client()->Register("app_id", "cert", senders); | 341 gcm_client()->Register("app_id", "cert", senders); |
| 336 CompleteRegistration("reg_id"); | 342 CompleteRegistration("reg_id"); |
| 337 | 343 |
| 338 EXPECT_EQ(REGISTRATION_COMPLETED, last_event()); | 344 EXPECT_EQ(REGISTRATION_COMPLETED, last_event()); |
| 339 EXPECT_EQ("app_id", last_app_id()); | 345 EXPECT_EQ("app_id", last_app_id()); |
| 340 EXPECT_EQ("reg_id", last_registration_id()); | 346 EXPECT_EQ("reg_id", last_registration_id()); |
| 341 EXPECT_EQ(GCMClient::SUCCESS, last_result()); | 347 EXPECT_EQ(GCMClient::SUCCESS, last_result()); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 EXPECT_EQ(CurrentTime(), mcs_client()->last_data_message_stanza().sent()); | 407 EXPECT_EQ(CurrentTime(), mcs_client()->last_data_message_stanza().sent()); |
| 402 EXPECT_EQ("007", mcs_client()->last_data_message_stanza().id()); | 408 EXPECT_EQ("007", mcs_client()->last_data_message_stanza().id()); |
| 403 EXPECT_EQ("gcm@chrome.com", mcs_client()->last_data_message_stanza().from()); | 409 EXPECT_EQ("gcm@chrome.com", mcs_client()->last_data_message_stanza().from()); |
| 404 EXPECT_EQ("project_id", mcs_client()->last_data_message_stanza().to()); | 410 EXPECT_EQ("project_id", mcs_client()->last_data_message_stanza().to()); |
| 405 EXPECT_EQ("key", mcs_client()->last_data_message_stanza().app_data(0).key()); | 411 EXPECT_EQ("key", mcs_client()->last_data_message_stanza().app_data(0).key()); |
| 406 EXPECT_EQ("value", | 412 EXPECT_EQ("value", |
| 407 mcs_client()->last_data_message_stanza().app_data(0).value()); | 413 mcs_client()->last_data_message_stanza().app_data(0).value()); |
| 408 } | 414 } |
| 409 | 415 |
| 410 } // namespace gcm | 416 } // namespace gcm |
| OLD | NEW |