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
11#include <catch2/catch_amalgamated.hpp>
12#include <harness.h>
13
14using namespace yarp::dev;
15using namespace yarp::os;
16
17TEST_CASE("dev::fakeDeviceWrapper", "[yarp::dev]")
18{
19 YARP_REQUIRE_PLUGIN("fakeDeviceUnwrapped", "device");
20 YARP_REQUIRE_PLUGIN("fakeDeviceWrapper", "device");
21
22 Network::setLocalMode(true);
23
24 SECTION("Checking fakeDeviceWrapper device alone")
25 {
26 PolyDriver dd;
28
30 {
32 p_cfg.put("device", "fakeDeviceWrapper");
33 REQUIRE(dd.open(p_cfg));
34 }
35
36 //"Close all polydrivers and check"
37 {
38 CHECK(dd.close());
39 }
40 }
41
42 SECTION("Checking fakeDeviceWrapped device with automatically invoked wrapper")
43 {
44 PolyDriver dd;
48
50 {
52 p_cfg.put("device", "fakeDeviceUnwrapped");
53 REQUIRE(dd.open(p_cfg));
54 }
55 {
57 p_cfg.put("device", "fakeDeviceWrapper");
59 }
60 {
62 dd_wrapper.view(ww_wrap);
64 bool result_att = ww_wrap->attach(&dd);
66 }
67
68 dd.view(iTest1);
70 dd_wrapper.view(iTest2);
72
73 iTest1->testSetValue(5);
74 int val = 0;
75 iTest1->testGetValue(val);
76 CHECK(val == 5);
77
78 iTest2->testSetValue(6);
79 iTest2->testGetValue(val);
80 CHECK(val == 6);
81
82 iTest1->testSetValue(3);
83 iTest2->testGetValue(val);
84 CHECK(val == 3);
85
86 //"Close all polydrivers and check"
87 {
88 CHECK(dd.close());
89 }
90 }
91
92 Network::setLocalMode(false);
93}
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]")
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.