OLD | NEW |
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 "base/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
6 #include "chrome/browser/profiles/profile.h" | 6 #include "chrome/browser/profiles/profile.h" |
7 #include "chrome/browser/sync/profile_sync_service.h" | 7 #include "chrome/browser/sync/profile_sync_service.h" |
8 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" | 8 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" |
| 9 #include "chrome/browser/sync/test/integration/single_client_status_change_check
er.h" |
9 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" | 10 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" |
10 #include "chrome/browser/sync/test/integration/sync_test.h" | 11 #include "chrome/browser/sync/test/integration/sync_test.h" |
11 #include "components/bookmarks/browser/bookmark_model.h" | 12 #include "components/bookmarks/browser/bookmark_model.h" |
12 #include "sync/test/fake_server/bookmark_entity_builder.h" | 13 #include "sync/test/fake_server/bookmark_entity_builder.h" |
13 #include "sync/test/fake_server/entity_builder_factory.h" | 14 #include "sync/test/fake_server/entity_builder_factory.h" |
14 #include "sync/test/fake_server/fake_server_verifier.h" | 15 #include "sync/test/fake_server/fake_server_verifier.h" |
| 16 #include "sync/test/fake_server/tombstone_entity.h" |
15 #include "ui/base/layout.h" | 17 #include "ui/base/layout.h" |
16 | 18 |
17 using bookmarks::BookmarkModel; | 19 using bookmarks::BookmarkModel; |
18 using bookmarks::BookmarkNode; | 20 using bookmarks::BookmarkNode; |
19 using bookmarks_helper::AddFolder; | 21 using bookmarks_helper::AddFolder; |
20 using bookmarks_helper::AddURL; | 22 using bookmarks_helper::AddURL; |
| 23 using bookmarks_helper::AwaitCountBookmarksWithTitlesMatching; |
21 using bookmarks_helper::CountBookmarksWithTitlesMatching; | 24 using bookmarks_helper::CountBookmarksWithTitlesMatching; |
22 using bookmarks_helper::Create1xFaviconFromPNGFile; | 25 using bookmarks_helper::Create1xFaviconFromPNGFile; |
23 using bookmarks_helper::GetBookmarkBarNode; | 26 using bookmarks_helper::GetBookmarkBarNode; |
24 using bookmarks_helper::GetBookmarkModel; | 27 using bookmarks_helper::GetBookmarkModel; |
25 using bookmarks_helper::GetOtherNode; | 28 using bookmarks_helper::GetOtherNode; |
26 using bookmarks_helper::ModelMatchesVerifier; | 29 using bookmarks_helper::ModelMatchesVerifier; |
27 using bookmarks_helper::Move; | 30 using bookmarks_helper::Move; |
28 using bookmarks_helper::Remove; | 31 using bookmarks_helper::Remove; |
29 using bookmarks_helper::RemoveAll; | 32 using bookmarks_helper::RemoveAll; |
30 using bookmarks_helper::SetFavicon; | 33 using bookmarks_helper::SetFavicon; |
31 using bookmarks_helper::SetTitle; | 34 using bookmarks_helper::SetTitle; |
32 using sync_integration_test_util::AwaitCommitActivityCompletion; | 35 using sync_integration_test_util::AwaitCommitActivityCompletion; |
33 | 36 |
| 37 // All tests in this file utilize a single profile. |
| 38 // TODO(pvalenzuela): Standardize this pattern by moving this constant to |
| 39 // SyncTest and using it in all single client tests. |
| 40 const int kSingleProfileIndex = 0; |
| 41 |
34 class SingleClientBookmarksSyncTest : public SyncTest { | 42 class SingleClientBookmarksSyncTest : public SyncTest { |
35 public: | 43 public: |
36 SingleClientBookmarksSyncTest() : SyncTest(SINGLE_CLIENT) {} | 44 SingleClientBookmarksSyncTest() : SyncTest(SINGLE_CLIENT) {} |
37 ~SingleClientBookmarksSyncTest() override {} | 45 ~SingleClientBookmarksSyncTest() override {} |
38 | 46 |
39 // Verify that the local bookmark model (for the Profile corresponding to | 47 // Verify that the local bookmark model (for the Profile corresponding to |
40 // |index|) matches the data on the FakeServer. It is assumed that FakeServer | 48 // |index|) matches the data on the FakeServer. It is assumed that FakeServer |
41 // is being used and each bookmark has a unique title. Folders are not | 49 // is being used and each bookmark has a unique title. Folders are not |
42 // verified. | 50 // verified. |
43 void VerifyBookmarkModelMatchesFakeServer(int index); | 51 void VerifyBookmarkModelMatchesFakeServer(int index); |
(...skipping 29 matching lines...) Expand all Loading... |
73 | 81 |
74 // Starting state: | 82 // Starting state: |
75 // other_node | 83 // other_node |
76 // -> top | 84 // -> top |
77 // -> tier1_a | 85 // -> tier1_a |
78 // -> http://mail.google.com "tier1_a_url0" | 86 // -> http://mail.google.com "tier1_a_url0" |
79 // -> http://www.pandora.com "tier1_a_url1" | 87 // -> http://www.pandora.com "tier1_a_url1" |
80 // -> http://www.facebook.com "tier1_a_url2" | 88 // -> http://www.facebook.com "tier1_a_url2" |
81 // -> tier1_b | 89 // -> tier1_b |
82 // -> http://www.nhl.com "tier1_b_url0" | 90 // -> http://www.nhl.com "tier1_b_url0" |
83 const BookmarkNode* top = AddFolder(0, GetOtherNode(0), 0, "top"); | 91 const BookmarkNode* top = AddFolder( |
84 const BookmarkNode* tier1_a = AddFolder(0, top, 0, "tier1_a"); | 92 kSingleProfileIndex, GetOtherNode(kSingleProfileIndex), 0, "top"); |
85 const BookmarkNode* tier1_b = AddFolder(0, top, 1, "tier1_b"); | 93 const BookmarkNode* tier1_a = AddFolder( |
| 94 kSingleProfileIndex, top, 0, "tier1_a"); |
| 95 const BookmarkNode* tier1_b = AddFolder( |
| 96 kSingleProfileIndex, top, 1, "tier1_b"); |
86 const BookmarkNode* tier1_a_url0 = AddURL( | 97 const BookmarkNode* tier1_a_url0 = AddURL( |
87 0, tier1_a, 0, "tier1_a_url0", GURL("http://mail.google.com")); | 98 kSingleProfileIndex, tier1_a, 0, "tier1_a_url0", |
| 99 GURL("http://mail.google.com")); |
88 const BookmarkNode* tier1_a_url1 = AddURL( | 100 const BookmarkNode* tier1_a_url1 = AddURL( |
89 0, tier1_a, 1, "tier1_a_url1", GURL("http://www.pandora.com")); | 101 kSingleProfileIndex, tier1_a, 1, "tier1_a_url1", |
| 102 GURL("http://www.pandora.com")); |
90 const BookmarkNode* tier1_a_url2 = AddURL( | 103 const BookmarkNode* tier1_a_url2 = AddURL( |
91 0, tier1_a, 2, "tier1_a_url2", GURL("http://www.facebook.com")); | 104 kSingleProfileIndex, tier1_a, 2, "tier1_a_url2", |
| 105 GURL("http://www.facebook.com")); |
92 const BookmarkNode* tier1_b_url0 = AddURL( | 106 const BookmarkNode* tier1_b_url0 = AddURL( |
93 0, tier1_b, 0, "tier1_b_url0", GURL("http://www.nhl.com")); | 107 kSingleProfileIndex, tier1_b, 0, "tier1_b_url0", |
| 108 GURL("http://www.nhl.com")); |
94 | 109 |
95 // 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. |
96 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 111 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
97 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 112 ASSERT_TRUE(AwaitCommitActivityCompletion( |
98 ASSERT_TRUE(ModelMatchesVerifier(0)); | 113 GetSyncService((kSingleProfileIndex)))); |
| 114 ASSERT_TRUE(ModelMatchesVerifier(kSingleProfileIndex)); |
99 | 115 |
100 // 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 |
101 // more about the journey than the destination. | 117 // more about the journey than the destination. |
102 // | 118 // |
103 // bookmark_bar | 119 // bookmark_bar |
104 // -> CNN (www.cnn.com) | 120 // -> CNN (www.cnn.com) |
105 // -> tier1_a | 121 // -> tier1_a |
106 // -> tier1_a_url2 (www.facebook.com) | 122 // -> tier1_a_url2 (www.facebook.com) |
107 // -> tier1_a_url1 (www.pandora.com) | 123 // -> tier1_a_url1 (www.pandora.com) |
108 // -> Porsche (www.porsche.com) | 124 // -> Porsche (www.porsche.com) |
109 // -> Bank of America (www.bankofamerica.com) | 125 // -> Bank of America (www.bankofamerica.com) |
110 // -> Seattle Bubble | 126 // -> Seattle Bubble |
111 // other_node | 127 // other_node |
112 // -> top | 128 // -> top |
113 // -> tier1_b | 129 // -> tier1_b |
114 // -> Wired News (www.wired.com) | 130 // -> Wired News (www.wired.com) |
115 // -> tier2_b | 131 // -> tier2_b |
116 // -> tier1_b_url0 | 132 // -> tier1_b_url0 |
117 // -> tier3_b | 133 // -> tier3_b |
118 // -> Toronto Maple Leafs (mapleleafs.nhl.com) | 134 // -> Toronto Maple Leafs (mapleleafs.nhl.com) |
119 // -> Wynn (www.wynnlasvegas.com) | 135 // -> Wynn (www.wynnlasvegas.com) |
120 // -> tier1_a_url0 | 136 // -> tier1_a_url0 |
121 const BookmarkNode* bar = GetBookmarkBarNode(0); | 137 const BookmarkNode* bar = GetBookmarkBarNode(kSingleProfileIndex); |
122 const BookmarkNode* cnn = AddURL(0, bar, 0, "CNN", | 138 const BookmarkNode* cnn = AddURL( |
123 GURL("http://www.cnn.com")); | 139 kSingleProfileIndex, bar, 0, "CNN", GURL("http://www.cnn.com")); |
124 ASSERT_TRUE(cnn != NULL); | 140 ASSERT_TRUE(cnn != NULL); |
125 Move(0, tier1_a, bar, 1); | 141 Move(kSingleProfileIndex, tier1_a, bar, 1); |
126 | 142 |
127 // Wait for the bookmark position change to sync. | 143 // Wait for the bookmark position change to sync. |
128 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 144 ASSERT_TRUE(AwaitCommitActivityCompletion( |
129 ASSERT_TRUE(ModelMatchesVerifier(0)); | 145 GetSyncService((kSingleProfileIndex)))); |
| 146 ASSERT_TRUE(ModelMatchesVerifier(kSingleProfileIndex)); |
130 | 147 |
131 const BookmarkNode* porsche = AddURL(0, bar, 2, "Porsche", | 148 const BookmarkNode* porsche = AddURL( |
132 GURL("http://www.porsche.com")); | 149 kSingleProfileIndex, bar, 2, "Porsche", GURL("http://www.porsche.com")); |
133 // Rearrange stuff in tier1_a. | 150 // Rearrange stuff in tier1_a. |
134 ASSERT_EQ(tier1_a, tier1_a_url2->parent()); | 151 ASSERT_EQ(tier1_a, tier1_a_url2->parent()); |
135 ASSERT_EQ(tier1_a, tier1_a_url1->parent()); | 152 ASSERT_EQ(tier1_a, tier1_a_url1->parent()); |
136 Move(0, tier1_a_url2, tier1_a, 0); | 153 Move(kSingleProfileIndex, tier1_a_url2, tier1_a, 0); |
137 Move(0, tier1_a_url1, tier1_a, 2); | 154 Move(kSingleProfileIndex, tier1_a_url1, tier1_a, 2); |
138 | 155 |
139 // Wait for the rearranged hierarchy to sync. | 156 // Wait for the rearranged hierarchy to sync. |
140 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 157 ASSERT_TRUE(AwaitCommitActivityCompletion( |
141 ASSERT_TRUE(ModelMatchesVerifier(0)); | 158 GetSyncService((kSingleProfileIndex)))); |
| 159 ASSERT_TRUE(ModelMatchesVerifier(kSingleProfileIndex)); |
142 | 160 |
143 ASSERT_EQ(1, tier1_a_url0->parent()->GetIndexOf(tier1_a_url0)); | 161 ASSERT_EQ(1, tier1_a_url0->parent()->GetIndexOf(tier1_a_url0)); |
144 Move(0, tier1_a_url0, bar, bar->child_count()); | 162 Move(kSingleProfileIndex, tier1_a_url0, bar, bar->child_count()); |
145 const BookmarkNode* boa = AddURL(0, bar, bar->child_count(), | 163 const BookmarkNode* boa = AddURL( |
| 164 kSingleProfileIndex, bar, bar->child_count(), |
146 "Bank of America", GURL("https://www.bankofamerica.com")); | 165 "Bank of America", GURL("https://www.bankofamerica.com")); |
147 ASSERT_TRUE(boa != NULL); | 166 ASSERT_TRUE(boa != NULL); |
148 Move(0, tier1_a_url0, top, top->child_count()); | 167 Move(kSingleProfileIndex, tier1_a_url0, top, top->child_count()); |
149 const BookmarkNode* bubble = AddURL( | 168 const BookmarkNode* bubble = AddURL( |
150 0, bar, bar->child_count(), "Seattle Bubble", | 169 kSingleProfileIndex, bar, bar->child_count(), "Seattle Bubble", |
151 GURL("http://seattlebubble.com")); | 170 GURL("http://seattlebubble.com")); |
152 ASSERT_TRUE(bubble != NULL); | 171 ASSERT_TRUE(bubble != NULL); |
153 const BookmarkNode* wired = AddURL(0, bar, 2, "Wired News", | 172 const BookmarkNode* wired = AddURL( |
154 GURL("http://www.wired.com")); | 173 kSingleProfileIndex, bar, 2, "Wired News", GURL("http://www.wired.com")); |
155 const BookmarkNode* tier2_b = AddFolder( | 174 const BookmarkNode* tier2_b = AddFolder( |
156 0, tier1_b, 0, "tier2_b"); | 175 kSingleProfileIndex, tier1_b, 0, "tier2_b"); |
157 Move(0, tier1_b_url0, tier2_b, 0); | 176 Move(kSingleProfileIndex, tier1_b_url0, tier2_b, 0); |
158 Move(0, porsche, bar, 0); | 177 Move(kSingleProfileIndex, porsche, bar, 0); |
159 SetTitle(0, wired, "News Wired"); | 178 SetTitle(kSingleProfileIndex, wired, "News Wired"); |
160 SetTitle(0, porsche, "ICanHazPorsche?"); | 179 SetTitle(kSingleProfileIndex, porsche, "ICanHazPorsche?"); |
161 | 180 |
162 // Wait for the title change to sync. | 181 // Wait for the title change to sync. |
163 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 182 ASSERT_TRUE(AwaitCommitActivityCompletion( |
164 ASSERT_TRUE(ModelMatchesVerifier(0)); | 183 GetSyncService((kSingleProfileIndex)))); |
| 184 ASSERT_TRUE(ModelMatchesVerifier(kSingleProfileIndex)); |
165 | 185 |
166 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()); |
167 Remove(0, top, top->child_count() - 1); | 187 Remove(kSingleProfileIndex, top, top->child_count() - 1); |
168 Move(0, wired, tier1_b, 0); | 188 Move(kSingleProfileIndex, wired, tier1_b, 0); |
169 Move(0, porsche, bar, 3); | 189 Move(kSingleProfileIndex, porsche, bar, 3); |
170 const BookmarkNode* tier3_b = AddFolder(0, tier2_b, 1, "tier3_b"); | 190 const BookmarkNode* tier3_b = AddFolder( |
| 191 kSingleProfileIndex, tier2_b, 1, "tier3_b"); |
171 const BookmarkNode* leafs = AddURL( | 192 const BookmarkNode* leafs = AddURL( |
172 0, tier1_a, 0, "Toronto Maple Leafs", GURL("http://mapleleafs.nhl.com")); | 193 kSingleProfileIndex, tier1_a, 0, "Toronto Maple Leafs", |
173 const BookmarkNode* wynn = AddURL(0, bar, 1, "Wynn", | 194 GURL("http://mapleleafs.nhl.com")); |
174 GURL("http://www.wynnlasvegas.com")); | 195 const BookmarkNode* wynn = AddURL( |
| 196 kSingleProfileIndex, bar, 1, "Wynn", GURL("http://www.wynnlasvegas.com")); |
175 | 197 |
176 Move(0, wynn, tier3_b, 0); | 198 Move(kSingleProfileIndex, wynn, tier3_b, 0); |
177 Move(0, leafs, tier3_b, 0); | 199 Move(kSingleProfileIndex, leafs, tier3_b, 0); |
178 | 200 |
179 // Wait for newly added bookmarks to sync. | 201 // Wait for newly added bookmarks to sync. |
180 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 202 ASSERT_TRUE(AwaitCommitActivityCompletion( |
181 ASSERT_TRUE(ModelMatchesVerifier(0)); | 203 GetSyncService((kSingleProfileIndex)))); |
| 204 ASSERT_TRUE(ModelMatchesVerifier(kSingleProfileIndex)); |
182 | 205 |
183 // Only verify FakeServer data if FakeServer is being used. | 206 // Only verify FakeServer data if FakeServer is being used. |
184 // 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 |
185 // proven stable. | 208 // proven stable. |
186 if (GetFakeServer()) | 209 if (GetFakeServer()) |
187 VerifyBookmarkModelMatchesFakeServer(0); | 210 VerifyBookmarkModelMatchesFakeServer(kSingleProfileIndex); |
188 } | 211 } |
189 | 212 |
190 IN_PROC_BROWSER_TEST_F(SingleClientBookmarksSyncTest, InjectedBookmark) { | 213 IN_PROC_BROWSER_TEST_F(SingleClientBookmarksSyncTest, InjectedBookmark) { |
191 std::string title = "Montreal Canadiens"; | 214 std::string title = "Montreal Canadiens"; |
192 fake_server::EntityBuilderFactory entity_builder_factory; | 215 fake_server::EntityBuilderFactory entity_builder_factory; |
193 scoped_ptr<fake_server::FakeServerEntity> entity = | 216 scoped_ptr<fake_server::FakeServerEntity> entity = |
194 entity_builder_factory.NewBookmarkEntityBuilder( | 217 entity_builder_factory.NewBookmarkEntityBuilder( |
195 title, GURL("http://canadiens.nhl.com")).Build(); | 218 title, GURL("http://canadiens.nhl.com")).Build(); |
196 fake_server_->InjectEntity(entity.Pass()); | 219 fake_server_->InjectEntity(entity.Pass()); |
197 | 220 |
198 DisableVerifier(); | 221 DisableVerifier(); |
199 ASSERT_TRUE(SetupClients()); | 222 ASSERT_TRUE(SetupClients()); |
200 ASSERT_TRUE(SetupSync()); | 223 ASSERT_TRUE(SetupSync()); |
201 | 224 |
202 ASSERT_EQ(1, CountBookmarksWithTitlesMatching(0, title)); | 225 ASSERT_EQ(1, CountBookmarksWithTitlesMatching(kSingleProfileIndex, title)); |
203 } | 226 } |
204 | 227 |
205 // Test that a client doesn't mutate the favicon data in the process | 228 // Test that a client doesn't mutate the favicon data in the process |
206 // of storing the favicon data from sync to the database or in the process | 229 // of storing the favicon data from sync to the database or in the process |
207 // of requesting data from the database for sync. | 230 // of requesting data from the database for sync. |
208 IN_PROC_BROWSER_TEST_F(SingleClientBookmarksSyncTest, | 231 IN_PROC_BROWSER_TEST_F(SingleClientBookmarksSyncTest, |
209 SetFaviconHiDPIDifferentCodec) { | 232 SetFaviconHiDPIDifferentCodec) { |
210 // Set the supported scale factors to 1x and 2x such that | 233 // Set the supported scale factors to 1x and 2x such that |
211 // BookmarkModel::GetFavicon() requests both 1x and 2x. | 234 // BookmarkModel::GetFavicon() requests both 1x and 2x. |
212 // 1x -> for sync, 2x -> for the UI. | 235 // 1x -> for sync, 2x -> for the UI. |
213 std::vector<ui::ScaleFactor> supported_scale_factors; | 236 std::vector<ui::ScaleFactor> supported_scale_factors; |
214 supported_scale_factors.push_back(ui::SCALE_FACTOR_100P); | 237 supported_scale_factors.push_back(ui::SCALE_FACTOR_100P); |
215 supported_scale_factors.push_back(ui::SCALE_FACTOR_200P); | 238 supported_scale_factors.push_back(ui::SCALE_FACTOR_200P); |
216 ui::SetSupportedScaleFactors(supported_scale_factors); | 239 ui::SetSupportedScaleFactors(supported_scale_factors); |
217 | 240 |
218 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 241 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
219 ASSERT_TRUE(ModelMatchesVerifier(0)); | 242 ASSERT_TRUE(ModelMatchesVerifier(kSingleProfileIndex)); |
220 | 243 |
221 const GURL page_url("http://www.google.com"); | 244 const GURL page_url("http://www.google.com"); |
222 const GURL icon_url("http://www.google.com/favicon.ico"); | 245 const GURL icon_url("http://www.google.com/favicon.ico"); |
223 const BookmarkNode* bookmark = AddURL(0, "title", page_url); | 246 const BookmarkNode* bookmark = AddURL(kSingleProfileIndex, "title", page_url); |
224 | 247 |
225 // 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 |
226 // 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 |
227 // 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 |
228 // between sync and the database. | 251 // between sync and the database. |
229 gfx::Image original_favicon = Create1xFaviconFromPNGFile( | 252 gfx::Image original_favicon = Create1xFaviconFromPNGFile( |
230 "favicon_cocoa_png_codec.png"); | 253 "favicon_cocoa_png_codec.png"); |
231 ASSERT_FALSE(original_favicon.IsEmpty()); | 254 ASSERT_FALSE(original_favicon.IsEmpty()); |
232 SetFavicon(0, bookmark, icon_url, original_favicon, | 255 SetFavicon(kSingleProfileIndex, bookmark, icon_url, original_favicon, |
233 bookmarks_helper::FROM_SYNC); | 256 bookmarks_helper::FROM_SYNC); |
234 | 257 |
235 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 258 ASSERT_TRUE(AwaitCommitActivityCompletion( |
236 ASSERT_TRUE(ModelMatchesVerifier(0)); | 259 GetSyncService((kSingleProfileIndex)))); |
| 260 ASSERT_TRUE(ModelMatchesVerifier(kSingleProfileIndex)); |
237 | 261 |
238 scoped_refptr<base::RefCountedMemory> original_favicon_bytes = | 262 scoped_refptr<base::RefCountedMemory> original_favicon_bytes = |
239 original_favicon.As1xPNGBytes(); | 263 original_favicon.As1xPNGBytes(); |
240 gfx::Image final_favicon = GetBookmarkModel(0)->GetFavicon(bookmark); | 264 gfx::Image final_favicon = |
| 265 GetBookmarkModel(kSingleProfileIndex)->GetFavicon(bookmark); |
241 scoped_refptr<base::RefCountedMemory> final_favicon_bytes = | 266 scoped_refptr<base::RefCountedMemory> final_favicon_bytes = |
242 final_favicon.As1xPNGBytes(); | 267 final_favicon.As1xPNGBytes(); |
243 | 268 |
244 // Check that the data was not mutated from the original. | 269 // Check that the data was not mutated from the original. |
245 EXPECT_TRUE(original_favicon_bytes.get()); | 270 EXPECT_TRUE(original_favicon_bytes.get()); |
246 EXPECT_TRUE(original_favicon_bytes->Equals(final_favicon_bytes)); | 271 EXPECT_TRUE(original_favicon_bytes->Equals(final_favicon_bytes)); |
247 } | 272 } |
248 | 273 |
249 IN_PROC_BROWSER_TEST_F(SingleClientBookmarksSyncTest, | 274 IN_PROC_BROWSER_TEST_F(SingleClientBookmarksSyncTest, |
250 BookmarkAllNodesRemovedEvent) { | 275 BookmarkAllNodesRemovedEvent) { |
251 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; | 276 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; |
252 // Starting state: | 277 // Starting state: |
253 // other_node | 278 // other_node |
254 // -> folder0 | 279 // -> folder0 |
255 // -> tier1_a | 280 // -> tier1_a |
256 // -> http://mail.google.com | 281 // -> http://mail.google.com |
257 // -> http://www.google.com | 282 // -> http://www.google.com |
258 // -> http://news.google.com | 283 // -> http://news.google.com |
259 // -> http://yahoo.com | 284 // -> http://yahoo.com |
260 // -> http://www.cnn.com | 285 // -> http://www.cnn.com |
261 // bookmark_bar | 286 // bookmark_bar |
262 // -> empty_folder | 287 // -> empty_folder |
263 // -> folder1 | 288 // -> folder1 |
264 // -> http://yahoo.com | 289 // -> http://yahoo.com |
265 // -> http://gmail.com | 290 // -> http://gmail.com |
266 | 291 |
267 const BookmarkNode* folder0 = AddFolder(0, GetOtherNode(0), 0, "folder0"); | 292 const BookmarkNode* folder0 = AddFolder( |
268 const BookmarkNode* tier1_a = AddFolder(0, folder0, 0, "tier1_a"); | 293 kSingleProfileIndex, GetOtherNode(kSingleProfileIndex), 0, "folder0"); |
269 ASSERT_TRUE(AddURL(0, folder0, 1, "News", GURL("http://news.google.com"))); | 294 const BookmarkNode* tier1_a = AddFolder( |
270 ASSERT_TRUE(AddURL(0, folder0, 2, "Yahoo", GURL("http://www.yahoo.com"))); | 295 kSingleProfileIndex, folder0, 0, "tier1_a"); |
271 ASSERT_TRUE(AddURL(0, tier1_a, 0, "Gmai", GURL("http://mail.google.com"))); | 296 ASSERT_TRUE(AddURL( |
272 ASSERT_TRUE(AddURL(0, tier1_a, 1, "Google", GURL("http://www.google.com"))); | 297 kSingleProfileIndex, folder0, 1, "News", GURL("http://news.google.com"))); |
273 ASSERT_TRUE( | 298 ASSERT_TRUE(AddURL( |
274 AddURL(0, GetOtherNode(0), 1, "CNN", GURL("http://www.cnn.com"))); | 299 kSingleProfileIndex, folder0, 2, "Yahoo", GURL("http://www.yahoo.com"))); |
| 300 ASSERT_TRUE(AddURL( |
| 301 kSingleProfileIndex, tier1_a, 0, "Gmai", GURL("http://mail.google.com"))); |
| 302 ASSERT_TRUE(AddURL( |
| 303 kSingleProfileIndex, tier1_a, 1, "Google", GURL("http://www.google.com")))
; |
| 304 ASSERT_TRUE(AddURL( |
| 305 kSingleProfileIndex, GetOtherNode(kSingleProfileIndex), 1, "CNN", |
| 306 GURL("http://www.cnn.com"))); |
275 | 307 |
276 ASSERT_TRUE(AddFolder(0, GetBookmarkBarNode(0), 0, "empty_folder")); | 308 ASSERT_TRUE(AddFolder( |
277 const BookmarkNode* folder1 = | 309 kSingleProfileIndex, GetBookmarkBarNode(kSingleProfileIndex), 0, |
278 AddFolder(0, GetBookmarkBarNode(0), 1, "folder1"); | 310 "empty_folder")); |
279 ASSERT_TRUE(AddURL(0, folder1, 0, "Yahoo", GURL("http://www.yahoo.com"))); | 311 const BookmarkNode* folder1 = AddFolder( |
280 ASSERT_TRUE( | 312 kSingleProfileIndex, GetBookmarkBarNode(kSingleProfileIndex), 1, |
281 AddURL(0, GetBookmarkBarNode(0), 2, "Gmai", GURL("http://gmail.com"))); | 313 "folder1"); |
| 314 ASSERT_TRUE(AddURL( |
| 315 kSingleProfileIndex, folder1, 0, "Yahoo", GURL("http://www.yahoo.com"))); |
| 316 ASSERT_TRUE(AddURL( |
| 317 kSingleProfileIndex, GetBookmarkBarNode(0), 2, "Gmai", |
| 318 GURL("http://gmail.com"))); |
282 | 319 |
283 // Set up sync, wait for its completion and verify that changes propagated. | 320 // Set up sync, wait for its completion and verify that changes propagated. |
284 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 321 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
285 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 322 ASSERT_TRUE(AwaitCommitActivityCompletion( |
286 ASSERT_TRUE(ModelMatchesVerifier(0)); | 323 GetSyncService((kSingleProfileIndex)))); |
| 324 ASSERT_TRUE(ModelMatchesVerifier(kSingleProfileIndex)); |
287 | 325 |
288 // Remove all bookmarks and wait for sync completion. | 326 // Remove all bookmarks and wait for sync completion. |
289 RemoveAll(0); | 327 RemoveAll(kSingleProfileIndex); |
290 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 328 ASSERT_TRUE(AwaitCommitActivityCompletion( |
| 329 GetSyncService((kSingleProfileIndex)))); |
291 // Verify other node has no children now. | 330 // Verify other node has no children now. |
292 EXPECT_EQ(0, GetOtherNode(0)->child_count()); | 331 EXPECT_EQ(0, GetOtherNode(kSingleProfileIndex)->child_count()); |
293 EXPECT_EQ(0, GetBookmarkBarNode(0)->child_count()); | 332 EXPECT_EQ(0, GetBookmarkBarNode(kSingleProfileIndex)->child_count()); |
294 // Verify model matches verifier. | 333 // Verify model matches verifier. |
295 ASSERT_TRUE(ModelMatchesVerifier(0)); | 334 ASSERT_TRUE(ModelMatchesVerifier(kSingleProfileIndex)); |
296 } | 335 } |
| 336 |
| 337 IN_PROC_BROWSER_TEST_F(SingleClientBookmarksSyncTest, |
| 338 DownloadDeletedBookmark) { |
| 339 std::string title = "Patrick Star"; |
| 340 fake_server::EntityBuilderFactory entity_builder_factory; |
| 341 scoped_ptr<fake_server::FakeServerEntity> entity = |
| 342 entity_builder_factory.NewBookmarkEntityBuilder( |
| 343 title, GURL("http://en.wikipedia.org/wiki/Patrick_Star")).Build(); |
| 344 fake_server_->InjectEntity(entity.Pass()); |
| 345 |
| 346 DisableVerifier(); |
| 347 ASSERT_TRUE(SetupSync()); |
| 348 |
| 349 ASSERT_EQ(1, CountBookmarksWithTitlesMatching(kSingleProfileIndex, title)); |
| 350 |
| 351 std::vector<sync_pb::SyncEntity> server_bookmarks = |
| 352 GetFakeServer()->GetSyncEntitiesByModelType(syncer::BOOKMARKS); |
| 353 ASSERT_EQ(1ul, server_bookmarks.size()); |
| 354 std::string entity_id = server_bookmarks[0].id_string(); |
| 355 scoped_ptr<fake_server::FakeServerEntity> tombstone( |
| 356 fake_server::TombstoneEntity::Create(entity_id)); |
| 357 GetFakeServer()->InjectEntity(tombstone.Pass()); |
| 358 |
| 359 const syncer::ModelTypeSet kBookmarksType(syncer::BOOKMARKS); |
| 360 TriggerSyncForModelTypes(kSingleProfileIndex, kBookmarksType); |
| 361 |
| 362 const int kExpectedCountAfterDeletion = 0; |
| 363 ASSERT_TRUE(AwaitCountBookmarksWithTitlesMatching( |
| 364 kSingleProfileIndex, title, kExpectedCountAfterDeletion)); |
| 365 } |
OLD | NEW |