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

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

Issue 2881173003: Download Service : Added leveldb proto layer (Closed)
Patch Set: Removed Model::Destroy 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) {
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
16 // TODO(shaktisahu): Add operator== in Entry.
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 CompareEntryList(const std::vector<Entry*>& expected,
22 const std::vector<Entry*>& actual) { 34 const std::vector<Entry*>& actual) {
23 return std::is_permutation(actual.cbegin(), actual.cend(), expected.cbegin(), 35 return std::is_permutation(actual.cbegin(), actual.cend(), expected.cbegin(),
24 SuperficialEntryCompare); 36 CompareEntry);
37 }
38
39 bool EntryComparison(const Entry& expected, const Entry& actual) {
40 return CompareEntry(&expected, &actual);
41 }
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 EntryComparison);
25 } 47 }
26 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 = BuildEntry(client, guid);
66 entry.scheduling_params.cancel_time = cancel_time;
67 entry.scheduling_params.network_requirements = network_requirements;
68 entry.scheduling_params.battery_requirements = battery_requirements;
69 entry.scheduling_params.priority = priority;
70 entry.request_params.url = url;
71 entry.request_params.method = request_method;
72 entry.state = state;
73 return entry;
74 }
75
34 } // namespace test 76 } // namespace test
35 } // namespace download 77 } // namespace download
OLDNEW
« no previous file with comments | « components/download/internal/test/entry_utils.h ('k') | components/download/internal/test/mock_model_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698