YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
fakeDeviceWrapped_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::fakeDeviceWrapped", "[yarp::dev]")
19{
20 YARP_REQUIRE_PLUGIN("fakeDeviceWrapped", "device");
21
22 Network::setLocalMode(true);
23
24 auto tc = GENERATE("fakeDeviceWrapped",
25 "fakeDeviceWrappedOld");
26
27 SECTION("Checking fakeDeviceWrapped device")
28 {
29 PolyDriver dd;
31
33 {
35 p_cfg.put("device", tc);
36 REQUIRE(dd.open(p_cfg));
38 }
39
40 dd.view(iTest);
41 REQUIRE(iTest);
42
43 iTest->testSetValue(5);
44 int val = 0;
45 iTest->testGetValue(val);
46 CHECK(val == 5);
47
48 //"Close all polydrivers and check"
49 {
50 CHECK(dd.close());
51 }
52 }
53
54 SECTION("Checking fakeDeviceWrapped device with automatically invoked wrapper")
55 {
56 PolyDriver dd;
58
60 {
62 p_cfg.put("device", tc);
63 //this option, should be used only by yarpdev executable: it is used here for testing purposes only,
64 //wrapping_enabled=1 will open deviceBundler, fakeDeviceWrapper and perform an attach with fakeDeviceWrapped.
65 p_cfg.put("wrapping_enabled", 1);
66 REQUIRE(dd.open(p_cfg));
67 }
68
69 //what interfaces are available now?
70 //This part is not well specified.
71 //Currently no interfaces can be opened since dd will be a deviceBundler and not
72 //a fakeDeviceWrapped (even if dd.id() shows `fakeDeviceWrapped`).
73 //This behavior may change in the future, but it is not very important since `wrapping_enabled` is used
74 //only by yarpdev executable.
75 std::string devicename = dd.id();
76 CHECK (devicename == tc);
77
78 REQUIRE(iTest == nullptr);
79
80 //"Close all polydrivers and check"
81 {
82 CHECK(dd.close());
83 }
84 }
85
86 Network::setLocalMode(false);
87}
virtual std::string id() const
Return the id assigned to the PolyDriver.
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.
A test interface used internally by continuous integration.
virtual yarp::dev::ReturnValue testGetValue(int &value)=0
This method is used to get a single value from a test device.
virtual yarp::dev::ReturnValue testSetValue(int value)=0
This method is used to set a single value inside the test device.
A mini-server for performing network communication in the background.
A class for storing options and configuration information.
Definition Property.h:33
TEST_CASE("dev::fakeDeviceWrapped", "[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