| 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 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 | 613 |
| 612 TEST_F(ProfileSyncServiceTest, GetSyncServiceURL) { | 614 TEST_F(ProfileSyncServiceTest, GetSyncServiceURL) { |
| 613 // See that we can override the URL with a flag. | 615 // See that we can override the URL with a flag. |
| 614 CommandLine command_line( | 616 CommandLine command_line( |
| 615 base::FilePath(base::FilePath(FILE_PATH_LITERAL("chrome.exe")))); | 617 base::FilePath(base::FilePath(FILE_PATH_LITERAL("chrome.exe")))); |
| 616 command_line.AppendSwitchASCII(switches::kSyncServiceURL, "https://foo/bar"); | 618 command_line.AppendSwitchASCII(switches::kSyncServiceURL, "https://foo/bar"); |
| 617 EXPECT_EQ("https://foo/bar", | 619 EXPECT_EQ("https://foo/bar", |
| 618 ProfileSyncService::GetSyncServiceURL(command_line).spec()); | 620 ProfileSyncService::GetSyncServiceURL(command_line).spec()); |
| 619 } | 621 } |
| 620 | 622 |
| 623 // Verify that LastSyncedTime is cleared when the user signs out. |
| 624 TEST_F(ProfileSyncServiceTest, ClearLastSyncedTimeOnSignOut) { |
| 625 IssueTestTokens(); |
| 626 CreateService(AUTO_START); |
| 627 ExpectDataTypeManagerCreation(1); |
| 628 ExpectSyncBackendHostCreation(1); |
| 629 InitializeForNthSync(); |
| 630 EXPECT_TRUE(service()->SyncActive()); |
| 631 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_SYNC_TIME_JUST_NOW), |
| 632 service()->GetLastSyncedTimeString()); |
| 633 |
| 634 // Sign out. |
| 635 service()->DisableForUser(); |
| 636 PumpLoop(); |
| 637 |
| 638 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_SYNC_TIME_NEVER), |
| 639 service()->GetLastSyncedTimeString()); |
| 640 } |
| 641 |
| 621 } // namespace | 642 } // namespace |
| 622 } // namespace browser_sync | 643 } // namespace browser_sync |
| OLD | NEW |