YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
robotDescriptionStorage_test.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2025-2025 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
8
10#include <yarp/os/Time.h>
11#include <yarp/os/Network.h>
12
13#include <algorithm>
14#include <vector>
15
17#include <catch2/catch_amalgamated.hpp>
18#include <harness.h>
19
20using namespace yarp::os;
21using namespace yarp::dev;
22
23TEST_CASE("dev::robotDescriptionStorage_Test", "[yarp::dev]")
24{
25 YARP_REQUIRE_PLUGIN("robotDescriptionStorage", "device");
26 YARP_REQUIRE_PLUGIN("fakeDeviceUnwrapped", "device");
27 YARP_REQUIRE_PLUGIN("controlBoard_nws_yarp", "device");
28
29 Network::setLocalMode(true);
30
31 SECTION("Test the robotDescriptionStorage device")
32 {
35 IRobotDescription* idesc = nullptr;
36 pcfg.put("device", "robotDescriptionStorage");
37 REQUIRE(ddstor.open(pcfg)); // robotDescriptionStorage open reported successful
39
40 REQUIRE(ddstor.view(idesc)); // IRobotDescription interface open reported successful
42
44 devc.device_name = "test_dev_name";
45 devc.device_type = "device_type";
46 yarp::dev::ReturnValue r = idesc->registerDevice(devc);
47 CHECK(r);
48 std::vector<DeviceDescription> list;
49 r = idesc->getAllDevices(list);
50 CHECK(r);
51 CHECK(list.size() == 1);
52 CHECK(list[0].device_name == "test_dev_name");
53 CHECK(list[0].device_type == "device_type");
54
55 // Close devices
56 CHECK(ddstor.close()); // robotDescriptionStorage successfully closed
57 }
58
59 SECTION("Test the robotDescriptionStorage device with attach")
60 {
63 p_cfg_adevice.put("device", "fakeDeviceUnwrapped");
65
68 pcfg.put("device", "robotDescriptionStorage");
69 REQUIRE(ddstor.open(pcfg)); // robotDescription_nws_yarp open reported successful
70
74 drivers_list.push(&dd_adevice,"fakedev");
75 bool result_att = ww_nws->attachAll(drivers_list);
77
79
80 // Close devices
81 CHECK(ddstor.close()); // robotDescription_nws_yarp successfully closed
83 }
84
85 SECTION("Test the robotDescriptionStorage device with attach")
86 {
89 p_cfg_adevice.put("device", "controlBoard_nws_yarp");
90 p_cfg_adevice.put("name", "/test");
92
95 pcfg.put("device", "robotDescriptionStorage");
96 REQUIRE(ddstor.open(pcfg)); // robotDescription_nws_yarp open reported successful
97
99 ddstor.view(ww_nws);
102 drivers_list.push(&dd_adevice, "fakedev");
103 bool result_att = ww_nws->attachAll(drivers_list);
105
107
108 // Close devices
109 CHECK(ddstor.close()); // robotDescription_nws_yarp successfully closed
111 }
112
113 Network::setLocalMode(false);
114}
Interface for an object that can wrap/attach to to another.
This interface allows users to retrieve a list which contains the names and the types of the currentl...
A container for a device driver.
Definition PolyDriver.h:23
A mini-server for performing network communication in the background.
void close() override
Stop port activity.
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
void exec_params_test(yarp::dev::PolyDriver *pdrv)
For streams capable of holding different kinds of content, check what they actually have.
void delay(double seconds)
Wait for a certain number of seconds.
Definition Time.cpp:111
An interface to the operating system, including Port based communication.
Definition OSTestMsg.cpp:13
TEST_CASE("dev::robotDescriptionStorage_Test", "[yarp::dev]")