test: add new test to Task test

Also adds one more check to setStatus test
This commit is contained in:
flow 2022-04-07 19:42:26 -03:00
parent d0cda6d605
commit eeae3eca67
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469

View File

@ -6,23 +6,49 @@
/* Does nothing. Only used for testing. */ /* Does nothing. Only used for testing. */
class BasicTask : public Task { class BasicTask : public Task {
Q_OBJECT Q_OBJECT
public:
explicit BasicTask() : Task() {}; friend class TaskTest;
private: private:
void executeTask() override {}; 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 { class TaskTest : public QObject {
Q_OBJECT Q_OBJECT
private slots: private slots:
void test_SetStatus(){ void test_SetStatus_NoMultiStep(){
BasicTask t; BasicTask t;
QString status {"test status"}; QString status {"test status"};
t.setStatus(status); t.setStatus(status);
QCOMPARE(t.getStatus(), 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(){ void test_SetProgress(){