Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "components/download/internal/test/entry_utils.h" | 7 #include "components/download/internal/test/entry_utils.h" |
| 8 | 8 |
| 9 namespace download { | 9 namespace download { |
| 10 namespace test { | 10 namespace test { |
| 11 | 11 |
| 12 bool SuperficialEntryCompare(const Entry* const& expected, | 12 bool SuperficialEntryCompare(const Entry* const& expected, |
|
David Trainor- moved to gerrit
2017/05/18 19:41:00
This compare is no longer superficial.
shaktisahu
2017/05/19 04:54:57
Done. Renamed to CompareEntry.
| |
| 13 const Entry* const& actual) { | 13 const Entry* const& actual) { |
| 14 if (expected == nullptr || actual == nullptr) | 14 if (expected == nullptr || actual == nullptr) |
| 15 return expected == actual; | 15 return expected == actual; |
| 16 | 16 |
| 17 return expected->client == actual->client && expected->guid == actual->guid && | 17 return expected->client == actual->client && expected->guid == actual->guid && |
| 18 expected->scheduling_params.cancel_time == | |
| 19 actual->scheduling_params.cancel_time && | |
| 20 expected->scheduling_params.network_requirements == | |
| 21 actual->scheduling_params.network_requirements && | |
| 22 expected->scheduling_params.battery_requirements == | |
| 23 actual->scheduling_params.battery_requirements && | |
| 24 expected->scheduling_params.priority == | |
| 25 actual->scheduling_params.priority && | |
| 26 expected->request_params.url == actual->request_params.url && | |
| 27 expected->request_params.method == actual->request_params.method && | |
| 28 expected->request_params.request_headers.ToString() == | |
| 29 actual->request_params.request_headers.ToString() && | |
| 18 expected->state == actual->state; | 30 expected->state == actual->state; |
| 19 } | 31 } |
| 20 | 32 |
| 21 bool SuperficialEntryListCompare(const std::vector<Entry*>& expected, | 33 bool CompareEntry(const Entry& expected, const Entry& actual) { |
| 22 const std::vector<Entry*>& actual) { | 34 return SuperficialEntryCompare(&expected, &actual); |
| 35 } | |
| 36 | |
| 37 bool CompareEntryList(const std::vector<Entry*>& expected, | |
| 38 const std::vector<Entry*>& actual) { | |
| 23 return std::is_permutation(actual.cbegin(), actual.cend(), expected.cbegin(), | 39 return std::is_permutation(actual.cbegin(), actual.cend(), expected.cbegin(), |
| 24 SuperficialEntryCompare); | 40 SuperficialEntryCompare); |
| 25 } | 41 } |
| 26 | 42 |
| 43 bool CompareEntryList(const std::vector<Entry>& list1, | |
| 44 const std::vector<Entry>& list2) { | |
| 45 return std::is_permutation(list1.begin(), list1.end(), list2.begin(), | |
| 46 CompareEntry); | |
| 47 } | |
| 48 | |
| 27 Entry BuildEntry(DownloadClient client, const std::string& guid) { | 49 Entry BuildEntry(DownloadClient client, const std::string& guid) { |
| 28 Entry entry; | 50 Entry entry; |
| 29 entry.client = client; | 51 entry.client = client; |
| 30 entry.guid = guid; | 52 entry.guid = guid; |
| 31 return entry; | 53 return entry; |
| 32 } | 54 } |
| 33 | 55 |
| 56 Entry BuildEntry(DownloadClient client, | |
| 57 const std::string& guid, | |
| 58 base::Time cancel_time, | |
| 59 SchedulingParams::NetworkRequirements network_requirements, | |
| 60 SchedulingParams::BatteryRequirements battery_requirements, | |
| 61 SchedulingParams::Priority priority, | |
| 62 const GURL& url, | |
| 63 const std::string& request_method, | |
| 64 Entry::State state) { | |
| 65 Entry entry; | |
|
David Trainor- moved to gerrit
2017/05/18 19:41:00
Call BuildEntry(client, guid) and then set the res
shaktisahu
2017/05/19 04:54:57
Done.
| |
| 66 entry.client = client; | |
| 67 entry.guid = guid; | |
| 68 entry.scheduling_params.cancel_time = cancel_time; | |
| 69 entry.scheduling_params.network_requirements = network_requirements; | |
| 70 entry.scheduling_params.battery_requirements = battery_requirements; | |
| 71 entry.scheduling_params.priority = priority; | |
| 72 entry.request_params.url = url; | |
| 73 entry.request_params.method = request_method; | |
| 74 entry.state = state; | |
| 75 return entry; | |
| 76 } | |
| 77 | |
| 34 } // namespace test | 78 } // namespace test |
| 35 } // namespace download | 79 } // namespace download |
| OLD | NEW |