Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: chrome/browser/history/history_unittest.cc

Issue 217063005: Separate SyncData methods into three groups, local, remote, and common. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@syncapi
Patch Set: Remove AsLocal and AsRemote methods from SyncData. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // History unit tests come in two flavors: 5 // History unit tests come in two flavors:
6 // 6 //
7 // 1. The more complicated style is that the unit test creates a full history 7 // 1. The more complicated style is that the unit test creates a full history
8 // service. This spawns a background thread for the history backend, and 8 // service. This spawns a background thread for the history backend, and
9 // all communication is asynchronous. This is useful for testing more 9 // all communication is asynchronous. This is useful for testing more
10 // complicated things or end-to-end behavior. 10 // complicated things or end-to-end behavior.
(...skipping 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after
1676 query_url_visits_[2].visit_time); 1676 query_url_visits_[2].visit_time);
1677 EXPECT_EQ(base::Time::UnixEpoch() + base::TimeDelta::FromMicroseconds(12), 1677 EXPECT_EQ(base::Time::UnixEpoch() + base::TimeDelta::FromMicroseconds(12),
1678 query_url_visits_[3].visit_time); 1678 query_url_visits_[3].visit_time);
1679 EXPECT_EQ(base::Time::UnixEpoch() + base::TimeDelta::FromMicroseconds(20), 1679 EXPECT_EQ(base::Time::UnixEpoch() + base::TimeDelta::FromMicroseconds(20),
1680 query_url_visits_[4].visit_time); 1680 query_url_visits_[4].visit_time);
1681 1681
1682 // Expect two sync changes for deleting processed directives. 1682 // Expect two sync changes for deleting processed directives.
1683 const syncer::SyncChangeList& sync_changes = change_processor.changes(); 1683 const syncer::SyncChangeList& sync_changes = change_processor.changes();
1684 ASSERT_EQ(2u, sync_changes.size()); 1684 ASSERT_EQ(2u, sync_changes.size());
1685 EXPECT_EQ(syncer::SyncChange::ACTION_DELETE, sync_changes[0].change_type()); 1685 EXPECT_EQ(syncer::SyncChange::ACTION_DELETE, sync_changes[0].change_type());
1686 EXPECT_EQ(1, sync_changes[0].sync_data().GetRemoteId()); 1686 EXPECT_EQ(1, syncer::SyncDataRemote(sync_changes[0].sync_data()).GetId());
1687 EXPECT_EQ(syncer::SyncChange::ACTION_DELETE, sync_changes[1].change_type()); 1687 EXPECT_EQ(syncer::SyncChange::ACTION_DELETE, sync_changes[1].change_type());
1688 EXPECT_EQ(2, sync_changes[1].sync_data().GetRemoteId()); 1688 EXPECT_EQ(2, syncer::SyncDataRemote(sync_changes[1].sync_data()).GetId());
1689 } 1689 }
1690 1690
1691 // Create delete directives for time ranges. The expected entries should be 1691 // Create delete directives for time ranges. The expected entries should be
1692 // deleted. 1692 // deleted.
1693 TEST_F(HistoryTest, ProcessTimeRangeDeleteDirective) { 1693 TEST_F(HistoryTest, ProcessTimeRangeDeleteDirective) {
1694 ASSERT_TRUE(history_service_.get()); 1694 ASSERT_TRUE(history_service_.get());
1695 const GURL test_url("http://www.google.com/"); 1695 const GURL test_url("http://www.google.com/");
1696 for (int64 i = 1; i <= 10; ++i) { 1696 for (int64 i = 1; i <= 10; ++i) {
1697 base::Time t = 1697 base::Time t =
1698 base::Time::UnixEpoch() + base::TimeDelta::FromMicroseconds(i); 1698 base::Time::UnixEpoch() + base::TimeDelta::FromMicroseconds(i);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1751 query_url_visits_[0].visit_time); 1751 query_url_visits_[0].visit_time);
1752 EXPECT_EQ(base::Time::UnixEpoch() + base::TimeDelta::FromMicroseconds(6), 1752 EXPECT_EQ(base::Time::UnixEpoch() + base::TimeDelta::FromMicroseconds(6),
1753 query_url_visits_[1].visit_time); 1753 query_url_visits_[1].visit_time);
1754 EXPECT_EQ(base::Time::UnixEpoch() + base::TimeDelta::FromMicroseconds(7), 1754 EXPECT_EQ(base::Time::UnixEpoch() + base::TimeDelta::FromMicroseconds(7),
1755 query_url_visits_[2].visit_time); 1755 query_url_visits_[2].visit_time);
1756 1756
1757 // Expect two sync changes for deleting processed directives. 1757 // Expect two sync changes for deleting processed directives.
1758 const syncer::SyncChangeList& sync_changes = change_processor.changes(); 1758 const syncer::SyncChangeList& sync_changes = change_processor.changes();
1759 ASSERT_EQ(2u, sync_changes.size()); 1759 ASSERT_EQ(2u, sync_changes.size());
1760 EXPECT_EQ(syncer::SyncChange::ACTION_DELETE, sync_changes[0].change_type()); 1760 EXPECT_EQ(syncer::SyncChange::ACTION_DELETE, sync_changes[0].change_type());
1761 EXPECT_EQ(1, sync_changes[0].sync_data().GetRemoteId()); 1761 EXPECT_EQ(1, syncer::SyncDataRemote(sync_changes[0].sync_data()).GetId());
1762 EXPECT_EQ(syncer::SyncChange::ACTION_DELETE, sync_changes[1].change_type()); 1762 EXPECT_EQ(syncer::SyncChange::ACTION_DELETE, sync_changes[1].change_type());
1763 EXPECT_EQ(2, sync_changes[1].sync_data().GetRemoteId()); 1763 EXPECT_EQ(2, syncer::SyncDataRemote(sync_changes[1].sync_data()).GetId());
1764 } 1764 }
1765 1765
1766 TEST_F(HistoryBackendDBTest, MigratePresentations) { 1766 TEST_F(HistoryBackendDBTest, MigratePresentations) {
1767 // Create the db we want. Use 22 since segments didn't change in that time 1767 // Create the db we want. Use 22 since segments didn't change in that time
1768 // frame. 1768 // frame.
1769 ASSERT_NO_FATAL_FAILURE(CreateDBVersion(22)); 1769 ASSERT_NO_FATAL_FAILURE(CreateDBVersion(22));
1770 1770
1771 const SegmentID segment_id = 2; 1771 const SegmentID segment_id = 2;
1772 const URLID url_id = 3; 1772 const URLID url_id = 3;
1773 const GURL url("http://www.foo.com"); 1773 const GURL url("http://www.foo.com");
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1826 std::vector<PageUsageData*> results; 1826 std::vector<PageUsageData*> results;
1827 db_->QuerySegmentUsage(segment_time, 10, &results); 1827 db_->QuerySegmentUsage(segment_time, 10, &results);
1828 ASSERT_EQ(1u, results.size()); 1828 ASSERT_EQ(1u, results.size());
1829 EXPECT_EQ(url, results[0]->GetURL()); 1829 EXPECT_EQ(url, results[0]->GetURL());
1830 EXPECT_EQ(segment_id, results[0]->GetID()); 1830 EXPECT_EQ(segment_id, results[0]->GetID());
1831 EXPECT_EQ(title, results[0]->GetTitle()); 1831 EXPECT_EQ(title, results[0]->GetTitle());
1832 STLDeleteElements(&results); 1832 STLDeleteElements(&results);
1833 } 1833 }
1834 1834
1835 } // namespace history 1835 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698