diff options
author | Sefa Eyeoglu <contact@scrumplex.net> | 2022-04-08 09:45:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-08 09:45:06 +0200 |
commit | ab8d897bd7070554daa2890088a472c9e5a1d2f1 (patch) | |
tree | 02e7c557ab5db262270624d3dde19e416225b141 /launcher/tasks/Task_test.cpp | |
parent | c3f1c13a31ab92778ad89160dfc0e73358b29ae3 (diff) | |
parent | eeae3eca6719a43a3dd868c37e9f31b4463f4924 (diff) | |
download | PrismLauncher-ab8d897bd7070554daa2890088a472c9e5a1d2f1.tar.gz PrismLauncher-ab8d897bd7070554daa2890088a472c9e5a1d2f1.tar.bz2 PrismLauncher-ab8d897bd7070554daa2890088a472c9e5a1d2f1.zip |
Merge pull request #409 from flowln/tasks
Diffstat (limited to 'launcher/tasks/Task_test.cpp')
-rw-r--r-- | launcher/tasks/Task_test.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/launcher/tasks/Task_test.cpp b/launcher/tasks/Task_test.cpp new file mode 100644 index 00000000..9b6cc2e5 --- /dev/null +++ b/launcher/tasks/Task_test.cpp @@ -0,0 +1,68 @@ +#include <QTest> +#include "TestUtil.h" + +#include "Task.h" + +/* Does nothing. Only used for testing. */ +class BasicTask : public Task { + Q_OBJECT + + friend class TaskTest; + + private: + void executeTask() override {}; +}; + +/* Does nothing. Only used for testing. */ +class BasicTask_MultiStep : public Task { + Q_OBJECT + + friend class TaskTest; + + private: + auto isMultiStep() const -> bool override { return true; } + + void executeTask() override {}; +}; + +class TaskTest : public QObject { + Q_OBJECT + + private slots: + void test_SetStatus_NoMultiStep(){ + BasicTask t; + QString status {"test status"}; + + t.setStatus(status); + + QCOMPARE(t.getStatus(), status); + QCOMPARE(t.getStepStatus(), status); + } + + void test_SetStatus_MultiStep(){ + BasicTask_MultiStep t; + QString status {"test status"}; + + t.setStatus(status); + + QCOMPARE(t.getStatus(), status); + // Even though it is multi step, it does not override the getStepStatus method, + // so it should remain the same. + QCOMPARE(t.getStepStatus(), 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" |