blob: e35aec1f3e472a2079e6d64558c7401deea6b487 [file] [log] [blame]
Weiwei Liue4765012016-06-01 00:10:29 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesaventoe9c69852017-11-04 18:08:37 -04002/*
3 * Copyright (c) 2016-2017, Regents of the University of California,
4 * Colorado State University,
5 * University Pierre & Marie Curie, Sorbonne University.
Weiwei Liue4765012016-06-01 00:10:29 -07006 *
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 Pesaventoe9c69852017-11-04 18:08:37 -040024 * @author Davide Pesavento
Weiwei Liue4765012016-06-01 00:10:29 -070025 * @author Weiwei Liu
26 */
27
28#ifndef NDN_TOOLS_TESTS_CHUNKS_PIPELINE_INTERESTS_FIXTURE_HPP
29#define NDN_TOOLS_TESTS_CHUNKS_PIPELINE_INTERESTS_FIXTURE_HPP
30
31#include "tools/chunks/catchunks/pipeline-interests.hpp"
32
33#include "tests/test-common.hpp"
Davide Pesaventoe9c69852017-11-04 18:08:37 -040034
Weiwei Liue4765012016-06-01 00:10:29 -070035#include <ndn-cxx/util/dummy-client-face.hpp>
36
37namespace ndn {
38namespace chunks {
39namespace tests {
40
41using namespace ndn::tests;
42
43class PipelineInterestsFixture : public UnitTestTimeFixture
44{
45public:
46 PipelineInterestsFixture()
47 : face(io)
48 , name("/ndn/chunks/test")
49 , nDataSegments(0)
Weiwei Liue4765012016-06-01 00:10:29 -070050 , hasFailed(false)
51 {
52 }
53
54protected:
55 void
56 setPipeline(unique_ptr<PipelineInterests> pline)
57 {
58 pipeline = std::move(pline);
59 }
60
61 shared_ptr<Data>
62 makeDataWithSegment(uint64_t segmentNo, bool setFinalBlockId = true) const
63 {
64 auto data = make_shared<Data>(Name(name).appendVersion(0).appendSegment(segmentNo));
65 if (setFinalBlockId)
66 data->setFinalBlockId(name::Component::fromSegment(nDataSegments - 1));
67 return signData(data);
68 }
69
70 void
71 runWithData(const Data& data)
72 {
73 pipeline->run(data,
Davide Pesaventoe9c69852017-11-04 18:08:37 -040074 [this] (const Data&) {},
75 [this] (const std::string&) { hasFailed = true; });
Weiwei Liue4765012016-06-01 00:10:29 -070076 }
77
78protected:
79 boost::asio::io_service io;
80 util::DummyClientFace face;
81 Name name;
82 unique_ptr<PipelineInterests> pipeline;
83 uint64_t nDataSegments;
Weiwei Liue4765012016-06-01 00:10:29 -070084 bool hasFailed;
85};
86
87} // namespace tests
88} // namespace chunks
89} // namespace ndn
90
91#endif // NDN_TOOLS_TESTS_CHUNKS_PIPELINE_INTERESTS_FIXTURE_HPP