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

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

Issue 8334030: Merge search engines sync data type with Preferences. Sync the default search provider. Add some ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Merge to TOT and fixed additional conflicts from rsimha. Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/memory/scoped_vector.h" 5 #include "base/memory/scoped_vector.h"
6 #include "chrome/browser/sessions/session_service.h" 6 #include "chrome/browser/sessions/session_service.h"
7 #include "chrome/browser/sync/profile_sync_service_harness.h" 7 #include "chrome/browser/sync/profile_sync_service_harness.h"
8 #include "chrome/browser/sync/sessions/session_state.h" 8 #include "chrome/browser/sync/sessions/session_state.h"
9 #include "chrome/browser/sync/test/integration/sync_test.h" 9 #include "chrome/browser/sync/test/integration/sync_test.h"
10 #include "chrome/browser/sync/test/integration/sessions_helper.h" 10 #include "chrome/browser/sync/test/integration/sessions_helper.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), 153 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1),
154 client0_windows.GetMutable())); 154 client0_windows.GetMutable()));
155 155
156 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); 156 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS));
157 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true); 157 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true);
158 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); 158 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted());
159 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 159 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
160 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); 160 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired());
161 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> 161 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()->
162 num_blocking_conflicting_updates); 162 num_blocking_conflicting_updates);
163 // We have 6 non-blocking conflicts due to the two meta nodes (one for each 163 // We have two meta nodes (one for each client), the one tab node, plus the
164 // client), the one tab node, and the six basic preference/themes/search 164 // basic preference/themes/search engines items.
165 // engines. 165 ASSERT_EQ(NumberOfDefaultSyncItems() + 3,
166 ASSERT_EQ(9, GetClient(1)->GetLastSessionSnapshot()-> 166 GetClient(1)->GetLastSessionSnapshot()->
167 num_conflicting_updates); // The encrypted nodes. 167 num_conflicting_updates); // The encrypted nodes.
168 168
169 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true); 169 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true);
170 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); 170 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted());
171 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); 171 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS));
172 172
173 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS)); 173 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS));
174 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); 174 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS));
175 // Get foreign session data from client 0 and 1. 175 // Get foreign session data from client 0 and 1.
176 SyncedSessionVector sessions1; 176 SyncedSessionVector sessions1;
(...skipping 13 matching lines...) Expand all
190 ASSERT_TRUE(CheckInitialState(0)); 190 ASSERT_TRUE(CheckInitialState(0));
191 ASSERT_TRUE(CheckInitialState(1)); 191 ASSERT_TRUE(CheckInitialState(1));
192 192
193 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); 193 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS));
194 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true); 194 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true);
195 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); 195 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted());
196 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 196 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
197 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); 197 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired());
198 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> 198 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()->
199 num_blocking_conflicting_updates); 199 num_blocking_conflicting_updates);
200 // We have eight non-blocking conflicts due to the two meta nodes (one for 200 // We have nine non-blocking conflicts due to the two meta nodes (one for
201 // each client), and the 6 basic preference/themes/search engines nodes. 201 // each client), plus the basic preference/themes/search engines nodes.
202 ASSERT_EQ(8, GetClient(1)->GetLastSessionSnapshot()-> 202 ASSERT_EQ(NumberOfDefaultSyncItems() + 2,
203 GetClient(1)->GetLastSessionSnapshot()->
203 num_conflicting_updates); // The encrypted nodes. 204 num_conflicting_updates); // The encrypted nodes.
204 205
205 ScopedWindowMap client0_windows; 206 ScopedWindowMap client0_windows;
206 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), 207 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1),
207 client0_windows.GetMutable())); 208 client0_windows.GetMutable()));
208 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 209 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
209 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> 210 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()->
210 num_blocking_conflicting_updates); 211 num_blocking_conflicting_updates);
211 ASSERT_EQ(9, GetClient(1)->GetLastSessionSnapshot()-> 212 ASSERT_EQ(NumberOfDefaultSyncItems() + 3,
213 GetClient(1)->GetLastSessionSnapshot()->
212 num_conflicting_updates); // The encrypted nodes. 214 num_conflicting_updates); // The encrypted nodes.
213 215
214 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true); 216 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true);
215 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); 217 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted());
216 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); 218 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS));
217 219
218 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS)); 220 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS));
219 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); 221 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS));
220 // Get foreign session data from client 0 and 1. 222 // Get foreign session data from client 0 and 1.
221 SyncedSessionVector sessions1; 223 SyncedSessionVector sessions1;
(...skipping 13 matching lines...) Expand all
235 ASSERT_TRUE(CheckInitialState(1)); 237 ASSERT_TRUE(CheckInitialState(1));
236 238
237 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); 239 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS));
238 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true); 240 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true);
239 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); 241 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted());
240 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 242 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
241 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); 243 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired());
242 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> 244 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()->
243 num_blocking_conflicting_updates); 245 num_blocking_conflicting_updates);
244 // We have two non-blocking conflicts due to the two meta nodes (one for each 246 // We have two non-blocking conflicts due to the two meta nodes (one for each
245 // client), and the 6 basic preference/themes/search engines nodes. 247 // client), plus the basic preference/themes/search engines nodes.
246 ASSERT_EQ(8, GetClient(1)->GetLastSessionSnapshot()-> 248 ASSERT_EQ(NumberOfDefaultSyncItems() + 2,
249 GetClient(1)->GetLastSessionSnapshot()->
247 num_conflicting_updates); // The encrypted nodes. 250 num_conflicting_updates); // The encrypted nodes.
248 251
249 // These changes are either made with the old passphrase or not encrypted at 252 // These changes are either made with the old passphrase or not encrypted at
250 // all depending on when client 0's changes are propagated. 253 // all depending on when client 0's changes are propagated.
251 ScopedWindowMap client1_windows; 254 ScopedWindowMap client1_windows;
252 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL1), 255 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL1),
253 client1_windows.GetMutable())); 256 client1_windows.GetMutable()));
254 257
255 // At this point we enter the passphrase, triggering a resync, in which the 258 // At this point we enter the passphrase, triggering a resync, in which the
256 // local changes of client 1 get overwritten for now. 259 // local changes of client 1 get overwritten for now.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 // Turn encryption on client 0. Client 1's foreign will be encrypted with the 291 // Turn encryption on client 0. Client 1's foreign will be encrypted with the
289 // new passphrase and synced back. It will be unable to decrypt it yet. 292 // new passphrase and synced back. It will be unable to decrypt it yet.
290 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); 293 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS));
291 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true); 294 GetClient(0)->service()->SetPassphrase(kValidPassphrase, true);
292 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); 295 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted());
293 ASSERT_TRUE(AwaitQuiescence()); 296 ASSERT_TRUE(AwaitQuiescence());
294 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); 297 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired());
295 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> 298 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()->
296 num_blocking_conflicting_updates); 299 num_blocking_conflicting_updates);
297 // We have three non-blocking conflicts due to the two meta nodes (one for 300 // We have three non-blocking conflicts due to the two meta nodes (one for
298 // each client), the one tab node, and the 6 basic preference/themes/search 301 // each client), the one tab node, plus the basic preference/themes/search
299 // engines nodes. 302 // engines nodes.
300 ASSERT_GE(9, GetClient(1)->GetLastSessionSnapshot()-> 303 ASSERT_GE(NumberOfDefaultSyncItems() + 3,
304 GetClient(1)->GetLastSessionSnapshot()->
301 num_conflicting_updates); // The encrypted nodes. 305 num_conflicting_updates); // The encrypted nodes.
302 306
303 // At this point we enter the passphrase, triggering a resync. 307 // At this point we enter the passphrase, triggering a resync.
304 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true); 308 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true);
305 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); 309 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted());
306 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); 310 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS));
307 311
308 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS)); 312 ASSERT_TRUE(IsEncrypted(0, syncable::SESSIONS));
309 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS)); 313 ASSERT_TRUE(IsEncrypted(1, syncable::SESSIONS));
310 // Client 0's foreign data should match client 1's local data. Client 1's 314 // Client 0's foreign data should match client 1's local data. Client 1's
(...skipping 21 matching lines...) Expand all
332 // These changes will sync over to client 1, who will be unable to decrypt 336 // These changes will sync over to client 1, who will be unable to decrypt
333 // them due to the missing passphrase. 337 // them due to the missing passphrase.
334 ScopedWindowMap client0_windows; 338 ScopedWindowMap client0_windows;
335 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), 339 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1),
336 client0_windows.GetMutable())); 340 client0_windows.GetMutable()));
337 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); 341 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS));
338 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 342 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
339 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> 343 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()->
340 num_blocking_conflicting_updates); 344 num_blocking_conflicting_updates);
341 // We have three non-blocking conflicts due to the two meta nodes (one for 345 // We have three non-blocking conflicts due to the two meta nodes (one for
342 // each client), the one tab node, and the 6 basic preference/themes/search 346 // each client), the one tab node, plus the basic preference/themes/search
343 // engines nodes. 347 // engines nodes.
344 ASSERT_EQ(9, GetClient(1)->GetLastSessionSnapshot()-> 348 ASSERT_EQ(NumberOfDefaultSyncItems() + 3,
349 GetClient(1)->GetLastSessionSnapshot()->
345 num_conflicting_updates); // The encrypted nodes. 350 num_conflicting_updates); // The encrypted nodes.
346 351
347 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true); 352 GetClient(1)->service()->SetPassphrase(kValidPassphrase, true);
348 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); 353 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted());
349 ASSERT_FALSE(GetClient(1)->service()->IsPassphraseRequired()); 354 ASSERT_FALSE(GetClient(1)->service()->IsPassphraseRequired());
350 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS)); 355 ASSERT_TRUE(GetClient(1)->WaitForTypeEncryption(syncable::SESSIONS));
351 356
352 // Open windows on client 1, which should automatically be encrypted. 357 // Open windows on client 1, which should automatically be encrypted.
353 ScopedWindowMap client1_windows; 358 ScopedWindowMap client1_windows;
354 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL2), 359 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL2),
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 ASSERT_FALSE(GetSessionData(1, &sessions1)); 426 ASSERT_FALSE(GetSessionData(1, &sessions1));
422 427
423 // Client 0 becomes active again with a new tab. 428 // Client 0 becomes active again with a new tab.
424 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL2), 429 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL2),
425 client0_windows.GetMutable())); 430 client0_windows.GetMutable()));
426 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 431 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
427 ASSERT_TRUE(GetSessionData(1, &sessions1)); 432 ASSERT_TRUE(GetSessionData(1, &sessions1));
428 ASSERT_EQ(1U, sessions1.size()); 433 ASSERT_EQ(1U, sessions1.size());
429 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.Get())); 434 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.Get()));
430 } 435 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698