Commit 111454b9 authored by Volker Krause's avatar Volker Krause
Browse files

Allow importing documents containing different data types

A side-effect of this is however that ApplicationController will now
need a full setup for all data types to import data, which requires
some changes to existing unit tests.
parent df5f591b
Pipeline #192486 passed with stage
in 3 minutes and 47 seconds
......@@ -92,17 +92,16 @@ private Q_SLOTS:
// combined reservation/ticket data
appController.importData(Test::readFile(QLatin1String(SOURCE_DIR "/data/mixed-reservation-ticket.json")));
QCOMPARE(resSpy.size(), 5);
QEXPECT_FAIL("", "hybrid import not implemented yet", Abort);
QCOMPARE(passMgr.rowCount(), 1);
QCOMPARE(infoSpy.size(), 6);
}
void testImportFile()
{
PkPassManager passMgr;
Test::clearAll(&passMgr);
QSignalSpy passSpy(&passMgr, &PkPassManager::passAdded);
QVERIFY(passSpy.isValid());
PkPassManager pkPassMgr;
Test::clearAll(&pkPassMgr);
QSignalSpy pkPassSpy(&pkPassMgr, &PkPassManager::passAdded);
QVERIFY(pkPassSpy.isValid());
ReservationManager resMgr;
Test::clearAll(&resMgr);
......@@ -113,28 +112,31 @@ private Q_SLOTS:
Test::clearAll(&docMgr);
HealthCertificateManager healthCertMgr;
PassManager passMgr;
Test::clearAll(&passMgr);
ApplicationController appController;
QSignalSpy infoSpy(&appController, &ApplicationController::infoMessage);
appController.setPkPassManager(&passMgr);
appController.setPkPassManager(&pkPassMgr);
appController.setReservationManager(&resMgr);
appController.setDocumentManager(&docMgr);
appController.setHealthCertificateManager(&healthCertMgr);
appController.setPassManager(&passMgr);
appController.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/4U8465-v1.json")));
QCOMPARE(resSpy.size(), 1);
QCOMPARE(passSpy.size(), 0);
QCOMPARE(pkPassSpy.size(), 0);
QCOMPARE(infoSpy.size(), 1);
appController.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/boardingpass-v1.pkpass")));
QCOMPARE(resSpy.size(), 2);
QCOMPARE(passSpy.size(), 1);
QCOMPARE(pkPassSpy.size(), 1);
QCOMPARE(infoSpy.size(), 2);
appController.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/iata-bcbp-demo.pdf")));
if (!hasZxing()) {
QSKIP("Built without ZXing");
}
QCOMPARE(resSpy.size(), 3);
QCOMPARE(passSpy.size(), 1);
QCOMPARE(pkPassSpy.size(), 1);
QCOMPARE(infoSpy.size(), 3);
QCOMPARE(docMgr.documents().size(), 1);
}
......
......@@ -86,9 +86,9 @@ private Q_SLOTS:
ldm.m_unitTestTime = QDateTime({2017, 9, 10}, {12, 0}, QTimeZone("Europe/Zurich")); // that's in the middle of the first train leg
ldm.setReservationManager(&resMgr);
ApplicationController ctrl;
ctrl.setReservationManager(&resMgr);
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
auto ctrl = Test::makeAppController();
ctrl->setReservationManager(&resMgr);
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
QCOMPARE(resMgr.batches().size(), 11);
const auto flight = resMgr.batches()[0];
......
......@@ -43,9 +43,9 @@ private Q_SLOTS:
QVERIFY(rmSpy.isValid());
QVERIFY(mgr.batches().empty());
ApplicationController ctrl;
ctrl.setReservationManager(&mgr);
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/4U8465-v1.json")));
auto ctrl = Test::makeAppController();
ctrl->setReservationManager(&mgr);
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/4U8465-v1.json")));
auto res = mgr.batches();
QCOMPARE(res.size(), 1);
......@@ -57,7 +57,7 @@ private Q_SLOTS:
QVERIFY(updateSpy.isEmpty());
QVERIFY(!mgr.reservation(resId).isNull());
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/4U8465-v2.json")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/4U8465-v2.json")));
QCOMPARE(addSpy.size(), 1);
QCOMPARE(updateSpy.size(), 1);
QCOMPARE(mgr.batches().size(), 1);
......@@ -95,9 +95,9 @@ private Q_SLOTS:
ReservationManager mgr;
Test::clearAll(&mgr);
ApplicationController ctrl;
ctrl.setPkPassManager(&passMgr);
ctrl.setReservationManager(&mgr);
auto ctrl = Test::makeAppController();
ctrl->setPkPassManager(&passMgr);
ctrl->setReservationManager(&mgr);
QSignalSpy addSpy(&mgr, &ReservationManager::reservationAdded);
QVERIFY(addSpy.isValid());
......@@ -107,11 +107,11 @@ private Q_SLOTS:
QVERIFY(mgr.batches().empty());
const auto passId = QStringLiteral("pass.booking.kde.org/MTIzNA==");
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/boardingpass-v1.pkpass")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/boardingpass-v1.pkpass")));
QCOMPARE(addSpy.size(), 1);
QVERIFY(updateSpy.isEmpty());
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/boardingpass-v2.pkpass")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/boardingpass-v2.pkpass")));
QCOMPARE(addSpy.size(), 1);
QCOMPARE(updateSpy.size(), 1);
}
......@@ -120,11 +120,11 @@ private Q_SLOTS:
{
ReservationManager mgr;
Test::clearAll(&mgr);
ApplicationController ctrl;
ctrl.setReservationManager(&mgr);
auto ctrl = Test::makeAppController();
ctrl->setReservationManager(&mgr);
QCOMPARE(mgr.batches().size(), 0);
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/google-multi-passenger-flight.json")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/google-multi-passenger-flight.json")));
QCOMPARE(mgr.batches().size(), 2);
const auto batchId = mgr.batches()[0];
......@@ -162,9 +162,9 @@ private Q_SLOTS:
QSignalSpy batchRenameSpy(&mgr, &ReservationManager::batchRenamed);
QSignalSpy batchRemovedSpy(&mgr, &ReservationManager::batchRemoved);
ApplicationController ctrl;
ctrl.setReservationManager(&mgr);
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/google-multi-passenger-flight.json")));
auto ctrl = Test::makeAppController();
ctrl->setReservationManager(&mgr);
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/google-multi-passenger-flight.json")));
QCOMPARE(batchAddSpy.size(), 2);
QCOMPARE(batchChangeSpy.size(), 2);
QCOMPARE(batchRenameSpy.size(), 0);
......@@ -320,10 +320,10 @@ private Q_SLOTS:
{
ReservationManager mgr;
Test::clearAll(&mgr);
ApplicationController ctrl;
ctrl.setReservationManager(&mgr);
auto ctrl = Test::makeAppController();
ctrl->setReservationManager(&mgr);
QCOMPARE(mgr.batches().size(), 0);
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
QCOMPARE(mgr.batches().size(), 11);
auto res = mgr.reservation(mgr.batches().at(0));
......@@ -338,7 +338,7 @@ private Q_SLOTS:
QSignalSpy batchRenameSpy(&mgr, &ReservationManager::batchRenamed);
QSignalSpy batchRemovedSpy(&mgr, &ReservationManager::batchRemoved);
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017-flight-cancellation.json")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017-flight-cancellation.json")));
QCOMPARE(mgr.batches().size(), 11);
QCOMPARE(batchAddSpy.size(), 0);
QCOMPARE(batchChangeSpy.size(), 0);
......
......@@ -46,18 +46,18 @@ private Q_SLOTS:
TripGroupManager::clear();
TripGroupManager tgMgr;
tgMgr.setReservationManager(&resMgr);
ApplicationController ctrl;
ctrl.setReservationManager(&resMgr);
auto ctrl = Test::makeAppController();
ctrl->setReservationManager(&resMgr);
StatisticsModel stats;
QSignalSpy changeSpy(&stats, &StatisticsModel::changed);
stats.setReservationManager(&resMgr);
stats.setTripGroupManager(&tgMgr);
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/akademy2017.json")));
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/akademy2018-program.json")));
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/timeline/flight-cancelation.json"))); // canceled flight, should not change stats
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/akademy2017.json")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/akademy2018-program.json")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/timeline/flight-cancelation.json"))); // canceled flight, should not change stats
stats.setTimeRange({}, {});
QVERIFY(!changeSpy.isEmpty());
......@@ -139,12 +139,12 @@ private Q_SLOTS:
{
ReservationManager resMgr;
Test::clearAll(&resMgr);
ApplicationController ctrl;
ctrl.setReservationManager(&resMgr);
auto ctrl = Test::makeAppController();
ctrl->setReservationManager(&resMgr);
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/akademy2017.json")));
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/akademy2018-program.json")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/akademy2017.json")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/akademy2018-program.json")));
StatisticsTimeRangeModel model;
QAbstractItemModelTester tester(&model);
......
......@@ -7,7 +7,9 @@
#ifndef TESTHELPER_H
#define TESTHELPER_H
#include <applicationcontroller.h>
#include <documentmanager.h>
#include <healthcertificatemanager.h>
#include <passmanager.h>
#include <pkpassmanager.h>
#include <reservationmanager.h>
......@@ -62,6 +64,20 @@ inline void clearAll(PassManager *passMgr)
Q_ASSERT(passMgr->rowCount() == 0);
}
/** Fully set up application controller. */
inline std::unique_ptr<ApplicationController> makeAppController()
{
std::unique_ptr<ApplicationController> ctrl(new ApplicationController);
auto healthMgr = new HealthCertificateManager(ctrl.get());
ctrl->setHealthCertificateManager(healthMgr);
auto passMgr = new PassManager(ctrl.get());
clearAll(passMgr);
ctrl->setPassManager(passMgr);
return ctrl;
}
}
#endif
......@@ -163,9 +163,9 @@ private Q_SLOTS:
ReservationManager mgr;
Test::clearAll(&mgr);
LiveDataManager ldm;
ApplicationController ctrl;
ctrl.setReservationManager(&mgr);
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
auto ctrl = Test::makeAppController();
ctrl->setReservationManager(&mgr);
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
TimelineDelegateController controller;
controller.setReservationManager(&mgr);
......@@ -205,9 +205,9 @@ private Q_SLOTS:
LiveData::clearStorage();
LiveDataManager ldm;
ldm.setReservationManager(&mgr);
ApplicationController ctrl;
ctrl.setReservationManager(&mgr);
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
auto ctrl = Test::makeAppController();
ctrl->setReservationManager(&mgr);
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
TimelineDelegateController controller;
controller.setReservationManager(&mgr);
......@@ -247,9 +247,9 @@ private Q_SLOTS:
{
ReservationManager mgr;
Test::clearAll(&mgr);
ApplicationController ctrl;
ctrl.setReservationManager(&mgr);
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/timeline/flight-cancelation.json")));
auto ctrl = Test::makeAppController();
ctrl->setReservationManager(&mgr);
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/timeline/flight-cancelation.json")));
TimelineDelegateController controller;
controller.setReservationManager(&mgr);
......@@ -266,9 +266,9 @@ private Q_SLOTS:
LiveDataManager ldm;
ldm.setReservationManager(&mgr);
TransferManager trfMgr;
ApplicationController ctrl;
ctrl.setReservationManager(&mgr);
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
auto ctrl = Test::makeAppController();
ctrl->setReservationManager(&mgr);
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
TimelineDelegateController controller;
controller.setReservationManager(&mgr);
......
......@@ -90,9 +90,9 @@ private Q_SLOTS:
Test::clearAll(&mgr);
ReservationManager resMgr;
Test::clearAll(&resMgr);
ApplicationController ctrl;
ctrl.setPkPassManager(&mgr);
ctrl.setReservationManager(&resMgr);
auto ctrl = Test::makeAppController();
ctrl->setPkPassManager(&mgr);
ctrl->setReservationManager(&resMgr);
TimelineModel model;
QAbstractItemModelTester tester(&model);
......@@ -107,7 +107,7 @@ private Q_SLOTS:
QCOMPARE(model.rowCount(), 1);
QCOMPARE(model.index(0, 0).data(TimelineModel::ElementTypeRole), TimelineElement::TodayMarker);
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/boardingpass-v1.pkpass")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/boardingpass-v1.pkpass")));
QCOMPARE(insertSpy.size(), 1);
QCOMPARE(insertSpy.at(0).at(1).toInt(), 0);
QCOMPARE(insertSpy.at(0).at(2).toInt(), 0);
......@@ -115,7 +115,7 @@ private Q_SLOTS:
QCOMPARE(model.rowCount(), 2);
QCOMPARE(model.index(0, 0).data(TimelineModel::ElementTypeRole), TimelineElement::Flight);
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/boardingpass-v2.pkpass")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/boardingpass-v2.pkpass")));
QCOMPARE(insertSpy.size(), 1);
QCOMPARE(updateSpy.size(), 1);
QCOMPARE(updateSpy.at(0).at(0).toModelIndex().row(), 0);
......@@ -132,8 +132,8 @@ private Q_SLOTS:
{
ReservationManager resMgr;
Test::clearAll(&resMgr);
ApplicationController ctrl;
ctrl.setReservationManager(&resMgr);
auto ctrl = Test::makeAppController();
ctrl->setReservationManager(&resMgr);
TimelineModel model;
QAbstractItemModelTester tester(&model);
......@@ -149,7 +149,7 @@ private Q_SLOTS:
QCOMPARE(model.rowCount(), 1);
QCOMPARE(model.index(0, 0).data(TimelineModel::ElementTypeRole), TimelineElement::TodayMarker);
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/haus-randa-v1.json")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/haus-randa-v1.json")));
QCOMPARE(insertSpy.size(), 3);
QCOMPARE(insertSpy.at(0).at(1).toInt(), 0);
QCOMPARE(insertSpy.at(0).at(2).toInt(), 0);
......@@ -164,7 +164,7 @@ private Q_SLOTS:
QCOMPARE(model.index(2, 0).data(TimelineModel::ElementRangeRole), TimelineElement::RangeEnd);
// move end date of a hotel booking: dataChanged on RangeBegin, move (or del/ins) on RangeEnd
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/haus-randa-v2.json")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/haus-randa-v2.json")));
QCOMPARE(insertSpy.size(), 5);
QCOMPARE(updateSpy.size(), 1);
QCOMPARE(rmSpy.size(), 2);
......@@ -187,8 +187,8 @@ private Q_SLOTS:
{
ReservationManager resMgr;
Test::clearAll(&resMgr);
ApplicationController ctrl;
ctrl.setReservationManager(&resMgr);
auto ctrl = Test::makeAppController();
ctrl->setReservationManager(&resMgr);
TimelineModel model;
QAbstractItemModelTester tester(&model);
......@@ -198,7 +198,7 @@ private Q_SLOTS:
QCOMPARE(model.rowCount(), 1);
QCOMPARE(model.index(0, 0).data(TimelineModel::ElementTypeRole), TimelineElement::TodayMarker);
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/flight-txl-lhr-sfo.json")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/flight-txl-lhr-sfo.json")));
QCOMPARE(model.rowCount(), 5); // 2x country info, 2x flights, today marker
QCOMPARE(model.index(0, 0).data(TimelineModel::ElementTypeRole), TimelineElement::Flight);
......@@ -389,8 +389,8 @@ private Q_SLOTS:
ReservationManager resMgr;
Test::clearAll(&resMgr);
ApplicationController ctrl;
ctrl.setReservationManager(&resMgr);
auto ctrl = Test::makeAppController();
ctrl->setReservationManager(&resMgr);
TimelineModel model;
QAbstractItemModelTester tester(&model);
model.setReservationManager(&resMgr);
......@@ -404,7 +404,7 @@ private Q_SLOTS:
QVERIFY(rmSpy.isValid());
// full import at runtime
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/google-multi-passenger-flight.json")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/google-multi-passenger-flight.json")));
QCOMPARE(model.rowCount(), 3); // 2x Flight, 1x TodayMarger
QCOMPARE(insertSpy.count(), 2);
QCOMPARE(updateSpy.count(), 2);
......@@ -464,8 +464,8 @@ private Q_SLOTS:
{
ReservationManager resMgr;
Test::clearAll(&resMgr);
ApplicationController ctrl;
ctrl.setReservationManager(&resMgr);
auto ctrl = Test::makeAppController();
ctrl->setReservationManager(&resMgr);
WeatherForecastManager weatherMgr;
weatherMgr.setTestModeEnabled(true);
......@@ -487,7 +487,7 @@ private Q_SLOTS:
QVERIFY(vp1.verify(&model));
// load something to define the current location, so we get weather
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/flight-txl-lhr-sfo.json")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/flight-txl-lhr-sfo.json")));
ModelVerificationPoint vp2(QLatin1String(SOURCE_DIR "/data/timeline/daychange-r2.model"));
vp2.setRoleFilter({TimelineModel::BatchIdRole});
QVERIFY(vp2.verify(&model));
......@@ -516,9 +516,9 @@ private Q_SLOTS:
QFETCH(QString, baseName);
ReservationManager resMgr;
Test::clearAll(&resMgr);
ApplicationController ctrl;
ctrl.setReservationManager(&resMgr);
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/timeline/") + baseName + QLatin1String(".json")));
auto ctrl = Test::makeAppController();
ctrl->setReservationManager(&resMgr);
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/timeline/") + baseName + QLatin1String(".json")));
TripGroupManager groupMgr;
groupMgr.setReservationManager(&resMgr);
WeatherForecastManager weatherMgr;
......@@ -559,7 +559,7 @@ private Q_SLOTS:
// retry with loading during runtime
Test::clearAll(&resMgr);
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/timeline/") + baseName + QLatin1String(".json")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/timeline/") + baseName + QLatin1String(".json")));
QVERIFY(vp.verify(&model));
}
......@@ -567,8 +567,8 @@ private Q_SLOTS:
{
ReservationManager resMgr;
Test::clearAll(&resMgr);
ApplicationController ctrl;
ctrl.setReservationManager(&resMgr);
auto ctrl = Test::makeAppController();
ctrl->setReservationManager(&resMgr);
TimelineModel model;
model.setCurrentDateTime(QDateTime({2017, 8, 1}, {23, 0}, QTimeZone("Europe/Zurich")));
......@@ -577,7 +577,7 @@ private Q_SLOTS:
QSignalSpy currentResChangedSpy(&model, &TimelineModel::currentBatchChanged);
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
QCOMPARE(model.rowCount(), 13);
QVERIFY(!currentResChangedSpy.empty());
......
......@@ -49,9 +49,9 @@ private Q_SLOTS:
{
ReservationManager mgr;
Test::clearAll(&mgr);
ApplicationController ctrl;
ctrl.setReservationManager(&mgr);
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
auto ctrl = Test::makeAppController();
ctrl->setReservationManager(&mgr);
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
TimelineModel model;
model.setCurrentDateTime(QDateTime({2021, 3, 7}, {8, 0}));
......@@ -91,10 +91,10 @@ private Q_SLOTS:
{
ReservationManager mgr;
Test::clearAll(&mgr);
ApplicationController ctrl;
ctrl.setReservationManager(&mgr);
auto ctrl = Test::makeAppController();
ctrl->setReservationManager(&mgr);
// test data puts our known location to DE-BY and then adds a hotel in DE-BE for the BY-only public holiday on 2022-06-16
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/bug455083.json")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/bug455083.json")));
TimelineModel model;
model.setCurrentDateTime(QDateTime({2022, 6, 14}, {8, 0}));
......
......@@ -35,8 +35,8 @@ private Q_SLOTS:
{
ReservationManager resMgr;
Test::clearAll(&resMgr);
ApplicationController ctrl;
ctrl.setReservationManager(&resMgr);
auto ctrl = Test::makeAppController();
ctrl->setReservationManager(&resMgr);
TripGroupManager::clear();
TripGroupManager tgMgr;
......@@ -66,7 +66,7 @@ private Q_SLOTS:
QSignalSpy changeSpy(&mgr, &TransferManager::transferChanged);
QSignalSpy removeSpy(&mgr, &TransferManager::transferRemoved);
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
// ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/akademy2017.json")));
// ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/akademy2018-program.json")));
......
......@@ -38,10 +38,10 @@ private Q_SLOTS:
mgr.setReservationManager(&resMgr);
WeatherForecastManager fcMgr;
fcMgr.setTestModeEnabled(true);
ApplicationController ctrl;
ctrl.setReservationManager(&resMgr);
auto ctrl = Test::makeAppController();
ctrl->setReservationManager(&resMgr);
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
QCOMPARE(mgr.tripGroups().size(), 1);
TripGroupInfoProvider provider;
......
......@@ -45,11 +45,11 @@ private Q_SLOTS:
{
ReservationManager resMgr;
Test::clearAll(&resMgr);
ApplicationController ctrl;
ctrl.setReservationManager(&resMgr);
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/timeline/multi-traveler-merge-with-countryinfo.json")));
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/google-multi-passenger-flight.json")));
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
auto ctrl = Test::makeAppController();
ctrl->setReservationManager(&resMgr);
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/timeline/multi-traveler-merge-with-countryinfo.json")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/google-multi-passenger-flight.json")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
TripGroupManager groupMgr;
QSignalSpy addSpy(&groupMgr, &TripGroupManager::tripGroupAdded);
......@@ -101,9 +101,9 @@ private Q_SLOTS:
{
ReservationManager resMgr;
Test::clearAll(&resMgr);
ApplicationController ctrl;
ctrl.setReservationManager(&resMgr);
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
auto ctrl = Test::makeAppController();
ctrl->setReservationManager(&resMgr);
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
TripGroupManager groupMgr;
QSignalSpy addSpy(&groupMgr, &TripGroupManager::tripGroupAdded);
......
......@@ -42,9 +42,9 @@ private Q_SLOTS:
{
ReservationManager resMgr;
Test::clearAll(&resMgr);
ApplicationController ctrl;
ctrl.setReservationManager(&resMgr);
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/google-multi-passenger-flight.json")));
auto ctrl = Test::makeAppController();
ctrl->setReservationManager(&resMgr);
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/google-multi-passenger-flight.json")));
{
TripGroupManager mgr;
QSignalSpy addSpy(&mgr, &TripGroupManager::tripGroupAdded);
......@@ -57,7 +57,7 @@ private Q_SLOTS:
TripGroupManager::clear();
Test::clearAll(&resMgr);
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
{
TripGroupManager mgr;
QSignalSpy addSpy(&mgr, &TripGroupManager::tripGroupAdded);
......@@ -70,7 +70,7 @@ private Q_SLOTS:
TripGroupManager::clear();
Test::clearAll(&resMgr);
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/timeline/multi-traveler-merge-with-countryinfo.json")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/timeline/multi-traveler-merge-with-countryinfo.json")));
{
TripGroupManager mgr;
QSignalSpy addSpy(&mgr, &TripGroupManager::tripGroupAdded);
......@@ -82,8 +82,8 @@ private Q_SLOTS:
}
TripGroupManager::clear();
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/google-multi-passenger-flight.json")));
ctrl.importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/data/google-multi-passenger-flight.json")));
ctrl->importFromUrl(QUrl::fromLocalFile(QLatin1String(SOURCE_DIR "/../tests/randa2017.json")));
{