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

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

Issue 2365763002: [Sync] Removed passphrase helper methods, removed ((n)) pattern, and fixed lint violations. (Closed)
Patch Set: Removed useless pass-through accessors. Created 4 years, 2 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <utility> 5 #include <utility>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" 10 #include "chrome/browser/sync/test/integration/bookmarks_helper.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 GURL("http://www.pandora.com")); 102 GURL("http://www.pandora.com"));
103 const BookmarkNode* tier1_a_url2 = AddURL( 103 const BookmarkNode* tier1_a_url2 = AddURL(
104 kSingleProfileIndex, tier1_a, 2, "tier1_a_url2", 104 kSingleProfileIndex, tier1_a, 2, "tier1_a_url2",
105 GURL("http://www.facebook.com")); 105 GURL("http://www.facebook.com"));
106 const BookmarkNode* tier1_b_url0 = AddURL( 106 const BookmarkNode* tier1_b_url0 = AddURL(
107 kSingleProfileIndex, tier1_b, 0, "tier1_b_url0", 107 kSingleProfileIndex, tier1_b, 0, "tier1_b_url0",
108 GURL("http://www.nhl.com")); 108 GURL("http://www.nhl.com"));
109 109
110 // Setup sync, wait for its completion, and make sure changes were synced. 110 // Setup sync, wait for its completion, and make sure changes were synced.
111 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 111 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
112 ASSERT_TRUE(AwaitCommitActivityCompletion( 112 ASSERT_TRUE(
113 GetSyncService((kSingleProfileIndex)))); 113 AwaitCommitActivityCompletion(GetSyncService(kSingleProfileIndex)));
114 ASSERT_TRUE(ModelMatchesVerifier(kSingleProfileIndex)); 114 ASSERT_TRUE(ModelMatchesVerifier(kSingleProfileIndex));
115 115
116 // Ultimately we want to end up with the following model; but this test is 116 // Ultimately we want to end up with the following model; but this test is
117 // more about the journey than the destination. 117 // more about the journey than the destination.
118 // 118 //
119 // bookmark_bar 119 // bookmark_bar
120 // -> CNN (www.cnn.com) 120 // -> CNN (www.cnn.com)
121 // -> tier1_a 121 // -> tier1_a
122 // -> tier1_a_url2 (www.facebook.com) 122 // -> tier1_a_url2 (www.facebook.com)
123 // -> tier1_a_url1 (www.pandora.com) 123 // -> tier1_a_url1 (www.pandora.com)
(...skipping 10 matching lines...) Expand all
134 // -> Toronto Maple Leafs (mapleleafs.nhl.com) 134 // -> Toronto Maple Leafs (mapleleafs.nhl.com)
135 // -> Wynn (www.wynnlasvegas.com) 135 // -> Wynn (www.wynnlasvegas.com)
136 // -> tier1_a_url0 136 // -> tier1_a_url0
137 const BookmarkNode* bar = GetBookmarkBarNode(kSingleProfileIndex); 137 const BookmarkNode* bar = GetBookmarkBarNode(kSingleProfileIndex);
138 const BookmarkNode* cnn = AddURL( 138 const BookmarkNode* cnn = AddURL(
139 kSingleProfileIndex, bar, 0, "CNN", GURL("http://www.cnn.com")); 139 kSingleProfileIndex, bar, 0, "CNN", GURL("http://www.cnn.com"));
140 ASSERT_TRUE(cnn != NULL); 140 ASSERT_TRUE(cnn != NULL);
141 Move(kSingleProfileIndex, tier1_a, bar, 1); 141 Move(kSingleProfileIndex, tier1_a, bar, 1);
142 142
143 // Wait for the bookmark position change to sync. 143 // Wait for the bookmark position change to sync.
144 ASSERT_TRUE(AwaitCommitActivityCompletion( 144 ASSERT_TRUE(
145 GetSyncService((kSingleProfileIndex)))); 145 AwaitCommitActivityCompletion(GetSyncService(kSingleProfileIndex)));
146 ASSERT_TRUE(ModelMatchesVerifier(kSingleProfileIndex)); 146 ASSERT_TRUE(ModelMatchesVerifier(kSingleProfileIndex));
147 147
148 const BookmarkNode* porsche = AddURL( 148 const BookmarkNode* porsche = AddURL(
149 kSingleProfileIndex, bar, 2, "Porsche", GURL("http://www.porsche.com")); 149 kSingleProfileIndex, bar, 2, "Porsche", GURL("http://www.porsche.com"));
150 // Rearrange stuff in tier1_a. 150 // Rearrange stuff in tier1_a.
151 ASSERT_EQ(tier1_a, tier1_a_url2->parent()); 151 ASSERT_EQ(tier1_a, tier1_a_url2->parent());
152 ASSERT_EQ(tier1_a, tier1_a_url1->parent()); 152 ASSERT_EQ(tier1_a, tier1_a_url1->parent());
153 Move(kSingleProfileIndex, tier1_a_url2, tier1_a, 0); 153 Move(kSingleProfileIndex, tier1_a_url2, tier1_a, 0);
154 Move(kSingleProfileIndex, tier1_a_url1, tier1_a, 2); 154 Move(kSingleProfileIndex, tier1_a_url1, tier1_a, 2);
155 155
156 // Wait for the rearranged hierarchy to sync. 156 // Wait for the rearranged hierarchy to sync.
157 ASSERT_TRUE(AwaitCommitActivityCompletion( 157 ASSERT_TRUE(
158 GetSyncService((kSingleProfileIndex)))); 158 AwaitCommitActivityCompletion(GetSyncService(kSingleProfileIndex)));
159 ASSERT_TRUE(ModelMatchesVerifier(kSingleProfileIndex)); 159 ASSERT_TRUE(ModelMatchesVerifier(kSingleProfileIndex));
160 160
161 ASSERT_EQ(1, tier1_a_url0->parent()->GetIndexOf(tier1_a_url0)); 161 ASSERT_EQ(1, tier1_a_url0->parent()->GetIndexOf(tier1_a_url0));
162 Move(kSingleProfileIndex, tier1_a_url0, bar, bar->child_count()); 162 Move(kSingleProfileIndex, tier1_a_url0, bar, bar->child_count());
163 const BookmarkNode* boa = AddURL( 163 const BookmarkNode* boa = AddURL(
164 kSingleProfileIndex, bar, bar->child_count(), 164 kSingleProfileIndex, bar, bar->child_count(),
165 "Bank of America", GURL("https://www.bankofamerica.com")); 165 "Bank of America", GURL("https://www.bankofamerica.com"));
166 ASSERT_TRUE(boa != NULL); 166 ASSERT_TRUE(boa != NULL);
167 Move(kSingleProfileIndex, tier1_a_url0, top, top->child_count()); 167 Move(kSingleProfileIndex, tier1_a_url0, top, top->child_count());
168 const BookmarkNode* bubble = AddURL( 168 const BookmarkNode* bubble = AddURL(
169 kSingleProfileIndex, bar, bar->child_count(), "Seattle Bubble", 169 kSingleProfileIndex, bar, bar->child_count(), "Seattle Bubble",
170 GURL("http://seattlebubble.com")); 170 GURL("http://seattlebubble.com"));
171 ASSERT_TRUE(bubble != NULL); 171 ASSERT_TRUE(bubble != NULL);
172 const BookmarkNode* wired = AddURL( 172 const BookmarkNode* wired = AddURL(
173 kSingleProfileIndex, bar, 2, "Wired News", GURL("http://www.wired.com")); 173 kSingleProfileIndex, bar, 2, "Wired News", GURL("http://www.wired.com"));
174 const BookmarkNode* tier2_b = AddFolder( 174 const BookmarkNode* tier2_b = AddFolder(
175 kSingleProfileIndex, tier1_b, 0, "tier2_b"); 175 kSingleProfileIndex, tier1_b, 0, "tier2_b");
176 Move(kSingleProfileIndex, tier1_b_url0, tier2_b, 0); 176 Move(kSingleProfileIndex, tier1_b_url0, tier2_b, 0);
177 Move(kSingleProfileIndex, porsche, bar, 0); 177 Move(kSingleProfileIndex, porsche, bar, 0);
178 SetTitle(kSingleProfileIndex, wired, "News Wired"); 178 SetTitle(kSingleProfileIndex, wired, "News Wired");
179 SetTitle(kSingleProfileIndex, porsche, "ICanHazPorsche?"); 179 SetTitle(kSingleProfileIndex, porsche, "ICanHazPorsche?");
180 180
181 // Wait for the title change to sync. 181 // Wait for the title change to sync.
182 ASSERT_TRUE(AwaitCommitActivityCompletion( 182 ASSERT_TRUE(
183 GetSyncService((kSingleProfileIndex)))); 183 AwaitCommitActivityCompletion(GetSyncService(kSingleProfileIndex)));
184 ASSERT_TRUE(ModelMatchesVerifier(kSingleProfileIndex)); 184 ASSERT_TRUE(ModelMatchesVerifier(kSingleProfileIndex));
185 185
186 ASSERT_EQ(tier1_a_url0->id(), top->GetChild(top->child_count() - 1)->id()); 186 ASSERT_EQ(tier1_a_url0->id(), top->GetChild(top->child_count() - 1)->id());
187 Remove(kSingleProfileIndex, top, top->child_count() - 1); 187 Remove(kSingleProfileIndex, top, top->child_count() - 1);
188 Move(kSingleProfileIndex, wired, tier1_b, 0); 188 Move(kSingleProfileIndex, wired, tier1_b, 0);
189 Move(kSingleProfileIndex, porsche, bar, 3); 189 Move(kSingleProfileIndex, porsche, bar, 3);
190 const BookmarkNode* tier3_b = AddFolder( 190 const BookmarkNode* tier3_b = AddFolder(
191 kSingleProfileIndex, tier2_b, 1, "tier3_b"); 191 kSingleProfileIndex, tier2_b, 1, "tier3_b");
192 const BookmarkNode* leafs = AddURL( 192 const BookmarkNode* leafs = AddURL(
193 kSingleProfileIndex, tier1_a, 0, "Toronto Maple Leafs", 193 kSingleProfileIndex, tier1_a, 0, "Toronto Maple Leafs",
194 GURL("http://mapleleafs.nhl.com")); 194 GURL("http://mapleleafs.nhl.com"));
195 const BookmarkNode* wynn = AddURL( 195 const BookmarkNode* wynn = AddURL(
196 kSingleProfileIndex, bar, 1, "Wynn", GURL("http://www.wynnlasvegas.com")); 196 kSingleProfileIndex, bar, 1, "Wynn", GURL("http://www.wynnlasvegas.com"));
197 197
198 Move(kSingleProfileIndex, wynn, tier3_b, 0); 198 Move(kSingleProfileIndex, wynn, tier3_b, 0);
199 Move(kSingleProfileIndex, leafs, tier3_b, 0); 199 Move(kSingleProfileIndex, leafs, tier3_b, 0);
200 200
201 // Wait for newly added bookmarks to sync. 201 // Wait for newly added bookmarks to sync.
202 ASSERT_TRUE(AwaitCommitActivityCompletion( 202 ASSERT_TRUE(
203 GetSyncService((kSingleProfileIndex)))); 203 AwaitCommitActivityCompletion(GetSyncService(kSingleProfileIndex)));
204 ASSERT_TRUE(ModelMatchesVerifier(kSingleProfileIndex)); 204 ASSERT_TRUE(ModelMatchesVerifier(kSingleProfileIndex));
205 205
206 // Only verify FakeServer data if FakeServer is being used. 206 // Only verify FakeServer data if FakeServer is being used.
207 // TODO(pvalenzuela): Use this style of verification in more tests once it is 207 // TODO(pvalenzuela): Use this style of verification in more tests once it is
208 // proven stable. 208 // proven stable.
209 if (GetFakeServer()) 209 if (GetFakeServer())
210 VerifyBookmarkModelMatchesFakeServer(kSingleProfileIndex); 210 VerifyBookmarkModelMatchesFakeServer(kSingleProfileIndex);
211 } 211 }
212 212
213 IN_PROC_BROWSER_TEST_F(SingleClientBookmarksSyncTest, InjectedBookmark) { 213 IN_PROC_BROWSER_TEST_F(SingleClientBookmarksSyncTest, InjectedBookmark) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 // Simulate receiving a favicon from sync encoded by a different PNG encoder 248 // Simulate receiving a favicon from sync encoded by a different PNG encoder
249 // than the one native to the OS. This tests the PNG data is not decoded to 249 // than the one native to the OS. This tests the PNG data is not decoded to
250 // SkBitmap (or any other image format) then encoded back to PNG on the path 250 // SkBitmap (or any other image format) then encoded back to PNG on the path
251 // between sync and the database. 251 // between sync and the database.
252 gfx::Image original_favicon = Create1xFaviconFromPNGFile( 252 gfx::Image original_favicon = Create1xFaviconFromPNGFile(
253 "favicon_cocoa_png_codec.png"); 253 "favicon_cocoa_png_codec.png");
254 ASSERT_FALSE(original_favicon.IsEmpty()); 254 ASSERT_FALSE(original_favicon.IsEmpty());
255 SetFavicon(kSingleProfileIndex, bookmark, icon_url, original_favicon, 255 SetFavicon(kSingleProfileIndex, bookmark, icon_url, original_favicon,
256 bookmarks_helper::FROM_SYNC); 256 bookmarks_helper::FROM_SYNC);
257 257
258 ASSERT_TRUE(AwaitCommitActivityCompletion( 258 ASSERT_TRUE(
259 GetSyncService((kSingleProfileIndex)))); 259 AwaitCommitActivityCompletion(GetSyncService(kSingleProfileIndex)));
260 ASSERT_TRUE(ModelMatchesVerifier(kSingleProfileIndex)); 260 ASSERT_TRUE(ModelMatchesVerifier(kSingleProfileIndex));
261 261
262 scoped_refptr<base::RefCountedMemory> original_favicon_bytes = 262 scoped_refptr<base::RefCountedMemory> original_favicon_bytes =
263 original_favicon.As1xPNGBytes(); 263 original_favicon.As1xPNGBytes();
264 gfx::Image final_favicon = 264 gfx::Image final_favicon =
265 GetBookmarkModel(kSingleProfileIndex)->GetFavicon(bookmark); 265 GetBookmarkModel(kSingleProfileIndex)->GetFavicon(bookmark);
266 scoped_refptr<base::RefCountedMemory> final_favicon_bytes = 266 scoped_refptr<base::RefCountedMemory> final_favicon_bytes =
267 final_favicon.As1xPNGBytes(); 267 final_favicon.As1xPNGBytes();
268 268
269 // Check that the data was not mutated from the original. 269 // Check that the data was not mutated from the original.
(...skipping 14 matching lines...) Expand all
284 // -> http://yahoo.com 284 // -> http://yahoo.com
285 // -> http://www.cnn.com 285 // -> http://www.cnn.com
286 // bookmark_bar 286 // bookmark_bar
287 // -> empty_folder 287 // -> empty_folder
288 // -> folder1 288 // -> folder1
289 // -> http://yahoo.com 289 // -> http://yahoo.com
290 // -> http://gmail.com 290 // -> http://gmail.com
291 291
292 const BookmarkNode* folder0 = AddFolder( 292 const BookmarkNode* folder0 = AddFolder(
293 kSingleProfileIndex, GetOtherNode(kSingleProfileIndex), 0, "folder0"); 293 kSingleProfileIndex, GetOtherNode(kSingleProfileIndex), 0, "folder0");
294 const BookmarkNode* tier1_a = AddFolder( 294 const BookmarkNode* tier1_a =
295 kSingleProfileIndex, folder0, 0, "tier1_a"); 295 AddFolder(kSingleProfileIndex, folder0, 0, "tier1_a");
296 ASSERT_TRUE(AddURL( 296 ASSERT_TRUE(AddURL(kSingleProfileIndex, folder0, 1, "News",
297 kSingleProfileIndex, folder0, 1, "News", GURL("http://news.google.com"))); 297 GURL("http://news.google.com")));
298 ASSERT_TRUE(AddURL( 298 ASSERT_TRUE(AddURL(kSingleProfileIndex, folder0, 2, "Yahoo",
299 kSingleProfileIndex, folder0, 2, "Yahoo", GURL("http://www.yahoo.com"))); 299 GURL("http://www.yahoo.com")));
300 ASSERT_TRUE(AddURL( 300 ASSERT_TRUE(AddURL(kSingleProfileIndex, tier1_a, 0, "Gmai",
301 kSingleProfileIndex, tier1_a, 0, "Gmai", GURL("http://mail.google.com"))); 301 GURL("http://mail.google.com")));
302 ASSERT_TRUE(AddURL( 302 ASSERT_TRUE(AddURL(kSingleProfileIndex, tier1_a, 1, "Google",
303 kSingleProfileIndex, tier1_a, 1, "Google", GURL("http://www.google.com"))) ; 303 GURL("http://www.google.com")));
304 ASSERT_TRUE(AddURL( 304 ASSERT_TRUE(AddURL(kSingleProfileIndex, GetOtherNode(kSingleProfileIndex), 1,
305 kSingleProfileIndex, GetOtherNode(kSingleProfileIndex), 1, "CNN", 305 "CNN", GURL("http://www.cnn.com")));
306 GURL("http://www.cnn.com")));
307 306
308 ASSERT_TRUE(AddFolder( 307 ASSERT_TRUE(AddFolder(kSingleProfileIndex,
309 kSingleProfileIndex, GetBookmarkBarNode(kSingleProfileIndex), 0, 308 GetBookmarkBarNode(kSingleProfileIndex), 0,
310 "empty_folder")); 309 "empty_folder"));
311 const BookmarkNode* folder1 = AddFolder( 310 const BookmarkNode* folder1 =
312 kSingleProfileIndex, GetBookmarkBarNode(kSingleProfileIndex), 1, 311 AddFolder(kSingleProfileIndex, GetBookmarkBarNode(kSingleProfileIndex), 1,
313 "folder1"); 312 "folder1");
314 ASSERT_TRUE(AddURL( 313 ASSERT_TRUE(AddURL(kSingleProfileIndex, folder1, 0, "Yahoo",
315 kSingleProfileIndex, folder1, 0, "Yahoo", GURL("http://www.yahoo.com"))); 314 GURL("http://www.yahoo.com")));
316 ASSERT_TRUE(AddURL( 315 ASSERT_TRUE(AddURL(kSingleProfileIndex, GetBookmarkBarNode(0), 2, "Gmai",
317 kSingleProfileIndex, GetBookmarkBarNode(0), 2, "Gmai", 316 GURL("http://gmail.com")));
318 GURL("http://gmail.com")));
319 317
320 // Set up sync, wait for its completion and verify that changes propagated. 318 // Set up sync, wait for its completion and verify that changes propagated.
321 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 319 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
322 ASSERT_TRUE(AwaitCommitActivityCompletion( 320 ASSERT_TRUE(
323 GetSyncService((kSingleProfileIndex)))); 321 AwaitCommitActivityCompletion(GetSyncService(kSingleProfileIndex)));
324 ASSERT_TRUE(ModelMatchesVerifier(kSingleProfileIndex)); 322 ASSERT_TRUE(ModelMatchesVerifier(kSingleProfileIndex));
325 323
326 // Remove all bookmarks and wait for sync completion. 324 // Remove all bookmarks and wait for sync completion.
327 RemoveAll(kSingleProfileIndex); 325 RemoveAll(kSingleProfileIndex);
328 ASSERT_TRUE(AwaitCommitActivityCompletion( 326 ASSERT_TRUE(
329 GetSyncService((kSingleProfileIndex)))); 327 AwaitCommitActivityCompletion(GetSyncService(kSingleProfileIndex)));
330 // Verify other node has no children now. 328 // Verify other node has no children now.
331 EXPECT_EQ(0, GetOtherNode(kSingleProfileIndex)->child_count()); 329 EXPECT_EQ(0, GetOtherNode(kSingleProfileIndex)->child_count());
332 EXPECT_EQ(0, GetBookmarkBarNode(kSingleProfileIndex)->child_count()); 330 EXPECT_EQ(0, GetBookmarkBarNode(kSingleProfileIndex)->child_count());
333 // Verify model matches verifier. 331 // Verify model matches verifier.
334 ASSERT_TRUE(ModelMatchesVerifier(kSingleProfileIndex)); 332 ASSERT_TRUE(ModelMatchesVerifier(kSingleProfileIndex));
335 } 333 }
336 334
337 IN_PROC_BROWSER_TEST_F(SingleClientBookmarksSyncTest, 335 IN_PROC_BROWSER_TEST_F(SingleClientBookmarksSyncTest,
338 DownloadDeletedBookmark) { 336 DownloadDeletedBookmark) {
339 std::string title = "Patrick Star"; 337 std::string title = "Patrick Star";
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 ASSERT_EQ(0, CountFoldersWithTitlesMatching(kSingleProfileIndex, title)); 414 ASSERT_EQ(0, CountFoldersWithTitlesMatching(kSingleProfileIndex, title));
417 415
418 ASSERT_TRUE(SetupSync()); 416 ASSERT_TRUE(SetupSync());
419 417
420 ASSERT_EQ(1, CountFoldersWithTitlesMatching(kSingleProfileIndex, title)); 418 ASSERT_EQ(1, CountFoldersWithTitlesMatching(kSingleProfileIndex, title));
421 } 419 }
422 420
423 IN_PROC_BROWSER_TEST_F(SingleClientBookmarksSyncTest, E2E_ONLY(SanitySetup)) { 421 IN_PROC_BROWSER_TEST_F(SingleClientBookmarksSyncTest, E2E_ONLY(SanitySetup)) {
424 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 422 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
425 } 423 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698