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 "chrome/browser/sync/glue/favicon_cache.h" | 5 #include "chrome/browser/sync/glue/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 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1465 syncer::AttachmentServiceProxyForTest::Create())); | 1465 syncer::AttachmentServiceProxyForTest::Create())); |
1466 } | 1466 } |
1467 | 1467 |
1468 SetUpInitialSync(initial_image_data, initial_tracking_data); | 1468 SetUpInitialSync(initial_image_data, initial_tracking_data); |
1469 syncer::SyncChangeList changes = processor()->GetAndResetChangeList(); | 1469 syncer::SyncChangeList changes = processor()->GetAndResetChangeList(); |
1470 EXPECT_TRUE(changes.empty()); | 1470 EXPECT_TRUE(changes.empty()); |
1471 | 1471 |
1472 history::URLsDeletedDetails deletions; | 1472 history::URLsDeletedDetails deletions; |
1473 deletions.all_history = true; | 1473 deletions.all_history = true; |
1474 EXPECT_EQ((unsigned long)kFaviconBatchSize, GetFaviconCount()); | 1474 EXPECT_EQ((unsigned long)kFaviconBatchSize, GetFaviconCount()); |
1475 content::NotificationService::current()->Notify( | 1475 cache()->OnURLsDeleted(nullptr, deletions); |
1476 chrome::NOTIFICATION_HISTORY_URLS_DELETED, | |
1477 content::Source<Profile>(NULL), | |
1478 content::Details<history::URLsDeletedDetails>(&deletions)); | |
1479 EXPECT_EQ(0U, GetFaviconCount()); | 1476 EXPECT_EQ(0U, GetFaviconCount()); |
1480 changes = processor()->GetAndResetChangeList(); | 1477 changes = processor()->GetAndResetChangeList(); |
1481 ASSERT_EQ(changes.size(), (unsigned long)kFaviconBatchSize*2); | 1478 ASSERT_EQ(changes.size(), (unsigned long)kFaviconBatchSize*2); |
1482 syncer::SyncChangeList changes_1, changes_2; | 1479 syncer::SyncChangeList changes_1, changes_2; |
1483 for (int i = 0; i < kFaviconBatchSize; ++i) { | 1480 for (int i = 0; i < kFaviconBatchSize; ++i) { |
1484 changes_1.push_back(changes[i]); | 1481 changes_1.push_back(changes[i]); |
1485 changes_2.push_back(changes[i + kFaviconBatchSize]); | 1482 changes_2.push_back(changes[i + kFaviconBatchSize]); |
1486 } | 1483 } |
1487 VerifyChanges(syncer::FAVICON_IMAGES, | 1484 VerifyChanges(syncer::FAVICON_IMAGES, |
1488 expected_deletions, | 1485 expected_deletions, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1525 base::Time(), | 1522 base::Time(), |
1526 syncer::AttachmentIdList(), | 1523 syncer::AttachmentIdList(), |
1527 syncer::AttachmentServiceProxyForTest::Create())); | 1524 syncer::AttachmentServiceProxyForTest::Create())); |
1528 } | 1525 } |
1529 | 1526 |
1530 SetUpInitialSync(initial_image_data, initial_tracking_data); | 1527 SetUpInitialSync(initial_image_data, initial_tracking_data); |
1531 syncer::SyncChangeList changes = processor()->GetAndResetChangeList(); | 1528 syncer::SyncChangeList changes = processor()->GetAndResetChangeList(); |
1532 EXPECT_TRUE(changes.empty()); | 1529 EXPECT_TRUE(changes.empty()); |
1533 | 1530 |
1534 EXPECT_EQ((unsigned long)kFaviconBatchSize, GetFaviconCount()); | 1531 EXPECT_EQ((unsigned long)kFaviconBatchSize, GetFaviconCount()); |
1535 content::NotificationService::current()->Notify( | 1532 cache()->OnURLsDeleted(nullptr, deletions); |
1536 chrome::NOTIFICATION_HISTORY_URLS_DELETED, | |
1537 content::Source<Profile>(NULL), | |
1538 content::Details<history::URLsDeletedDetails>(&deletions)); | |
1539 EXPECT_EQ((unsigned long)kFaviconBatchSize/2, GetFaviconCount()); | 1533 EXPECT_EQ((unsigned long)kFaviconBatchSize/2, GetFaviconCount()); |
1540 changes = processor()->GetAndResetChangeList(); | 1534 changes = processor()->GetAndResetChangeList(); |
1541 ASSERT_EQ(changes.size(), (unsigned long)kFaviconBatchSize); | 1535 ASSERT_EQ(changes.size(), (unsigned long)kFaviconBatchSize); |
1542 syncer::SyncChangeList changes_1, changes_2; | 1536 syncer::SyncChangeList changes_1, changes_2; |
1543 for (size_t i = 0; i < kFaviconBatchSize/2; ++i) { | 1537 for (size_t i = 0; i < kFaviconBatchSize/2; ++i) { |
1544 changes_1.push_back(changes[i]); | 1538 changes_1.push_back(changes[i]); |
1545 changes_2.push_back(changes[i + kFaviconBatchSize/2]); | 1539 changes_2.push_back(changes[i + kFaviconBatchSize/2]); |
1546 } | 1540 } |
1547 VerifyChanges(syncer::FAVICON_IMAGES, | 1541 VerifyChanges(syncer::FAVICON_IMAGES, |
1548 expected_deletions, | 1542 expected_deletions, |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1931 EXPECT_EQ(changes[4].change_type(), syncer::SyncChange::ACTION_ADD); | 1925 EXPECT_EQ(changes[4].change_type(), syncer::SyncChange::ACTION_ADD); |
1932 EXPECT_EQ(changes[4].sync_data().GetDataType(), syncer::FAVICON_TRACKING); | 1926 EXPECT_EQ(changes[4].sync_data().GetDataType(), syncer::FAVICON_TRACKING); |
1933 EXPECT_EQ(kMaxSyncFavicons, GetFaviconId(changes[4])); | 1927 EXPECT_EQ(kMaxSyncFavicons, GetFaviconId(changes[4])); |
1934 // Expire tracking for favicon[0]. | 1928 // Expire tracking for favicon[0]. |
1935 EXPECT_EQ(changes[5].change_type(), syncer::SyncChange::ACTION_DELETE); | 1929 EXPECT_EQ(changes[5].change_type(), syncer::SyncChange::ACTION_DELETE); |
1936 EXPECT_EQ(changes[5].sync_data().GetDataType(), syncer::FAVICON_TRACKING); | 1930 EXPECT_EQ(changes[5].sync_data().GetDataType(), syncer::FAVICON_TRACKING); |
1937 EXPECT_EQ(0, GetFaviconId(changes[5])); | 1931 EXPECT_EQ(0, GetFaviconId(changes[5])); |
1938 } | 1932 } |
1939 | 1933 |
1940 } // namespace browser_sync | 1934 } // namespace browser_sync |
OLD | NEW |