refactor: fix some minor clang-tidy warnings

This commit is contained in:
Evgenii Alekseev 2024-04-19 17:59:10 +03:00
parent 2f4f05b5af
commit ed5ae40624
56 changed files with 225 additions and 265 deletions

View File

@ -47,7 +47,7 @@ AWBugReporter::~AWBugReporter()
} }
void AWBugReporter::doConnect() void AWBugReporter::doConnect() const
{ {
// additional method for testing needs // additional method for testing needs
connect(this, &AWBugReporter::replyReceived, this, &AWBugReporter::showInformation); connect(this, &AWBugReporter::replyReceived, this, &AWBugReporter::showInformation);

View File

@ -30,7 +30,7 @@ class AWBugReporter : public QObject
public: public:
explicit AWBugReporter(QObject *_parent = nullptr); explicit AWBugReporter(QObject *_parent = nullptr);
~AWBugReporter() override; ~AWBugReporter() override;
Q_INVOKABLE void doConnect(); Q_INVOKABLE void doConnect() const;
Q_INVOKABLE static QString generateText(const QString &_description, const QString &_reproduce, Q_INVOKABLE static QString generateText(const QString &_description, const QString &_reproduce,
const QString &_expected, const QString &_logs); const QString &_expected, const QString &_logs);
Q_INVOKABLE void sendBugReport(const QString &_title, const QString &_body); Q_INVOKABLE void sendBugReport(const QString &_title, const QString &_body);

View File

@ -24,7 +24,6 @@
class QGraphicsScene; class QGraphicsScene;
class QGraphicsView; class QGraphicsView;
class QPixmap; class QPixmap;
class QThreadPool;
class AWDataAggregator : public QObject class AWDataAggregator : public QObject
{ {

View File

@ -38,7 +38,7 @@ public:
[[nodiscard]] AWKeysAggregator::FormatterType formatter(const QString &_key) const; [[nodiscard]] AWKeysAggregator::FormatterType formatter(const QString &_key) const;
[[nodiscard]] QStringList keysFromSource(const QString &_source) const; [[nodiscard]] QStringList keysFromSource(const QString &_source) const;
// set methods // set methods
QStringList registerSource(const QString &_source, const KSysGuard::Unit _units, const QStringList &_keys); QStringList registerSource(const QString &_source, KSysGuard::Unit _units, const QStringList &_keys);
void setDevices(const QHash<QString, QStringList> &_devices); void setDevices(const QHash<QString, QStringList> &_devices);
private: private:

View File

@ -86,7 +86,7 @@ public:
void setTranslate(bool _translate); void setTranslate(bool _translate);
public slots: public slots:
QStringList registerSource(const QString &_source, const KSysGuard::Unit _units, const QStringList &_keys); QStringList registerSource(const QString &_source, KSysGuard::Unit _units, const QStringList &_keys);
private: private:
[[nodiscard]] double temperature(double temp) const; [[nodiscard]] double temperature(double temp) const;

View File

@ -95,7 +95,7 @@ void AWUpdateHelper::showInfo(const QVersionNumber &_version)
} }
void AWUpdateHelper::showUpdates(const QVersionNumber &_version) void AWUpdateHelper::showUpdates(const QVersionNumber &_version) const
{ {
qCDebug(LOG_AW) << "Version" << _version; qCDebug(LOG_AW) << "Version" << _version;

View File

@ -37,7 +37,7 @@ public:
private slots: private slots:
void openReleasesPage(); void openReleasesPage();
static void showInfo(const QVersionNumber &_version); static void showInfo(const QVersionNumber &_version);
void showUpdates(const QVersionNumber &_version); void showUpdates(const QVersionNumber &_version) const;
void versionReplyReceived(QNetworkReply *_reply, bool _showAnyway); void versionReplyReceived(QNetworkReply *_reply, bool _showAnyway);
private: private:

View File

@ -245,7 +245,7 @@ void AbstractExtItem::setNumber(int _number)
if (generateNumber) { if (generateNumber) {
_number = []() { _number = []() {
qCWarning(LOG_LIB) << "Number is empty, generate new one"; qCWarning(LOG_LIB) << "Number is empty, generate new one";
auto n = QRandomGenerator::global()->generate() % 1000; auto n = QRandomGenerator::global()->bounded(1000);
qCInfo(LOG_LIB) << "Generated number is" << n; qCInfo(LOG_LIB) << "Generated number is" << n;
return n; return n;
}(); }();

View File

@ -184,8 +184,9 @@ void ExtQuotes::quotesReplyReceived(QNetworkReply *_reply)
_reply->deleteLater(); _reply->deleteLater();
auto data = m_providerObject->parse(text); auto data = m_providerObject->parse(text);
for (auto [key, value] : data.asKeyValueRange()) for (auto [key, value] : data.asKeyValueRange()) {
m_values[tag(key)] = value; m_values[tag(key)] = value;
}
emit(dataReceived(m_values)); emit(dataReceived(m_values));
} }

View File

@ -94,7 +94,7 @@ QString GraphicalItem::image(const QVariant &value)
m_scene->clear(); m_scene->clear();
auto scaleX = 1, scaleY = 1; auto scaleX = 1, scaleY = 1;
auto converted = GraphicalItemHelper::getPercents(value.toFloat(), minValue(), maxValue()); auto converted = GraphicalItemHelper::getPercents(value.toDouble(), minValue(), maxValue());
// paint // paint
switch (m_type) { switch (m_type) {
@ -182,13 +182,13 @@ int GraphicalItem::itemWidth() const
} }
float GraphicalItem::maxValue() const double GraphicalItem::maxValue() const
{ {
return m_maxValue; return m_maxValue;
} }
float GraphicalItem::minValue() const double GraphicalItem::minValue() const
{ {
return m_minValue; return m_minValue;
} }
@ -321,7 +321,7 @@ void GraphicalItem::setItemWidth(const int _width)
} }
void GraphicalItem::setMaxValue(const float _value) void GraphicalItem::setMaxValue(const double _value)
{ {
qCDebug(LOG_LIB) << "Max value" << _value; qCDebug(LOG_LIB) << "Max value" << _value;
@ -329,7 +329,7 @@ void GraphicalItem::setMaxValue(const float _value)
} }
void GraphicalItem::setMinValue(const float _value) void GraphicalItem::setMinValue(const double _value)
{ {
qCDebug(LOG_LIB) << "Min value" << _value; qCDebug(LOG_LIB) << "Min value" << _value;
@ -406,8 +406,8 @@ void GraphicalItem::readConfiguration()
setCount(settings.value("X-AW-Count", count()).toInt()); setCount(settings.value("X-AW-Count", count()).toInt());
setCustom(settings.value("X-AW-Custom", isCustom()).toBool()); setCustom(settings.value("X-AW-Custom", isCustom()).toBool());
setBar(settings.value("X-AW-Value", bar()).toString()); setBar(settings.value("X-AW-Value", bar()).toString());
setMaxValue(settings.value("X-AW-Max", maxValue()).toFloat()); setMaxValue(settings.value("X-AW-Max", maxValue()).toDouble());
setMinValue(settings.value("X-AW-Min", minValue()).toFloat()); setMinValue(settings.value("X-AW-Min", minValue()).toDouble());
setActiveColor(settings.value("X-AW-ActiveColor", activeColor()).toString()); setActiveColor(settings.value("X-AW-ActiveColor", activeColor()).toString());
setInactiveColor(settings.value("X-AW-InactiveColor", inactiveColor()).toString()); setInactiveColor(settings.value("X-AW-InactiveColor", inactiveColor()).toString());
setStrType(settings.value("X-AW-Type", strType()).toString()); setStrType(settings.value("X-AW-Type", strType()).toString());
@ -439,9 +439,8 @@ int GraphicalItem::showConfiguration(QWidget *_parent, const QVariant &_args)
ui->setupUi(dialog); ui->setupUi(dialog);
translate(ui); translate(ui);
connect(ui->checkBox_custom, &QCheckBox::stateChanged, [this, ui](const int state) { changeValue(ui, state); }); connect(ui->checkBox_custom, &QCheckBox::stateChanged, [ui](const int state) { changeValue(ui, state); });
connect(ui->comboBox_type, &QComboBox::currentIndexChanged, connect(ui->comboBox_type, &QComboBox::currentIndexChanged, [ui](const int state) { changeCountState(ui, state); });
[this, ui](const int state) { changeCountState(ui, state); });
connect(ui->toolButton_activeColor, &QToolButton::clicked, [this, ui]() { changeColor(ui); }); connect(ui->toolButton_activeColor, &QToolButton::clicked, [this, ui]() { changeColor(ui); });
connect(ui->toolButton_inactiveColor, &QToolButton::clicked, [this, ui]() { changeColor(ui); }); connect(ui->toolButton_inactiveColor, &QToolButton::clicked, [this, ui]() { changeColor(ui); });

View File

@ -64,8 +64,8 @@ public:
[[nodiscard]] bool isCustom() const; [[nodiscard]] bool isCustom() const;
[[nodiscard]] int itemHeight() const; [[nodiscard]] int itemHeight() const;
[[nodiscard]] int itemWidth() const; [[nodiscard]] int itemWidth() const;
[[nodiscard]] float minValue() const; [[nodiscard]] double minValue() const;
[[nodiscard]] float maxValue() const; [[nodiscard]] double maxValue() const;
[[nodiscard]] Type type() const; [[nodiscard]] Type type() const;
[[nodiscard]] QString strType() const; [[nodiscard]] QString strType() const;
[[nodiscard]] Direction direction() const; [[nodiscard]] Direction direction() const;
@ -80,8 +80,8 @@ public:
void setInactiveColor(const QString &_color); void setInactiveColor(const QString &_color);
void setItemHeight(int _height); void setItemHeight(int _height);
void setItemWidth(int _width); void setItemWidth(int _width);
void setMinValue(float _value); void setMinValue(double _value);
void setMaxValue(float _value); void setMaxValue(double _value);
void setType(Type _type); void setType(Type _type);
void setStrType(const QString &_type); void setStrType(const QString &_type);
void setDirection(Direction _direction); void setDirection(Direction _direction);
@ -110,8 +110,8 @@ private:
bool m_custom = false; bool m_custom = false;
QString m_activeColor = "color://0,0,0,130"; QString m_activeColor = "color://0,0,0,130";
QString m_inactiveColor = "color://255,255,255,130"; QString m_inactiveColor = "color://255,255,255,130";
float m_minValue = 0.0f; double m_minValue = 0.0;
float m_maxValue = 100.0f; double m_maxValue = 100.0;
Type m_type = Type::Horizontal; Type m_type = Type::Horizontal;
Direction m_direction = Direction::LeftToRight; Direction m_direction = Direction::LeftToRight;
int m_height = 100; int m_height = 100;

View File

@ -155,7 +155,7 @@ void GraphicalItemHelper::paintVertical(const float _percent)
} }
float GraphicalItemHelper::getPercents(const float _value, const float _min, const float _max) double GraphicalItemHelper::getPercents(const double _value, const double _min, const double _max)
{ {
qCDebug(LOG_LIB) << "Get percent value from" << _value; qCDebug(LOG_LIB) << "Get percent value from" << _value;
// newest Qt crashes here if value is nan // newest Qt crashes here if value is nan

View File

@ -40,12 +40,12 @@ public:
void paintHorizontal(float _percent); void paintHorizontal(float _percent);
void paintVertical(float _percent); void paintVertical(float _percent);
// additional conversion methods // additional conversion methods
static float getPercents(float _value, float _min, float _max); static double getPercents(double _value, double _min, double _max);
static bool isColor(const QString &_input); static bool isColor(const QString &_input);
static QColor stringToColor(const QString &_color); static QColor stringToColor(const QString &_color);
private: private:
static QBrush parseBrush(const QString &_input, const int _width, const int _height, const QColor &_default); static QBrush parseBrush(const QString &_input, int _width, int _height, const QColor &_default);
void storeValue(float _value); void storeValue(float _value);
QGraphicsScene *m_scene = nullptr; QGraphicsScene *m_scene = nullptr;
int m_count = 100; int m_count = 100;

View File

@ -1,25 +1,22 @@
# flags # flags
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "-Wall") set(CMAKE_CXX_FLAGS "-Wall")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
set(CMAKE_CXX_FLAGS_OPTIMIZATION "-Ofast -DNDEBUG") set(CMAKE_CXX_FLAGS_OPTIMIZATION "-Ofast -DNDEBUG")
# avoid newer gcc warnings
add_definitions(-D_DEFAULT_SOURCE)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "-Wall")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
set(CMAKE_CXX_FLAGS_OPTIMIZATION "-Ofast -DNDEBUG")
# linker flags
else ()
message(FATAL_ERROR "Unknown compiler")
endif ()
# some flags # standard force
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# enable clang-tidy
set(CMAKE_CXX_CLANG_TIDY
clang-tidy;
-format-style='file';
-header-filter=${CMAKE_CURRENT_SOURCE_DIR};
)
endif ()
# verbose output for debug builds # verbose output for debug builds
if (CMAKE_BUILD_TYPE MATCHES Debug) if (CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_VERBOSE_MAKEFILE ON) set(CMAKE_VERBOSE_MAKEFILE ON)

View File

@ -0,0 +1,52 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "abstractextsysmonsource.h"
#include "awdebug.h"
AbstractExtSysMonSource::AbstractExtSysMonSource(QObject *_parent)
: QObject(_parent)
{
qCDebug(LOG_ESS) << __PRETTY_FUNCTION__;
}
// This method returns -1 in case of invalid source name (like if there is no number)
int AbstractExtSysMonSource::index(const QString &_source)
{
auto match = NUMBER_REGEX.match(_source);
return match.hasMatch() ? match.captured().toInt() : -1;
}
KSysGuard::SensorInfo *AbstractExtSysMonSource::makeSensorInfo(const QString &_name, const QMetaType::Type _type,
const KSysGuard::Unit _unit, const double _min,
const double _max)
{
auto info = new KSysGuard::SensorInfo();
info->name = _name;
info->variantType = static_cast<QVariant::Type>(_type);
info->unit = _unit;
info->min = _min;
info->max = _max;
return info;
}

View File

@ -30,20 +30,11 @@ class AbstractExtSysMonSource : public QObject
public: public:
inline static QRegularExpression NUMBER_REGEX = QRegularExpression("\\d+$"); inline static QRegularExpression NUMBER_REGEX = QRegularExpression("\\d+$");
explicit AbstractExtSysMonSource(QObject *_parent) explicit AbstractExtSysMonSource(QObject *_parent);
: QObject(_parent){};
~AbstractExtSysMonSource() override = default; ~AbstractExtSysMonSource() override = default;
virtual QVariant data(const QString &_source) = 0; virtual QVariant data(const QString &_source) = 0;
[[nodiscard]] virtual QHash<QString, KSysGuard::SensorInfo *> sources() const = 0; [[nodiscard]] virtual QHash<QString, KSysGuard::SensorInfo *> sources() const = 0;
static int index(const QString &_source);
// used by extensions
// This method returns -1 in case of invalid source name (like if there is no number)
static int index(const QString &_source)
{
auto match = NUMBER_REGEX.match(_source);
return match.hasMatch() ? match.captured().toInt() : -1;
}
// safe value extractor // safe value extractor
template <class T> static QVariantHash dataByItem(T *_extension, const QString &_source) template <class T> static QVariantHash dataByItem(T *_extension, const QString &_source)
{ {
@ -54,22 +45,9 @@ public:
auto item = _extension->itemByTagNumber(idx); auto item = _extension->itemByTagNumber(idx);
return item ? item->run() : QVariantHash(); return item ? item->run() : QVariantHash();
} }
static KSysGuard::SensorInfo *makeSensorInfo(const QString &_name, QMetaType::Type _type,
static KSysGuard::SensorInfo *makeSensorInfo(const QString &_name, const QVariant::Type _type, KSysGuard::Unit _unit = KSysGuard::UnitNone,
const KSysGuard::Unit _unit = KSysGuard::UnitNone, double _min = 0, double _max = 0);
const double _min = 0, const double _max = 0)
{
auto info = new KSysGuard::SensorInfo();
info->name = _name;
info->variantType = _type;
info->unit = _unit;
info->min = _min;
info->max = _max;
return info;
}
signals: signals:
void dataReceived(const QVariantHash &); void dataReceived(const QVariantHash &);

View File

@ -71,11 +71,11 @@ void BatterySource::run()
m_values[QString("battotal%1").arg(i)] = QString(fullLevelFile.readLine()).toInt(); m_values[QString("battotal%1").arg(i)] = QString(fullLevelFile.readLine()).toInt();
fullLevelFile.close(); fullLevelFile.close();
m_values[QString("bat%1").arg(i)] = static_cast<int>(100 * m_values[QString("batnow%1").arg(i)].toFloat() m_values[QString("bat%1").arg(i)] = static_cast<int>(100 * m_values[QString("batnow%1").arg(i)].toDouble()
/ m_values[QString("battotal%1").arg(i)].toFloat()); / m_values[QString("battotal%1").arg(i)].toDouble());
// accumulate // accumulate
currentLevel += m_values[QString("batnow%1").arg(i)].toFloat(); currentLevel += m_values[QString("batnow%1").arg(i)].toDouble();
fullLevel += m_values[QString("battotal%1").arg(i)].toFloat(); fullLevel += m_values[QString("battotal%1").arg(i)].toDouble();
} }
// total // total
@ -93,24 +93,25 @@ QHash<QString, KSysGuard::SensorInfo *> BatterySource::sources() const
auto result = QHash<QString, KSysGuard::SensorInfo *>(); auto result = QHash<QString, KSysGuard::SensorInfo *>();
// fixed fields // fixed fields
result.insert("ac", makeSensorInfo("Is AC online or not", QVariant::Bool)); result.insert("ac", makeSensorInfo("Is AC online or not", QMetaType::Bool));
result.insert("bat", makeSensorInfo("Average battery usage", QVariant::Int, KSysGuard::UnitPercent, 0, 100)); result.insert("bat", makeSensorInfo("Average battery usage", QMetaType::Int, KSysGuard::UnitPercent, 0, 100));
result.insert("batleft", makeSensorInfo("Battery discharge time", QVariant::Int, KSysGuard::UnitSecond)); result.insert("batleft", makeSensorInfo("Battery discharge time", QMetaType::Int, KSysGuard::UnitSecond));
result.insert("batnow", makeSensorInfo("Current battery capacity", QVariant::Int)); result.insert("batnow", makeSensorInfo("Current battery capacity", QMetaType::Int));
result.insert("batrate", makeSensorInfo("Average battery discharge rate", QVariant::Double, KSysGuard::UnitRate)); result.insert("batrate", makeSensorInfo("Average battery discharge rate", QMetaType::Double, KSysGuard::UnitRate));
result.insert("battotal", makeSensorInfo("Full battery capacity", QVariant::Int)); result.insert("battotal", makeSensorInfo("Full battery capacity", QMetaType::Int));
// generators // generators
for (auto i = 0; i < m_batteriesCount; ++i) { for (auto i = 0; i < m_batteriesCount; ++i) {
result.insert(QString("bat%1").arg(i), makeSensorInfo(QString("Battery %1 usage").arg(i), QVariant::Int, result.insert(QString("bat%1").arg(i), makeSensorInfo(QString("Battery %1 usage").arg(i), QMetaType::Int,
KSysGuard::UnitPercent, 0, 100)); KSysGuard::UnitPercent, 0, 100));
result.insert(QString("batleft%1").arg(i), makeSensorInfo(QString("Battery %1 discharge time").arg(i), result.insert(QString("batleft%1").arg(i), makeSensorInfo(QString("Battery %1 discharge time").arg(i),
QVariant::Int, KSysGuard::UnitSecond)); QMetaType::Int, KSysGuard::UnitSecond));
result.insert(QString("batnow%1").arg(i), makeSensorInfo(QString("Battery %1 capacity").arg(i), QVariant::Int)); result.insert(QString("batnow%1").arg(i),
makeSensorInfo(QString("Battery %1 capacity").arg(i), QMetaType::Int));
result.insert(QString("batrate%1").arg(i), makeSensorInfo(QString("Battery %1 discharge rate").arg(i), result.insert(QString("batrate%1").arg(i), makeSensorInfo(QString("Battery %1 discharge rate").arg(i),
QVariant::Double, KSysGuard::UnitRate)); QMetaType::Double, KSysGuard::UnitRate));
result.insert(QString("battotal%1").arg(i), result.insert(QString("battotal%1").arg(i),
makeSensorInfo(QString("Battery %1 full capacity").arg(i), QVariant::Int)); makeSensorInfo(QString("Battery %1 full capacity").arg(i), QMetaType::Int));
} }
return result; return result;
@ -145,20 +146,19 @@ void BatterySource::calculateRates()
// check time interval // check time interval
auto now = QDateTime::currentDateTimeUtc(); auto now = QDateTime::currentDateTimeUtc();
auto interval = m_timestamp.secsTo(now); auto interval = static_cast<double>(m_timestamp.secsTo(now));
qCDebug(LOG_AW) << interval;
m_timestamp.swap(now); m_timestamp.swap(now);
for (auto i = 0; i < m_batteriesCount; ++i) { for (auto i = 0; i < m_batteriesCount; ++i) {
auto approx = approximate(m_trend[i + 1]); auto approx = approximate(m_trend[i + 1]);
m_values[QString("batrate%1").arg(i)] = approx / interval; m_values[QString("batrate%1").arg(i)] = approx / interval;
m_values[QString("batleft%1").arg(i)] = interval * m_values[QString("batnow%1").arg(i)].toFloat() / approx; m_values[QString("batleft%1").arg(i)] = interval * m_values[QString("batnow%1").arg(i)].toDouble() / approx;
} }
// total // total
auto approx = approximate(m_trend[0]); auto approx = approximate(m_trend[0]);
m_values["batrate"] = approx / interval; m_values["batrate"] = approx / interval;
m_values["batleft"] = interval * m_values["batnow"].toFloat() / approx; m_values["batleft"] = interval * m_values["batnow"].toDouble() / approx;
// old data cleanup // old data cleanup
for (auto &trend : m_trend.keys()) { for (auto &trend : m_trend.keys()) {

View File

@ -46,7 +46,7 @@ QHash<QString, KSysGuard::SensorInfo *> CustomSource::sources() const
for (auto item : m_extScripts->activeItems()) for (auto item : m_extScripts->activeItems())
result.insert(item->tag("custom"), result.insert(item->tag("custom"),
makeSensorInfo(QString("Custom command '%1' output").arg(item->uniq()), QVariant::String)); makeSensorInfo(QString("Custom command '%1' output").arg(item->uniq()), QMetaType::QString));
return result; return result;
} }

