|
| 1 | +// this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*- |
| 2 | + |
| 3 | +// -- BEGIN LICENSE BLOCK ---------------------------------------------- |
| 4 | +// -- END LICENSE BLOCK ------------------------------------------------ |
| 5 | + |
| 6 | +//---------------------------------------------------------------------- |
| 7 | +/*!\file |
| 8 | + * |
| 9 | + * \author Felix Exner [email protected] |
| 10 | + * \date 2020-07-09 |
| 11 | + * |
| 12 | + */ |
| 13 | +//---------------------------------------------------------------------- |
| 14 | + |
| 15 | +#include <gtest/gtest.h> |
| 16 | + |
| 17 | +#include <ur_robot_driver/rtde/rtde_client.h> |
| 18 | + |
| 19 | +using namespace ur_driver; |
| 20 | + |
| 21 | +const std::string ROBOT_IP = "172.17.0.2"; |
| 22 | + |
| 23 | +TEST(UrRobotDriver, rtde_handshake) |
| 24 | +{ |
| 25 | + comm::INotifier notifier; |
| 26 | + std::string output_recipe = "resources/rtde_output_recipe.txt"; |
| 27 | + std::string input_recipe = "resources/rtde_input_recipe.txt"; |
| 28 | + rtde_interface::RTDEClient client(ROBOT_IP, notifier, output_recipe, input_recipe); |
| 29 | + |
| 30 | + EXPECT_TRUE(client.init()); |
| 31 | +} |
| 32 | + |
| 33 | +TEST(UrRobotDriver, rtde_handshake_wrong_ip) |
| 34 | +{ |
| 35 | + comm::INotifier notifier; |
| 36 | + std::string output_recipe = "resources/rtde_output_recipe.txt"; |
| 37 | + std::string input_recipe = "resources/rtde_input_recipe.txt"; |
| 38 | + rtde_interface::RTDEClient client("1.2.3.4", notifier, output_recipe, input_recipe); |
| 39 | + |
| 40 | + EXPECT_THROW(client.init(), UrException); |
| 41 | +} |
| 42 | + |
| 43 | +TEST(UrRobotDriver, rtde_handshake_illegal_ip) |
| 44 | +{ |
| 45 | + comm::INotifier notifier; |
| 46 | + std::string output_recipe = "resources/rtde_output_recipe.txt"; |
| 47 | + std::string input_recipe = "resources/rtde_input_recipe.txt"; |
| 48 | + rtde_interface::RTDEClient client("abcd", notifier, output_recipe, input_recipe); |
| 49 | + |
| 50 | + EXPECT_THROW(client.init(), UrException); |
| 51 | +} |
| 52 | + |
| 53 | +TEST(UrRobotDriver, no_recipe) |
| 54 | +{ |
| 55 | + comm::INotifier notifier; |
| 56 | + std::string output_recipe = ""; |
| 57 | + std::string input_recipe = ""; |
| 58 | + EXPECT_THROW(rtde_interface::RTDEClient client(ROBOT_IP, notifier, output_recipe, input_recipe), UrException); |
| 59 | +} |
| 60 | + |
| 61 | +TEST(UrRobotDriver, empty_recipe) |
| 62 | +{ |
| 63 | + comm::INotifier notifier; |
| 64 | + std::string output_recipe = "resources/empty.txt"; |
| 65 | + std::string input_recipe = "resources/empty.txt"; |
| 66 | + rtde_interface::RTDEClient client(ROBOT_IP, notifier, output_recipe, input_recipe); |
| 67 | + |
| 68 | + EXPECT_THROW(client.init(), UrException); |
| 69 | +} |
| 70 | + |
| 71 | +int main(int argc, char* argv[]) |
| 72 | +{ |
| 73 | + ::testing::InitGoogleTest(&argc, argv); |
| 74 | + |
| 75 | + return RUN_ALL_TESTS(); |
| 76 | +} |
0 commit comments