Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/strings/string_number_conversions.h" | |
| 10 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/values.h" | 12 #include "base/values.h" |
| 12 #include "chrome/browser/invalidation/fake_invalidation_service.h" | 13 #include "chrome/browser/invalidation/fake_invalidation_service.h" |
| 13 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" | 14 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" |
| 14 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" | 15 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
| 15 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" | 16 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" |
| 16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 17 #include "chrome/browser/signin/signin_manager_factory.h" | 18 #include "chrome/browser/signin/signin_manager_factory.h" |
| 18 #include "chrome/browser/sync/glue/sync_backend_host_mock.h" | 19 #include "chrome/browser/sync/glue/sync_backend_host_mock.h" |
| 19 #include "chrome/browser/sync/profile_sync_components_factory_mock.h" | 20 #include "chrome/browser/sync/profile_sync_components_factory_mock.h" |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 580 EXPECT_EQ(ProfileSyncService::BACKUP, service()->backend_mode()); | 581 EXPECT_EQ(ProfileSyncService::BACKUP, service()->backend_mode()); |
| 581 | 582 |
| 582 // First sync time is erased once backup starts. | 583 // First sync time is erased once backup starts. |
| 583 EXPECT_TRUE(sync_prefs.GetFirstSyncTime().is_null()); | 584 EXPECT_TRUE(sync_prefs.GetFirstSyncTime().is_null()); |
| 584 | 585 |
| 585 EXPECT_EQ(3u, delete_dir_param.size()); | 586 EXPECT_EQ(3u, delete_dir_param.size()); |
| 586 EXPECT_FALSE(delete_dir_param[0]); | 587 EXPECT_FALSE(delete_dir_param[0]); |
| 587 EXPECT_FALSE(delete_dir_param[1]); | 588 EXPECT_FALSE(delete_dir_param[1]); |
| 588 EXPECT_TRUE(delete_dir_param[2]); | 589 EXPECT_TRUE(delete_dir_param[2]); |
| 589 } | 590 } |
| 591 | |
| 592 TEST_F(ProfileSyncServiceTest, StartNewBackupDbOnSettingsReset) { | |
| 593 CreateServiceWithoutSignIn(); | |
| 594 ExpectDataTypeManagerCreation(1); | |
| 595 std::vector<bool> delete_dir_param; | |
| 596 ExpectSyncBackendHostCreationCollectDeleteDir(1, &delete_dir_param); | |
| 597 Initialize(); | |
| 598 EXPECT_EQ(ProfileSyncService::IDLE, service()->backend_mode()); | |
| 599 | |
| 600 // Set reset time to pretend settings reset happened. | |
| 601 profile()->GetPrefs()->SetString( | |
| 602 prefs::kPreferenceResetTime, | |
| 603 base::Int64ToString(base::Time::Now().ToInternalValue())); | |
| 604 | |
| 605 base::MessageLoop::current()->PostDelayedTask( | |
| 606 FROM_HERE, base::Bind(&QuitLoop), | |
|
gab
2014/07/08 14:27:06
Instead of base::Bind(&QuitLoop) these tests shoul
gab
2014/07/08 14:27:06
nit: one space too many after "FROM_HERE,"
haitaol1
2014/07/08 20:31:40
Done.
haitaol1
2014/07/08 20:31:40
Done.
| |
| 607 base::TimeDelta::FromMilliseconds(100)); | |
| 608 base::MessageLoop::current()->Run(); | |
| 609 EXPECT_EQ(ProfileSyncService::BACKUP, service()->backend_mode()); | |
| 610 | |
| 611 EXPECT_EQ(1u, delete_dir_param.size()); | |
| 612 EXPECT_TRUE(delete_dir_param[0]); | |
| 613 } | |
| 614 | |
| 590 #endif | 615 #endif |
| 591 | 616 |
| 592 TEST_F(ProfileSyncServiceTest, GetSyncServiceURL) { | 617 TEST_F(ProfileSyncServiceTest, GetSyncServiceURL) { |
| 593 // See that we can override the URL with a flag. | 618 // See that we can override the URL with a flag. |
| 594 CommandLine command_line( | 619 CommandLine command_line( |
| 595 base::FilePath(base::FilePath(FILE_PATH_LITERAL("chrome.exe")))); | 620 base::FilePath(base::FilePath(FILE_PATH_LITERAL("chrome.exe")))); |
| 596 command_line.AppendSwitchASCII(switches::kSyncServiceURL, "https://foo/bar"); | 621 command_line.AppendSwitchASCII(switches::kSyncServiceURL, "https://foo/bar"); |
| 597 EXPECT_EQ("https://foo/bar", | 622 EXPECT_EQ("https://foo/bar", |
| 598 ProfileSyncService::GetSyncServiceURL(command_line).spec()); | 623 ProfileSyncService::GetSyncServiceURL(command_line).spec()); |
| 599 } | 624 } |
| 600 | 625 |
| 601 } // namespace | 626 } // namespace |
| 602 } // namespace browser_sync | 627 } // namespace browser_sync |
| OLD | NEW |