View File

@ -55,9 +55,9 @@ QHash<QString, KSysGuard::SensorInfo *> DesktopSource::sources() const
{ {
auto result = QHash<QString, KSysGuard::SensorInfo *>(); auto result = QHash<QString, KSysGuard::SensorInfo *>();
result.insert("name", makeSensorInfo("Current desktop name", QVariant::String)); result.insert("name", makeSensorInfo("Current desktop name", QMetaType::QString));
result.insert("number", makeSensorInfo("Current desktop number", QVariant::Int)); result.insert("number", makeSensorInfo("Current desktop number", QMetaType::Int));
result.insert("count", makeSensorInfo("Desktops count", QVariant::Int)); result.insert("count", makeSensorInfo("Desktops count", QMetaType::Int));
return result; return result;
} }

View File

@ -42,7 +42,7 @@ QHash<QString, KSysGuard::SensorInfo *> LoadSource::sources() const
auto result = QHash<QString, KSysGuard::SensorInfo *>(); auto result = QHash<QString, KSysGuard::SensorInfo *>();
for (auto i = 0; i < 1000; ++i) for (auto i = 0; i < 1000; ++i)
result.insert(QString("load%1").arg(i), makeSensorInfo("Simple sources for load tests", QVariant::Int)); result.insert(QString("load%1").arg(i), makeSensorInfo("Simple sources for load tests", QMetaType::Int));
return result; return result;
} }

