| 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_account_mapper.h" | 5 #include "components/gcm_driver/gcm_account_mapper.h" |
| 6 | 6 |
| 7 #include "base/test/simple_test_clock.h" | 7 #include "base/test/simple_test_clock.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "components/gcm_driver/fake_gcm_driver.h" | 9 #include "components/gcm_driver/fake_gcm_driver.h" |
| 10 #include "google_apis/gcm/engine/account_mapping.h" | 10 #include "google_apis/gcm/engine/account_mapping.h" |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 | 268 |
| 269 GCMAccountMapperTest::~GCMAccountMapperTest() { | 269 GCMAccountMapperTest::~GCMAccountMapperTest() { |
| 270 } | 270 } |
| 271 | 271 |
| 272 void GCMAccountMapperTest::Restart() { | 272 void GCMAccountMapperTest::Restart() { |
| 273 if (account_mapper_) | 273 if (account_mapper_) |
| 274 account_mapper_->ShutdownHandler(); | 274 account_mapper_->ShutdownHandler(); |
| 275 account_mapper_.reset(new GCMAccountMapper(&gcm_driver_)); | 275 account_mapper_.reset(new GCMAccountMapper(&gcm_driver_)); |
| 276 scoped_ptr<base::SimpleTestClock> clock(new base::SimpleTestClock); | 276 scoped_ptr<base::SimpleTestClock> clock(new base::SimpleTestClock); |
| 277 clock_ = clock.get(); | 277 clock_ = clock.get(); |
| 278 account_mapper_->SetClockForTesting(clock.PassAs<base::Clock>()); | 278 account_mapper_->SetClockForTesting(clock.Pass()); |
| 279 } | 279 } |
| 280 | 280 |
| 281 // Tests the initialization of account mappings (from the store) when empty. | 281 // Tests the initialization of account mappings (from the store) when empty. |
| 282 // It also checks that initialization triggers registration ID request. | 282 // It also checks that initialization triggers registration ID request. |
| 283 TEST_F(GCMAccountMapperTest, InitializeAccountMappingsEmpty) { | 283 TEST_F(GCMAccountMapperTest, InitializeAccountMappingsEmpty) { |
| 284 EXPECT_FALSE(gcm_driver().registration_id_requested()); | 284 EXPECT_FALSE(gcm_driver().registration_id_requested()); |
| 285 mapper()->Initialize(GCMAccountMapper::AccountMappings()); | 285 mapper()->Initialize(GCMAccountMapper::AccountMappings()); |
| 286 EXPECT_TRUE(GetAccounts().empty()); | 286 EXPECT_TRUE(GetAccounts().empty()); |
| 287 EXPECT_TRUE(gcm_driver().registration_id_requested()); | 287 EXPECT_TRUE(gcm_driver().registration_id_requested()); |
| 288 } | 288 } |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 expected_mappings[1].status_change_timestamp = clock()->Now(); | 897 expected_mappings[1].status_change_timestamp = clock()->Now(); |
| 898 expected_mappings[1].status = AccountMapping::MAPPED; | 898 expected_mappings[1].status = AccountMapping::MAPPED; |
| 899 expected_mappings[2].status_change_timestamp = clock()->Now(); | 899 expected_mappings[2].status_change_timestamp = clock()->Now(); |
| 900 expected_mappings[2].status = AccountMapping::MAPPED; | 900 expected_mappings[2].status = AccountMapping::MAPPED; |
| 901 | 901 |
| 902 VerifyMappings( | 902 VerifyMappings( |
| 903 expected_mappings, GetAccounts(), "Step 6, Three mapped accounts"); | 903 expected_mappings, GetAccounts(), "Step 6, Three mapped accounts"); |
| 904 } | 904 } |
| 905 | 905 |
| 906 } // namespace gcm | 906 } // namespace gcm |
| OLD | NEW |