/* This file is part of the KDE project SPDX-FileCopyrightText: 2007-2011 Dag Andersen SPDX-License-Identifier: LGPL-2.0-or-later */ // clazy:excludeall=qstring-arg #include "SchedulerTester.h" #include "PlanTJScheduler.h" #include "kptcommand.h" #include "kptcalendar.h" #include "kptdatetime.h" #include "kptresource.h" #include "kptnode.h" #include "kpttask.h" #include "kptschedule.h" #include "kptxmlloaderobject.h" #include #include "tests/DateTimeTester.h" #include "tests/debug.cpp" namespace KPlato { QStringList SchedulerTester::data() { return QStringList() << "test1.plan" << "startnotearlier.plan" ; } void SchedulerTester::loadDocument(const QString &dir, const QString &fname, KoXmlDocument &doc) const { QFile file(dir + fname); QVERIFY2(file.open(QIODevice::ReadOnly), fname.toLatin1()); QString error; bool setContent; int line, column; if (! (setContent = doc.setContent(&file, &error, &line, &column))) { file.close(); QString s = QString("%1: %2 Line %3, column %4").arg(fname).arg(error).arg(line).arg(column); QVERIFY2(setContent, s.toLatin1()); } } void SchedulerTester::testSingle() { QString dir = QFINDTESTDATA("data/"); const auto lst = data(); for (const QString &fname : lst) { qDebug()<<"Testing file:"<calculationResult() != ScheduleManager::CalculationDone) { Debug::printSchedulingLog(*sm, "----"); } s = QString("%1: Scheduling failed").arg(fname); QVERIFY2(sm->calculationResult() == ScheduleManager::CalculationDone, s.toLatin1()); long id1 = manager->scheduleId(); long id2 = sm->scheduleId(); qDebug()<<"Project start, finish:"<name()); QVERIFY2(n->startTime(id1) == n->startTime(id2), (s.arg(n->startTime(id1).toString(Qt::ISODate)).arg(n->startTime(id2).toString(Qt::ISODate))).toLatin1()); QVERIFY2(n->endTime(id1) == n->endTime(id2), (s.arg(n->endTime(id1).toString(Qt::ISODate)).arg(n->endTime(id2).toString(Qt::ISODate))).toLatin1()); } void SchedulerTester::loadDocuments(QString &dir, QList files, QList &docs) const { for (const QString &fname : files) { QFile file(dir + fname); QVERIFY2(file.open(QIODevice::ReadOnly), fname.toLatin1()); KoXmlDocument doc; loadDocument(dir, fname, doc); docs << doc; } } } //namespace KPlato QTEST_GUILESS_MAIN(KPlato::SchedulerTester)