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

Side by Side Diff: chrome/test/live_sync/single_client_live_bookmarks_sync_unittest.cc

Issue 159728: Add browser/sync to the repository. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2006-2009 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.
4
5 #ifdef CHROME_PERSONALIZATION
6
7 #include "base/command_line.h"
8 #include "chrome/browser/bookmarks/bookmark_model.h"
9 #include "chrome/browser/browser.h"
10 #include "chrome/browser/profile.h"
11 #include "chrome/browser/sync/personalization.h"
12 #include "chrome/browser/sync/profile_sync_service.h"
13 #include "chrome/test/live_sync/bookmark_model_verifier.h"
14 #include "chrome/test/live_sync/profile_sync_service_test_harness.h"
15 #include "chrome/test/live_sync/live_bookmarks_sync_test.h"
16
17 class SingleClientLiveBookmarksSyncTest : public LiveBookmarksSyncTest {
18 public:
19 SingleClientLiveBookmarksSyncTest() { }
20 ~SingleClientLiveBookmarksSyncTest() { }
21
22 bool SetupSync() {
23 client_.reset(new ProfileSyncServiceTestHarness(
24 browser()->profile(), username_, password_));
25 return client_->SetupSync();
26 }
27
28 ProfileSyncServiceTestHarness* client() { return client_.get(); }
29 ProfileSyncService* service() { return client_->service(); }
30
31 private:
32 scoped_ptr<ProfileSyncServiceTestHarness> client_;
33
34 DISALLOW_COPY_AND_ASSIGN(SingleClientLiveBookmarksSyncTest);
35 };
36
37 IN_PROC_BROWSER_TEST_F(SingleClientLiveBookmarksSyncTest, Sanity) {
38 scoped_ptr<BookmarkModelVerifier> verifier(BookmarkModelVerifier::Create());
39 BookmarkModel* m = browser()->profile()->GetBookmarkModel();
40 BlockUntilLoaded(m);
41
42 // Starting state:
43 // other_node
44 // -> top
45 // -> tier1_a
46 // -> http://mail.google.com "tier1_a_url0"
47 // -> http://www.pandora.com "tier1_a_url1"
48 // -> http://www.facebook.com "tier1_a_url2"
49 // -> tier1_b
50 // -> http://www.nhl.com "tier1_b_url0"
51 const BookmarkNode* top = verifier->AddGroup(m, m->other_node(), 0, L"top");
52 const BookmarkNode* tier1_a = verifier->AddGroup(m, top, 0, L"tier1_a");
53 const BookmarkNode* tier1_b = verifier->AddGroup(m, top, 1, L"tier1_b");
54 const BookmarkNode* t1au0 = verifier->AddURL(m, tier1_a, 0, L"tier1_a_url0",
55 GURL(L"http://mail.google.com"));
56 const BookmarkNode* t1au1 = verifier->AddURL(m, tier1_a, 1, L"tier1_a_url1",
57 GURL(L"http://www.pandora.com"));
58 const BookmarkNode* t1au2 = verifier->AddURL(
59 m, tier1_a, 2, L"tier1_a_url2", GURL(L"http://www.facebook.com"));
60 const BookmarkNode* t1bu0 = verifier->AddURL(m, tier1_b, 0, L"tier1_b_url0",
61 GURL(L"http://www.nhl.com"));
62
63 ASSERT_TRUE(SetupSync()) << "Failed to SetupSync";
64 // SetupSync returns after init, which means got_zero_updates, which means
65 // before we merge and associate, so we now have to wait for our above state
66 // to round-trip.
67 ASSERT_TRUE(client()->AwaitSyncCycleCompletion(
68 "Waiting for initial sync completed."));
69 verifier->ExpectMatch(m);
70
71 // Ultimately we want to end up with the following model; but this test is
72 // more about the journey than the destination.
73 //
74 // bookmark_bar
75 // -> CNN (www.cnn.com)
76 // -> tier1_a
77 // -> tier1_a_url2 (www.facebook.com)
78 // -> tier1_a_url1 (www.pandora.com)
79 // -> Porsche (www.porsche.com)
80 // -> Bank of America (www.bankofamerica.com)
81 // -> Seattle Bubble
82 // other_node
83 // -> top
84 // -> tier1_b
85 // -> Wired News (www.wired.com)
86 // -> tier2_b
87 // -> tier1_b_url0
88 // -> tier3_b
89 // -> Toronto Maple Leafs (mapleleafs.nhl.com)
90 // -> Wynn (www.wynnlasvegas.com)
91 // -> tier1_a_url0
92 const BookmarkNode* bar = m->GetBookmarkBarNode();
93 const BookmarkNode* cnn =
94 verifier->AddURL(m, bar, 0, L"CNN", GURL(L"http://www.cnn.com"));
95 verifier->Move(m, tier1_a, bar, 1); // 1 should be the end at this point.
96 ASSERT_TRUE(client()->AwaitSyncCycleCompletion("Bookmark moved."));
97 verifier->ExpectMatch(m);
98
99 const BookmarkNode* porsche = verifier->AddURL(
100 m, bar, 2, L"Porsche", GURL(L"http://www.porsche.com"));
101 // Rearrange stuff in tier1_a.
102 EXPECT_EQ(tier1_a, t1au2->GetParent());
103 EXPECT_EQ(tier1_a, t1au1->GetParent());
104 verifier->Move(m, t1au2, tier1_a, 0);
105 verifier->Move(m, t1au1, tier1_a, 2);
106 ASSERT_TRUE(client()->AwaitSyncCycleCompletion("Rearrange stuff in tier1_a"));
107 verifier->ExpectMatch(m);
108
109 EXPECT_EQ(1, t1au0->GetParent()->IndexOfChild(t1au0));
110 verifier->Move(m, t1au0, bar, bar->GetChildCount());
111 const BookmarkNode* boa = verifier->AddURL(m, bar, bar->GetChildCount(),
112 L"Bank of America", GURL(L"https://www.bankofamerica.com"));
113 verifier->Move(m, t1au0, top, top->GetChildCount());
114 const BookmarkNode* bubble = verifier->AddURL(m, bar, bar->GetChildCount(),
115 L"Seattle Bubble", GURL(L"http://seattlebubble.com"));
116 const BookmarkNode* wired = verifier->AddURL(m, bar, 2, L"Wired News",
117 GURL(L"http://www.wired.com"));
118 const BookmarkNode* tier2_b = verifier->AddGroup(m, tier1_b, 0, L"tier2_b");
119 verifier->Move(m, t1bu0, tier2_b, 0);
120 verifier->Move(m, porsche, bar, 0);
121 verifier->SetTitle(m, wired, L"News Wired");
122 verifier->SetTitle(m, porsche, L"ICanHazPorsche?");
123 ASSERT_TRUE(client()->AwaitSyncCycleCompletion("Change title."));
124 verifier->ExpectMatch(m);
125
126 EXPECT_EQ(t1au0->id(), top->GetChild(top->GetChildCount() - 1)->id());
127 verifier->Remove(m, top, top->GetChildCount() - 1);
128 verifier->Move(m, wired, tier1_b, 0);
129 verifier->Move(m, porsche, bar, 3);
130 const BookmarkNode* tier3_b = verifier->AddGroup(m, tier2_b, 1, L"tier3_b");
131 const BookmarkNode* leafs = verifier->AddURL(
132 m, tier1_a, 0, L"Toronto Maple Leafs",
133 GURL(L"http://mapleleafs.nhl.com"));
134 const BookmarkNode* wynn = verifier->AddURL(
135 m, bar, 1, L"Wynn", GURL(L"http://www.wynnlasvegas.com"));
136
137 verifier->Move(m, wynn, tier3_b, 0);
138 verifier->Move(m, leafs, tier3_b, 0);
139 ASSERT_TRUE(client()->AwaitSyncCycleCompletion(
140 "Move after addition of bookmarks."));
141 verifier->ExpectMatch(m);
142 }
143
144 // Connects a client with no bookmarks to a cloud account. As a natural
145 // consequence of shutdown, this will encode the BookmarkModel as JSON to the
146 // 'Bookmarks' file. This is mostly useful to verify server state.
147 // DISABLED because it should be; we use this as a utility more than a test.
148 IN_PROC_BROWSER_TEST_F(SingleClientLiveBookmarksSyncTest, DISABLED_GetUpdates) {
149 ASSERT_TRUE(SetupSync()) << "Failed to SetupSync";
150 BlockUntilLoaded(browser()->profile()->GetBookmarkModel());
151 EXPECT_TRUE(client()->ServiceIsPushingChanges());
152 ProfileSyncService::Status status(service()->QueryDetailedSyncStatus());
153 EXPECT_EQ(status.summary, ProfileSyncService::Status::READY);
154 EXPECT_EQ(status.unsynced_count, 0);
155 }
156
157 #endif // CHROME_PERSONALIZATION
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698