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/string_number_conversions.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 // This is useful if we want to test the ProfileSyncService and don't care about | 169 // This is useful if we want to test the ProfileSyncService and don't care about |
170 // testing the SyncBackendHost. | 170 // testing the SyncBackendHost. |
171 class ProfileSyncServiceTest : public ::testing::Test { | 171 class ProfileSyncServiceTest : public ::testing::Test { |
172 protected: | 172 protected: |
173 ProfileSyncServiceTest() | 173 ProfileSyncServiceTest() |
174 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), | 174 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), |
175 profile_manager_(TestingBrowserProcess::GetGlobal()) {} | 175 profile_manager_(TestingBrowserProcess::GetGlobal()) {} |
176 ~ProfileSyncServiceTest() override {} | 176 ~ProfileSyncServiceTest() override {} |
177 | 177 |
178 void SetUp() override { | 178 void SetUp() override { |
179 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 179 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
180 switches::kSyncDeferredStartupTimeoutSeconds, "0"); | 180 switches::kSyncDeferredStartupTimeoutSeconds, "0"); |
181 | 181 |
182 CHECK(profile_manager_.SetUp()); | 182 CHECK(profile_manager_.SetUp()); |
183 | 183 |
184 TestingProfile::TestingFactories testing_facotries; | 184 TestingProfile::TestingFactories testing_facotries; |
185 testing_facotries.push_back( | 185 testing_facotries.push_back( |
186 std::make_pair(ProfileOAuth2TokenServiceFactory::GetInstance(), | 186 std::make_pair(ProfileOAuth2TokenServiceFactory::GetInstance(), |
187 BuildAutoIssuingFakeProfileOAuth2TokenService)); | 187 BuildAutoIssuingFakeProfileOAuth2TokenService)); |
188 testing_facotries.push_back( | 188 testing_facotries.push_back( |
189 std::make_pair( | 189 std::make_pair( |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 | 606 |
607 EXPECT_EQ(2u, delete_dir_param.size()); | 607 EXPECT_EQ(2u, delete_dir_param.size()); |
608 EXPECT_FALSE(delete_dir_param[0]); | 608 EXPECT_FALSE(delete_dir_param[0]); |
609 EXPECT_FALSE(delete_dir_param[1]); | 609 EXPECT_FALSE(delete_dir_param[1]); |
610 } | 610 } |
611 | 611 |
612 #endif | 612 #endif |
613 | 613 |
614 TEST_F(ProfileSyncServiceTest, GetSyncServiceURL) { | 614 TEST_F(ProfileSyncServiceTest, GetSyncServiceURL) { |
615 // See that we can override the URL with a flag. | 615 // See that we can override the URL with a flag. |
616 CommandLine command_line( | 616 base::CommandLine command_line( |
617 base::FilePath(base::FilePath(FILE_PATH_LITERAL("chrome.exe")))); | 617 base::FilePath(base::FilePath(FILE_PATH_LITERAL("chrome.exe")))); |
618 command_line.AppendSwitchASCII(switches::kSyncServiceURL, "https://foo/bar"); | 618 command_line.AppendSwitchASCII(switches::kSyncServiceURL, "https://foo/bar"); |
619 EXPECT_EQ("https://foo/bar", | 619 EXPECT_EQ("https://foo/bar", |
620 ProfileSyncService::GetSyncServiceURL(command_line).spec()); | 620 ProfileSyncService::GetSyncServiceURL(command_line).spec()); |
621 } | 621 } |
622 | 622 |
623 // Verify that LastSyncedTime is cleared when the user signs out. | 623 // Verify that LastSyncedTime is cleared when the user signs out. |
624 TEST_F(ProfileSyncServiceTest, ClearLastSyncedTimeOnSignOut) { | 624 TEST_F(ProfileSyncServiceTest, ClearLastSyncedTimeOnSignOut) { |
625 IssueTestTokens(); | 625 IssueTestTokens(); |
626 CreateService(AUTO_START); | 626 CreateService(AUTO_START); |
627 ExpectDataTypeManagerCreation(1); | 627 ExpectDataTypeManagerCreation(1); |
628 ExpectSyncBackendHostCreation(1); | 628 ExpectSyncBackendHostCreation(1); |
629 InitializeForNthSync(); | 629 InitializeForNthSync(); |
630 EXPECT_TRUE(service()->SyncActive()); | 630 EXPECT_TRUE(service()->SyncActive()); |
631 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_SYNC_TIME_JUST_NOW), | 631 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_SYNC_TIME_JUST_NOW), |
632 service()->GetLastSyncedTimeString()); | 632 service()->GetLastSyncedTimeString()); |
633 | 633 |
634 // Sign out. | 634 // Sign out. |
635 service()->DisableForUser(); | 635 service()->DisableForUser(); |
636 PumpLoop(); | 636 PumpLoop(); |
637 | 637 |
638 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_SYNC_TIME_NEVER), | 638 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_SYNC_TIME_NEVER), |
639 service()->GetLastSyncedTimeString()); | 639 service()->GetLastSyncedTimeString()); |
640 } | 640 } |
641 | 641 |
642 } // namespace | 642 } // namespace |
643 } // namespace browser_sync | 643 } // namespace browser_sync |
OLD | NEW |