Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1055)

Side by Side Diff: chrome/browser/sync/test/integration/sync_errors_test.cc

Issue 2551023006: [Sync] SyncEngine 1.5: Fix all backend references in PSS. (Closed)
Patch Set: Fix Android. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/macros.h" 5 #include "base/macros.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "build/build_config.h" 7 #include "build/build_config.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 20 matching lines...) Expand all
31 : SingleClientStatusChangeChecker(service) {} 31 : SingleClientStatusChangeChecker(service) {}
32 32
33 bool IsExitConditionSatisfied() override { 33 bool IsExitConditionSatisfied() override {
34 return !service()->IsSetupInProgress() && 34 return !service()->IsSetupInProgress() &&
35 !service()->IsFirstSetupComplete(); 35 !service()->IsFirstSetupComplete();
36 } 36 }
37 37
38 std::string GetDebugMessage() const override { return "Sync Disabled"; } 38 std::string GetDebugMessage() const override { return "Sync Disabled"; }
39 }; 39 };
40 40
41 class SyncBackendStoppedChecker : public SingleClientStatusChangeChecker { 41 class SyncEngineStoppedChecker : public SingleClientStatusChangeChecker {
42 public: 42 public:
43 explicit SyncBackendStoppedChecker(ProfileSyncService* service) 43 explicit SyncEngineStoppedChecker(ProfileSyncService* service)
44 : SingleClientStatusChangeChecker(service) {} 44 : SingleClientStatusChangeChecker(service) {}
45 45
46 // StatusChangeChecker implementation. 46 // StatusChangeChecker implementation.
47 bool IsExitConditionSatisfied() override { 47 bool IsExitConditionSatisfied() override {
48 return !service()->IsBackendInitialized(); 48 return !service()->IsEngineInitialized();
49 } 49 }
50 std::string GetDebugMessage() const override { return "Sync stopped"; } 50 std::string GetDebugMessage() const override { return "Sync stopped"; }
51 }; 51 };
52 52
53 class TypeDisabledChecker : public SingleClientStatusChangeChecker { 53 class TypeDisabledChecker : public SingleClientStatusChangeChecker {
54 public: 54 public:
55 explicit TypeDisabledChecker(ProfileSyncService* service, 55 explicit TypeDisabledChecker(ProfileSyncService* service,
56 syncer::ModelType type) 56 syncer::ModelType type)
57 : SingleClientStatusChangeChecker(service), type_(type) {} 57 : SingleClientStatusChangeChecker(service), type_(type) {}
58 58
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 SetTitle(0, node2, "new_title2"); 193 SetTitle(0, node2, "new_title2");
194 ASSERT_TRUE(SyncDisabledChecker(GetSyncService(0)).Wait()); 194 ASSERT_TRUE(SyncDisabledChecker(GetSyncService(0)).Wait());
195 ProfileSyncService::Status status; 195 ProfileSyncService::Status status;
196 GetSyncService(0)->QueryDetailedSyncStatus(&status); 196 GetSyncService(0)->QueryDetailedSyncStatus(&status);
197 ASSERT_EQ(status.sync_protocol_error.error_type, syncer::NOT_MY_BIRTHDAY); 197 ASSERT_EQ(status.sync_protocol_error.error_type, syncer::NOT_MY_BIRTHDAY);
198 ASSERT_EQ(status.sync_protocol_error.action, syncer::DISABLE_SYNC_ON_CLIENT); 198 ASSERT_EQ(status.sync_protocol_error.action, syncer::DISABLE_SYNC_ON_CLIENT);
199 ASSERT_EQ(status.sync_protocol_error.url, url); 199 ASSERT_EQ(status.sync_protocol_error.url, url);
200 ASSERT_EQ(status.sync_protocol_error.error_description, description); 200 ASSERT_EQ(status.sync_protocol_error.error_description, description);
201 } 201 }
202 202
203 // Tests that on receiving CLIENT_DATA_OBSOLETE sync backend gets restarted and 203 // Tests that on receiving CLIENT_DATA_OBSOLETE sync engine gets restarted and
204 // initialized with different cache_guld. 204 // initialized with different cache_guld.
205 IN_PROC_BROWSER_TEST_F(SyncErrorTest, ClientDataObsoleteTest) { 205 IN_PROC_BROWSER_TEST_F(SyncErrorTest, ClientDataObsoleteTest) {
206 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 206 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
207 207
208 const BookmarkNode* node1 = AddFolder(0, 0, "title1"); 208 const BookmarkNode* node1 = AddFolder(0, 0, "title1");
209 SetTitle(0, node1, "new_title1"); 209 SetTitle(0, node1, "new_title1");
210 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); 210 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait());
211 211
212 std::string description = "Not My Fault"; 212 std::string description = "Not My Fault";
213 std::string url = "www.google.com"; 213 std::string url = "www.google.com";
214 214
215 // Remember cache_guid before actionable error. 215 // Remember cache_guid before actionable error.
216 ProfileSyncService::Status status; 216 ProfileSyncService::Status status;
217 GetSyncService(0)->QueryDetailedSyncStatus(&status); 217 GetSyncService(0)->QueryDetailedSyncStatus(&status);
218 std::string old_cache_guid = status.sync_id; 218 std::string old_cache_guid = status.sync_id;
219 219
220 EXPECT_TRUE( 220 EXPECT_TRUE(
221 GetFakeServer()->TriggerError(sync_pb::SyncEnums::CLIENT_DATA_OBSOLETE)); 221 GetFakeServer()->TriggerError(sync_pb::SyncEnums::CLIENT_DATA_OBSOLETE));
222 222
223 // Trigger sync by making one more change. 223 // Trigger sync by making one more change.
224 const BookmarkNode* node2 = AddFolder(0, 0, "title2"); 224 const BookmarkNode* node2 = AddFolder(0, 0, "title2");
225 SetTitle(0, node2, "new_title2"); 225 SetTitle(0, node2, "new_title2");
226 226
227 ASSERT_TRUE(SyncBackendStoppedChecker(GetSyncService(0)).Wait()); 227 ASSERT_TRUE(SyncEngineStoppedChecker(GetSyncService(0)).Wait());
228 228
229 // Make server return SUCCESS so that sync can initialize. 229 // Make server return SUCCESS so that sync can initialize.
230 EXPECT_TRUE(GetFakeServer()->TriggerError(sync_pb::SyncEnums::SUCCESS)); 230 EXPECT_TRUE(GetFakeServer()->TriggerError(sync_pb::SyncEnums::SUCCESS));
231 231
232 ASSERT_TRUE(GetClient(0)->AwaitBackendInitialization()); 232 ASSERT_TRUE(GetClient(0)->AwaitEngineInitialization());
233 233
234 // Ensure cache_guid changed. 234 // Ensure cache_guid changed.
235 GetSyncService(0)->QueryDetailedSyncStatus(&status); 235 GetSyncService(0)->QueryDetailedSyncStatus(&status);
236 ASSERT_NE(old_cache_guid, status.sync_id); 236 ASSERT_NE(old_cache_guid, status.sync_id);
237 } 237 }
238 238
239 IN_PROC_BROWSER_TEST_F(SyncErrorTest, DisableDatatypeWhileRunning) { 239 IN_PROC_BROWSER_TEST_F(SyncErrorTest, DisableDatatypeWhileRunning) {
240 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 240 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
241 syncer::ModelTypeSet synced_datatypes = 241 syncer::ModelTypeSet synced_datatypes =
242 GetSyncService(0)->GetActiveDataTypes(); 242 GetSyncService(0)->GetActiveDataTypes();
243 ASSERT_TRUE(synced_datatypes.Has(syncer::TYPED_URLS)); 243 ASSERT_TRUE(synced_datatypes.Has(syncer::TYPED_URLS));
244 ASSERT_TRUE(synced_datatypes.Has(syncer::SESSIONS)); 244 ASSERT_TRUE(synced_datatypes.Has(syncer::SESSIONS));
245 GetProfile(0)->GetPrefs()->SetBoolean( 245 GetProfile(0)->GetPrefs()->SetBoolean(
246 prefs::kSavingBrowserHistoryDisabled, true); 246 prefs::kSavingBrowserHistoryDisabled, true);
247 247
248 // Wait for reconfigurations. 248 // Wait for reconfigurations.
249 ASSERT_TRUE( 249 ASSERT_TRUE(
250 TypeDisabledChecker(GetSyncService(0), syncer::TYPED_URLS).Wait()); 250 TypeDisabledChecker(GetSyncService(0), syncer::TYPED_URLS).Wait());
251 ASSERT_TRUE(TypeDisabledChecker(GetSyncService(0), syncer::SESSIONS).Wait()); 251 ASSERT_TRUE(TypeDisabledChecker(GetSyncService(0), syncer::SESSIONS).Wait());
252 252
253 const BookmarkNode* node1 = AddFolder(0, 0, "title1"); 253 const BookmarkNode* node1 = AddFolder(0, 0, "title1");
254 SetTitle(0, node1, "new_title1"); 254 SetTitle(0, node1, "new_title1");
255 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); 255 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait());
256 // TODO(lipalani): Verify initial sync ended for typed url is false. 256 // TODO(lipalani): Verify initial sync ended for typed url is false.
257 } 257 }
258 258
259 } // namespace 259 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698