summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-03-31 14:57:35 (GMT)
committerTobias Markmann <tm@ayena.de>2016-03-31 14:57:35 (GMT)
commitcfbdb43d2cadd40aa87338d41548e4bf89e146e6 (patch)
tree18d94153a302445196fc0c18586abf44a1ce4a38 /Swiften/QA/DNSSDTest
parent1d545a4a7fb877f021508094b88c1f17b30d8b4e (diff)
downloadswift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.zip
swift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.tar.bz2
Convert tabs to 4 spaces for all source files
Removed trailing spaces and whitespace on empty lines in the process. Changed CheckTabs.py tool to disallow hard tabs in source files. Test-Information: Manually checked 30 random files that the conversion worked as expected. Change-Id: I874f99d617bd3d2bb55f02d58f22f58f9b094480
Diffstat (limited to 'Swiften/QA/DNSSDTest')
-rw-r--r--Swiften/QA/DNSSDTest/DNSSDTest.cpp228
1 files changed, 114 insertions, 114 deletions
diff --git a/Swiften/QA/DNSSDTest/DNSSDTest.cpp b/Swiften/QA/DNSSDTest/DNSSDTest.cpp
index bd06445..3b7191d 100644
--- a/Swiften/QA/DNSSDTest/DNSSDTest.cpp
+++ b/Swiften/QA/DNSSDTest/DNSSDTest.cpp
@@ -28,120 +28,120 @@ using namespace Swift;
template <typename DNSSDQuerierType>
class DNSSDTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(DNSSDTest);
- CPPUNIT_TEST(testPublish);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void setUp() {
- eventLoop = new DummyEventLoop();
- querier = boost::shared_ptr<DNSSDQuerier>(new DNSSDQuerierType());
- querier->start();
- }
-
- void tearDown() {
- querier->stop();
- querier.reset();
- delete eventLoop;
- }
-
- void testPublish() {
- boost::shared_ptr<DNSSDBrowseQuery> browseQuery = querier->createBrowseQuery();
- browseQuery->onServiceAdded.connect(boost::bind(&DNSSDTest::handleServiceAdded, this, _1));
- browseQuery->onServiceRemoved.connect(boost::bind(&DNSSDTest::handleServiceRemoved, this, _1));
- browseQuery->onError.connect(boost::bind(&DNSSDTest::handleBrowseError, this));
- browseQuery->startBrowsing();
- eventLoop->processEvents();
-
- // Publish the service
- LinkLocalServiceInfo info;
- boost::shared_ptr<DNSSDRegisterQuery> registerQuery = querier->createRegisterQuery("DNSSDTest", 1234, info.toTXTRecord());
- registerQuery->onRegisterFinished.connect(boost::bind(&DNSSDTest::handleRegisterFinished, this, _1));
- registerQuery->registerService();
-
- // Wait for a while
- wait();
-
- // Check that our registered queries are correct
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>((registered.size())));
- CPPUNIT_ASSERT_EQUAL(std::string("DNSSDTest"), registered[0].getName());
- CPPUNIT_ASSERT_EQUAL(std::string("local"), registered[0].getDomain());
- CPPUNIT_ASSERT_EQUAL(std::string("_presence._tcp"), registered[0].getType());
-
- // Check that our browse query discovered us
- std::sort(added.begin(), added.end());
- CPPUNIT_ASSERT(added.size() >= 1);
- //for (size_t i = 0; i < added.size(); ++i) {
- for (size_t i = 0; i < added.size(); ++i) {
- CPPUNIT_ASSERT_EQUAL(std::string("DNSSDTest"), added[i].getName());
- CPPUNIT_ASSERT_EQUAL(std::string("local"), added[i].getDomain());
- CPPUNIT_ASSERT_EQUAL(std::string("_presence._tcp"), added[i].getType());
- CPPUNIT_ASSERT(added[i].getNetworkInterfaceID() != 0);
- }
-
- // Resolve all added services
- for (size_t i = 0; i < added.size(); ++i) {
- resolvedServices.clear();
- boost::shared_ptr<DNSSDResolveServiceQuery> resolveServiceQuery = querier->createResolveServiceQuery(added[i]);
- resolveServiceQuery->onServiceResolved.connect(boost::bind(&DNSSDTest::handleResolveFinished, this, _1));
- resolveServiceQuery->start();
- wait();
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(resolvedServices.size()));
- resolveServiceQuery->stop();
- }
-
- // Unregister the service & check if the browse query picks this up
- toRemove.clear();
- toRemove.insert(toRemove.begin(), added.begin(), added.end());
- registerQuery->unregisterService();
- while (!toRemove.empty()) {
- Swift::sleep(100);
- eventLoop->processEvents();
- }
-
- browseQuery->stopBrowsing();
- eventLoop->processEvents();
- }
-
- private:
- void handleServiceAdded(const DNSSDServiceID& id) {
- std::cout << "Service added: " << id.getNetworkInterfaceID() << std::endl;
- added.push_back(id);
- }
-
- void handleServiceRemoved(const DNSSDServiceID& id) {
- CPPUNIT_ASSERT(std::find(toRemove.begin(), toRemove.end(), id) != toRemove.end());
- erase(toRemove, id);
- }
-
- void handleRegisterFinished(boost::optional<DNSSDServiceID> id) {
- if (id) {
- registered.push_back(*id);
- }
- }
-
- void handleBrowseError() {
- }
-
- void wait() {
- for (int i = 0; i < SLEEP_INTERVALS; ++i) {
- Swift::sleep(100);
- eventLoop->processEvents();
- }
- }
-
- void handleResolveFinished(const boost::optional<DNSSDResolveServiceQuery::Result>& result) {
- CPPUNIT_ASSERT(result);
- resolvedServices.push_back(*result);
- }
-
- private:
- DummyEventLoop* eventLoop;
- boost::shared_ptr<DNSSDQuerier> querier;
- std::vector<DNSSDServiceID> added;
- std::vector<DNSSDServiceID> registered;
- std::vector<DNSSDServiceID> toRemove;
- std::vector<DNSSDResolveServiceQuery::Result> resolvedServices;
+ CPPUNIT_TEST_SUITE(DNSSDTest);
+ CPPUNIT_TEST(testPublish);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void setUp() {
+ eventLoop = new DummyEventLoop();
+ querier = boost::shared_ptr<DNSSDQuerier>(new DNSSDQuerierType());
+ querier->start();
+ }
+
+ void tearDown() {
+ querier->stop();
+ querier.reset();
+ delete eventLoop;
+ }
+
+ void testPublish() {
+ boost::shared_ptr<DNSSDBrowseQuery> browseQuery = querier->createBrowseQuery();
+ browseQuery->onServiceAdded.connect(boost::bind(&DNSSDTest::handleServiceAdded, this, _1));
+ browseQuery->onServiceRemoved.connect(boost::bind(&DNSSDTest::handleServiceRemoved, this, _1));
+ browseQuery->onError.connect(boost::bind(&DNSSDTest::handleBrowseError, this));
+ browseQuery->startBrowsing();
+ eventLoop->processEvents();
+
+ // Publish the service
+ LinkLocalServiceInfo info;
+ boost::shared_ptr<DNSSDRegisterQuery> registerQuery = querier->createRegisterQuery("DNSSDTest", 1234, info.toTXTRecord());
+ registerQuery->onRegisterFinished.connect(boost::bind(&DNSSDTest::handleRegisterFinished, this, _1));
+ registerQuery->registerService();
+
+ // Wait for a while
+ wait();
+
+ // Check that our registered queries are correct
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>((registered.size())));
+ CPPUNIT_ASSERT_EQUAL(std::string("DNSSDTest"), registered[0].getName());
+ CPPUNIT_ASSERT_EQUAL(std::string("local"), registered[0].getDomain());
+ CPPUNIT_ASSERT_EQUAL(std::string("_presence._tcp"), registered[0].getType());
+
+ // Check that our browse query discovered us
+ std::sort(added.begin(), added.end());
+ CPPUNIT_ASSERT(added.size() >= 1);
+ //for (size_t i = 0; i < added.size(); ++i) {
+ for (size_t i = 0; i < added.size(); ++i) {
+ CPPUNIT_ASSERT_EQUAL(std::string("DNSSDTest"), added[i].getName());
+ CPPUNIT_ASSERT_EQUAL(std::string("local"), added[i].getDomain());
+ CPPUNIT_ASSERT_EQUAL(std::string("_presence._tcp"), added[i].getType());
+ CPPUNIT_ASSERT(added[i].getNetworkInterfaceID() != 0);
+ }
+
+ // Resolve all added services
+ for (size_t i = 0; i < added.size(); ++i) {
+ resolvedServices.clear();
+ boost::shared_ptr<DNSSDResolveServiceQuery> resolveServiceQuery = querier->createResolveServiceQuery(added[i]);
+ resolveServiceQuery->onServiceResolved.connect(boost::bind(&DNSSDTest::handleResolveFinished, this, _1));
+ resolveServiceQuery->start();
+ wait();
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(resolvedServices.size()));
+ resolveServiceQuery->stop();
+ }
+
+ // Unregister the service & check if the browse query picks this up
+ toRemove.clear();
+ toRemove.insert(toRemove.begin(), added.begin(), added.end());
+ registerQuery->unregisterService();
+ while (!toRemove.empty()) {
+ Swift::sleep(100);
+ eventLoop->processEvents();
+ }
+
+ browseQuery->stopBrowsing();
+ eventLoop->processEvents();
+ }
+
+ private:
+ void handleServiceAdded(const DNSSDServiceID& id) {
+ std::cout << "Service added: " << id.getNetworkInterfaceID() << std::endl;
+ added.push_back(id);
+ }
+
+ void handleServiceRemoved(const DNSSDServiceID& id) {
+ CPPUNIT_ASSERT(std::find(toRemove.begin(), toRemove.end(), id) != toRemove.end());
+ erase(toRemove, id);
+ }
+
+ void handleRegisterFinished(boost::optional<DNSSDServiceID> id) {
+ if (id) {
+ registered.push_back(*id);
+ }
+ }
+
+ void handleBrowseError() {
+ }
+
+ void wait() {
+ for (int i = 0; i < SLEEP_INTERVALS; ++i) {
+ Swift::sleep(100);
+ eventLoop->processEvents();
+ }
+ }
+
+ void handleResolveFinished(const boost::optional<DNSSDResolveServiceQuery::Result>& result) {
+ CPPUNIT_ASSERT(result);
+ resolvedServices.push_back(*result);
+ }
+
+ private:
+ DummyEventLoop* eventLoop;
+ boost::shared_ptr<DNSSDQuerier> querier;
+ std::vector<DNSSDServiceID> added;
+ std::vector<DNSSDServiceID> registered;
+ std::vector<DNSSDServiceID> toRemove;
+ std::vector<DNSSDResolveServiceQuery::Result> resolvedServices;
};
#ifdef HAVE_AVAHI