View File

@ -65,8 +65,8 @@ QHash<QString, KSysGuard::SensorInfo *> NetworkSource::sources() const
{ {
auto result = QHash<QString, KSysGuard::SensorInfo *>(); auto result = QHash<QString, KSysGuard::SensorInfo *>();
result.insert("device", makeSensorInfo("Current network device name", QVariant::String)); result.insert("device", makeSensorInfo("Current network device name", QMetaType::QString));
result.insert("ssid", makeSensorInfo("Current SSID name", QVariant::String)); result.insert("ssid", makeSensorInfo("Current SSID name", QMetaType::QString));
return result; return result;
} }

View File

@ -32,7 +32,6 @@ public:
explicit NetworkSource(QObject *_parent); explicit NetworkSource(QObject *_parent);
~NetworkSource() override; ~NetworkSource() override;
QVariant data(const QString &_source) override; QVariant data(const QString &_source) override;
void run();
[[nodiscard]] QHash<QString, KSysGuard::SensorInfo *> sources() const override; [[nodiscard]] QHash<QString, KSysGuard::SensorInfo *> sources() const override;
private slots: private slots:

View File

@ -115,23 +115,23 @@ QHash<QString, KSysGuard::SensorInfo *> PlayerSource::sources() const
{ {
auto result = QHash<QString, KSysGuard::SensorInfo *>(); auto result = QHash<QString, KSysGuard::SensorInfo *>();
result.insert("album", makeSensorInfo("Current song album", QVariant::String)); result.insert("album", makeSensorInfo("Current song album", QMetaType::QString));
result.insert("salbum", result.insert("salbum",
makeSensorInfo(QString("Current song album (%1 symbols)").arg(m_symbols), QVariant::String)); makeSensorInfo(QString("Current song album (%1 symbols)").arg(m_symbols), QMetaType::QString));
result.insert("dalbum", result.insert("dalbum", makeSensorInfo(QString("Current song album (%1 symbols, dynamic)").arg(m_symbols),
makeSensorInfo(QString("Current song album (%1 symbols, dynamic)").arg(m_symbols), QVariant::String)); QMetaType::QString));
result.insert("artist", makeSensorInfo("Current song artist", QVariant::String)); result.insert("artist", makeSensorInfo("Current song artist", QMetaType::QString));
result.insert("sartist", result.insert("sartist",
makeSensorInfo(QString("Current song artist (%1 symbols)").arg(m_symbols), QVariant::String)); makeSensorInfo(QString("Current song artist (%1 symbols)").arg(m_symbols), QMetaType::QString));
result.insert("dartist", makeSensorInfo(QString("Current song artist (%1 symbols, dynamic)").arg(m_symbols), result.insert("dartist", makeSensorInfo(QString("Current song artist (%1 symbols, dynamic)").arg(m_symbols),
QVariant::String)); QMetaType::QString));
result.insert("duration", makeSensorInfo("Current song duration", QVariant::Int, KSysGuard::UnitSecond)); result.insert("duration", makeSensorInfo("Current song duration", QMetaType::Int, KSysGuard::UnitSecond));
result.insert("progress", makeSensorInfo("Current song progress", QVariant::Int, KSysGuard::UnitSecond)); result.insert("progress", makeSensorInfo("Current song progress", QMetaType::Int, KSysGuard::UnitSecond));
result.insert("title", makeSensorInfo("Current song title", QVariant::String)); result.insert("title", makeSensorInfo("Current song title", QMetaType::QString));
result.insert("stitle", result.insert("stitle",
makeSensorInfo(QString("Current song title (%1 symbols)").arg(m_symbols), QVariant::String)); makeSensorInfo(QString("Current song title (%1 symbols)").arg(m_symbols), QMetaType::QString));
result.insert("dtitle", result.insert("dtitle", makeSensorInfo(QString("Current song title (%1 symbols, dynamic)").arg(m_symbols),
makeSensorInfo(QString("Current song title (%1 symbols, dynamic)").arg(m_symbols), QVariant::String)); QMetaType::QString));
return result; return result;
} }

