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" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/invalidation/fake_invalidation_service.h" | 13 #include "chrome/browser/invalidation/fake_invalidation_service.h" |
14 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" | 14 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" |
15 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" | 15 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
16 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" | 16 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" |
17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
18 #include "chrome/browser/signin/signin_manager_factory.h" | 18 #include "chrome/browser/signin/signin_manager_factory.h" |
19 #include "chrome/browser/sync/glue/sync_backend_host_mock.h" | 19 #include "chrome/browser/sync/glue/sync_backend_host_mock.h" |
20 #include "chrome/browser/sync/profile_sync_components_factory_mock.h" | 20 #include "chrome/browser/sync/profile_sync_components_factory_mock.h" |
21 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" | 21 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" |
22 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
23 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
| 24 #include "chrome/grit/generated_resources.h" |
24 #include "chrome/test/base/testing_browser_process.h" | 25 #include "chrome/test/base/testing_browser_process.h" |
25 #include "chrome/test/base/testing_pref_service_syncable.h" | 26 #include "chrome/test/base/testing_pref_service_syncable.h" |
26 #include "chrome/test/base/testing_profile.h" | 27 #include "chrome/test/base/testing_profile.h" |
27 #include "chrome/test/base/testing_profile_manager.h" | 28 #include "chrome/test/base/testing_profile_manager.h" |
28 #include "components/invalidation/invalidation_service.h" | 29 #include "components/invalidation/invalidation_service.h" |
29 #include "components/invalidation/profile_invalidation_provider.h" | 30 #include "components/invalidation/profile_invalidation_provider.h" |
30 #include "components/signin/core/browser/signin_manager.h" | 31 #include "components/signin/core/browser/signin_manager.h" |
31 #include "components/sync_driver/data_type_manager.h" | 32 #include "components/sync_driver/data_type_manager.h" |
32 #include "components/sync_driver/pref_names.h" | 33 #include "components/sync_driver/pref_names.h" |
33 #include "components/sync_driver/sync_prefs.h" | 34 #include "components/sync_driver/sync_prefs.h" |
34 #include "content/public/test/test_browser_thread_bundle.h" | 35 #include "content/public/test/test_browser_thread_bundle.h" |
35 #include "google_apis/gaia/gaia_constants.h" | 36 #include "google_apis/gaia/gaia_constants.h" |
36 #include "testing/gmock/include/gmock/gmock.h" | 37 #include "testing/gmock/include/gmock/gmock.h" |
37 #include "testing/gtest/include/gtest/gtest.h" | 38 #include "testing/gtest/include/gtest/gtest.h" |
| 39 #include "ui/base/l10n/l10n_util.h" |
38 | 40 |
39 namespace content { | 41 namespace content { |
40 class BrowserContext; | 42 class BrowserContext; |
41 } | 43 } |
42 | 44 |
43 namespace browser_sync { | 45 namespace browser_sync { |
44 | 46 |
45 namespace { | 47 namespace { |
46 | 48 |
47 class FakeDataTypeManager : public sync_driver::DataTypeManager { | 49 class FakeDataTypeManager : public sync_driver::DataTypeManager { |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 | 611 |
610 TEST_F(ProfileSyncServiceTest, GetSyncServiceURL) { | 612 TEST_F(ProfileSyncServiceTest, GetSyncServiceURL) { |
611 // See that we can override the URL with a flag. | 613 // See that we can override the URL with a flag. |
612 CommandLine command_line( | 614 CommandLine command_line( |
613 base::FilePath(base::FilePath(FILE_PATH_LITERAL("chrome.exe")))); | 615 base::FilePath(base::FilePath(FILE_PATH_LITERAL("chrome.exe")))); |
614 command_line.AppendSwitchASCII(switches::kSyncServiceURL, "https://foo/bar"); | 616 command_line.AppendSwitchASCII(switches::kSyncServiceURL, "https://foo/bar"); |
615 EXPECT_EQ("https://foo/bar", | 617 EXPECT_EQ("https://foo/bar", |
616 ProfileSyncService::GetSyncServiceURL(command_line).spec()); | 618 ProfileSyncService::GetSyncServiceURL(command_line).spec()); |
617 } | 619 } |
618 | 620 |
| 621 // Verify that LastSyncedTime is cleared when the user signs out. |
| 622 TEST_F(ProfileSyncServiceTest, ClearLastSyncedTimeOnSignOut) { |
| 623 IssueTestTokens(); |
| 624 CreateService(AUTO_START); |
| 625 ExpectDataTypeManagerCreation(1); |
| 626 ExpectSyncBackendHostCreation(1); |
| 627 InitializeForNthSync(); |
| 628 EXPECT_TRUE(service()->SyncActive()); |
| 629 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_SYNC_TIME_JUST_NOW), |
| 630 service()->GetLastSyncedTimeString()); |
| 631 |
| 632 // Sign out. |
| 633 service()->DisableForUser(); |
| 634 PumpLoop(); |
| 635 |
| 636 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_SYNC_TIME_NEVER), |
| 637 service()->GetLastSyncedTimeString()); |
| 638 } |
| 639 |
619 } // namespace | 640 } // namespace |
620 } // namespace browser_sync | 641 } // namespace browser_sync |
OLD | NEW |