| 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/prefs/pref_member.h" | 5 #include "base/prefs/pref_member.h" |
| 6 #include "base/prefs/pref_service.h" | 6 #include "base/prefs/pref_service.h" |
| 7 #include "chrome/browser/sync/profile_sync_service.h" | 7 #include "chrome/browser/sync/profile_sync_service.h" |
| 8 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" | 8 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" |
| 9 #include "chrome/browser/sync/test/integration/passwords_helper.h" | 9 #include "chrome/browser/sync/test/integration/passwords_helper.h" |
| 10 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" | 10 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 } | 84 } |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 DISALLOW_COPY_AND_ASSIGN(ActionableErrorChecker); | 87 DISALLOW_COPY_AND_ASSIGN(ActionableErrorChecker); |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 IN_PROC_BROWSER_TEST_F(SyncErrorTest, BirthdayErrorTest) { | 90 IN_PROC_BROWSER_TEST_F(SyncErrorTest, BirthdayErrorTest) { |
| 91 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 91 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 92 | 92 |
| 93 // Add an item, wait for sync, and trigger a birthday error on the server. | 93 // Add an item, wait for sync, and trigger a birthday error on the server. |
| 94 const BookmarkNode* node1 = AddFolder(0, 0, L"title1"); | 94 const BookmarkNode* node1 = AddFolder(0, 0, "title1"); |
| 95 SetTitle(0, node1, L"new_title1"); | 95 SetTitle(0, node1, "new_title1"); |
| 96 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 96 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); |
| 97 ASSERT_TRUE(GetFakeServer()->SetNewStoreBirthday("new store birthday")); | 97 ASSERT_TRUE(GetFakeServer()->SetNewStoreBirthday("new store birthday")); |
| 98 | 98 |
| 99 // Now make one more change so we will do another sync. | 99 // Now make one more change so we will do another sync. |
| 100 const BookmarkNode* node2 = AddFolder(0, 0, L"title2"); | 100 const BookmarkNode* node2 = AddFolder(0, 0, "title2"); |
| 101 SetTitle(0, node2, L"new_title2"); | 101 SetTitle(0, node2, "new_title2"); |
| 102 ASSERT_TRUE(AwaitSyncDisabled(GetSyncService((0)))); | 102 ASSERT_TRUE(AwaitSyncDisabled(GetSyncService((0)))); |
| 103 } | 103 } |
| 104 | 104 |
| 105 IN_PROC_BROWSER_TEST_F(LegacySyncErrorTest, ActionableErrorTest) { | 105 IN_PROC_BROWSER_TEST_F(LegacySyncErrorTest, ActionableErrorTest) { |
| 106 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 106 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 107 | 107 |
| 108 const BookmarkNode* node1 = AddFolder(0, 0, L"title1"); | 108 const BookmarkNode* node1 = AddFolder(0, 0, "title1"); |
| 109 SetTitle(0, node1, L"new_title1"); | 109 SetTitle(0, node1, "new_title1"); |
| 110 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 110 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); |
| 111 | 111 |
| 112 syncer::SyncProtocolError protocol_error; | 112 syncer::SyncProtocolError protocol_error; |
| 113 protocol_error.error_type = syncer::TRANSIENT_ERROR; | 113 protocol_error.error_type = syncer::TRANSIENT_ERROR; |
| 114 protocol_error.action = syncer::UPGRADE_CLIENT; | 114 protocol_error.action = syncer::UPGRADE_CLIENT; |
| 115 protocol_error.error_description = "Not My Fault"; | 115 protocol_error.error_description = "Not My Fault"; |
| 116 protocol_error.url = "www.google.com"; | 116 protocol_error.url = "www.google.com"; |
| 117 TriggerSyncError(protocol_error, SyncTest::ERROR_FREQUENCY_ALWAYS); | 117 TriggerSyncError(protocol_error, SyncTest::ERROR_FREQUENCY_ALWAYS); |
| 118 | 118 |
| 119 // Now make one more change so we will do another sync. | 119 // Now make one more change so we will do another sync. |
| 120 const BookmarkNode* node2 = AddFolder(0, 0, L"title2"); | 120 const BookmarkNode* node2 = AddFolder(0, 0, "title2"); |
| 121 SetTitle(0, node2, L"new_title2"); | 121 SetTitle(0, node2, "new_title2"); |
| 122 | 122 |
| 123 // Wait until an actionable error is encountered. | 123 // Wait until an actionable error is encountered. |
| 124 ActionableErrorChecker actionable_error_checker(GetSyncService((0))); | 124 ActionableErrorChecker actionable_error_checker(GetSyncService((0))); |
| 125 actionable_error_checker.Wait(); | 125 actionable_error_checker.Wait(); |
| 126 ASSERT_FALSE(actionable_error_checker.TimedOut()); | 126 ASSERT_FALSE(actionable_error_checker.TimedOut()); |
| 127 | 127 |
| 128 ProfileSyncService::Status status; | 128 ProfileSyncService::Status status; |
| 129 GetSyncService((0))->QueryDetailedSyncStatus(&status); | 129 GetSyncService((0))->QueryDetailedSyncStatus(&status); |
| 130 ASSERT_EQ(status.sync_protocol_error.error_type, protocol_error.error_type); | 130 ASSERT_EQ(status.sync_protocol_error.error_type, protocol_error.error_type); |
| 131 ASSERT_EQ(status.sync_protocol_error.action, protocol_error.action); | 131 ASSERT_EQ(status.sync_protocol_error.action, protocol_error.action); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 162 // Now enable a datatype, whose first 2 syncs would fail, but we should | 162 // Now enable a datatype, whose first 2 syncs would fail, but we should |
| 163 // recover and setup succesfully on the third attempt. | 163 // recover and setup succesfully on the third attempt. |
| 164 ASSERT_TRUE(GetClient(0)->EnableSyncForDatatype(syncer::AUTOFILL)); | 164 ASSERT_TRUE(GetClient(0)->EnableSyncForDatatype(syncer::AUTOFILL)); |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 | 167 |
| 168 IN_PROC_BROWSER_TEST_F(LegacySyncErrorTest, | 168 IN_PROC_BROWSER_TEST_F(LegacySyncErrorTest, |
| 169 BirthdayErrorUsingActionableErrorTest) { | 169 BirthdayErrorUsingActionableErrorTest) { |
| 170 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 170 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 171 | 171 |
| 172 const BookmarkNode* node1 = AddFolder(0, 0, L"title1"); | 172 const BookmarkNode* node1 = AddFolder(0, 0, "title1"); |
| 173 SetTitle(0, node1, L"new_title1"); | 173 SetTitle(0, node1, "new_title1"); |
| 174 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 174 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); |
| 175 | 175 |
| 176 syncer::SyncProtocolError protocol_error; | 176 syncer::SyncProtocolError protocol_error; |
| 177 protocol_error.error_type = syncer::NOT_MY_BIRTHDAY; | 177 protocol_error.error_type = syncer::NOT_MY_BIRTHDAY; |
| 178 protocol_error.action = syncer::DISABLE_SYNC_ON_CLIENT; | 178 protocol_error.action = syncer::DISABLE_SYNC_ON_CLIENT; |
| 179 protocol_error.error_description = "Not My Fault"; | 179 protocol_error.error_description = "Not My Fault"; |
| 180 protocol_error.url = "www.google.com"; | 180 protocol_error.url = "www.google.com"; |
| 181 TriggerSyncError(protocol_error, SyncTest::ERROR_FREQUENCY_ALWAYS); | 181 TriggerSyncError(protocol_error, SyncTest::ERROR_FREQUENCY_ALWAYS); |
| 182 | 182 |
| 183 // Now make one more change so we will do another sync. | 183 // Now make one more change so we will do another sync. |
| 184 const BookmarkNode* node2 = AddFolder(0, 0, L"title2"); | 184 const BookmarkNode* node2 = AddFolder(0, 0, "title2"); |
| 185 SetTitle(0, node2, L"new_title2"); | 185 SetTitle(0, node2, "new_title2"); |
| 186 ASSERT_TRUE(AwaitSyncDisabled(GetSyncService((0)))); | 186 ASSERT_TRUE(AwaitSyncDisabled(GetSyncService((0)))); |
| 187 ProfileSyncService::Status status; | 187 ProfileSyncService::Status status; |
| 188 GetSyncService((0))->QueryDetailedSyncStatus(&status); | 188 GetSyncService((0))->QueryDetailedSyncStatus(&status); |
| 189 ASSERT_EQ(status.sync_protocol_error.error_type, protocol_error.error_type); | 189 ASSERT_EQ(status.sync_protocol_error.error_type, protocol_error.error_type); |
| 190 ASSERT_EQ(status.sync_protocol_error.action, protocol_error.action); | 190 ASSERT_EQ(status.sync_protocol_error.action, protocol_error.action); |
| 191 ASSERT_EQ(status.sync_protocol_error.url, protocol_error.url); | 191 ASSERT_EQ(status.sync_protocol_error.url, protocol_error.url); |
| 192 ASSERT_EQ(status.sync_protocol_error.error_description, | 192 ASSERT_EQ(status.sync_protocol_error.error_description, |
| 193 protocol_error.error_description); | 193 protocol_error.error_description); |
| 194 } | 194 } |
| 195 | 195 |
| 196 // TODO(lipalani): Fix the typed_url dtc so this test case can pass. | 196 // TODO(lipalani): Fix the typed_url dtc so this test case can pass. |
| 197 IN_PROC_BROWSER_TEST_F(LegacySyncErrorTest, | 197 IN_PROC_BROWSER_TEST_F(LegacySyncErrorTest, |
| 198 DISABLED_DisableDatatypeWhileRunning) { | 198 DISABLED_DisableDatatypeWhileRunning) { |
| 199 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 199 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 200 syncer::ModelTypeSet synced_datatypes = | 200 syncer::ModelTypeSet synced_datatypes = |
| 201 GetSyncService((0))->GetPreferredDataTypes(); | 201 GetSyncService((0))->GetPreferredDataTypes(); |
| 202 ASSERT_TRUE(synced_datatypes.Has(syncer::TYPED_URLS)); | 202 ASSERT_TRUE(synced_datatypes.Has(syncer::TYPED_URLS)); |
| 203 GetProfile(0)->GetPrefs()->SetBoolean( | 203 GetProfile(0)->GetPrefs()->SetBoolean( |
| 204 prefs::kSavingBrowserHistoryDisabled, true); | 204 prefs::kSavingBrowserHistoryDisabled, true); |
| 205 | 205 |
| 206 synced_datatypes = GetSyncService((0))->GetPreferredDataTypes(); | 206 synced_datatypes = GetSyncService((0))->GetPreferredDataTypes(); |
| 207 ASSERT_FALSE(synced_datatypes.Has(syncer::TYPED_URLS)); | 207 ASSERT_FALSE(synced_datatypes.Has(syncer::TYPED_URLS)); |
| 208 | 208 |
| 209 const BookmarkNode* node1 = AddFolder(0, 0, L"title1"); | 209 const BookmarkNode* node1 = AddFolder(0, 0, "title1"); |
| 210 SetTitle(0, node1, L"new_title1"); | 210 SetTitle(0, node1, "new_title1"); |
| 211 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 211 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); |
| 212 // TODO(lipalani)" Verify initial sync ended for typed url is false. | 212 // TODO(lipalani)" Verify initial sync ended for typed url is false. |
| 213 } | 213 } |
| 214 | 214 |
| 215 } // namespace | 215 } // namespace |
| OLD | NEW |