YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
googleDialogFlowCxChatBot_test.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#include <yarp/dev/IChatBot.h>
7#include <yarp/os/Network.h>
8#include <yarp/os/LogStream.h>
10#include <yarp/dev/PolyDriver.h>
12
13#include <catch2/catch_amalgamated.hpp>
14#include <harness.h>
15
16using namespace yarp::dev;
17using namespace yarp::os;
18
19TEST_CASE("dev::googleDialogFlowCxChatBot_test", "[yarp::dev]")
20{
21 YARP_REQUIRE_PLUGIN("googleDialogFlowCxChatBot", "device");
22
23 Network::setLocalMode(true);
24
25 SECTION("Checking googleDialogFlowCxChatBot device")
26 {
27 IChatBot* iChat{nullptr};
28 PolyDriver dd;
30
31 rf.setQuiet(false);
32 rf.setVerbose(true);
33
34 //"Checking opening device"
35 {
37 const std::string init_lang{"it-IT"};
38 const std::string init_voice{"it-IT-Wavenet-A"};
39 pcfg.put("device", "googleDialogFlowCxChatBot");
40 pcfg.put("language_code",init_lang);
41 pcfg.put("location","global");
42 // Fake value for test purpouses
43 pcfg.put("project","test_project");
44 pcfg.put("agent_name","test_agent");
45 REQUIRE(dd.open(pcfg));
46 REQUIRE(dd.view(iChat));
47 }
48
49
50 //Checking interface methods
51 {
52 const std::string lang_to_set{"en-US"};
53 const std::string messageIn{"Hello"};
54 std::string lang_set;
55 std::string messageOut;
56 bool resp;
57 resp = iChat->setLanguage(lang_to_set);
58 CHECK(resp);
59 resp = iChat->getLanguage(lang_set);
60 CHECK(resp);
62 resp = iChat->resetBot();
63 CHECK(resp);
64 //Without the proper credentials and agent id the following method has to fail
65 resp = iChat->interact(messageIn,messageOut);
66 CHECK(!resp);
67 }
68
69
70 //"Close all polydrivers and check"
71 {
72 CHECK(dd.close());
73 }
74 }
75
76 Network::setLocalMode(false);
77}
bool view(T *&x)
Get an interface to the device driver.
IChatBot interface.
Definition IChatBot.h:26
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 mini-server for performing network communication in the background.
A class for storing options and configuration information.
Definition Property.h:33
Helper class for finding config files and other external resources.
bool setQuiet(bool quiet=true)
Request that information be suppressed from the console.
bool setVerbose(bool verbose=true)
Request that information be printed to the console on how resources are being found.
TEST_CASE("dev::googleDialogFlowCxChatBot_test", "[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.