diff --git a/src/libcalamares/geoip/GeoIPTests.cpp b/src/libcalamares/geoip/GeoIPTests.cpp index 4b1f8f8e1..7dd8c92b0 100644 --- a/src/libcalamares/geoip/GeoIPTests.cpp +++ b/src/libcalamares/geoip/GeoIPTests.cpp @@ -18,6 +18,7 @@ #include "GeoIPTests.h" +#include "GeoIPFixed.h" #include "GeoIPJSON.h" #ifdef QT_XML_LIB #include "GeoIPXML.h" @@ -240,3 +241,35 @@ GeoIPTests::testGet() CHECK_GET( XML, QString(), "https://geoip.kde.org/v1/ubiquity" ) // Temporary KDE service #endif } + +void +GeoIPTests::testFixed() +{ + { + GeoIPFixed f; + auto tz = f.processReply( QByteArray() ); + QCOMPARE( tz.first, QStringLiteral( "Europe" ) ); + QCOMPARE( tz.second, QStringLiteral( "Amsterdam" ) ); + + QCOMPARE( f.processReply( xml_data_ubiquity ), tz ); + QCOMPARE( f.processReply( QByteArray( "derp" ) ), tz ); + } + { + GeoIPFixed f( QStringLiteral( "America/Vancouver" ) ); + auto tz = f.processReply( QByteArray() ); + QCOMPARE( tz.first, QStringLiteral( "America" ) ); + QCOMPARE( tz.second, QStringLiteral( "Vancouver" ) ); + + QCOMPARE( f.processReply( xml_data_ubiquity ), tz ); + QCOMPARE( f.processReply( QByteArray( "derp" ) ), tz ); + } + { + GeoIPFixed f( QStringLiteral( "America/North Dakota/Beulah" ) ); + auto tz = f.processReply( QByteArray() ); + QCOMPARE( tz.first, QStringLiteral( "America" ) ); + QCOMPARE( tz.second, QStringLiteral( "North_Dakota/Beulah" ) ); + + QCOMPARE( f.processReply( xml_data_ubiquity ), tz ); + QCOMPARE( f.processReply( QByteArray( "derp" ) ), tz ); + } +} diff --git a/src/libcalamares/geoip/GeoIPTests.h b/src/libcalamares/geoip/GeoIPTests.h index a320e3263..45aae23e7 100644 --- a/src/libcalamares/geoip/GeoIPTests.h +++ b/src/libcalamares/geoip/GeoIPTests.h @@ -30,6 +30,7 @@ public: private Q_SLOTS: void initTestCase(); + void testFixed(); void testJSON(); void testJSONalt(); void testJSONbad();