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

Side by Side Diff: components/download/internal/test/entry_utils.cc

Issue 2881173003: Download Service : Added leveldb proto layer (Closed)
Patch Set: comments Created 3 years, 7 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 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 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
13 const Entry* const& actual) {
14 if (expected == nullptr || actual == nullptr) 13 if (expected == nullptr || actual == nullptr)
15 return expected == actual; 14 return expected == actual;
16 15
17 return expected->client == actual->client && expected->guid == actual->guid && 16 return expected->client == actual->client && expected->guid == actual->guid &&
17 expected->scheduling_params.cancel_time ==
18 actual->scheduling_params.cancel_time &&
19 expected->scheduling_params.network_requirements ==
20 actual->scheduling_params.network_requirements &&
21 expected->scheduling_params.battery_requirements ==
22 actual->scheduling_params.battery_requirements &&
23 expected->scheduling_params.priority ==
24 actual->scheduling_params.priority &&
25 expected->request_params.url == actual->request_params.url &&
26 expected->request_params.method == actual->request_params.method &&
27 expected->request_params.request_headers.ToString() ==
28 actual->request_params.request_headers.ToString() &&
18 expected->state == actual->state; 29 expected->state == actual->state;
19 } 30 }
20 31
21 bool SuperficialEntryListCompare(const std::vector<Entry*>& expected, 32 bool CompareEntryList(const std::vector<Entry*>& expected,
22 const std::vector<Entry*>& actual) { 33 const std::vector<Entry*>& actual) {
23 return std::is_permutation(actual.cbegin(), actual.cend(), expected.cbegin(), 34 return std::is_permutation(actual.cbegin(), actual.cend(), expected.cbegin(),
24 SuperficialEntryCompare); 35 CompareEntry);
36 }
37
38 bool EntryComparison(const Entry& expected, const Entry& actual) {
39 return CompareEntry(&expected, &actual);
40 }
41
42 bool CompareEntryList(const std::vector<Entry>& list1,
43 const std::vector<Entry>& list2) {
44 return std::is_permutation(list1.begin(), list1.end(), list2.begin(),
45 EntryComparison);
25 } 46 }
26 47
27 Entry BuildEntry(DownloadClient client, const std::string& guid) { 48 Entry BuildEntry(DownloadClient client, const std::string& guid) {
28 Entry entry; 49 Entry entry;
29 entry.client = client; 50 entry.client = client;
30 entry.guid = guid; 51 entry.guid = guid;
31 return entry; 52 return entry;
32 } 53 }
33 54
55 Entry BuildEntry(DownloadClient client,
56 const std::string& guid,
57 base::Time cancel_time,
58 SchedulingParams::NetworkRequirements network_requirements,
59 SchedulingParams::BatteryRequirements battery_requirements,
60 SchedulingParams::Priority priority,
61 const GURL& url,
62 const std::string& request_method,
63 Entry::State state) {
64 Entry entry = BuildEntry(client, guid);
65 entry.scheduling_params.cancel_time = cancel_time;
66 entry.scheduling_params.network_requirements = network_requirements;
67 entry.scheduling_params.battery_requirements = battery_requirements;
68 entry.scheduling_params.priority = priority;
69 entry.request_params.url = url;
70 entry.request_params.method = request_method;
71 entry.state = state;
72 return entry;
73 }
74
34 } // namespace test 75 } // namespace test
35 } // namespace download 76 } // namespace download
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698