YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
fakeDeviceWrapper_test.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2024-2024 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#include <yarp/os/Network.h>
10
12#include <catch2/catch_amalgamated.hpp>
13#include <harness.h>
14
15using namespace yarp::dev;
16using namespace yarp::os;
17
18TEST_CASE("dev::fakeDeviceWrapper", "[yarp::dev]")
19{
20 YARP_REQUIRE_PLUGIN("fakeDeviceUnwrapped", "device");
21 YARP_REQUIRE_PLUGIN("fakeDeviceWrapper", "device");
22
23 Network::setLocalMode(true);
24
25 SECTION("Checking fakeDeviceWrapper device alone")
26 {
27 PolyDriver dd;
29
31 {
33 p_cfg.put("device", "fakeDeviceWrapper");
34 REQUIRE(dd.open(p_cfg));
36 }
37
38 //"Close all polydrivers and check"
39 {
40 CHECK(dd.close());
41 }
42 }
43
44 SECTION("Checking fakeDeviceWrapped device with automatically invoked wrapper")
45 {
46 PolyDriver dd;
50
52 {
54 p_cfg.put("device", "fakeDeviceUnwrapped");
55 REQUIRE(dd.open(p_cfg));
56 }
57 {
59 p_cfg.put("device", "fakeDeviceWrapper");
61 }
62 {
64 dd_wrapper.view(ww_wrap);
66 bool result_att = ww_wrap->attach(&dd);
68 }
69
70 dd.view(iTest1);
72 dd_wrapper.view(iTest2);
74
75 iTest1->testSetValue(5);
76 int val = 0;
77 iTest1->testGetValue(val);
78 CHECK(val == 5);
79
80 iTest2->testSetValue(6);
81 iTest2->testGetValue(val);
82 CHECK(val == 6);
83
84 iTest1->testSetValue(3);
85 iTest2->testGetValue(val);
86 CHECK(val == 3);
87
88 //"Close all polydrivers and check"
89 {
90 CHECK(dd.close());
91 }
92 }
93
94 Network::setLocalMode(false);
95}
bool view(T *&x)
Get an interface to the device driver.
A container for a device driver.
Definition PolyDriver.h:23
bool close() override
Close the DeviceDriver.
bool open(const std::string &txt)
Construct and configure a device by its common name.
Helper interface for an object that can wrap/or "attach" to a single other device.
A test interface used internally by continuous integration.
A mini-server for performing network communication in the background.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
A class for storing options and configuration information.
Definition Property.h:33
TEST_CASE("dev::fakeDeviceWrapper", "[yarp::dev]")
void exec_params_test(yarp::dev::PolyDriver *pdrv)
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.
Definition OSTestMsg.cpp:13