summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp')
-rw-r--r--Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp b/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp
index a80d748..3491634 100644
--- a/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp
+++ b/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp
@@ -1,11 +1,11 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <map>
#include <memory>
#include <boost/bind.hpp>
@@ -41,22 +41,24 @@ class LinkLocalServiceBrowserTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testRegisterService_Reregister);
CPPUNIT_TEST(testUpdateService);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {
eventLoop = new DummyEventLoop();
querier = std::make_shared<FakeDNSSDQuerier>("wonderland.lit", eventLoop);
aliceServiceID = new DNSSDServiceID("alice", "wonderland.lit");
- aliceServiceInfo = new DNSSDResolveServiceQuery::Result("_presence._tcp.wonderland.lit", "xmpp.wonderland.lit", 1234, LinkLocalServiceInfo().toTXTRecord());
+ auto txtRecord = LinkLocalServiceInfo().toTXTRecord();
+ CPPUNIT_ASSERT(txtRecord);
+ aliceServiceInfo = new DNSSDResolveServiceQuery::Result("_presence._tcp.wonderland.lit", "xmpp.wonderland.lit", 1234, *txtRecord);
testServiceID = new DNSSDServiceID("foo", "bar.local");
- testServiceInfo = new DNSSDResolveServiceQuery::Result("_presence._tcp.bar.local", "xmpp.bar.local", 1234, LinkLocalServiceInfo().toTXTRecord());
- testServiceInfo2 = new DNSSDResolveServiceQuery::Result("_presence.tcp.bar.local", "xmpp.foo.local", 2345, LinkLocalServiceInfo().toTXTRecord());
+ testServiceInfo = new DNSSDResolveServiceQuery::Result("_presence._tcp.bar.local", "xmpp.bar.local", 1234, *txtRecord);
+ testServiceInfo2 = new DNSSDResolveServiceQuery::Result("_presence.tcp.bar.local", "xmpp.foo.local", 2345, *txtRecord);
errorStopReceived = false;
normalStopReceived = false;
}
void tearDown() {
querier->clearAllQueriesEverRun();
addedServices.clear();
removedServices.clear();
changedServices.clear();
@@ -286,73 +288,81 @@ class LinkLocalServiceBrowserTest : public CppUnit::TestFixture {
std::shared_ptr<LinkLocalServiceBrowser> testling = createTestling();
testling->start();
eventLoop->processEvents();
LinkLocalServiceInfo info;
info.setFirstName("Foo");
testling->registerService("foo@bar", 1234, info);
eventLoop->processEvents();
- CPPUNIT_ASSERT(querier->isServiceRegistered("foo@bar", 1234, info.toTXTRecord()));
+ auto txtRecord = info.toTXTRecord();
+ CPPUNIT_ASSERT(txtRecord);
+ CPPUNIT_ASSERT(querier->isServiceRegistered("foo@bar", 1234, *txtRecord));
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(registeredServices.size()));
CPPUNIT_ASSERT(registeredServices[0] == DNSSDServiceID("foo@bar", "wonderland.lit"));
testling->stop();
}
void testRegisterService_Error() {
std::shared_ptr<LinkLocalServiceBrowser> testling = createTestling();
testling->start();
LinkLocalServiceInfo info;
testling->registerService("foo@bar", 1234, info);
eventLoop->processEvents();
querier->setRegisterError();
eventLoop->processEvents();
CPPUNIT_ASSERT(!testling->isRunning());
CPPUNIT_ASSERT(testling->hasError());
CPPUNIT_ASSERT(errorStopReceived);
- CPPUNIT_ASSERT(!querier->isServiceRegistered("foo@bar", 1234, info.toTXTRecord()));
+ auto txtRecord = info.toTXTRecord();
+ CPPUNIT_ASSERT(txtRecord);
+ CPPUNIT_ASSERT(!querier->isServiceRegistered("foo@bar", 1234, *txtRecord));
}
void testRegisterService_Reregister() {
std::shared_ptr<LinkLocalServiceBrowser> testling = createTestling();
testling->start();
eventLoop->processEvents();
LinkLocalServiceInfo info;
info.setFirstName("Foo");
testling->registerService("foo@bar", 1234, info);
eventLoop->processEvents();
testling->unregisterService();
eventLoop->processEvents();
info.setFirstName("Bar");
testling->registerService("bar@baz", 3456, info);
eventLoop->processEvents();
- CPPUNIT_ASSERT(querier->isServiceRegistered("bar@baz", 3456, info.toTXTRecord()));
+ auto txtRecord = info.toTXTRecord();
+ CPPUNIT_ASSERT(txtRecord);
+ CPPUNIT_ASSERT(querier->isServiceRegistered("bar@baz", 3456, *txtRecord));
testling->stop();
}
void testUpdateService() {
std::shared_ptr<LinkLocalServiceBrowser> testling = createTestling();
testling->start();
eventLoop->processEvents();
LinkLocalServiceInfo info;
info.setFirstName("Foo");
testling->registerService("foo@bar", 1234, info);
eventLoop->processEvents();
info.setFirstName("Bar");
testling->updateService(info);
- CPPUNIT_ASSERT(querier->isServiceRegistered("foo@bar", 1234, info.toTXTRecord()));
+ auto txtRecord = info.toTXTRecord();
+ CPPUNIT_ASSERT(txtRecord);
+ CPPUNIT_ASSERT(querier->isServiceRegistered("foo@bar", 1234, *txtRecord));
testling->stop();
}
private:
std::shared_ptr<LinkLocalServiceBrowser> createTestling() {
std::shared_ptr<LinkLocalServiceBrowser> testling(
new LinkLocalServiceBrowser(querier));
testling->onServiceAdded.connect(boost::bind(