View File

@ -71,9 +71,9 @@ QHash<QString, KSysGuard::SensorInfo *> ProcessesSource::sources() const
{ {
auto result = QHash<QString, KSysGuard::SensorInfo *>(); auto result = QHash<QString, KSysGuard::SensorInfo *>();
result.insert("running", makeSensorInfo("Count of running processes", QVariant::Int)); result.insert("running", makeSensorInfo("Count of running processes", QMetaType::Int));
result.insert("list", makeSensorInfo("All running processes list", QVariant::StringList)); result.insert("list", makeSensorInfo("All running processes list", QMetaType::QStringList));
result.insert("count", makeSensorInfo("Total count of processes", QVariant::Int)); result.insert("count", makeSensorInfo("Total count of processes", QMetaType::Int));
return result; return result;
} }

View File

@ -48,17 +48,17 @@ QHash<QString, KSysGuard::SensorInfo *> QuotesSource::sources() const
for (auto item : m_extQuotes->activeItems()) { for (auto item : m_extQuotes->activeItems()) {
result.insert(item->tag("pricechg"), result.insert(item->tag("pricechg"),
makeSensorInfo(QString("Absolute price changes for '%1'").arg(item->uniq()), QVariant::Double)); makeSensorInfo(QString("Absolute price changes for '%1'").arg(item->uniq()), QMetaType::Double));
result.insert(item->tag("price"), result.insert(item->tag("price"),
makeSensorInfo(QString("Price for '%1'").arg(item->uniq()), QVariant::Double)); makeSensorInfo(QString("Price for '%1'").arg(item->uniq()), QMetaType::Double));
result.insert(item->tag("percpricechg"), makeSensorInfo(QString("Price changes for '%1'").arg(item->uniq()), result.insert(item->tag("percpricechg"), makeSensorInfo(QString("Price changes for '%1'").arg(item->uniq()),
QVariant::Double, KSysGuard::UnitPercent, 0, 100)); QMetaType::Double, KSysGuard::UnitPercent, 0, 100));
result.insert(item->tag("volumechg"), result.insert(item->tag("volumechg"),
makeSensorInfo(QString("Absolute volume changes for '%1'").arg(item->uniq()), QVariant::Double)); makeSensorInfo(QString("Absolute volume changes for '%1'").arg(item->uniq()), QMetaType::Double));
result.insert(item->tag("volume"), result.insert(item->tag("volume"),
makeSensorInfo(QString("Volume for '%1'").arg(item->uniq()), QVariant::Double)); makeSensorInfo(QString("Volume for '%1'").arg(item->uniq()), QMetaType::Double));
result.insert(item->tag("percvolumechg"), makeSensorInfo(QString("Volume changes for '%1'").arg(item->uniq()), result.insert(item->tag("percvolumechg"), makeSensorInfo(QString("Volume changes for '%1'").arg(item->uniq()),
QVariant::Double, KSysGuard::UnitPercent, 0, 100)); QMetaType::Double, KSysGuard::UnitPercent, 0, 100));
} }
return result; return result;

