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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "base/guid.h" | 7 #include "base/guid.h" |
8 #include "base/i18n/number_formatting.h" | 8 #include "base/i18n/number_formatting.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "chrome/browser/sessions/session_service.h" | 13 #include "chrome/browser/sessions/session_service.h" |
14 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" | 14 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" |
15 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" | 15 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
16 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" | |
17 #include "chrome/browser/sync/test/integration/sync_test.h" | 16 #include "chrome/browser/sync/test/integration/sync_test.h" |
18 #include "chrome/browser/sync/test/integration/typed_urls_helper.h" | 17 #include "chrome/browser/sync/test/integration/typed_urls_helper.h" |
| 18 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h
" |
19 #include "components/history/core/browser/history_types.h" | 19 #include "components/history/core/browser/history_types.h" |
20 | 20 |
21 using base::ASCIIToUTF16; | 21 using base::ASCIIToUTF16; |
22 using bookmarks::BookmarkNode; | 22 using bookmarks::BookmarkNode; |
23 using sync_integration_test_util::AwaitCommitActivityCompletion; | |
24 using typed_urls_helper::AddUrlToHistory; | 23 using typed_urls_helper::AddUrlToHistory; |
25 using typed_urls_helper::AddUrlToHistoryWithTimestamp; | 24 using typed_urls_helper::AddUrlToHistoryWithTimestamp; |
26 using typed_urls_helper::AddUrlToHistoryWithTransition; | 25 using typed_urls_helper::AddUrlToHistoryWithTransition; |
27 using typed_urls_helper::AreVisitsEqual; | 26 using typed_urls_helper::AreVisitsEqual; |
28 using typed_urls_helper::AreVisitsUnique; | 27 using typed_urls_helper::AreVisitsUnique; |
29 using typed_urls_helper::AwaitCheckAllProfilesHaveSameURLs; | |
30 using typed_urls_helper::CheckURLRowVectorsAreEqual; | 28 using typed_urls_helper::CheckURLRowVectorsAreEqual; |
31 using typed_urls_helper::DeleteUrlFromHistory; | 29 using typed_urls_helper::DeleteUrlFromHistory; |
32 using typed_urls_helper::GetTypedUrlsFromClient; | 30 using typed_urls_helper::GetTypedUrlsFromClient; |
33 using typed_urls_helper::GetUrlFromClient; | 31 using typed_urls_helper::GetUrlFromClient; |
34 using typed_urls_helper::GetVisitsFromClient; | 32 using typed_urls_helper::GetVisitsFromClient; |
35 using typed_urls_helper::RemoveVisitsFromClient; | 33 using typed_urls_helper::RemoveVisitsFromClient; |
36 | 34 |
37 class TwoClientTypedUrlsSyncTest : public SyncTest { | 35 class TwoClientTypedUrlsSyncTest : public SyncTest { |
38 public: | 36 public: |
39 TwoClientTypedUrlsSyncTest() : SyncTest(TWO_CLIENT) {} | 37 TwoClientTypedUrlsSyncTest() : SyncTest(TWO_CLIENT) {} |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // Use a randomized URL to prevent test collisions. | 81 // Use a randomized URL to prevent test collisions. |
84 const base::string16 kHistoryUrl = ASCIIToUTF16(base::StringPrintf( | 82 const base::string16 kHistoryUrl = ASCIIToUTF16(base::StringPrintf( |
85 "http://www.add-history.google.com/%s", base::GenerateGUID().c_str())); | 83 "http://www.add-history.google.com/%s", base::GenerateGUID().c_str())); |
86 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 84 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
87 | 85 |
88 size_t initial_count = GetTypedUrlsFromClient(0).size(); | 86 size_t initial_count = GetTypedUrlsFromClient(0).size(); |
89 | 87 |
90 // Populate one client with a URL, wait for it to sync to the other. | 88 // Populate one client with a URL, wait for it to sync to the other. |
91 GURL new_url(kHistoryUrl); | 89 GURL new_url(kHistoryUrl); |
92 AddUrlToHistory(0, new_url); | 90 AddUrlToHistory(0, new_url); |
93 ASSERT_TRUE(AwaitCheckAllProfilesHaveSameURLs()); | 91 ASSERT_TRUE(ProfilesHaveSameURLsChecker().Wait()); |
94 | 92 |
95 // Assert that the second client has the correct new URL. | 93 // Assert that the second client has the correct new URL. |
96 history::URLRows urls = GetTypedUrlsFromClient(1); | 94 history::URLRows urls = GetTypedUrlsFromClient(1); |
97 ASSERT_EQ(initial_count + 1, urls.size()); | 95 ASSERT_EQ(initial_count + 1, urls.size()); |
98 ASSERT_EQ(new_url, urls.back().url()); | 96 ASSERT_EQ(new_url, urls.back().url()); |
99 } | 97 } |
100 | 98 |
101 IN_PROC_BROWSER_TEST_F(TwoClientTypedUrlsSyncTest, AddExpired) { | 99 IN_PROC_BROWSER_TEST_F(TwoClientTypedUrlsSyncTest, AddExpired) { |
102 const base::string16 kHistoryUrl( | 100 const base::string16 kHistoryUrl( |
103 ASCIIToUTF16("http://www.add-one-history.google.com/")); | 101 ASCIIToUTF16("http://www.add-one-history.google.com/")); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 // Use a randomized URL to prevent test collisions. | 169 // Use a randomized URL to prevent test collisions. |
172 const base::string16 kHistoryUrl = ASCIIToUTF16(base::StringPrintf( | 170 const base::string16 kHistoryUrl = ASCIIToUTF16(base::StringPrintf( |
173 "http://www.add-history.google.com/%s", base::GenerateGUID().c_str())); | 171 "http://www.add-history.google.com/%s", base::GenerateGUID().c_str())); |
174 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 172 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
175 | 173 |
176 size_t initial_count = GetTypedUrlsFromClient(0).size(); | 174 size_t initial_count = GetTypedUrlsFromClient(0).size(); |
177 | 175 |
178 // Populate one client with a URL, wait for it to sync to the other. | 176 // Populate one client with a URL, wait for it to sync to the other. |
179 GURL new_url(kHistoryUrl); | 177 GURL new_url(kHistoryUrl); |
180 AddUrlToHistory(0, new_url); | 178 AddUrlToHistory(0, new_url); |
181 ASSERT_TRUE(AwaitCheckAllProfilesHaveSameURLs()); | 179 ASSERT_TRUE(ProfilesHaveSameURLsChecker().Wait()); |
182 | 180 |
183 // Assert that the second client has the correct new URL. | 181 // Assert that the second client has the correct new URL. |
184 history::URLRows urls = GetTypedUrlsFromClient(1); | 182 history::URLRows urls = GetTypedUrlsFromClient(1); |
185 ASSERT_EQ(initial_count + 1, urls.size()); | 183 ASSERT_EQ(initial_count + 1, urls.size()); |
186 ASSERT_EQ(new_url, urls.back().url()); | 184 ASSERT_EQ(new_url, urls.back().url()); |
187 | 185 |
188 // Delete from first client, and wait for them to sync. | 186 // Delete from first client, and wait for them to sync. |
189 DeleteUrlFromHistory(0, new_url); | 187 DeleteUrlFromHistory(0, new_url); |
190 ASSERT_TRUE(AwaitCheckAllProfilesHaveSameURLs()); | 188 ASSERT_TRUE(ProfilesHaveSameURLsChecker().Wait()); |
191 | 189 |
192 // Assert that it's deleted from the second client. | 190 // Assert that it's deleted from the second client. |
193 ASSERT_EQ(initial_count, GetTypedUrlsFromClient(1).size()); | 191 ASSERT_EQ(initial_count, GetTypedUrlsFromClient(1).size()); |
194 } | 192 } |
195 | 193 |
196 // TCM: 3643277 | 194 // TCM: 3643277 |
197 IN_PROC_BROWSER_TEST_F(TwoClientTypedUrlsSyncTest, | 195 IN_PROC_BROWSER_TEST_F(TwoClientTypedUrlsSyncTest, |
198 E2E_ENABLED(DisableEnableSync)) { | 196 E2E_ENABLED(DisableEnableSync)) { |
199 const base::string16 kUrl1(ASCIIToUTF16("http://history1.google.com/")); | 197 const base::string16 kUrl1(ASCIIToUTF16("http://history1.google.com/")); |
200 const base::string16 kUrl2(ASCIIToUTF16("http://history2.google.com/")); | 198 const base::string16 kUrl2(ASCIIToUTF16("http://history2.google.com/")); |
201 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 199 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
202 | 200 |
203 // Disable typed url sync for one client, leave it active for the other. | 201 // Disable typed url sync for one client, leave it active for the other. |
204 GetClient(0)->DisableSyncForDatatype(syncer::TYPED_URLS); | 202 GetClient(0)->DisableSyncForDatatype(syncer::TYPED_URLS); |
205 | 203 |
206 // Add one URL to non-syncing client, add a different URL to the other, | 204 // Add one URL to non-syncing client, add a different URL to the other, |
207 // wait for sync cycle to complete. No data should be exchanged. | 205 // wait for sync cycle to complete. No data should be exchanged. |
208 GURL url1(kUrl1); | 206 GURL url1(kUrl1); |
209 GURL url2(kUrl2); | 207 GURL url2(kUrl2); |
210 AddUrlToHistory(0, url1); | 208 AddUrlToHistory(0, url1); |
211 AddUrlToHistory(1, url2); | 209 AddUrlToHistory(1, url2); |
212 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService(1))); | 210 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(1)).Wait()); |
213 | 211 |
214 // Make sure that no data was exchanged. | 212 // Make sure that no data was exchanged. |
215 history::URLRows post_sync_urls = GetTypedUrlsFromClient(0); | 213 history::URLRows post_sync_urls = GetTypedUrlsFromClient(0); |
216 ASSERT_EQ(1U, post_sync_urls.size()); | 214 ASSERT_EQ(1U, post_sync_urls.size()); |
217 ASSERT_EQ(url1, post_sync_urls[0].url()); | 215 ASSERT_EQ(url1, post_sync_urls[0].url()); |
218 post_sync_urls = GetTypedUrlsFromClient(1); | 216 post_sync_urls = GetTypedUrlsFromClient(1); |
219 ASSERT_EQ(1U, post_sync_urls.size()); | 217 ASSERT_EQ(1U, post_sync_urls.size()); |
220 ASSERT_EQ(url2, post_sync_urls[0].url()); | 218 ASSERT_EQ(url2, post_sync_urls[0].url()); |
221 | 219 |
222 // Enable typed url sync, make both URLs are synced to each client. | 220 // Enable typed url sync, make both URLs are synced to each client. |
223 GetClient(0)->EnableSyncForDatatype(syncer::TYPED_URLS); | 221 GetClient(0)->EnableSyncForDatatype(syncer::TYPED_URLS); |
224 | 222 |
225 ASSERT_TRUE(AwaitCheckAllProfilesHaveSameURLs()); | 223 ASSERT_TRUE(ProfilesHaveSameURLsChecker().Wait()); |
226 } | 224 } |
227 | 225 |
228 // flaky, see crbug.com/108511 | 226 // flaky, see crbug.com/108511 |
229 IN_PROC_BROWSER_TEST_F(TwoClientTypedUrlsSyncTest, DISABLED_AddOneDeleteOther) { | 227 IN_PROC_BROWSER_TEST_F(TwoClientTypedUrlsSyncTest, DISABLED_AddOneDeleteOther) { |
230 const base::string16 kHistoryUrl( | 228 const base::string16 kHistoryUrl( |
231 ASCIIToUTF16("http://www.add-one-delete-history.google.com/")); | 229 ASCIIToUTF16("http://www.add-one-delete-history.google.com/")); |
232 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 230 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
233 | 231 |
234 // Populate one client with a URL, should sync to the other. | 232 // Populate one client with a URL, should sync to the other. |
235 GURL new_url(kHistoryUrl); | 233 GURL new_url(kHistoryUrl); |
236 AddUrlToHistory(0, new_url); | 234 AddUrlToHistory(0, new_url); |
237 history::URLRows urls = GetTypedUrlsFromClient(0); | 235 history::URLRows urls = GetTypedUrlsFromClient(0); |
238 ASSERT_EQ(1U, urls.size()); | 236 ASSERT_EQ(1U, urls.size()); |
239 ASSERT_EQ(new_url, urls[0].url()); | 237 ASSERT_EQ(new_url, urls[0].url()); |
240 | 238 |
241 // Both clients should have this URL. | 239 // Both clients should have this URL. |
242 ASSERT_TRUE(AwaitCheckAllProfilesHaveSameURLs()); | 240 ASSERT_TRUE(ProfilesHaveSameURLsChecker().Wait()); |
243 | 241 |
244 // Now, delete the URL from the second client. | 242 // Now, delete the URL from the second client. |
245 DeleteUrlFromHistory(1, new_url); | 243 DeleteUrlFromHistory(1, new_url); |
246 urls = GetTypedUrlsFromClient(0); | 244 urls = GetTypedUrlsFromClient(0); |
247 ASSERT_EQ(1U, urls.size()); | 245 ASSERT_EQ(1U, urls.size()); |
248 | 246 |
249 // Both clients should have this URL removed. | 247 // Both clients should have this URL removed. |
250 ASSERT_TRUE(AwaitCheckAllProfilesHaveSameURLs()); | 248 ASSERT_TRUE(ProfilesHaveSameURLsChecker().Wait()); |
251 } | 249 } |
252 | 250 |
253 // flaky, see crbug.com/108511 | 251 // flaky, see crbug.com/108511 |
254 IN_PROC_BROWSER_TEST_F(TwoClientTypedUrlsSyncTest, | 252 IN_PROC_BROWSER_TEST_F(TwoClientTypedUrlsSyncTest, |
255 DISABLED_AddOneDeleteOtherAddAgain) { | 253 DISABLED_AddOneDeleteOtherAddAgain) { |
256 const base::string16 kHistoryUrl( | 254 const base::string16 kHistoryUrl( |
257 ASCIIToUTF16("http://www.add-delete-add-history.google.com/")); | 255 ASCIIToUTF16("http://www.add-delete-add-history.google.com/")); |
258 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 256 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
259 | 257 |
260 // Populate one client with a URL, should sync to the other. | 258 // Populate one client with a URL, should sync to the other. |
261 GURL new_url(kHistoryUrl); | 259 GURL new_url(kHistoryUrl); |
262 AddUrlToHistory(0, new_url); | 260 AddUrlToHistory(0, new_url); |
263 history::URLRows urls = GetTypedUrlsFromClient(0); | 261 history::URLRows urls = GetTypedUrlsFromClient(0); |
264 ASSERT_EQ(1U, urls.size()); | 262 ASSERT_EQ(1U, urls.size()); |
265 ASSERT_EQ(new_url, urls[0].url()); | 263 ASSERT_EQ(new_url, urls[0].url()); |
266 | 264 |
267 // Both clients should have this URL. | 265 // Both clients should have this URL. |
268 ASSERT_TRUE(AwaitCheckAllProfilesHaveSameURLs()); | 266 ASSERT_TRUE(ProfilesHaveSameURLsChecker().Wait()); |
269 | 267 |
270 // Now, delete the URL from the second client. | 268 // Now, delete the URL from the second client. |
271 DeleteUrlFromHistory(1, new_url); | 269 DeleteUrlFromHistory(1, new_url); |
272 urls = GetTypedUrlsFromClient(0); | 270 urls = GetTypedUrlsFromClient(0); |
273 ASSERT_EQ(1U, urls.size()); | 271 ASSERT_EQ(1U, urls.size()); |
274 | 272 |
275 // Both clients should have this URL removed. | 273 // Both clients should have this URL removed. |
276 ASSERT_TRUE(AwaitCheckAllProfilesHaveSameURLs()); | 274 ASSERT_TRUE(ProfilesHaveSameURLsChecker().Wait()); |
277 | 275 |
278 // Add it to the first client again, should succeed (tests that the deletion | 276 // Add it to the first client again, should succeed (tests that the deletion |
279 // properly disassociates that URL). | 277 // properly disassociates that URL). |
280 AddUrlToHistory(0, new_url); | 278 AddUrlToHistory(0, new_url); |
281 | 279 |
282 // Both clients should have this URL added again. | 280 // Both clients should have this URL added again. |
283 ASSERT_TRUE(AwaitCheckAllProfilesHaveSameURLs()); | 281 ASSERT_TRUE(ProfilesHaveSameURLsChecker().Wait()); |
284 } | 282 } |
285 | 283 |
286 IN_PROC_BROWSER_TEST_F(TwoClientTypedUrlsSyncTest, | 284 IN_PROC_BROWSER_TEST_F(TwoClientTypedUrlsSyncTest, |
287 MergeTypedWithNonTypedDuringAssociation) { | 285 MergeTypedWithNonTypedDuringAssociation) { |
288 ASSERT_TRUE(SetupClients()); | 286 ASSERT_TRUE(SetupClients()); |
289 GURL new_url("http://history.com"); | 287 GURL new_url("http://history.com"); |
290 base::Time timestamp = base::Time::Now(); | 288 base::Time timestamp = base::Time::Now(); |
291 // Put a non-typed URL in both clients with an identical timestamp. | 289 // Put a non-typed URL in both clients with an identical timestamp. |
292 // Then add a typed URL to the second client - this test makes sure that | 290 // Then add a typed URL to the second client - this test makes sure that |
293 // we properly merge both sets of visits together to end up with the same | 291 // we properly merge both sets of visits together to end up with the same |
294 // set of visits on both ends. | 292 // set of visits on both ends. |
295 AddUrlToHistoryWithTimestamp(0, new_url, ui::PAGE_TRANSITION_LINK, | 293 AddUrlToHistoryWithTimestamp(0, new_url, ui::PAGE_TRANSITION_LINK, |
296 history::SOURCE_BROWSED, timestamp); | 294 history::SOURCE_BROWSED, timestamp); |
297 AddUrlToHistoryWithTimestamp(1, new_url, ui::PAGE_TRANSITION_LINK, | 295 AddUrlToHistoryWithTimestamp(1, new_url, ui::PAGE_TRANSITION_LINK, |
298 history::SOURCE_BROWSED, timestamp); | 296 history::SOURCE_BROWSED, timestamp); |
299 AddUrlToHistoryWithTimestamp(1, new_url, ui::PAGE_TRANSITION_TYPED, | 297 AddUrlToHistoryWithTimestamp(1, new_url, ui::PAGE_TRANSITION_TYPED, |
300 history::SOURCE_BROWSED, | 298 history::SOURCE_BROWSED, |
301 timestamp + base::TimeDelta::FromSeconds(1)); | 299 timestamp + base::TimeDelta::FromSeconds(1)); |
302 | 300 |
303 // Now start up sync - URLs should get merged. Fully sync client 1 first, | 301 // Now start up sync - URLs should get merged. Fully sync client 1 first, |
304 // before syncing client 0, so we have both of client 1's URLs in the sync DB | 302 // before syncing client 0, so we have both of client 1's URLs in the sync DB |
305 // at the time that client 0 does model association. | 303 // at the time that client 0 does model association. |
306 ASSERT_TRUE(GetClient(1)->SetupSync()) << "SetupSync() failed"; | 304 ASSERT_TRUE(GetClient(1)->SetupSync()) << "SetupSync() failed"; |
307 AwaitCommitActivityCompletion(GetSyncService(1)); | 305 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(1)).Wait()); |
308 ASSERT_TRUE(GetClient(0)->SetupSync()) << "SetupSync() failed"; | 306 ASSERT_TRUE(GetClient(0)->SetupSync()) << "SetupSync() failed"; |
309 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 307 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
310 | 308 |
311 ASSERT_TRUE(CheckClientsEqual()); | 309 ASSERT_TRUE(CheckClientsEqual()); |
312 // At this point, we should have no duplicates (total visit count should be | 310 // At this point, we should have no duplicates (total visit count should be |
313 // 2). We only need to check client 0 since we already verified that both | 311 // 2). We only need to check client 0 since we already verified that both |
314 // clients are identical above. | 312 // clients are identical above. |
315 history::URLRows urls = GetTypedUrlsFromClient(0); | 313 history::URLRows urls = GetTypedUrlsFromClient(0); |
316 ASSERT_EQ(1U, urls.size()); | 314 ASSERT_EQ(1U, urls.size()); |
317 ASSERT_EQ(new_url, urls[0].url()); | 315 ASSERT_EQ(new_url, urls[0].url()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 362 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
365 | 363 |
366 // Populate one client with a non-typed URL, should not be synced. | 364 // Populate one client with a non-typed URL, should not be synced. |
367 GURL new_url(kHistoryUrl); | 365 GURL new_url(kHistoryUrl); |
368 AddUrlToHistoryWithTransition(0, new_url, ui::PAGE_TRANSITION_LINK, | 366 AddUrlToHistoryWithTransition(0, new_url, ui::PAGE_TRANSITION_LINK, |
369 history::SOURCE_BROWSED); | 367 history::SOURCE_BROWSED); |
370 history::URLRows urls = GetTypedUrlsFromClient(0); | 368 history::URLRows urls = GetTypedUrlsFromClient(0); |
371 ASSERT_EQ(0U, urls.size()); | 369 ASSERT_EQ(0U, urls.size()); |
372 | 370 |
373 // Both clients should have 0 typed URLs. | 371 // Both clients should have 0 typed URLs. |
374 ASSERT_TRUE(AwaitCheckAllProfilesHaveSameURLs()); | 372 ASSERT_TRUE(ProfilesHaveSameURLsChecker().Wait()); |
375 urls = GetTypedUrlsFromClient(0); | 373 urls = GetTypedUrlsFromClient(0); |
376 ASSERT_EQ(0U, urls.size()); | 374 ASSERT_EQ(0U, urls.size()); |
377 | 375 |
378 // Now, add a typed visit to this URL. | 376 // Now, add a typed visit to this URL. |
379 AddUrlToHistory(0, new_url); | 377 AddUrlToHistory(0, new_url); |
380 | 378 |
381 // Let sync finish. | 379 // Let sync finish. |
382 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 380 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
383 | 381 |
384 // Both clients should have this URL as typed and have two visits synced up. | 382 // Both clients should have this URL as typed and have two visits synced up. |
(...skipping 14 matching lines...) Expand all Loading... |
399 const GURL kNonTypedURL("http://link.google.com/"); | 397 const GURL kNonTypedURL("http://link.google.com/"); |
400 const GURL kTypedURL("http://typed.google.com/"); | 398 const GURL kTypedURL("http://typed.google.com/"); |
401 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 399 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
402 AddUrlToHistoryWithTransition(0, kNonTypedURL, ui::PAGE_TRANSITION_LINK, | 400 AddUrlToHistoryWithTransition(0, kNonTypedURL, ui::PAGE_TRANSITION_LINK, |
403 history::SOURCE_BROWSED); | 401 history::SOURCE_BROWSED); |
404 AddUrlToHistoryWithTransition(0, kTypedURL, ui::PAGE_TRANSITION_TYPED, | 402 AddUrlToHistoryWithTransition(0, kTypedURL, ui::PAGE_TRANSITION_TYPED, |
405 history::SOURCE_BROWSED); | 403 history::SOURCE_BROWSED); |
406 | 404 |
407 // Modify the non-typed URL. It should not get synced. | 405 // Modify the non-typed URL. It should not get synced. |
408 typed_urls_helper::SetPageTitle(0, kNonTypedURL, "Welcome to Non-Typed URL"); | 406 typed_urls_helper::SetPageTitle(0, kNonTypedURL, "Welcome to Non-Typed URL"); |
409 ASSERT_TRUE(AwaitCheckAllProfilesHaveSameURLs()); | 407 ASSERT_TRUE(ProfilesHaveSameURLsChecker().Wait()); |
410 | 408 |
411 history::VisitVector visits; | 409 history::VisitVector visits; |
412 // First client has both visits. | 410 // First client has both visits. |
413 visits = typed_urls_helper::GetVisitsForURLFromClient(0, kNonTypedURL); | 411 visits = typed_urls_helper::GetVisitsForURLFromClient(0, kNonTypedURL); |
414 ASSERT_EQ(1U, visits.size()); | 412 ASSERT_EQ(1U, visits.size()); |
415 EXPECT_TRUE(ui::PageTransitionCoreTypeIs(visits[0].transition, | 413 EXPECT_TRUE(ui::PageTransitionCoreTypeIs(visits[0].transition, |
416 ui::PAGE_TRANSITION_LINK)); | 414 ui::PAGE_TRANSITION_LINK)); |
417 visits = typed_urls_helper::GetVisitsForURLFromClient(0, kTypedURL); | 415 visits = typed_urls_helper::GetVisitsForURLFromClient(0, kTypedURL); |
418 ASSERT_EQ(1U, visits.size()); | 416 ASSERT_EQ(1U, visits.size()); |
419 EXPECT_TRUE(ui::PageTransitionCoreTypeIs(visits[0].transition, | 417 EXPECT_TRUE(ui::PageTransitionCoreTypeIs(visits[0].transition, |
(...skipping 25 matching lines...) Expand all Loading... |
445 GURL redirected_url(kRedirectedHistoryUrl); | 443 GURL redirected_url(kRedirectedHistoryUrl); |
446 const ui::PageTransition redirected_transition = ui::PageTransitionFromInt( | 444 const ui::PageTransition redirected_transition = ui::PageTransitionFromInt( |
447 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_CHAIN_END | | 445 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_CHAIN_END | |
448 ui::PAGE_TRANSITION_SERVER_REDIRECT); | 446 ui::PAGE_TRANSITION_SERVER_REDIRECT); |
449 // This address will have a typed_count == 0 because it's a redirection. | 447 // This address will have a typed_count == 0 because it's a redirection. |
450 // It should still be synced. | 448 // It should still be synced. |
451 AddUrlToHistoryWithTransition(0, redirected_url, redirected_transition, | 449 AddUrlToHistoryWithTransition(0, redirected_url, redirected_transition, |
452 history::SOURCE_BROWSED); | 450 history::SOURCE_BROWSED); |
453 | 451 |
454 // Both clients should have both URLs. | 452 // Both clients should have both URLs. |
455 ASSERT_TRUE(AwaitCheckAllProfilesHaveSameURLs()); | 453 ASSERT_TRUE(ProfilesHaveSameURLsChecker().Wait()); |
456 | 454 |
457 history::VisitVector visits = | 455 history::VisitVector visits = |
458 typed_urls_helper::GetVisitsForURLFromClient(0, initial_url); | 456 typed_urls_helper::GetVisitsForURLFromClient(0, initial_url); |
459 ASSERT_EQ(1U, visits.size()); | 457 ASSERT_EQ(1U, visits.size()); |
460 EXPECT_TRUE(ui::PageTransitionCoreTypeIs(visits[0].transition, | 458 EXPECT_TRUE(ui::PageTransitionCoreTypeIs(visits[0].transition, |
461 ui::PAGE_TRANSITION_TYPED)); | 459 ui::PAGE_TRANSITION_TYPED)); |
462 visits = typed_urls_helper::GetVisitsForURLFromClient(0, redirected_url); | 460 visits = typed_urls_helper::GetVisitsForURLFromClient(0, redirected_url); |
463 ASSERT_EQ(1U, visits.size()); | 461 ASSERT_EQ(1U, visits.size()); |
464 EXPECT_TRUE(ui::PageTransitionCoreTypeIs(visits[0].transition, | 462 EXPECT_TRUE(ui::PageTransitionCoreTypeIs(visits[0].transition, |
465 ui::PAGE_TRANSITION_TYPED)); | 463 ui::PAGE_TRANSITION_TYPED)); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 // A row in the DB for client 1 should have been created as a result of the | 528 // A row in the DB for client 1 should have been created as a result of the |
531 // sync. | 529 // sync. |
532 history::URLRow row; | 530 history::URLRow row; |
533 ASSERT_TRUE(GetUrlFromClient(1, bookmark_url, &row)); | 531 ASSERT_TRUE(GetUrlFromClient(1, bookmark_url, &row)); |
534 | 532 |
535 // Now, add a typed visit for client 0 to the bookmark URL and sync it over | 533 // Now, add a typed visit for client 0 to the bookmark URL and sync it over |
536 // - this should not cause a crash. | 534 // - this should not cause a crash. |
537 AddUrlToHistory(0, bookmark_url); | 535 AddUrlToHistory(0, bookmark_url); |
538 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 536 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
539 | 537 |
540 ASSERT_TRUE(AwaitCheckAllProfilesHaveSameURLs()); | 538 ASSERT_TRUE(ProfilesHaveSameURLsChecker().Wait()); |
541 history::URLRows urls = GetTypedUrlsFromClient(0); | 539 history::URLRows urls = GetTypedUrlsFromClient(0); |
542 ASSERT_EQ(1U, urls.size()); | 540 ASSERT_EQ(1U, urls.size()); |
543 ASSERT_EQ(bookmark_url, urls[0].url()); | 541 ASSERT_EQ(bookmark_url, urls[0].url()); |
544 ASSERT_EQ(1, GetVisitCountForFirstURL(0)); | 542 ASSERT_EQ(1, GetVisitCountForFirstURL(0)); |
545 } | 543 } |
OLD | NEW |