test: add basic Task unit test

Only only two tests for now. We can iterate on this later :^)

This is to try to avoid breaking things again!
This commit is contained in:
flow 2022-04-07 19:03:29 -03:00
parent 167e32a69f
commit d0cda6d605
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469
2 changed files with 47 additions and 0 deletions

View File

@ -413,6 +413,11 @@ set(TASKS_SOURCES
tasks/SequentialTask.cpp tasks/SequentialTask.cpp
) )
add_unit_test(Task
SOURCES tasks/Task_test.cpp
LIBS Launcher_logic
)
set(SETTINGS_SOURCES set(SETTINGS_SOURCES
# Settings # Settings
settings/INIFile.cpp settings/INIFile.cpp

View File

@ -0,0 +1,42 @@
#include <QTest>
#include "TestUtil.h"
#include "Task.h"
/* Does nothing. Only used for testing. */
class BasicTask : public Task {
Q_OBJECT
public:
explicit BasicTask() : Task() {};
private:
void executeTask() override {};
};
class TaskTest : public QObject {
Q_OBJECT
private slots:
void test_SetStatus(){
BasicTask t;
QString status {"test status"};
t.setStatus(status);
QCOMPARE(t.getStatus(), status);
}
void test_SetProgress(){
BasicTask t;
int current = 42;
int total = 207;
t.setProgress(current, total);
QCOMPARE(t.getProgress(), current);
QCOMPARE(t.getTotalProgress(), total);
}
};
QTEST_GUILESS_MAIN(TaskTest)
#include "Task_test.moc"