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
3 // found in the LICENSE file.
5 #include "base/rand_util.h"
6 #include "base/run_loop.h"
7 #include "base/values.h"
8 #include "chrome/browser/policy/profile_policy_connector_factory.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/sync/test/integration/bookmarks_helper.h"
11 #include "chrome/browser/sync/test/integration/passwords_helper.h"
12 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
13 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h"
14 #include "chrome/browser/sync/test/integration/sync_test.h"
15 #include "components/bookmarks/browser/bookmark_node.h"
16 #include "components/policy/core/common/mock_configuration_policy_provider.h"
17 #include "components/policy/core/common/policy_map.h"
18 #include "policy/policy_constants.h"
19 #include "sync/internal_api/public/sessions/sync_session_snapshot.h"
20 #include "testing/gmock/include/gmock/gmock.h"
21 #include "ui/base/layout.h"
23 using bookmarks::BookmarkNode
;
24 using bookmarks_helper::AddFolder
;
25 using bookmarks_helper::AddURL
;
26 using bookmarks_helper::AllModelsMatch
;
27 using bookmarks_helper::AllModelsMatchVerifier
;
28 using bookmarks_helper::ContainsDuplicateBookmarks
;
29 using bookmarks_helper::CountBookmarksWithTitlesMatching
;
30 using bookmarks_helper::CreateFavicon
;
31 using bookmarks_helper::GetBookmarkBarNode
;
32 using bookmarks_helper::GetManagedNode
;
33 using bookmarks_helper::GetOtherNode
;
34 using bookmarks_helper::GetSyncedBookmarksNode
;
35 using bookmarks_helper::GetUniqueNodeByURL
;
36 using bookmarks_helper::HasNodeWithURL
;
37 using bookmarks_helper::IndexedFolderName
;
38 using bookmarks_helper::IndexedSubfolderName
;
39 using bookmarks_helper::IndexedSubsubfolderName
;
40 using bookmarks_helper::IndexedURL
;
41 using bookmarks_helper::IndexedURLTitle
;
42 using bookmarks_helper::Move
;
43 using bookmarks_helper::Remove
;
44 using bookmarks_helper::RemoveAll
;
45 using bookmarks_helper::ReverseChildOrder
;
46 using bookmarks_helper::SetFavicon
;
47 using bookmarks_helper::SetTitle
;
48 using bookmarks_helper::SetURL
;
49 using bookmarks_helper::SortChildren
;
50 using passwords_helper::SetDecryptionPassphrase
;
51 using passwords_helper::SetEncryptionPassphrase
;
52 using sync_integration_test_util::AwaitCommitActivityCompletion
;
53 using sync_integration_test_util::AwaitPassphraseAccepted
;
54 using sync_integration_test_util::AwaitPassphraseRequired
;
58 const char kGenericURL
[] = "http://www.host.ext:1234/path/filename";
59 const char kGenericURLTitle
[] = "URL Title";
60 const char kGenericFolderName
[] = "Folder Name";
61 const char kGenericSubfolderName
[] = "Subfolder Name";
62 const char kValidPassphrase
[] = "passphrase!";
66 class TwoClientBookmarksSyncTest
: public SyncTest
{
68 TwoClientBookmarksSyncTest() : SyncTest(TWO_CLIENT
) {}
69 ~TwoClientBookmarksSyncTest() override
{}
71 void TearDownInProcessBrowserTestFixture() override
{
72 SyncTest::TearDownInProcessBrowserTestFixture();
73 policy_provider_
.Shutdown();
77 // Needs to be deleted after all Profiles are deleted.
78 policy::MockConfigurationPolicyProvider policy_provider_
;
81 DISALLOW_COPY_AND_ASSIGN(TwoClientBookmarksSyncTest
);
84 class LegacyTwoClientBookmarksSyncTest
: public SyncTest
{
86 LegacyTwoClientBookmarksSyncTest() : SyncTest(TWO_CLIENT_LEGACY
) {}
87 ~LegacyTwoClientBookmarksSyncTest() override
{}
90 DISALLOW_COPY_AND_ASSIGN(LegacyTwoClientBookmarksSyncTest
);
93 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, Sanity
) {
94 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
95 ASSERT_TRUE(AllModelsMatchVerifier());
97 GURL
google_url("http://www.google.com");
98 ASSERT_TRUE(AddURL(0, "Google", google_url
) != NULL
);
99 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
100 ASSERT_TRUE(AddURL(1, "Yahoo", GURL("http://www.yahoo.com")) != NULL
);
101 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
102 ASSERT_TRUE(AllModelsMatchVerifier());
104 const BookmarkNode
* new_folder
= AddFolder(0, 2, "New Folder");
105 Move(0, GetUniqueNodeByURL(0, google_url
), new_folder
, 0);
106 SetTitle(0, GetBookmarkBarNode(0)->GetChild(0), "Yahoo!!");
107 ASSERT_TRUE(AddURL(0, GetBookmarkBarNode(0), 1, "CNN",
108 GURL("http://www.cnn.com")) != NULL
);
109 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
110 ASSERT_TRUE(AllModelsMatchVerifier());
112 ASSERT_TRUE(AddURL(1, "Facebook", GURL("http://www.facebook.com")) != NULL
);
113 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
114 ASSERT_TRUE(AllModelsMatchVerifier());
116 SortChildren(1, GetBookmarkBarNode(1));
117 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
118 ASSERT_TRUE(AllModelsMatchVerifier());
121 SetTitle(0, GetUniqueNodeByURL(0, google_url
), "Google++");
122 SetTitle(1, GetUniqueNodeByURL(1, google_url
), "Google--");
123 ASSERT_TRUE(AwaitQuiescence());
124 ASSERT_TRUE(AllModelsMatch());
127 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, SimultaneousURLChanges
) {
128 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
129 ASSERT_TRUE(AllModelsMatchVerifier());
131 GURL
initial_url("http://www.google.com");
132 GURL
second_url("http://www.google.com/abc");
133 GURL
third_url("http://www.google.com/def");
134 std::string title
= "Google";
136 ASSERT_TRUE(AddURL(0, title
, initial_url
) != NULL
);
137 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
141 0, GetUniqueNodeByURL(0, initial_url
), second_url
) != NULL
);
143 1, GetUniqueNodeByURL(1, initial_url
), third_url
) != NULL
);
144 ASSERT_TRUE(AwaitQuiescence());
145 ASSERT_TRUE(AllModelsMatch());
147 SetTitle(0, GetBookmarkBarNode(0)->GetChild(0), "Google1");
148 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
149 ASSERT_TRUE(AllModelsMatch());
152 // Test Scribe ID - 370558.
153 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, SC_AddFirstFolder
) {
154 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
155 ASSERT_TRUE(AllModelsMatchVerifier());
157 ASSERT_TRUE(AddFolder(0, kGenericFolderName
) != NULL
);
158 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
159 ASSERT_TRUE(AllModelsMatchVerifier());
162 // Test Scribe ID - 370559.
163 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
164 SC_AddFirstBMWithoutFavicon
) {
165 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
166 ASSERT_TRUE(AllModelsMatchVerifier());
168 ASSERT_TRUE(AddURL(0, kGenericURLTitle
, GURL(kGenericURL
)) != NULL
);
169 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
170 ASSERT_TRUE(AllModelsMatchVerifier());
173 // Test Scribe ID - 370489.
174 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, SC_AddFirstBMWithFavicon
) {
175 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
176 ASSERT_TRUE(AllModelsMatchVerifier());
178 const GURL
page_url(kGenericURL
);
179 const GURL
icon_url("http://www.google.com/favicon.ico");
181 const BookmarkNode
* bookmark
= AddURL(0, kGenericURLTitle
, page_url
);
183 ASSERT_TRUE(bookmark
!= NULL
);
184 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
185 SetFavicon(0, bookmark
, icon_url
, CreateFavicon(SK_ColorWHITE
),
186 bookmarks_helper::FROM_UI
);
187 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
188 ASSERT_TRUE(AllModelsMatchVerifier());
191 // Test that the history service logic for not losing the hidpi versions of
192 // favicons as a result of sync does not result in dropping sync updates.
193 // In particular, the synced 16x16 favicon bitmap should overwrite 16x16
194 // favicon bitmaps on all clients. (Though non-16x16 favicon bitmaps
196 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, SC_SetFaviconHiDPI
) {
197 // Set the supported scale factors to include 2x such that CreateFavicon()
198 // creates a favicon with hidpi representations and that methods in the
199 // FaviconService request hidpi favicons.
200 std::vector
<ui::ScaleFactor
> supported_scale_factors
;
201 supported_scale_factors
.push_back(ui::SCALE_FACTOR_100P
);
202 supported_scale_factors
.push_back(ui::SCALE_FACTOR_200P
);
203 ui::SetSupportedScaleFactors(supported_scale_factors
);
205 const GURL
page_url(kGenericURL
);
206 const GURL
icon_url1("http://www.google.com/favicon1.ico");
207 const GURL
icon_url2("http://www.google.com/favicon2.ico");
209 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
210 ASSERT_TRUE(AllModelsMatchVerifier());
212 const BookmarkNode
* bookmark0
= AddURL(0, kGenericURLTitle
, page_url
);
213 ASSERT_TRUE(bookmark0
!= NULL
);
214 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
215 SetFavicon(0, bookmark0
, icon_url1
, CreateFavicon(SK_ColorWHITE
),
216 bookmarks_helper::FROM_UI
);
217 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
218 ASSERT_TRUE(AllModelsMatchVerifier());
220 const BookmarkNode
* bookmark1
= GetUniqueNodeByURL(1, page_url
);
221 SetFavicon(1, bookmark1
, icon_url1
, CreateFavicon(SK_ColorBLUE
),
222 bookmarks_helper::FROM_UI
);
223 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
224 ASSERT_TRUE(AllModelsMatchVerifier());
226 SetFavicon(0, bookmark0
, icon_url2
, CreateFavicon(SK_ColorGREEN
),
227 bookmarks_helper::FROM_UI
);
228 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
229 ASSERT_TRUE(AllModelsMatchVerifier());
232 // Test Scribe ID - 370560.
233 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, SC_AddNonHTTPBMs
) {
234 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
235 ASSERT_TRUE(AllModelsMatchVerifier());
238 0, "FTP UR", GURL("ftp://user:password@host:1234/path")) != NULL
);
239 ASSERT_TRUE(AddURL(0, "File UR", GURL("file://host/path")) != NULL
);
240 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
241 ASSERT_TRUE(AllModelsMatchVerifier());
244 // Test Scribe ID - 370561.
245 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
246 SC_AddFirstBMUnderFolder
) {
247 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
248 ASSERT_TRUE(AllModelsMatchVerifier());
250 const BookmarkNode
* folder
= AddFolder(0, kGenericFolderName
);
251 ASSERT_TRUE(folder
!= NULL
);
253 0, folder
, 0, kGenericURLTitle
, GURL(kGenericURL
)) != NULL
);
254 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
255 ASSERT_TRUE(AllModelsMatchVerifier());
258 // Test Scribe ID - 370562.
259 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
260 SC_AddSeveralBMsUnderBMBarAndOtherBM
) {
261 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
262 ASSERT_TRUE(AllModelsMatchVerifier());
264 for (int i
= 0; i
< 20; ++i
) {
265 std::string title
= IndexedURLTitle(i
);
266 GURL url
= GURL(IndexedURL(i
));
267 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
269 0, GetOtherNode(0), i
, title
, url
) != NULL
);
271 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
272 ASSERT_TRUE(AllModelsMatchVerifier());
275 // Test Scribe ID - 370563.
276 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
277 SC_AddSeveralBMsAndFolders
) {
278 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
279 ASSERT_TRUE(AllModelsMatchVerifier());
281 for (int i
= 0; i
< 15; ++i
) {
282 if (base::RandDouble() > 0.6) {
283 std::string title
= IndexedURLTitle(i
);
284 GURL url
= GURL(IndexedURL(i
));
285 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
287 std::string title
= IndexedFolderName(i
);
288 const BookmarkNode
* folder
= AddFolder(0, i
, title
);
289 ASSERT_TRUE(folder
!= NULL
);
290 if (base::RandDouble() > 0.4) {
291 for (int i
= 0; i
< 20; ++i
) {
292 std::string title
= IndexedURLTitle(i
);
293 GURL url
= GURL(IndexedURL(i
));
295 AddURL(0, folder
, i
, title
, url
) != NULL
);
300 for (int i
= 0; i
< 10; i
++) {
301 std::string title
= IndexedURLTitle(i
);
302 GURL url
= GURL(IndexedURL(i
));
303 ASSERT_TRUE(AddURL(0, GetOtherNode(0), i
, title
, url
) != NULL
);
305 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
306 ASSERT_TRUE(AllModelsMatchVerifier());
309 // Test Scribe ID - 370641.
310 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
311 SC_DuplicateBMWithDifferentURLSameName
) {
312 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
313 ASSERT_TRUE(AllModelsMatchVerifier());
315 GURL url0
= GURL(IndexedURL(0));
316 GURL url1
= GURL(IndexedURL(1));
317 ASSERT_TRUE(AddURL(0, kGenericURLTitle
, url0
) != NULL
);
318 ASSERT_TRUE(AddURL(0, kGenericURLTitle
, url1
) != NULL
);
319 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
320 ASSERT_TRUE(AllModelsMatchVerifier());
323 // Test Scribe ID - 370639 - Add bookmarks with different name and same URL.
324 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
325 SC_DuplicateBookmarksWithSameURL
) {
326 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
327 ASSERT_TRUE(AllModelsMatchVerifier());
329 std::string title0
= IndexedURLTitle(0);
330 std::string title1
= IndexedURLTitle(1);
331 ASSERT_TRUE(AddURL(0, title0
, GURL(kGenericURL
)) != NULL
);
332 ASSERT_TRUE(AddURL(0, title1
, GURL(kGenericURL
)) != NULL
);
333 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
334 ASSERT_TRUE(AllModelsMatchVerifier());
337 // Test Scribe ID - 371817.
338 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, SC_RenameBMName
) {
339 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
340 ASSERT_TRUE(AllModelsMatchVerifier());
342 std::string title
= IndexedURLTitle(1);
343 const BookmarkNode
* bookmark
= AddURL(0, title
, GURL(kGenericURL
));
344 ASSERT_TRUE(bookmark
!= NULL
);
345 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
346 ASSERT_TRUE(AllModelsMatchVerifier());
348 std::string new_title
= IndexedURLTitle(2);
349 SetTitle(0, bookmark
, new_title
);
350 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
351 ASSERT_TRUE(AllModelsMatchVerifier());
354 // Test Scribe ID - 371822.
355 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, SC_RenameBMURL
) {
356 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
357 ASSERT_TRUE(AllModelsMatchVerifier());
359 GURL url
= GURL(IndexedURL(1));
360 const BookmarkNode
* bookmark
= AddURL(0, kGenericURLTitle
, url
);
361 ASSERT_TRUE(bookmark
!= NULL
);
362 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
363 ASSERT_TRUE(AllModelsMatchVerifier());
365 GURL new_url
= GURL(IndexedURL(2));
366 ASSERT_TRUE(SetURL(0, bookmark
, new_url
) != NULL
);
367 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
368 ASSERT_TRUE(AllModelsMatchVerifier());
372 // Test Scribe ID - 371818 - Renaming the same bookmark name twice.
373 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
374 SC_TwiceRenamingBookmarkName
) {
375 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
376 ASSERT_TRUE(AllModelsMatchVerifier());
378 std::string title
= IndexedURLTitle(1);
379 const BookmarkNode
* bookmark
= AddURL(0, title
, GURL(kGenericURL
));
380 ASSERT_TRUE(bookmark
!= NULL
);
381 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
382 ASSERT_TRUE(AllModelsMatchVerifier());
384 std::string new_title
= IndexedURLTitle(2);
385 SetTitle(0, bookmark
, new_title
);
386 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
387 ASSERT_TRUE(AllModelsMatchVerifier());
389 SetTitle(0, bookmark
, title
);
390 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
391 ASSERT_TRUE(AllModelsMatchVerifier());
394 // Test Scribe ID - 371823 - Renaming the same bookmark URL twice.
395 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
396 SC_TwiceRenamingBookmarkURL
) {
397 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
398 ASSERT_TRUE(AllModelsMatchVerifier());
400 GURL url
= GURL(IndexedURL(1));
401 const BookmarkNode
* bookmark
= AddURL(0, kGenericURLTitle
, url
);
402 ASSERT_TRUE(bookmark
!= NULL
);
403 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
404 ASSERT_TRUE(AllModelsMatchVerifier());
406 GURL new_url
= GURL(IndexedURL(2));
407 ASSERT_TRUE(SetURL(0, bookmark
, new_url
) != NULL
);
408 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
409 ASSERT_TRUE(AllModelsMatchVerifier());
411 ASSERT_TRUE(SetURL(0, bookmark
, url
) != NULL
);
412 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
413 ASSERT_TRUE(AllModelsMatchVerifier());
416 // Test Scribe ID - 371824.
417 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, SC_RenameBMFolder
) {
418 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
419 ASSERT_TRUE(AllModelsMatchVerifier());
421 std::string title
= IndexedFolderName(1);
422 const BookmarkNode
* folder
= AddFolder(0, title
);
424 0, folder
, 0, kGenericURLTitle
, GURL(kGenericURL
)) != NULL
);
425 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
426 ASSERT_TRUE(AllModelsMatchVerifier());
428 std::string new_title
= IndexedFolderName(2);
429 SetTitle(0, folder
, new_title
);
430 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
431 ASSERT_TRUE(AllModelsMatchVerifier());
434 // Test Scribe ID - 371825.
435 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, SC_RenameEmptyBMFolder
) {
436 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
437 ASSERT_TRUE(AllModelsMatchVerifier());
439 std::string title
= IndexedFolderName(1);
440 const BookmarkNode
* folder
= AddFolder(0, title
);
441 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
442 ASSERT_TRUE(AllModelsMatchVerifier());
444 std::string new_title
= IndexedFolderName(2);
445 SetTitle(0, folder
, new_title
);
446 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
447 ASSERT_TRUE(AllModelsMatchVerifier());
450 // Test Scribe ID - 371826.
451 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
452 SC_RenameBMFolderWithLongHierarchy
) {
453 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
454 ASSERT_TRUE(AllModelsMatchVerifier());
456 std::string title
= IndexedFolderName(1);
457 const BookmarkNode
* folder
= AddFolder(0, title
);
458 ASSERT_TRUE(folder
!= NULL
);
459 for (int i
= 0; i
< 120; ++i
) {
460 if (base::RandDouble() > 0.15) {
461 std::string title
= IndexedURLTitle(i
);
462 GURL url
= GURL(IndexedURL(i
));
463 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
465 std::string title
= IndexedSubfolderName(i
);
466 ASSERT_TRUE(AddFolder(0, folder
, i
, title
) != NULL
);
469 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
470 ASSERT_TRUE(AllModelsMatchVerifier());
472 std::string new_title
= IndexedFolderName(2);
473 SetTitle(0, folder
, new_title
);
474 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
475 ASSERT_TRUE(AllModelsMatchVerifier());
478 // Test Scribe ID - 371827.
479 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
480 SC_RenameBMFolderThatHasParentAndChildren
) {
481 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
482 ASSERT_TRUE(AllModelsMatchVerifier());
484 const BookmarkNode
* folder
= AddFolder(0, kGenericFolderName
);
485 ASSERT_TRUE(folder
!= NULL
);
486 for (int i
= 1; i
< 15; ++i
) {
487 std::string title
= IndexedURLTitle(i
);
488 GURL url
= GURL(IndexedURL(i
));
489 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
491 std::string title
= IndexedSubfolderName(1);
492 const BookmarkNode
* subfolder
= AddFolder(0, folder
, 0, title
);
493 for (int i
= 0; i
< 120; ++i
) {
494 if (base::RandDouble() > 0.15) {
495 std::string title
= IndexedURLTitle(i
);
496 GURL url
= GURL(IndexedURL(i
));
497 ASSERT_TRUE(AddURL(0, subfolder
, i
, title
, url
) != NULL
);
499 std::string title
= IndexedSubsubfolderName(i
);
500 ASSERT_TRUE(AddFolder(0, subfolder
, i
, title
) != NULL
);
503 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
504 ASSERT_TRUE(AllModelsMatchVerifier());
506 std::string new_title
= IndexedSubfolderName(2);
507 SetTitle(0, subfolder
, new_title
);
508 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
509 ASSERT_TRUE(AllModelsMatchVerifier());
512 // Test Scribe ID - 371828.
513 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, SC_RenameBMNameAndURL
) {
514 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
515 ASSERT_TRUE(AllModelsMatchVerifier());
517 GURL url
= GURL(IndexedURL(1));
518 std::string title
= IndexedURLTitle(1);
519 const BookmarkNode
* bookmark
= AddURL(0, title
, url
);
520 ASSERT_TRUE(bookmark
!= NULL
);
521 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
522 ASSERT_TRUE(AllModelsMatchVerifier());
524 GURL new_url
= GURL(IndexedURL(2));
525 std::string new_title
= IndexedURLTitle(2);
526 bookmark
= SetURL(0, bookmark
, new_url
);
527 ASSERT_TRUE(bookmark
!= NULL
);
528 SetTitle(0, bookmark
, new_title
);
529 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
530 ASSERT_TRUE(AllModelsMatchVerifier());
533 // Test Scribe ID - 371832.
534 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
535 SC_DeleteBMEmptyAccountAfterwards
) {
536 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
537 ASSERT_TRUE(AllModelsMatchVerifier());
540 0, kGenericURLTitle
, GURL(kGenericURL
)) != NULL
);
541 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
542 ASSERT_TRUE(AllModelsMatchVerifier());
544 Remove(0, GetBookmarkBarNode(0), 0);
545 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
546 ASSERT_TRUE(AllModelsMatchVerifier());
549 // Test Scribe ID - 371833.
550 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
551 SC_DelBMNonEmptyAccountAfterwards
) {
552 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
553 ASSERT_TRUE(AllModelsMatchVerifier());
555 for (int i
= 0; i
< 20; ++i
) {
556 std::string title
= IndexedURLTitle(i
);
557 GURL url
= GURL(IndexedURL(i
));
558 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
560 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
561 ASSERT_TRUE(AllModelsMatchVerifier());
563 Remove(0, GetBookmarkBarNode(0), 0);
564 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
565 ASSERT_TRUE(AllModelsMatchVerifier());
568 // Test Scribe ID - 371835.
569 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
570 SC_DelFirstBMUnderBMFoldNonEmptyFoldAfterwards
) {
571 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
572 ASSERT_TRUE(AllModelsMatchVerifier());
574 const BookmarkNode
* folder
= AddFolder(0, kGenericFolderName
);
575 ASSERT_TRUE(folder
!= NULL
);
576 for (int i
= 0; i
< 10; ++i
) {
577 std::string title
= IndexedURLTitle(i
);
578 GURL url
= GURL(IndexedURL(i
));
579 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
581 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
582 ASSERT_TRUE(AllModelsMatchVerifier());
584 Remove(0, folder
, 0);
585 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
586 ASSERT_TRUE(AllModelsMatchVerifier());
589 // Test Scribe ID - 371836.
590 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
591 SC_DelLastBMUnderBMFoldNonEmptyFoldAfterwards
) {
592 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
593 ASSERT_TRUE(AllModelsMatchVerifier());
595 const BookmarkNode
* folder
= AddFolder(0, kGenericFolderName
);
596 ASSERT_TRUE(folder
!= NULL
);
597 for (int i
= 0; i
< 10; ++i
) {
598 std::string title
= IndexedURLTitle(i
);
599 GURL url
= GURL(IndexedURL(i
));
600 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
602 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
603 ASSERT_TRUE(AllModelsMatchVerifier());
605 Remove(0, folder
, folder
->child_count() - 1);
606 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
607 ASSERT_TRUE(AllModelsMatchVerifier());
610 // Test Scribe ID - 371856.
611 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
612 SC_DelMiddleBMUnderBMFoldNonEmptyFoldAfterwards
) {
613 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
614 ASSERT_TRUE(AllModelsMatchVerifier());
616 const BookmarkNode
* folder
= AddFolder(0, kGenericFolderName
);
617 ASSERT_TRUE(folder
!= NULL
);
618 for (int i
= 0; i
< 10; ++i
) {
619 std::string title
= IndexedURLTitle(i
);
620 GURL url
= GURL(IndexedURL(i
));
621 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
623 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
624 ASSERT_TRUE(AllModelsMatchVerifier());
626 Remove(0, folder
, 4);
627 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
628 ASSERT_TRUE(AllModelsMatchVerifier());
631 // Test Scribe ID - 371857.
632 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
633 SC_DelBMsUnderBMFoldEmptyFolderAfterwards
) {
634 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
635 ASSERT_TRUE(AllModelsMatchVerifier());
637 const BookmarkNode
* folder
= AddFolder(0, kGenericFolderName
);
638 ASSERT_TRUE(folder
!= NULL
);
639 for (int i
= 0; i
< 10; ++i
) {
640 std::string title
= IndexedURLTitle(i
);
641 GURL url
= GURL(IndexedURL(i
));
642 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
644 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
645 ASSERT_TRUE(AllModelsMatchVerifier());
647 int child_count
= folder
->child_count();
648 for (int i
= 0; i
< child_count
; ++i
) {
649 Remove(0, folder
, 0);
651 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
652 ASSERT_TRUE(AllModelsMatchVerifier());
655 // Test Scribe ID - 371858.
656 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
657 SC_DelEmptyBMFoldEmptyAccountAfterwards
) {
658 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
659 ASSERT_TRUE(AllModelsMatchVerifier());
661 ASSERT_TRUE(AddFolder(0, kGenericFolderName
) != NULL
);
662 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
663 ASSERT_TRUE(AllModelsMatchVerifier());
665 Remove(0, GetBookmarkBarNode(0), 0);
666 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
667 ASSERT_TRUE(AllModelsMatchVerifier());
670 // Test Scribe ID - 371869.
671 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
672 SC_DelEmptyBMFoldNonEmptyAccountAfterwards
) {
673 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
674 ASSERT_TRUE(AllModelsMatchVerifier());
676 ASSERT_TRUE(AddFolder(0, kGenericFolderName
) != NULL
);
677 for (int i
= 1; i
< 15; ++i
) {
678 if (base::RandDouble() > 0.6) {
679 std::string title
= IndexedURLTitle(i
);
680 GURL url
= GURL(IndexedURL(i
));
681 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
683 std::string title
= IndexedFolderName(i
);
684 ASSERT_TRUE(AddFolder(0, i
, title
) != NULL
);
687 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
688 ASSERT_TRUE(AllModelsMatchVerifier());
690 Remove(0, GetBookmarkBarNode(0), 0);
691 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
692 ASSERT_TRUE(AllModelsMatchVerifier());
695 // Test Scribe ID - 371879.
696 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
697 SC_DelBMFoldWithBMsNonEmptyAccountAfterwards
) {
698 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
699 ASSERT_TRUE(AllModelsMatchVerifier());
701 ASSERT_TRUE(AddURL(0, kGenericURLTitle
, GURL(kGenericURL
)) != NULL
);
702 const BookmarkNode
* folder
= AddFolder(0, 1, kGenericFolderName
);
703 ASSERT_TRUE(folder
!= NULL
);
704 for (int i
= 2; i
< 10; ++i
) {
705 if (base::RandDouble() > 0.6) {
706 std::string title
= IndexedURLTitle(i
);
707 GURL url
= GURL(IndexedURL(i
));
708 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
710 std::string title
= IndexedFolderName(i
);
711 ASSERT_TRUE(AddFolder(0, i
, title
) != NULL
);
714 for (int i
= 0; i
< 15; ++i
) {
715 std::string title
= IndexedURLTitle(i
);
716 GURL url
= GURL(IndexedURL(i
));
717 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
719 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
720 ASSERT_TRUE(AllModelsMatchVerifier());
722 Remove(0, GetBookmarkBarNode(0), 1);
723 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
724 ASSERT_TRUE(AllModelsMatchVerifier());
727 // Test Scribe ID - 371880.
728 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
729 SC_DelBMFoldWithBMsAndBMFoldsNonEmptyACAfterwards
) {
730 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
731 ASSERT_TRUE(AllModelsMatchVerifier());
733 ASSERT_TRUE(AddURL(0, kGenericURLTitle
, GURL(kGenericURL
)) != NULL
);
734 const BookmarkNode
* folder
= AddFolder(0, 1, kGenericFolderName
);
735 ASSERT_TRUE(folder
!= NULL
);
736 for (int i
= 2; i
< 10; ++i
) {
737 if (base::RandDouble() > 0.6) {
738 std::string title
= IndexedURLTitle(i
);
739 GURL url
= GURL(IndexedURL(i
));
740 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
742 std::string title
= IndexedFolderName(i
);
743 ASSERT_TRUE(AddFolder(0, i
, title
) != NULL
);
746 for (int i
= 0; i
< 10; ++i
) {
747 if (base::RandDouble() > 0.6) {
748 std::string title
= IndexedURLTitle(i
);
749 GURL url
= GURL(IndexedURL(i
));
750 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
752 std::string title
= IndexedSubfolderName(i
);
753 const BookmarkNode
* subfolder
=
754 AddFolder(0, folder
, i
, title
);
755 ASSERT_TRUE(subfolder
!= NULL
);
756 if (base::RandDouble() > 0.3) {
757 for (int j
= 0; j
< 10; ++j
) {
758 if (base::RandDouble() > 0.6) {
759 std::string title
= IndexedURLTitle(j
);
760 GURL url
= GURL(IndexedURL(j
));
762 0, subfolder
, j
, title
, url
) != NULL
);
764 std::string title
= IndexedSubsubfolderName(j
);
765 ASSERT_TRUE(AddFolder(
766 0, subfolder
, j
, title
) != NULL
);
772 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
773 ASSERT_TRUE(AllModelsMatchVerifier());
775 Remove(0, GetBookmarkBarNode(0), 1);
776 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
777 ASSERT_TRUE(AllModelsMatchVerifier());
780 // Test Scribe ID - 371882.
781 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
782 SC_DelBMFoldWithParentAndChildrenBMsAndBMFolds
) {
783 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
784 ASSERT_TRUE(AllModelsMatchVerifier());
786 const BookmarkNode
* folder
= AddFolder(0, kGenericFolderName
);
787 ASSERT_TRUE(folder
!= NULL
);
788 for (int i
= 1; i
< 11; ++i
) {
789 std::string title
= IndexedURLTitle(i
);
790 GURL url
= GURL(IndexedURL(i
));
791 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
793 const BookmarkNode
* subfolder
=
794 AddFolder(0, folder
, 0, kGenericSubfolderName
);
795 ASSERT_TRUE(subfolder
!= NULL
);
796 for (int i
= 0; i
< 30; ++i
) {
797 if (base::RandDouble() > 0.2) {
798 std::string title
= IndexedURLTitle(i
);
799 GURL url
= GURL(IndexedURL(i
));
800 ASSERT_TRUE(AddURL(0, subfolder
, i
, title
, url
) != NULL
);
802 std::string title
= IndexedSubsubfolderName(i
);
803 ASSERT_TRUE(AddFolder(0, subfolder
, i
, title
) != NULL
);
806 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
807 ASSERT_TRUE(AllModelsMatchVerifier());
809 Remove(0, folder
, 0);
810 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
811 ASSERT_TRUE(AllModelsMatchVerifier());
814 // Test Scribe ID - 371931.
815 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
816 SC_ReverseTheOrderOfTwoBMs
) {
817 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
818 ASSERT_TRUE(AllModelsMatchVerifier());
820 GURL url0
= GURL(IndexedURL(0));
821 GURL url1
= GURL(IndexedURL(1));
822 std::string title0
= IndexedURLTitle(0);
823 std::string title1
= IndexedURLTitle(1);
824 const BookmarkNode
* bookmark0
= AddURL(0, 0, title0
, url0
);
825 const BookmarkNode
* bookmark1
= AddURL(0, 1, title1
, url1
);
826 ASSERT_TRUE(bookmark0
!= NULL
);
827 ASSERT_TRUE(bookmark1
!= NULL
);
828 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
829 ASSERT_TRUE(AllModelsMatchVerifier());
831 Move(0, bookmark0
, GetBookmarkBarNode(0), 2);
832 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
833 ASSERT_TRUE(AllModelsMatchVerifier());
836 // Test Scribe ID - 371933.
837 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, SC_ReverseTheOrderOf10BMs
) {
838 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
839 ASSERT_TRUE(AllModelsMatchVerifier());
841 for (int i
= 0; i
< 10; ++i
) {
842 std::string title
= IndexedURLTitle(i
);
843 GURL url
= GURL(IndexedURL(i
));
844 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
846 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
847 ASSERT_TRUE(AllModelsMatchVerifier());
849 ReverseChildOrder(0, GetBookmarkBarNode(0));
850 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
851 ASSERT_TRUE(AllModelsMatchVerifier());
854 // Test Scribe ID - 371954.
855 // flaky on Windows: http://crbug.com/412169
856 #if defined(OS_WIN) || defined(OS_MACOSX)
857 #define MAYBE_SC_MovingBMsFromBMBarToBMFolder DISABLED_SC_MovingBMsFromBMBarToBMFolder
859 #define MAYBE_SC_MovingBMsFromBMBarToBMFolder SC_MovingBMsFromBMBarToBMFolder
861 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
862 MAYBE_SC_MovingBMsFromBMBarToBMFolder
) {
863 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
864 ASSERT_TRUE(AllModelsMatchVerifier());
866 ASSERT_TRUE(AddURL(0, kGenericURLTitle
, GURL(kGenericURL
)) != NULL
);
867 const BookmarkNode
* folder
= AddFolder(0, 1, kGenericFolderName
);
868 ASSERT_TRUE(folder
!= NULL
);
869 for (int i
= 2; i
< 10; ++i
) {
870 std::string title
= IndexedURLTitle(i
);
871 GURL url
= GURL(IndexedURL(i
));
872 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
874 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
875 ASSERT_TRUE(AllModelsMatchVerifier());
877 int num_bookmarks_to_move
=
878 GetBookmarkBarNode(0)->child_count() - 2;
879 for (int i
= 0; i
< num_bookmarks_to_move
; ++i
) {
881 0, GetBookmarkBarNode(0)->GetChild(2), folder
, i
);
882 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
883 ASSERT_TRUE(AllModelsMatchVerifier());
887 // Test Scribe ID - 371957.
888 // flaky on Windows and Mac: http://crbug.com/412169
889 #if defined(OS_WIN) || defined(OS_MACOSX)
890 #define MAYBE_SC_MovingBMsFromBMFoldToBMBar DISABLED_SC_MovingBMsFromBMFoldToBMBar
892 #define MAYBE_SC_MovingBMsFromBMFoldToBMBar SC_MovingBMsFromBMFoldToBMBar
894 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
895 MAYBE_SC_MovingBMsFromBMFoldToBMBar
) {
896 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
897 ASSERT_TRUE(AllModelsMatchVerifier());
899 ASSERT_TRUE(AddURL(0, kGenericURLTitle
, GURL(kGenericURL
)) != NULL
);
900 const BookmarkNode
* folder
= AddFolder(0, 1, kGenericFolderName
);
901 ASSERT_TRUE(folder
!= NULL
);
902 for (int i
= 0; i
< 10; ++i
) {
903 std::string title
= IndexedURLTitle(i
);
904 GURL url
= GURL(IndexedURL(i
));
905 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
907 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
908 ASSERT_TRUE(AllModelsMatchVerifier());
910 int num_bookmarks_to_move
= folder
->child_count() - 2;
911 for (int i
= 0; i
< num_bookmarks_to_move
; ++i
) {
912 Move(0, folder
->GetChild(0), GetBookmarkBarNode(0), i
);
913 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
914 ASSERT_TRUE(AllModelsMatchVerifier());
918 // Test Scribe ID - 371961.
919 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
920 SC_MovingBMsFromParentBMFoldToChildBMFold
) {
921 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
922 ASSERT_TRUE(AllModelsMatchVerifier());
924 const BookmarkNode
* folder
= AddFolder(0, kGenericFolderName
);
925 ASSERT_TRUE(folder
!= NULL
);
926 for (int i
= 0; i
< 3; ++i
) {
927 std::string title
= IndexedURLTitle(i
);
928 GURL url
= GURL(IndexedURL(i
));
929 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
931 const BookmarkNode
* subfolder
=
932 AddFolder(0, folder
, 3, kGenericSubfolderName
);
933 ASSERT_TRUE(subfolder
!= NULL
);
934 for (int i
= 0; i
< 10; ++i
) {
935 std::string title
= IndexedURLTitle(i
+ 3);
936 GURL url
= GURL(IndexedURL(i
+ 3));
937 ASSERT_TRUE(AddURL(0, subfolder
, i
, title
, url
) != NULL
);
939 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
940 ASSERT_TRUE(AllModelsMatchVerifier());
942 for (int i
= 0; i
< 3; ++i
) {
943 GURL url
= GURL(IndexedURL(i
));
944 Move(0, GetUniqueNodeByURL(0, url
), subfolder
, i
+ 10);
946 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
947 ASSERT_TRUE(AllModelsMatchVerifier());
950 // Test Scribe ID - 371964.
951 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
952 SC_MovingBMsFromChildBMFoldToParentBMFold
) {
953 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
954 ASSERT_TRUE(AllModelsMatchVerifier());
956 const BookmarkNode
* folder
= AddFolder(0, kGenericFolderName
);
957 ASSERT_TRUE(folder
!= NULL
);
958 for (int i
= 0; i
< 3; ++i
) {
959 std::string title
= IndexedURLTitle(i
);
960 GURL url
= GURL(IndexedURL(i
));
961 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
963 const BookmarkNode
* subfolder
=
964 AddFolder(0, folder
, 3, kGenericSubfolderName
);
965 ASSERT_TRUE(subfolder
!= NULL
);
966 for (int i
= 0; i
< 5; ++i
) {
967 std::string title
= IndexedURLTitle(i
+ 3);
968 GURL url
= GURL(IndexedURL(i
+ 3));
969 ASSERT_TRUE(AddURL(0, subfolder
, i
, title
, url
) != NULL
);
971 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
972 ASSERT_TRUE(AllModelsMatchVerifier());
974 for (int i
= 0; i
< 3; ++i
) {
975 GURL url
= GURL(IndexedURL(i
+ 3));
976 Move(0, GetUniqueNodeByURL(0, url
), folder
, i
+ 4);
978 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
979 ASSERT_TRUE(AllModelsMatchVerifier());
982 // Test Scribe ID - 371967.
983 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, SC_HoistBMs10LevelUp
) {
984 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
985 ASSERT_TRUE(AllModelsMatchVerifier());
987 const BookmarkNode
* folder
= GetBookmarkBarNode(0);
988 const BookmarkNode
* folder_L0
= NULL
;
989 const BookmarkNode
* folder_L10
= NULL
;
990 for (int level
= 0; level
< 15; ++level
) {
991 int num_bookmarks
= base::RandInt(0, 9);
992 for (int i
= 0; i
< num_bookmarks
; ++i
) {
993 std::string title
= IndexedURLTitle(i
);
994 GURL url
= GURL(IndexedURL(i
));
995 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
997 std::string title
= IndexedFolderName(level
);
998 folder
= AddFolder(0, folder
, folder
->child_count(), title
);
999 ASSERT_TRUE(folder
!= NULL
);
1000 if (level
== 0) folder_L0
= folder
;
1001 if (level
== 10) folder_L10
= folder
;
1003 for (int i
= 0; i
< 3; ++i
) {
1004 std::string title
= IndexedURLTitle(i
+ 10);
1005 GURL url
= GURL(IndexedURL(i
+ 10));
1006 ASSERT_TRUE(AddURL(0, folder_L10
, i
, title
, url
) != NULL
);
1008 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1009 ASSERT_TRUE(AllModelsMatchVerifier());
1011 GURL url10
= GURL(IndexedURL(10));
1012 Move(0, GetUniqueNodeByURL(
1013 0, url10
), folder_L0
, folder_L0
->child_count());
1014 GURL url11
= GURL(IndexedURL(11));
1015 Move(0, GetUniqueNodeByURL(0, url11
), folder_L0
, 0);
1016 GURL url12
= GURL(IndexedURL(12));
1017 Move(0, GetUniqueNodeByURL(0, url12
), folder_L0
, 1);
1018 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1019 ASSERT_TRUE(AllModelsMatchVerifier());
1022 // Test Scribe ID - 371968.
1023 // Flaky. http://crbug.com/107744.
1024 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, SC_SinkBMs10LevelDown
) {
1025 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1026 ASSERT_TRUE(AllModelsMatchVerifier());
1028 const BookmarkNode
* folder
= GetBookmarkBarNode(0);
1029 const BookmarkNode
* folder_L0
= NULL
;
1030 const BookmarkNode
* folder_L10
= NULL
;
1031 for (int level
= 0; level
< 15; ++level
) {
1032 int num_bookmarks
= base::RandInt(0, 9);
1033 for (int i
= 0; i
< num_bookmarks
; ++i
) {
1034 std::string title
= IndexedURLTitle(i
);
1035 GURL url
= GURL(IndexedURL(i
));
1036 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
1038 std::string title
= IndexedFolderName(level
);
1039 folder
= AddFolder(0, folder
, folder
->child_count(), title
);
1040 ASSERT_TRUE(folder
!= NULL
);
1041 if (level
== 0) folder_L0
= folder
;
1042 if (level
== 10) folder_L10
= folder
;
1044 for (int i
= 0; i
< 3; ++i
) {
1045 std::string title
= IndexedURLTitle(i
+ 10);
1046 GURL url
= GURL(IndexedURL(i
+ 10));
1047 ASSERT_TRUE(AddURL(0, folder_L0
, 0, title
, url
) != NULL
);
1049 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1050 ASSERT_TRUE(AllModelsMatchVerifier());
1052 GURL url10
= GURL(IndexedURL(10));
1053 Move(0, GetUniqueNodeByURL(0, url10
), folder_L10
, folder_L10
->child_count());
1054 GURL url11
= GURL(IndexedURL(11));
1055 Move(0, GetUniqueNodeByURL(0, url11
), folder_L10
, 0);
1056 GURL url12
= GURL(IndexedURL(12));
1057 Move(0, GetUniqueNodeByURL(0, url12
), folder_L10
, 1);
1058 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1059 ASSERT_TRUE(AllModelsMatchVerifier());
1062 // Test Scribe ID - 371980.
1063 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1064 SC_SinkEmptyBMFold5LevelsDown
) {
1065 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1066 ASSERT_TRUE(AllModelsMatchVerifier());
1068 const BookmarkNode
* folder
= GetBookmarkBarNode(0);
1069 const BookmarkNode
* folder_L5
= NULL
;
1070 for (int level
= 0; level
< 15; ++level
) {
1071 int num_bookmarks
= base::RandInt(0, 9);
1072 for (int i
= 0; i
< num_bookmarks
; ++i
) {
1073 std::string title
= IndexedURLTitle(i
);
1074 GURL url
= GURL(IndexedURL(i
));
1075 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
1077 std::string title
= IndexedFolderName(level
);
1079 0, folder
, folder
->child_count(), title
);
1080 ASSERT_TRUE(folder
!= NULL
);
1081 if (level
== 5) folder_L5
= folder
;
1084 0, GetBookmarkBarNode(0)->child_count(), kGenericFolderName
);
1085 ASSERT_TRUE(folder
!= NULL
);
1086 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1087 ASSERT_TRUE(AllModelsMatchVerifier());
1089 Move(0, folder
, folder_L5
, folder_L5
->child_count());
1090 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1091 ASSERT_TRUE(AllModelsMatchVerifier());
1094 // Test Scribe ID - 371997.
1095 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1096 SC_SinkNonEmptyBMFold5LevelsDown
) {
1097 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1098 ASSERT_TRUE(AllModelsMatchVerifier());
1100 const BookmarkNode
* folder
= GetBookmarkBarNode(0);
1101 const BookmarkNode
* folder_L5
= NULL
;
1102 for (int level
= 0; level
< 6; ++level
) {
1103 int num_bookmarks
= base::RandInt(0, 9);
1104 for (int i
= 0; i
< num_bookmarks
; ++i
) {
1105 std::string title
= IndexedURLTitle(i
);
1106 GURL url
= GURL(IndexedURL(i
));
1107 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
1109 std::string title
= IndexedFolderName(level
);
1110 folder
= AddFolder(0, folder
, folder
->child_count(), title
);
1111 ASSERT_TRUE(folder
!= NULL
);
1112 if (level
== 5) folder_L5
= folder
;
1115 0, GetBookmarkBarNode(0)->child_count(), kGenericFolderName
);
1116 ASSERT_TRUE(folder
!= NULL
);
1117 for (int i
= 0; i
< 10; ++i
) {
1118 std::string title
= IndexedURLTitle(i
);
1119 GURL url
= GURL(IndexedURL(i
));
1120 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
1122 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1123 ASSERT_TRUE(AllModelsMatchVerifier());
1125 Move(0, folder
, folder_L5
, folder_L5
->child_count());
1126 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1127 ASSERT_TRUE(AllModelsMatchVerifier());
1130 // Test Scribe ID - 372006.
1131 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1132 SC_HoistFolder5LevelsUp
) {
1133 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1134 ASSERT_TRUE(AllModelsMatchVerifier());
1136 const BookmarkNode
* folder
= GetBookmarkBarNode(0);
1137 const BookmarkNode
* folder_L5
= NULL
;
1138 for (int level
= 0; level
< 6; ++level
) {
1139 int num_bookmarks
= base::RandInt(0, 9);
1140 for (int i
= 0; i
< num_bookmarks
; ++i
) {
1141 std::string title
= IndexedURLTitle(i
);
1142 GURL url
= GURL(IndexedURL(i
));
1143 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
1145 std::string title
= IndexedFolderName(level
);
1146 folder
= AddFolder(0, folder
, folder
->child_count(), title
);
1147 ASSERT_TRUE(folder
!= NULL
);
1148 if (level
== 5) folder_L5
= folder
;
1151 0, folder_L5
, folder_L5
->child_count(), kGenericFolderName
);
1152 ASSERT_TRUE(folder
!= NULL
);
1153 for (int i
= 0; i
< 10; ++i
) {
1154 std::string title
= IndexedURLTitle(i
);
1155 GURL url
= GURL(IndexedURL(i
));
1156 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
1158 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1159 ASSERT_TRUE(AllModelsMatchVerifier());
1161 Move(0, folder
, GetBookmarkBarNode(0), GetBookmarkBarNode(0)->child_count());
1162 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1163 ASSERT_TRUE(AllModelsMatchVerifier());
1166 // Test Scribe ID - 372026.
1167 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1168 SC_ReverseTheOrderOfTwoBMFolders
) {
1169 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1170 ASSERT_TRUE(AllModelsMatchVerifier());
1172 for (int i
= 0; i
< 2; ++i
) {
1173 std::string title
= IndexedFolderName(i
);
1174 const BookmarkNode
* folder
= AddFolder(0, i
, title
);
1175 ASSERT_TRUE(folder
!= NULL
);
1176 for (int j
= 0; j
< 10; ++j
) {
1177 std::string title
= IndexedURLTitle(j
);
1178 GURL url
= GURL(IndexedURL(j
));
1179 ASSERT_TRUE(AddURL(0, folder
, j
, title
, url
) != NULL
);
1182 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1183 ASSERT_TRUE(AllModelsMatchVerifier());
1185 ReverseChildOrder(0, GetBookmarkBarNode(0));
1186 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1187 ASSERT_TRUE(AllModelsMatchVerifier());
1190 // Test Scribe ID - 372028.
1191 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1192 SC_ReverseTheOrderOfTenBMFolders
) {
1193 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1194 ASSERT_TRUE(AllModelsMatchVerifier());
1196 for (int i
= 0; i
< 10; ++i
) {
1197 std::string title
= IndexedFolderName(i
);
1198 const BookmarkNode
* folder
= AddFolder(0, i
, title
);
1199 ASSERT_TRUE(folder
!= NULL
);
1200 for (int j
= 0; j
< 10; ++j
) {
1201 std::string title
= IndexedURLTitle(1000 * i
+ j
);
1202 GURL url
= GURL(IndexedURL(j
));
1203 ASSERT_TRUE(AddURL(0, folder
, j
, title
, url
) != NULL
);
1206 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1207 ASSERT_TRUE(AllModelsMatchVerifier());
1209 ReverseChildOrder(0, GetBookmarkBarNode(0));
1210 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1211 ASSERT_TRUE(AllModelsMatchVerifier());
1214 // Test Scribe ID - 373379.
1215 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1216 MC_BiDirectionalPushAddingBM
) {
1217 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1218 ASSERT_TRUE(AllModelsMatchVerifier());
1221 for (int i
= 0; i
< 2; ++i
) {
1222 std::string title0
= IndexedURLTitle(2*i
);
1223 GURL url0
= GURL(IndexedURL(2*i
));
1224 ASSERT_TRUE(AddURL(0, title0
, url0
) != NULL
);
1225 std::string title1
= IndexedURLTitle(2*i
+1);
1226 GURL url1
= GURL(IndexedURL(2*i
+1));
1227 ASSERT_TRUE(AddURL(1, title1
, url1
) != NULL
);
1229 ASSERT_TRUE(AwaitQuiescence());
1230 ASSERT_TRUE(AllModelsMatch());
1231 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1234 // Test Scribe ID - 373503.
1235 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1236 MC_BiDirectionalPush_AddingSameBMs
) {
1237 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1238 ASSERT_TRUE(AllModelsMatchVerifier());
1240 // Note: When a racy commit is done with identical bookmarks, it is possible
1241 // for duplicates to exist after sync completes. See http://crbug.com/19769.
1243 for (int i
= 0; i
< 2; ++i
) {
1244 std::string title
= IndexedURLTitle(i
);
1245 GURL url
= GURL(IndexedURL(i
));
1246 ASSERT_TRUE(AddURL(0, title
, url
) != NULL
);
1247 ASSERT_TRUE(AddURL(1, title
, url
) != NULL
);
1249 ASSERT_TRUE(AwaitQuiescence());
1250 ASSERT_TRUE(AllModelsMatch());
1253 // Test Scribe ID - 373506.
1254 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1255 MC_BootStrapEmptyStateEverywhere
) {
1256 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1257 ASSERT_TRUE(AwaitQuiescence());
1258 ASSERT_TRUE(AllModelsMatchVerifier());
1261 // Test Scribe ID - 373505.
1262 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1263 MC_Merge_CaseInsensitivity_InNames
) {
1264 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
1267 const BookmarkNode
* folder0
= AddFolder(0, "Folder");
1268 ASSERT_TRUE(folder0
!= NULL
);
1269 ASSERT_TRUE(AddURL(0, folder0
, 0, "Bookmark 0", GURL(kGenericURL
)) != NULL
);
1270 ASSERT_TRUE(AddURL(0, folder0
, 1, "Bookmark 1", GURL(kGenericURL
)) != NULL
);
1271 ASSERT_TRUE(AddURL(0, folder0
, 2, "Bookmark 2", GURL(kGenericURL
)) != NULL
);
1273 const BookmarkNode
* folder1
= AddFolder(1, "fOlDeR");
1274 ASSERT_TRUE(folder1
!= NULL
);
1275 ASSERT_TRUE(AddURL(1, folder1
, 0, "bOoKmArK 0", GURL(kGenericURL
)) != NULL
);
1276 ASSERT_TRUE(AddURL(1, folder1
, 1, "BooKMarK 1", GURL(kGenericURL
)) != NULL
);
1277 ASSERT_TRUE(AddURL(1, folder1
, 2, "bOOKMARK 2", GURL(kGenericURL
)) != NULL
);
1279 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1280 ASSERT_TRUE(AwaitQuiescence());
1281 ASSERT_TRUE(AllModelsMatch());
1282 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1285 // Test Scribe ID - 373508.
1286 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1287 MC_SimpleMergeOfDifferentBMModels
) {
1288 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
1291 for (int i
= 0; i
< 3; ++i
) {
1292 std::string title
= IndexedURLTitle(i
);
1293 GURL url
= GURL(IndexedURL(i
));
1294 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
1295 ASSERT_TRUE(AddURL(1, i
, title
, url
) != NULL
);
1298 for (int i
= 3; i
< 10; ++i
) {
1299 std::string title0
= IndexedURLTitle(i
);
1300 GURL url0
= GURL(IndexedURL(i
));
1301 ASSERT_TRUE(AddURL(0, i
, title0
, url0
) != NULL
);
1302 std::string title1
= IndexedURLTitle(i
+7);
1303 GURL url1
= GURL(IndexedURL(i
+7));
1304 ASSERT_TRUE(AddURL(1, i
, title1
, url1
) != NULL
);
1307 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1308 ASSERT_TRUE(AwaitQuiescence());
1309 ASSERT_TRUE(AllModelsMatch());
1310 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1313 // Test Scribe ID - 386586.
1314 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1315 MC_MergeSimpleBMHierarchyUnderBMBar
) {
1316 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
1319 for (int i
= 0; i
< 3; ++i
) {
1320 std::string title
= IndexedURLTitle(i
);
1321 GURL url
= GURL(IndexedURL(i
));
1322 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
1323 ASSERT_TRUE(AddURL(1, i
, title
, url
) != NULL
);
1326 for (int i
= 3; i
< 10; ++i
) {
1327 std::string title
= IndexedURLTitle(i
);
1328 GURL url
= GURL(IndexedURL(i
));
1329 ASSERT_TRUE(AddURL(1, i
, title
, url
) != NULL
);
1332 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1333 ASSERT_TRUE(AwaitQuiescence());
1334 ASSERT_TRUE(AllModelsMatch());
1335 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1338 // Test Scribe ID - 386589.
1339 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1340 MC_MergeSimpleBMHierarchyEqualSetsUnderBMBar
) {
1341 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
1344 for (int i
= 0; i
< 3; ++i
) {
1345 std::string title
= IndexedURLTitle(i
);
1346 GURL url
= GURL(IndexedURL(i
));
1347 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
1348 ASSERT_TRUE(AddURL(1, i
, title
, url
) != NULL
);
1351 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1352 ASSERT_TRUE(AwaitQuiescence());
1353 ASSERT_TRUE(AllModelsMatch());
1354 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1357 // Test Scribe ID - 373504 - Merge bookmark folders with different bookmarks.
1358 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1359 MC_MergeBMFoldersWithDifferentBMs
) {
1360 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
1363 const BookmarkNode
* folder0
= AddFolder(0, kGenericFolderName
);
1364 ASSERT_TRUE(folder0
!= NULL
);
1365 const BookmarkNode
* folder1
= AddFolder(1, kGenericFolderName
);
1366 ASSERT_TRUE(folder1
!= NULL
);
1367 for (int i
= 0; i
< 2; ++i
) {
1368 std::string title0
= IndexedURLTitle(2*i
);
1369 GURL url0
= GURL(IndexedURL(2*i
));
1370 ASSERT_TRUE(AddURL(0, folder0
, i
, title0
, url0
) != NULL
);
1371 std::string title1
= IndexedURLTitle(2*i
+1);
1372 GURL url1
= GURL(IndexedURL(2*i
+1));
1373 ASSERT_TRUE(AddURL(1, folder1
, i
, title1
, url1
) != NULL
);
1375 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1376 ASSERT_TRUE(AwaitQuiescence());
1377 ASSERT_TRUE(AllModelsMatch());
1378 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1381 // Test Scribe ID - 373509 - Merge moderately complex bookmark models.
1382 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1383 MC_MergeDifferentBMModelsModeratelyComplex
) {
1384 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
1387 for (int i
= 0; i
< 25; ++i
) {
1388 std::string title0
= IndexedURLTitle(i
);
1389 GURL url0
= GURL(IndexedURL(i
));
1390 ASSERT_TRUE(AddURL(0, i
, title0
, url0
) != NULL
);
1391 std::string title1
= IndexedURLTitle(i
+50);
1392 GURL url1
= GURL(IndexedURL(i
+50));
1393 ASSERT_TRUE(AddURL(1, i
, title1
, url1
) != NULL
);
1395 for (int i
= 25; i
< 30; ++i
) {
1396 std::string title0
= IndexedFolderName(i
);
1397 const BookmarkNode
* folder0
= AddFolder(0, i
, title0
);
1398 ASSERT_TRUE(folder0
!= NULL
);
1399 std::string title1
= IndexedFolderName(i
+50);
1400 const BookmarkNode
* folder1
= AddFolder(1, i
, title1
);
1401 ASSERT_TRUE(folder1
!= NULL
);
1402 for (int j
= 0; j
< 5; ++j
) {
1403 std::string title0
= IndexedURLTitle(i
+5*j
);
1404 GURL url0
= GURL(IndexedURL(i
+5*j
));
1405 ASSERT_TRUE(AddURL(0, folder0
, j
, title0
, url0
) != NULL
);
1406 std::string title1
= IndexedURLTitle(i
+5*j
+50);
1407 GURL url1
= GURL(IndexedURL(i
+5*j
+50));
1408 ASSERT_TRUE(AddURL(1, folder1
, j
, title1
, url1
) != NULL
);
1411 for (int i
= 100; i
< 125; ++i
) {
1412 std::string title
= IndexedURLTitle(i
);
1413 GURL url
= GURL(IndexedURL(i
));
1414 ASSERT_TRUE(AddURL(0, title
, url
) != NULL
);
1415 ASSERT_TRUE(AddURL(1, title
, url
) != NULL
);
1417 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1418 ASSERT_TRUE(AwaitQuiescence());
1419 ASSERT_TRUE(AllModelsMatch());
1420 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1423 // TCM ID - 3675271 - Merge simple bookmark subset under bookmark folder.
1424 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1425 MC_MergeSimpleBMHierarchySubsetUnderBMFolder
) {
1426 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
1429 for (int i
= 0; i
< 2; ++i
) {
1430 const BookmarkNode
* folder
= AddFolder(i
, kGenericFolderName
);
1431 ASSERT_TRUE(folder
!= NULL
);
1432 for (int j
= 0; j
< 4; ++j
) {
1433 if (base::RandDouble() < 0.5) {
1434 std::string title
= IndexedURLTitle(j
);
1435 GURL url
= GURL(IndexedURL(j
));
1436 ASSERT_TRUE(AddURL(i
, folder
, j
, title
, url
) != NULL
);
1438 std::string title
= IndexedFolderName(j
);
1439 ASSERT_TRUE(AddFolder(i
, folder
, j
, title
) != NULL
);
1443 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1444 ASSERT_TRUE(AwaitQuiescence());
1445 ASSERT_TRUE(AllModelsMatch());
1446 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1449 // TCM ID - 3727284 - Merge subsets of bookmark under bookmark bar.
1450 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1451 MC_MergeSimpleBMHierarchySubsetUnderBookmarkBar
) {
1452 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
1455 for (int i
= 0; i
< 4; ++i
) {
1456 std::string title
= IndexedURLTitle(i
);
1457 GURL url
= GURL(IndexedURL(i
));
1458 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
1461 for (int j
= 0; j
< 2; ++j
) {
1462 std::string title
= IndexedURLTitle(j
);
1463 GURL url
= GURL(IndexedURL(j
));
1464 ASSERT_TRUE(AddURL(1, j
, title
, url
) != NULL
);
1467 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1468 ASSERT_TRUE(AwaitQuiescence());
1469 ASSERT_TRUE(AllModelsMatch());
1470 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1471 ASSERT_FALSE(ContainsDuplicateBookmarks(1));
1474 // TCM ID - 3659294 - Merge simple bookmark hierarchy under bookmark folder.
1475 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1476 MC_Merge_SimpleBMHierarchy_Under_BMFolder
) {
1477 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
1480 const BookmarkNode
* folder0
= AddFolder(0, 0, kGenericFolderName
);
1481 ASSERT_TRUE(folder0
!= NULL
);
1483 0, folder0
, 0, IndexedURLTitle(1), GURL(IndexedURL(1))) != NULL
);
1484 ASSERT_TRUE(AddFolder(0, folder0
, 1, IndexedSubfolderName(2)) != NULL
);
1486 0, folder0
, 2, IndexedURLTitle(3), GURL(IndexedURL(3))) != NULL
);
1487 ASSERT_TRUE(AddFolder(0, folder0
, 3, IndexedSubfolderName(4)) != NULL
);
1489 const BookmarkNode
* folder1
= AddFolder(1, 0, kGenericFolderName
);
1490 ASSERT_TRUE(folder1
!= NULL
);
1491 ASSERT_TRUE(AddFolder(1, folder1
, 0, IndexedSubfolderName(0)) != NULL
);
1492 ASSERT_TRUE(AddFolder(1, folder1
, 1, IndexedSubfolderName(2)) != NULL
);
1494 1, folder1
, 2, IndexedURLTitle(3), GURL(IndexedURL(3))) != NULL
);
1495 ASSERT_TRUE(AddFolder(1, folder1
, 3, IndexedSubfolderName(5)) != NULL
);
1497 1, folder1
, 4, IndexedURLTitle(1), GURL(IndexedURL(1))) != NULL
);
1499 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1500 ASSERT_TRUE(AwaitQuiescence());
1501 ASSERT_TRUE(AllModelsMatch());
1502 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1505 // TCM ID - 3711273 - Merge disjoint sets of bookmark hierarchy under bookmark
1507 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1508 MC_Merge_SimpleBMHierarchy_DisjointSets_Under_BMFolder
) {
1509 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
1512 const BookmarkNode
* folder0
=
1513 AddFolder(0, 0, kGenericFolderName
);
1514 ASSERT_TRUE(folder0
!= NULL
);
1516 0, folder0
, 0, IndexedURLTitle(1), GURL(IndexedURL(1))) != NULL
);
1517 ASSERT_TRUE(AddFolder(0, folder0
, 1, IndexedSubfolderName(2)) != NULL
);
1519 0, folder0
, 2, IndexedURLTitle(3), GURL(IndexedURL(3))) != NULL
);
1520 ASSERT_TRUE(AddFolder(0, folder0
, 3, IndexedSubfolderName(4)) != NULL
);
1522 const BookmarkNode
* folder1
= AddFolder(1, 0, kGenericFolderName
);
1523 ASSERT_TRUE(folder1
!= NULL
);
1524 ASSERT_TRUE(AddFolder(1, folder1
, 0, IndexedSubfolderName(5)) != NULL
);
1525 ASSERT_TRUE(AddFolder(1, folder1
, 1, IndexedSubfolderName(6)) != NULL
);
1527 1, folder1
, 2, IndexedURLTitle(7), GURL(IndexedURL(7))) != NULL
);
1529 1, folder1
, 3, IndexedURLTitle(8), GURL(IndexedURL(8))) != NULL
);
1531 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1532 ASSERT_TRUE(AwaitQuiescence());
1533 ASSERT_TRUE(AllModelsMatch());
1534 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1537 // TCM ID - 3639296 - Merge disjoint sets of bookmark hierarchy under bookmark
1539 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1540 MC_Merge_SimpleBMHierarchy_DisjointSets_Under_BookmarkBar
) {
1541 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
1544 for (int i
= 0; i
< 3; ++i
) {
1545 std::string title
= IndexedURLTitle(i
+1);
1546 GURL url
= GURL(IndexedURL(i
+1));
1547 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
1550 for (int j
= 0; j
< 3; ++j
) {
1551 std::string title
= IndexedURLTitle(j
+4);
1552 GURL url
= GURL(IndexedURL(j
+4));
1553 ASSERT_TRUE(AddURL(0, j
, title
, url
) != NULL
);
1556 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1557 ASSERT_TRUE(AwaitQuiescence());
1558 ASSERT_TRUE(AllModelsMatch());
1559 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1562 // TCM ID - 3616282 - Merge sets of duplicate bookmarks under bookmark bar.
1563 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1564 MC_Merge_SimpleBMHierarchy_DuplicateBMs_Under_BMBar
) {
1565 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
1568 // Let's add duplicate set of bookmark {1,2,2,3,3,3,4,4,4,4} to client0.
1570 for (int i
= 1; i
< 5 ; ++i
) {
1571 for (int j
= 0; j
< i
; ++j
) {
1572 std::string title
= IndexedURLTitle(i
);
1573 GURL url
= GURL(IndexedURL(i
));
1574 ASSERT_TRUE(AddURL(0, node_index
, title
, url
) != NULL
);
1578 // Let's add a set of bookmarks {1,2,3,4} to client1.
1579 for (int i
= 0; i
< 4; ++i
) {
1580 std::string title
= IndexedURLTitle(i
+1);
1581 GURL url
= GURL(IndexedURL(i
+1));
1582 ASSERT_TRUE(AddURL(1, i
, title
, url
) != NULL
);
1585 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1586 ASSERT_TRUE(AwaitQuiescence());
1587 ASSERT_TRUE(AllModelsMatch());
1589 for (int i
= 1; i
< 5 ; ++i
) {
1590 ASSERT_TRUE(CountBookmarksWithTitlesMatching(1, IndexedURLTitle(i
)) == i
);
1594 // TCM ID - 6593872.
1595 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, DisableBookmarks
) {
1596 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1597 ASSERT_TRUE(AllModelsMatchVerifier());
1599 ASSERT_TRUE(GetClient(1)->DisableSyncForDatatype(syncer::BOOKMARKS
));
1600 ASSERT_TRUE(AddFolder(1, kGenericFolderName
) != NULL
);
1601 ASSERT_TRUE(AwaitQuiescence());
1602 ASSERT_FALSE(AllModelsMatch());
1604 ASSERT_TRUE(GetClient(1)->EnableSyncForDatatype(syncer::BOOKMARKS
));
1605 ASSERT_TRUE(AwaitQuiescence());
1606 ASSERT_TRUE(AllModelsMatch());
1609 // TCM ID - 7343544.
1610 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, DisableSync
) {
1611 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1612 ASSERT_TRUE(AllModelsMatchVerifier());
1614 ASSERT_TRUE(GetClient(1)->DisableSyncForAllDatatypes());
1615 ASSERT_TRUE(AddFolder(0, IndexedFolderName(0)) != NULL
);
1616 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0))));
1617 ASSERT_FALSE(AllModelsMatch());
1619 ASSERT_TRUE(AddFolder(1, IndexedFolderName(1)) != NULL
);
1620 ASSERT_FALSE(AllModelsMatch());
1622 ASSERT_TRUE(GetClient(1)->EnableSyncForAllDatatypes());
1623 ASSERT_TRUE(AwaitQuiescence());
1624 ASSERT_TRUE(AllModelsMatch());
1627 // TCM ID - 3662298 - Test adding duplicate folder - Both with different BMs
1629 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, MC_DuplicateFolders
) {
1630 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
1633 const BookmarkNode
* folder0
= AddFolder(0, kGenericFolderName
);
1634 ASSERT_TRUE(folder0
!= NULL
);
1635 const BookmarkNode
* folder1
= AddFolder(1, kGenericFolderName
);
1636 ASSERT_TRUE(folder1
!= NULL
);
1637 for (int i
= 0; i
< 5; ++i
) {
1638 std::string title0
= IndexedURLTitle(i
);
1639 GURL url0
= GURL(IndexedURL(i
));
1640 ASSERT_TRUE(AddURL(0, folder0
, i
, title0
, url0
) != NULL
);
1641 std::string title1
= IndexedURLTitle(i
+5);
1642 GURL url1
= GURL(IndexedURL(i
+5));
1643 ASSERT_TRUE(AddURL(1, folder1
, i
, title1
, url1
) != NULL
);
1646 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1647 ASSERT_TRUE(AwaitQuiescence());
1648 ASSERT_TRUE(AllModelsMatch());
1649 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1652 // This test fails when run with FakeServer and FakeServerInvalidationService.
1653 IN_PROC_BROWSER_TEST_F(LegacyTwoClientBookmarksSyncTest
, MC_DeleteBookmark
) {
1654 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1655 ASSERT_TRUE(GetClient(1)->DisableSyncForDatatype(syncer::BOOKMARKS
));
1657 const GURL
bar_url("http://example.com/bar");
1658 const GURL
other_url("http://example.com/other");
1660 ASSERT_TRUE(AddURL(0, GetBookmarkBarNode(0), 0, "bar", bar_url
) != NULL
);
1661 ASSERT_TRUE(AddURL(0, GetOtherNode(0), 0, "other", other_url
) != NULL
);
1663 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0))));
1665 ASSERT_TRUE(HasNodeWithURL(0, bar_url
));
1666 ASSERT_TRUE(HasNodeWithURL(0, other_url
));
1667 ASSERT_FALSE(HasNodeWithURL(1, bar_url
));
1668 ASSERT_FALSE(HasNodeWithURL(1, other_url
));
1670 Remove(0, GetBookmarkBarNode(0), 0);
1671 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0))));
1673 ASSERT_FALSE(HasNodeWithURL(0, bar_url
));
1674 ASSERT_TRUE(HasNodeWithURL(0, other_url
));
1676 ASSERT_TRUE(GetClient(1)->EnableSyncForDatatype(syncer::BOOKMARKS
));
1677 ASSERT_TRUE(AwaitQuiescence());
1679 ASSERT_FALSE(HasNodeWithURL(0, bar_url
));
1680 ASSERT_TRUE(HasNodeWithURL(0, other_url
));
1681 ASSERT_FALSE(HasNodeWithURL(1, bar_url
));
1682 ASSERT_TRUE(HasNodeWithURL(1, other_url
));
1685 // TCM ID - 3719307 - Test a scenario of updating the name of the same bookmark
1686 // from two clients at the same time.
1687 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1688 MC_BookmarkNameChangeConflict
) {
1689 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1691 const BookmarkNode
* folder0
= AddFolder(0, kGenericFolderName
);
1692 ASSERT_TRUE(folder0
!= NULL
);
1693 for (int i
= 0; i
< 3; ++i
) {
1694 std::string title
= IndexedURLTitle(i
);
1695 GURL url
= GURL(IndexedURL(i
));
1696 ASSERT_TRUE(AddURL(0, folder0
, i
, title
, url
) != NULL
);
1698 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1699 ASSERT_TRUE(AllModelsMatchVerifier());
1700 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1703 GURL
url(IndexedURL(0));
1704 SetTitle(0, GetUniqueNodeByURL(0, url
), "Title++");
1705 SetTitle(1, GetUniqueNodeByURL(1, url
), "Title--");
1707 ASSERT_TRUE(AwaitQuiescence());
1708 ASSERT_TRUE(AllModelsMatch());
1709 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1712 // TCM ID - 3672299 - Test a scenario of updating the URL of the same bookmark
1713 // from two clients at the same time.
1714 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1715 MC_BookmarkURLChangeConflict
) {
1716 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1718 const BookmarkNode
* folder0
= AddFolder(0, kGenericFolderName
);
1719 ASSERT_TRUE(folder0
!= NULL
);
1720 for (int i
= 0; i
< 3; ++i
) {
1721 std::string title
= IndexedURLTitle(i
);
1722 GURL url
= GURL(IndexedURL(i
));
1723 ASSERT_TRUE(AddURL(0, folder0
, i
, title
, url
) != NULL
);
1725 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1726 ASSERT_TRUE(AllModelsMatchVerifier());
1727 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1730 GURL
url(IndexedURL(0));
1732 0, GetUniqueNodeByURL(0, url
), GURL("http://www.google.com/00")));
1734 1, GetUniqueNodeByURL(1, url
), GURL("http://www.google.com/11")));
1736 ASSERT_TRUE(AwaitQuiescence());
1737 ASSERT_TRUE(AllModelsMatch());
1738 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1741 // TCM ID - 3699290 - Test a scenario of updating the BM Folder name from two
1742 // clients at the same time.
1743 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1744 MC_FolderNameChangeConflict
) {
1745 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
1748 const BookmarkNode
* folderA
[2];
1749 const BookmarkNode
* folderB
[2];
1750 const BookmarkNode
* folderC
[2];
1752 // Create empty folder A on both clients.
1753 folderA
[0] = AddFolder(0, IndexedFolderName(0));
1754 ASSERT_TRUE(folderA
[0] != NULL
);
1755 folderA
[1] = AddFolder(1, IndexedFolderName(0));
1756 ASSERT_TRUE(folderA
[1] != NULL
);
1758 // Create folder B with bookmarks on both clients.
1759 folderB
[0] = AddFolder(0, IndexedFolderName(1));
1760 ASSERT_TRUE(folderB
[0] != NULL
);
1761 folderB
[1] = AddFolder(1, IndexedFolderName(1));
1762 ASSERT_TRUE(folderB
[1] != NULL
);
1763 for (int i
= 0; i
< 3; ++i
) {
1764 std::string title
= IndexedURLTitle(i
);
1765 GURL url
= GURL(IndexedURL(i
));
1766 ASSERT_TRUE(AddURL(0, folderB
[0], i
, title
, url
) != NULL
);
1769 // Create folder C with bookmarks and subfolders on both clients.
1770 folderC
[0] = AddFolder(0, IndexedFolderName(2));
1771 ASSERT_TRUE(folderC
[0] != NULL
);
1772 folderC
[1] = AddFolder(1, IndexedFolderName(2));
1773 ASSERT_TRUE(folderC
[1] != NULL
);
1774 for (int i
= 0; i
< 3; ++i
) {
1775 std::string folder_name
= IndexedSubfolderName(i
);
1776 const BookmarkNode
* subfolder
= AddFolder(0, folderC
[0], i
, folder_name
);
1777 ASSERT_TRUE(subfolder
!= NULL
);
1778 for (int j
= 0; j
< 3; ++j
) {
1779 std::string title
= IndexedURLTitle(j
);
1780 GURL url
= GURL(IndexedURL(j
));
1781 ASSERT_TRUE(AddURL(0, subfolder
, j
, title
, url
) != NULL
);
1785 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1786 ASSERT_TRUE(AwaitQuiescence());
1787 ASSERT_TRUE(AllModelsMatch());
1788 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1790 // Simultaneously rename folder A on both clients.
1791 SetTitle(0, folderA
[0], "Folder A++");
1792 SetTitle(1, folderA
[1], "Folder A--");
1793 ASSERT_TRUE(AwaitQuiescence());
1794 ASSERT_TRUE(AllModelsMatch());
1795 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1797 // Simultaneously rename folder B on both clients.
1798 SetTitle(0, folderB
[0], "Folder B++");
1799 SetTitle(1, folderB
[1], "Folder B--");
1800 ASSERT_TRUE(AwaitQuiescence());
1801 ASSERT_TRUE(AllModelsMatch());
1802 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1804 // Simultaneously rename folder C on both clients.
1805 SetTitle(0, folderC
[0], "Folder C++");
1806 SetTitle(1, folderC
[1], "Folder C--");
1807 ASSERT_TRUE(AwaitQuiescence());
1808 ASSERT_TRUE(AllModelsMatch());
1809 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1812 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1813 SingleClientEnabledEncryption
) {
1814 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1815 ASSERT_TRUE(AllModelsMatchVerifier());
1817 ASSERT_TRUE(EnableEncryption(0));
1818 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1819 ASSERT_TRUE(IsEncryptionComplete(0));
1820 ASSERT_TRUE(IsEncryptionComplete(1));
1821 ASSERT_TRUE(AllModelsMatchVerifier());
1824 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1825 SingleClientEnabledEncryptionAndChanged
) {
1826 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1827 ASSERT_TRUE(AllModelsMatchVerifier());
1829 ASSERT_TRUE(EnableEncryption(0));
1830 ASSERT_TRUE(AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL
);
1831 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1832 ASSERT_TRUE(IsEncryptionComplete(0));
1833 ASSERT_TRUE(IsEncryptionComplete(1));
1834 ASSERT_TRUE(AllModelsMatchVerifier());
1837 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1838 BothClientsEnabledEncryption
) {
1839 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1840 ASSERT_TRUE(AllModelsMatchVerifier());
1842 ASSERT_TRUE(EnableEncryption(0));
1843 ASSERT_TRUE(EnableEncryption(1));
1844 ASSERT_TRUE(AwaitQuiescence());
1845 ASSERT_TRUE(IsEncryptionComplete(0));
1846 ASSERT_TRUE(IsEncryptionComplete(1));
1847 ASSERT_TRUE(AllModelsMatchVerifier());
1850 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1851 SingleClientEnabledEncryptionBothChanged
) {
1852 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1853 ASSERT_TRUE(AllModelsMatchVerifier());
1855 ASSERT_TRUE(EnableEncryption(0));
1856 ASSERT_TRUE(AwaitQuiescence());
1857 ASSERT_TRUE(IsEncryptionComplete(0));
1858 ASSERT_TRUE(IsEncryptionComplete(1));
1859 ASSERT_TRUE(AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL
);
1860 ASSERT_TRUE(AddURL(0, IndexedURLTitle(1), GURL(IndexedURL(1))) != NULL
);
1861 ASSERT_TRUE(AwaitQuiescence());
1862 ASSERT_TRUE(AllModelsMatchVerifier());
1863 ASSERT_TRUE(IsEncryptionComplete(0));
1864 ASSERT_TRUE(IsEncryptionComplete(1));
1867 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1868 SingleClientEnabledEncryptionAndChangedMultipleTimes
) {
1869 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1870 ASSERT_TRUE(AllModelsMatchVerifier());
1872 ASSERT_TRUE(AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL
);
1873 ASSERT_TRUE(EnableEncryption(0));
1874 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1875 ASSERT_TRUE(IsEncryptionComplete(0));
1876 ASSERT_TRUE(IsEncryptionComplete(1));
1877 ASSERT_TRUE(AllModelsMatchVerifier());
1879 ASSERT_TRUE(AddURL(0, IndexedURLTitle(1), GURL(IndexedURL(1))) != NULL
);
1880 ASSERT_TRUE(AddFolder(0, IndexedFolderName(0)) != NULL
);
1881 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1882 ASSERT_TRUE(AllModelsMatchVerifier());
1885 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1886 FirstClientEnablesEncryptionWithPassSecondChanges
) {
1887 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1888 ASSERT_TRUE(AllModelsMatchVerifier());
1890 // Add initial bookmarks.
1891 ASSERT_TRUE(AddURL(0, 0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL
);
1892 ASSERT_TRUE(AddURL(0, 1, IndexedURLTitle(1), GURL(IndexedURL(1))) != NULL
);
1893 ASSERT_TRUE(AddURL(0, 2, IndexedURLTitle(2), GURL(IndexedURL(2))) != NULL
);
1894 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1895 ASSERT_TRUE(AllModelsMatchVerifier());
1897 // Set a passphrase and enable encryption on Client 0. Client 1 will not
1898 // understand the bookmark updates.
1899 SetEncryptionPassphrase(0, kValidPassphrase
, ProfileSyncService::EXPLICIT
);
1900 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService((0))));
1901 ASSERT_TRUE(EnableEncryption(0));
1902 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1903 ASSERT_TRUE(IsEncryptionComplete(0));
1904 ASSERT_TRUE(IsEncryptionComplete(1));
1905 ASSERT_TRUE(GetSyncService((1))->IsPassphraseRequired());
1907 // Client 1 adds bookmarks between the first two and between the second two.
1908 ASSERT_TRUE(AddURL(0, 1, IndexedURLTitle(3), GURL(IndexedURL(3))) != NULL
);
1909 ASSERT_TRUE(AddURL(0, 3, IndexedURLTitle(4), GURL(IndexedURL(4))) != NULL
);
1910 EXPECT_FALSE(AllModelsMatchVerifier());
1911 EXPECT_FALSE(AllModelsMatch());
1913 // Set the passphrase. Everything should resolve.
1914 ASSERT_TRUE(AwaitPassphraseRequired(GetSyncService((1))));
1915 ASSERT_TRUE(SetDecryptionPassphrase(1, kValidPassphrase
));
1916 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService((1))));
1917 ASSERT_TRUE(AwaitQuiescence());
1918 EXPECT_TRUE(AllModelsMatch());
1920 GetClient(1)->GetLastSessionSnapshot().num_encryption_conflicts());
1922 // Ensure everything is syncing normally by appending a final bookmark.
1923 ASSERT_TRUE(AddURL(1, 5, IndexedURLTitle(5), GURL(IndexedURL(5))) != NULL
);
1924 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
1925 EXPECT_TRUE(AllModelsMatch());
1927 GetClient(1)->GetLastSessionSnapshot().num_encryption_conflicts());
1930 // Deliberately racy rearranging of bookmarks to test that our conflict resolver
1931 // code results in a consistent view across machines (no matter what the final
1933 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, RacyPositionChanges
) {
1934 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1935 ASSERT_TRUE(AllModelsMatchVerifier());
1937 // Add initial bookmarks.
1938 size_t num_bookmarks
= 5;
1939 for (size_t i
= 0; i
< num_bookmarks
; ++i
) {
1940 ASSERT_TRUE(AddURL(0, i
, IndexedURLTitle(i
), GURL(IndexedURL(i
))) != NULL
);
1943 // Once we make diverging changes the verifer is helpless.
1944 ASSERT_TRUE(AwaitQuiescence());
1945 ASSERT_TRUE(AllModelsMatchVerifier());
1948 // Make changes on client 0.
1949 for (size_t i
= 0; i
< num_bookmarks
; ++i
) {
1950 const BookmarkNode
* node
= GetUniqueNodeByURL(0, GURL(IndexedURL(i
)));
1951 int rand_pos
= base::RandInt(0, num_bookmarks
-1);
1952 DVLOG(1) << "Moving client 0's bookmark " << i
<< " to position "
1954 Move(0, node
, node
->parent(), rand_pos
);
1957 // Make changes on client 1.
1958 for (size_t i
= 0; i
< num_bookmarks
; ++i
) {
1959 const BookmarkNode
* node
= GetUniqueNodeByURL(1, GURL(IndexedURL(i
)));
1960 int rand_pos
= base::RandInt(0, num_bookmarks
-1);
1961 DVLOG(1) << "Moving client 1's bookmark " << i
<< " to position "
1963 Move(1, node
, node
->parent(), rand_pos
);
1966 ASSERT_TRUE(AwaitQuiescence());
1967 ASSERT_TRUE(AllModelsMatch());
1969 // Now make changes to client 1 first.
1970 for (size_t i
= 0; i
< num_bookmarks
; ++i
) {
1971 const BookmarkNode
* node
= GetUniqueNodeByURL(1, GURL(IndexedURL(i
)));
1972 int rand_pos
= base::RandInt(0, num_bookmarks
-1);
1973 DVLOG(1) << "Moving client 1's bookmark " << i
<< " to position "
1975 Move(1, node
, node
->parent(), rand_pos
);
1978 // Make changes on client 0.
1979 for (size_t i
= 0; i
< num_bookmarks
; ++i
) {
1980 const BookmarkNode
* node
= GetUniqueNodeByURL(0, GURL(IndexedURL(i
)));
1981 int rand_pos
= base::RandInt(0, num_bookmarks
-1);
1982 DVLOG(1) << "Moving client 0's bookmark " << i
<< " to position "
1984 Move(0, node
, node
->parent(), rand_pos
);
1987 ASSERT_TRUE(AwaitQuiescence());
1988 ASSERT_TRUE(AllModelsMatch());
1991 // Trigger the server side creation of Synced Bookmarks. Ensure both clients
1992 // remain syncing afterwards. Add bookmarks to the synced bookmarks folder
1993 // and ensure both clients receive the boomkmark.
1994 IN_PROC_BROWSER_TEST_F(LegacyTwoClientBookmarksSyncTest
,
1995 CreateSyncedBookmarks
) {
1996 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1997 ASSERT_TRUE(AllModelsMatchVerifier());
1999 TriggerCreateSyncedBookmarks();
2001 // Add a bookmark on Client 0 and ensure it syncs over. This will also trigger
2002 // both clients downloading the new Synced Bookmarks folder.
2003 ASSERT_TRUE(AddURL(0, "Google", GURL("http://www.google.com")));
2004 ASSERT_TRUE(AwaitQuiescence());
2005 ASSERT_TRUE(AllModelsMatch());
2007 // Now add a bookmark within the Synced Bookmarks folder and ensure it syncs
2009 const BookmarkNode
* synced_bookmarks
= GetSyncedBookmarksNode(0);
2010 ASSERT_TRUE(synced_bookmarks
);
2011 ASSERT_TRUE(AddURL(0, synced_bookmarks
, 0, "Google2",
2012 GURL("http://www.google2.com")));
2013 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
2014 ASSERT_TRUE(AllModelsMatch());
2017 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
2018 BookmarkAllNodesRemovedEvent
) {
2020 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
2021 ASSERT_TRUE(AllModelsMatchVerifier());
2027 // -> http://mail.google.com
2028 // -> http://www.google.com
2029 // -> http://news.google.com
2030 // -> http://yahoo.com
2031 // -> http://www.cnn.com
2035 // -> http://yahoo.com
2036 // -> http://gmail.com
2038 const BookmarkNode
* folder0
= AddFolder(0, GetOtherNode(0), 0, "folder0");
2039 const BookmarkNode
* tier1_a
= AddFolder(0, folder0
, 0, "tier1_a");
2040 ASSERT_TRUE(AddURL(0, folder0
, 1, "News", GURL("http://news.google.com")));
2041 ASSERT_TRUE(AddURL(0, folder0
, 2, "Yahoo", GURL("http://www.yahoo.com")));
2042 ASSERT_TRUE(AddURL(0, tier1_a
, 0, "Gmai", GURL("http://mail.google.com")));
2043 ASSERT_TRUE(AddURL(0, tier1_a
, 1, "Google", GURL("http://www.google.com")));
2045 AddURL(0, GetOtherNode(0), 1, "CNN", GURL("http://www.cnn.com")));
2047 ASSERT_TRUE(AddFolder(0, GetBookmarkBarNode(0), 0, "empty_folder"));
2048 const BookmarkNode
* folder1
=
2049 AddFolder(0, GetBookmarkBarNode(0), 1, "folder1");
2050 ASSERT_TRUE(AddURL(0, folder1
, 0, "Yahoo", GURL("http://www.yahoo.com")));
2052 AddURL(0, GetBookmarkBarNode(0), 2, "Gmai", GURL("http://gmail.com")));
2054 ASSERT_TRUE(AwaitQuiescence());
2055 ASSERT_TRUE(AllModelsMatch());
2060 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
2061 // Verify other node has no children now.
2062 EXPECT_EQ(0, GetOtherNode(0)->child_count());
2063 EXPECT_EQ(0, GetBookmarkBarNode(0)->child_count());
2064 ASSERT_TRUE(AllModelsMatch());
2067 // Verifies that managed bookmarks (installed by policy) don't get synced.
2068 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, ManagedBookmarks
) {
2069 // Make sure the first Profile has an overridden policy provider.
2070 EXPECT_CALL(policy_provider_
, IsInitializationComplete(testing::_
))
2071 .WillRepeatedly(testing::Return(true));
2072 policy::ProfilePolicyConnectorFactory::GetInstance()->PushProviderForTesting(
2076 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
2077 ASSERT_TRUE(AllModelsMatchVerifier());
2079 // Verify that there are no managed bookmarks at startup in either profile.
2080 // The Managed Bookmarks folder should not be visible at this stage.
2081 const BookmarkNode
* managed_node0
= GetManagedNode(0);
2082 ASSERT_TRUE(managed_node0
->empty());
2083 ASSERT_FALSE(managed_node0
->IsVisible());
2084 const BookmarkNode
* managed_node1
= GetManagedNode(1);
2085 ASSERT_TRUE(managed_node1
->empty());
2086 ASSERT_FALSE(managed_node1
->IsVisible());
2088 // Verify that the bookmark bar node is empty on both profiles too.
2089 const BookmarkNode
* bar_node0
= GetBookmarkBarNode(0);
2090 ASSERT_TRUE(bar_node0
->empty());
2091 ASSERT_TRUE(bar_node0
->IsVisible());
2092 const BookmarkNode
* bar_node1
= GetBookmarkBarNode(1);
2093 ASSERT_TRUE(bar_node1
->empty());
2094 ASSERT_TRUE(bar_node1
->IsVisible());
2096 // Verify that adding a bookmark is observed by the second Profile.
2097 GURL
google_url("http://www.google.com");
2098 ASSERT_TRUE(AddURL(0, "Google", google_url
) != NULL
);
2099 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
2100 ASSERT_TRUE(AllModelsMatchVerifier());
2101 ASSERT_EQ(1, bar_node0
->child_count());
2102 ASSERT_EQ(1, bar_node1
->child_count());
2104 // Set the ManagedBookmarks policy for the first Profile,
2105 // which will add one new managed bookmark.
2106 base::DictionaryValue
* bookmark
= new base::DictionaryValue();
2107 bookmark
->SetString("name", "Managed bookmark");
2108 bookmark
->SetString("url", "youtube.com");
2109 base::ListValue
* list
= new base::ListValue();
2110 list
->Append(bookmark
);
2111 policy::PolicyMap policy
;
2112 policy
.Set(policy::key::kManagedBookmarks
,
2113 policy::POLICY_LEVEL_MANDATORY
, policy::POLICY_SCOPE_USER
,
2115 policy_provider_
.UpdateChromePolicy(policy
);
2116 base::RunLoop().RunUntilIdle();
2118 // Now add another user bookmark and wait for it to sync.
2119 ASSERT_TRUE(AddURL(0, "Google 2", google_url
) != NULL
);
2120 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
2121 ASSERT_TRUE(AllModelsMatchVerifier());
2123 EXPECT_FALSE(GetSyncService(0)->HasUnrecoverableError());
2124 EXPECT_FALSE(GetSyncService(1)->HasUnrecoverableError());
2126 // Verify that the managed bookmark exists in the local model of the first
2127 // Profile, and has a child node.
2128 ASSERT_EQ(1, managed_node0
->child_count());
2129 ASSERT_TRUE(managed_node0
->IsVisible());
2130 EXPECT_EQ(GURL("http://youtube.com/"), managed_node0
->GetChild(0)->url());
2132 // Verify that the second Profile didn't get this node.
2133 ASSERT_EQ(0, managed_node1
->child_count());