DoctorPill/tests/units/basetest.cpp

66 lines
1.2 KiB
C++
Raw Normal View History

2022-01-17 17:31:44 +03:00
//#
2023-12-31 10:02:22 +01:00
//# Copyright (C) 2020-2024 QuasarApp.
2022-01-17 17:31:44 +03:00
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#include "basetest.h"
#include <DoctorPillCore/ipill.h>
class TestPill: public DP::iPill {
// iPill interface
public:
TestPill(BaseTest* app) {
_app = app;
};
2022-02-03 11:44:16 +03:00
int id() const override {
return typeid (this).hash_code();
};
2022-01-17 17:31:44 +03:00
QString name() const override {
return "Test pill";
};
QString description() const override {
return "just test pill";
};
protected:
2022-07-11 16:57:22 +03:00
bool diagnostic() override {
2022-01-17 17:31:44 +03:00
return _app->_appIsBroken;
};
2022-07-11 16:57:22 +03:00
bool fix() override {
2022-01-17 17:31:44 +03:00
_app->_appIsBroken = false;
return !_app->_appIsBroken;
};
private:
BaseTest * _app = nullptr;
};
BaseTest::BaseTest() {
}
BaseTest::~BaseTest() {
}
void BaseTest::test() {
_appIsBroken = true;
QVERIFY(_test.test({QSharedPointer<TestPill>::create(this)}, _appIsBroken));
QVERIFY(!_appIsBroken);
QVERIFY(_test.test({QSharedPointer<TestPill>::create(this)}, _appIsBroken));
QVERIFY(!_appIsBroken);
}