Chromium Code Reviews| Index: components/download/internal/test/entry_utils.cc |
| diff --git a/components/download/internal/test/entry_utils.cc b/components/download/internal/test/entry_utils.cc |
| index 33b4abfc5a57933e1bb07b2231f2df67b732d291..f36ef1fa4df452898df785c81d62db03a488ca8b 100644 |
| --- a/components/download/internal/test/entry_utils.cc |
| +++ b/components/download/internal/test/entry_utils.cc |
| @@ -9,19 +9,40 @@ |
| namespace download { |
| namespace test { |
| -bool SuperficialEntryCompare(const Entry* const& expected, |
| - const Entry* const& actual) { |
| +bool CompareEntry(const Entry* const& expected, const Entry* const& actual) { |
|
David Trainor- moved to gerrit
2017/05/19 19:07:06
Might just be worth adding an == operator to Entry
|
| if (expected == nullptr || actual == nullptr) |
| return expected == actual; |
| return expected->client == actual->client && expected->guid == actual->guid && |
| + expected->scheduling_params.cancel_time == |
| + actual->scheduling_params.cancel_time && |
| + expected->scheduling_params.network_requirements == |
| + actual->scheduling_params.network_requirements && |
| + expected->scheduling_params.battery_requirements == |
| + actual->scheduling_params.battery_requirements && |
| + expected->scheduling_params.priority == |
| + actual->scheduling_params.priority && |
| + expected->request_params.url == actual->request_params.url && |
| + expected->request_params.method == actual->request_params.method && |
| + expected->request_params.request_headers.ToString() == |
| + actual->request_params.request_headers.ToString() && |
| expected->state == actual->state; |
| } |
| -bool SuperficialEntryListCompare(const std::vector<Entry*>& expected, |
| - const std::vector<Entry*>& actual) { |
| +bool CompareEntryList(const std::vector<Entry*>& expected, |
| + const std::vector<Entry*>& actual) { |
| return std::is_permutation(actual.cbegin(), actual.cend(), expected.cbegin(), |
| - SuperficialEntryCompare); |
| + CompareEntry); |
| +} |
| + |
| +bool EntryComparison(const Entry& expected, const Entry& actual) { |
| + return CompareEntry(&expected, &actual); |
| +} |
| + |
| +bool CompareEntryList(const std::vector<Entry>& list1, |
| + const std::vector<Entry>& list2) { |
| + return std::is_permutation(list1.begin(), list1.end(), list2.begin(), |
| + EntryComparison); |
| } |
| Entry BuildEntry(DownloadClient client, const std::string& guid) { |
| @@ -31,5 +52,25 @@ Entry BuildEntry(DownloadClient client, const std::string& guid) { |
| return entry; |
| } |
| +Entry BuildEntry(DownloadClient client, |
| + const std::string& guid, |
| + base::Time cancel_time, |
| + SchedulingParams::NetworkRequirements network_requirements, |
| + SchedulingParams::BatteryRequirements battery_requirements, |
| + SchedulingParams::Priority priority, |
| + const GURL& url, |
| + const std::string& request_method, |
| + Entry::State state) { |
| + Entry entry = BuildEntry(client, guid); |
| + entry.scheduling_params.cancel_time = cancel_time; |
| + entry.scheduling_params.network_requirements = network_requirements; |
| + entry.scheduling_params.battery_requirements = battery_requirements; |
| + entry.scheduling_params.priority = priority; |
| + entry.request_params.url = url; |
| + entry.request_params.method = request_method; |
| + entry.state = state; |
| + return entry; |
| +} |
| + |
| } // namespace test |
| } // namespace download |