Commit cf736e4c authored by Volker Krause's avatar Volker Krause
Browse files

Also make unit tests work against older KF versions without KI18nLocaleData

parent e5945d6e
......@@ -269,12 +269,20 @@ private Q_SLOTS:
QQmlEngine::setObjectOwnership(&controller, QQmlEngine::CppOwnership);
engine.newQObject(&controller);
// workaround for pre-KF5I18nLocaleData code for region lookups still in use on the CI
const auto isRegion = [](const QString &region, QLatin1String ref) {
if (region.size() == 2) {
return ref.startsWith(region);
}
return region == ref;
};
controller.setBatchId(mgr.batches().at(0)); // flight
auto args = controller.departureMapArguments().toVariant().toMap();
QCOMPARE(args.value(QLatin1String("departureGateName")).toString(), QLatin1String("A10"));
QCOMPARE(args.value(QLatin1String("endTime")).toDateTime(), QDateTime({2017, 9, 10}, {6, 45}, QTimeZone("Europe/Berlin")));
QCOMPARE(args.value(QLatin1String("placeName")).toString(), QLatin1String("Berlin Tegel"));
QCOMPARE(args.value(QLatin1String("region")).toString(), QLatin1String("DE-BE"));
QVERIFY(isRegion(args.value(QLatin1String("region")).toString(), QLatin1String("DE-BE")));
QCOMPARE(args.value(QLatin1String("timeZone")), QLatin1String("Europe/Berlin"));
args = controller.arrivalMapArguments().toVariant().toMap();
......@@ -284,7 +292,7 @@ private Q_SLOTS:
QCOMPARE(args.value(QLatin1String("departurePlatformName")).toString(), QLatin1String("3"));
QCOMPARE(args.value(QLatin1String("endTime")).toDateTime(), QDateTime({2017, 9, 10}, {11, 40}, QTimeZone("Europe/Zurich")));
QCOMPARE(args.value(QLatin1String("placeName")).toString(), QStringLiteral("Zürich"));
QCOMPARE(args.value(QLatin1String("region")).toString(), QLatin1String("CH-ZH"));
QVERIFY(isRegion(args.value(QLatin1String("region")).toString(), QLatin1String("CH-ZH")));
QCOMPARE(args.value(QLatin1String("timeZone")), QLatin1String("Europe/Zurich"));
controller.setBatchId(mgr.batches().at(1)); // first train leg
......@@ -295,7 +303,7 @@ private Q_SLOTS:
QCOMPARE(args.value(QLatin1String("departurePlatformName")).toString(), QLatin1String("3"));
QCOMPARE(args.value(QLatin1String("endTime")).toDateTime(), QDateTime({2017, 9, 10}, {11, 40}, QTimeZone("Europe/Zurich")));
QCOMPARE(args.value(QLatin1String("placeName")).toString(), QStringLiteral("Zürich Flughafen"));
QCOMPARE(args.value(QLatin1String("region")).toString(), QLatin1String("CH-ZH"));
QVERIFY(isRegion(args.value(QLatin1String("region")).toString(), QLatin1String("CH-ZH")));
QCOMPARE(args.value(QLatin1String("timeZone")), QLatin1String("Europe/Zurich"));
args = controller.arrivalMapArguments().toVariant().toMap();
......@@ -306,7 +314,7 @@ private Q_SLOTS:
QCOMPARE(args.value(QLatin1String("departurePlatformName")).toString(), QLatin1String("3"));
QCOMPARE(args.value(QLatin1String("endTime")).toDateTime(), QDateTime({2017, 9, 10}, {14, 8}, QTimeZone("Europe/Zurich")));
QCOMPARE(args.value(QLatin1String("placeName")).toString(), QLatin1String("Visp"));
QCOMPARE(args.value(QLatin1String("region")).toString(), QLatin1String("CH-VS"));
QVERIFY(isRegion(args.value(QLatin1String("region")).toString(), QLatin1String("CH-VS")));
QCOMPARE(args.value(QLatin1String("timeZone")), QLatin1String("Europe/Zurich"));
controller.setBatchId(mgr.batches().at(2)); // final train leg
......@@ -318,7 +326,7 @@ private Q_SLOTS:
QCOMPARE(args.value(QLatin1String("departurePlatformName")).toString(), QLatin1String("3"));
QCOMPARE(args.value(QLatin1String("endTime")).toDateTime(), QDateTime({2017, 9, 10}, {14, 8}, QTimeZone("Europe/Zurich")));
QCOMPARE(args.value(QLatin1String("placeName")).toString(), QLatin1String("Visp"));
QCOMPARE(args.value(QLatin1String("region")).toString(), QLatin1String("CH-VS"));
QVERIFY(isRegion(args.value(QLatin1String("region")).toString(), QLatin1String("CH-VS")));
QCOMPARE(args.value(QLatin1String("timeZone")), QLatin1String("Europe/Zurich"));
args = controller.arrivalMapArguments().toVariant().toMap();
......@@ -326,7 +334,7 @@ private Q_SLOTS:
QCOMPARE(args.value(QLatin1String("arrivalPlatformName")).toString(), QString());
QCOMPARE(args.value(QLatin1String("beginTime")).toDateTime(), QDateTime({2017, 9, 10}, {14, 53}, QTimeZone("Europe/Zurich")));
QCOMPARE(args.value(QLatin1String("placeName")).toString(), QLatin1String("Randa"));
QCOMPARE(args.value(QLatin1String("region")).toString(), QLatin1String("CH-VS"));
QVERIFY(isRegion(args.value(QLatin1String("region")).toString(), QLatin1String("CH-VS")));
QCOMPARE(args.value(QLatin1String("timeZone")), QLatin1String("Europe/Zurich"));
controller.setBatchId(mgr.batches().at(9)); // final return leg
......@@ -337,7 +345,7 @@ private Q_SLOTS:
QCOMPARE(args.value(QLatin1String("departureGateName")).toString(), QLatin1String("52"));
QCOMPARE(args.value(QLatin1String("endTime")).toDateTime(), QDateTime({2017, 9, 15}, {20, 50}, QTimeZone("Europe/Zurich")));
QCOMPARE(args.value(QLatin1String("placeName")).toString(), QStringLiteral("Zürich Flughafen"));
QCOMPARE(args.value(QLatin1String("region")).toString(), QLatin1String("CH-ZH"));
QVERIFY(isRegion(args.value(QLatin1String("region")).toString(), QLatin1String("CH-ZH")));
QCOMPARE(args.value(QLatin1String("timeZone")), QLatin1String("Europe/Zurich"));
controller.setBatchId(mgr.batches().at(10)); // return flight
......@@ -348,7 +356,7 @@ private Q_SLOTS:
QCOMPARE(args.value(QLatin1String("departureGateName")).toString(), QLatin1String("52"));
QCOMPARE(args.value(QLatin1String("endTime")).toDateTime(), QDateTime({2017, 9, 15}, {20, 50}, QTimeZone("Europe/Zurich")));
QCOMPARE(args.value(QLatin1String("placeName")).toString(), QStringLiteral("Zürich"));
QCOMPARE(args.value(QLatin1String("region")).toString(), QLatin1String("CH-ZH"));
QVERIFY(isRegion(args.value(QLatin1String("region")).toString(), QLatin1String("CH-ZH")));
QCOMPARE(args.value(QLatin1String("timeZone")), QLatin1String("Europe/Zurich"));
}
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment