diff --git a/hueplusplus/test/test_UPnP.cpp b/hueplusplus/test/test_UPnP.cpp new file mode 100755 index 0000000..b7aa345 --- /dev/null +++ b/hueplusplus/test/test_UPnP.cpp @@ -0,0 +1,27 @@ +#include +#include + +#include "../include/json/json.h" +#include "mocks/mock_HttpHandler.h" +#include "testhelper.h" +#include "../include/UPnP.h" + +#include "iostream" + +const std::vector> expected_uplug_dev = { + {"http://192.168.2.1:1900/gatedesc.xml", "Linux/2.6.36, UPnP/1.0, Portable SDK for UPnP devices/1.6.19"}, + {"http://192.168.2.116:80/description.xml", "Linux/3.14.0 UPnP/1.0 IpBridge/1.21.0"} +}; + +TEST(UPnP, getDevices) +{ + std::shared_ptr handler = std::make_shared(); + EXPECT_CALL(*handler, sendMulticast("M-SEARCH * HTTP/1.1\r\nHOST: 239.255.255.250:1900\r\nMAN: \"ssdp:discover\"\r\nMX: 5\r\nST: ssdp:all\r\n\r\n", "239.255.255.250", 1900, 5)) + .Times(1) + .WillRepeatedly(::testing::Return(multicast_reply)); + + UPnP uplug; + std::vector> foundDevices = uplug.getDevices(handler); + + EXPECT_EQ(foundDevices, expected_uplug_dev); +}