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

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

Issue 308963006: Convert Sync BirthdayErrorTest to use FakeServer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 months 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
« no previous file with comments | « no previous file | chrome/browser/sync/test/integration/sync_test.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 26 matching lines...) Expand all
37 }; 37 };
38 38
39 bool AwaitSyncDisabled(ProfileSyncService* service) { 39 bool AwaitSyncDisabled(ProfileSyncService* service) {
40 SyncDisabledChecker checker(service); 40 SyncDisabledChecker checker(service);
41 checker.Wait(); 41 checker.Wait();
42 return !checker.TimedOut(); 42 return !checker.TimedOut();
43 } 43 }
44 44
45 class SyncErrorTest : public SyncTest { 45 class SyncErrorTest : public SyncTest {
46 public: 46 public:
47 // TODO(pvalenzuela): Switch to SINGLE_CLIENT once FakeServer 47 SyncErrorTest() : SyncTest(SINGLE_CLIENT) {}
48 // supports this scenario.
49 SyncErrorTest() : SyncTest(SINGLE_CLIENT_LEGACY) {}
50 virtual ~SyncErrorTest() {} 48 virtual ~SyncErrorTest() {}
51 49
52 private: 50 private:
53 DISALLOW_COPY_AND_ASSIGN(SyncErrorTest); 51 DISALLOW_COPY_AND_ASSIGN(SyncErrorTest);
54 }; 52 };
55 53
54 // TODO(pvalenzuela): Remove this class when all tests here are converted to
55 // use FakeServer.
56 class LegacySyncErrorTest : public SyncTest {
57 public:
58 LegacySyncErrorTest() : SyncTest(SINGLE_CLIENT_LEGACY) {}
59 virtual ~LegacySyncErrorTest() {}
60
61 private:
62 DISALLOW_COPY_AND_ASSIGN(LegacySyncErrorTest);
63 };
64
56 // Helper class that waits until the sync engine has hit an actionable error. 65 // Helper class that waits until the sync engine has hit an actionable error.
57 class ActionableErrorChecker : public SingleClientStatusChangeChecker { 66 class ActionableErrorChecker : public SingleClientStatusChangeChecker {
58 public: 67 public:
59 explicit ActionableErrorChecker(ProfileSyncService* service) 68 explicit ActionableErrorChecker(ProfileSyncService* service)
60 : SingleClientStatusChangeChecker(service) {} 69 : SingleClientStatusChangeChecker(service) {}
61 70
62 virtual ~ActionableErrorChecker() {} 71 virtual ~ActionableErrorChecker() {}
63 72
64 // Checks if an actionable error has been hit. Called repeatedly each time PSS 73 // Checks if an actionable error has been hit. Called repeatedly each time PSS
65 // notifies observers of a state change. 74 // notifies observers of a state change.
(...skipping 12 matching lines...) Expand all
78 DISALLOW_COPY_AND_ASSIGN(ActionableErrorChecker); 87 DISALLOW_COPY_AND_ASSIGN(ActionableErrorChecker);
79 }; 88 };
80 89
81 IN_PROC_BROWSER_TEST_F(SyncErrorTest, BirthdayErrorTest) { 90 IN_PROC_BROWSER_TEST_F(SyncErrorTest, BirthdayErrorTest) {
82 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 91 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
83 92
84 // 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.
85 const BookmarkNode* node1 = AddFolder(0, 0, L"title1"); 94 const BookmarkNode* node1 = AddFolder(0, 0, L"title1");
86 SetTitle(0, node1, L"new_title1"); 95 SetTitle(0, node1, L"new_title1");
87 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); 96 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0))));
88 TriggerBirthdayError(); 97 ASSERT_TRUE(GetFakeServer()->SetNewStoreBirthday("new store birthday"));
89 98
90 // Now make one more change so we will do another sync. 99 // Now make one more change so we will do another sync.
91 const BookmarkNode* node2 = AddFolder(0, 0, L"title2"); 100 const BookmarkNode* node2 = AddFolder(0, 0, L"title2");
92 SetTitle(0, node2, L"new_title2"); 101 SetTitle(0, node2, L"new_title2");
93 ASSERT_TRUE(AwaitSyncDisabled(GetSyncService((0)))); 102 ASSERT_TRUE(AwaitSyncDisabled(GetSyncService((0))));
94 } 103 }
95 104
96 IN_PROC_BROWSER_TEST_F(SyncErrorTest, ActionableErrorTest) { 105 IN_PROC_BROWSER_TEST_F(LegacySyncErrorTest, ActionableErrorTest) {
97 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 106 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
98 107
99 const BookmarkNode* node1 = AddFolder(0, 0, L"title1"); 108 const BookmarkNode* node1 = AddFolder(0, 0, L"title1");
100 SetTitle(0, node1, L"new_title1"); 109 SetTitle(0, node1, L"new_title1");
101 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); 110 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0))));
102 111
103 syncer::SyncProtocolError protocol_error; 112 syncer::SyncProtocolError protocol_error;
104 protocol_error.error_type = syncer::TRANSIENT_ERROR; 113 protocol_error.error_type = syncer::TRANSIENT_ERROR;
105 protocol_error.action = syncer::UPGRADE_CLIENT; 114 protocol_error.action = syncer::UPGRADE_CLIENT;
106 protocol_error.error_description = "Not My Fault"; 115 protocol_error.error_description = "Not My Fault";
(...skipping 12 matching lines...) Expand all
119 ProfileSyncService::Status status; 128 ProfileSyncService::Status status;
120 GetSyncService((0))->QueryDetailedSyncStatus(&status); 129 GetSyncService((0))->QueryDetailedSyncStatus(&status);
121 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);
122 ASSERT_EQ(status.sync_protocol_error.action, protocol_error.action); 131 ASSERT_EQ(status.sync_protocol_error.action, protocol_error.action);
123 ASSERT_EQ(status.sync_protocol_error.url, protocol_error.url); 132 ASSERT_EQ(status.sync_protocol_error.url, protocol_error.url);
124 ASSERT_EQ(status.sync_protocol_error.error_description, 133 ASSERT_EQ(status.sync_protocol_error.error_description,
125 protocol_error.error_description); 134 protocol_error.error_description);
126 } 135 }
127 136
128 // Disabled, http://crbug.com/351160 . 137 // Disabled, http://crbug.com/351160 .
129 IN_PROC_BROWSER_TEST_F(SyncErrorTest, DISABLED_ErrorWhileSettingUp) { 138 IN_PROC_BROWSER_TEST_F(LegacySyncErrorTest, DISABLED_ErrorWhileSettingUp) {
130 ASSERT_TRUE(SetupClients()); 139 ASSERT_TRUE(SetupClients());
131 140
132 syncer::SyncProtocolError protocol_error; 141 syncer::SyncProtocolError protocol_error;
133 protocol_error.error_type = syncer::TRANSIENT_ERROR; 142 protocol_error.error_type = syncer::TRANSIENT_ERROR;
134 protocol_error.error_description = "Not My Fault"; 143 protocol_error.error_description = "Not My Fault";
135 protocol_error.url = "www.google.com"; 144 protocol_error.url = "www.google.com";
136 145
137 if (GetSyncService(0)->auto_start_enabled()) { 146 if (GetSyncService(0)->auto_start_enabled()) {
138 // In auto start enabled platforms like chrome os we should be 147 // In auto start enabled platforms like chrome os we should be
139 // able to set up even if the first sync while setting up fails. 148 // able to set up even if the first sync while setting up fails.
140 // Trigger error on every 2 out of 3 requests. 149 // Trigger error on every 2 out of 3 requests.
141 TriggerSyncError(protocol_error, SyncTest::ERROR_FREQUENCY_TWO_THIRDS); 150 TriggerSyncError(protocol_error, SyncTest::ERROR_FREQUENCY_TWO_THIRDS);
142 // Now setup sync and it should succeed. 151 // Now setup sync and it should succeed.
143 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 152 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
144 } else { 153 } else {
145 // In Non auto start enabled environments if the setup sync fails then 154 // In Non auto start enabled environments if the setup sync fails then
146 // the setup would fail. So setup sync normally. 155 // the setup would fail. So setup sync normally.
147 ASSERT_TRUE(SetupSync()) << "Setup sync failed"; 156 ASSERT_TRUE(SetupSync()) << "Setup sync failed";
148 ASSERT_TRUE(GetClient(0)->DisableSyncForDatatype(syncer::AUTOFILL)); 157 ASSERT_TRUE(GetClient(0)->DisableSyncForDatatype(syncer::AUTOFILL));
149 158
150 // Trigger error on every 2 out of 3 requests. 159 // Trigger error on every 2 out of 3 requests.
151 TriggerSyncError(protocol_error, SyncTest::ERROR_FREQUENCY_TWO_THIRDS); 160 TriggerSyncError(protocol_error, SyncTest::ERROR_FREQUENCY_TWO_THIRDS);
152 161
153 // 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
154 // recover and setup succesfully on the third attempt. 163 // recover and setup succesfully on the third attempt.
155 ASSERT_TRUE(GetClient(0)->EnableSyncForDatatype(syncer::AUTOFILL)); 164 ASSERT_TRUE(GetClient(0)->EnableSyncForDatatype(syncer::AUTOFILL));
156 } 165 }
157 } 166 }
158 167
159 IN_PROC_BROWSER_TEST_F(SyncErrorTest, 168 IN_PROC_BROWSER_TEST_F(LegacySyncErrorTest,
160 BirthdayErrorUsingActionableErrorTest) { 169 BirthdayErrorUsingActionableErrorTest) {
161 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 170 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
162 171
163 const BookmarkNode* node1 = AddFolder(0, 0, L"title1"); 172 const BookmarkNode* node1 = AddFolder(0, 0, L"title1");
164 SetTitle(0, node1, L"new_title1"); 173 SetTitle(0, node1, L"new_title1");
165 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); 174 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0))));
166 175
167 syncer::SyncProtocolError protocol_error; 176 syncer::SyncProtocolError protocol_error;
168 protocol_error.error_type = syncer::NOT_MY_BIRTHDAY; 177 protocol_error.error_type = syncer::NOT_MY_BIRTHDAY;
169 protocol_error.action = syncer::DISABLE_SYNC_ON_CLIENT; 178 protocol_error.action = syncer::DISABLE_SYNC_ON_CLIENT;
170 protocol_error.error_description = "Not My Fault"; 179 protocol_error.error_description = "Not My Fault";
171 protocol_error.url = "www.google.com"; 180 protocol_error.url = "www.google.com";
172 TriggerSyncError(protocol_error, SyncTest::ERROR_FREQUENCY_ALWAYS); 181 TriggerSyncError(protocol_error, SyncTest::ERROR_FREQUENCY_ALWAYS);
173 182
174 // Now make one more change so we will do another sync. 183 // Now make one more change so we will do another sync.
175 const BookmarkNode* node2 = AddFolder(0, 0, L"title2"); 184 const BookmarkNode* node2 = AddFolder(0, 0, L"title2");
176 SetTitle(0, node2, L"new_title2"); 185 SetTitle(0, node2, L"new_title2");
177 ASSERT_TRUE(AwaitSyncDisabled(GetSyncService((0)))); 186 ASSERT_TRUE(AwaitSyncDisabled(GetSyncService((0))));
178 ProfileSyncService::Status status; 187 ProfileSyncService::Status status;
179 GetSyncService((0))->QueryDetailedSyncStatus(&status); 188 GetSyncService((0))->QueryDetailedSyncStatus(&status);
180 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);
181 ASSERT_EQ(status.sync_protocol_error.action, protocol_error.action); 190 ASSERT_EQ(status.sync_protocol_error.action, protocol_error.action);
182 ASSERT_EQ(status.sync_protocol_error.url, protocol_error.url); 191 ASSERT_EQ(status.sync_protocol_error.url, protocol_error.url);
183 ASSERT_EQ(status.sync_protocol_error.error_description, 192 ASSERT_EQ(status.sync_protocol_error.error_description,
184 protocol_error.error_description); 193 protocol_error.error_description);
185 } 194 }
186 195
187 // 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.
188 IN_PROC_BROWSER_TEST_F(SyncErrorTest, DISABLED_DisableDatatypeWhileRunning) { 197 IN_PROC_BROWSER_TEST_F(LegacySyncErrorTest,
198 DISABLED_DisableDatatypeWhileRunning) {
189 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 199 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
190 syncer::ModelTypeSet synced_datatypes = 200 syncer::ModelTypeSet synced_datatypes =
191 GetSyncService((0))->GetPreferredDataTypes(); 201 GetSyncService((0))->GetPreferredDataTypes();
192 ASSERT_TRUE(synced_datatypes.Has(syncer::TYPED_URLS)); 202 ASSERT_TRUE(synced_datatypes.Has(syncer::TYPED_URLS));
193 GetProfile(0)->GetPrefs()->SetBoolean( 203 GetProfile(0)->GetPrefs()->SetBoolean(
194 prefs::kSavingBrowserHistoryDisabled, true); 204 prefs::kSavingBrowserHistoryDisabled, true);
195 205
196 synced_datatypes = GetSyncService((0))->GetPreferredDataTypes(); 206 synced_datatypes = GetSyncService((0))->GetPreferredDataTypes();
197 ASSERT_FALSE(synced_datatypes.Has(syncer::TYPED_URLS)); 207 ASSERT_FALSE(synced_datatypes.Has(syncer::TYPED_URLS));
198 208
199 const BookmarkNode* node1 = AddFolder(0, 0, L"title1"); 209 const BookmarkNode* node1 = AddFolder(0, 0, L"title1");
200 SetTitle(0, node1, L"new_title1"); 210 SetTitle(0, node1, L"new_title1");
201 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); 211 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0))));
202 // TODO(lipalani)" Verify initial sync ended for typed url is false. 212 // TODO(lipalani)" Verify initial sync ended for typed url is false.
203 } 213 }
204 214
205 } // namespace 215 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/test/integration/sync_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698