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
16#include <catch2/catch_amalgamated.hpp>
17#include <harness.h>
18
19using namespace yarp::os;
20using namespace yarp::dev;
21
22TEST_CASE("dev::robotDescriptionStorage_Test", "[yarp::dev]")
23{
24 YARP_REQUIRE_PLUGIN("robotDescriptionStorage", "device");
25 YARP_REQUIRE_PLUGIN("fakeDeviceUnwrapped", "device");
26 YARP_REQUIRE_PLUGIN("controlBoard_nws_yarp", "device");
27
28 Network::setLocalMode(true);
29
30 SECTION("Test the robotDescriptionStorage device")
31 {
34 IRobotDescription* idesc = nullptr;
35 pcfg.put("device", "robotDescriptionStorage");
36 REQUIRE(ddstor.open(pcfg)); // robotDescriptionStorage open reported successful
37
38 REQUIRE(ddstor.view(idesc)); // IRobotDescription interface open reported successful
40
42 devc.device_name = "test_dev_name";
43 devc.device_type = "device_type";
44 yarp::dev::ReturnValue r = idesc->registerDevice(devc);
45 CHECK(r);
46 std::vector<DeviceDescription> list;
47 r = idesc->getAllDevices(list);
48 CHECK(r);
49 CHECK(list.size() == 1);
50 CHECK(list[0].device_name == "test_dev_name");
51 CHECK(list[0].device_type == "device_type");
52
53 // Close devices
54 CHECK(ddstor.close()); // robotDescriptionStorage successfully closed
55 }
56
57 SECTION("Test the robotDescriptionStorage device with attach")
58 {
61 p_cfg_adevice.put("device", "fakeDeviceUnwrapped");
63
66 pcfg.put("device", "robotDescriptionStorage");
67 REQUIRE(ddstor.open(pcfg)); // robotDescription_nws_yarp open reported successful
68
72 drivers_list.push(&dd_adevice,"fakedev");
73 bool result_att = ww_nws->attachAll(drivers_list);
75
77
78 // Close devices
79 CHECK(ddstor.close()); // robotDescription_nws_yarp successfully closed
81 }
82
83 SECTION("Test the robotDescriptionStorage device with attach")
84 {
87 p_cfg_adevice.put("device", "controlBoard_nws_yarp");
88 p_cfg_adevice.put("name", "/test");
90
93 pcfg.put("device", "robotDescriptionStorage");
94 REQUIRE(ddstor.open(pcfg)); // robotDescription_nws_yarp open reported successful
95
97 ddstor.view(ww_nws);
100 drivers_list.push(&dd_adevice, "fakedev");
101 bool result_att = ww_nws->attachAll(drivers_list);
103
105
106 // Close devices
107 CHECK(ddstor.close()); // robotDescription_nws_yarp successfully closed
109 }
110
111 Network::setLocalMode(false);
112}
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
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.
TEST_CASE("dev::robotDescriptionStorage_Test", "[yarp::dev]")