diff options
Diffstat (limited to 'Swiften/LinkLocal/UnitTest')
-rw-r--r-- | Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp | 5 | ||||
-rw-r--r-- | Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp | 3 |
2 files changed, 4 insertions, 4 deletions
diff --git a/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp b/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp index 474c772..dd5e884 100644 --- a/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp +++ b/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp @@ -1,71 +1,70 @@ /* * Copyright (c) 2010 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #include <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/TestFactoryRegistry.h> #include <boost/bind.hpp> #include <Swiften/LinkLocal/LinkLocalConnector.h> #include <Swiften/LinkLocal/LinkLocalService.h> #include <Swiften/LinkLocal/DNSSD/DNSSDServiceID.h> #include <Swiften/LinkLocal/DNSSD/DNSSDResolveHostnameQuery.h> #include <Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h> #include <Swiften/EventLoop/DummyEventLoop.h> #include <Swiften/Network/FakeConnection.h> using namespace Swift; class LinkLocalConnectorTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(LinkLocalConnectorTest); CPPUNIT_TEST(testConnect); CPPUNIT_TEST(testConnect_UnableToResolve); CPPUNIT_TEST(testConnect_UnableToConnect); CPPUNIT_TEST(testCancel_DuringResolve); CPPUNIT_TEST(testCancel_DuringConnect); CPPUNIT_TEST_SUITE_END(); public: void setUp() { eventLoop = new DummyEventLoop(); - querier = boost::shared_ptr<FakeDNSSDQuerier>( - new FakeDNSSDQuerier("rabbithole.local", eventLoop)); - connection = boost::shared_ptr<FakeConnection>(new FakeConnection(eventLoop)); + querier = boost::make_shared<FakeDNSSDQuerier>("rabbithole.local", eventLoop); + connection = boost::make_shared<FakeConnection>(eventLoop); connectFinished = false; } void tearDown() { querier->clearAllQueriesEverRun(); delete eventLoop; } void testConnect() { boost::shared_ptr<LinkLocalConnector> testling(createConnector("rabbithole.local", 1234)); querier->setAddress("rabbithole.local", HostAddress("192.168.1.1")); testling->connect(); eventLoop->processEvents(); CPPUNIT_ASSERT(connectFinished); CPPUNIT_ASSERT(!connectError); CPPUNIT_ASSERT(connection->connectedTo); CPPUNIT_ASSERT_EQUAL(std::string(connection->connectedTo->getAddress().toString()), std::string("192.168.1.1")); CPPUNIT_ASSERT_EQUAL(connection->connectedTo->getPort(), 1234); } void testConnect_UnableToResolve() { boost::shared_ptr<LinkLocalConnector> testling(createConnector("rabbithole.local", 1234)); querier->setAddress("rabbithole.local", boost::optional<HostAddress>()); testling->connect(); eventLoop->processEvents(); CPPUNIT_ASSERT(connectFinished); CPPUNIT_ASSERT(connectError); CPPUNIT_ASSERT(!connection->connectedTo); } diff --git a/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp b/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp index c0fd248..93deea5 100644 --- a/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp +++ b/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp @@ -1,80 +1,81 @@ /* * Copyright (c) 2010 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #include <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/TestFactoryRegistry.h> #include <boost/bind.hpp> +#include <boost/smart_ptr/make_shared.hpp> #include <map> #include <Swiften/LinkLocal/LinkLocalServiceBrowser.h> #include <Swiften/LinkLocal/LinkLocalService.h> #include <Swiften/LinkLocal/DNSSD/DNSSDServiceID.h> #include <Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h> #include <Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h> #include <Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDResolveServiceQuery.h> #include <Swiften/EventLoop/DummyEventLoop.h> using namespace Swift; class LinkLocalServiceBrowserTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(LinkLocalServiceBrowserTest); CPPUNIT_TEST(testConstructor); CPPUNIT_TEST(testStart); CPPUNIT_TEST(testServiceAdded); CPPUNIT_TEST(testServiceAdded_NoServiceInfo); CPPUNIT_TEST(testServiceAdded_RegisteredService); CPPUNIT_TEST(testServiceAdded_UnregisteredService); CPPUNIT_TEST(testServiceAdded_Twice); CPPUNIT_TEST(testServiceChanged); CPPUNIT_TEST(testServiceRemoved); CPPUNIT_TEST(testServiceRemoved_UnregisteredService); CPPUNIT_TEST(testError_BrowseErrorAfterStart); CPPUNIT_TEST(testError_BrowseErrorAfterResolve); CPPUNIT_TEST(testRegisterService); CPPUNIT_TEST(testRegisterService_Error); CPPUNIT_TEST(testRegisterService_Reregister); CPPUNIT_TEST(testUpdateService); CPPUNIT_TEST_SUITE_END(); public: void setUp() { eventLoop = new DummyEventLoop(); - querier = boost::shared_ptr<FakeDNSSDQuerier>(new FakeDNSSDQuerier("wonderland.lit", eventLoop)); + querier = boost::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()); 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()); errorStopReceived = false; normalStopReceived = false; } void tearDown() { querier->clearAllQueriesEverRun(); addedServices.clear(); removedServices.clear(); changedServices.clear(); delete aliceServiceID; delete aliceServiceInfo; delete testServiceInfo2; delete testServiceInfo; delete testServiceID; delete eventLoop; } void testConstructor() { boost::shared_ptr<LinkLocalServiceBrowser> testling = createTestling(); CPPUNIT_ASSERT(!testling->isRunning()); CPPUNIT_ASSERT(!testling->hasError()); } void testStart() { boost::shared_ptr<LinkLocalServiceBrowser> testling = createTestling(); testling->start(); CPPUNIT_ASSERT(testling->isRunning()); |