| 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 "components/browser_sync/browser/profile_sync_service.h" | 5 #include "components/browser_sync/browser/profile_sync_service.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 // once when handling actionable error. | 897 // once when handling actionable error. |
| 898 ExpectDataTypeManagerCreation(2, GetDefaultConfigureCalledCallback()); | 898 ExpectDataTypeManagerCreation(2, GetDefaultConfigureCalledCallback()); |
| 899 ExpectSyncBackendHostCreation(2); | 899 ExpectSyncBackendHostCreation(2); |
| 900 InitializeForNthSync(); | 900 InitializeForNthSync(); |
| 901 | 901 |
| 902 syncer::SyncProtocolError client_cmd; | 902 syncer::SyncProtocolError client_cmd; |
| 903 client_cmd.action = syncer::RESET_LOCAL_SYNC_DATA; | 903 client_cmd.action = syncer::RESET_LOCAL_SYNC_DATA; |
| 904 service()->OnActionableError(client_cmd); | 904 service()->OnActionableError(client_cmd); |
| 905 } | 905 } |
| 906 | 906 |
| 907 // Test that when ProfileSyncService receives actionable error | |
| 908 // DISABLE_SYNC_ON_CLIENT it disables sync and signs out. | |
| 909 TEST_F(ProfileSyncServiceTest, DisableSyncOnClient) { | |
| 910 IssueTestTokens(); | |
| 911 CreateService(ProfileSyncService::AUTO_START); | |
| 912 ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback()); | |
| 913 ExpectSyncBackendHostCreation(1); | |
| 914 InitializeForNthSync(); | |
| 915 | |
| 916 EXPECT_TRUE(service()->IsSyncActive()); | |
| 917 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_SYNC_TIME_JUST_NOW), | |
| 918 service()->GetLastSyncedTimeString()); | |
| 919 EXPECT_TRUE(service()->GetLocalDeviceInfoProvider()->GetLocalDeviceInfo()); | |
| 920 | |
| 921 syncer::SyncProtocolError client_cmd; | |
| 922 client_cmd.action = syncer::DISABLE_SYNC_ON_CLIENT; | |
| 923 service()->OnActionableError(client_cmd); | |
| 924 | |
| 925 // CrOS does not support signout. | |
| 926 #if !defined(OS_CHROMEOS) | |
| 927 EXPECT_TRUE(signin_manager()->GetAuthenticatedAccountId().empty()); | |
| 928 #else | |
| 929 EXPECT_FALSE(signin_manager()->GetAuthenticatedAccountId().empty()); | |
| 930 #endif | |
| 931 | |
| 932 EXPECT_FALSE(service()->IsSyncActive()); | |
| 933 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_SYNC_TIME_NEVER), | |
| 934 service()->GetLastSyncedTimeString()); | |
| 935 EXPECT_FALSE(service()->GetLocalDeviceInfoProvider()->GetLocalDeviceInfo()); | |
| 936 } | |
| 937 | |
| 938 // Regression test for crbug/555434. The issue is that check for sessions DTC in | 907 // Regression test for crbug/555434. The issue is that check for sessions DTC in |
| 939 // OnSessionRestoreComplete was creating map entry with nullptr which later was | 908 // OnSessionRestoreComplete was creating map entry with nullptr which later was |
| 940 // dereferenced in OnSyncCycleCompleted. The fix is to use find() to check if | 909 // dereferenced in OnSyncCycleCompleted. The fix is to use find() to check if |
| 941 // entry for sessions exists in map. | 910 // entry for sessions exists in map. |
| 942 TEST_F(ProfileSyncServiceTest, ValidPointersInDTCMap) { | 911 TEST_F(ProfileSyncServiceTest, ValidPointersInDTCMap) { |
| 943 CreateService(ProfileSyncService::AUTO_START); | 912 CreateService(ProfileSyncService::AUTO_START); |
| 944 service()->OnSessionRestoreComplete(); | 913 service()->OnSessionRestoreComplete(); |
| 945 service()->OnSyncCycleCompleted(); | 914 service()->OnSyncCycleCompleted(); |
| 946 } | 915 } |
| 947 | 916 |
| 948 } // namespace | 917 } // namespace |
| 949 } // namespace browser_sync | 918 } // namespace browser_sync |
| OLD | NEW |