| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "components/sync_driver/favicon_cache.h" | 5 #include "components/sync_driver/favicon_cache.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 i); | 563 i); |
| 564 expected_change_types.push_back(syncer::SyncChange::ACTION_ADD); | 564 expected_change_types.push_back(syncer::SyncChange::ACTION_ADD); |
| 565 expected_icons.push_back(i); | 565 expected_icons.push_back(i); |
| 566 } | 566 } |
| 567 | 567 |
| 568 syncer::SyncMergeResult merge_result = | 568 syncer::SyncMergeResult merge_result = |
| 569 cache()->MergeDataAndStartSyncing(syncer::FAVICON_IMAGES, | 569 cache()->MergeDataAndStartSyncing(syncer::FAVICON_IMAGES, |
| 570 syncer::SyncDataList(), | 570 syncer::SyncDataList(), |
| 571 CreateAndPassProcessor(), | 571 CreateAndPassProcessor(), |
| 572 CreateAndPassSyncErrorFactory()); | 572 CreateAndPassSyncErrorFactory()); |
| 573 EXPECT_EQ((unsigned long)kFaviconBatchSize, | 573 EXPECT_EQ(static_cast<size_t>(kFaviconBatchSize), |
| 574 cache()->GetAllSyncData(syncer::FAVICON_IMAGES).size()); | 574 cache()->GetAllSyncData(syncer::FAVICON_IMAGES).size()); |
| 575 syncer::SyncChangeList change_list = processor()->GetAndResetChangeList(); | 575 syncer::SyncChangeList change_list = processor()->GetAndResetChangeList(); |
| 576 EXPECT_TRUE(VerifyChanges(syncer::FAVICON_IMAGES, | 576 EXPECT_TRUE(VerifyChanges(syncer::FAVICON_IMAGES, |
| 577 expected_change_types, | 577 expected_change_types, |
| 578 expected_icons, | 578 expected_icons, |
| 579 change_list)); | 579 change_list)); |
| 580 EXPECT_EQ(0, merge_result.num_items_added()); | 580 EXPECT_EQ(0, merge_result.num_items_added()); |
| 581 EXPECT_EQ(0, merge_result.num_items_modified()); | 581 EXPECT_EQ(0, merge_result.num_items_modified()); |
| 582 EXPECT_EQ(0, merge_result.num_items_deleted()); | 582 EXPECT_EQ(0, merge_result.num_items_deleted()); |
| 583 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_before_association()); | 583 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_before_association()); |
| 584 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_after_association()); | 584 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_after_association()); |
| 585 | 585 |
| 586 merge_result = | 586 merge_result = |
| 587 cache()->MergeDataAndStartSyncing(syncer::FAVICON_TRACKING, | 587 cache()->MergeDataAndStartSyncing(syncer::FAVICON_TRACKING, |
| 588 syncer::SyncDataList(), | 588 syncer::SyncDataList(), |
| 589 CreateAndPassProcessor(), | 589 CreateAndPassProcessor(), |
| 590 CreateAndPassSyncErrorFactory()); | 590 CreateAndPassSyncErrorFactory()); |
| 591 EXPECT_EQ((unsigned long)kFaviconBatchSize, | 591 EXPECT_EQ(static_cast<size_t>(kFaviconBatchSize), |
| 592 cache()->GetAllSyncData(syncer::FAVICON_TRACKING).size()); | 592 cache()->GetAllSyncData(syncer::FAVICON_TRACKING).size()); |
| 593 change_list = processor()->GetAndResetChangeList(); | 593 change_list = processor()->GetAndResetChangeList(); |
| 594 EXPECT_TRUE(VerifyChanges(syncer::FAVICON_TRACKING, | 594 EXPECT_TRUE(VerifyChanges(syncer::FAVICON_TRACKING, |
| 595 expected_change_types, | 595 expected_change_types, |
| 596 expected_icons, | 596 expected_icons, |
| 597 change_list)); | 597 change_list)); |
| 598 EXPECT_EQ(0, merge_result.num_items_added()); | 598 EXPECT_EQ(0, merge_result.num_items_added()); |
| 599 EXPECT_EQ(0, merge_result.num_items_modified()); | 599 EXPECT_EQ(0, merge_result.num_items_modified()); |
| 600 EXPECT_EQ(0, merge_result.num_items_deleted()); | 600 EXPECT_EQ(0, merge_result.num_items_deleted()); |
| 601 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_before_association()); | 601 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_before_association()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 626 base::Time(), | 626 base::Time(), |
| 627 syncer::AttachmentIdList(), | 627 syncer::AttachmentIdList(), |
| 628 syncer::AttachmentServiceProxyForTest::Create())); | 628 syncer::AttachmentServiceProxyForTest::Create())); |
| 629 } | 629 } |
| 630 | 630 |
| 631 syncer::SyncMergeResult merge_result = | 631 syncer::SyncMergeResult merge_result = |
| 632 cache()->MergeDataAndStartSyncing(syncer::FAVICON_IMAGES, | 632 cache()->MergeDataAndStartSyncing(syncer::FAVICON_IMAGES, |
| 633 initial_image_data, | 633 initial_image_data, |
| 634 CreateAndPassProcessor(), | 634 CreateAndPassProcessor(), |
| 635 CreateAndPassSyncErrorFactory()); | 635 CreateAndPassSyncErrorFactory()); |
| 636 EXPECT_EQ((unsigned long)kFaviconBatchSize, | 636 EXPECT_EQ(static_cast<size_t>(kFaviconBatchSize), |
| 637 cache()->GetAllSyncData(syncer::FAVICON_IMAGES).size()); | 637 cache()->GetAllSyncData(syncer::FAVICON_IMAGES).size()); |
| 638 EXPECT_EQ(0U, processor()->GetAndResetChangeList().size()); | 638 EXPECT_EQ(0U, processor()->GetAndResetChangeList().size()); |
| 639 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_added()); | 639 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_added()); |
| 640 EXPECT_EQ(0, merge_result.num_items_modified()); | 640 EXPECT_EQ(0, merge_result.num_items_modified()); |
| 641 EXPECT_EQ(0, merge_result.num_items_deleted()); | 641 EXPECT_EQ(0, merge_result.num_items_deleted()); |
| 642 EXPECT_EQ(0, merge_result.num_items_before_association()); | 642 EXPECT_EQ(0, merge_result.num_items_before_association()); |
| 643 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_after_association()); | 643 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_after_association()); |
| 644 | 644 |
| 645 merge_result = | 645 merge_result = |
| 646 cache()->MergeDataAndStartSyncing(syncer::FAVICON_TRACKING, | 646 cache()->MergeDataAndStartSyncing(syncer::FAVICON_TRACKING, |
| 647 initial_tracking_data, | 647 initial_tracking_data, |
| 648 CreateAndPassProcessor(), | 648 CreateAndPassProcessor(), |
| 649 CreateAndPassSyncErrorFactory()); | 649 CreateAndPassSyncErrorFactory()); |
| 650 EXPECT_EQ((unsigned long)kFaviconBatchSize, | 650 EXPECT_EQ(static_cast<size_t>(kFaviconBatchSize), |
| 651 cache()->GetAllSyncData(syncer::FAVICON_TRACKING).size()); | 651 cache()->GetAllSyncData(syncer::FAVICON_TRACKING).size()); |
| 652 EXPECT_EQ(0U, processor()->GetAndResetChangeList().size()); | 652 EXPECT_EQ(0U, processor()->GetAndResetChangeList().size()); |
| 653 EXPECT_EQ(0, merge_result.num_items_added()); | 653 EXPECT_EQ(0, merge_result.num_items_added()); |
| 654 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_modified()); | 654 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_modified()); |
| 655 EXPECT_EQ(0, merge_result.num_items_deleted()); | 655 EXPECT_EQ(0, merge_result.num_items_deleted()); |
| 656 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_before_association()); | 656 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_before_association()); |
| 657 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_after_association()); | 657 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_after_association()); |
| 658 | 658 |
| 659 ASSERT_TRUE(VerifyLocalIcons(expected_icons)); | 659 ASSERT_TRUE(VerifyLocalIcons(expected_icons)); |
| 660 } | 660 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 base::Time(), | 705 base::Time(), |
| 706 syncer::AttachmentIdList(), | 706 syncer::AttachmentIdList(), |
| 707 syncer::AttachmentServiceProxyForTest::Create())); | 707 syncer::AttachmentServiceProxyForTest::Create())); |
| 708 } | 708 } |
| 709 | 709 |
| 710 syncer::SyncMergeResult merge_result = | 710 syncer::SyncMergeResult merge_result = |
| 711 cache()->MergeDataAndStartSyncing(syncer::FAVICON_IMAGES, | 711 cache()->MergeDataAndStartSyncing(syncer::FAVICON_IMAGES, |
| 712 initial_image_data, | 712 initial_image_data, |
| 713 CreateAndPassProcessor(), | 713 CreateAndPassProcessor(), |
| 714 CreateAndPassSyncErrorFactory()); | 714 CreateAndPassSyncErrorFactory()); |
| 715 EXPECT_EQ((unsigned long)kFaviconBatchSize, | 715 EXPECT_EQ(static_cast<size_t>(kFaviconBatchSize), |
| 716 cache()->GetAllSyncData(syncer::FAVICON_IMAGES).size()); | 716 cache()->GetAllSyncData(syncer::FAVICON_IMAGES).size()); |
| 717 syncer::SyncChangeList changes = processor()->GetAndResetChangeList(); | 717 syncer::SyncChangeList changes = processor()->GetAndResetChangeList(); |
| 718 EXPECT_EQ((unsigned long)kFaviconBatchSize/2, changes.size()); | 718 EXPECT_EQ(static_cast<size_t>(kFaviconBatchSize)/2, changes.size()); |
| 719 EXPECT_EQ(0, merge_result.num_items_added()); | 719 EXPECT_EQ(0, merge_result.num_items_added()); |
| 720 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_modified()); | 720 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_modified()); |
| 721 EXPECT_EQ(0, merge_result.num_items_deleted()); | 721 EXPECT_EQ(0, merge_result.num_items_deleted()); |
| 722 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_before_association()); | 722 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_before_association()); |
| 723 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_after_association()); | 723 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_after_association()); |
| 724 | 724 |
| 725 merge_result = | 725 merge_result = |
| 726 cache()->MergeDataAndStartSyncing(syncer::FAVICON_TRACKING, | 726 cache()->MergeDataAndStartSyncing(syncer::FAVICON_TRACKING, |
| 727 initial_tracking_data, | 727 initial_tracking_data, |
| 728 CreateAndPassProcessor(), | 728 CreateAndPassProcessor(), |
| 729 CreateAndPassSyncErrorFactory()); | 729 CreateAndPassSyncErrorFactory()); |
| 730 EXPECT_EQ((unsigned long)kFaviconBatchSize, | 730 EXPECT_EQ(static_cast<size_t>(kFaviconBatchSize), |
| 731 cache()->GetAllSyncData(syncer::FAVICON_TRACKING).size()); | 731 cache()->GetAllSyncData(syncer::FAVICON_TRACKING).size()); |
| 732 EXPECT_EQ(0U, processor()->GetAndResetChangeList().size()); | 732 EXPECT_EQ(0U, processor()->GetAndResetChangeList().size()); |
| 733 EXPECT_EQ(0, merge_result.num_items_added()); | 733 EXPECT_EQ(0, merge_result.num_items_added()); |
| 734 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_modified()); | 734 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_modified()); |
| 735 EXPECT_EQ(0, merge_result.num_items_deleted()); | 735 EXPECT_EQ(0, merge_result.num_items_deleted()); |
| 736 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_before_association()); | 736 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_before_association()); |
| 737 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_after_association()); | 737 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_after_association()); |
| 738 | 738 |
| 739 ASSERT_TRUE(VerifyLocalIcons(expected_icons)); | 739 ASSERT_TRUE(VerifyLocalIcons(expected_icons)); |
| 740 ASSERT_TRUE(VerifyLocalCustomIcons(expected_data)); | 740 ASSERT_TRUE(VerifyLocalCustomIcons(expected_data)); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 base::Time(), | 790 base::Time(), |
| 791 syncer::AttachmentIdList(), | 791 syncer::AttachmentIdList(), |
| 792 syncer::AttachmentServiceProxyForTest::Create())); | 792 syncer::AttachmentServiceProxyForTest::Create())); |
| 793 } | 793 } |
| 794 | 794 |
| 795 syncer::SyncMergeResult merge_result = | 795 syncer::SyncMergeResult merge_result = |
| 796 cache()->MergeDataAndStartSyncing(syncer::FAVICON_IMAGES, | 796 cache()->MergeDataAndStartSyncing(syncer::FAVICON_IMAGES, |
| 797 initial_image_data, | 797 initial_image_data, |
| 798 CreateAndPassProcessor(), | 798 CreateAndPassProcessor(), |
| 799 CreateAndPassSyncErrorFactory()); | 799 CreateAndPassSyncErrorFactory()); |
| 800 EXPECT_EQ((unsigned long)kFaviconBatchSize, | 800 EXPECT_EQ(static_cast<size_t>(kFaviconBatchSize), |
| 801 cache()->GetAllSyncData(syncer::FAVICON_IMAGES).size()); | 801 cache()->GetAllSyncData(syncer::FAVICON_IMAGES).size()); |
| 802 EXPECT_EQ(0U, processor()->GetAndResetChangeList().size()); | 802 EXPECT_EQ(0U, processor()->GetAndResetChangeList().size()); |
| 803 EXPECT_EQ(0, merge_result.num_items_added()); | 803 EXPECT_EQ(0, merge_result.num_items_added()); |
| 804 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_modified()); | 804 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_modified()); |
| 805 EXPECT_EQ(0, merge_result.num_items_deleted()); | 805 EXPECT_EQ(0, merge_result.num_items_deleted()); |
| 806 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_before_association()); | 806 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_before_association()); |
| 807 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_after_association()); | 807 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_after_association()); |
| 808 | 808 |
| 809 merge_result = | 809 merge_result = |
| 810 cache()->MergeDataAndStartSyncing(syncer::FAVICON_TRACKING, | 810 cache()->MergeDataAndStartSyncing(syncer::FAVICON_TRACKING, |
| 811 initial_tracking_data, | 811 initial_tracking_data, |
| 812 CreateAndPassProcessor(), | 812 CreateAndPassProcessor(), |
| 813 CreateAndPassSyncErrorFactory()); | 813 CreateAndPassSyncErrorFactory()); |
| 814 EXPECT_EQ((unsigned long)kFaviconBatchSize, | 814 EXPECT_EQ(static_cast<size_t>(kFaviconBatchSize), |
| 815 cache()->GetAllSyncData(syncer::FAVICON_TRACKING).size()); | 815 cache()->GetAllSyncData(syncer::FAVICON_TRACKING).size()); |
| 816 syncer::SyncChangeList changes = processor()->GetAndResetChangeList(); | 816 syncer::SyncChangeList changes = processor()->GetAndResetChangeList(); |
| 817 EXPECT_EQ((unsigned long)kFaviconBatchSize/2, changes.size()); | 817 EXPECT_EQ(static_cast<size_t>(kFaviconBatchSize)/2, changes.size()); |
| 818 EXPECT_EQ(0, merge_result.num_items_added()); | 818 EXPECT_EQ(0, merge_result.num_items_added()); |
| 819 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_modified()); | 819 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_modified()); |
| 820 EXPECT_EQ(0, merge_result.num_items_deleted()); | 820 EXPECT_EQ(0, merge_result.num_items_deleted()); |
| 821 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_before_association()); | 821 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_before_association()); |
| 822 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_after_association()); | 822 EXPECT_EQ(kFaviconBatchSize, merge_result.num_items_after_association()); |
| 823 | 823 |
| 824 ASSERT_TRUE(VerifyLocalIcons(expected_icons)); | 824 ASSERT_TRUE(VerifyLocalIcons(expected_icons)); |
| 825 ASSERT_TRUE(VerifyLocalCustomIcons(expected_data)); | 825 ASSERT_TRUE(VerifyLocalCustomIcons(expected_data)); |
| 826 ASSERT_TRUE(VerifyChanges(syncer::FAVICON_TRACKING, | 826 ASSERT_TRUE(VerifyChanges(syncer::FAVICON_TRACKING, |
| 827 expected_change_types, | 827 expected_change_types, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 syncer::AttachmentIdList(), | 867 syncer::AttachmentIdList(), |
| 868 syncer::AttachmentServiceProxyForTest::Create())); | 868 syncer::AttachmentServiceProxyForTest::Create())); |
| 869 } | 869 } |
| 870 | 870 |
| 871 SetUpInitialSync(initial_image_data, initial_tracking_data); | 871 SetUpInitialSync(initial_image_data, initial_tracking_data); |
| 872 | 872 |
| 873 // Now receive the same icons as an update, but with missing image data. | 873 // Now receive the same icons as an update, but with missing image data. |
| 874 cache()->ProcessSyncChanges(FROM_HERE, stale_changes); | 874 cache()->ProcessSyncChanges(FROM_HERE, stale_changes); |
| 875 syncer::SyncChangeList changes = processor()->GetAndResetChangeList(); | 875 syncer::SyncChangeList changes = processor()->GetAndResetChangeList(); |
| 876 ASSERT_TRUE(VerifyLocalIcons(expected_icons)); | 876 ASSERT_TRUE(VerifyLocalIcons(expected_icons)); |
| 877 ASSERT_EQ((unsigned long)kFaviconBatchSize, changes.size()); | 877 ASSERT_EQ(static_cast<size_t>(kFaviconBatchSize), changes.size()); |
| 878 ASSERT_TRUE(VerifyChanges(syncer::FAVICON_IMAGES, | 878 ASSERT_TRUE(VerifyChanges(syncer::FAVICON_IMAGES, |
| 879 expected_change_types, | 879 expected_change_types, |
| 880 expected_icons, | 880 expected_icons, |
| 881 changes)); | 881 changes)); |
| 882 } | 882 } |
| 883 | 883 |
| 884 // New icons should be added locally without pushing anything back to the | 884 // New icons should be added locally without pushing anything back to the |
| 885 // remote syncer. | 885 // remote syncer. |
| 886 TEST_F(SyncFaviconCacheTest, ReceiveNewImages) { | 886 TEST_F(SyncFaviconCacheTest, ReceiveNewImages) { |
| 887 syncer::SyncDataList initial_image_data, initial_tracking_data; | 887 syncer::SyncDataList initial_image_data, initial_tracking_data; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1012 syncer::AttachmentIdList(), | 1012 syncer::AttachmentIdList(), |
| 1013 syncer::AttachmentServiceProxyForTest::Create()))); | 1013 syncer::AttachmentServiceProxyForTest::Create()))); |
| 1014 } | 1014 } |
| 1015 | 1015 |
| 1016 SetUpInitialSync(initial_image_data, initial_tracking_data); | 1016 SetUpInitialSync(initial_image_data, initial_tracking_data); |
| 1017 | 1017 |
| 1018 // Now receive the same icons as an update, but with missing image data. | 1018 // Now receive the same icons as an update, but with missing image data. |
| 1019 cache()->ProcessSyncChanges(FROM_HERE, stale_changes); | 1019 cache()->ProcessSyncChanges(FROM_HERE, stale_changes); |
| 1020 syncer::SyncChangeList changes = processor()->GetAndResetChangeList(); | 1020 syncer::SyncChangeList changes = processor()->GetAndResetChangeList(); |
| 1021 ASSERT_TRUE(VerifyLocalIcons(expected_icons)); | 1021 ASSERT_TRUE(VerifyLocalIcons(expected_icons)); |
| 1022 ASSERT_EQ((unsigned long)kFaviconBatchSize, changes.size()); | 1022 ASSERT_EQ(static_cast<size_t>(kFaviconBatchSize), changes.size()); |
| 1023 ASSERT_TRUE(VerifyChanges(syncer::FAVICON_TRACKING, | 1023 ASSERT_TRUE(VerifyChanges(syncer::FAVICON_TRACKING, |
| 1024 expected_change_types, | 1024 expected_change_types, |
| 1025 expected_icons, | 1025 expected_icons, |
| 1026 changes)); | 1026 changes)); |
| 1027 } | 1027 } |
| 1028 | 1028 |
| 1029 // New tracking information should be added locally without pushing anything | 1029 // New tracking information should be added locally without pushing anything |
| 1030 // back to the remote syncer. | 1030 // back to the remote syncer. |
| 1031 TEST_F(SyncFaviconCacheTest, ReceiveNewTracking) { | 1031 TEST_F(SyncFaviconCacheTest, ReceiveNewTracking) { |
| 1032 syncer::SyncDataList initial_image_data, initial_tracking_data; | 1032 syncer::SyncDataList initial_image_data, initial_tracking_data; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1155 image_specifics, | 1155 image_specifics, |
| 1156 base::Time(), | 1156 base::Time(), |
| 1157 syncer::AttachmentIdList(), | 1157 syncer::AttachmentIdList(), |
| 1158 syncer::AttachmentServiceProxyForTest::Create()))); | 1158 syncer::AttachmentServiceProxyForTest::Create()))); |
| 1159 } | 1159 } |
| 1160 | 1160 |
| 1161 SetUpInitialSync(initial_image_data, initial_tracking_data); | 1161 SetUpInitialSync(initial_image_data, initial_tracking_data); |
| 1162 | 1162 |
| 1163 // Now receive the tracking deletions. Since we'll still have orphan data, | 1163 // Now receive the tracking deletions. Since we'll still have orphan data, |
| 1164 // the favicon count should remain the same. | 1164 // the favicon count should remain the same. |
| 1165 EXPECT_EQ((unsigned long)kFaviconBatchSize, GetFaviconCount()); | 1165 EXPECT_EQ(static_cast<size_t>(kFaviconBatchSize), GetFaviconCount()); |
| 1166 cache()->ProcessSyncChanges(FROM_HERE, tracking_deletions); | 1166 cache()->ProcessSyncChanges(FROM_HERE, tracking_deletions); |
| 1167 EXPECT_EQ(0U, processor()->GetAndResetChangeList().size()); | 1167 EXPECT_EQ(0U, processor()->GetAndResetChangeList().size()); |
| 1168 EXPECT_EQ((unsigned long)kFaviconBatchSize, GetFaviconCount()); | 1168 EXPECT_EQ(static_cast<size_t>(kFaviconBatchSize), GetFaviconCount()); |
| 1169 | 1169 |
| 1170 // Once the image deletions arrive, the favicon count should be 0 again. | 1170 // Once the image deletions arrive, the favicon count should be 0 again. |
| 1171 cache()->ProcessSyncChanges(FROM_HERE, image_deletions); | 1171 cache()->ProcessSyncChanges(FROM_HERE, image_deletions); |
| 1172 EXPECT_EQ(0U, processor()->GetAndResetChangeList().size()); | 1172 EXPECT_EQ(0U, processor()->GetAndResetChangeList().size()); |
| 1173 EXPECT_EQ(0U, GetFaviconCount()); | 1173 EXPECT_EQ(0U, GetFaviconCount()); |
| 1174 } | 1174 } |
| 1175 | 1175 |
| 1176 // Ensure that MergeDataAndStartSyncing enforces the sync favicon limit by | 1176 // Ensure that MergeDataAndStartSyncing enforces the sync favicon limit by |
| 1177 // dropping local icons. | 1177 // dropping local icons. |
| 1178 TEST_F(SyncFaviconCacheTest, ExpireOnMergeData) { | 1178 TEST_F(SyncFaviconCacheTest, ExpireOnMergeData) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1209 } | 1209 } |
| 1210 | 1210 |
| 1211 EXPECT_FALSE(VerifyLocalIcons(expected_icons)); | 1211 EXPECT_FALSE(VerifyLocalIcons(expected_icons)); |
| 1212 | 1212 |
| 1213 // Drops image part of the unsynced icons. | 1213 // Drops image part of the unsynced icons. |
| 1214 syncer::SyncMergeResult merge_result = | 1214 syncer::SyncMergeResult merge_result = |
| 1215 cache()->MergeDataAndStartSyncing(syncer::FAVICON_IMAGES, | 1215 cache()->MergeDataAndStartSyncing(syncer::FAVICON_IMAGES, |
| 1216 initial_image_data, | 1216 initial_image_data, |
| 1217 CreateAndPassProcessor(), | 1217 CreateAndPassProcessor(), |
| 1218 CreateAndPassSyncErrorFactory()); | 1218 CreateAndPassSyncErrorFactory()); |
| 1219 EXPECT_EQ((unsigned long)kMaxSyncFavicons * 2, | 1219 EXPECT_EQ(static_cast<size_t>(kMaxSyncFavicons)*2, |
| 1220 GetFaviconCount()); // Still have tracking. | 1220 GetFaviconCount()); // Still have tracking. |
| 1221 EXPECT_EQ((unsigned long)kMaxSyncFavicons, | 1221 EXPECT_EQ(static_cast<size_t>(kMaxSyncFavicons), |
| 1222 cache()->GetAllSyncData(syncer::FAVICON_IMAGES).size()); | 1222 cache()->GetAllSyncData(syncer::FAVICON_IMAGES).size()); |
| 1223 EXPECT_EQ(0U, processor()->GetAndResetChangeList().size()); | 1223 EXPECT_EQ(0U, processor()->GetAndResetChangeList().size()); |
| 1224 EXPECT_EQ(kMaxSyncFavicons, merge_result.num_items_added()); | 1224 EXPECT_EQ(kMaxSyncFavicons, merge_result.num_items_added()); |
| 1225 EXPECT_EQ(0, merge_result.num_items_modified()); | 1225 EXPECT_EQ(0, merge_result.num_items_modified()); |
| 1226 EXPECT_EQ(kMaxSyncFavicons, merge_result.num_items_deleted()); | 1226 EXPECT_EQ(kMaxSyncFavicons, merge_result.num_items_deleted()); |
| 1227 EXPECT_EQ(kMaxSyncFavicons, merge_result.num_items_before_association()); | 1227 EXPECT_EQ(kMaxSyncFavicons, merge_result.num_items_before_association()); |
| 1228 EXPECT_EQ(kMaxSyncFavicons * 2, merge_result.num_items_after_association()); | 1228 EXPECT_EQ(kMaxSyncFavicons * 2, merge_result.num_items_after_association()); |
| 1229 | 1229 |
| 1230 // Drops tracking part of the unsynced icons. | 1230 // Drops tracking part of the unsynced icons. |
| 1231 merge_result = | 1231 merge_result = |
| 1232 cache()->MergeDataAndStartSyncing(syncer::FAVICON_TRACKING, | 1232 cache()->MergeDataAndStartSyncing(syncer::FAVICON_TRACKING, |
| 1233 initial_tracking_data, | 1233 initial_tracking_data, |
| 1234 CreateAndPassProcessor(), | 1234 CreateAndPassProcessor(), |
| 1235 CreateAndPassSyncErrorFactory()); | 1235 CreateAndPassSyncErrorFactory()); |
| 1236 EXPECT_EQ((unsigned long)kMaxSyncFavicons, | 1236 EXPECT_EQ(static_cast<size_t>(kMaxSyncFavicons), |
| 1237 cache()->GetAllSyncData(syncer::FAVICON_TRACKING).size()); | 1237 cache()->GetAllSyncData(syncer::FAVICON_TRACKING).size()); |
| 1238 EXPECT_EQ(0U, processor()->GetAndResetChangeList().size()); | 1238 EXPECT_EQ(0U, processor()->GetAndResetChangeList().size()); |
| 1239 EXPECT_EQ(0, merge_result.num_items_added()); | 1239 EXPECT_EQ(0, merge_result.num_items_added()); |
| 1240 EXPECT_EQ(kMaxSyncFavicons, merge_result.num_items_modified()); | 1240 EXPECT_EQ(kMaxSyncFavicons, merge_result.num_items_modified()); |
| 1241 EXPECT_EQ(kMaxSyncFavicons, merge_result.num_items_deleted()); | 1241 EXPECT_EQ(kMaxSyncFavicons, merge_result.num_items_deleted()); |
| 1242 EXPECT_EQ(kMaxSyncFavicons * 2, merge_result.num_items_before_association()); | 1242 EXPECT_EQ(kMaxSyncFavicons * 2, merge_result.num_items_before_association()); |
| 1243 EXPECT_EQ(kMaxSyncFavicons, merge_result.num_items_after_association()); | 1243 EXPECT_EQ(kMaxSyncFavicons, merge_result.num_items_after_association()); |
| 1244 | 1244 |
| 1245 EXPECT_TRUE(VerifyLocalIcons(expected_icons)); | 1245 EXPECT_TRUE(VerifyLocalIcons(expected_icons)); |
| 1246 } | 1246 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1292 1, | 1292 1, |
| 1293 tracking_specifics, | 1293 tracking_specifics, |
| 1294 base::Time(), | 1294 base::Time(), |
| 1295 syncer::AttachmentIdList(), | 1295 syncer::AttachmentIdList(), |
| 1296 syncer::AttachmentServiceProxyForTest::Create()))); | 1296 syncer::AttachmentServiceProxyForTest::Create()))); |
| 1297 } | 1297 } |
| 1298 | 1298 |
| 1299 SetUpInitialSync(initial_image_data, initial_tracking_data); | 1299 SetUpInitialSync(initial_image_data, initial_tracking_data); |
| 1300 | 1300 |
| 1301 // Now receive the new icons as an update. | 1301 // Now receive the new icons as an update. |
| 1302 EXPECT_EQ((unsigned long)kMaxSyncFavicons, GetFaviconCount()); | 1302 EXPECT_EQ(static_cast<size_t>(kMaxSyncFavicons), GetFaviconCount()); |
| 1303 cache()->ProcessSyncChanges(FROM_HERE, image_changes); | 1303 cache()->ProcessSyncChanges(FROM_HERE, image_changes); |
| 1304 EXPECT_EQ(0U, processor()->GetAndResetChangeList().size()); | 1304 EXPECT_EQ(0U, processor()->GetAndResetChangeList().size()); |
| 1305 cache()->ProcessSyncChanges(FROM_HERE, tracking_changes); | 1305 cache()->ProcessSyncChanges(FROM_HERE, tracking_changes); |
| 1306 EXPECT_EQ(0U, processor()->GetAndResetChangeList().size()); | 1306 EXPECT_EQ(0U, processor()->GetAndResetChangeList().size()); |
| 1307 EXPECT_TRUE(VerifyLocalIcons(expected_icons)); | 1307 EXPECT_TRUE(VerifyLocalIcons(expected_icons)); |
| 1308 EXPECT_GT(GetFaviconCount(), (unsigned long)kMaxSyncFavicons); | 1308 EXPECT_LT(static_cast<size_t>(kMaxSyncFavicons), GetFaviconCount()); |
| 1309 } | 1309 } |
| 1310 | 1310 |
| 1311 // Test that visiting a new page triggers a favicon load and a sync addition. | 1311 // Test that visiting a new page triggers a favicon load and a sync addition. |
| 1312 TEST_F(SyncFaviconCacheTest, AddOnFaviconVisited) { | 1312 TEST_F(SyncFaviconCacheTest, AddOnFaviconVisited) { |
| 1313 EXPECT_EQ(0U, GetFaviconCount()); | 1313 EXPECT_EQ(0U, GetFaviconCount()); |
| 1314 SetUpInitialSync(syncer::SyncDataList(), syncer::SyncDataList()); | 1314 SetUpInitialSync(syncer::SyncDataList(), syncer::SyncDataList()); |
| 1315 std::vector<int> expected_icons; | 1315 std::vector<int> expected_icons; |
| 1316 | 1316 |
| 1317 for (int i = 0; i < kFaviconBatchSize; ++i) { | 1317 for (int i = 0; i < kFaviconBatchSize; ++i) { |
| 1318 expected_icons.push_back(i); | 1318 expected_icons.push_back(i); |
| 1319 TestFaviconData test_data = BuildFaviconData(i); | 1319 TestFaviconData test_data = BuildFaviconData(i); |
| 1320 cache()->OnFaviconVisited(test_data.page_url, test_data.icon_url); | 1320 cache()->OnFaviconVisited(test_data.page_url, test_data.icon_url); |
| 1321 } | 1321 } |
| 1322 | 1322 |
| 1323 EXPECT_EQ((unsigned long)kFaviconBatchSize, GetTaskCount()); | 1323 EXPECT_EQ(static_cast<size_t>(kFaviconBatchSize), GetTaskCount()); |
| 1324 | 1324 |
| 1325 for (int i = 0; i < kFaviconBatchSize; ++i) { | 1325 for (int i = 0; i < kFaviconBatchSize; ++i) { |
| 1326 TestFaviconData test_data = BuildFaviconData(i); | 1326 TestFaviconData test_data = BuildFaviconData(i); |
| 1327 OnCustomFaviconDataAvailable(test_data); | 1327 OnCustomFaviconDataAvailable(test_data); |
| 1328 | 1328 |
| 1329 syncer::SyncChangeList changes = processor()->GetAndResetChangeList(); | 1329 syncer::SyncChangeList changes = processor()->GetAndResetChangeList(); |
| 1330 ASSERT_EQ(2U, changes.size()); | 1330 ASSERT_EQ(2U, changes.size()); |
| 1331 EXPECT_EQ(syncer::SyncChange::ACTION_ADD, changes[0].change_type()); | 1331 EXPECT_EQ(syncer::SyncChange::ACTION_ADD, changes[0].change_type()); |
| 1332 EXPECT_EQ(syncer::FAVICON_IMAGES, changes[0].sync_data().GetDataType()); | 1332 EXPECT_EQ(syncer::FAVICON_IMAGES, changes[0].sync_data().GetDataType()); |
| 1333 EXPECT_TRUE( | 1333 EXPECT_TRUE( |
| 1334 CompareFaviconDataToSpecifics(test_data, | 1334 CompareFaviconDataToSpecifics(test_data, |
| 1335 changes[0].sync_data().GetSpecifics())); | 1335 changes[0].sync_data().GetSpecifics())); |
| 1336 EXPECT_EQ(syncer::FAVICON_TRACKING, changes[1].sync_data().GetDataType()); | 1336 EXPECT_EQ(syncer::FAVICON_TRACKING, changes[1].sync_data().GetDataType()); |
| 1337 // Just verify the favicon url for the tracking specifics and that the | 1337 // Just verify the favicon url for the tracking specifics and that the |
| 1338 // timestamp is non-null. | 1338 // timestamp is non-null. |
| 1339 EXPECT_EQ(syncer::SyncChange::ACTION_ADD, changes[1].change_type()); | 1339 EXPECT_EQ(syncer::SyncChange::ACTION_ADD, changes[1].change_type()); |
| 1340 EXPECT_EQ(test_data.icon_url.spec(), | 1340 EXPECT_EQ(test_data.icon_url.spec(), |
| 1341 changes[1].sync_data().GetSpecifics().favicon_tracking(). | 1341 changes[1].sync_data().GetSpecifics().favicon_tracking(). |
| 1342 favicon_url()); | 1342 favicon_url()); |
| 1343 EXPECT_NE(changes[1].sync_data().GetSpecifics().favicon_tracking(). | 1343 EXPECT_NE(changes[1].sync_data().GetSpecifics().favicon_tracking(). |
| 1344 last_visit_time_ms(), 0); | 1344 last_visit_time_ms(), 0); |
| 1345 } | 1345 } |
| 1346 | 1346 |
| 1347 EXPECT_EQ(0U, GetTaskCount()); | 1347 EXPECT_EQ(0U, GetTaskCount()); |
| 1348 EXPECT_EQ((unsigned long)kFaviconBatchSize, GetFaviconCount()); | 1348 EXPECT_EQ(static_cast<size_t>(kFaviconBatchSize), GetFaviconCount()); |
| 1349 } | 1349 } |
| 1350 | 1350 |
| 1351 // Test that visiting a known page does not trigger a favicon load and just | 1351 // Test that visiting a known page does not trigger a favicon load and just |
| 1352 // updates the sync tracking info. | 1352 // updates the sync tracking info. |
| 1353 TEST_F(SyncFaviconCacheTest, UpdateOnFaviconVisited) { | 1353 TEST_F(SyncFaviconCacheTest, UpdateOnFaviconVisited) { |
| 1354 EXPECT_EQ(0U, GetFaviconCount()); | 1354 EXPECT_EQ(0U, GetFaviconCount()); |
| 1355 SetUpInitialSync(syncer::SyncDataList(), syncer::SyncDataList()); | 1355 SetUpInitialSync(syncer::SyncDataList(), syncer::SyncDataList()); |
| 1356 std::vector<int> expected_icons; | 1356 std::vector<int> expected_icons; |
| 1357 | 1357 |
| 1358 // Add the favicons. | 1358 // Add the favicons. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1375 // Just verify the favicon url for the tracking specifics and that the | 1375 // Just verify the favicon url for the tracking specifics and that the |
| 1376 // timestamp is non-null. | 1376 // timestamp is non-null. |
| 1377 EXPECT_EQ(syncer::SyncChange::ACTION_UPDATE, changes[0].change_type()); | 1377 EXPECT_EQ(syncer::SyncChange::ACTION_UPDATE, changes[0].change_type()); |
| 1378 EXPECT_EQ(test_data.icon_url.spec(), | 1378 EXPECT_EQ(test_data.icon_url.spec(), |
| 1379 changes[0].sync_data().GetSpecifics().favicon_tracking(). | 1379 changes[0].sync_data().GetSpecifics().favicon_tracking(). |
| 1380 favicon_url()); | 1380 favicon_url()); |
| 1381 EXPECT_NE(changes[0].sync_data().GetSpecifics().favicon_tracking(). | 1381 EXPECT_NE(changes[0].sync_data().GetSpecifics().favicon_tracking(). |
| 1382 last_visit_time_ms(), 0); | 1382 last_visit_time_ms(), 0); |
| 1383 } | 1383 } |
| 1384 EXPECT_EQ(0U, GetTaskCount()); | 1384 EXPECT_EQ(0U, GetTaskCount()); |
| 1385 EXPECT_EQ((unsigned long)kFaviconBatchSize, GetFaviconCount()); | 1385 EXPECT_EQ(static_cast<size_t>(kFaviconBatchSize), GetFaviconCount()); |
| 1386 } | 1386 } |
| 1387 | 1387 |
| 1388 // Ensure we properly expire old synced favicons as new ones are updated. | 1388 // Ensure we properly expire old synced favicons as new ones are updated. |
| 1389 TEST_F(SyncFaviconCacheTest, ExpireOnFaviconVisited) { | 1389 TEST_F(SyncFaviconCacheTest, ExpireOnFaviconVisited) { |
| 1390 EXPECT_EQ(0U, GetFaviconCount()); | 1390 EXPECT_EQ(0U, GetFaviconCount()); |
| 1391 SetUpInitialSync(syncer::SyncDataList(), syncer::SyncDataList()); | 1391 SetUpInitialSync(syncer::SyncDataList(), syncer::SyncDataList()); |
| 1392 std::vector<int> expected_icons; | 1392 std::vector<int> expected_icons; |
| 1393 | 1393 |
| 1394 // Add the initial favicons. | 1394 // Add the initial favicons. |
| 1395 for (int i = 0; i < kMaxSyncFavicons; ++i) { | 1395 for (int i = 0; i < kMaxSyncFavicons; ++i) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1423 changes[2].sync_data().GetSpecifics().favicon_tracking(). | 1423 changes[2].sync_data().GetSpecifics().favicon_tracking(). |
| 1424 favicon_url()); | 1424 favicon_url()); |
| 1425 EXPECT_NE(changes[2].sync_data().GetSpecifics().favicon_tracking(). | 1425 EXPECT_NE(changes[2].sync_data().GetSpecifics().favicon_tracking(). |
| 1426 last_visit_time_ms(), 0); | 1426 last_visit_time_ms(), 0); |
| 1427 EXPECT_EQ(syncer::SyncChange::ACTION_DELETE, changes[3].change_type()); | 1427 EXPECT_EQ(syncer::SyncChange::ACTION_DELETE, changes[3].change_type()); |
| 1428 EXPECT_EQ(old_favicon.icon_url.spec(), | 1428 EXPECT_EQ(old_favicon.icon_url.spec(), |
| 1429 syncer::SyncDataLocal(changes[3].sync_data()).GetTag()); | 1429 syncer::SyncDataLocal(changes[3].sync_data()).GetTag()); |
| 1430 } | 1430 } |
| 1431 | 1431 |
| 1432 EXPECT_EQ(0U, GetTaskCount()); | 1432 EXPECT_EQ(0U, GetTaskCount()); |
| 1433 EXPECT_EQ((unsigned long)kMaxSyncFavicons, GetFaviconCount()); | 1433 EXPECT_EQ(static_cast<size_t>(kMaxSyncFavicons), GetFaviconCount()); |
| 1434 } | 1434 } |
| 1435 | 1435 |
| 1436 // A full history clear notification should result in all synced favicons being | 1436 // A full history clear notification should result in all synced favicons being |
| 1437 // deleted. | 1437 // deleted. |
| 1438 TEST_F(SyncFaviconCacheTest, HistoryFullClear) { | 1438 TEST_F(SyncFaviconCacheTest, HistoryFullClear) { |
| 1439 syncer::SyncDataList initial_image_data, initial_tracking_data; | 1439 syncer::SyncDataList initial_image_data, initial_tracking_data; |
| 1440 std::vector<int> expected_icons; | 1440 std::vector<int> expected_icons; |
| 1441 std::vector<syncer::SyncChange::SyncChangeType> expected_deletions; | 1441 std::vector<syncer::SyncChange::SyncChangeType> expected_deletions; |
| 1442 for (int i = 0; i < kFaviconBatchSize; ++i) { | 1442 for (int i = 0; i < kFaviconBatchSize; ++i) { |
| 1443 expected_icons.push_back(i); | 1443 expected_icons.push_back(i); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1459 tracking_specifics, | 1459 tracking_specifics, |
| 1460 base::Time(), | 1460 base::Time(), |
| 1461 syncer::AttachmentIdList(), | 1461 syncer::AttachmentIdList(), |
| 1462 syncer::AttachmentServiceProxyForTest::Create())); | 1462 syncer::AttachmentServiceProxyForTest::Create())); |
| 1463 } | 1463 } |
| 1464 | 1464 |
| 1465 SetUpInitialSync(initial_image_data, initial_tracking_data); | 1465 SetUpInitialSync(initial_image_data, initial_tracking_data); |
| 1466 syncer::SyncChangeList changes = processor()->GetAndResetChangeList(); | 1466 syncer::SyncChangeList changes = processor()->GetAndResetChangeList(); |
| 1467 EXPECT_TRUE(changes.empty()); | 1467 EXPECT_TRUE(changes.empty()); |
| 1468 | 1468 |
| 1469 EXPECT_EQ((unsigned long)kFaviconBatchSize, GetFaviconCount()); | 1469 EXPECT_EQ(static_cast<size_t>(kFaviconBatchSize), GetFaviconCount()); |
| 1470 cache()->OnURLsDeleted(nullptr, true, false, history::URLRows(), | 1470 cache()->OnURLsDeleted(nullptr, true, false, history::URLRows(), |
| 1471 std::set<GURL>()); | 1471 std::set<GURL>()); |
| 1472 EXPECT_EQ(0U, GetFaviconCount()); | 1472 EXPECT_EQ(0U, GetFaviconCount()); |
| 1473 changes = processor()->GetAndResetChangeList(); | 1473 changes = processor()->GetAndResetChangeList(); |
| 1474 ASSERT_EQ(changes.size(), (unsigned long)kFaviconBatchSize*2); | 1474 ASSERT_EQ(changes.size(), static_cast<size_t>(kFaviconBatchSize)*2); |
| 1475 syncer::SyncChangeList changes_1, changes_2; | 1475 syncer::SyncChangeList changes_1, changes_2; |
| 1476 for (int i = 0; i < kFaviconBatchSize; ++i) { | 1476 for (int i = 0; i < kFaviconBatchSize; ++i) { |
| 1477 changes_1.push_back(changes[i]); | 1477 changes_1.push_back(changes[i]); |
| 1478 changes_2.push_back(changes[i + kFaviconBatchSize]); | 1478 changes_2.push_back(changes[i + kFaviconBatchSize]); |
| 1479 } | 1479 } |
| 1480 VerifyChanges(syncer::FAVICON_IMAGES, | 1480 VerifyChanges(syncer::FAVICON_IMAGES, |
| 1481 expected_deletions, | 1481 expected_deletions, |
| 1482 expected_icons, | 1482 expected_icons, |
| 1483 changes_1); | 1483 changes_1); |
| 1484 VerifyChanges(syncer::FAVICON_TRACKING, | 1484 VerifyChanges(syncer::FAVICON_TRACKING, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1517 tracking_specifics, | 1517 tracking_specifics, |
| 1518 base::Time(), | 1518 base::Time(), |
| 1519 syncer::AttachmentIdList(), | 1519 syncer::AttachmentIdList(), |
| 1520 syncer::AttachmentServiceProxyForTest::Create())); | 1520 syncer::AttachmentServiceProxyForTest::Create())); |
| 1521 } | 1521 } |
| 1522 | 1522 |
| 1523 SetUpInitialSync(initial_image_data, initial_tracking_data); | 1523 SetUpInitialSync(initial_image_data, initial_tracking_data); |
| 1524 syncer::SyncChangeList changes = processor()->GetAndResetChangeList(); | 1524 syncer::SyncChangeList changes = processor()->GetAndResetChangeList(); |
| 1525 EXPECT_TRUE(changes.empty()); | 1525 EXPECT_TRUE(changes.empty()); |
| 1526 | 1526 |
| 1527 EXPECT_EQ((unsigned long)kFaviconBatchSize, GetFaviconCount()); | 1527 EXPECT_EQ(static_cast<size_t>(kFaviconBatchSize), GetFaviconCount()); |
| 1528 cache()->OnURLsDeleted(nullptr, false, false, history::URLRows(), | 1528 cache()->OnURLsDeleted(nullptr, false, false, history::URLRows(), |
| 1529 favicon_urls_to_delete); | 1529 favicon_urls_to_delete); |
| 1530 EXPECT_EQ((unsigned long)kFaviconBatchSize/2, GetFaviconCount()); | 1530 EXPECT_EQ(static_cast<size_t>(kFaviconBatchSize)/2, GetFaviconCount()); |
| 1531 changes = processor()->GetAndResetChangeList(); | 1531 changes = processor()->GetAndResetChangeList(); |
| 1532 ASSERT_EQ(changes.size(), (unsigned long)kFaviconBatchSize); | 1532 ASSERT_EQ(changes.size(), static_cast<size_t>(kFaviconBatchSize)); |
| 1533 syncer::SyncChangeList changes_1, changes_2; | 1533 syncer::SyncChangeList changes_1, changes_2; |
| 1534 for (size_t i = 0; i < kFaviconBatchSize/2; ++i) { | 1534 for (size_t i = 0; i < kFaviconBatchSize/2; ++i) { |
| 1535 changes_1.push_back(changes[i]); | 1535 changes_1.push_back(changes[i]); |
| 1536 changes_2.push_back(changes[i + kFaviconBatchSize/2]); | 1536 changes_2.push_back(changes[i + kFaviconBatchSize/2]); |
| 1537 } | 1537 } |
| 1538 VerifyChanges(syncer::FAVICON_IMAGES, | 1538 VerifyChanges(syncer::FAVICON_IMAGES, |
| 1539 expected_deletions, | 1539 expected_deletions, |
| 1540 expected_icons, | 1540 expected_icons, |
| 1541 changes_1); | 1541 changes_1); |
| 1542 VerifyChanges(syncer::FAVICON_TRACKING, | 1542 VerifyChanges(syncer::FAVICON_TRACKING, |
| 1543 expected_deletions, | 1543 expected_deletions, |
| 1544 expected_icons, | 1544 expected_icons, |
| 1545 changes_2); | 1545 changes_2); |
| 1546 } | 1546 } |
| 1547 | 1547 |
| 1548 // Any favicon urls with the "data" scheme should be ignored. | 1548 // Any favicon urls with the "data" scheme should be ignored. |
| 1549 TEST_F(SyncFaviconCacheTest, IgnoreDataScheme) { | 1549 TEST_F(SyncFaviconCacheTest, IgnoreDataScheme) { |
| 1550 EXPECT_EQ(0U, GetFaviconCount()); | 1550 EXPECT_EQ(0U, GetFaviconCount()); |
| 1551 SetUpInitialSync(syncer::SyncDataList(), syncer::SyncDataList()); | 1551 SetUpInitialSync(syncer::SyncDataList(), syncer::SyncDataList()); |
| 1552 std::vector<int> expected_icons; | 1552 std::vector<int> expected_icons; |
| 1553 | 1553 |
| 1554 for (int i = 0; i < kFaviconBatchSize; ++i) { | 1554 for (int i = 0; i < kFaviconBatchSize; ++i) { |
| 1555 TestFaviconData test_data = BuildFaviconData(i); | 1555 TestFaviconData test_data = BuildFaviconData(i); |
| 1556 cache()->OnFaviconVisited(test_data.page_url, GURL()); | 1556 cache()->OnFaviconVisited(test_data.page_url, GURL()); |
| 1557 } | 1557 } |
| 1558 | 1558 |
| 1559 EXPECT_EQ((unsigned long)kFaviconBatchSize, GetTaskCount()); | 1559 EXPECT_EQ(static_cast<size_t>(kFaviconBatchSize), GetTaskCount()); |
| 1560 | 1560 |
| 1561 for (int i = 0; i < kFaviconBatchSize; ++i) { | 1561 for (int i = 0; i < kFaviconBatchSize; ++i) { |
| 1562 TestFaviconData test_data = BuildFaviconData(i); | 1562 TestFaviconData test_data = BuildFaviconData(i); |
| 1563 test_data.icon_url = GURL("data:image/png;base64;blabla"); | 1563 test_data.icon_url = GURL("data:image/png;base64;blabla"); |
| 1564 EXPECT_TRUE(test_data.icon_url.is_valid()); | 1564 EXPECT_TRUE(test_data.icon_url.is_valid()); |
| 1565 OnCustomFaviconDataAvailable(test_data); | 1565 OnCustomFaviconDataAvailable(test_data); |
| 1566 } | 1566 } |
| 1567 | 1567 |
| 1568 EXPECT_EQ(0U, GetTaskCount()); | 1568 EXPECT_EQ(0U, GetTaskCount()); |
| 1569 EXPECT_EQ(0U, GetFaviconCount()); | 1569 EXPECT_EQ(0U, GetFaviconCount()); |
| 1570 syncer::SyncChangeList changes = processor()->GetAndResetChangeList(); | 1570 syncer::SyncChangeList changes = processor()->GetAndResetChangeList(); |
| 1571 EXPECT_TRUE(changes.empty()); | 1571 EXPECT_TRUE(changes.empty()); |
| 1572 } | 1572 } |
| 1573 | 1573 |
| 1574 // When visiting a page we've already loaded the favicon for, don't attempt to | 1574 // When visiting a page we've already loaded the favicon for, don't attempt to |
| 1575 // reload the favicon, just update the visit time using the cached icon url. | 1575 // reload the favicon, just update the visit time using the cached icon url. |
| 1576 TEST_F(SyncFaviconCacheTest, ReuseCachedIconUrl) { | 1576 TEST_F(SyncFaviconCacheTest, ReuseCachedIconUrl) { |
| 1577 EXPECT_EQ(0U, GetFaviconCount()); | 1577 EXPECT_EQ(0U, GetFaviconCount()); |
| 1578 SetUpInitialSync(syncer::SyncDataList(), syncer::SyncDataList()); | 1578 SetUpInitialSync(syncer::SyncDataList(), syncer::SyncDataList()); |
| 1579 std::vector<int> expected_icons; | 1579 std::vector<int> expected_icons; |
| 1580 | 1580 |
| 1581 for (int i = 0; i < kFaviconBatchSize; ++i) { | 1581 for (int i = 0; i < kFaviconBatchSize; ++i) { |
| 1582 expected_icons.push_back(i); | 1582 expected_icons.push_back(i); |
| 1583 TestFaviconData test_data = BuildFaviconData(i); | 1583 TestFaviconData test_data = BuildFaviconData(i); |
| 1584 cache()->OnFaviconVisited(test_data.page_url, test_data.icon_url); | 1584 cache()->OnFaviconVisited(test_data.page_url, test_data.icon_url); |
| 1585 } | 1585 } |
| 1586 | 1586 |
| 1587 EXPECT_EQ((unsigned long)kFaviconBatchSize, GetTaskCount()); | 1587 EXPECT_EQ(static_cast<size_t>(kFaviconBatchSize), GetTaskCount()); |
| 1588 | 1588 |
| 1589 for (int i = 0; i < kFaviconBatchSize; ++i) { | 1589 for (int i = 0; i < kFaviconBatchSize; ++i) { |
| 1590 TestFaviconData test_data = BuildFaviconData(i); | 1590 TestFaviconData test_data = BuildFaviconData(i); |
| 1591 OnCustomFaviconDataAvailable(test_data); | 1591 OnCustomFaviconDataAvailable(test_data); |
| 1592 } | 1592 } |
| 1593 processor()->GetAndResetChangeList(); | 1593 processor()->GetAndResetChangeList(); |
| 1594 EXPECT_EQ(0U, GetTaskCount()); | 1594 EXPECT_EQ(0U, GetTaskCount()); |
| 1595 EXPECT_EQ((unsigned long)kFaviconBatchSize, GetFaviconCount()); | 1595 EXPECT_EQ(static_cast<size_t>(kFaviconBatchSize), GetFaviconCount()); |
| 1596 | 1596 |
| 1597 for (int i = 0; i < kFaviconBatchSize; ++i) { | 1597 for (int i = 0; i < kFaviconBatchSize; ++i) { |
| 1598 TestFaviconData test_data = BuildFaviconData(i); | 1598 TestFaviconData test_data = BuildFaviconData(i); |
| 1599 cache()->OnFaviconVisited(test_data.page_url, test_data.icon_url); | 1599 cache()->OnFaviconVisited(test_data.page_url, test_data.icon_url); |
| 1600 syncer::SyncChangeList changes = processor()->GetAndResetChangeList(); | 1600 syncer::SyncChangeList changes = processor()->GetAndResetChangeList(); |
| 1601 ASSERT_EQ(1U, changes.size()); | 1601 ASSERT_EQ(1U, changes.size()); |
| 1602 // Just verify the favicon url for the tracking specifics and that the | 1602 // Just verify the favicon url for the tracking specifics and that the |
| 1603 // timestamp is non-null. | 1603 // timestamp is non-null. |
| 1604 EXPECT_EQ(syncer::SyncChange::ACTION_UPDATE, changes[0].change_type()); | 1604 EXPECT_EQ(syncer::SyncChange::ACTION_UPDATE, changes[0].change_type()); |
| 1605 EXPECT_EQ(test_data.icon_url.spec(), | 1605 EXPECT_EQ(test_data.icon_url.spec(), |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1648 tracking_specifics, | 1648 tracking_specifics, |
| 1649 base::Time(), | 1649 base::Time(), |
| 1650 syncer::AttachmentIdList(), | 1650 syncer::AttachmentIdList(), |
| 1651 syncer::AttachmentServiceProxyForTest::Create()))); | 1651 syncer::AttachmentServiceProxyForTest::Create()))); |
| 1652 } | 1652 } |
| 1653 } | 1653 } |
| 1654 | 1654 |
| 1655 cache()->ProcessSyncChanges(FROM_HERE, initial_image_changes); | 1655 cache()->ProcessSyncChanges(FROM_HERE, initial_image_changes); |
| 1656 cache()->ProcessSyncChanges(FROM_HERE, initial_tracking_changes); | 1656 cache()->ProcessSyncChanges(FROM_HERE, initial_tracking_changes); |
| 1657 EXPECT_EQ(0U, processor()->GetAndResetChangeList().size()); | 1657 EXPECT_EQ(0U, processor()->GetAndResetChangeList().size()); |
| 1658 EXPECT_EQ((unsigned long)kFaviconBatchSize, GetFaviconCount()); | 1658 EXPECT_EQ(static_cast<size_t>(kFaviconBatchSize), GetFaviconCount()); |
| 1659 | 1659 |
| 1660 for (int i = 0; i < kFaviconBatchSize/2; ++i) { | 1660 for (int i = 0; i < kFaviconBatchSize/2; ++i) { |
| 1661 TestFaviconData test_data = BuildFaviconData(i); | 1661 TestFaviconData test_data = BuildFaviconData(i); |
| 1662 cache()->OnFaviconVisited(test_data.page_url, GURL()); | 1662 cache()->OnFaviconVisited(test_data.page_url, GURL()); |
| 1663 EXPECT_EQ(1U, GetTaskCount()); | 1663 EXPECT_EQ(1U, GetTaskCount()); |
| 1664 OnCustomFaviconDataAvailable(test_data); | 1664 OnCustomFaviconDataAvailable(test_data); |
| 1665 syncer::SyncChangeList changes = processor()->GetAndResetChangeList(); | 1665 syncer::SyncChangeList changes = processor()->GetAndResetChangeList(); |
| 1666 | 1666 |
| 1667 // Even favicons had image data, so should now receive new tracking data | 1667 // Even favicons had image data, so should now receive new tracking data |
| 1668 // and updated image data (we allow one update after the initial add). | 1668 // and updated image data (we allow one update after the initial add). |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1689 EXPECT_EQ(syncer::SyncChange::ACTION_UPDATE, changes[1].change_type()); | 1689 EXPECT_EQ(syncer::SyncChange::ACTION_UPDATE, changes[1].change_type()); |
| 1690 EXPECT_EQ(test_data.icon_url.spec(), | 1690 EXPECT_EQ(test_data.icon_url.spec(), |
| 1691 changes[1].sync_data().GetSpecifics().favicon_tracking(). | 1691 changes[1].sync_data().GetSpecifics().favicon_tracking(). |
| 1692 favicon_url()); | 1692 favicon_url()); |
| 1693 EXPECT_NE(changes[1].sync_data().GetSpecifics().favicon_tracking(). | 1693 EXPECT_NE(changes[1].sync_data().GetSpecifics().favicon_tracking(). |
| 1694 last_visit_time_ms(), 0); | 1694 last_visit_time_ms(), 0); |
| 1695 } | 1695 } |
| 1696 } | 1696 } |
| 1697 | 1697 |
| 1698 EXPECT_EQ(0U, GetTaskCount()); | 1698 EXPECT_EQ(0U, GetTaskCount()); |
| 1699 EXPECT_EQ((unsigned long)kFaviconBatchSize, GetFaviconCount()); | 1699 EXPECT_EQ(static_cast<size_t>(kFaviconBatchSize), GetFaviconCount()); |
| 1700 } | 1700 } |
| 1701 | 1701 |
| 1702 // Verify that orphaned favicon images don't result in creating invalid | 1702 // Verify that orphaned favicon images don't result in creating invalid |
| 1703 // favicon tracking data. | 1703 // favicon tracking data. |
| 1704 TEST_F(SyncFaviconCacheTest, PartialAssociationInfo) { | 1704 TEST_F(SyncFaviconCacheTest, PartialAssociationInfo) { |
| 1705 syncer::SyncDataList initial_image_data, initial_tracking_data; | 1705 syncer::SyncDataList initial_image_data, initial_tracking_data; |
| 1706 for (int i = 0; i < kFaviconBatchSize; ++i) { | 1706 for (int i = 0; i < kFaviconBatchSize; ++i) { |
| 1707 sync_pb::EntitySpecifics image_specifics; | 1707 sync_pb::EntitySpecifics image_specifics; |
| 1708 FillImageSpecifics(BuildFaviconData(i), | 1708 FillImageSpecifics(BuildFaviconData(i), |
| 1709 image_specifics.mutable_favicon_image()); | 1709 image_specifics.mutable_favicon_image()); |
| 1710 initial_image_data.push_back(syncer::SyncData::CreateRemoteData( | 1710 initial_image_data.push_back(syncer::SyncData::CreateRemoteData( |
| 1711 1, | 1711 1, |
| 1712 image_specifics, | 1712 image_specifics, |
| 1713 base::Time(), | 1713 base::Time(), |
| 1714 syncer::AttachmentIdList(), | 1714 syncer::AttachmentIdList(), |
| 1715 syncer::AttachmentServiceProxyForTest::Create())); | 1715 syncer::AttachmentServiceProxyForTest::Create())); |
| 1716 image_specifics.mutable_favicon_image()->clear_favicon_web(); | 1716 image_specifics.mutable_favicon_image()->clear_favicon_web(); |
| 1717 } | 1717 } |
| 1718 | 1718 |
| 1719 SetUpInitialSync(initial_image_data, initial_tracking_data); | 1719 SetUpInitialSync(initial_image_data, initial_tracking_data); |
| 1720 syncer::SyncChangeList change_list = processor()->GetAndResetChangeList(); | 1720 syncer::SyncChangeList change_list = processor()->GetAndResetChangeList(); |
| 1721 EXPECT_TRUE(change_list.empty()); | 1721 EXPECT_TRUE(change_list.empty()); |
| 1722 EXPECT_EQ((unsigned long)kFaviconBatchSize, GetFaviconCount()); | 1722 EXPECT_EQ(static_cast<size_t>(kFaviconBatchSize), GetFaviconCount()); |
| 1723 } | 1723 } |
| 1724 | 1724 |
| 1725 // Tests that we don't choke if a favicon visit node with a null visit time is | 1725 // Tests that we don't choke if a favicon visit node with a null visit time is |
| 1726 // present (see crbug.com/258196) and an update is made. | 1726 // present (see crbug.com/258196) and an update is made. |
| 1727 TEST_F(SyncFaviconCacheTest, NullFaviconVisitTime) { | 1727 TEST_F(SyncFaviconCacheTest, NullFaviconVisitTime) { |
| 1728 EXPECT_EQ(0U, GetFaviconCount()); | 1728 EXPECT_EQ(0U, GetFaviconCount()); |
| 1729 | 1729 |
| 1730 syncer::SyncDataList initial_image_data, initial_tracking_data; | 1730 syncer::SyncDataList initial_image_data, initial_tracking_data; |
| 1731 std::vector<int> expected_icons; | 1731 std::vector<int> expected_icons; |
| 1732 for (int i = 0; i < kFaviconBatchSize; ++i) { | 1732 for (int i = 0; i < kFaviconBatchSize; ++i) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1754 | 1754 |
| 1755 cache()->MergeDataAndStartSyncing(syncer::FAVICON_IMAGES, | 1755 cache()->MergeDataAndStartSyncing(syncer::FAVICON_IMAGES, |
| 1756 initial_image_data, | 1756 initial_image_data, |
| 1757 CreateAndPassProcessor(), | 1757 CreateAndPassProcessor(), |
| 1758 CreateAndPassSyncErrorFactory()); | 1758 CreateAndPassSyncErrorFactory()); |
| 1759 ASSERT_EQ(0U, processor()->GetAndResetChangeList().size()); | 1759 ASSERT_EQ(0U, processor()->GetAndResetChangeList().size()); |
| 1760 cache()->MergeDataAndStartSyncing(syncer::FAVICON_TRACKING, | 1760 cache()->MergeDataAndStartSyncing(syncer::FAVICON_TRACKING, |
| 1761 initial_tracking_data, | 1761 initial_tracking_data, |
| 1762 CreateAndPassProcessor(), | 1762 CreateAndPassProcessor(), |
| 1763 CreateAndPassSyncErrorFactory()); | 1763 CreateAndPassSyncErrorFactory()); |
| 1764 ASSERT_EQ((unsigned long)kFaviconBatchSize, | 1764 ASSERT_EQ(static_cast<size_t>(kFaviconBatchSize), |
| 1765 processor()->GetAndResetChangeList().size()); | 1765 processor()->GetAndResetChangeList().size()); |
| 1766 EXPECT_EQ((unsigned long)kFaviconBatchSize, GetFaviconCount()); | 1766 EXPECT_EQ(static_cast<size_t>(kFaviconBatchSize), GetFaviconCount()); |
| 1767 | 1767 |
| 1768 // Visit the favicons again. | 1768 // Visit the favicons again. |
| 1769 EXPECT_EQ(0U, GetTaskCount()); | 1769 EXPECT_EQ(0U, GetTaskCount()); |
| 1770 for (int i = 0; i < kFaviconBatchSize; ++i) { | 1770 for (int i = 0; i < kFaviconBatchSize; ++i) { |
| 1771 TestFaviconData test_data = BuildFaviconData(i); | 1771 TestFaviconData test_data = BuildFaviconData(i); |
| 1772 cache()->OnFaviconVisited(test_data.page_url, test_data.icon_url); | 1772 cache()->OnFaviconVisited(test_data.page_url, test_data.icon_url); |
| 1773 | 1773 |
| 1774 syncer::SyncChangeList changes = processor()->GetAndResetChangeList(); | 1774 syncer::SyncChangeList changes = processor()->GetAndResetChangeList(); |
| 1775 ASSERT_EQ(1U, changes.size()); | 1775 ASSERT_EQ(1U, changes.size()); |
| 1776 // Just verify the favicon url for the tracking specifics and that the | 1776 // Just verify the favicon url for the tracking specifics and that the |
| 1777 // timestamp is non-null. | 1777 // timestamp is non-null. |
| 1778 EXPECT_EQ(syncer::SyncChange::ACTION_UPDATE, changes[0].change_type()); | 1778 EXPECT_EQ(syncer::SyncChange::ACTION_UPDATE, changes[0].change_type()); |
| 1779 EXPECT_EQ(test_data.icon_url.spec(), | 1779 EXPECT_EQ(test_data.icon_url.spec(), |
| 1780 changes[0].sync_data().GetSpecifics().favicon_tracking(). | 1780 changes[0].sync_data().GetSpecifics().favicon_tracking(). |
| 1781 favicon_url()); | 1781 favicon_url()); |
| 1782 EXPECT_NE(changes[0].sync_data().GetSpecifics().favicon_tracking(). | 1782 EXPECT_NE(changes[0].sync_data().GetSpecifics().favicon_tracking(). |
| 1783 last_visit_time_ms(), 0); | 1783 last_visit_time_ms(), 0); |
| 1784 } | 1784 } |
| 1785 EXPECT_EQ(0U, GetTaskCount()); | 1785 EXPECT_EQ(0U, GetTaskCount()); |
| 1786 EXPECT_EQ((unsigned long)kFaviconBatchSize, GetFaviconCount()); | 1786 EXPECT_EQ(static_cast<size_t>(kFaviconBatchSize), GetFaviconCount()); |
| 1787 } | 1787 } |
| 1788 | 1788 |
| 1789 // If another synced client has a clock skewed towards the future, it's possible | 1789 // If another synced client has a clock skewed towards the future, it's possible |
| 1790 // that favicons added locally will be expired as they are added. Ensure this | 1790 // that favicons added locally will be expired as they are added. Ensure this |
| 1791 // doesn't crash (see crbug.com/306150). | 1791 // doesn't crash (see crbug.com/306150). |
| 1792 TEST_F(SyncFaviconCacheTest, VisitFaviconClockSkew) { | 1792 TEST_F(SyncFaviconCacheTest, VisitFaviconClockSkew) { |
| 1793 EXPECT_EQ(0U, GetFaviconCount()); | 1793 EXPECT_EQ(0U, GetFaviconCount()); |
| 1794 const int kClockSkew = 20; // 20 minutes in the future. | 1794 const int kClockSkew = 20; // 20 minutes in the future. |
| 1795 | 1795 |
| 1796 // Set up sync with kMaxSyncFavicons starting kClockSkew minutes in the | 1796 // Set up sync with kMaxSyncFavicons starting kClockSkew minutes in the |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1836 ASSERT_EQ(changes[0].change_type(), syncer::SyncChange::ACTION_ADD); | 1836 ASSERT_EQ(changes[0].change_type(), syncer::SyncChange::ACTION_ADD); |
| 1837 ASSERT_EQ(changes[0].sync_data().GetDataType(), syncer::FAVICON_IMAGES); | 1837 ASSERT_EQ(changes[0].sync_data().GetDataType(), syncer::FAVICON_IMAGES); |
| 1838 ASSERT_EQ(changes[1].change_type(), syncer::SyncChange::ACTION_DELETE); | 1838 ASSERT_EQ(changes[1].change_type(), syncer::SyncChange::ACTION_DELETE); |
| 1839 ASSERT_EQ(changes[1].sync_data().GetDataType(), syncer::FAVICON_IMAGES); | 1839 ASSERT_EQ(changes[1].sync_data().GetDataType(), syncer::FAVICON_IMAGES); |
| 1840 ASSERT_EQ(changes[2].change_type(), syncer::SyncChange::ACTION_ADD); | 1840 ASSERT_EQ(changes[2].change_type(), syncer::SyncChange::ACTION_ADD); |
| 1841 ASSERT_EQ(changes[2].sync_data().GetDataType(), syncer::FAVICON_TRACKING); | 1841 ASSERT_EQ(changes[2].sync_data().GetDataType(), syncer::FAVICON_TRACKING); |
| 1842 ASSERT_EQ(changes[3].change_type(), syncer::SyncChange::ACTION_DELETE); | 1842 ASSERT_EQ(changes[3].change_type(), syncer::SyncChange::ACTION_DELETE); |
| 1843 ASSERT_EQ(changes[3].sync_data().GetDataType(), syncer::FAVICON_TRACKING); | 1843 ASSERT_EQ(changes[3].sync_data().GetDataType(), syncer::FAVICON_TRACKING); |
| 1844 } | 1844 } |
| 1845 EXPECT_EQ(0U, GetTaskCount()); | 1845 EXPECT_EQ(0U, GetTaskCount()); |
| 1846 EXPECT_EQ((unsigned long)kMaxSyncFavicons, GetFaviconCount()); | 1846 EXPECT_EQ(static_cast<size_t>(kMaxSyncFavicons), GetFaviconCount()); |
| 1847 } | 1847 } |
| 1848 | 1848 |
| 1849 // Simulate a case where the set of tracking info and image info doesn't match, | 1849 // Simulate a case where the set of tracking info and image info doesn't match, |
| 1850 // and there is more tracking info than the max. A local update should correctly | 1850 // and there is more tracking info than the max. A local update should correctly |
| 1851 // determine whether to update/add an image/tracking entity. | 1851 // determine whether to update/add an image/tracking entity. |
| 1852 TEST_F(SyncFaviconCacheTest, MixedThreshold) { | 1852 TEST_F(SyncFaviconCacheTest, MixedThreshold) { |
| 1853 // First go through and add local favicons. | 1853 // First go through and add local favicons. |
| 1854 for (int i = kMaxSyncFavicons; i < kMaxSyncFavicons + 5; ++i) { | 1854 for (int i = kMaxSyncFavicons; i < kMaxSyncFavicons + 5; ++i) { |
| 1855 TestFaviconData favicon = BuildFaviconData(i); | 1855 TestFaviconData favicon = BuildFaviconData(i); |
| 1856 TriggerSyncFaviconReceived(favicon.page_url, | 1856 TriggerSyncFaviconReceived(favicon.page_url, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1884 syncer::AttachmentIdList(), | 1884 syncer::AttachmentIdList(), |
| 1885 syncer::AttachmentServiceProxyForTest::Create())); | 1885 syncer::AttachmentServiceProxyForTest::Create())); |
| 1886 } | 1886 } |
| 1887 SetUpInitialSync(initial_image_data, initial_tracking_data); | 1887 SetUpInitialSync(initial_image_data, initial_tracking_data); |
| 1888 | 1888 |
| 1889 // The local unsynced tracking info should be dropped, but not deleted. | 1889 // The local unsynced tracking info should be dropped, but not deleted. |
| 1890 EXPECT_EQ(0U, processor()->GetAndResetChangeList().size()); | 1890 EXPECT_EQ(0U, processor()->GetAndResetChangeList().size()); |
| 1891 | 1891 |
| 1892 // Because the image and tracking data don't overlap, the total number of | 1892 // Because the image and tracking data don't overlap, the total number of |
| 1893 // favicons is still over the limit. | 1893 // favicons is still over the limit. |
| 1894 EXPECT_EQ((unsigned long)kMaxSyncFavicons + 5, GetFaviconCount()); | 1894 EXPECT_EQ(static_cast<size_t>(kMaxSyncFavicons)+5, GetFaviconCount()); |
| 1895 | 1895 |
| 1896 // Trigger a tracking change for one of the favicons whose tracking info | 1896 // Trigger a tracking change for one of the favicons whose tracking info |
| 1897 // was dropped, resulting in a tracking add and expiration of the orphaned | 1897 // was dropped, resulting in a tracking add and expiration of the orphaned |
| 1898 // images. | 1898 // images. |
| 1899 TestFaviconData test_data = BuildFaviconData(kMaxSyncFavicons); | 1899 TestFaviconData test_data = BuildFaviconData(kMaxSyncFavicons); |
| 1900 cache()->OnFaviconVisited(test_data.page_url, test_data.icon_url); | 1900 cache()->OnFaviconVisited(test_data.page_url, test_data.icon_url); |
| 1901 | 1901 |
| 1902 syncer::SyncChangeList changes = processor()->GetAndResetChangeList(); | 1902 syncer::SyncChangeList changes = processor()->GetAndResetChangeList(); |
| 1903 // 1 image update, 5 image deletions, 1 tracking deletion. | 1903 // 1 image update, 5 image deletions, 1 tracking deletion. |
| 1904 ASSERT_EQ(6U, changes.size()); | 1904 ASSERT_EQ(6U, changes.size()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1922 EXPECT_EQ(changes[4].change_type(), syncer::SyncChange::ACTION_ADD); | 1922 EXPECT_EQ(changes[4].change_type(), syncer::SyncChange::ACTION_ADD); |
| 1923 EXPECT_EQ(changes[4].sync_data().GetDataType(), syncer::FAVICON_TRACKING); | 1923 EXPECT_EQ(changes[4].sync_data().GetDataType(), syncer::FAVICON_TRACKING); |
| 1924 EXPECT_EQ(kMaxSyncFavicons, GetFaviconId(changes[4])); | 1924 EXPECT_EQ(kMaxSyncFavicons, GetFaviconId(changes[4])); |
| 1925 // Expire tracking for favicon[0]. | 1925 // Expire tracking for favicon[0]. |
| 1926 EXPECT_EQ(changes[5].change_type(), syncer::SyncChange::ACTION_DELETE); | 1926 EXPECT_EQ(changes[5].change_type(), syncer::SyncChange::ACTION_DELETE); |
| 1927 EXPECT_EQ(changes[5].sync_data().GetDataType(), syncer::FAVICON_TRACKING); | 1927 EXPECT_EQ(changes[5].sync_data().GetDataType(), syncer::FAVICON_TRACKING); |
| 1928 EXPECT_EQ(0, GetFaviconId(changes[5])); | 1928 EXPECT_EQ(0, GetFaviconId(changes[5])); |
| 1929 } | 1929 } |
| 1930 | 1930 |
| 1931 } // namespace browser_sync | 1931 } // namespace browser_sync |
| OLD | NEW |