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

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

Issue 213003004: Replace calls to 3-arg SyncData::CreateLocalData with 5-arg version. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@syncapi
Patch Set: Apply feedback from review 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #include "chrome/browser/history/page_usage_data.h" 53 #include "chrome/browser/history/page_usage_data.h"
54 #include "chrome/common/chrome_constants.h" 54 #include "chrome/common/chrome_constants.h"
55 #include "chrome/common/chrome_paths.h" 55 #include "chrome/common/chrome_paths.h"
56 #include "chrome/common/thumbnail_score.h" 56 #include "chrome/common/thumbnail_score.h"
57 #include "chrome/tools/profiles/thumbnail-inl.h" 57 #include "chrome/tools/profiles/thumbnail-inl.h"
58 #include "content/public/browser/download_item.h" 58 #include "content/public/browser/download_item.h"
59 #include "content/public/browser/notification_details.h" 59 #include "content/public/browser/notification_details.h"
60 #include "content/public/browser/notification_source.h" 60 #include "content/public/browser/notification_source.h"
61 #include "sql/connection.h" 61 #include "sql/connection.h"
62 #include "sql/statement.h" 62 #include "sql/statement.h"
63 #include "sync/api/attachments/attachment_id.h"
64 #include "sync/api/attachments/attachment_service_proxy_for_test.h"
63 #include "sync/api/fake_sync_change_processor.h" 65 #include "sync/api/fake_sync_change_processor.h"
64 #include "sync/api/sync_change.h" 66 #include "sync/api/sync_change.h"
65 #include "sync/api/sync_change_processor.h" 67 #include "sync/api/sync_change_processor.h"
66 #include "sync/api/sync_change_processor_wrapper_for_test.h" 68 #include "sync/api/sync_change_processor_wrapper_for_test.h"
67 #include "sync/api/sync_error.h" 69 #include "sync/api/sync_error.h"
68 #include "sync/api/sync_error_factory.h" 70 #include "sync/api/sync_error_factory.h"
69 #include "sync/api/sync_merge_result.h" 71 #include "sync/api/sync_merge_result.h"
70 #include "sync/protocol/history_delete_directive_specifics.pb.h" 72 #include "sync/protocol/history_delete_directive_specifics.pb.h"
71 #include "sync/protocol/sync.pb.h" 73 #include "sync/protocol/sync.pb.h"
72 #include "testing/gtest/include/gtest/gtest.h" 74 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 1553 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 // 1st directive. 1628 // 1st directive.
1627 sync_pb::EntitySpecifics entity_specs; 1629 sync_pb::EntitySpecifics entity_specs;
1628 sync_pb::GlobalIdDirective* global_id_directive = 1630 sync_pb::GlobalIdDirective* global_id_directive =
1629 entity_specs.mutable_history_delete_directive() 1631 entity_specs.mutable_history_delete_directive()
1630 ->mutable_global_id_directive(); 1632 ->mutable_global_id_directive();
1631 global_id_directive->add_global_id( 1633 global_id_directive->add_global_id(
1632 (base::Time::UnixEpoch() + base::TimeDelta::FromMicroseconds(6)) 1634 (base::Time::UnixEpoch() + base::TimeDelta::FromMicroseconds(6))
1633 .ToInternalValue()); 1635 .ToInternalValue());
1634 global_id_directive->set_start_time_usec(3); 1636 global_id_directive->set_start_time_usec(3);
1635 global_id_directive->set_end_time_usec(10); 1637 global_id_directive->set_end_time_usec(10);
1636 directives.push_back( 1638 directives.push_back(syncer::SyncData::CreateRemoteData(
1637 syncer::SyncData::CreateRemoteData(1, entity_specs, base::Time())); 1639 1,
1640 entity_specs,
1641 base::Time(),
1642 syncer::AttachmentIdList(),
1643 syncer::AttachmentServiceProxyForTest::Create()));
1638 1644
1639 // 2nd directive. 1645 // 2nd directive.
1640 global_id_directive->Clear(); 1646 global_id_directive->Clear();
1641 global_id_directive->add_global_id( 1647 global_id_directive->add_global_id(
1642 (base::Time::UnixEpoch() + base::TimeDelta::FromMicroseconds(17)) 1648 (base::Time::UnixEpoch() + base::TimeDelta::FromMicroseconds(17))
1643 .ToInternalValue()); 1649 .ToInternalValue());
1644 global_id_directive->set_start_time_usec(13); 1650 global_id_directive->set_start_time_usec(13);
1645 global_id_directive->set_end_time_usec(19); 1651 global_id_directive->set_end_time_usec(19);
1646 directives.push_back( 1652 directives.push_back(syncer::SyncData::CreateRemoteData(
1647 syncer::SyncData::CreateRemoteData(2, entity_specs, base::Time())); 1653 2,
1654 entity_specs,
1655 base::Time(),
1656 syncer::AttachmentIdList(),
1657 syncer::AttachmentServiceProxyForTest::Create()));
1648 1658
1649 syncer::FakeSyncChangeProcessor change_processor; 1659 syncer::FakeSyncChangeProcessor change_processor;
1650 EXPECT_FALSE( 1660 EXPECT_FALSE(
1651 history_service_->MergeDataAndStartSyncing( 1661 history_service_->MergeDataAndStartSyncing(
1652 syncer::HISTORY_DELETE_DIRECTIVES, 1662 syncer::HISTORY_DELETE_DIRECTIVES,
1653 directives, 1663 directives,
1654 scoped_ptr<syncer::SyncChangeProcessor>( 1664 scoped_ptr<syncer::SyncChangeProcessor>(
1655 new syncer::SyncChangeProcessorWrapperForTest( 1665 new syncer::SyncChangeProcessorWrapperForTest(
1656 &change_processor)), 1666 &change_processor)),
1657 scoped_ptr<syncer::SyncErrorFactory>()) 1667 scoped_ptr<syncer::SyncErrorFactory>())
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1706 EXPECT_EQ(10, query_url_row_.visit_count()); 1716 EXPECT_EQ(10, query_url_row_.visit_count());
1707 1717
1708 syncer::SyncDataList directives; 1718 syncer::SyncDataList directives;
1709 // 1st directive. 1719 // 1st directive.
1710 sync_pb::EntitySpecifics entity_specs; 1720 sync_pb::EntitySpecifics entity_specs;
1711 sync_pb::TimeRangeDirective* time_range_directive = 1721 sync_pb::TimeRangeDirective* time_range_directive =
1712 entity_specs.mutable_history_delete_directive() 1722 entity_specs.mutable_history_delete_directive()
1713 ->mutable_time_range_directive(); 1723 ->mutable_time_range_directive();
1714 time_range_directive->set_start_time_usec(2); 1724 time_range_directive->set_start_time_usec(2);
1715 time_range_directive->set_end_time_usec(5); 1725 time_range_directive->set_end_time_usec(5);
1716 directives.push_back(syncer::SyncData::CreateRemoteData(1, 1726 directives.push_back(syncer::SyncData::CreateRemoteData(
1717 entity_specs, 1727 1,
1718 base::Time())); 1728 entity_specs,
1729 base::Time(),
1730 syncer::AttachmentIdList(),
1731 syncer::AttachmentServiceProxyForTest::Create()));
1719 1732
1720 // 2nd directive. 1733 // 2nd directive.
1721 time_range_directive->Clear(); 1734 time_range_directive->Clear();
1722 time_range_directive->set_start_time_usec(8); 1735 time_range_directive->set_start_time_usec(8);
1723 time_range_directive->set_end_time_usec(10); 1736 time_range_directive->set_end_time_usec(10);
1724 directives.push_back(syncer::SyncData::CreateRemoteData(2, 1737 directives.push_back(syncer::SyncData::CreateRemoteData(
1725 entity_specs, 1738 2,
1726 base::Time())); 1739 entity_specs,
1740 base::Time(),
1741 syncer::AttachmentIdList(),
1742 syncer::AttachmentServiceProxyForTest::Create()));
1727 1743
1728 syncer::FakeSyncChangeProcessor change_processor; 1744 syncer::FakeSyncChangeProcessor change_processor;
1729 EXPECT_FALSE( 1745 EXPECT_FALSE(
1730 history_service_->MergeDataAndStartSyncing( 1746 history_service_->MergeDataAndStartSyncing(
1731 syncer::HISTORY_DELETE_DIRECTIVES, 1747 syncer::HISTORY_DELETE_DIRECTIVES,
1732 directives, 1748 directives,
1733 scoped_ptr<syncer::SyncChangeProcessor>( 1749 scoped_ptr<syncer::SyncChangeProcessor>(
1734 new syncer::SyncChangeProcessorWrapperForTest( 1750 new syncer::SyncChangeProcessorWrapperForTest(
1735 &change_processor)), 1751 &change_processor)),
1736 scoped_ptr<syncer::SyncErrorFactory>()) 1752 scoped_ptr<syncer::SyncErrorFactory>())
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1826 std::vector<PageUsageData*> results; 1842 std::vector<PageUsageData*> results;
1827 db_->QuerySegmentUsage(segment_time, 10, &results); 1843 db_->QuerySegmentUsage(segment_time, 10, &results);
1828 ASSERT_EQ(1u, results.size()); 1844 ASSERT_EQ(1u, results.size());
1829 EXPECT_EQ(url, results[0]->GetURL()); 1845 EXPECT_EQ(url, results[0]->GetURL());
1830 EXPECT_EQ(segment_id, results[0]->GetID()); 1846 EXPECT_EQ(segment_id, results[0]->GetID());
1831 EXPECT_EQ(title, results[0]->GetTitle()); 1847 EXPECT_EQ(title, results[0]->GetTitle());
1832 STLDeleteElements(&results); 1848 STLDeleteElements(&results);
1833 } 1849 }
1834 1850
1835 } // namespace history 1851 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698