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

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

Issue 148723002: [sync] Eliminate Await*SyncCompletion methods in integration tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address feedback Created 6 years, 10 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
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 "chrome/browser/profiles/profile.h" 5 #include "chrome/browser/profiles/profile.h"
6 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" 6 #include "chrome/browser/sync/test/integration/bookmarks_helper.h"
7 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" 7 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
8 #include "chrome/browser/sync/test/integration/sync_test.h" 8 #include "chrome/browser/sync/test/integration/sync_test.h"
9 #include "ui/base/layout.h" 9 #include "ui/base/layout.h"
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 0, tier1_a, 0, L"tier1_a_url0", GURL("http://mail.google.com")); 49 0, tier1_a, 0, L"tier1_a_url0", GURL("http://mail.google.com"));
50 const BookmarkNode* tier1_a_url1 = AddURL( 50 const BookmarkNode* tier1_a_url1 = AddURL(
51 0, tier1_a, 1, L"tier1_a_url1", GURL("http://www.pandora.com")); 51 0, tier1_a, 1, L"tier1_a_url1", GURL("http://www.pandora.com"));
52 const BookmarkNode* tier1_a_url2 = AddURL( 52 const BookmarkNode* tier1_a_url2 = AddURL(
53 0, tier1_a, 2, L"tier1_a_url2", GURL("http://www.facebook.com")); 53 0, tier1_a, 2, L"tier1_a_url2", GURL("http://www.facebook.com"));
54 const BookmarkNode* tier1_b_url0 = AddURL( 54 const BookmarkNode* tier1_b_url0 = AddURL(
55 0, tier1_b, 0, L"tier1_b_url0", GURL("http://www.nhl.com")); 55 0, tier1_b, 0, L"tier1_b_url0", GURL("http://www.nhl.com"));
56 56
57 // Setup sync, wait for its completion, and make sure changes were synced. 57 // Setup sync, wait for its completion, and make sure changes were synced.
58 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 58 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
59 ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion()); 59 ASSERT_TRUE(GetClient(0)->AwaitCommitActivityCompletion());
60 ASSERT_TRUE(ModelMatchesVerifier(0)); 60 ASSERT_TRUE(ModelMatchesVerifier(0));
61 61
62 // Ultimately we want to end up with the following model; but this test is 62 // Ultimately we want to end up with the following model; but this test is
63 // more about the journey than the destination. 63 // more about the journey than the destination.
64 // 64 //
65 // bookmark_bar 65 // bookmark_bar
66 // -> CNN (www.cnn.com) 66 // -> CNN (www.cnn.com)
67 // -> tier1_a 67 // -> tier1_a
68 // -> tier1_a_url2 (www.facebook.com) 68 // -> tier1_a_url2 (www.facebook.com)
69 // -> tier1_a_url1 (www.pandora.com) 69 // -> tier1_a_url1 (www.pandora.com)
(...skipping 10 matching lines...) Expand all
80 // -> Toronto Maple Leafs (mapleleafs.nhl.com) 80 // -> Toronto Maple Leafs (mapleleafs.nhl.com)
81 // -> Wynn (www.wynnlasvegas.com) 81 // -> Wynn (www.wynnlasvegas.com)
82 // -> tier1_a_url0 82 // -> tier1_a_url0
83 const BookmarkNode* bar = GetBookmarkBarNode(0); 83 const BookmarkNode* bar = GetBookmarkBarNode(0);
84 const BookmarkNode* cnn = AddURL(0, bar, 0, L"CNN", 84 const BookmarkNode* cnn = AddURL(0, bar, 0, L"CNN",
85 GURL("http://www.cnn.com")); 85 GURL("http://www.cnn.com"));
86 ASSERT_TRUE(cnn != NULL); 86 ASSERT_TRUE(cnn != NULL);
87 Move(0, tier1_a, bar, 1); 87 Move(0, tier1_a, bar, 1);
88 88
89 // Wait for the bookmark position change to sync. 89 // Wait for the bookmark position change to sync.
90 ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion()); 90 ASSERT_TRUE(GetClient(0)->AwaitCommitActivityCompletion());
91 ASSERT_TRUE(ModelMatchesVerifier(0)); 91 ASSERT_TRUE(ModelMatchesVerifier(0));
92 92
93 const BookmarkNode* porsche = AddURL(0, bar, 2, L"Porsche", 93 const BookmarkNode* porsche = AddURL(0, bar, 2, L"Porsche",
94 GURL("http://www.porsche.com")); 94 GURL("http://www.porsche.com"));
95 // Rearrange stuff in tier1_a. 95 // Rearrange stuff in tier1_a.
96 ASSERT_EQ(tier1_a, tier1_a_url2->parent()); 96 ASSERT_EQ(tier1_a, tier1_a_url2->parent());
97 ASSERT_EQ(tier1_a, tier1_a_url1->parent()); 97 ASSERT_EQ(tier1_a, tier1_a_url1->parent());
98 Move(0, tier1_a_url2, tier1_a, 0); 98 Move(0, tier1_a_url2, tier1_a, 0);
99 Move(0, tier1_a_url1, tier1_a, 2); 99 Move(0, tier1_a_url1, tier1_a, 2);
100 100
101 // Wait for the rearranged hierarchy to sync. 101 // Wait for the rearranged hierarchy to sync.
102 ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion()); 102 ASSERT_TRUE(GetClient(0)->AwaitCommitActivityCompletion());
103 ASSERT_TRUE(ModelMatchesVerifier(0)); 103 ASSERT_TRUE(ModelMatchesVerifier(0));
104 104
105 ASSERT_EQ(1, tier1_a_url0->parent()->GetIndexOf(tier1_a_url0)); 105 ASSERT_EQ(1, tier1_a_url0->parent()->GetIndexOf(tier1_a_url0));
106 Move(0, tier1_a_url0, bar, bar->child_count()); 106 Move(0, tier1_a_url0, bar, bar->child_count());
107 const BookmarkNode* boa = AddURL(0, bar, bar->child_count(), 107 const BookmarkNode* boa = AddURL(0, bar, bar->child_count(),
108 L"Bank of America", GURL("https://www.bankofamerica.com")); 108 L"Bank of America", GURL("https://www.bankofamerica.com"));
109 ASSERT_TRUE(boa != NULL); 109 ASSERT_TRUE(boa != NULL);
110 Move(0, tier1_a_url0, top, top->child_count()); 110 Move(0, tier1_a_url0, top, top->child_count());
111 const BookmarkNode* bubble = AddURL( 111 const BookmarkNode* bubble = AddURL(
112 0, bar, bar->child_count(), L"Seattle Bubble", 112 0, bar, bar->child_count(), L"Seattle Bubble",
113 GURL("http://seattlebubble.com")); 113 GURL("http://seattlebubble.com"));
114 ASSERT_TRUE(bubble != NULL); 114 ASSERT_TRUE(bubble != NULL);
115 const BookmarkNode* wired = AddURL(0, bar, 2, L"Wired News", 115 const BookmarkNode* wired = AddURL(0, bar, 2, L"Wired News",
116 GURL("http://www.wired.com")); 116 GURL("http://www.wired.com"));
117 const BookmarkNode* tier2_b = AddFolder( 117 const BookmarkNode* tier2_b = AddFolder(
118 0, tier1_b, 0, L"tier2_b"); 118 0, tier1_b, 0, L"tier2_b");
119 Move(0, tier1_b_url0, tier2_b, 0); 119 Move(0, tier1_b_url0, tier2_b, 0);
120 Move(0, porsche, bar, 0); 120 Move(0, porsche, bar, 0);
121 SetTitle(0, wired, L"News Wired"); 121 SetTitle(0, wired, L"News Wired");
122 SetTitle(0, porsche, L"ICanHazPorsche?"); 122 SetTitle(0, porsche, L"ICanHazPorsche?");
123 123
124 // Wait for the title change to sync. 124 // Wait for the title change to sync.
125 ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion()); 125 ASSERT_TRUE(GetClient(0)->AwaitCommitActivityCompletion());
126 ASSERT_TRUE(ModelMatchesVerifier(0)); 126 ASSERT_TRUE(ModelMatchesVerifier(0));
127 127
128 ASSERT_EQ(tier1_a_url0->id(), top->GetChild(top->child_count() - 1)->id()); 128 ASSERT_EQ(tier1_a_url0->id(), top->GetChild(top->child_count() - 1)->id());
129 Remove(0, top, top->child_count() - 1); 129 Remove(0, top, top->child_count() - 1);
130 Move(0, wired, tier1_b, 0); 130 Move(0, wired, tier1_b, 0);
131 Move(0, porsche, bar, 3); 131 Move(0, porsche, bar, 3);
132 const BookmarkNode* tier3_b = AddFolder(0, tier2_b, 1, L"tier3_b"); 132 const BookmarkNode* tier3_b = AddFolder(0, tier2_b, 1, L"tier3_b");
133 const BookmarkNode* leafs = AddURL( 133 const BookmarkNode* leafs = AddURL(
134 0, tier1_a, 0, L"Toronto Maple Leafs", GURL("http://mapleleafs.nhl.com")); 134 0, tier1_a, 0, L"Toronto Maple Leafs", GURL("http://mapleleafs.nhl.com"));
135 const BookmarkNode* wynn = AddURL(0, bar, 1, L"Wynn", 135 const BookmarkNode* wynn = AddURL(0, bar, 1, L"Wynn",
136 GURL("http://www.wynnlasvegas.com")); 136 GURL("http://www.wynnlasvegas.com"));
137 137
138 Move(0, wynn, tier3_b, 0); 138 Move(0, wynn, tier3_b, 0);
139 Move(0, leafs, tier3_b, 0); 139 Move(0, leafs, tier3_b, 0);
140 140
141 // Wait for newly added bookmarks to sync. 141 // Wait for newly added bookmarks to sync.
142 ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion()); 142 ASSERT_TRUE(GetClient(0)->AwaitCommitActivityCompletion());
143 ASSERT_TRUE(ModelMatchesVerifier(0)); 143 ASSERT_TRUE(ModelMatchesVerifier(0));
144 } 144 }
145 145
146 // Test that a client doesn't mutate the favicon data in the process 146 // Test that a client doesn't mutate the favicon data in the process
147 // of storing the favicon data from sync to the database or in the process 147 // of storing the favicon data from sync to the database or in the process
148 // of requesting data from the database for sync. 148 // of requesting data from the database for sync.
149 IN_PROC_BROWSER_TEST_F(SingleClientBookmarksSyncTest, 149 IN_PROC_BROWSER_TEST_F(SingleClientBookmarksSyncTest,
150 SetFaviconHiDPIDifferentCodec) { 150 SetFaviconHiDPIDifferentCodec) {
151 // Set the supported scale factors to 1x and 2x such that 151 // Set the supported scale factors to 1x and 2x such that
152 // BookmarkModel::GetFavicon() requests both 1x and 2x. 152 // BookmarkModel::GetFavicon() requests both 1x and 2x.
(...skipping 13 matching lines...) Expand all
166 // Simulate receiving a favicon from sync encoded by a different PNG encoder 166 // Simulate receiving a favicon from sync encoded by a different PNG encoder
167 // than the one native to the OS. This tests the PNG data is not decoded to 167 // than the one native to the OS. This tests the PNG data is not decoded to
168 // SkBitmap (or any other image format) then encoded back to PNG on the path 168 // SkBitmap (or any other image format) then encoded back to PNG on the path
169 // between sync and the database. 169 // between sync and the database.
170 gfx::Image original_favicon = Create1xFaviconFromPNGFile( 170 gfx::Image original_favicon = Create1xFaviconFromPNGFile(
171 "favicon_cocoa_png_codec.png"); 171 "favicon_cocoa_png_codec.png");
172 ASSERT_FALSE(original_favicon.IsEmpty()); 172 ASSERT_FALSE(original_favicon.IsEmpty());
173 SetFavicon(0, bookmark, icon_url, original_favicon, 173 SetFavicon(0, bookmark, icon_url, original_favicon,
174 bookmarks_helper::FROM_SYNC); 174 bookmarks_helper::FROM_SYNC);
175 175
176 ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion()); 176 ASSERT_TRUE(GetClient(0)->AwaitCommitActivityCompletion());
177 ASSERT_TRUE(ModelMatchesVerifier(0)); 177 ASSERT_TRUE(ModelMatchesVerifier(0));
178 178
179 scoped_refptr<base::RefCountedMemory> original_favicon_bytes = 179 scoped_refptr<base::RefCountedMemory> original_favicon_bytes =
180 original_favicon.As1xPNGBytes(); 180 original_favicon.As1xPNGBytes();
181 gfx::Image final_favicon = GetBookmarkModel(0)->GetFavicon(bookmark); 181 gfx::Image final_favicon = GetBookmarkModel(0)->GetFavicon(bookmark);
182 scoped_refptr<base::RefCountedMemory> final_favicon_bytes = 182 scoped_refptr<base::RefCountedMemory> final_favicon_bytes =
183 final_favicon.As1xPNGBytes(); 183 final_favicon.As1xPNGBytes();
184 184
185 // Check that the data was not mutated from the original. 185 // Check that the data was not mutated from the original.
186 EXPECT_TRUE(original_favicon_bytes.get()); 186 EXPECT_TRUE(original_favicon_bytes.get());
(...skipping 29 matching lines...) Expand all
216 216
217 ASSERT_TRUE(AddFolder(0, GetBookmarkBarNode(0), 0, L"empty_folder")); 217 ASSERT_TRUE(AddFolder(0, GetBookmarkBarNode(0), 0, L"empty_folder"));
218 const BookmarkNode* folder1 = 218 const BookmarkNode* folder1 =
219 AddFolder(0, GetBookmarkBarNode(0), 1, L"folder1"); 219 AddFolder(0, GetBookmarkBarNode(0), 1, L"folder1");
220 ASSERT_TRUE(AddURL(0, folder1, 0, L"Yahoo", GURL("http://www.yahoo.com"))); 220 ASSERT_TRUE(AddURL(0, folder1, 0, L"Yahoo", GURL("http://www.yahoo.com")));
221 ASSERT_TRUE( 221 ASSERT_TRUE(
222 AddURL(0, GetBookmarkBarNode(0), 2, L"Gmail", GURL("http://gmail.com"))); 222 AddURL(0, GetBookmarkBarNode(0), 2, L"Gmail", GURL("http://gmail.com")));
223 223
224 // Set up sync, wait for its completion and verify that changes propagated. 224 // Set up sync, wait for its completion and verify that changes propagated.
225 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 225 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
226 ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion()); 226 ASSERT_TRUE(GetClient(0)->AwaitCommitActivityCompletion());
227 ASSERT_TRUE(ModelMatchesVerifier(0)); 227 ASSERT_TRUE(ModelMatchesVerifier(0));
228 228
229 // Remove all bookmarks and wait for sync completion. 229 // Remove all bookmarks and wait for sync completion.
230 RemoveAll(0); 230 RemoveAll(0);
231 ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion()); 231 ASSERT_TRUE(GetClient(0)->AwaitCommitActivityCompletion());
232 // Verify other node has no children now. 232 // Verify other node has no children now.
233 EXPECT_EQ(0, GetOtherNode(0)->child_count()); 233 EXPECT_EQ(0, GetOtherNode(0)->child_count());
234 EXPECT_EQ(0, GetBookmarkBarNode(0)->child_count()); 234 EXPECT_EQ(0, GetBookmarkBarNode(0)->child_count());
235 // Verify model matches verifier. 235 // Verify model matches verifier.
236 ASSERT_TRUE(ModelMatchesVerifier(0)); 236 ASSERT_TRUE(ModelMatchesVerifier(0));
237 } 237 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698