diff --git a/src/modules/locale/GeoIPTests.cpp b/src/modules/locale/GeoIPTests.cpp
index 4848f1a2d..554e6f0c0 100644
--- a/src/modules/locale/GeoIPTests.cpp
+++ b/src/modules/locale/GeoIPTests.cpp
@@ -40,14 +40,14 @@ GeoIPTests::initTestCase()
{
}
+static const char json_data_attribute[] =
+ "{\"time_zone\":\"Europe/Amsterdam\"}";
+
void
GeoIPTests::testJSON()
{
- static const char data[] =
- "{\"time_zone\":\"Europe/Amsterdam\"}";
-
GeoIPJSON handler;
- auto tz = handler.processReply( data );
+ auto tz = handler.processReply( json_data_attribute );
QCOMPARE( tz.first, QLatin1String( "Europe" ) );
QCOMPARE( tz.second, QLatin1String( "Amsterdam" ) );
@@ -60,6 +60,18 @@ GeoIPTests::testJSON()
QCOMPARE( tz.first, "America" );
}
+void GeoIPTests::testJSONalt()
+{
+ GeoIPJSON handler( "zona_de_hora" );
+
+ auto tz = handler.processReply( json_data_attribute );
+ QCOMPARE( tz.first, QString() ); // Not found
+
+ tz = handler.processReply( "tarifa: 12\nzona_de_hora: Europe/Madrid" );
+ QCOMPARE( tz.first, QLatin1String( "Europe" ) );
+ QCOMPARE( tz.second, QLatin1String( "Madrid" ) );
+}
+
void
GeoIPTests::testJSONbad()
{
@@ -82,10 +94,7 @@ GeoIPTests::testJSONbad()
}
-void
-GeoIPTests::testXML()
-{
- static const char data[] =
+static const char xml_data_ubiquity[] =
R"(
85.150.1.1
OK
@@ -102,9 +111,12 @@ GeoIPTests::testXML()
Europe/Amsterdam
)";
+void
+GeoIPTests::testXML()
+{
#ifdef HAVE_XML
GeoIPXML handler;
- auto tz = handler.processReply( data );
+ auto tz = handler.processReply( xml_data_ubiquity );
QCOMPARE( tz.first, QLatin1String( "Europe" ) );
QCOMPARE( tz.second, QLatin1String( "Amsterdam" ) );
@@ -126,6 +138,18 @@ GeoIPTests::testXML2()
#endif
}
+
+void GeoIPTests::testXMLalt()
+{
+#ifdef HAvE_XML
+ GeoIPXML handler( "ZT" );
+
+ auto tz = handler.processReply( "Moon/Dark_side" );
+ QCOMPARE( tz.first, QLatin1String( "Moon" ) );
+ QCOMPARE( tz.second, QLatin1String( "Dark_side" ) );
+#endif
+}
+
void
GeoIPTests::testXMLbad()
{
diff --git a/src/modules/locale/GeoIPTests.h b/src/modules/locale/GeoIPTests.h
index e673a0740..87918ace0 100644
--- a/src/modules/locale/GeoIPTests.h
+++ b/src/modules/locale/GeoIPTests.h
@@ -31,9 +31,11 @@ public:
private Q_SLOTS:
void initTestCase();
void testJSON();
+ void testJSONalt();
void testJSONbad();
void testXML();
void testXML2();
+ void testXMLalt();
void testXMLbad();
};