summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-04-05 12:10:17 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-04-06 19:31:39 (GMT)
commit725c4e1ad0710606421f9705d994688116a9fc1f (patch)
treec9297107c494e0858d6c626ae91936462add72e1 /Swiften/QA
parent29be0c8e4ebecd007ea0787a6c6decfedc4b4e4f (diff)
downloadswift-725c4e1ad0710606421f9705d994688116a9fc1f.zip
swift-725c4e1ad0710606421f9705d994688116a9fc1f.tar.bz2
Refactored DomainNameAddressQuery.
Result can now consist of multiple addresses.
Diffstat (limited to 'Swiften/QA')
-rw-r--r--Swiften/QA/NetworkTest/DomainNameResolverTest.cpp32
1 files changed, 24 insertions, 8 deletions
diff --git a/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp b/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp
index 09837d6..ec9d555 100644
--- a/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp
+++ b/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp
@@ -16,7 +16,8 @@ class DomainNameResolverTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(DomainNameResolverTest);
CPPUNIT_TEST(testResolveAddress);
CPPUNIT_TEST(testResolveAddress_Error);
- //CPPUNIT_TEST(testResolveAddress_IPv6);
+ CPPUNIT_TEST(testResolveAddress_IPv6);
+ CPPUNIT_TEST(testResolveAddress_IPv4and6);
CPPUNIT_TEST(testResolveAddress_International);
CPPUNIT_TEST(testResolveAddress_Localhost);
CPPUNIT_TEST(testResolveService);
@@ -44,7 +45,8 @@ class DomainNameResolverTest : public CppUnit::TestFixture {
waitForResults();
CPPUNIT_ASSERT(!addressQueryError);
- CPPUNIT_ASSERT_EQUAL(std::string("10.0.0.0"), addressQueryResult.toString());
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(addressQueryResult.size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("10.0.0.0"), addressQueryResult[0].toString());
}
void testResolveAddress_Error() {
@@ -63,7 +65,19 @@ class DomainNameResolverTest : public CppUnit::TestFixture {
waitForResults();
CPPUNIT_ASSERT(!addressQueryError);
- CPPUNIT_ASSERT_EQUAL(std::string("0000:0000:0000:0000:0000:ffff:0a00:0104"), addressQueryResult.toString());
+ CPPUNIT_ASSERT_EQUAL(std::string("0000:0000:0000:0000:0000:ffff:0a00:0104"), addressQueryResult[0].toString());
+ }
+
+ void testResolveAddress_IPv4and6() {
+ boost::shared_ptr<DomainNameAddressQuery> query(createAddressQuery("xmpp-ipv46.test.swift.im"));
+
+ query->run();
+ waitForResults();
+
+ CPPUNIT_ASSERT(!addressQueryError);
+ CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(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());
}
void testResolveAddress_International() {
@@ -73,7 +87,8 @@ class DomainNameResolverTest : public CppUnit::TestFixture {
waitForResults();
CPPUNIT_ASSERT(!addressQueryError);
- CPPUNIT_ASSERT_EQUAL(std::string("10.0.0.3"), addressQueryResult.toString());
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(addressQueryResult.size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("10.0.0.3"), addressQueryResult[0].toString());
}
void testResolveAddress_Localhost() {
@@ -83,7 +98,8 @@ class DomainNameResolverTest : public CppUnit::TestFixture {
waitForResults();
CPPUNIT_ASSERT(!addressQueryError);
- CPPUNIT_ASSERT_EQUAL(std::string("127.0.0.1"), addressQueryResult.toString());
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(addressQueryResult.size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("127.0.0.1"), addressQueryResult[0].toString());
}
@@ -126,8 +142,8 @@ class DomainNameResolverTest : public CppUnit::TestFixture {
return result;
}
- void handleAddressQueryResult(const HostAddress& address, boost::optional<DomainNameResolveError> error) {
- addressQueryResult = address;
+ void handleAddressQueryResult(const std::vector<HostAddress>& addresses, boost::optional<DomainNameResolveError> error) {
+ addressQueryResult = addresses;
addressQueryError = error;
resultsAvailable = true;
}
@@ -159,7 +175,7 @@ class DomainNameResolverTest : public CppUnit::TestFixture {
private:
DummyEventLoop* eventLoop;
bool resultsAvailable;
- HostAddress addressQueryResult;
+ std::vector<HostAddress> addressQueryResult;
boost::optional<DomainNameResolveError> addressQueryError;
std::vector<DomainNameServiceQuery::Result> serviceQueryResult;
PlatformDomainNameResolver* resolver;