diff options
author | Remko Tronçon <git@el-tramo.be> | 2009-07-30 19:15:34 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2009-07-30 22:08:39 (GMT) |
commit | c8634883470be42eaa674aab05db61c46b005608 (patch) | |
tree | f0c05e8488c6f7845481d9ef27a56336a8912c55 /Swiften/LinkLocal/UnitTest | |
parent | f1938c7096f2ab77fb438d285f1eadb094010b0a (diff) | |
download | swift-c8634883470be42eaa674aab05db61c46b005608.zip swift-c8634883470be42eaa674aab05db61c46b005608.tar.bz2 |
Make Slimber use the new LinkLocal framework.
XMPP Server is temporarily out of order.
Diffstat (limited to 'Swiften/LinkLocal/UnitTest')
-rw-r--r-- | Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp b/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp index 6e4d3b4..76117c0 100644 --- a/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp +++ b/Swiften/LinkLocal/UnitTest/LinkLocalServiceBrowserTest.cpp @@ -27,6 +27,7 @@ class LinkLocalServiceBrowserTest : public CppUnit::TestFixture { CPPUNIT_TEST(testRegisterService); CPPUNIT_TEST(testRegisterService_Error); CPPUNIT_TEST(testRegisterService_Reregister); + CPPUNIT_TEST(testUpdateService); CPPUNIT_TEST_SUITE_END(); public: @@ -239,7 +240,8 @@ class LinkLocalServiceBrowserTest : public CppUnit::TestFixture { eventLoop->processEvents(); CPPUNIT_ASSERT(querier->isServiceRegistered("foo@bar", 1234, info.toTXTRecord())); - + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(registeredServices.size())); + CPPUNIT_ASSERT(registeredServices[0] == DNSSDServiceID("foo@bar", "wonderland.lit")); testling->stop(); } @@ -279,6 +281,23 @@ class LinkLocalServiceBrowserTest : public CppUnit::TestFixture { testling->stop(); } + void testUpdateService() { + boost::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())); + + testling->stop(); + } + private: boost::shared_ptr<LinkLocalServiceBrowser> createTestling() { boost::shared_ptr<LinkLocalServiceBrowser> testling( @@ -289,6 +308,8 @@ class LinkLocalServiceBrowserTest : public CppUnit::TestFixture { &LinkLocalServiceBrowserTest::handleServiceChanged, this, _1)); testling->onServiceRemoved.connect(boost::bind( &LinkLocalServiceBrowserTest::handleServiceRemoved, this, _1)); + testling->onServiceRegistered.connect(boost::bind( + &LinkLocalServiceBrowserTest::handleServiceRegistered, this, _1)); testling->onStopped.connect(boost::bind( &LinkLocalServiceBrowserTest::handleStopped, this, _1)); return testling; @@ -306,6 +327,10 @@ class LinkLocalServiceBrowserTest : public CppUnit::TestFixture { changedServices.push_back(service); } + void handleServiceRegistered(const DNSSDServiceID& service) { + registeredServices.push_back(service); + } + void handleStopped(bool error) { CPPUNIT_ASSERT(!errorStopReceived); CPPUNIT_ASSERT(!normalStopReceived); @@ -323,6 +348,7 @@ class LinkLocalServiceBrowserTest : public CppUnit::TestFixture { std::vector<LinkLocalService> addedServices; std::vector<LinkLocalService> changedServices; std::vector<LinkLocalService> removedServices; + std::vector<DNSSDServiceID> registeredServices; DNSSDServiceID* aliceServiceID; DNSSDResolveServiceQuery::Result* aliceServiceInfo; DNSSDServiceID* testServiceID; |