View File

@ -46,7 +46,7 @@ QHash<QString, KSysGuard::SensorInfo *> RequestSource::sources() const
for (auto item : m_extNetRequest->activeItems()) for (auto item : m_extNetRequest->activeItems())
result.insert(item->tag("response"), result.insert(item->tag("response"),
makeSensorInfo(QString("Network response for %1").arg(item->uniq()), QVariant::String)); makeSensorInfo(QString("Network response for %1").arg(item->uniq()), QMetaType::QString));
return result; return result;
} }

View File

@ -54,8 +54,8 @@ QHash<QString, KSysGuard::SensorInfo *> SystemInfoSource::sources() const
{ {
auto result = QHash<QString, KSysGuard::SensorInfo *>(); auto result = QHash<QString, KSysGuard::SensorInfo *>();
result.insert("brightness", makeSensorInfo("Screen brightness", QVariant::Double, KSysGuard::UnitPercent, 0, 100)); result.insert("brightness", makeSensorInfo("Screen brightness", QMetaType::Double, KSysGuard::UnitPercent, 0, 100));
result.insert("volume", makeSensorInfo("Master volume", QVariant::Double, KSysGuard::UnitNone)); result.insert("volume", makeSensorInfo("Master volume", QMetaType::Double, KSysGuard::UnitNone));
return result; return result;
} }

View File

@ -43,7 +43,7 @@ QHash<QString, KSysGuard::SensorInfo *> TimeSource::sources() const
{ {
auto result = QHash<QString, KSysGuard::SensorInfo *>(); auto result = QHash<QString, KSysGuard::SensorInfo *>();
result.insert("now", makeSensorInfo("Current time", QVariant::LongLong, KSysGuard::UnitSecond)); result.insert("now", makeSensorInfo("Current time", QMetaType::LongLong, KSysGuard::UnitSecond));
return result; return result;
} }

View File

@ -46,7 +46,7 @@ QHash<QString, KSysGuard::SensorInfo *> UpgradeSource::sources() const
for (auto item : m_extUpgrade->activeItems()) for (auto item : m_extUpgrade->activeItems())
result.insert(item->tag("pkgcount"), result.insert(item->tag("pkgcount"),
makeSensorInfo(QString("Package manager '%1' metadata").arg(item->uniq()), QVariant::Int)); makeSensorInfo(QString("Package manager '%1' metadata").arg(item->uniq()), QMetaType::Int));
return result; return result;
} }

View File

@ -48,17 +48,17 @@ QHash<QString, KSysGuard::SensorInfo *> WeatherSource::sources() const
for (auto item : m_extWeather->activeItems()) { for (auto item : m_extWeather->activeItems()) {
result.insert(item->tag("weatherId"), makeSensorInfo(QString("Numeric weather ID for '%1'").arg(item->uniq()), result.insert(item->tag("weatherId"), makeSensorInfo(QString("Numeric weather ID for '%1'").arg(item->uniq()),
QVariant::Int, KSysGuard::UnitNone, 0, 1000)); QMetaType::Int, KSysGuard::UnitNone, 0, 1000));
result.insert(item->tag("weather"), result.insert(item->tag("weather"),
makeSensorInfo(QString("ID string map for '%1'").arg(item->uniq()), QVariant::String)); makeSensorInfo(QString("ID string map for '%1'").arg(item->uniq()), QMetaType::QString));
result.insert(item->tag("humidity"), makeSensorInfo(QString("Humidity for '%1'").arg(item->uniq()), result.insert(item->tag("humidity"), makeSensorInfo(QString("Humidity for '%1'").arg(item->uniq()),
QVariant::Int, KSysGuard::UnitPercent, 0, 100)); QMetaType::Int, KSysGuard::UnitPercent, 0, 100));
result.insert(item->tag("pressure"), result.insert(item->tag("pressure"),
makeSensorInfo(QString("Atmospheric pressure for '%1'").arg(item->uniq()), QVariant::Int)); makeSensorInfo(QString("Atmospheric pressure for '%1'").arg(item->uniq()), QMetaType::Int));
result.insert(item->tag("temperature"), makeSensorInfo(QString("Temperature for '%1'").arg(item->uniq()), result.insert(item->tag("temperature"), makeSensorInfo(QString("Temperature for '%1'").arg(item->uniq()),
QVariant::Double, KSysGuard::UnitCelsius)); QMetaType::Double, KSysGuard::UnitCelsius));
result.insert(item->tag("timestamp"), makeSensorInfo(QString("Timestamp for '%1'").arg(item->uniq()), result.insert(item->tag("timestamp"), makeSensorInfo(QString("Timestamp for '%1'").arg(item->uniq()),
QVariant::DateTime, KSysGuard::UnitNone)); QMetaType::QDateTime, KSysGuard::UnitNone));
} }
return result; return result;

View File

@ -34,7 +34,7 @@ void TestAbstractExtItem::initTestCase()
comment = AWTestLibrary::randomString(); comment = AWTestLibrary::randomString();
socket = AWTestLibrary::randomString(); socket = AWTestLibrary::randomString();
extItem = new ExtUpgrade(nullptr, filePath); extItem = new ExtUpgrade(this, filePath);
extItem->setActive(false); extItem->setActive(false);
extItem->setApiVersion(1); extItem->setApiVersion(1);
extItem->setComment(comment); extItem->setComment(comment);
@ -48,7 +48,6 @@ void TestAbstractExtItem::initTestCase()
void TestAbstractExtItem::cleanupTestCase() void TestAbstractExtItem::cleanupTestCase()
{ {
QFile::remove(filePath); QFile::remove(filePath);
delete extItem;
} }
@ -83,7 +82,7 @@ void TestAbstractExtItem::test_configuration()
QCOMPARE(newExtItem->socket(), extItem->socket()); QCOMPARE(newExtItem->socket(), extItem->socket());
QCOMPARE(newExtItem->cron(), extItem->cron()); QCOMPARE(newExtItem->cron(), extItem->cron());
delete newExtItem; newExtItem->deleteLater();
} }
@ -102,7 +101,7 @@ void TestAbstractExtItem::test_delete()
QVERIFY(newExtItem->tryDelete()); QVERIFY(newExtItem->tryDelete());
QVERIFY(!QFile::exists(writeFilePath)); QVERIFY(!QFile::exists(writeFilePath));
delete newExtItem; newExtItem->deleteLater();
} }
@ -117,7 +116,7 @@ void TestAbstractExtItem::test_copy()
QCOMPARE(newExtItem->socket(), extItem->socket()); QCOMPARE(newExtItem->socket(), extItem->socket());
QCOMPARE(newExtItem->cron(), extItem->cron()); QCOMPARE(newExtItem->cron(), extItem->cron());
delete newExtItem; newExtItem->deleteLater();
} }

