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, | |
maniscalco
2015/05/08 19:38:00
Nice test.
| |
381 DontSyncUpdatedNonTypedURLs) { | |
382 // Checks if a non-typed URL that has been updated (modified) doesn't get | |
383 // synced. This is a regression test after fixing a bug where adding a | |
384 // non-typed URL was guarded against but later modifying it was not. Since | |
385 // "update" is "update or create if missing", non-typed URLs were being | |
386 // created. | |
387 const GURL kNonTypedURL("http://link.google.com/"); | |
388 const GURL kTypedURL("http://typed.google.com/"); | |
389 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
390 AddUrlToHistoryWithTransition(0, kNonTypedURL, ui::PAGE_TRANSITION_LINK, | |
391 history::SOURCE_BROWSED); | |
392 AddUrlToHistoryWithTransition(0, kTypedURL, ui::PAGE_TRANSITION_TYPED, | |
393 history::SOURCE_BROWSED); | |
394 | |
395 // Modify the non-typed URL. It should not get synced. | |
396 typed_urls_helper::SetPageTitle(0, kNonTypedURL, "Welcome to Non-Typed URL"); | |
397 ASSERT_TRUE(AwaitCheckAllProfilesHaveSameURLsAsVerifier()); | |
398 | |
399 history::VisitVector visits; | |
400 // First client has both visits. | |
401 visits = typed_urls_helper::GetVisitsForURLFromClient(0, kNonTypedURL); | |
402 ASSERT_EQ(1U, visits.size()); | |
403 EXPECT_TRUE(ui::PageTransitionCoreTypeIs(visits[0].transition, | |
404 ui::PAGE_TRANSITION_LINK)); | |
405 visits = typed_urls_helper::GetVisitsForURLFromClient(0, kTypedURL); | |
406 ASSERT_EQ(1U, visits.size()); | |
407 EXPECT_TRUE(ui::PageTransitionCoreTypeIs(visits[0].transition, | |
408 ui::PAGE_TRANSITION_TYPED)); | |
409 // Second client has only the typed visit. | |
410 visits = typed_urls_helper::GetVisitsForURLFromClient(1, kNonTypedURL); | |
411 ASSERT_EQ(0U, visits.size()); | |
412 visits = typed_urls_helper::GetVisitsForURLFromClient(1, kTypedURL); | |
413 ASSERT_EQ(1U, visits.size()); | |
414 EXPECT_TRUE(ui::PageTransitionCoreTypeIs(visits[0].transition, | |
415 ui::PAGE_TRANSITION_TYPED)); | |
416 } | |
417 | |
380 IN_PROC_BROWSER_TEST_F(TwoClientTypedUrlsSyncTest, SyncTypedRedirects) { | 418 IN_PROC_BROWSER_TEST_F(TwoClientTypedUrlsSyncTest, SyncTypedRedirects) { |
381 const base::string16 kHistoryUrl(ASCIIToUTF16("http://typed.google.com/")); | 419 const base::string16 kHistoryUrl(ASCIIToUTF16("http://typed.google.com/")); |
382 const base::string16 kRedirectedHistoryUrl( | 420 const base::string16 kRedirectedHistoryUrl( |
383 ASCIIToUTF16("http://www.typed.google.com/")); | 421 ASCIIToUTF16("http://www.typed.google.com/")); |
384 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 422 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
385 | 423 |
386 // Simulate a typed address that gets redirected by the server to a different | 424 // Simulate a typed address that gets redirected by the server to a different |
387 // address. | 425 // address. |
388 GURL initial_url(kHistoryUrl); | 426 GURL initial_url(kHistoryUrl); |
389 const ui::PageTransition initial_transition = ui::PageTransitionFromInt( | 427 const ui::PageTransition initial_transition = ui::PageTransitionFromInt( |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
486 // - this should not cause a crash. | 524 // - this should not cause a crash. |
487 AddUrlToHistory(0, bookmark_url); | 525 AddUrlToHistory(0, bookmark_url); |
488 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 526 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
489 | 527 |
490 ASSERT_TRUE(AwaitCheckAllProfilesHaveSameURLsAsVerifier()); | 528 ASSERT_TRUE(AwaitCheckAllProfilesHaveSameURLsAsVerifier()); |
491 history::URLRows urls = GetTypedUrlsFromClient(0); | 529 history::URLRows urls = GetTypedUrlsFromClient(0); |
492 ASSERT_EQ(1U, urls.size()); | 530 ASSERT_EQ(1U, urls.size()); |
493 ASSERT_EQ(bookmark_url, urls[0].url()); | 531 ASSERT_EQ(bookmark_url, urls[0].url()); |
494 ASSERT_EQ(1, GetVisitCountForFirstURL(0)); | 532 ASSERT_EQ(1, GetVisitCountForFirstURL(0)); |
495 } | 533 } |
OLD | NEW |