YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
speechSynthesizer_nws_yarp_test.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#include <yarp/os/Network.h>
9
11#include <catch2/catch_amalgamated.hpp>
12#include <harness.h>
13
14#include <yarp/sig/Sound.h>
15
16using namespace yarp::dev;
17using namespace yarp::os;
18
19TEST_CASE("dev::speechSynthesizer_nws_yarp", "[yarp::dev]")
20{
21 YARP_REQUIRE_PLUGIN("fakeSpeechSynthesizer", "device");
22 YARP_REQUIRE_PLUGIN("speechSynthesizer_nws_yarp", "device");
23
24 Network::setLocalMode(true);
25
26 SECTION("Checking speechSynthesizer_nws_yarp device alone")
27 {
28 PolyDriver dd;
29
31 {
33 pnws_cfg.put("device", "speechSynthesizer_nws_yarp");
34 pnws_cfg.put("name", "/speechSynthesizer_nws");
37 }
38
40
41 //"Close all polydrivers and check"
42 {
43 CHECK(dd.close());
44 }
45 }
46
47 SECTION("Checking speechSynthesizer_nws_yarp device attached to fake device")
48 {
51
53 {
55 pnws_cfg.put("device", "speechSynthesizer_nws_yarp");
56 pnws_cfg.put("name", "/speechSynthesizer_nws");
58
60 pdev_cfg.put("device", "fakeSpeechSynthesizer");
62
65 bool result_att = ww_nws->attach(&ddfake);
67 }
68
69 //tests
70 {
71 Port po;
72 Port pi;
73 CHECK(po.open("/test:o"));
74 CHECK(Network::connect("/test:o","/speechSynthesizer_nws/text:i"));
75 CHECK(pi.open("/test:i"));
76 CHECK(Network::connect("/speechSynthesizer_nws/sound:o", "/test:i"));
78
80 b.addString("hello world");
81 CHECK(po.write(b));
84 CHECK(pi.read(ss));
85 CHECK(ss.getChannels() == 2);
86 CHECK(ss.getSamples() == 100);
87
88 po.close();
89 pi.close();
90 }
92
93 //"Close all polydrivers and check"
94 {
95 CHECK(ddnws.close());
97 }
98 }
99
100 Network::setLocalMode(false);
101}
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 simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:65
void addString(const char *str)
Places a string in the bottle, at the end of the list.
Definition Bottle.cpp:176
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.
T * read(bool shouldWait=true) override
Read an available object from the port.
void write(bool forceStrict=false)
Write the current object being returned by BufferedPort::prepare.
A mini-server for network communication.
Definition Port.h:46
A class for storing options and configuration information.
Definition Property.h:33
Class for storing sounds See Audio in YARP for additional documentation on YARP audio.
Definition Sound.h:42
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::speechSynthesizer_nws_yarp", "[yarp::dev]")