View File

@ -26,14 +26,11 @@
void TestAbstractFormatter::initTestCase() void TestAbstractFormatter::initTestCase()
{ {
AWTestLibrary::init(); AWTestLibrary::init();
formatter = new AWNoFormatter(nullptr); formatter = new AWNoFormatter(this);
} }
void TestAbstractFormatter::cleanupTestCase() void TestAbstractFormatter::cleanupTestCase() {}
{
delete formatter;
}
void TestAbstractFormatter::test_values() {} void TestAbstractFormatter::test_values() {}
@ -58,7 +55,7 @@ void TestAbstractFormatter::test_copy()
QCOMPARE(newFormatter->type(), formatter->type()); QCOMPARE(newFormatter->type(), formatter->type());
QCOMPARE(newFormatter->name(), formatter->name()); QCOMPARE(newFormatter->name(), formatter->name());
delete newFormatter; newFormatter->deleteLater();
} }

View File

@ -31,10 +31,7 @@ void TestAWBugReporter::initTestCase()
} }
void TestAWBugReporter::cleanupTestCase() void TestAWBugReporter::cleanupTestCase() {}
{
delete plugin;
}
void TestAWBugReporter::test_generateText() void TestAWBugReporter::test_generateText()
@ -54,7 +51,7 @@ void TestAWBugReporter::test_sendBugReport()
plugin->generateText(data.at(0), data.at(1), data.at(2), data.at(3))); plugin->generateText(data.at(0), data.at(1), data.at(2), data.at(3)));
QVERIFY(spy.wait(5000)); QVERIFY(spy.wait(5000));
QVariantList arguments = spy.takeFirst(); auto arguments = spy.takeFirst();
QVERIFY(arguments.at(0).toInt() > 0); QVERIFY(arguments.at(0).toInt() > 0);
QVERIFY(!arguments.at(1).toString().isEmpty()); QVERIFY(!arguments.at(1).toString().isEmpty());

View File

@ -30,10 +30,7 @@ void TestAWConfigHelper::initTestCase()
} }
void TestAWConfigHelper::cleanupTestCase() void TestAWConfigHelper::cleanupTestCase() {}
{
delete plugin;
}
void TestAWConfigHelper::test_configurationDirectory() void TestAWConfigHelper::test_configurationDirectory()

View File

@ -67,10 +67,7 @@ void TestAWKeys::initTestCase()
} }
void TestAWKeys::cleanupTestCase() void TestAWKeys::cleanupTestCase() {}
{
delete plugin;
}
void TestAWKeys::test_dictKeys() void TestAWKeys::test_dictKeys()

View File

@ -42,7 +42,7 @@ void TestAWPatternFunctions::test_findFunctionCalls()
auto pattern = AWTestLibrary::randomString() + function + AWTestLibrary::randomString(); auto pattern = AWTestLibrary::randomString() + function + AWTestLibrary::randomString();
QList<AWPatternFunctions::AWFunction> found = AWPatternFunctions::findFunctionCalls(name, pattern); auto found = AWPatternFunctions::findFunctionCalls(name, pattern);
QCOMPARE(found.count(), 1); QCOMPARE(found.count(), 1);
QCOMPARE(found.at(0).args, args); QCOMPARE(found.at(0).args, args);

View File

@ -33,10 +33,7 @@ void TestAWTelemetryHandler::initTestCase()
} }
void TestAWTelemetryHandler::cleanupTestCase() void TestAWTelemetryHandler::cleanupTestCase() {}
{
delete plugin;
}
void TestAWTelemetryHandler::test_put() void TestAWTelemetryHandler::test_put()

View File

@ -30,10 +30,7 @@ void TestAWUpdateHelper::initTestCase()
} }
void TestAWUpdateHelper::cleanupTestCase() void TestAWUpdateHelper::cleanupTestCase() {}
{
delete plugin;
}
void TestAWUpdateHelper::test_checkVersion() void TestAWUpdateHelper::test_checkVersion()

View File

@ -32,10 +32,7 @@ void TestBatterySource::initTestCase()
} }
void TestBatterySource::cleanupTestCase() void TestBatterySource::cleanupTestCase() {}
{
delete source;
}
void TestBatterySource::test_sources() void TestBatterySource::test_sources()
@ -53,11 +50,11 @@ void TestBatterySource::test_battery()
std::for_each(batteries.cbegin(), batteries.cend(), [this](auto bat) { std::for_each(batteries.cbegin(), batteries.cend(), [this](auto bat) {
auto value = source->data(bat); auto value = source->data(bat);
if (bat == "ac") if (bat == "ac")
QCOMPARE(value.type(), QVariant::Bool); QCOMPARE(value.typeId(), QMetaType::Bool);
else if (bat.startsWith("batrate") || bat.startsWith("batleft")) else if (bat.startsWith("batrate") || bat.startsWith("batleft"))
; ;
else else
QVERIFY((value.toFloat() >= battery.first) || (std::isnan(value.toFloat()))); QVERIFY((value.toDouble() >= battery.first) || (std::isnan(value.toDouble())));
}); });
} }

View File

@ -29,15 +29,12 @@ void TestAWDateTimeFormatter::initTestCase()
AWTestLibrary::init(); AWTestLibrary::init();
format = AWTestLibrary::randomSelect(QString(TIME_KEYS).split(',')).join(' '); format = AWTestLibrary::randomSelect(QString(TIME_KEYS).split(',')).join(' ');
formatter = new AWDateTimeFormatter(nullptr); formatter = new AWDateTimeFormatter(this);
formatter->setFormat(format); formatter->setFormat(format);
} }
void TestAWDateTimeFormatter::cleanupTestCase() void TestAWDateTimeFormatter::cleanupTestCase() {}
{
delete formatter;
}
void TestAWDateTimeFormatter::test_values() void TestAWDateTimeFormatter::test_values()
@ -62,7 +59,7 @@ void TestAWDateTimeFormatter::test_copy()
QCOMPARE(newFormatter->translateString(), formatter->translateString()); QCOMPARE(newFormatter->translateString(), formatter->translateString());
QCOMPARE(newFormatter->number(), 1); QCOMPARE(newFormatter->number(), 1);
delete newFormatter; newFormatter->deleteLater();
} }

View File

@ -31,10 +31,7 @@ void TestDesktopSource::initTestCase()
} }
void TestDesktopSource::cleanupTestCase() void TestDesktopSource::cleanupTestCase() {}
{
delete source;
}
void TestDesktopSource::test_sources() void TestDesktopSource::test_sources()

View File

@ -32,10 +32,7 @@ void TestDPPlugin::initTestCase()
} }
void TestDPPlugin::cleanupTestCase() void TestDPPlugin::cleanupTestCase() {}
{
delete plugin;
}
void TestDPPlugin::test_desktops() void TestDPPlugin::test_desktops()

View File

@ -27,14 +27,11 @@
void TestExtItemAggregator::initTestCase() void TestExtItemAggregator::initTestCase()
{ {
AWTestLibrary::init(); AWTestLibrary::init();
aggregator = new ExtItemAggregator<AWNoFormatter>(nullptr, type); aggregator = new ExtItemAggregator<AWNoFormatter>(this, type);
} }
void TestExtItemAggregator::cleanupTestCase() void TestExtItemAggregator::cleanupTestCase() {}
{
delete aggregator;
}
void TestExtItemAggregator::test_values() void TestExtItemAggregator::test_values()

