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:
parent
167e32a69f
commit
d0cda6d605
@ -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
|
||||||
|
42
launcher/tasks/Task_test.cpp
Normal file
42
launcher/tasks/Task_test.cpp
Normal 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"
|
Loading…
Reference in New Issue
Block a user