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/i18n/number_formatting.h" | 5 #include "base/i18n/number_formatting.h" |
6 #include "base/memory/scoped_vector.h" | 6 #include "base/memory/scoped_vector.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/sessions/session_service.h" | 8 #include "chrome/browser/sessions/session_service.h" |
9 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" | 9 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" |
10 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" | 10 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
370 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 370 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
371 | 371 |
372 // Both clients should have this URL as typed and have two visits synced up. | 372 // Both clients should have this URL as typed and have two visits synced up. |
373 ASSERT_TRUE(CheckClientsEqual()); | 373 ASSERT_TRUE(CheckClientsEqual()); |
374 urls = GetTypedUrlsFromClient(0); | 374 urls = GetTypedUrlsFromClient(0); |
375 ASSERT_EQ(1U, urls.size()); | 375 ASSERT_EQ(1U, urls.size()); |
376 ASSERT_EQ(new_url, urls[0].url()); | 376 ASSERT_EQ(new_url, urls[0].url()); |
377 ASSERT_EQ(2, GetVisitCountForFirstURL(0)); | 377 ASSERT_EQ(2, GetVisitCountForFirstURL(0)); |
378 } | 378 } |
379 | 379 |
380 IN_PROC_BROWSER_TEST_F(TwoClientTypedUrlsSyncTest, SyncTypedRedirects) { | |
Nicolas Zea
2015/04/20 19:46:03
nit: add a comment describing the purpose of the t
| |
381 const base::string16 kHistoryUrl(ASCIIToUTF16("http://typed.google.com/")); | |
382 const base::string16 kRedirectedHistoryUrl( | |
383 ASCIIToUTF16("http://www.typed.google.com/")); | |
384 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
385 | |
386 // Simulate a typed address that gets redirected by the server to a different | |
387 // address. | |
388 GURL initial_url(kHistoryUrl); | |
389 const ui::PageTransition initial_transition = ui::PageTransitionFromInt( | |
390 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_CHAIN_START); | |
391 AddUrlToHistoryWithTransition(0, initial_url, initial_transition, | |
392 history::SOURCE_BROWSED); | |
393 | |
394 GURL redirected_url(kRedirectedHistoryUrl); | |
395 const ui::PageTransition redirected_transition = ui::PageTransitionFromInt( | |
396 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_CHAIN_END | | |
397 ui::PAGE_TRANSITION_SERVER_REDIRECT); | |
398 // This address will have a typed_count == 0 because it's a redirection. | |
399 // It should still be synced. | |
400 AddUrlToHistoryWithTransition(0, redirected_url, redirected_transition, | |
401 history::SOURCE_BROWSED); | |
402 | |
403 // Both clients should have both URLs. | |
404 ASSERT_TRUE(AwaitCheckAllProfilesHaveSameURLsAsVerifier()); | |
405 | |
406 history::VisitVector visits = | |
407 typed_urls_helper::GetVisitsForURLFromClient(0, initial_url); | |
408 ASSERT_EQ(1U, visits.size()); | |
409 EXPECT_TRUE(ui::PageTransitionCoreTypeIs(visits[0].transition, | |
410 ui::PAGE_TRANSITION_TYPED)); | |
411 visits = typed_urls_helper::GetVisitsForURLFromClient(0, redirected_url); | |
412 ASSERT_EQ(1U, visits.size()); | |
413 EXPECT_TRUE(ui::PageTransitionCoreTypeIs(visits[0].transition, | |
414 ui::PAGE_TRANSITION_TYPED)); | |
415 | |
416 visits = typed_urls_helper::GetVisitsForURLFromClient(1, initial_url); | |
417 ASSERT_EQ(1U, visits.size()); | |
418 EXPECT_TRUE(ui::PageTransitionCoreTypeIs(visits[0].transition, | |
419 ui::PAGE_TRANSITION_TYPED)); | |
420 visits = typed_urls_helper::GetVisitsForURLFromClient(1, redirected_url); | |
421 ASSERT_EQ(1U, visits.size()); | |
422 EXPECT_TRUE(ui::PageTransitionCoreTypeIs(visits[0].transition, | |
423 ui::PAGE_TRANSITION_TYPED)); | |
424 } | |
425 | |
380 IN_PROC_BROWSER_TEST_F(TwoClientTypedUrlsSyncTest, | 426 IN_PROC_BROWSER_TEST_F(TwoClientTypedUrlsSyncTest, |
381 SkipImportedVisits) { | 427 SkipImportedVisits) { |
382 | 428 |
383 GURL imported_url("http://imported_url.com"); | 429 GURL imported_url("http://imported_url.com"); |
384 GURL browsed_url("http://browsed_url.com"); | 430 GURL browsed_url("http://browsed_url.com"); |
385 GURL browsed_and_imported_url("http://browsed_and_imported_url.com"); | 431 GURL browsed_and_imported_url("http://browsed_and_imported_url.com"); |
386 ASSERT_TRUE(SetupClients()); | 432 ASSERT_TRUE(SetupClients()); |
387 | 433 |
388 // Create 3 items in our first client - 1 imported, one browsed, one with | 434 // Create 3 items in our first client - 1 imported, one browsed, one with |
389 // both imported and browsed entries. | 435 // both imported and browsed entries. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
440 // - this should not cause a crash. | 486 // - this should not cause a crash. |
441 AddUrlToHistory(0, bookmark_url); | 487 AddUrlToHistory(0, bookmark_url); |
442 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 488 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
443 | 489 |
444 ASSERT_TRUE(AwaitCheckAllProfilesHaveSameURLsAsVerifier()); | 490 ASSERT_TRUE(AwaitCheckAllProfilesHaveSameURLsAsVerifier()); |
445 history::URLRows urls = GetTypedUrlsFromClient(0); | 491 history::URLRows urls = GetTypedUrlsFromClient(0); |
446 ASSERT_EQ(1U, urls.size()); | 492 ASSERT_EQ(1U, urls.size()); |
447 ASSERT_EQ(bookmark_url, urls[0].url()); | 493 ASSERT_EQ(bookmark_url, urls[0].url()); |
448 ASSERT_EQ(1, GetVisitCountForFirstURL(0)); | 494 ASSERT_EQ(1, GetVisitCountForFirstURL(0)); |
449 } | 495 } |
OLD | NEW |