Weiwei Liu | e476501 | 2016-06-01 00:10:29 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | e9c6985 | 2017-11-04 18:08:37 -0400 | [diff] [blame] | 2 | /* |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame^] | 3 | * Copyright (c) 2016-2020, Regents of the University of California, |
Davide Pesavento | e9c6985 | 2017-11-04 18:08:37 -0400 | [diff] [blame] | 4 | * Colorado State University, |
| 5 | * University Pierre & Marie Curie, Sorbonne University. |
Weiwei Liu | e476501 | 2016-06-01 00:10:29 -0700 | [diff] [blame] | 6 | * |
| 7 | * This file is part of ndn-tools (Named Data Networking Essential Tools). |
| 8 | * See AUTHORS.md for complete list of ndn-tools authors and contributors. |
| 9 | * |
| 10 | * ndn-tools is free software: you can redistribute it and/or modify it under the terms |
| 11 | * of the GNU General Public License as published by the Free Software Foundation, |
| 12 | * either version 3 of the License, or (at your option) any later version. |
| 13 | * |
| 14 | * ndn-tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 15 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE. See the GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along with |
| 19 | * ndn-tools, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 20 | * |
| 21 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. |
| 22 | * |
| 23 | * @author Andrea Tosatto |
Davide Pesavento | e9c6985 | 2017-11-04 18:08:37 -0400 | [diff] [blame] | 24 | * @author Davide Pesavento |
Weiwei Liu | e476501 | 2016-06-01 00:10:29 -0700 | [diff] [blame] | 25 | * @author Weiwei Liu |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 26 | * @author Chavoosh Ghasemi |
Weiwei Liu | e476501 | 2016-06-01 00:10:29 -0700 | [diff] [blame] | 27 | */ |
| 28 | |
| 29 | #ifndef NDN_TOOLS_TESTS_CHUNKS_PIPELINE_INTERESTS_FIXTURE_HPP |
| 30 | #define NDN_TOOLS_TESTS_CHUNKS_PIPELINE_INTERESTS_FIXTURE_HPP |
| 31 | |
| 32 | #include "tools/chunks/catchunks/pipeline-interests.hpp" |
| 33 | |
| 34 | #include "tests/test-common.hpp" |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame^] | 35 | #include "tests/io-fixture.hpp" |
Davide Pesavento | e9c6985 | 2017-11-04 18:08:37 -0400 | [diff] [blame] | 36 | |
Weiwei Liu | e476501 | 2016-06-01 00:10:29 -0700 | [diff] [blame] | 37 | #include <ndn-cxx/util/dummy-client-face.hpp> |
| 38 | |
| 39 | namespace ndn { |
| 40 | namespace chunks { |
| 41 | namespace tests { |
| 42 | |
| 43 | using namespace ndn::tests; |
| 44 | |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame^] | 45 | class PipelineInterestsFixture : public IoFixture |
Weiwei Liu | e476501 | 2016-06-01 00:10:29 -0700 | [diff] [blame] | 46 | { |
Weiwei Liu | e476501 | 2016-06-01 00:10:29 -0700 | [diff] [blame] | 47 | protected: |
| 48 | void |
| 49 | setPipeline(unique_ptr<PipelineInterests> pline) |
| 50 | { |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 51 | m_pipeline = std::move(pline); |
Weiwei Liu | e476501 | 2016-06-01 00:10:29 -0700 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | shared_ptr<Data> |
| 55 | makeDataWithSegment(uint64_t segmentNo, bool setFinalBlockId = true) const |
| 56 | { |
| 57 | auto data = make_shared<Data>(Name(name).appendVersion(0).appendSegment(segmentNo)); |
| 58 | if (setFinalBlockId) |
Davide Pesavento | 969cd5a | 2018-04-20 16:27:47 -0400 | [diff] [blame] | 59 | data->setFinalBlock(name::Component::fromSegment(nDataSegments - 1)); |
Weiwei Liu | e476501 | 2016-06-01 00:10:29 -0700 | [diff] [blame] | 60 | return signData(data); |
| 61 | } |
| 62 | |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 63 | shared_ptr<Data> |
Davide Pesavento | dc4cb4b | 2017-11-21 13:40:22 -0500 | [diff] [blame] | 64 | makeDataWithSegmentAndCongMark(uint64_t segmentNo, |
| 65 | uint64_t congestionMark = 1, |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 66 | bool setFinalBlockId = true) const |
| 67 | { |
| 68 | auto data = makeDataWithSegment(segmentNo, setFinalBlockId); |
| 69 | data->setCongestionMark(congestionMark); |
| 70 | return data; |
| 71 | } |
| 72 | |
Weiwei Liu | e476501 | 2016-06-01 00:10:29 -0700 | [diff] [blame] | 73 | void |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 74 | run(const Name& name, uint64_t version = 0) |
Weiwei Liu | e476501 | 2016-06-01 00:10:29 -0700 | [diff] [blame] | 75 | { |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 76 | m_pipeline->run(Name(name).appendVersion(version), |
| 77 | [] (const Data&) {}, |
| 78 | [this] (const std::string&) { hasFailed = true; }); |
Weiwei Liu | e476501 | 2016-06-01 00:10:29 -0700 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | protected: |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame^] | 82 | util::DummyClientFace face{m_io}; |
Davide Pesavento | dc4cb4b | 2017-11-21 13:40:22 -0500 | [diff] [blame] | 83 | Name name{"/ndn/chunks/test"}; |
| 84 | uint64_t nDataSegments = 0; |
| 85 | bool hasFailed = false; |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 86 | |
| 87 | private: |
| 88 | unique_ptr<PipelineInterests> m_pipeline; |
Weiwei Liu | e476501 | 2016-06-01 00:10:29 -0700 | [diff] [blame] | 89 | }; |
| 90 | |
| 91 | } // namespace tests |
| 92 | } // namespace chunks |
| 93 | } // namespace ndn |
| 94 | |
| 95 | #endif // NDN_TOOLS_TESTS_CHUNKS_PIPELINE_INTERESTS_FIXTURE_HPP |