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::CheckFaviconExpired
;
29 using bookmarks_helper::ContainsDuplicateBookmarks
;
30 using bookmarks_helper::CountBookmarksWithTitlesMatching
;
31 using bookmarks_helper::CreateFavicon
;
32 using bookmarks_helper::ExpireFavicon
;
33 using bookmarks_helper::GetBookmarkBarNode
;
34 using bookmarks_helper::GetManagedNode
;
35 using bookmarks_helper::GetOtherNode
;
36 using bookmarks_helper::GetSyncedBookmarksNode
;
37 using bookmarks_helper::GetUniqueNodeByURL
;
38 using bookmarks_helper::HasNodeWithURL
;
39 using bookmarks_helper::IndexedFolderName
;
40 using bookmarks_helper::IndexedSubfolderName
;
41 using bookmarks_helper::IndexedSubsubfolderName
;
42 using bookmarks_helper::IndexedURL
;
43 using bookmarks_helper::IndexedURLTitle
;
44 using bookmarks_helper::Move
;
45 using bookmarks_helper::Remove
;
46 using bookmarks_helper::RemoveAll
;
47 using bookmarks_helper::ReverseChildOrder
;
48 using bookmarks_helper::SetFavicon
;
49 using bookmarks_helper::SetTitle
;
50 using bookmarks_helper::SetURL
;
51 using bookmarks_helper::SortChildren
;
52 using passwords_helper::SetDecryptionPassphrase
;
53 using passwords_helper::SetEncryptionPassphrase
;
54 using sync_integration_test_util::AwaitCommitActivityCompletion
;
55 using sync_integration_test_util::AwaitPassphraseAccepted
;
56 using sync_integration_test_util::AwaitPassphraseRequired
;
60 const char kGenericURL
[] = "http://www.host.ext:1234/path/filename";
61 const char kGenericURLTitle
[] = "URL Title";
62 const char kGenericFolderName
[] = "Folder Name";
63 const char kGenericSubfolderName
[] = "Subfolder Name";
64 const char kValidPassphrase
[] = "passphrase!";
68 class TwoClientBookmarksSyncTest
: public SyncTest
{
70 TwoClientBookmarksSyncTest() : SyncTest(TWO_CLIENT
) {}
71 ~TwoClientBookmarksSyncTest() override
{}
73 void TearDownInProcessBrowserTestFixture() override
{
74 SyncTest::TearDownInProcessBrowserTestFixture();
75 policy_provider_
.Shutdown();
79 // Needs to be deleted after all Profiles are deleted.
80 policy::MockConfigurationPolicyProvider policy_provider_
;
83 DISALLOW_COPY_AND_ASSIGN(TwoClientBookmarksSyncTest
);
86 class LegacyTwoClientBookmarksSyncTest
: public SyncTest
{
88 LegacyTwoClientBookmarksSyncTest() : SyncTest(TWO_CLIENT_LEGACY
) {}
89 ~LegacyTwoClientBookmarksSyncTest() override
{}
92 DISALLOW_COPY_AND_ASSIGN(LegacyTwoClientBookmarksSyncTest
);
95 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, Sanity
) {
96 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
97 ASSERT_TRUE(AllModelsMatchVerifier());
99 GURL
google_url("http://www.google.com");
100 ASSERT_TRUE(AddURL(0, "Google", google_url
) != NULL
);
101 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
102 ASSERT_TRUE(AddURL(1, "Yahoo", GURL("http://www.yahoo.com")) != NULL
);
103 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
104 ASSERT_TRUE(AllModelsMatchVerifier());
106 const BookmarkNode
* new_folder
= AddFolder(0, 2, "New Folder");
107 Move(0, GetUniqueNodeByURL(0, google_url
), new_folder
, 0);
108 SetTitle(0, GetBookmarkBarNode(0)->GetChild(0), "Yahoo!!");
109 ASSERT_TRUE(AddURL(0, GetBookmarkBarNode(0), 1, "CNN",
110 GURL("http://www.cnn.com")) != NULL
);
111 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
112 ASSERT_TRUE(AllModelsMatchVerifier());
114 ASSERT_TRUE(AddURL(1, "Facebook", GURL("http://www.facebook.com")) != NULL
);
115 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
116 ASSERT_TRUE(AllModelsMatchVerifier());
118 SortChildren(1, GetBookmarkBarNode(1));
119 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
120 ASSERT_TRUE(AllModelsMatchVerifier());
123 SetTitle(0, GetUniqueNodeByURL(0, google_url
), "Google++");
124 SetTitle(1, GetUniqueNodeByURL(1, google_url
), "Google--");
125 ASSERT_TRUE(AwaitQuiescence());
126 ASSERT_TRUE(AllModelsMatch());
129 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, SimultaneousURLChanges
) {
130 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
131 ASSERT_TRUE(AllModelsMatchVerifier());
133 GURL
initial_url("http://www.google.com");
134 GURL
second_url("http://www.google.com/abc");
135 GURL
third_url("http://www.google.com/def");
136 std::string title
= "Google";
138 ASSERT_TRUE(AddURL(0, title
, initial_url
) != NULL
);
139 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
143 0, GetUniqueNodeByURL(0, initial_url
), second_url
) != NULL
);
145 1, GetUniqueNodeByURL(1, initial_url
), third_url
) != NULL
);
146 ASSERT_TRUE(AwaitQuiescence());
147 ASSERT_TRUE(AllModelsMatch());
149 SetTitle(0, GetBookmarkBarNode(0)->GetChild(0), "Google1");
150 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
151 ASSERT_TRUE(AllModelsMatch());
154 // Test Scribe ID - 370558.
155 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, SC_AddFirstFolder
) {
156 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
157 ASSERT_TRUE(AllModelsMatchVerifier());
159 ASSERT_TRUE(AddFolder(0, kGenericFolderName
) != NULL
);
160 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
161 ASSERT_TRUE(AllModelsMatchVerifier());
164 // Test Scribe ID - 370559.
165 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
166 SC_AddFirstBMWithoutFavicon
) {
167 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
168 ASSERT_TRUE(AllModelsMatchVerifier());
170 ASSERT_TRUE(AddURL(0, kGenericURLTitle
, GURL(kGenericURL
)) != NULL
);
171 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
172 ASSERT_TRUE(AllModelsMatchVerifier());
175 // Test Scribe ID - 370489.
176 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, SC_AddFirstBMWithFavicon
) {
177 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
178 ASSERT_TRUE(AllModelsMatchVerifier());
180 const GURL
page_url(kGenericURL
);
181 const GURL
icon_url("http://www.google.com/favicon.ico");
183 const BookmarkNode
* bookmark
= AddURL(0, kGenericURLTitle
, page_url
);
185 ASSERT_TRUE(bookmark
!= NULL
);
186 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
187 SetFavicon(0, bookmark
, icon_url
, CreateFavicon(SK_ColorWHITE
),
188 bookmarks_helper::FROM_UI
);
189 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
190 ASSERT_TRUE(AllModelsMatchVerifier());
193 // Test that the history service logic for not losing the hidpi versions of
194 // favicons as a result of sync does not result in dropping sync updates.
195 // In particular, the synced 16x16 favicon bitmap should overwrite 16x16
196 // favicon bitmaps on all clients. (Though non-16x16 favicon bitmaps
198 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, SC_SetFaviconHiDPI
) {
199 // Set the supported scale factors to include 2x such that CreateFavicon()
200 // creates a favicon with hidpi representations and that methods in the
201 // FaviconService request hidpi favicons.
202 std::vector
<ui::ScaleFactor
> supported_scale_factors
;
203 supported_scale_factors
.push_back(ui::SCALE_FACTOR_100P
);
204 supported_scale_factors
.push_back(ui::SCALE_FACTOR_200P
);
205 ui::SetSupportedScaleFactors(supported_scale_factors
);
207 const GURL
page_url(kGenericURL
);
208 const GURL
icon_url1("http://www.google.com/favicon1.ico");
209 const GURL
icon_url2("http://www.google.com/favicon2.ico");
211 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
212 ASSERT_TRUE(AllModelsMatchVerifier());
214 const BookmarkNode
* bookmark0
= AddURL(0, kGenericURLTitle
, page_url
);
215 ASSERT_TRUE(bookmark0
!= NULL
);
216 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
217 SetFavicon(0, bookmark0
, icon_url1
, CreateFavicon(SK_ColorWHITE
),
218 bookmarks_helper::FROM_UI
);
219 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
220 ASSERT_TRUE(AllModelsMatchVerifier());
222 const BookmarkNode
* bookmark1
= GetUniqueNodeByURL(1, page_url
);
223 SetFavicon(1, bookmark1
, icon_url1
, CreateFavicon(SK_ColorBLUE
),
224 bookmarks_helper::FROM_UI
);
225 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
226 ASSERT_TRUE(AllModelsMatchVerifier());
228 SetFavicon(0, bookmark0
, icon_url2
, CreateFavicon(SK_ColorGREEN
),
229 bookmarks_helper::FROM_UI
);
230 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
231 ASSERT_TRUE(AllModelsMatchVerifier());
234 // Test that if sync does not modify a favicon bitmap's data that it does not
235 // modify the favicon bitmap's "last updated time" either. This is important
236 // because the last updated time is used to determine whether a bookmark's
237 // favicon should be redownloaded when the web when the bookmark is visited.
238 // If sync prevents the "last updated time" from expiring, the favicon is
239 // never redownloaded from the web. (http://crbug.com/481414)
240 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
241 SC_UpdatingTitleDoesNotUpdateFaviconLastUpdatedTime
) {
242 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
244 std::vector
<ui::ScaleFactor
> supported_scale_factors
;
245 supported_scale_factors
.push_back(ui::SCALE_FACTOR_100P
);
246 ui::SetSupportedScaleFactors(supported_scale_factors
);
248 const GURL
page_url(kGenericURL
);
249 const GURL
icon_url("http://www.google.com/favicon.ico");
251 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
252 ASSERT_TRUE(AllModelsMatchVerifier());
254 const BookmarkNode
* bookmark0
= AddURL(0, kGenericURLTitle
, page_url
);
255 ASSERT_NE(bookmark0
, nullptr);
256 gfx::Image favicon0
= CreateFavicon(SK_ColorBLUE
);
257 ASSERT_FALSE(favicon0
.IsEmpty());
258 SetFavicon(0, bookmark0
, icon_url
, favicon0
, bookmarks_helper::FROM_UI
);
260 // Expire the favicon (e.g. as a result of the user "clearing browsing
261 // history from the beginning of time")
262 ExpireFavicon(0, bookmark0
);
263 CheckFaviconExpired(0, icon_url
);
265 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
266 ASSERT_TRUE(AllModelsMatchVerifier());
268 // Change the bookmark's title for profile 1. Changing the title will cause
269 // the bookmark's favicon data to be synced from profile 1 to profile 0 even
270 // though the favicon data did not change.
271 const std::string kNewTitle
= "New Title";
272 ASSERT_NE(kNewTitle
, kGenericURLTitle
);
273 const BookmarkNode
* bookmark1
= GetUniqueNodeByURL(1, page_url
);
274 SetTitle(1, bookmark1
, kNewTitle
);
275 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
276 ASSERT_TRUE(AllModelsMatchVerifier());
278 // The favicon for profile 0 should still be expired.
279 CheckFaviconExpired(0, icon_url
);
282 // When two bookmarks use the same icon URL, both bookmarks use the same row
283 // in the favicons table in the Favicons database. Test that when the favicon
284 // is updated for one bookmark it is also updated for the other bookmark. This
285 // ensures that sync has the most up to date data and prevents sync from
286 // reverting the newly updated bookmark favicon back to the old favicon.
288 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
289 SC_SetFaviconTwoBookmarksSameIconURL
) {
290 const GURL
page_url1("http://www.google.com/a");
291 const GURL
page_url2("http://www.google.com/b");
292 const GURL
icon_url("http://www.google.com/favicon.ico");
294 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
295 ASSERT_TRUE(AllModelsMatchVerifier());
297 const BookmarkNode
* bookmark01
= AddURL(0, kGenericURLTitle
, page_url1
);
298 ASSERT_TRUE(bookmark01
!= nullptr);
299 const BookmarkNode
* bookmark02
= AddURL(0, kGenericURLTitle
, page_url2
);
300 ASSERT_TRUE(bookmark02
!= nullptr);
302 SetFavicon(0, bookmark01
, icon_url
, CreateFavicon(SK_ColorWHITE
),
303 bookmarks_helper::FROM_UI
);
304 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
305 ASSERT_TRUE(AllModelsMatchVerifier());
307 // Set |page_url2| with the new (blue) favicon at |icon_url|. The sync favicon
308 // for both |page_url1| and |page_url2| should be updated to the blue one.
309 SetFavicon(0, bookmark02
, icon_url
, CreateFavicon(SK_ColorBLUE
),
310 bookmarks_helper::FROM_UI
);
311 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
312 ASSERT_TRUE(AllModelsMatchVerifier());
314 // Set the title for |page_url1|. This should not revert either of the
315 // bookmark favicons back to white.
316 const char kNewTitle
[] = "New Title";
317 ASSERT_STRNE(kGenericURLTitle
, kNewTitle
);
318 const BookmarkNode
* bookmark11
= GetUniqueNodeByURL(1, page_url1
);
319 SetTitle(1, bookmark11
, std::string(kNewTitle
));
320 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
321 ASSERT_TRUE(AllModelsMatchVerifier());
324 // Test Scribe ID - 370560.
325 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, SC_AddNonHTTPBMs
) {
326 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
327 ASSERT_TRUE(AllModelsMatchVerifier());
330 0, "FTP UR", GURL("ftp://user:password@host:1234/path")) != NULL
);
331 ASSERT_TRUE(AddURL(0, "File UR", GURL("file://host/path")) != NULL
);
332 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
333 ASSERT_TRUE(AllModelsMatchVerifier());
336 // Test Scribe ID - 370561.
337 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
338 SC_AddFirstBMUnderFolder
) {
339 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
340 ASSERT_TRUE(AllModelsMatchVerifier());
342 const BookmarkNode
* folder
= AddFolder(0, kGenericFolderName
);
343 ASSERT_TRUE(folder
!= NULL
);
345 0, folder
, 0, kGenericURLTitle
, GURL(kGenericURL
)) != NULL
);
346 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
347 ASSERT_TRUE(AllModelsMatchVerifier());
350 // Test Scribe ID - 370562.
351 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
352 SC_AddSeveralBMsUnderBMBarAndOtherBM
) {
353 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
354 ASSERT_TRUE(AllModelsMatchVerifier());
356 for (int i
= 0; i
< 20; ++i
) {
357 std::string title
= IndexedURLTitle(i
);
358 GURL url
= GURL(IndexedURL(i
));
359 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
361 0, GetOtherNode(0), i
, title
, url
) != NULL
);
363 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
364 ASSERT_TRUE(AllModelsMatchVerifier());
367 // Test Scribe ID - 370563.
368 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
369 SC_AddSeveralBMsAndFolders
) {
370 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
371 ASSERT_TRUE(AllModelsMatchVerifier());
373 for (int i
= 0; i
< 15; ++i
) {
374 if (base::RandDouble() > 0.6) {
375 std::string title
= IndexedURLTitle(i
);
376 GURL url
= GURL(IndexedURL(i
));
377 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
379 std::string title
= IndexedFolderName(i
);
380 const BookmarkNode
* folder
= AddFolder(0, i
, title
);
381 ASSERT_TRUE(folder
!= NULL
);
382 if (base::RandDouble() > 0.4) {
383 for (int i
= 0; i
< 20; ++i
) {
384 std::string title
= IndexedURLTitle(i
);
385 GURL url
= GURL(IndexedURL(i
));
387 AddURL(0, folder
, i
, title
, url
) != NULL
);
392 for (int i
= 0; i
< 10; i
++) {
393 std::string title
= IndexedURLTitle(i
);
394 GURL url
= GURL(IndexedURL(i
));
395 ASSERT_TRUE(AddURL(0, GetOtherNode(0), i
, title
, url
) != NULL
);
397 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
398 ASSERT_TRUE(AllModelsMatchVerifier());
401 // Test Scribe ID - 370641.
402 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
403 SC_DuplicateBMWithDifferentURLSameName
) {
404 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
405 ASSERT_TRUE(AllModelsMatchVerifier());
407 GURL url0
= GURL(IndexedURL(0));
408 GURL url1
= GURL(IndexedURL(1));
409 ASSERT_TRUE(AddURL(0, kGenericURLTitle
, url0
) != NULL
);
410 ASSERT_TRUE(AddURL(0, kGenericURLTitle
, url1
) != NULL
);
411 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
412 ASSERT_TRUE(AllModelsMatchVerifier());
415 // Test Scribe ID - 370639 - Add bookmarks with different name and same URL.
416 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
417 SC_DuplicateBookmarksWithSameURL
) {
418 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
419 ASSERT_TRUE(AllModelsMatchVerifier());
421 std::string title0
= IndexedURLTitle(0);
422 std::string title1
= IndexedURLTitle(1);
423 ASSERT_TRUE(AddURL(0, title0
, GURL(kGenericURL
)) != NULL
);
424 ASSERT_TRUE(AddURL(0, title1
, GURL(kGenericURL
)) != NULL
);
425 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
426 ASSERT_TRUE(AllModelsMatchVerifier());
429 // Test Scribe ID - 371817.
430 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, SC_RenameBMName
) {
431 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
432 ASSERT_TRUE(AllModelsMatchVerifier());
434 std::string title
= IndexedURLTitle(1);
435 const BookmarkNode
* bookmark
= AddURL(0, title
, GURL(kGenericURL
));
436 ASSERT_TRUE(bookmark
!= NULL
);
437 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
438 ASSERT_TRUE(AllModelsMatchVerifier());
440 std::string new_title
= IndexedURLTitle(2);
441 SetTitle(0, bookmark
, new_title
);
442 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
443 ASSERT_TRUE(AllModelsMatchVerifier());
446 // Test Scribe ID - 371822.
447 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, SC_RenameBMURL
) {
448 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
449 ASSERT_TRUE(AllModelsMatchVerifier());
451 GURL url
= GURL(IndexedURL(1));
452 const BookmarkNode
* bookmark
= AddURL(0, kGenericURLTitle
, url
);
453 ASSERT_TRUE(bookmark
!= NULL
);
454 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
455 ASSERT_TRUE(AllModelsMatchVerifier());
457 GURL new_url
= GURL(IndexedURL(2));
458 ASSERT_TRUE(SetURL(0, bookmark
, new_url
) != NULL
);
459 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
460 ASSERT_TRUE(AllModelsMatchVerifier());
464 // Test Scribe ID - 371818 - Renaming the same bookmark name twice.
465 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
466 SC_TwiceRenamingBookmarkName
) {
467 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
468 ASSERT_TRUE(AllModelsMatchVerifier());
470 std::string title
= IndexedURLTitle(1);
471 const BookmarkNode
* bookmark
= AddURL(0, title
, GURL(kGenericURL
));
472 ASSERT_TRUE(bookmark
!= NULL
);
473 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
474 ASSERT_TRUE(AllModelsMatchVerifier());
476 std::string new_title
= IndexedURLTitle(2);
477 SetTitle(0, bookmark
, new_title
);
478 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
479 ASSERT_TRUE(AllModelsMatchVerifier());
481 SetTitle(0, bookmark
, title
);
482 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
483 ASSERT_TRUE(AllModelsMatchVerifier());
486 // Test Scribe ID - 371823 - Renaming the same bookmark URL twice.
487 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
488 SC_TwiceRenamingBookmarkURL
) {
489 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
490 ASSERT_TRUE(AllModelsMatchVerifier());
492 GURL url
= GURL(IndexedURL(1));
493 const BookmarkNode
* bookmark
= AddURL(0, kGenericURLTitle
, url
);
494 ASSERT_TRUE(bookmark
!= NULL
);
495 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
496 ASSERT_TRUE(AllModelsMatchVerifier());
498 GURL new_url
= GURL(IndexedURL(2));
499 ASSERT_TRUE(SetURL(0, bookmark
, new_url
) != NULL
);
500 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
501 ASSERT_TRUE(AllModelsMatchVerifier());
503 ASSERT_TRUE(SetURL(0, bookmark
, url
) != NULL
);
504 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
505 ASSERT_TRUE(AllModelsMatchVerifier());
508 // Test Scribe ID - 371824.
509 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, SC_RenameBMFolder
) {
510 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
511 ASSERT_TRUE(AllModelsMatchVerifier());
513 std::string title
= IndexedFolderName(1);
514 const BookmarkNode
* folder
= AddFolder(0, title
);
516 0, folder
, 0, kGenericURLTitle
, GURL(kGenericURL
)) != NULL
);
517 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
518 ASSERT_TRUE(AllModelsMatchVerifier());
520 std::string new_title
= IndexedFolderName(2);
521 SetTitle(0, folder
, new_title
);
522 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
523 ASSERT_TRUE(AllModelsMatchVerifier());
526 // Test Scribe ID - 371825.
527 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, SC_RenameEmptyBMFolder
) {
528 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
529 ASSERT_TRUE(AllModelsMatchVerifier());
531 std::string title
= IndexedFolderName(1);
532 const BookmarkNode
* folder
= AddFolder(0, title
);
533 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
534 ASSERT_TRUE(AllModelsMatchVerifier());
536 std::string new_title
= IndexedFolderName(2);
537 SetTitle(0, folder
, new_title
);
538 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
539 ASSERT_TRUE(AllModelsMatchVerifier());
542 // Test Scribe ID - 371826.
543 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
544 SC_RenameBMFolderWithLongHierarchy
) {
545 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
546 ASSERT_TRUE(AllModelsMatchVerifier());
548 std::string title
= IndexedFolderName(1);
549 const BookmarkNode
* folder
= AddFolder(0, title
);
550 ASSERT_TRUE(folder
!= NULL
);
551 for (int i
= 0; i
< 120; ++i
) {
552 if (base::RandDouble() > 0.15) {
553 std::string title
= IndexedURLTitle(i
);
554 GURL url
= GURL(IndexedURL(i
));
555 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
557 std::string title
= IndexedSubfolderName(i
);
558 ASSERT_TRUE(AddFolder(0, folder
, i
, title
) != NULL
);
561 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
562 ASSERT_TRUE(AllModelsMatchVerifier());
564 std::string new_title
= IndexedFolderName(2);
565 SetTitle(0, folder
, new_title
);
566 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
567 ASSERT_TRUE(AllModelsMatchVerifier());
570 // Test Scribe ID - 371827.
571 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
572 SC_RenameBMFolderThatHasParentAndChildren
) {
573 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
574 ASSERT_TRUE(AllModelsMatchVerifier());
576 const BookmarkNode
* folder
= AddFolder(0, kGenericFolderName
);
577 ASSERT_TRUE(folder
!= NULL
);
578 for (int i
= 1; i
< 15; ++i
) {
579 std::string title
= IndexedURLTitle(i
);
580 GURL url
= GURL(IndexedURL(i
));
581 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
583 std::string title
= IndexedSubfolderName(1);
584 const BookmarkNode
* subfolder
= AddFolder(0, folder
, 0, title
);
585 for (int i
= 0; i
< 120; ++i
) {
586 if (base::RandDouble() > 0.15) {
587 std::string title
= IndexedURLTitle(i
);
588 GURL url
= GURL(IndexedURL(i
));
589 ASSERT_TRUE(AddURL(0, subfolder
, i
, title
, url
) != NULL
);
591 std::string title
= IndexedSubsubfolderName(i
);
592 ASSERT_TRUE(AddFolder(0, subfolder
, i
, title
) != NULL
);
595 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
596 ASSERT_TRUE(AllModelsMatchVerifier());
598 std::string new_title
= IndexedSubfolderName(2);
599 SetTitle(0, subfolder
, new_title
);
600 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
601 ASSERT_TRUE(AllModelsMatchVerifier());
604 // Test Scribe ID - 371828.
605 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, SC_RenameBMNameAndURL
) {
606 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
607 ASSERT_TRUE(AllModelsMatchVerifier());
609 GURL url
= GURL(IndexedURL(1));
610 std::string title
= IndexedURLTitle(1);
611 const BookmarkNode
* bookmark
= AddURL(0, title
, url
);
612 ASSERT_TRUE(bookmark
!= NULL
);
613 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
614 ASSERT_TRUE(AllModelsMatchVerifier());
616 GURL new_url
= GURL(IndexedURL(2));
617 std::string new_title
= IndexedURLTitle(2);
618 bookmark
= SetURL(0, bookmark
, new_url
);
619 ASSERT_TRUE(bookmark
!= NULL
);
620 SetTitle(0, bookmark
, new_title
);
621 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
622 ASSERT_TRUE(AllModelsMatchVerifier());
625 // Test Scribe ID - 371832.
626 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
627 SC_DeleteBMEmptyAccountAfterwards
) {
628 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
629 ASSERT_TRUE(AllModelsMatchVerifier());
632 0, kGenericURLTitle
, GURL(kGenericURL
)) != NULL
);
633 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
634 ASSERT_TRUE(AllModelsMatchVerifier());
636 Remove(0, GetBookmarkBarNode(0), 0);
637 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
638 ASSERT_TRUE(AllModelsMatchVerifier());
641 // Test Scribe ID - 371833.
642 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
643 SC_DelBMNonEmptyAccountAfterwards
) {
644 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
645 ASSERT_TRUE(AllModelsMatchVerifier());
647 for (int i
= 0; i
< 20; ++i
) {
648 std::string title
= IndexedURLTitle(i
);
649 GURL url
= GURL(IndexedURL(i
));
650 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
652 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
653 ASSERT_TRUE(AllModelsMatchVerifier());
655 Remove(0, GetBookmarkBarNode(0), 0);
656 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
657 ASSERT_TRUE(AllModelsMatchVerifier());
660 // Test Scribe ID - 371835.
661 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
662 SC_DelFirstBMUnderBMFoldNonEmptyFoldAfterwards
) {
663 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
664 ASSERT_TRUE(AllModelsMatchVerifier());
666 const BookmarkNode
* folder
= AddFolder(0, kGenericFolderName
);
667 ASSERT_TRUE(folder
!= NULL
);
668 for (int i
= 0; i
< 10; ++i
) {
669 std::string title
= IndexedURLTitle(i
);
670 GURL url
= GURL(IndexedURL(i
));
671 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
673 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
674 ASSERT_TRUE(AllModelsMatchVerifier());
676 Remove(0, folder
, 0);
677 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
678 ASSERT_TRUE(AllModelsMatchVerifier());
681 // Test Scribe ID - 371836.
682 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
683 SC_DelLastBMUnderBMFoldNonEmptyFoldAfterwards
) {
684 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
685 ASSERT_TRUE(AllModelsMatchVerifier());
687 const BookmarkNode
* folder
= AddFolder(0, kGenericFolderName
);
688 ASSERT_TRUE(folder
!= NULL
);
689 for (int i
= 0; i
< 10; ++i
) {
690 std::string title
= IndexedURLTitle(i
);
691 GURL url
= GURL(IndexedURL(i
));
692 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
694 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
695 ASSERT_TRUE(AllModelsMatchVerifier());
697 Remove(0, folder
, folder
->child_count() - 1);
698 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
699 ASSERT_TRUE(AllModelsMatchVerifier());
702 // Test Scribe ID - 371856.
703 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
704 SC_DelMiddleBMUnderBMFoldNonEmptyFoldAfterwards
) {
705 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
706 ASSERT_TRUE(AllModelsMatchVerifier());
708 const BookmarkNode
* folder
= AddFolder(0, kGenericFolderName
);
709 ASSERT_TRUE(folder
!= NULL
);
710 for (int i
= 0; i
< 10; ++i
) {
711 std::string title
= IndexedURLTitle(i
);
712 GURL url
= GURL(IndexedURL(i
));
713 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
715 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
716 ASSERT_TRUE(AllModelsMatchVerifier());
718 Remove(0, folder
, 4);
719 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
720 ASSERT_TRUE(AllModelsMatchVerifier());
723 // Test Scribe ID - 371857.
724 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
725 SC_DelBMsUnderBMFoldEmptyFolderAfterwards
) {
726 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
727 ASSERT_TRUE(AllModelsMatchVerifier());
729 const BookmarkNode
* folder
= AddFolder(0, kGenericFolderName
);
730 ASSERT_TRUE(folder
!= NULL
);
731 for (int i
= 0; i
< 10; ++i
) {
732 std::string title
= IndexedURLTitle(i
);
733 GURL url
= GURL(IndexedURL(i
));
734 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
736 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
737 ASSERT_TRUE(AllModelsMatchVerifier());
739 int child_count
= folder
->child_count();
740 for (int i
= 0; i
< child_count
; ++i
) {
741 Remove(0, folder
, 0);
743 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
744 ASSERT_TRUE(AllModelsMatchVerifier());
747 // Test Scribe ID - 371858.
748 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
749 SC_DelEmptyBMFoldEmptyAccountAfterwards
) {
750 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
751 ASSERT_TRUE(AllModelsMatchVerifier());
753 ASSERT_TRUE(AddFolder(0, kGenericFolderName
) != NULL
);
754 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
755 ASSERT_TRUE(AllModelsMatchVerifier());
757 Remove(0, GetBookmarkBarNode(0), 0);
758 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
759 ASSERT_TRUE(AllModelsMatchVerifier());
762 // Test Scribe ID - 371869.
763 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
764 SC_DelEmptyBMFoldNonEmptyAccountAfterwards
) {
765 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
766 ASSERT_TRUE(AllModelsMatchVerifier());
768 ASSERT_TRUE(AddFolder(0, kGenericFolderName
) != NULL
);
769 for (int i
= 1; i
< 15; ++i
) {
770 if (base::RandDouble() > 0.6) {
771 std::string title
= IndexedURLTitle(i
);
772 GURL url
= GURL(IndexedURL(i
));
773 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
775 std::string title
= IndexedFolderName(i
);
776 ASSERT_TRUE(AddFolder(0, i
, title
) != NULL
);
779 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
780 ASSERT_TRUE(AllModelsMatchVerifier());
782 Remove(0, GetBookmarkBarNode(0), 0);
783 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
784 ASSERT_TRUE(AllModelsMatchVerifier());
787 // Test Scribe ID - 371879.
788 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
789 SC_DelBMFoldWithBMsNonEmptyAccountAfterwards
) {
790 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
791 ASSERT_TRUE(AllModelsMatchVerifier());
793 ASSERT_TRUE(AddURL(0, kGenericURLTitle
, GURL(kGenericURL
)) != NULL
);
794 const BookmarkNode
* folder
= AddFolder(0, 1, kGenericFolderName
);
795 ASSERT_TRUE(folder
!= NULL
);
796 for (int i
= 2; i
< 10; ++i
) {
797 if (base::RandDouble() > 0.6) {
798 std::string title
= IndexedURLTitle(i
);
799 GURL url
= GURL(IndexedURL(i
));
800 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
802 std::string title
= IndexedFolderName(i
);
803 ASSERT_TRUE(AddFolder(0, i
, title
) != NULL
);
806 for (int i
= 0; i
< 15; ++i
) {
807 std::string title
= IndexedURLTitle(i
);
808 GURL url
= GURL(IndexedURL(i
));
809 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
811 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
812 ASSERT_TRUE(AllModelsMatchVerifier());
814 Remove(0, GetBookmarkBarNode(0), 1);
815 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
816 ASSERT_TRUE(AllModelsMatchVerifier());
819 // Test Scribe ID - 371880.
820 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
821 SC_DelBMFoldWithBMsAndBMFoldsNonEmptyACAfterwards
) {
822 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
823 ASSERT_TRUE(AllModelsMatchVerifier());
825 ASSERT_TRUE(AddURL(0, kGenericURLTitle
, GURL(kGenericURL
)) != NULL
);
826 const BookmarkNode
* folder
= AddFolder(0, 1, kGenericFolderName
);
827 ASSERT_TRUE(folder
!= NULL
);
828 for (int i
= 2; i
< 10; ++i
) {
829 if (base::RandDouble() > 0.6) {
830 std::string title
= IndexedURLTitle(i
);
831 GURL url
= GURL(IndexedURL(i
));
832 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
834 std::string title
= IndexedFolderName(i
);
835 ASSERT_TRUE(AddFolder(0, i
, title
) != NULL
);
838 for (int i
= 0; i
< 10; ++i
) {
839 if (base::RandDouble() > 0.6) {
840 std::string title
= IndexedURLTitle(i
);
841 GURL url
= GURL(IndexedURL(i
));
842 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
844 std::string title
= IndexedSubfolderName(i
);
845 const BookmarkNode
* subfolder
=
846 AddFolder(0, folder
, i
, title
);
847 ASSERT_TRUE(subfolder
!= NULL
);
848 if (base::RandDouble() > 0.3) {
849 for (int j
= 0; j
< 10; ++j
) {
850 if (base::RandDouble() > 0.6) {
851 std::string title
= IndexedURLTitle(j
);
852 GURL url
= GURL(IndexedURL(j
));
854 0, subfolder
, j
, title
, url
) != NULL
);
856 std::string title
= IndexedSubsubfolderName(j
);
857 ASSERT_TRUE(AddFolder(
858 0, subfolder
, j
, title
) != NULL
);
864 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
865 ASSERT_TRUE(AllModelsMatchVerifier());
867 Remove(0, GetBookmarkBarNode(0), 1);
868 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
869 ASSERT_TRUE(AllModelsMatchVerifier());
872 // Test Scribe ID - 371882.
873 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
874 SC_DelBMFoldWithParentAndChildrenBMsAndBMFolds
) {
875 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
876 ASSERT_TRUE(AllModelsMatchVerifier());
878 const BookmarkNode
* folder
= AddFolder(0, kGenericFolderName
);
879 ASSERT_TRUE(folder
!= NULL
);
880 for (int i
= 1; i
< 11; ++i
) {
881 std::string title
= IndexedURLTitle(i
);
882 GURL url
= GURL(IndexedURL(i
));
883 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
885 const BookmarkNode
* subfolder
=
886 AddFolder(0, folder
, 0, kGenericSubfolderName
);
887 ASSERT_TRUE(subfolder
!= NULL
);
888 for (int i
= 0; i
< 30; ++i
) {
889 if (base::RandDouble() > 0.2) {
890 std::string title
= IndexedURLTitle(i
);
891 GURL url
= GURL(IndexedURL(i
));
892 ASSERT_TRUE(AddURL(0, subfolder
, i
, title
, url
) != NULL
);
894 std::string title
= IndexedSubsubfolderName(i
);
895 ASSERT_TRUE(AddFolder(0, subfolder
, i
, title
) != NULL
);
898 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
899 ASSERT_TRUE(AllModelsMatchVerifier());
901 Remove(0, folder
, 0);
902 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
903 ASSERT_TRUE(AllModelsMatchVerifier());
906 // Test Scribe ID - 371931.
907 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
908 SC_ReverseTheOrderOfTwoBMs
) {
909 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
910 ASSERT_TRUE(AllModelsMatchVerifier());
912 GURL url0
= GURL(IndexedURL(0));
913 GURL url1
= GURL(IndexedURL(1));
914 std::string title0
= IndexedURLTitle(0);
915 std::string title1
= IndexedURLTitle(1);
916 const BookmarkNode
* bookmark0
= AddURL(0, 0, title0
, url0
);
917 const BookmarkNode
* bookmark1
= AddURL(0, 1, title1
, url1
);
918 ASSERT_TRUE(bookmark0
!= NULL
);
919 ASSERT_TRUE(bookmark1
!= NULL
);
920 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
921 ASSERT_TRUE(AllModelsMatchVerifier());
923 Move(0, bookmark0
, GetBookmarkBarNode(0), 2);
924 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
925 ASSERT_TRUE(AllModelsMatchVerifier());
928 // Test Scribe ID - 371933.
929 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, SC_ReverseTheOrderOf10BMs
) {
930 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
931 ASSERT_TRUE(AllModelsMatchVerifier());
933 for (int i
= 0; i
< 10; ++i
) {
934 std::string title
= IndexedURLTitle(i
);
935 GURL url
= GURL(IndexedURL(i
));
936 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
938 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
939 ASSERT_TRUE(AllModelsMatchVerifier());
941 ReverseChildOrder(0, GetBookmarkBarNode(0));
942 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
943 ASSERT_TRUE(AllModelsMatchVerifier());
946 // Test Scribe ID - 371954.
947 // flaky on Windows: http://crbug.com/412169
948 #if defined(OS_WIN) || defined(OS_MACOSX)
949 #define MAYBE_SC_MovingBMsFromBMBarToBMFolder DISABLED_SC_MovingBMsFromBMBarToBMFolder
951 #define MAYBE_SC_MovingBMsFromBMBarToBMFolder SC_MovingBMsFromBMBarToBMFolder
953 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
954 MAYBE_SC_MovingBMsFromBMBarToBMFolder
) {
955 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
956 ASSERT_TRUE(AllModelsMatchVerifier());
958 ASSERT_TRUE(AddURL(0, kGenericURLTitle
, GURL(kGenericURL
)) != NULL
);
959 const BookmarkNode
* folder
= AddFolder(0, 1, kGenericFolderName
);
960 ASSERT_TRUE(folder
!= NULL
);
961 for (int i
= 2; i
< 10; ++i
) {
962 std::string title
= IndexedURLTitle(i
);
963 GURL url
= GURL(IndexedURL(i
));
964 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
966 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
967 ASSERT_TRUE(AllModelsMatchVerifier());
969 int num_bookmarks_to_move
=
970 GetBookmarkBarNode(0)->child_count() - 2;
971 for (int i
= 0; i
< num_bookmarks_to_move
; ++i
) {
973 0, GetBookmarkBarNode(0)->GetChild(2), folder
, i
);
974 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
975 ASSERT_TRUE(AllModelsMatchVerifier());
979 // Test Scribe ID - 371957.
980 // flaky on Windows and Mac: http://crbug.com/412169
981 #if defined(OS_WIN) || defined(OS_MACOSX)
982 #define MAYBE_SC_MovingBMsFromBMFoldToBMBar DISABLED_SC_MovingBMsFromBMFoldToBMBar
984 #define MAYBE_SC_MovingBMsFromBMFoldToBMBar SC_MovingBMsFromBMFoldToBMBar
986 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
987 MAYBE_SC_MovingBMsFromBMFoldToBMBar
) {
988 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
989 ASSERT_TRUE(AllModelsMatchVerifier());
991 ASSERT_TRUE(AddURL(0, kGenericURLTitle
, GURL(kGenericURL
)) != NULL
);
992 const BookmarkNode
* folder
= AddFolder(0, 1, kGenericFolderName
);
993 ASSERT_TRUE(folder
!= NULL
);
994 for (int i
= 0; i
< 10; ++i
) {
995 std::string title
= IndexedURLTitle(i
);
996 GURL url
= GURL(IndexedURL(i
));
997 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
999 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1000 ASSERT_TRUE(AllModelsMatchVerifier());
1002 int num_bookmarks_to_move
= folder
->child_count() - 2;
1003 for (int i
= 0; i
< num_bookmarks_to_move
; ++i
) {
1004 Move(0, folder
->GetChild(0), GetBookmarkBarNode(0), i
);
1005 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1006 ASSERT_TRUE(AllModelsMatchVerifier());
1010 // Test Scribe ID - 371961.
1011 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1012 SC_MovingBMsFromParentBMFoldToChildBMFold
) {
1013 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1014 ASSERT_TRUE(AllModelsMatchVerifier());
1016 const BookmarkNode
* folder
= AddFolder(0, kGenericFolderName
);
1017 ASSERT_TRUE(folder
!= NULL
);
1018 for (int i
= 0; i
< 3; ++i
) {
1019 std::string title
= IndexedURLTitle(i
);
1020 GURL url
= GURL(IndexedURL(i
));
1021 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
1023 const BookmarkNode
* subfolder
=
1024 AddFolder(0, folder
, 3, kGenericSubfolderName
);
1025 ASSERT_TRUE(subfolder
!= NULL
);
1026 for (int i
= 0; i
< 10; ++i
) {
1027 std::string title
= IndexedURLTitle(i
+ 3);
1028 GURL url
= GURL(IndexedURL(i
+ 3));
1029 ASSERT_TRUE(AddURL(0, subfolder
, i
, title
, url
) != NULL
);
1031 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1032 ASSERT_TRUE(AllModelsMatchVerifier());
1034 for (int i
= 0; i
< 3; ++i
) {
1035 GURL url
= GURL(IndexedURL(i
));
1036 Move(0, GetUniqueNodeByURL(0, url
), subfolder
, i
+ 10);
1038 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1039 ASSERT_TRUE(AllModelsMatchVerifier());
1042 // Test Scribe ID - 371964.
1043 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1044 SC_MovingBMsFromChildBMFoldToParentBMFold
) {
1045 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1046 ASSERT_TRUE(AllModelsMatchVerifier());
1048 const BookmarkNode
* folder
= AddFolder(0, kGenericFolderName
);
1049 ASSERT_TRUE(folder
!= NULL
);
1050 for (int i
= 0; i
< 3; ++i
) {
1051 std::string title
= IndexedURLTitle(i
);
1052 GURL url
= GURL(IndexedURL(i
));
1053 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
1055 const BookmarkNode
* subfolder
=
1056 AddFolder(0, folder
, 3, kGenericSubfolderName
);
1057 ASSERT_TRUE(subfolder
!= NULL
);
1058 for (int i
= 0; i
< 5; ++i
) {
1059 std::string title
= IndexedURLTitle(i
+ 3);
1060 GURL url
= GURL(IndexedURL(i
+ 3));
1061 ASSERT_TRUE(AddURL(0, subfolder
, i
, title
, url
) != NULL
);
1063 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1064 ASSERT_TRUE(AllModelsMatchVerifier());
1066 for (int i
= 0; i
< 3; ++i
) {
1067 GURL url
= GURL(IndexedURL(i
+ 3));
1068 Move(0, GetUniqueNodeByURL(0, url
), folder
, i
+ 4);
1070 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1071 ASSERT_TRUE(AllModelsMatchVerifier());
1074 // Test Scribe ID - 371967.
1075 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, SC_HoistBMs10LevelUp
) {
1076 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1077 ASSERT_TRUE(AllModelsMatchVerifier());
1079 const BookmarkNode
* folder
= GetBookmarkBarNode(0);
1080 const BookmarkNode
* folder_L0
= NULL
;
1081 const BookmarkNode
* folder_L10
= NULL
;
1082 for (int level
= 0; level
< 15; ++level
) {
1083 int num_bookmarks
= base::RandInt(0, 9);
1084 for (int i
= 0; i
< num_bookmarks
; ++i
) {
1085 std::string title
= IndexedURLTitle(i
);
1086 GURL url
= GURL(IndexedURL(i
));
1087 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
1089 std::string title
= IndexedFolderName(level
);
1090 folder
= AddFolder(0, folder
, folder
->child_count(), title
);
1091 ASSERT_TRUE(folder
!= NULL
);
1092 if (level
== 0) folder_L0
= folder
;
1093 if (level
== 10) folder_L10
= folder
;
1095 for (int i
= 0; i
< 3; ++i
) {
1096 std::string title
= IndexedURLTitle(i
+ 10);
1097 GURL url
= GURL(IndexedURL(i
+ 10));
1098 ASSERT_TRUE(AddURL(0, folder_L10
, i
, title
, url
) != NULL
);
1100 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1101 ASSERT_TRUE(AllModelsMatchVerifier());
1103 GURL url10
= GURL(IndexedURL(10));
1104 Move(0, GetUniqueNodeByURL(
1105 0, url10
), folder_L0
, folder_L0
->child_count());
1106 GURL url11
= GURL(IndexedURL(11));
1107 Move(0, GetUniqueNodeByURL(0, url11
), folder_L0
, 0);
1108 GURL url12
= GURL(IndexedURL(12));
1109 Move(0, GetUniqueNodeByURL(0, url12
), folder_L0
, 1);
1110 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1111 ASSERT_TRUE(AllModelsMatchVerifier());
1114 // Test Scribe ID - 371968.
1115 // Flaky. http://crbug.com/107744.
1116 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, SC_SinkBMs10LevelDown
) {
1117 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1118 ASSERT_TRUE(AllModelsMatchVerifier());
1120 const BookmarkNode
* folder
= GetBookmarkBarNode(0);
1121 const BookmarkNode
* folder_L0
= NULL
;
1122 const BookmarkNode
* folder_L10
= NULL
;
1123 for (int level
= 0; level
< 15; ++level
) {
1124 int num_bookmarks
= base::RandInt(0, 9);
1125 for (int i
= 0; i
< num_bookmarks
; ++i
) {
1126 std::string title
= IndexedURLTitle(i
);
1127 GURL url
= GURL(IndexedURL(i
));
1128 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
1130 std::string title
= IndexedFolderName(level
);
1131 folder
= AddFolder(0, folder
, folder
->child_count(), title
);
1132 ASSERT_TRUE(folder
!= NULL
);
1133 if (level
== 0) folder_L0
= folder
;
1134 if (level
== 10) folder_L10
= folder
;
1136 for (int i
= 0; i
< 3; ++i
) {
1137 std::string title
= IndexedURLTitle(i
+ 10);
1138 GURL url
= GURL(IndexedURL(i
+ 10));
1139 ASSERT_TRUE(AddURL(0, folder_L0
, 0, title
, url
) != NULL
);
1141 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1142 ASSERT_TRUE(AllModelsMatchVerifier());
1144 GURL url10
= GURL(IndexedURL(10));
1145 Move(0, GetUniqueNodeByURL(0, url10
), folder_L10
, folder_L10
->child_count());
1146 GURL url11
= GURL(IndexedURL(11));
1147 Move(0, GetUniqueNodeByURL(0, url11
), folder_L10
, 0);
1148 GURL url12
= GURL(IndexedURL(12));
1149 Move(0, GetUniqueNodeByURL(0, url12
), folder_L10
, 1);
1150 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1151 ASSERT_TRUE(AllModelsMatchVerifier());
1154 // Test Scribe ID - 371980.
1155 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1156 SC_SinkEmptyBMFold5LevelsDown
) {
1157 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1158 ASSERT_TRUE(AllModelsMatchVerifier());
1160 const BookmarkNode
* folder
= GetBookmarkBarNode(0);
1161 const BookmarkNode
* folder_L5
= NULL
;
1162 for (int level
= 0; level
< 15; ++level
) {
1163 int num_bookmarks
= base::RandInt(0, 9);
1164 for (int i
= 0; i
< num_bookmarks
; ++i
) {
1165 std::string title
= IndexedURLTitle(i
);
1166 GURL url
= GURL(IndexedURL(i
));
1167 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
1169 std::string title
= IndexedFolderName(level
);
1171 0, folder
, folder
->child_count(), title
);
1172 ASSERT_TRUE(folder
!= NULL
);
1173 if (level
== 5) folder_L5
= folder
;
1176 0, GetBookmarkBarNode(0)->child_count(), kGenericFolderName
);
1177 ASSERT_TRUE(folder
!= NULL
);
1178 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1179 ASSERT_TRUE(AllModelsMatchVerifier());
1181 Move(0, folder
, folder_L5
, folder_L5
->child_count());
1182 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1183 ASSERT_TRUE(AllModelsMatchVerifier());
1186 // Test Scribe ID - 371997.
1187 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1188 SC_SinkNonEmptyBMFold5LevelsDown
) {
1189 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1190 ASSERT_TRUE(AllModelsMatchVerifier());
1192 const BookmarkNode
* folder
= GetBookmarkBarNode(0);
1193 const BookmarkNode
* folder_L5
= NULL
;
1194 for (int level
= 0; level
< 6; ++level
) {
1195 int num_bookmarks
= base::RandInt(0, 9);
1196 for (int i
= 0; i
< num_bookmarks
; ++i
) {
1197 std::string title
= IndexedURLTitle(i
);
1198 GURL url
= GURL(IndexedURL(i
));
1199 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
1201 std::string title
= IndexedFolderName(level
);
1202 folder
= AddFolder(0, folder
, folder
->child_count(), title
);
1203 ASSERT_TRUE(folder
!= NULL
);
1204 if (level
== 5) folder_L5
= folder
;
1207 0, GetBookmarkBarNode(0)->child_count(), kGenericFolderName
);
1208 ASSERT_TRUE(folder
!= NULL
);
1209 for (int i
= 0; i
< 10; ++i
) {
1210 std::string title
= IndexedURLTitle(i
);
1211 GURL url
= GURL(IndexedURL(i
));
1212 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
1214 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1215 ASSERT_TRUE(AllModelsMatchVerifier());
1217 Move(0, folder
, folder_L5
, folder_L5
->child_count());
1218 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1219 ASSERT_TRUE(AllModelsMatchVerifier());
1222 // Test Scribe ID - 372006.
1223 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1224 SC_HoistFolder5LevelsUp
) {
1225 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1226 ASSERT_TRUE(AllModelsMatchVerifier());
1228 const BookmarkNode
* folder
= GetBookmarkBarNode(0);
1229 const BookmarkNode
* folder_L5
= NULL
;
1230 for (int level
= 0; level
< 6; ++level
) {
1231 int num_bookmarks
= base::RandInt(0, 9);
1232 for (int i
= 0; i
< num_bookmarks
; ++i
) {
1233 std::string title
= IndexedURLTitle(i
);
1234 GURL url
= GURL(IndexedURL(i
));
1235 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
1237 std::string title
= IndexedFolderName(level
);
1238 folder
= AddFolder(0, folder
, folder
->child_count(), title
);
1239 ASSERT_TRUE(folder
!= NULL
);
1240 if (level
== 5) folder_L5
= folder
;
1243 0, folder_L5
, folder_L5
->child_count(), kGenericFolderName
);
1244 ASSERT_TRUE(folder
!= NULL
);
1245 for (int i
= 0; i
< 10; ++i
) {
1246 std::string title
= IndexedURLTitle(i
);
1247 GURL url
= GURL(IndexedURL(i
));
1248 ASSERT_TRUE(AddURL(0, folder
, i
, title
, url
) != NULL
);
1250 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1251 ASSERT_TRUE(AllModelsMatchVerifier());
1253 Move(0, folder
, GetBookmarkBarNode(0), GetBookmarkBarNode(0)->child_count());
1254 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1255 ASSERT_TRUE(AllModelsMatchVerifier());
1258 // Test Scribe ID - 372026.
1259 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1260 SC_ReverseTheOrderOfTwoBMFolders
) {
1261 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1262 ASSERT_TRUE(AllModelsMatchVerifier());
1264 for (int i
= 0; i
< 2; ++i
) {
1265 std::string title
= IndexedFolderName(i
);
1266 const BookmarkNode
* folder
= AddFolder(0, i
, title
);
1267 ASSERT_TRUE(folder
!= NULL
);
1268 for (int j
= 0; j
< 10; ++j
) {
1269 std::string title
= IndexedURLTitle(j
);
1270 GURL url
= GURL(IndexedURL(j
));
1271 ASSERT_TRUE(AddURL(0, folder
, j
, title
, url
) != NULL
);
1274 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1275 ASSERT_TRUE(AllModelsMatchVerifier());
1277 ReverseChildOrder(0, GetBookmarkBarNode(0));
1278 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1279 ASSERT_TRUE(AllModelsMatchVerifier());
1282 // Test Scribe ID - 372028.
1283 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1284 SC_ReverseTheOrderOfTenBMFolders
) {
1285 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1286 ASSERT_TRUE(AllModelsMatchVerifier());
1288 for (int i
= 0; i
< 10; ++i
) {
1289 std::string title
= IndexedFolderName(i
);
1290 const BookmarkNode
* folder
= AddFolder(0, i
, title
);
1291 ASSERT_TRUE(folder
!= NULL
);
1292 for (int j
= 0; j
< 10; ++j
) {
1293 std::string title
= IndexedURLTitle(1000 * i
+ j
);
1294 GURL url
= GURL(IndexedURL(j
));
1295 ASSERT_TRUE(AddURL(0, folder
, j
, title
, url
) != NULL
);
1298 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1299 ASSERT_TRUE(AllModelsMatchVerifier());
1301 ReverseChildOrder(0, GetBookmarkBarNode(0));
1302 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1303 ASSERT_TRUE(AllModelsMatchVerifier());
1306 // Test Scribe ID - 373379.
1307 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1308 MC_BiDirectionalPushAddingBM
) {
1309 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1310 ASSERT_TRUE(AllModelsMatchVerifier());
1313 for (int i
= 0; i
< 2; ++i
) {
1314 std::string title0
= IndexedURLTitle(2*i
);
1315 GURL url0
= GURL(IndexedURL(2*i
));
1316 ASSERT_TRUE(AddURL(0, title0
, url0
) != NULL
);
1317 std::string title1
= IndexedURLTitle(2*i
+1);
1318 GURL url1
= GURL(IndexedURL(2*i
+1));
1319 ASSERT_TRUE(AddURL(1, title1
, url1
) != NULL
);
1321 ASSERT_TRUE(AwaitQuiescence());
1322 ASSERT_TRUE(AllModelsMatch());
1323 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1326 // Test Scribe ID - 373503.
1327 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1328 MC_BiDirectionalPush_AddingSameBMs
) {
1329 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1330 ASSERT_TRUE(AllModelsMatchVerifier());
1332 // Note: When a racy commit is done with identical bookmarks, it is possible
1333 // for duplicates to exist after sync completes. See http://crbug.com/19769.
1335 for (int i
= 0; i
< 2; ++i
) {
1336 std::string title
= IndexedURLTitle(i
);
1337 GURL url
= GURL(IndexedURL(i
));
1338 ASSERT_TRUE(AddURL(0, title
, url
) != NULL
);
1339 ASSERT_TRUE(AddURL(1, title
, url
) != NULL
);
1341 ASSERT_TRUE(AwaitQuiescence());
1342 ASSERT_TRUE(AllModelsMatch());
1345 // Test Scribe ID - 373506.
1346 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1347 MC_BootStrapEmptyStateEverywhere
) {
1348 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1349 ASSERT_TRUE(AwaitQuiescence());
1350 ASSERT_TRUE(AllModelsMatchVerifier());
1353 // Test Scribe ID - 373505.
1354 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1355 MC_Merge_CaseInsensitivity_InNames
) {
1356 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
1359 const BookmarkNode
* folder0
= AddFolder(0, "Folder");
1360 ASSERT_TRUE(folder0
!= NULL
);
1361 ASSERT_TRUE(AddURL(0, folder0
, 0, "Bookmark 0", GURL(kGenericURL
)) != NULL
);
1362 ASSERT_TRUE(AddURL(0, folder0
, 1, "Bookmark 1", GURL(kGenericURL
)) != NULL
);
1363 ASSERT_TRUE(AddURL(0, folder0
, 2, "Bookmark 2", GURL(kGenericURL
)) != NULL
);
1365 const BookmarkNode
* folder1
= AddFolder(1, "fOlDeR");
1366 ASSERT_TRUE(folder1
!= NULL
);
1367 ASSERT_TRUE(AddURL(1, folder1
, 0, "bOoKmArK 0", GURL(kGenericURL
)) != NULL
);
1368 ASSERT_TRUE(AddURL(1, folder1
, 1, "BooKMarK 1", GURL(kGenericURL
)) != NULL
);
1369 ASSERT_TRUE(AddURL(1, folder1
, 2, "bOOKMARK 2", GURL(kGenericURL
)) != NULL
);
1371 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1372 ASSERT_TRUE(AwaitQuiescence());
1373 ASSERT_TRUE(AllModelsMatch());
1374 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1377 // Test Scribe ID - 373508.
1378 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1379 MC_SimpleMergeOfDifferentBMModels
) {
1380 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
1383 for (int i
= 0; i
< 3; ++i
) {
1384 std::string title
= IndexedURLTitle(i
);
1385 GURL url
= GURL(IndexedURL(i
));
1386 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
1387 ASSERT_TRUE(AddURL(1, i
, title
, url
) != NULL
);
1390 for (int i
= 3; i
< 10; ++i
) {
1391 std::string title0
= IndexedURLTitle(i
);
1392 GURL url0
= GURL(IndexedURL(i
));
1393 ASSERT_TRUE(AddURL(0, i
, title0
, url0
) != NULL
);
1394 std::string title1
= IndexedURLTitle(i
+7);
1395 GURL url1
= GURL(IndexedURL(i
+7));
1396 ASSERT_TRUE(AddURL(1, i
, title1
, url1
) != NULL
);
1399 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1400 ASSERT_TRUE(AwaitQuiescence());
1401 ASSERT_TRUE(AllModelsMatch());
1402 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1405 // Test Scribe ID - 386586.
1406 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1407 MC_MergeSimpleBMHierarchyUnderBMBar
) {
1408 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
1411 for (int i
= 0; i
< 3; ++i
) {
1412 std::string title
= IndexedURLTitle(i
);
1413 GURL url
= GURL(IndexedURL(i
));
1414 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
1415 ASSERT_TRUE(AddURL(1, i
, title
, url
) != NULL
);
1418 for (int i
= 3; i
< 10; ++i
) {
1419 std::string title
= IndexedURLTitle(i
);
1420 GURL url
= GURL(IndexedURL(i
));
1421 ASSERT_TRUE(AddURL(1, i
, title
, url
) != NULL
);
1424 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1425 ASSERT_TRUE(AwaitQuiescence());
1426 ASSERT_TRUE(AllModelsMatch());
1427 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1430 // Test Scribe ID - 386589.
1431 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1432 MC_MergeSimpleBMHierarchyEqualSetsUnderBMBar
) {
1433 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
1436 for (int i
= 0; i
< 3; ++i
) {
1437 std::string title
= IndexedURLTitle(i
);
1438 GURL url
= GURL(IndexedURL(i
));
1439 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
1440 ASSERT_TRUE(AddURL(1, i
, title
, url
) != NULL
);
1443 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1444 ASSERT_TRUE(AwaitQuiescence());
1445 ASSERT_TRUE(AllModelsMatch());
1446 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1449 // Test Scribe ID - 373504 - Merge bookmark folders with different bookmarks.
1450 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1451 MC_MergeBMFoldersWithDifferentBMs
) {
1452 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
1455 const BookmarkNode
* folder0
= AddFolder(0, kGenericFolderName
);
1456 ASSERT_TRUE(folder0
!= NULL
);
1457 const BookmarkNode
* folder1
= AddFolder(1, kGenericFolderName
);
1458 ASSERT_TRUE(folder1
!= NULL
);
1459 for (int i
= 0; i
< 2; ++i
) {
1460 std::string title0
= IndexedURLTitle(2*i
);
1461 GURL url0
= GURL(IndexedURL(2*i
));
1462 ASSERT_TRUE(AddURL(0, folder0
, i
, title0
, url0
) != NULL
);
1463 std::string title1
= IndexedURLTitle(2*i
+1);
1464 GURL url1
= GURL(IndexedURL(2*i
+1));
1465 ASSERT_TRUE(AddURL(1, folder1
, i
, title1
, url1
) != NULL
);
1467 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1468 ASSERT_TRUE(AwaitQuiescence());
1469 ASSERT_TRUE(AllModelsMatch());
1470 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1473 // Test Scribe ID - 373509 - Merge moderately complex bookmark models.
1474 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1475 MC_MergeDifferentBMModelsModeratelyComplex
) {
1476 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
1479 for (int i
= 0; i
< 25; ++i
) {
1480 std::string title0
= IndexedURLTitle(i
);
1481 GURL url0
= GURL(IndexedURL(i
));
1482 ASSERT_TRUE(AddURL(0, i
, title0
, url0
) != NULL
);
1483 std::string title1
= IndexedURLTitle(i
+50);
1484 GURL url1
= GURL(IndexedURL(i
+50));
1485 ASSERT_TRUE(AddURL(1, i
, title1
, url1
) != NULL
);
1487 for (int i
= 25; i
< 30; ++i
) {
1488 std::string title0
= IndexedFolderName(i
);
1489 const BookmarkNode
* folder0
= AddFolder(0, i
, title0
);
1490 ASSERT_TRUE(folder0
!= NULL
);
1491 std::string title1
= IndexedFolderName(i
+50);
1492 const BookmarkNode
* folder1
= AddFolder(1, i
, title1
);
1493 ASSERT_TRUE(folder1
!= NULL
);
1494 for (int j
= 0; j
< 5; ++j
) {
1495 std::string title0
= IndexedURLTitle(i
+5*j
);
1496 GURL url0
= GURL(IndexedURL(i
+5*j
));
1497 ASSERT_TRUE(AddURL(0, folder0
, j
, title0
, url0
) != NULL
);
1498 std::string title1
= IndexedURLTitle(i
+5*j
+50);
1499 GURL url1
= GURL(IndexedURL(i
+5*j
+50));
1500 ASSERT_TRUE(AddURL(1, folder1
, j
, title1
, url1
) != NULL
);
1503 for (int i
= 100; i
< 125; ++i
) {
1504 std::string title
= IndexedURLTitle(i
);
1505 GURL url
= GURL(IndexedURL(i
));
1506 ASSERT_TRUE(AddURL(0, title
, url
) != NULL
);
1507 ASSERT_TRUE(AddURL(1, title
, url
) != NULL
);
1509 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1510 ASSERT_TRUE(AwaitQuiescence());
1511 ASSERT_TRUE(AllModelsMatch());
1512 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1515 // TCM ID - 3675271 - Merge simple bookmark subset under bookmark folder.
1516 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1517 MC_MergeSimpleBMHierarchySubsetUnderBMFolder
) {
1518 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
1521 for (int i
= 0; i
< 2; ++i
) {
1522 const BookmarkNode
* folder
= AddFolder(i
, kGenericFolderName
);
1523 ASSERT_TRUE(folder
!= NULL
);
1524 for (int j
= 0; j
< 4; ++j
) {
1525 if (base::RandDouble() < 0.5) {
1526 std::string title
= IndexedURLTitle(j
);
1527 GURL url
= GURL(IndexedURL(j
));
1528 ASSERT_TRUE(AddURL(i
, folder
, j
, title
, url
) != NULL
);
1530 std::string title
= IndexedFolderName(j
);
1531 ASSERT_TRUE(AddFolder(i
, folder
, j
, title
) != NULL
);
1535 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1536 ASSERT_TRUE(AwaitQuiescence());
1537 ASSERT_TRUE(AllModelsMatch());
1538 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1541 // TCM ID - 3727284 - Merge subsets of bookmark under bookmark bar.
1542 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1543 MC_MergeSimpleBMHierarchySubsetUnderBookmarkBar
) {
1544 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
1547 for (int i
= 0; i
< 4; ++i
) {
1548 std::string title
= IndexedURLTitle(i
);
1549 GURL url
= GURL(IndexedURL(i
));
1550 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
1553 for (int j
= 0; j
< 2; ++j
) {
1554 std::string title
= IndexedURLTitle(j
);
1555 GURL url
= GURL(IndexedURL(j
));
1556 ASSERT_TRUE(AddURL(1, j
, title
, url
) != NULL
);
1559 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1560 ASSERT_TRUE(AwaitQuiescence());
1561 ASSERT_TRUE(AllModelsMatch());
1562 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1563 ASSERT_FALSE(ContainsDuplicateBookmarks(1));
1566 // TCM ID - 3659294 - Merge simple bookmark hierarchy under bookmark folder.
1567 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1568 MC_Merge_SimpleBMHierarchy_Under_BMFolder
) {
1569 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
1572 const BookmarkNode
* folder0
= AddFolder(0, 0, kGenericFolderName
);
1573 ASSERT_TRUE(folder0
!= NULL
);
1575 0, folder0
, 0, IndexedURLTitle(1), GURL(IndexedURL(1))) != NULL
);
1576 ASSERT_TRUE(AddFolder(0, folder0
, 1, IndexedSubfolderName(2)) != NULL
);
1578 0, folder0
, 2, IndexedURLTitle(3), GURL(IndexedURL(3))) != NULL
);
1579 ASSERT_TRUE(AddFolder(0, folder0
, 3, IndexedSubfolderName(4)) != NULL
);
1581 const BookmarkNode
* folder1
= AddFolder(1, 0, kGenericFolderName
);
1582 ASSERT_TRUE(folder1
!= NULL
);
1583 ASSERT_TRUE(AddFolder(1, folder1
, 0, IndexedSubfolderName(0)) != NULL
);
1584 ASSERT_TRUE(AddFolder(1, folder1
, 1, IndexedSubfolderName(2)) != NULL
);
1586 1, folder1
, 2, IndexedURLTitle(3), GURL(IndexedURL(3))) != NULL
);
1587 ASSERT_TRUE(AddFolder(1, folder1
, 3, IndexedSubfolderName(5)) != NULL
);
1589 1, folder1
, 4, IndexedURLTitle(1), GURL(IndexedURL(1))) != NULL
);
1591 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1592 ASSERT_TRUE(AwaitQuiescence());
1593 ASSERT_TRUE(AllModelsMatch());
1594 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1597 // TCM ID - 3711273 - Merge disjoint sets of bookmark hierarchy under bookmark
1599 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1600 MC_Merge_SimpleBMHierarchy_DisjointSets_Under_BMFolder
) {
1601 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
1604 const BookmarkNode
* folder0
=
1605 AddFolder(0, 0, kGenericFolderName
);
1606 ASSERT_TRUE(folder0
!= NULL
);
1608 0, folder0
, 0, IndexedURLTitle(1), GURL(IndexedURL(1))) != NULL
);
1609 ASSERT_TRUE(AddFolder(0, folder0
, 1, IndexedSubfolderName(2)) != NULL
);
1611 0, folder0
, 2, IndexedURLTitle(3), GURL(IndexedURL(3))) != NULL
);
1612 ASSERT_TRUE(AddFolder(0, folder0
, 3, IndexedSubfolderName(4)) != NULL
);
1614 const BookmarkNode
* folder1
= AddFolder(1, 0, kGenericFolderName
);
1615 ASSERT_TRUE(folder1
!= NULL
);
1616 ASSERT_TRUE(AddFolder(1, folder1
, 0, IndexedSubfolderName(5)) != NULL
);
1617 ASSERT_TRUE(AddFolder(1, folder1
, 1, IndexedSubfolderName(6)) != NULL
);
1619 1, folder1
, 2, IndexedURLTitle(7), GURL(IndexedURL(7))) != NULL
);
1621 1, folder1
, 3, IndexedURLTitle(8), GURL(IndexedURL(8))) != NULL
);
1623 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1624 ASSERT_TRUE(AwaitQuiescence());
1625 ASSERT_TRUE(AllModelsMatch());
1626 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1629 // TCM ID - 3639296 - Merge disjoint sets of bookmark hierarchy under bookmark
1631 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1632 MC_Merge_SimpleBMHierarchy_DisjointSets_Under_BookmarkBar
) {
1633 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
1636 for (int i
= 0; i
< 3; ++i
) {
1637 std::string title
= IndexedURLTitle(i
+1);
1638 GURL url
= GURL(IndexedURL(i
+1));
1639 ASSERT_TRUE(AddURL(0, i
, title
, url
) != NULL
);
1642 for (int j
= 0; j
< 3; ++j
) {
1643 std::string title
= IndexedURLTitle(j
+4);
1644 GURL url
= GURL(IndexedURL(j
+4));
1645 ASSERT_TRUE(AddURL(0, j
, title
, url
) != NULL
);
1648 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1649 ASSERT_TRUE(AwaitQuiescence());
1650 ASSERT_TRUE(AllModelsMatch());
1651 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1654 // TCM ID - 3616282 - Merge sets of duplicate bookmarks under bookmark bar.
1655 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1656 MC_Merge_SimpleBMHierarchy_DuplicateBMs_Under_BMBar
) {
1657 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
1660 // Let's add duplicate set of bookmark {1,2,2,3,3,3,4,4,4,4} to client0.
1662 for (int i
= 1; i
< 5 ; ++i
) {
1663 for (int j
= 0; j
< i
; ++j
) {
1664 std::string title
= IndexedURLTitle(i
);
1665 GURL url
= GURL(IndexedURL(i
));
1666 ASSERT_TRUE(AddURL(0, node_index
, title
, url
) != NULL
);
1670 // Let's add a set of bookmarks {1,2,3,4} to client1.
1671 for (int i
= 0; i
< 4; ++i
) {
1672 std::string title
= IndexedURLTitle(i
+1);
1673 GURL url
= GURL(IndexedURL(i
+1));
1674 ASSERT_TRUE(AddURL(1, i
, title
, url
) != NULL
);
1677 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1678 ASSERT_TRUE(AwaitQuiescence());
1679 ASSERT_TRUE(AllModelsMatch());
1681 for (int i
= 1; i
< 5 ; ++i
) {
1682 ASSERT_TRUE(CountBookmarksWithTitlesMatching(1, IndexedURLTitle(i
)) == i
);
1686 // TCM ID - 6593872.
1687 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, DisableBookmarks
) {
1688 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1689 ASSERT_TRUE(AllModelsMatchVerifier());
1691 ASSERT_TRUE(GetClient(1)->DisableSyncForDatatype(syncer::BOOKMARKS
));
1692 ASSERT_TRUE(AddFolder(1, kGenericFolderName
) != NULL
);
1693 ASSERT_TRUE(AwaitQuiescence());
1694 ASSERT_FALSE(AllModelsMatch());
1696 ASSERT_TRUE(GetClient(1)->EnableSyncForDatatype(syncer::BOOKMARKS
));
1697 ASSERT_TRUE(AwaitQuiescence());
1698 ASSERT_TRUE(AllModelsMatch());
1701 // TCM ID - 7343544.
1702 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, DisableSync
) {
1703 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1704 ASSERT_TRUE(AllModelsMatchVerifier());
1706 ASSERT_TRUE(GetClient(1)->DisableSyncForAllDatatypes());
1707 ASSERT_TRUE(AddFolder(0, IndexedFolderName(0)) != NULL
);
1708 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0))));
1709 ASSERT_FALSE(AllModelsMatch());
1711 ASSERT_TRUE(AddFolder(1, IndexedFolderName(1)) != NULL
);
1712 ASSERT_FALSE(AllModelsMatch());
1714 ASSERT_TRUE(GetClient(1)->EnableSyncForAllDatatypes());
1715 ASSERT_TRUE(AwaitQuiescence());
1716 ASSERT_TRUE(AllModelsMatch());
1719 // TCM ID - 3662298 - Test adding duplicate folder - Both with different BMs
1721 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, MC_DuplicateFolders
) {
1722 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
1725 const BookmarkNode
* folder0
= AddFolder(0, kGenericFolderName
);
1726 ASSERT_TRUE(folder0
!= NULL
);
1727 const BookmarkNode
* folder1
= AddFolder(1, kGenericFolderName
);
1728 ASSERT_TRUE(folder1
!= NULL
);
1729 for (int i
= 0; i
< 5; ++i
) {
1730 std::string title0
= IndexedURLTitle(i
);
1731 GURL url0
= GURL(IndexedURL(i
));
1732 ASSERT_TRUE(AddURL(0, folder0
, i
, title0
, url0
) != NULL
);
1733 std::string title1
= IndexedURLTitle(i
+5);
1734 GURL url1
= GURL(IndexedURL(i
+5));
1735 ASSERT_TRUE(AddURL(1, folder1
, i
, title1
, url1
) != NULL
);
1738 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1739 ASSERT_TRUE(AwaitQuiescence());
1740 ASSERT_TRUE(AllModelsMatch());
1741 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1744 // This test fails when run with FakeServer and FakeServerInvalidationService.
1745 IN_PROC_BROWSER_TEST_F(LegacyTwoClientBookmarksSyncTest
, MC_DeleteBookmark
) {
1746 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1747 ASSERT_TRUE(GetClient(1)->DisableSyncForDatatype(syncer::BOOKMARKS
));
1749 const GURL
bar_url("http://example.com/bar");
1750 const GURL
other_url("http://example.com/other");
1752 ASSERT_TRUE(AddURL(0, GetBookmarkBarNode(0), 0, "bar", bar_url
) != NULL
);
1753 ASSERT_TRUE(AddURL(0, GetOtherNode(0), 0, "other", other_url
) != NULL
);
1755 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0))));
1757 ASSERT_TRUE(HasNodeWithURL(0, bar_url
));
1758 ASSERT_TRUE(HasNodeWithURL(0, other_url
));
1759 ASSERT_FALSE(HasNodeWithURL(1, bar_url
));
1760 ASSERT_FALSE(HasNodeWithURL(1, other_url
));
1762 Remove(0, GetBookmarkBarNode(0), 0);
1763 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0))));
1765 ASSERT_FALSE(HasNodeWithURL(0, bar_url
));
1766 ASSERT_TRUE(HasNodeWithURL(0, other_url
));
1768 ASSERT_TRUE(GetClient(1)->EnableSyncForDatatype(syncer::BOOKMARKS
));
1769 ASSERT_TRUE(AwaitQuiescence());
1771 ASSERT_FALSE(HasNodeWithURL(0, bar_url
));
1772 ASSERT_TRUE(HasNodeWithURL(0, other_url
));
1773 ASSERT_FALSE(HasNodeWithURL(1, bar_url
));
1774 ASSERT_TRUE(HasNodeWithURL(1, other_url
));
1777 // TCM ID - 3719307 - Test a scenario of updating the name of the same bookmark
1778 // from two clients at the same time.
1779 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1780 MC_BookmarkNameChangeConflict
) {
1781 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1783 const BookmarkNode
* folder0
= AddFolder(0, kGenericFolderName
);
1784 ASSERT_TRUE(folder0
!= NULL
);
1785 for (int i
= 0; i
< 3; ++i
) {
1786 std::string title
= IndexedURLTitle(i
);
1787 GURL url
= GURL(IndexedURL(i
));
1788 ASSERT_TRUE(AddURL(0, folder0
, i
, title
, url
) != NULL
);
1790 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1791 ASSERT_TRUE(AllModelsMatchVerifier());
1792 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1795 GURL
url(IndexedURL(0));
1796 SetTitle(0, GetUniqueNodeByURL(0, url
), "Title++");
1797 SetTitle(1, GetUniqueNodeByURL(1, url
), "Title--");
1799 ASSERT_TRUE(AwaitQuiescence());
1800 ASSERT_TRUE(AllModelsMatch());
1801 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1804 // TCM ID - 3672299 - Test a scenario of updating the URL of the same bookmark
1805 // from two clients at the same time.
1806 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1807 MC_BookmarkURLChangeConflict
) {
1808 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1810 const BookmarkNode
* folder0
= AddFolder(0, kGenericFolderName
);
1811 ASSERT_TRUE(folder0
!= NULL
);
1812 for (int i
= 0; i
< 3; ++i
) {
1813 std::string title
= IndexedURLTitle(i
);
1814 GURL url
= GURL(IndexedURL(i
));
1815 ASSERT_TRUE(AddURL(0, folder0
, i
, title
, url
) != NULL
);
1817 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1818 ASSERT_TRUE(AllModelsMatchVerifier());
1819 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1822 GURL
url(IndexedURL(0));
1824 0, GetUniqueNodeByURL(0, url
), GURL("http://www.google.com/00")));
1826 1, GetUniqueNodeByURL(1, url
), GURL("http://www.google.com/11")));
1828 ASSERT_TRUE(AwaitQuiescence());
1829 ASSERT_TRUE(AllModelsMatch());
1830 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1833 // TCM ID - 3699290 - Test a scenario of updating the BM Folder name from two
1834 // clients at the same time.
1835 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1836 MC_FolderNameChangeConflict
) {
1837 ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
1840 const BookmarkNode
* folderA
[2];
1841 const BookmarkNode
* folderB
[2];
1842 const BookmarkNode
* folderC
[2];
1844 // Create empty folder A on both clients.
1845 folderA
[0] = AddFolder(0, IndexedFolderName(0));
1846 ASSERT_TRUE(folderA
[0] != NULL
);
1847 folderA
[1] = AddFolder(1, IndexedFolderName(0));
1848 ASSERT_TRUE(folderA
[1] != NULL
);
1850 // Create folder B with bookmarks on both clients.
1851 folderB
[0] = AddFolder(0, IndexedFolderName(1));
1852 ASSERT_TRUE(folderB
[0] != NULL
);
1853 folderB
[1] = AddFolder(1, IndexedFolderName(1));
1854 ASSERT_TRUE(folderB
[1] != NULL
);
1855 for (int i
= 0; i
< 3; ++i
) {
1856 std::string title
= IndexedURLTitle(i
);
1857 GURL url
= GURL(IndexedURL(i
));
1858 ASSERT_TRUE(AddURL(0, folderB
[0], i
, title
, url
) != NULL
);
1861 // Create folder C with bookmarks and subfolders on both clients.
1862 folderC
[0] = AddFolder(0, IndexedFolderName(2));
1863 ASSERT_TRUE(folderC
[0] != NULL
);
1864 folderC
[1] = AddFolder(1, IndexedFolderName(2));
1865 ASSERT_TRUE(folderC
[1] != NULL
);
1866 for (int i
= 0; i
< 3; ++i
) {
1867 std::string folder_name
= IndexedSubfolderName(i
);
1868 const BookmarkNode
* subfolder
= AddFolder(0, folderC
[0], i
, folder_name
);
1869 ASSERT_TRUE(subfolder
!= NULL
);
1870 for (int j
= 0; j
< 3; ++j
) {
1871 std::string title
= IndexedURLTitle(j
);
1872 GURL url
= GURL(IndexedURL(j
));
1873 ASSERT_TRUE(AddURL(0, subfolder
, j
, title
, url
) != NULL
);
1877 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1878 ASSERT_TRUE(AwaitQuiescence());
1879 ASSERT_TRUE(AllModelsMatch());
1880 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1882 // Simultaneously rename folder A on both clients.
1883 SetTitle(0, folderA
[0], "Folder A++");
1884 SetTitle(1, folderA
[1], "Folder A--");
1885 ASSERT_TRUE(AwaitQuiescence());
1886 ASSERT_TRUE(AllModelsMatch());
1887 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1889 // Simultaneously rename folder B on both clients.
1890 SetTitle(0, folderB
[0], "Folder B++");
1891 SetTitle(1, folderB
[1], "Folder B--");
1892 ASSERT_TRUE(AwaitQuiescence());
1893 ASSERT_TRUE(AllModelsMatch());
1894 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1896 // Simultaneously rename folder C on both clients.
1897 SetTitle(0, folderC
[0], "Folder C++");
1898 SetTitle(1, folderC
[1], "Folder C--");
1899 ASSERT_TRUE(AwaitQuiescence());
1900 ASSERT_TRUE(AllModelsMatch());
1901 ASSERT_FALSE(ContainsDuplicateBookmarks(0));
1904 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1905 SingleClientEnabledEncryption
) {
1906 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1907 ASSERT_TRUE(AllModelsMatchVerifier());
1909 ASSERT_TRUE(EnableEncryption(0));
1910 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1911 ASSERT_TRUE(IsEncryptionComplete(0));
1912 ASSERT_TRUE(IsEncryptionComplete(1));
1913 ASSERT_TRUE(AllModelsMatchVerifier());
1916 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1917 SingleClientEnabledEncryptionAndChanged
) {
1918 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1919 ASSERT_TRUE(AllModelsMatchVerifier());
1921 ASSERT_TRUE(EnableEncryption(0));
1922 ASSERT_TRUE(AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL
);
1923 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1924 ASSERT_TRUE(IsEncryptionComplete(0));
1925 ASSERT_TRUE(IsEncryptionComplete(1));
1926 ASSERT_TRUE(AllModelsMatchVerifier());
1929 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1930 BothClientsEnabledEncryption
) {
1931 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1932 ASSERT_TRUE(AllModelsMatchVerifier());
1934 ASSERT_TRUE(EnableEncryption(0));
1935 ASSERT_TRUE(EnableEncryption(1));
1936 ASSERT_TRUE(AwaitQuiescence());
1937 ASSERT_TRUE(IsEncryptionComplete(0));
1938 ASSERT_TRUE(IsEncryptionComplete(1));
1939 ASSERT_TRUE(AllModelsMatchVerifier());
1942 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1943 SingleClientEnabledEncryptionBothChanged
) {
1944 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1945 ASSERT_TRUE(AllModelsMatchVerifier());
1947 ASSERT_TRUE(EnableEncryption(0));
1948 ASSERT_TRUE(AwaitQuiescence());
1949 ASSERT_TRUE(IsEncryptionComplete(0));
1950 ASSERT_TRUE(IsEncryptionComplete(1));
1951 ASSERT_TRUE(AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL
);
1952 ASSERT_TRUE(AddURL(0, IndexedURLTitle(1), GURL(IndexedURL(1))) != NULL
);
1953 ASSERT_TRUE(AwaitQuiescence());
1954 ASSERT_TRUE(AllModelsMatchVerifier());
1955 ASSERT_TRUE(IsEncryptionComplete(0));
1956 ASSERT_TRUE(IsEncryptionComplete(1));
1959 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1960 SingleClientEnabledEncryptionAndChangedMultipleTimes
) {
1961 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1962 ASSERT_TRUE(AllModelsMatchVerifier());
1964 ASSERT_TRUE(AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL
);
1965 ASSERT_TRUE(EnableEncryption(0));
1966 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1967 ASSERT_TRUE(IsEncryptionComplete(0));
1968 ASSERT_TRUE(IsEncryptionComplete(1));
1969 ASSERT_TRUE(AllModelsMatchVerifier());
1971 ASSERT_TRUE(AddURL(0, IndexedURLTitle(1), GURL(IndexedURL(1))) != NULL
);
1972 ASSERT_TRUE(AddFolder(0, IndexedFolderName(0)) != NULL
);
1973 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1974 ASSERT_TRUE(AllModelsMatchVerifier());
1977 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
1978 FirstClientEnablesEncryptionWithPassSecondChanges
) {
1979 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
1980 ASSERT_TRUE(AllModelsMatchVerifier());
1982 // Add initial bookmarks.
1983 ASSERT_TRUE(AddURL(0, 0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL
);
1984 ASSERT_TRUE(AddURL(0, 1, IndexedURLTitle(1), GURL(IndexedURL(1))) != NULL
);
1985 ASSERT_TRUE(AddURL(0, 2, IndexedURLTitle(2), GURL(IndexedURL(2))) != NULL
);
1986 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1987 ASSERT_TRUE(AllModelsMatchVerifier());
1989 // Set a passphrase and enable encryption on Client 0. Client 1 will not
1990 // understand the bookmark updates.
1991 SetEncryptionPassphrase(0, kValidPassphrase
, ProfileSyncService::EXPLICIT
);
1992 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService((0))));
1993 ASSERT_TRUE(EnableEncryption(0));
1994 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
1995 ASSERT_TRUE(IsEncryptionComplete(0));
1996 ASSERT_TRUE(IsEncryptionComplete(1));
1997 ASSERT_TRUE(GetSyncService((1))->IsPassphraseRequired());
1999 // Client 1 adds bookmarks between the first two and between the second two.
2000 ASSERT_TRUE(AddURL(0, 1, IndexedURLTitle(3), GURL(IndexedURL(3))) != NULL
);
2001 ASSERT_TRUE(AddURL(0, 3, IndexedURLTitle(4), GURL(IndexedURL(4))) != NULL
);
2002 EXPECT_FALSE(AllModelsMatchVerifier());
2003 EXPECT_FALSE(AllModelsMatch());
2005 // Set the passphrase. Everything should resolve.
2006 ASSERT_TRUE(AwaitPassphraseRequired(GetSyncService((1))));
2007 ASSERT_TRUE(SetDecryptionPassphrase(1, kValidPassphrase
));
2008 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService((1))));
2009 ASSERT_TRUE(AwaitQuiescence());
2010 EXPECT_TRUE(AllModelsMatch());
2012 GetClient(1)->GetLastSessionSnapshot().num_encryption_conflicts());
2014 // Ensure everything is syncing normally by appending a final bookmark.
2015 ASSERT_TRUE(AddURL(1, 5, IndexedURLTitle(5), GURL(IndexedURL(5))) != NULL
);
2016 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
2017 EXPECT_TRUE(AllModelsMatch());
2019 GetClient(1)->GetLastSessionSnapshot().num_encryption_conflicts());
2022 // Deliberately racy rearranging of bookmarks to test that our conflict resolver
2023 // code results in a consistent view across machines (no matter what the final
2025 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, RacyPositionChanges
) {
2026 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
2027 ASSERT_TRUE(AllModelsMatchVerifier());
2029 // Add initial bookmarks.
2030 size_t num_bookmarks
= 5;
2031 for (size_t i
= 0; i
< num_bookmarks
; ++i
) {
2032 ASSERT_TRUE(AddURL(0, i
, IndexedURLTitle(i
), GURL(IndexedURL(i
))) != NULL
);
2035 // Once we make diverging changes the verifer is helpless.
2036 ASSERT_TRUE(AwaitQuiescence());
2037 ASSERT_TRUE(AllModelsMatchVerifier());
2040 // Make changes on client 0.
2041 for (size_t i
= 0; i
< num_bookmarks
; ++i
) {
2042 const BookmarkNode
* node
= GetUniqueNodeByURL(0, GURL(IndexedURL(i
)));
2043 int rand_pos
= base::RandInt(0, num_bookmarks
-1);
2044 DVLOG(1) << "Moving client 0's bookmark " << i
<< " to position "
2046 Move(0, node
, node
->parent(), rand_pos
);
2049 // Make changes on client 1.
2050 for (size_t i
= 0; i
< num_bookmarks
; ++i
) {
2051 const BookmarkNode
* node
= GetUniqueNodeByURL(1, GURL(IndexedURL(i
)));
2052 int rand_pos
= base::RandInt(0, num_bookmarks
-1);
2053 DVLOG(1) << "Moving client 1's bookmark " << i
<< " to position "
2055 Move(1, node
, node
->parent(), rand_pos
);
2058 ASSERT_TRUE(AwaitQuiescence());
2059 ASSERT_TRUE(AllModelsMatch());
2061 // Now make changes to client 1 first.
2062 for (size_t i
= 0; i
< num_bookmarks
; ++i
) {
2063 const BookmarkNode
* node
= GetUniqueNodeByURL(1, GURL(IndexedURL(i
)));
2064 int rand_pos
= base::RandInt(0, num_bookmarks
-1);
2065 DVLOG(1) << "Moving client 1's bookmark " << i
<< " to position "
2067 Move(1, node
, node
->parent(), rand_pos
);
2070 // Make changes on client 0.
2071 for (size_t i
= 0; i
< num_bookmarks
; ++i
) {
2072 const BookmarkNode
* node
= GetUniqueNodeByURL(0, GURL(IndexedURL(i
)));
2073 int rand_pos
= base::RandInt(0, num_bookmarks
-1);
2074 DVLOG(1) << "Moving client 0's bookmark " << i
<< " to position "
2076 Move(0, node
, node
->parent(), rand_pos
);
2079 ASSERT_TRUE(AwaitQuiescence());
2080 ASSERT_TRUE(AllModelsMatch());
2083 // Trigger the server side creation of Synced Bookmarks. Ensure both clients
2084 // remain syncing afterwards. Add bookmarks to the synced bookmarks folder
2085 // and ensure both clients receive the boomkmark.
2086 IN_PROC_BROWSER_TEST_F(LegacyTwoClientBookmarksSyncTest
,
2087 CreateSyncedBookmarks
) {
2088 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
2089 ASSERT_TRUE(AllModelsMatchVerifier());
2091 TriggerCreateSyncedBookmarks();
2093 // Add a bookmark on Client 0 and ensure it syncs over. This will also trigger
2094 // both clients downloading the new Synced Bookmarks folder.
2095 ASSERT_TRUE(AddURL(0, "Google", GURL("http://www.google.com")));
2096 ASSERT_TRUE(AwaitQuiescence());
2097 ASSERT_TRUE(AllModelsMatch());
2099 // Now add a bookmark within the Synced Bookmarks folder and ensure it syncs
2101 const BookmarkNode
* synced_bookmarks
= GetSyncedBookmarksNode(0);
2102 ASSERT_TRUE(synced_bookmarks
);
2103 ASSERT_TRUE(AddURL(0, synced_bookmarks
, 0, "Google2",
2104 GURL("http://www.google2.com")));
2105 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
2106 ASSERT_TRUE(AllModelsMatch());
2109 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
,
2110 BookmarkAllNodesRemovedEvent
) {
2112 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
2113 ASSERT_TRUE(AllModelsMatchVerifier());
2119 // -> http://mail.google.com
2120 // -> http://www.google.com
2121 // -> http://news.google.com
2122 // -> http://yahoo.com
2123 // -> http://www.cnn.com
2127 // -> http://yahoo.com
2128 // -> http://gmail.com
2130 const BookmarkNode
* folder0
= AddFolder(0, GetOtherNode(0), 0, "folder0");
2131 const BookmarkNode
* tier1_a
= AddFolder(0, folder0
, 0, "tier1_a");
2132 ASSERT_TRUE(AddURL(0, folder0
, 1, "News", GURL("http://news.google.com")));
2133 ASSERT_TRUE(AddURL(0, folder0
, 2, "Yahoo", GURL("http://www.yahoo.com")));
2134 ASSERT_TRUE(AddURL(0, tier1_a
, 0, "Gmai", GURL("http://mail.google.com")));
2135 ASSERT_TRUE(AddURL(0, tier1_a
, 1, "Google", GURL("http://www.google.com")));
2137 AddURL(0, GetOtherNode(0), 1, "CNN", GURL("http://www.cnn.com")));
2139 ASSERT_TRUE(AddFolder(0, GetBookmarkBarNode(0), 0, "empty_folder"));
2140 const BookmarkNode
* folder1
=
2141 AddFolder(0, GetBookmarkBarNode(0), 1, "folder1");
2142 ASSERT_TRUE(AddURL(0, folder1
, 0, "Yahoo", GURL("http://www.yahoo.com")));
2144 AddURL(0, GetBookmarkBarNode(0), 2, "Gmai", GURL("http://gmail.com")));
2146 ASSERT_TRUE(AwaitQuiescence());
2147 ASSERT_TRUE(AllModelsMatch());
2152 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
2153 // Verify other node has no children now.
2154 EXPECT_EQ(0, GetOtherNode(0)->child_count());
2155 EXPECT_EQ(0, GetBookmarkBarNode(0)->child_count());
2156 ASSERT_TRUE(AllModelsMatch());
2159 // Verifies that managed bookmarks (installed by policy) don't get synced.
2160 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest
, ManagedBookmarks
) {
2161 // Make sure the first Profile has an overridden policy provider.
2162 EXPECT_CALL(policy_provider_
, IsInitializationComplete(testing::_
))
2163 .WillRepeatedly(testing::Return(true));
2164 policy::ProfilePolicyConnectorFactory::GetInstance()->PushProviderForTesting(
2168 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
2169 ASSERT_TRUE(AllModelsMatchVerifier());
2171 // Verify that there are no managed bookmarks at startup in either profile.
2172 // The Managed Bookmarks folder should not be visible at this stage.
2173 const BookmarkNode
* managed_node0
= GetManagedNode(0);
2174 ASSERT_TRUE(managed_node0
->empty());
2175 ASSERT_FALSE(managed_node0
->IsVisible());
2176 const BookmarkNode
* managed_node1
= GetManagedNode(1);
2177 ASSERT_TRUE(managed_node1
->empty());
2178 ASSERT_FALSE(managed_node1
->IsVisible());
2180 // Verify that the bookmark bar node is empty on both profiles too.
2181 const BookmarkNode
* bar_node0
= GetBookmarkBarNode(0);
2182 ASSERT_TRUE(bar_node0
->empty());
2183 ASSERT_TRUE(bar_node0
->IsVisible());
2184 const BookmarkNode
* bar_node1
= GetBookmarkBarNode(1);
2185 ASSERT_TRUE(bar_node1
->empty());
2186 ASSERT_TRUE(bar_node1
->IsVisible());
2188 // Verify that adding a bookmark is observed by the second Profile.
2189 GURL
google_url("http://www.google.com");
2190 ASSERT_TRUE(AddURL(0, "Google", google_url
) != NULL
);
2191 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
2192 ASSERT_TRUE(AllModelsMatchVerifier());
2193 ASSERT_EQ(1, bar_node0
->child_count());
2194 ASSERT_EQ(1, bar_node1
->child_count());
2196 // Set the ManagedBookmarks policy for the first Profile,
2197 // which will add one new managed bookmark.
2198 base::DictionaryValue
* bookmark
= new base::DictionaryValue();
2199 bookmark
->SetString("name", "Managed bookmark");
2200 bookmark
->SetString("url", "youtube.com");
2201 base::ListValue
* list
= new base::ListValue();
2202 list
->Append(bookmark
);
2203 policy::PolicyMap policy
;
2204 policy
.Set(policy::key::kManagedBookmarks
,
2205 policy::POLICY_LEVEL_MANDATORY
, policy::POLICY_SCOPE_USER
,
2207 policy_provider_
.UpdateChromePolicy(policy
);
2208 base::RunLoop().RunUntilIdle();
2210 // Now add another user bookmark and wait for it to sync.
2211 ASSERT_TRUE(AddURL(0, "Google 2", google_url
) != NULL
);
2212 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
2213 ASSERT_TRUE(AllModelsMatchVerifier());
2215 EXPECT_FALSE(GetSyncService(0)->HasUnrecoverableError());
2216 EXPECT_FALSE(GetSyncService(1)->HasUnrecoverableError());
2218 // Verify that the managed bookmark exists in the local model of the first
2219 // Profile, and has a child node.
2220 ASSERT_EQ(1, managed_node0
->child_count());
2221 ASSERT_TRUE(managed_node0
->IsVisible());
2222 EXPECT_EQ(GURL("http://youtube.com/"), managed_node0
->GetChild(0)->url());
2224 // Verify that the second Profile didn't get this node.
2225 ASSERT_EQ(0, managed_node1
->child_count());