View File

@ -26,7 +26,7 @@
void TestExtQuotes::initTestCase() void TestExtQuotes::initTestCase()
{ {
AWTestLibrary::init(); AWTestLibrary::init();
extQuotes = new ExtQuotes(nullptr); extQuotes = new ExtQuotes(this);
extQuotes->setInterval(1); extQuotes->setInterval(1);
extQuotes->setTicker(ticker); extQuotes->setTicker(ticker);
extQuotes->setNumber(0); extQuotes->setNumber(0);
@ -35,10 +35,7 @@ void TestExtQuotes::initTestCase()
} }
void TestExtQuotes::cleanupTestCase() void TestExtQuotes::cleanupTestCase() {}
{
delete extQuotes;
}
void TestExtQuotes::test_values() void TestExtQuotes::test_values()
@ -96,7 +93,7 @@ void TestExtQuotes::test_copy()
QCOMPARE(newExtQuotes->ticker(), extQuotes->ticker()); QCOMPARE(newExtQuotes->ticker(), extQuotes->ticker());
QCOMPARE(newExtQuotes->number(), 1); QCOMPARE(newExtQuotes->number(), 1);
delete newExtQuotes; newExtQuotes->deleteLater();
} }

View File

@ -28,7 +28,7 @@ void TestExtScript::initTestCase()
AWTestLibrary::init(); AWTestLibrary::init();
randomString = AWTestLibrary::randomString(); randomString = AWTestLibrary::randomString();
extScript = new ExtScript(nullptr); extScript = new ExtScript(this);
extScript->setInterval(1); extScript->setInterval(1);
extScript->setExecutable(QString("echo %1").arg(randomString)); extScript->setExecutable(QString("echo %1").arg(randomString));
extScript->setNumber(0); extScript->setNumber(0);
@ -38,10 +38,7 @@ void TestExtScript::initTestCase()
} }
void TestExtScript::cleanupTestCase() void TestExtScript::cleanupTestCase() {}
{
delete extScript;
}
void TestExtScript::test_values() void TestExtScript::test_values()
@ -95,7 +92,7 @@ void TestExtScript::test_copy()
QCOMPARE(newExtScript->filters(), extScript->filters()); QCOMPARE(newExtScript->filters(), extScript->filters());
QCOMPARE(newExtScript->number(), 1); QCOMPARE(newExtScript->number(), 1);
delete newExtScript; newExtScript->deleteLater();
} }

View File

@ -29,7 +29,7 @@ void TestExtUpgrade::initTestCase()
randomStrings = AWTestLibrary::randomStringList(); randomStrings = AWTestLibrary::randomStringList();
cmd = QString("echo -e '%1'").arg(randomStrings.join("\n")); cmd = QString("echo -e '%1'").arg(randomStrings.join("\n"));
extUpgrade = new ExtUpgrade(nullptr); extUpgrade = new ExtUpgrade(this);
extUpgrade->setInterval(1); extUpgrade->setInterval(1);
extUpgrade->setExecutable(cmd); extUpgrade->setExecutable(cmd);
extUpgrade->setNumber(0); extUpgrade->setNumber(0);
@ -38,10 +38,7 @@ void TestExtUpgrade::initTestCase()
} }
void TestExtUpgrade::cleanupTestCase() void TestExtUpgrade::cleanupTestCase() {}
{
delete extUpgrade;
}
void TestExtUpgrade::test_values() void TestExtUpgrade::test_values()
@ -106,7 +103,7 @@ void TestExtUpgrade::test_copy()
QCOMPARE(newExtUpgrade->null(), extUpgrade->null()); QCOMPARE(newExtUpgrade->null(), extUpgrade->null());
QCOMPARE(newExtUpgrade->number(), 1); QCOMPARE(newExtUpgrade->number(), 1);
delete newExtUpgrade; newExtUpgrade->deleteLater();
} }

View File

@ -26,7 +26,7 @@
void TestExtWeather::initTestCase() void TestExtWeather::initTestCase()
{ {
AWTestLibrary::init(); AWTestLibrary::init();
extWeather = new ExtWeather(nullptr); extWeather = new ExtWeather(this);
extWeather->setInterval(1); extWeather->setInterval(1);
extWeather->setCity(city); extWeather->setCity(city);
extWeather->setCountry(country); extWeather->setCountry(country);
@ -37,10 +37,7 @@ void TestExtWeather::initTestCase()
} }
void TestExtWeather::cleanupTestCase() void TestExtWeather::cleanupTestCase() {}
{
delete extWeather;
}
void TestExtWeather::test_values() void TestExtWeather::test_values()
@ -95,7 +92,7 @@ void TestExtWeather::test_copy()
QCOMPARE(newExtWeather->provider(), extWeather->provider()); QCOMPARE(newExtWeather->provider(), extWeather->provider());
QCOMPARE(newExtWeather->number(), 1); QCOMPARE(newExtWeather->number(), 1);
delete newExtWeather; newExtWeather->deleteLater();
} }
@ -114,8 +111,8 @@ void TestExtWeather::run()
&& (arguments[extWeather->tag("humidity")].toInt() <= humidity.second)); && (arguments[extWeather->tag("humidity")].toInt() <= humidity.second));
QVERIFY((arguments[extWeather->tag("pressure")].toInt() > pressure.first) QVERIFY((arguments[extWeather->tag("pressure")].toInt() > pressure.first)
&& (arguments[extWeather->tag("pressure")].toInt() < pressure.second)); && (arguments[extWeather->tag("pressure")].toInt() < pressure.second));
QVERIFY((arguments[extWeather->tag("temperature")].toFloat() > temp.first) QVERIFY((arguments[extWeather->tag("temperature")].toDouble() > temp.first)
&& (arguments[extWeather->tag("temperature")].toFloat() < temp.second)); && (arguments[extWeather->tag("temperature")].toDouble() < temp.second));
// image should be only one symbol here // image should be only one symbol here
if (extWeather->jsonMapFile().isEmpty()) if (extWeather->jsonMapFile().isEmpty())
QSKIP("No json map found for weather, skip image test"); QSKIP("No json map found for weather, skip image test");

View File

@ -27,14 +27,11 @@
void TestAWFloatFormatter::initTestCase() void TestAWFloatFormatter::initTestCase()
{ {
AWTestLibrary::init(); AWTestLibrary::init();
formatter = new AWFloatFormatter(nullptr); formatter = new AWFloatFormatter(this);
} }
void TestAWFloatFormatter::cleanupTestCase() void TestAWFloatFormatter::cleanupTestCase() {}
{
delete formatter;
}
void TestAWFloatFormatter::test_values() {} void TestAWFloatFormatter::test_values() {}
@ -95,7 +92,7 @@ void TestAWFloatFormatter::test_forceWidth()
void TestAWFloatFormatter::test_format() void TestAWFloatFormatter::test_format()
{ {
// assign // assign
QWARN("Lets assing 'z' formatter, it should cause a warning"); qWarning("Lets assign 'z' formatter, it should cause a warning");
formatter->setFormat('z'); formatter->setFormat('z');
QCOMPARE(formatter->format(), 'f'); QCOMPARE(formatter->format(), 'f');
formatter->setFormat('e'); formatter->setFormat('e');
@ -175,7 +172,7 @@ void TestAWFloatFormatter::test_copy()
QCOMPARE(newFormatter->summand(), formatter->summand()); QCOMPARE(newFormatter->summand(), formatter->summand());
QCOMPARE(newFormatter->number(), 1); QCOMPARE(newFormatter->number(), 1);
delete newFormatter; newFormatter->deleteLater();
} }

