From 181814572bf67d603d56a52a6fe3e12a2344c395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Wed, 21 Apr 2010 23:14:13 +0200 Subject: Fix non-determinism of DomainNameResolverTest. diff --git a/Swift/QtUI/QtSystemTray.cpp b/Swift/QtUI/QtSystemTray.cpp index 49c0812..de8de23 100644 --- a/Swift/QtUI/QtSystemTray.cpp +++ b/Swift/QtUI/QtSystemTray.cpp @@ -11,7 +11,7 @@ #include namespace Swift { -QtSystemTray::QtSystemTray() : QObject(), standardIcon_(":icons/tray-standard.png"), newMessageIcon_(":icons/new-chat.png") { +QtSystemTray::QtSystemTray() : QObject(), standardIcon_(":icons/online.png"), newMessageIcon_(":icons/new-chat.png") { trayIcon_ = new QSystemTrayIcon(standardIcon_); connect(trayIcon_, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(handleIconActivated(QSystemTrayIcon::ActivationReason))); trayIcon_->show(); diff --git a/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp b/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp index 7c99487..cd3c3e1 100644 --- a/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp +++ b/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp @@ -8,6 +8,8 @@ #include #include +#include + #include "Swiften/Base/sleep.h" #include "Swiften/Base/String.h" #include "Swiften/Base/ByteArray.h" @@ -18,6 +20,12 @@ using namespace Swift; +struct CompareHostAddresses { + bool operator()(const HostAddress& h1, const HostAddress& h2) { + return h1.toString() < h2.toString(); + } +}; + class DomainNameResolverTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(DomainNameResolverTest); CPPUNIT_TEST(testResolveAddress); @@ -82,8 +90,8 @@ class DomainNameResolverTest : public CppUnit::TestFixture { CPPUNIT_ASSERT(!addressQueryError); CPPUNIT_ASSERT_EQUAL(2, static_cast(addressQueryResult.size())); - CPPUNIT_ASSERT_EQUAL(std::string("1234:5678:9abc:def0:0fed:cba9:8765:4321"), addressQueryResult[0].toString()); - CPPUNIT_ASSERT_EQUAL(std::string("10.0.0.7"), addressQueryResult[1].toString()); + CPPUNIT_ASSERT_EQUAL(std::string("10.0.0.7"), addressQueryResult[0].toString()); + CPPUNIT_ASSERT_EQUAL(std::string("1234:5678:9abc:def0:0fed:cba9:8765:4321"), addressQueryResult[1].toString()); } void testResolveAddress_International() { @@ -104,8 +112,7 @@ class DomainNameResolverTest : public CppUnit::TestFixture { waitForResults(); CPPUNIT_ASSERT(!addressQueryError); - CPPUNIT_ASSERT_EQUAL(1, static_cast(addressQueryResult.size())); - CPPUNIT_ASSERT_EQUAL(std::string("127.0.0.1"), addressQueryResult[0].toString()); + CPPUNIT_ASSERT(std::find(addressQueryResult.begin(), addressQueryResult.end(), HostAddress("127.0.0.1")) != addressQueryResult.end()); } @@ -150,6 +157,7 @@ class DomainNameResolverTest : public CppUnit::TestFixture { void handleAddressQueryResult(const std::vector& addresses, boost::optional error) { addressQueryResult = addresses; + std::sort(addressQueryResult.begin(), addressQueryResult.end(), CompareHostAddresses()); addressQueryError = error; resultsAvailable = true; } -- cgit v0.10.2-6-g49f6