View File

@ -26,17 +26,14 @@
void TestAWJsonFormatter::initTestCase() void TestAWJsonFormatter::initTestCase()
{ {
AWTestLibrary::init(); AWTestLibrary::init();
formatter = new AWJsonFormatter(nullptr); formatter = new AWJsonFormatter(this);
generate(); generate();
formatter->setPath(path); formatter->setPath(path);
} }
void TestAWJsonFormatter::cleanupTestCase() void TestAWJsonFormatter::cleanupTestCase() {}
{
delete formatter;
}
void TestAWJsonFormatter::test_values() void TestAWJsonFormatter::test_values()
@ -58,7 +55,7 @@ void TestAWJsonFormatter::test_copy()
QCOMPARE(newFormatter->path(), formatter->path()); QCOMPARE(newFormatter->path(), formatter->path());
QCOMPARE(newFormatter->number(), 1); QCOMPARE(newFormatter->number(), 1);
delete newFormatter; newFormatter->deleteLater();
} }
@ -79,8 +76,7 @@ void TestAWJsonFormatter::generate()
} else { } else {
auto key = AWTestLibrary::randomString(); auto key = AWTestLibrary::randomString();
auto val = AWTestLibrary::randomString(); auto val = AWTestLibrary::randomString();
QVariantMap dict; QVariantMap dict{{key, val}};
dict[key] = val;
second.append(dict); second.append(dict);
} }
} }

View File

@ -28,15 +28,12 @@ void TestAWListFormatter::initTestCase()
AWTestLibrary::init(); AWTestLibrary::init();
separator = AWTestLibrary::randomString(9, 10); separator = AWTestLibrary::randomString(9, 10);
formatter = new AWListFormatter(nullptr); formatter = new AWListFormatter(this);
formatter->setSeparator(separator); formatter->setSeparator(separator);
} }
void TestAWListFormatter::cleanupTestCase() void TestAWListFormatter::cleanupTestCase() {}
{
delete formatter;
}
void TestAWListFormatter::test_values() void TestAWListFormatter::test_values()
@ -85,7 +82,7 @@ void TestAWListFormatter::test_copy()
QCOMPARE(newFormatter->separator(), formatter->separator()); QCOMPARE(newFormatter->separator(), formatter->separator());
QCOMPARE(newFormatter->isSorted(), formatter->isSorted()); QCOMPARE(newFormatter->isSorted(), formatter->isSorted());
delete newFormatter; newFormatter->deleteLater();
} }

View File

@ -30,10 +30,7 @@ void TestNetworkSource::initTestCase()
} }
void TestNetworkSource::cleanupTestCase() void TestNetworkSource::cleanupTestCase() {}
{
delete source;
}
void TestNetworkSource::test_sources() void TestNetworkSource::test_sources()

View File

@ -26,14 +26,11 @@
void TestAWNoFormatter::initTestCase() void TestAWNoFormatter::initTestCase()
{ {
AWTestLibrary::init(); AWTestLibrary::init();
formatter = new AWNoFormatter(nullptr); formatter = new AWNoFormatter(this);
} }
void TestAWNoFormatter::cleanupTestCase() void TestAWNoFormatter::cleanupTestCase() {}
{
delete formatter;
}
void TestAWNoFormatter::test_values() {} void TestAWNoFormatter::test_values() {}
@ -45,7 +42,7 @@ void TestAWNoFormatter::test_conversion()
auto randomInt = AWTestLibrary::randomInt(); auto randomInt = AWTestLibrary::randomInt();
QCOMPARE(formatter->convert(randomInt), QString::number(randomInt)); QCOMPARE(formatter->convert(randomInt), QString::number(randomInt));
// float // float
QWARN("Float conversion isn't tested here due to possible rounding errors"); qWarning("Float conversion isn't tested here due to possible rounding errors");
// string // string
auto randomString = AWTestLibrary::randomString(); auto randomString = AWTestLibrary::randomString();
QCOMPARE(formatter->convert(randomString), randomString); QCOMPARE(formatter->convert(randomString), randomString);
@ -58,7 +55,7 @@ void TestAWNoFormatter::test_copy()
QCOMPARE(newFormatter->number(), 1); QCOMPARE(newFormatter->number(), 1);
delete newFormatter; newFormatter->deleteLater();
} }

View File

@ -67,8 +67,10 @@ void TestPlayerSource::test_autoMpris()
auto source = new PlayerSource(this, "mpris", mpdAddress, mpdPort, "auto", 10); auto source = new PlayerSource(this, "mpris", mpdAddress, mpdPort, "auto", 10);
auto empty = source->getAutoMpris().isEmpty(); auto empty = source->getAutoMpris().isEmpty();
source->deleteLater();
if (empty) if (empty)
QWARN("No MPRIS found, manual check required"); qWarning("No MPRIS found, manual check required");
else else
QVERIFY(!empty); QVERIFY(!empty);
} }
@ -95,6 +97,8 @@ void TestPlayerSource::test_mpd()
QSKIP("No mpd found"); QSKIP("No mpd found");
QVERIFY(secondValue["progress"].toInt() < secondValue["duration"].toInt()); QVERIFY(secondValue["progress"].toInt() < secondValue["duration"].toInt());
source->deleteLater();
} }
@ -112,6 +116,8 @@ void TestPlayerSource::test_mpris()
QSKIP("No mpris found"); QSKIP("No mpris found");
QVERIFY(progress < duration); QVERIFY(progress < duration);
source->deleteLater();
} }

View File

@ -30,10 +30,7 @@ void TestProcessesSource::initTestCase()
} }
void TestProcessesSource::cleanupTestCase() void TestProcessesSource::cleanupTestCase() {}
{
delete source;
}
void TestProcessesSource::test_sources() void TestProcessesSource::test_sources()

View File

@ -33,10 +33,7 @@ void TestAWScriptFormatter::initTestCase()
} }
void TestAWScriptFormatter::cleanupTestCase() void TestAWScriptFormatter::cleanupTestCase() {}
{
delete formatter;
}
void TestAWScriptFormatter::test_values() void TestAWScriptFormatter::test_values()
@ -100,7 +97,7 @@ void TestAWScriptFormatter::test_copy()
QCOMPARE(newFormatter->program(), formatter->program()); QCOMPARE(newFormatter->program(), formatter->program());
QCOMPARE(newFormatter->number(), 1); QCOMPARE(newFormatter->number(), 1);
delete newFormatter; newFormatter->deleteLater();
} }

View File

@ -26,14 +26,11 @@
void TestAWStringFormatter::initTestCase() void TestAWStringFormatter::initTestCase()
{ {
AWTestLibrary::init(); AWTestLibrary::init();
formatter = new AWStringFormatter(nullptr); formatter = new AWStringFormatter(this);
} }
void TestAWStringFormatter::cleanupTestCase() void TestAWStringFormatter::cleanupTestCase() {}
{
delete formatter;
}
void TestAWStringFormatter::test_values() {} void TestAWStringFormatter::test_values() {}
@ -104,7 +101,7 @@ void TestAWStringFormatter::test_copy()
QCOMPARE(newFormatter->forceWidth(), formatter->forceWidth()); QCOMPARE(newFormatter->forceWidth(), formatter->forceWidth());
QCOMPARE(newFormatter->number(), 1); QCOMPARE(newFormatter->number(), 1);
delete newFormatter; newFormatter->deleteLater();
} }