mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 15:37:23 +00:00
refactor: fix some minor clang-tidy warnings
This commit is contained in:
parent
2f4f05b5af
commit
ed5ae40624
@ -47,7 +47,7 @@ AWBugReporter::~AWBugReporter()
|
||||
}
|
||||
|
||||
|
||||
void AWBugReporter::doConnect()
|
||||
void AWBugReporter::doConnect() const
|
||||
{
|
||||
// additional method for testing needs
|
||||
connect(this, &AWBugReporter::replyReceived, this, &AWBugReporter::showInformation);
|
||||
|
@ -30,7 +30,7 @@ class AWBugReporter : public QObject
|
||||
public:
|
||||
explicit AWBugReporter(QObject *_parent = nullptr);
|
||||
~AWBugReporter() override;
|
||||
Q_INVOKABLE void doConnect();
|
||||
Q_INVOKABLE void doConnect() const;
|
||||
Q_INVOKABLE static QString generateText(const QString &_description, const QString &_reproduce,
|
||||
const QString &_expected, const QString &_logs);
|
||||
Q_INVOKABLE void sendBugReport(const QString &_title, const QString &_body);
|
||||
|
@ -24,7 +24,6 @@
|
||||
class QGraphicsScene;
|
||||
class QGraphicsView;
|
||||
class QPixmap;
|
||||
class QThreadPool;
|
||||
|
||||
class AWDataAggregator : public QObject
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
[[nodiscard]] AWKeysAggregator::FormatterType formatter(const QString &_key) const;
|
||||
[[nodiscard]] QStringList keysFromSource(const QString &_source) const;
|
||||
// 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);
|
||||
|
||||
private:
|
||||
|
@ -86,7 +86,7 @@ public:
|
||||
void setTranslate(bool _translate);
|
||||
|
||||
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:
|
||||
[[nodiscard]] double temperature(double temp) const;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
private slots:
|
||||
void openReleasesPage();
|
||||
static void showInfo(const QVersionNumber &_version);
|
||||
void showUpdates(const QVersionNumber &_version);
|
||||
void showUpdates(const QVersionNumber &_version) const;
|
||||
void versionReplyReceived(QNetworkReply *_reply, bool _showAnyway);
|
||||
|
||||
private:
|
||||
|
@ -245,7 +245,7 @@ void AbstractExtItem::setNumber(int _number)
|
||||
if (generateNumber) {
|
||||
_number = []() {
|
||||
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;
|
||||
return n;
|
||||
}();
|
||||
|
@ -184,8 +184,9 @@ void ExtQuotes::quotesReplyReceived(QNetworkReply *_reply)
|
||||
_reply->deleteLater();
|
||||
|
||||
auto data = m_providerObject->parse(text);
|
||||
for (auto [key, value] : data.asKeyValueRange())
|
||||
for (auto [key, value] : data.asKeyValueRange()) {
|
||||
m_values[tag(key)] = value;
|
||||
}
|
||||
|
||||
emit(dataReceived(m_values));
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ QString GraphicalItem::image(const QVariant &value)
|
||||
|
||||
m_scene->clear();
|
||||
auto scaleX = 1, scaleY = 1;
|
||||
auto converted = GraphicalItemHelper::getPercents(value.toFloat(), minValue(), maxValue());
|
||||
auto converted = GraphicalItemHelper::getPercents(value.toDouble(), minValue(), maxValue());
|
||||
|
||||
// paint
|
||||
switch (m_type) {
|
||||
@ -182,13 +182,13 @@ int GraphicalItem::itemWidth() const
|
||||
}
|
||||
|
||||
|
||||
float GraphicalItem::maxValue() const
|
||||
double GraphicalItem::maxValue() const
|
||||
{
|
||||
return m_maxValue;
|
||||
}
|
||||
|
||||
|
||||
float GraphicalItem::minValue() const
|
||||
double GraphicalItem::minValue() const
|
||||
{
|
||||
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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -406,8 +406,8 @@ void GraphicalItem::readConfiguration()
|
||||
setCount(settings.value("X-AW-Count", count()).toInt());
|
||||
setCustom(settings.value("X-AW-Custom", isCustom()).toBool());
|
||||
setBar(settings.value("X-AW-Value", bar()).toString());
|
||||
setMaxValue(settings.value("X-AW-Max", maxValue()).toFloat());
|
||||
setMinValue(settings.value("X-AW-Min", minValue()).toFloat());
|
||||
setMaxValue(settings.value("X-AW-Max", maxValue()).toDouble());
|
||||
setMinValue(settings.value("X-AW-Min", minValue()).toDouble());
|
||||
setActiveColor(settings.value("X-AW-ActiveColor", activeColor()).toString());
|
||||
setInactiveColor(settings.value("X-AW-InactiveColor", inactiveColor()).toString());
|
||||
setStrType(settings.value("X-AW-Type", strType()).toString());
|
||||
@ -439,9 +439,8 @@ int GraphicalItem::showConfiguration(QWidget *_parent, const QVariant &_args)
|
||||
ui->setupUi(dialog);
|
||||
translate(ui);
|
||||
|
||||
connect(ui->checkBox_custom, &QCheckBox::stateChanged, [this, ui](const int state) { changeValue(ui, state); });
|
||||
connect(ui->comboBox_type, &QComboBox::currentIndexChanged,
|
||||
[this, ui](const int state) { changeCountState(ui, state); });
|
||||
connect(ui->checkBox_custom, &QCheckBox::stateChanged, [ui](const int state) { changeValue(ui, state); });
|
||||
connect(ui->comboBox_type, &QComboBox::currentIndexChanged, [ui](const int state) { changeCountState(ui, state); });
|
||||
connect(ui->toolButton_activeColor, &QToolButton::clicked, [this, ui]() { changeColor(ui); });
|
||||
connect(ui->toolButton_inactiveColor, &QToolButton::clicked, [this, ui]() { changeColor(ui); });
|
||||
|
||||
|
@ -64,8 +64,8 @@ public:
|
||||
[[nodiscard]] bool isCustom() const;
|
||||
[[nodiscard]] int itemHeight() const;
|
||||
[[nodiscard]] int itemWidth() const;
|
||||
[[nodiscard]] float minValue() const;
|
||||
[[nodiscard]] float maxValue() const;
|
||||
[[nodiscard]] double minValue() const;
|
||||
[[nodiscard]] double maxValue() const;
|
||||
[[nodiscard]] Type type() const;
|
||||
[[nodiscard]] QString strType() const;
|
||||
[[nodiscard]] Direction direction() const;
|
||||
@ -80,8 +80,8 @@ public:
|
||||
void setInactiveColor(const QString &_color);
|
||||
void setItemHeight(int _height);
|
||||
void setItemWidth(int _width);
|
||||
void setMinValue(float _value);
|
||||
void setMaxValue(float _value);
|
||||
void setMinValue(double _value);
|
||||
void setMaxValue(double _value);
|
||||
void setType(Type _type);
|
||||
void setStrType(const QString &_type);
|
||||
void setDirection(Direction _direction);
|
||||
@ -110,8 +110,8 @@ private:
|
||||
bool m_custom = false;
|
||||
QString m_activeColor = "color://0,0,0,130";
|
||||
QString m_inactiveColor = "color://255,255,255,130";
|
||||
float m_minValue = 0.0f;
|
||||
float m_maxValue = 100.0f;
|
||||
double m_minValue = 0.0;
|
||||
double m_maxValue = 100.0;
|
||||
Type m_type = Type::Horizontal;
|
||||
Direction m_direction = Direction::LeftToRight;
|
||||
int m_height = 100;
|
||||
|
@ -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;
|
||||
// newest Qt crashes here if value is nan
|
||||
|
@ -40,12 +40,12 @@ public:
|
||||
void paintHorizontal(float _percent);
|
||||
void paintVertical(float _percent);
|
||||
// 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 QColor stringToColor(const QString &_color);
|
||||
|
||||
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);
|
||||
QGraphicsScene *m_scene = nullptr;
|
||||
int m_count = 100;
|
||||
|
@ -1,25 +1,22 @@
|
||||
# flags
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
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")
|
||||
# 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 ()
|
||||
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")
|
||||
|
||||
# some flags
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
# standard force
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
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
|
||||
if (CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
|
52
sources/extsysmonsources/abstractextsysmonsource.cpp
Normal file
52
sources/extsysmonsources/abstractextsysmonsource.cpp
Normal 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;
|
||||
}
|
@ -30,20 +30,11 @@ class AbstractExtSysMonSource : public QObject
|
||||
public:
|
||||
inline static QRegularExpression NUMBER_REGEX = QRegularExpression("\\d+$");
|
||||
|
||||
explicit AbstractExtSysMonSource(QObject *_parent)
|
||||
: QObject(_parent){};
|
||||
explicit AbstractExtSysMonSource(QObject *_parent);
|
||||
~AbstractExtSysMonSource() override = default;
|
||||
virtual QVariant data(const QString &_source) = 0;
|
||||
[[nodiscard]] virtual QHash<QString, KSysGuard::SensorInfo *> sources() const = 0;
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
static int index(const QString &_source);
|
||||
// safe value extractor
|
||||
template <class T> static QVariantHash dataByItem(T *_extension, const QString &_source)
|
||||
{
|
||||
@ -54,22 +45,9 @@ public:
|
||||
auto item = _extension->itemByTagNumber(idx);
|
||||
return item ? item->run() : QVariantHash();
|
||||
}
|
||||
|
||||
static KSysGuard::SensorInfo *makeSensorInfo(const QString &_name, const QVariant::Type _type,
|
||||
const KSysGuard::Unit _unit = KSysGuard::UnitNone,
|
||||
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;
|
||||
}
|
||||
static KSysGuard::SensorInfo *makeSensorInfo(const QString &_name, QMetaType::Type _type,
|
||||
KSysGuard::Unit _unit = KSysGuard::UnitNone,
|
||||
double _min = 0, double _max = 0);
|
||||
|
||||
signals:
|
||||
void dataReceived(const QVariantHash &);
|
||||
|
@ -71,11 +71,11 @@ void BatterySource::run()
|
||||
m_values[QString("battotal%1").arg(i)] = QString(fullLevelFile.readLine()).toInt();
|
||||
fullLevelFile.close();
|
||||
|
||||
m_values[QString("bat%1").arg(i)] = static_cast<int>(100 * m_values[QString("batnow%1").arg(i)].toFloat()
|
||||
/ m_values[QString("battotal%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)].toDouble());
|
||||
// accumulate
|
||||
currentLevel += m_values[QString("batnow%1").arg(i)].toFloat();
|
||||
fullLevel += m_values[QString("battotal%1").arg(i)].toFloat();
|
||||
currentLevel += m_values[QString("batnow%1").arg(i)].toDouble();
|
||||
fullLevel += m_values[QString("battotal%1").arg(i)].toDouble();
|
||||
}
|
||||
|
||||
// total
|
||||
@ -93,24 +93,25 @@ QHash<QString, KSysGuard::SensorInfo *> BatterySource::sources() const
|
||||
auto result = QHash<QString, KSysGuard::SensorInfo *>();
|
||||
|
||||
// fixed fields
|
||||
result.insert("ac", makeSensorInfo("Is AC online or not", QVariant::Bool));
|
||||
result.insert("bat", makeSensorInfo("Average battery usage", QVariant::Int, KSysGuard::UnitPercent, 0, 100));
|
||||
result.insert("batleft", makeSensorInfo("Battery discharge time", QVariant::Int, KSysGuard::UnitSecond));
|
||||
result.insert("batnow", makeSensorInfo("Current battery capacity", QVariant::Int));
|
||||
result.insert("batrate", makeSensorInfo("Average battery discharge rate", QVariant::Double, KSysGuard::UnitRate));
|
||||
result.insert("battotal", makeSensorInfo("Full battery capacity", QVariant::Int));
|
||||
result.insert("ac", makeSensorInfo("Is AC online or not", QMetaType::Bool));
|
||||
result.insert("bat", makeSensorInfo("Average battery usage", QMetaType::Int, KSysGuard::UnitPercent, 0, 100));
|
||||
result.insert("batleft", makeSensorInfo("Battery discharge time", QMetaType::Int, KSysGuard::UnitSecond));
|
||||
result.insert("batnow", makeSensorInfo("Current battery capacity", QMetaType::Int));
|
||||
result.insert("batrate", makeSensorInfo("Average battery discharge rate", QMetaType::Double, KSysGuard::UnitRate));
|
||||
result.insert("battotal", makeSensorInfo("Full battery capacity", QMetaType::Int));
|
||||
|
||||
// generators
|
||||
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));
|
||||
result.insert(QString("batleft%1").arg(i), makeSensorInfo(QString("Battery %1 discharge time").arg(i),
|
||||
QVariant::Int, KSysGuard::UnitSecond));
|
||||
result.insert(QString("batnow%1").arg(i), makeSensorInfo(QString("Battery %1 capacity").arg(i), QVariant::Int));
|
||||
QMetaType::Int, KSysGuard::UnitSecond));
|
||||
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),
|
||||
QVariant::Double, KSysGuard::UnitRate));
|
||||
QMetaType::Double, KSysGuard::UnitRate));
|
||||
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;
|
||||
@ -145,20 +146,19 @@ void BatterySource::calculateRates()
|
||||
|
||||
// check time interval
|
||||
auto now = QDateTime::currentDateTimeUtc();
|
||||
auto interval = m_timestamp.secsTo(now);
|
||||
qCDebug(LOG_AW) << interval;
|
||||
auto interval = static_cast<double>(m_timestamp.secsTo(now));
|
||||
m_timestamp.swap(now);
|
||||
|
||||
for (auto i = 0; i < m_batteriesCount; ++i) {
|
||||
auto approx = approximate(m_trend[i + 1]);
|
||||
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
|
||||
auto approx = approximate(m_trend[0]);
|
||||
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
|
||||
for (auto &trend : m_trend.keys()) {
|
||||
|
@ -46,7 +46,7 @@ QHash<QString, KSysGuard::SensorInfo *> CustomSource::sources() const
|
||||
|
||||
for (auto item : m_extScripts->activeItems())
|
||||
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;
|
||||
}
|
||||
|
@ -55,9 +55,9 @@ QHash<QString, KSysGuard::SensorInfo *> DesktopSource::sources() const
|
||||
{
|
||||
auto result = QHash<QString, KSysGuard::SensorInfo *>();
|
||||
|
||||
result.insert("name", makeSensorInfo("Current desktop name", QVariant::String));
|
||||
result.insert("number", makeSensorInfo("Current desktop number", QVariant::Int));
|
||||
result.insert("count", makeSensorInfo("Desktops count", QVariant::Int));
|
||||
result.insert("name", makeSensorInfo("Current desktop name", QMetaType::QString));
|
||||
result.insert("number", makeSensorInfo("Current desktop number", QMetaType::Int));
|
||||
result.insert("count", makeSensorInfo("Desktops count", QMetaType::Int));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ QHash<QString, KSysGuard::SensorInfo *> LoadSource::sources() const
|
||||
auto result = QHash<QString, KSysGuard::SensorInfo *>();
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -65,8 +65,8 @@ QHash<QString, KSysGuard::SensorInfo *> NetworkSource::sources() const
|
||||
{
|
||||
auto result = QHash<QString, KSysGuard::SensorInfo *>();
|
||||
|
||||
result.insert("device", makeSensorInfo("Current network device name", QVariant::String));
|
||||
result.insert("ssid", makeSensorInfo("Current SSID name", QVariant::String));
|
||||
result.insert("device", makeSensorInfo("Current network device name", QMetaType::QString));
|
||||
result.insert("ssid", makeSensorInfo("Current SSID name", QMetaType::QString));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ public:
|
||||
explicit NetworkSource(QObject *_parent);
|
||||
~NetworkSource() override;
|
||||
QVariant data(const QString &_source) override;
|
||||
void run();
|
||||
[[nodiscard]] QHash<QString, KSysGuard::SensorInfo *> sources() const override;
|
||||
|
||||
private slots:
|
||||
|
@ -115,23 +115,23 @@ QHash<QString, KSysGuard::SensorInfo *> PlayerSource::sources() const
|
||||
{
|
||||
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",
|
||||
makeSensorInfo(QString("Current song album (%1 symbols)").arg(m_symbols), QVariant::String));
|
||||
result.insert("dalbum",
|
||||
makeSensorInfo(QString("Current song album (%1 symbols, dynamic)").arg(m_symbols), QVariant::String));
|
||||
result.insert("artist", makeSensorInfo("Current song artist", QVariant::String));
|
||||
makeSensorInfo(QString("Current song album (%1 symbols)").arg(m_symbols), QMetaType::QString));
|
||||
result.insert("dalbum", makeSensorInfo(QString("Current song album (%1 symbols, dynamic)").arg(m_symbols),
|
||||
QMetaType::QString));
|
||||
result.insert("artist", makeSensorInfo("Current song artist", QMetaType::QString));
|
||||
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),
|
||||
QVariant::String));
|
||||
result.insert("duration", makeSensorInfo("Current song duration", QVariant::Int, KSysGuard::UnitSecond));
|
||||
result.insert("progress", makeSensorInfo("Current song progress", QVariant::Int, KSysGuard::UnitSecond));
|
||||
result.insert("title", makeSensorInfo("Current song title", QVariant::String));
|
||||
QMetaType::QString));
|
||||
result.insert("duration", makeSensorInfo("Current song duration", QMetaType::Int, KSysGuard::UnitSecond));
|
||||
result.insert("progress", makeSensorInfo("Current song progress", QMetaType::Int, KSysGuard::UnitSecond));
|
||||
result.insert("title", makeSensorInfo("Current song title", QMetaType::QString));
|
||||
result.insert("stitle",
|
||||
makeSensorInfo(QString("Current song title (%1 symbols)").arg(m_symbols), QVariant::String));
|
||||
result.insert("dtitle",
|
||||
makeSensorInfo(QString("Current song title (%1 symbols, dynamic)").arg(m_symbols), QVariant::String));
|
||||
makeSensorInfo(QString("Current song title (%1 symbols)").arg(m_symbols), QMetaType::QString));
|
||||
result.insert("dtitle", makeSensorInfo(QString("Current song title (%1 symbols, dynamic)").arg(m_symbols),
|
||||
QMetaType::QString));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -71,9 +71,9 @@ QHash<QString, KSysGuard::SensorInfo *> ProcessesSource::sources() const
|
||||
{
|
||||
auto result = QHash<QString, KSysGuard::SensorInfo *>();
|
||||
|
||||
result.insert("running", makeSensorInfo("Count of running processes", QVariant::Int));
|
||||
result.insert("list", makeSensorInfo("All running processes list", QVariant::StringList));
|
||||
result.insert("count", makeSensorInfo("Total count of processes", QVariant::Int));
|
||||
result.insert("running", makeSensorInfo("Count of running processes", QMetaType::Int));
|
||||
result.insert("list", makeSensorInfo("All running processes list", QMetaType::QStringList));
|
||||
result.insert("count", makeSensorInfo("Total count of processes", QMetaType::Int));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -48,17 +48,17 @@ QHash<QString, KSysGuard::SensorInfo *> QuotesSource::sources() const
|
||||
|
||||
for (auto item : m_extQuotes->activeItems()) {
|
||||
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"),
|
||||
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()),
|
||||
QVariant::Double, KSysGuard::UnitPercent, 0, 100));
|
||||
QMetaType::Double, KSysGuard::UnitPercent, 0, 100));
|
||||
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"),
|
||||
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()),
|
||||
QVariant::Double, KSysGuard::UnitPercent, 0, 100));
|
||||
QMetaType::Double, KSysGuard::UnitPercent, 0, 100));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -46,7 +46,7 @@ QHash<QString, KSysGuard::SensorInfo *> RequestSource::sources() const
|
||||
|
||||
for (auto item : m_extNetRequest->activeItems())
|
||||
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;
|
||||
}
|
||||
|
@ -54,8 +54,8 @@ QHash<QString, KSysGuard::SensorInfo *> SystemInfoSource::sources() const
|
||||
{
|
||||
auto result = QHash<QString, KSysGuard::SensorInfo *>();
|
||||
|
||||
result.insert("brightness", makeSensorInfo("Screen brightness", QVariant::Double, KSysGuard::UnitPercent, 0, 100));
|
||||
result.insert("volume", makeSensorInfo("Master volume", QVariant::Double, KSysGuard::UnitNone));
|
||||
result.insert("brightness", makeSensorInfo("Screen brightness", QMetaType::Double, KSysGuard::UnitPercent, 0, 100));
|
||||
result.insert("volume", makeSensorInfo("Master volume", QMetaType::Double, KSysGuard::UnitNone));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ QHash<QString, KSysGuard::SensorInfo *> TimeSource::sources() const
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ QHash<QString, KSysGuard::SensorInfo *> UpgradeSource::sources() const
|
||||
|
||||
for (auto item : m_extUpgrade->activeItems())
|
||||
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;
|
||||
}
|
||||
|
@ -48,17 +48,17 @@ QHash<QString, KSysGuard::SensorInfo *> WeatherSource::sources() const
|
||||
|
||||
for (auto item : m_extWeather->activeItems()) {
|
||||
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"),
|
||||
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()),
|
||||
QVariant::Int, KSysGuard::UnitPercent, 0, 100));
|
||||
QMetaType::Int, KSysGuard::UnitPercent, 0, 100));
|
||||
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()),
|
||||
QVariant::Double, KSysGuard::UnitCelsius));
|
||||
QMetaType::Double, KSysGuard::UnitCelsius));
|
||||
result.insert(item->tag("timestamp"), makeSensorInfo(QString("Timestamp for '%1'").arg(item->uniq()),
|
||||
QVariant::DateTime, KSysGuard::UnitNone));
|
||||
QMetaType::QDateTime, KSysGuard::UnitNone));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -34,7 +34,7 @@ void TestAbstractExtItem::initTestCase()
|
||||
comment = AWTestLibrary::randomString();
|
||||
socket = AWTestLibrary::randomString();
|
||||
|
||||
extItem = new ExtUpgrade(nullptr, filePath);
|
||||
extItem = new ExtUpgrade(this, filePath);
|
||||
extItem->setActive(false);
|
||||
extItem->setApiVersion(1);
|
||||
extItem->setComment(comment);
|
||||
@ -48,7 +48,6 @@ void TestAbstractExtItem::initTestCase()
|
||||
void TestAbstractExtItem::cleanupTestCase()
|
||||
{
|
||||
QFile::remove(filePath);
|
||||
delete extItem;
|
||||
}
|
||||
|
||||
|
||||
@ -83,7 +82,7 @@ void TestAbstractExtItem::test_configuration()
|
||||
QCOMPARE(newExtItem->socket(), extItem->socket());
|
||||
QCOMPARE(newExtItem->cron(), extItem->cron());
|
||||
|
||||
delete newExtItem;
|
||||
newExtItem->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
@ -102,7 +101,7 @@ void TestAbstractExtItem::test_delete()
|
||||
QVERIFY(newExtItem->tryDelete());
|
||||
QVERIFY(!QFile::exists(writeFilePath));
|
||||
|
||||
delete newExtItem;
|
||||
newExtItem->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
@ -117,7 +116,7 @@ void TestAbstractExtItem::test_copy()
|
||||
QCOMPARE(newExtItem->socket(), extItem->socket());
|
||||
QCOMPARE(newExtItem->cron(), extItem->cron());
|
||||
|
||||
delete newExtItem;
|
||||
newExtItem->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
|
@ -26,14 +26,11 @@
|
||||
void TestAbstractFormatter::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
formatter = new AWNoFormatter(nullptr);
|
||||
formatter = new AWNoFormatter(this);
|
||||
}
|
||||
|
||||
|
||||
void TestAbstractFormatter::cleanupTestCase()
|
||||
{
|
||||
delete formatter;
|
||||
}
|
||||
void TestAbstractFormatter::cleanupTestCase() {}
|
||||
|
||||
|
||||
void TestAbstractFormatter::test_values() {}
|
||||
@ -58,7 +55,7 @@ void TestAbstractFormatter::test_copy()
|
||||
QCOMPARE(newFormatter->type(), formatter->type());
|
||||
QCOMPARE(newFormatter->name(), formatter->name());
|
||||
|
||||
delete newFormatter;
|
||||
newFormatter->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,10 +31,7 @@ void TestAWBugReporter::initTestCase()
|
||||
}
|
||||
|
||||
|
||||
void TestAWBugReporter::cleanupTestCase()
|
||||
{
|
||||
delete plugin;
|
||||
}
|
||||
void TestAWBugReporter::cleanupTestCase() {}
|
||||
|
||||
|
||||
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)));
|
||||
|
||||
QVERIFY(spy.wait(5000));
|
||||
QVariantList arguments = spy.takeFirst();
|
||||
auto arguments = spy.takeFirst();
|
||||
|
||||
QVERIFY(arguments.at(0).toInt() > 0);
|
||||
QVERIFY(!arguments.at(1).toString().isEmpty());
|
||||
|
@ -30,10 +30,7 @@ void TestAWConfigHelper::initTestCase()
|
||||
}
|
||||
|
||||
|
||||
void TestAWConfigHelper::cleanupTestCase()
|
||||
{
|
||||
delete plugin;
|
||||
}
|
||||
void TestAWConfigHelper::cleanupTestCase() {}
|
||||
|
||||
|
||||
void TestAWConfigHelper::test_configurationDirectory()
|
||||
|
@ -67,10 +67,7 @@ void TestAWKeys::initTestCase()
|
||||
}
|
||||
|
||||
|
||||
void TestAWKeys::cleanupTestCase()
|
||||
{
|
||||
delete plugin;
|
||||
}
|
||||
void TestAWKeys::cleanupTestCase() {}
|
||||
|
||||
|
||||
void TestAWKeys::test_dictKeys()
|
||||
|
@ -42,7 +42,7 @@ void TestAWPatternFunctions::test_findFunctionCalls()
|
||||
|
||||
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.at(0).args, args);
|
||||
|
@ -33,10 +33,7 @@ void TestAWTelemetryHandler::initTestCase()
|
||||
}
|
||||
|
||||
|
||||
void TestAWTelemetryHandler::cleanupTestCase()
|
||||
{
|
||||
delete plugin;
|
||||
}
|
||||
void TestAWTelemetryHandler::cleanupTestCase() {}
|
||||
|
||||
|
||||
void TestAWTelemetryHandler::test_put()
|
||||
|
@ -30,10 +30,7 @@ void TestAWUpdateHelper::initTestCase()
|
||||
}
|
||||
|
||||
|
||||
void TestAWUpdateHelper::cleanupTestCase()
|
||||
{
|
||||
delete plugin;
|
||||
}
|
||||
void TestAWUpdateHelper::cleanupTestCase() {}
|
||||
|
||||
|
||||
void TestAWUpdateHelper::test_checkVersion()
|
||||
|
@ -32,10 +32,7 @@ void TestBatterySource::initTestCase()
|
||||
}
|
||||
|
||||
|
||||
void TestBatterySource::cleanupTestCase()
|
||||
{
|
||||
delete source;
|
||||
}
|
||||
void TestBatterySource::cleanupTestCase() {}
|
||||
|
||||
|
||||
void TestBatterySource::test_sources()
|
||||
@ -53,11 +50,11 @@ void TestBatterySource::test_battery()
|
||||
std::for_each(batteries.cbegin(), batteries.cend(), [this](auto bat) {
|
||||
auto value = source->data(bat);
|
||||
if (bat == "ac")
|
||||
QCOMPARE(value.type(), QVariant::Bool);
|
||||
QCOMPARE(value.typeId(), QMetaType::Bool);
|
||||
else if (bat.startsWith("batrate") || bat.startsWith("batleft"))
|
||||
;
|
||||
else
|
||||
QVERIFY((value.toFloat() >= battery.first) || (std::isnan(value.toFloat())));
|
||||
QVERIFY((value.toDouble() >= battery.first) || (std::isnan(value.toDouble())));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -29,15 +29,12 @@ void TestAWDateTimeFormatter::initTestCase()
|
||||
AWTestLibrary::init();
|
||||
format = AWTestLibrary::randomSelect(QString(TIME_KEYS).split(',')).join(' ');
|
||||
|
||||
formatter = new AWDateTimeFormatter(nullptr);
|
||||
formatter = new AWDateTimeFormatter(this);
|
||||
formatter->setFormat(format);
|
||||
}
|
||||
|
||||
|
||||
void TestAWDateTimeFormatter::cleanupTestCase()
|
||||
{
|
||||
delete formatter;
|
||||
}
|
||||
void TestAWDateTimeFormatter::cleanupTestCase() {}
|
||||
|
||||
|
||||
void TestAWDateTimeFormatter::test_values()
|
||||
@ -62,7 +59,7 @@ void TestAWDateTimeFormatter::test_copy()
|
||||
QCOMPARE(newFormatter->translateString(), formatter->translateString());
|
||||
QCOMPARE(newFormatter->number(), 1);
|
||||
|
||||
delete newFormatter;
|
||||
newFormatter->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,10 +31,7 @@ void TestDesktopSource::initTestCase()
|
||||
}
|
||||
|
||||
|
||||
void TestDesktopSource::cleanupTestCase()
|
||||
{
|
||||
delete source;
|
||||
}
|
||||
void TestDesktopSource::cleanupTestCase() {}
|
||||
|
||||
|
||||
void TestDesktopSource::test_sources()
|
||||
|
@ -32,10 +32,7 @@ void TestDPPlugin::initTestCase()
|
||||
}
|
||||
|
||||
|
||||
void TestDPPlugin::cleanupTestCase()
|
||||
{
|
||||
delete plugin;
|
||||
}
|
||||
void TestDPPlugin::cleanupTestCase() {}
|
||||
|
||||
|
||||
void TestDPPlugin::test_desktops()
|
||||
|
@ -27,14 +27,11 @@
|
||||
void TestExtItemAggregator::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
aggregator = new ExtItemAggregator<AWNoFormatter>(nullptr, type);
|
||||
aggregator = new ExtItemAggregator<AWNoFormatter>(this, type);
|
||||
}
|
||||
|
||||
|
||||
void TestExtItemAggregator::cleanupTestCase()
|
||||
{
|
||||
delete aggregator;
|
||||
}
|
||||
void TestExtItemAggregator::cleanupTestCase() {}
|
||||
|
||||
|
||||
void TestExtItemAggregator::test_values()
|
||||
|
@ -26,7 +26,7 @@
|
||||
void TestExtQuotes::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
extQuotes = new ExtQuotes(nullptr);
|
||||
extQuotes = new ExtQuotes(this);
|
||||
extQuotes->setInterval(1);
|
||||
extQuotes->setTicker(ticker);
|
||||
extQuotes->setNumber(0);
|
||||
@ -35,10 +35,7 @@ void TestExtQuotes::initTestCase()
|
||||
}
|
||||
|
||||
|
||||
void TestExtQuotes::cleanupTestCase()
|
||||
{
|
||||
delete extQuotes;
|
||||
}
|
||||
void TestExtQuotes::cleanupTestCase() {}
|
||||
|
||||
|
||||
void TestExtQuotes::test_values()
|
||||
@ -96,7 +93,7 @@ void TestExtQuotes::test_copy()
|
||||
QCOMPARE(newExtQuotes->ticker(), extQuotes->ticker());
|
||||
QCOMPARE(newExtQuotes->number(), 1);
|
||||
|
||||
delete newExtQuotes;
|
||||
newExtQuotes->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,7 +28,7 @@ void TestExtScript::initTestCase()
|
||||
AWTestLibrary::init();
|
||||
randomString = AWTestLibrary::randomString();
|
||||
|
||||
extScript = new ExtScript(nullptr);
|
||||
extScript = new ExtScript(this);
|
||||
extScript->setInterval(1);
|
||||
extScript->setExecutable(QString("echo %1").arg(randomString));
|
||||
extScript->setNumber(0);
|
||||
@ -38,10 +38,7 @@ void TestExtScript::initTestCase()
|
||||
}
|
||||
|
||||
|
||||
void TestExtScript::cleanupTestCase()
|
||||
{
|
||||
delete extScript;
|
||||
}
|
||||
void TestExtScript::cleanupTestCase() {}
|
||||
|
||||
|
||||
void TestExtScript::test_values()
|
||||
@ -95,7 +92,7 @@ void TestExtScript::test_copy()
|
||||
QCOMPARE(newExtScript->filters(), extScript->filters());
|
||||
QCOMPARE(newExtScript->number(), 1);
|
||||
|
||||
delete newExtScript;
|
||||
newExtScript->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
|
@ -29,7 +29,7 @@ void TestExtUpgrade::initTestCase()
|
||||
randomStrings = AWTestLibrary::randomStringList();
|
||||
cmd = QString("echo -e '%1'").arg(randomStrings.join("\n"));
|
||||
|
||||
extUpgrade = new ExtUpgrade(nullptr);
|
||||
extUpgrade = new ExtUpgrade(this);
|
||||
extUpgrade->setInterval(1);
|
||||
extUpgrade->setExecutable(cmd);
|
||||
extUpgrade->setNumber(0);
|
||||
@ -38,10 +38,7 @@ void TestExtUpgrade::initTestCase()
|
||||
}
|
||||
|
||||
|
||||
void TestExtUpgrade::cleanupTestCase()
|
||||
{
|
||||
delete extUpgrade;
|
||||
}
|
||||
void TestExtUpgrade::cleanupTestCase() {}
|
||||
|
||||
|
||||
void TestExtUpgrade::test_values()
|
||||
@ -106,7 +103,7 @@ void TestExtUpgrade::test_copy()
|
||||
QCOMPARE(newExtUpgrade->null(), extUpgrade->null());
|
||||
QCOMPARE(newExtUpgrade->number(), 1);
|
||||
|
||||
delete newExtUpgrade;
|
||||
newExtUpgrade->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
void TestExtWeather::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
extWeather = new ExtWeather(nullptr);
|
||||
extWeather = new ExtWeather(this);
|
||||
extWeather->setInterval(1);
|
||||
extWeather->setCity(city);
|
||||
extWeather->setCountry(country);
|
||||
@ -37,10 +37,7 @@ void TestExtWeather::initTestCase()
|
||||
}
|
||||
|
||||
|
||||
void TestExtWeather::cleanupTestCase()
|
||||
{
|
||||
delete extWeather;
|
||||
}
|
||||
void TestExtWeather::cleanupTestCase() {}
|
||||
|
||||
|
||||
void TestExtWeather::test_values()
|
||||
@ -95,7 +92,7 @@ void TestExtWeather::test_copy()
|
||||
QCOMPARE(newExtWeather->provider(), extWeather->provider());
|
||||
QCOMPARE(newExtWeather->number(), 1);
|
||||
|
||||
delete newExtWeather;
|
||||
newExtWeather->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
@ -114,8 +111,8 @@ void TestExtWeather::run()
|
||||
&& (arguments[extWeather->tag("humidity")].toInt() <= humidity.second));
|
||||
QVERIFY((arguments[extWeather->tag("pressure")].toInt() > pressure.first)
|
||||
&& (arguments[extWeather->tag("pressure")].toInt() < pressure.second));
|
||||
QVERIFY((arguments[extWeather->tag("temperature")].toFloat() > temp.first)
|
||||
&& (arguments[extWeather->tag("temperature")].toFloat() < temp.second));
|
||||
QVERIFY((arguments[extWeather->tag("temperature")].toDouble() > temp.first)
|
||||
&& (arguments[extWeather->tag("temperature")].toDouble() < temp.second));
|
||||
// image should be only one symbol here
|
||||
if (extWeather->jsonMapFile().isEmpty())
|
||||
QSKIP("No json map found for weather, skip image test");
|
||||
|
@ -27,14 +27,11 @@
|
||||
void TestAWFloatFormatter::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
formatter = new AWFloatFormatter(nullptr);
|
||||
formatter = new AWFloatFormatter(this);
|
||||
}
|
||||
|
||||
|
||||
void TestAWFloatFormatter::cleanupTestCase()
|
||||
{
|
||||
delete formatter;
|
||||
}
|
||||
void TestAWFloatFormatter::cleanupTestCase() {}
|
||||
|
||||
|
||||
void TestAWFloatFormatter::test_values() {}
|
||||
@ -95,7 +92,7 @@ void TestAWFloatFormatter::test_forceWidth()
|
||||
void TestAWFloatFormatter::test_format()
|
||||
{
|
||||
// assign
|
||||
QWARN("Lets assing 'z' formatter, it should cause a warning");
|
||||
qWarning("Lets assign 'z' formatter, it should cause a warning");
|
||||
formatter->setFormat('z');
|
||||
QCOMPARE(formatter->format(), 'f');
|
||||
formatter->setFormat('e');
|
||||
@ -175,7 +172,7 @@ void TestAWFloatFormatter::test_copy()
|
||||
QCOMPARE(newFormatter->summand(), formatter->summand());
|
||||
QCOMPARE(newFormatter->number(), 1);
|
||||
|
||||
delete newFormatter;
|
||||
newFormatter->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
|
@ -26,17 +26,14 @@
|
||||
void TestAWJsonFormatter::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
formatter = new AWJsonFormatter(nullptr);
|
||||
formatter = new AWJsonFormatter(this);
|
||||
|
||||
generate();
|
||||
formatter->setPath(path);
|
||||
}
|
||||
|
||||
|
||||
void TestAWJsonFormatter::cleanupTestCase()
|
||||
{
|
||||
delete formatter;
|
||||
}
|
||||
void TestAWJsonFormatter::cleanupTestCase() {}
|
||||
|
||||
|
||||
void TestAWJsonFormatter::test_values()
|
||||
@ -58,7 +55,7 @@ void TestAWJsonFormatter::test_copy()
|
||||
QCOMPARE(newFormatter->path(), formatter->path());
|
||||
QCOMPARE(newFormatter->number(), 1);
|
||||
|
||||
delete newFormatter;
|
||||
newFormatter->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
@ -79,8 +76,7 @@ void TestAWJsonFormatter::generate()
|
||||
} else {
|
||||
auto key = AWTestLibrary::randomString();
|
||||
auto val = AWTestLibrary::randomString();
|
||||
QVariantMap dict;
|
||||
dict[key] = val;
|
||||
QVariantMap dict{{key, val}};
|
||||
second.append(dict);
|
||||
}
|
||||
}
|
||||
|
@ -28,15 +28,12 @@ void TestAWListFormatter::initTestCase()
|
||||
AWTestLibrary::init();
|
||||
separator = AWTestLibrary::randomString(9, 10);
|
||||
|
||||
formatter = new AWListFormatter(nullptr);
|
||||
formatter = new AWListFormatter(this);
|
||||
formatter->setSeparator(separator);
|
||||
}
|
||||
|
||||
|
||||
void TestAWListFormatter::cleanupTestCase()
|
||||
{
|
||||
delete formatter;
|
||||
}
|
||||
void TestAWListFormatter::cleanupTestCase() {}
|
||||
|
||||
|
||||
void TestAWListFormatter::test_values()
|
||||
@ -85,7 +82,7 @@ void TestAWListFormatter::test_copy()
|
||||
QCOMPARE(newFormatter->separator(), formatter->separator());
|
||||
QCOMPARE(newFormatter->isSorted(), formatter->isSorted());
|
||||
|
||||
delete newFormatter;
|
||||
newFormatter->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,10 +30,7 @@ void TestNetworkSource::initTestCase()
|
||||
}
|
||||
|
||||
|
||||
void TestNetworkSource::cleanupTestCase()
|
||||
{
|
||||
delete source;
|
||||
}
|
||||
void TestNetworkSource::cleanupTestCase() {}
|
||||
|
||||
|
||||
void TestNetworkSource::test_sources()
|
||||
|
@ -26,14 +26,11 @@
|
||||
void TestAWNoFormatter::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
formatter = new AWNoFormatter(nullptr);
|
||||
formatter = new AWNoFormatter(this);
|
||||
}
|
||||
|
||||
|
||||
void TestAWNoFormatter::cleanupTestCase()
|
||||
{
|
||||
delete formatter;
|
||||
}
|
||||
void TestAWNoFormatter::cleanupTestCase() {}
|
||||
|
||||
|
||||
void TestAWNoFormatter::test_values() {}
|
||||
@ -45,7 +42,7 @@ void TestAWNoFormatter::test_conversion()
|
||||
auto randomInt = AWTestLibrary::randomInt();
|
||||
QCOMPARE(formatter->convert(randomInt), QString::number(randomInt));
|
||||
// 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
|
||||
auto randomString = AWTestLibrary::randomString();
|
||||
QCOMPARE(formatter->convert(randomString), randomString);
|
||||
@ -58,7 +55,7 @@ void TestAWNoFormatter::test_copy()
|
||||
|
||||
QCOMPARE(newFormatter->number(), 1);
|
||||
|
||||
delete newFormatter;
|
||||
newFormatter->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
|
@ -67,8 +67,10 @@ void TestPlayerSource::test_autoMpris()
|
||||
auto source = new PlayerSource(this, "mpris", mpdAddress, mpdPort, "auto", 10);
|
||||
|
||||
auto empty = source->getAutoMpris().isEmpty();
|
||||
source->deleteLater();
|
||||
|
||||
if (empty)
|
||||
QWARN("No MPRIS found, manual check required");
|
||||
qWarning("No MPRIS found, manual check required");
|
||||
else
|
||||
QVERIFY(!empty);
|
||||
}
|
||||
@ -95,6 +97,8 @@ void TestPlayerSource::test_mpd()
|
||||
QSKIP("No mpd found");
|
||||
|
||||
QVERIFY(secondValue["progress"].toInt() < secondValue["duration"].toInt());
|
||||
|
||||
source->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
@ -112,6 +116,8 @@ void TestPlayerSource::test_mpris()
|
||||
QSKIP("No mpris found");
|
||||
|
||||
QVERIFY(progress < duration);
|
||||
|
||||
source->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,10 +30,7 @@ void TestProcessesSource::initTestCase()
|
||||
}
|
||||
|
||||
|
||||
void TestProcessesSource::cleanupTestCase()
|
||||
{
|
||||
delete source;
|
||||
}
|
||||
void TestProcessesSource::cleanupTestCase() {}
|
||||
|
||||
|
||||
void TestProcessesSource::test_sources()
|
||||
|
@ -33,10 +33,7 @@ void TestAWScriptFormatter::initTestCase()
|
||||
}
|
||||
|
||||
|
||||
void TestAWScriptFormatter::cleanupTestCase()
|
||||
{
|
||||
delete formatter;
|
||||
}
|
||||
void TestAWScriptFormatter::cleanupTestCase() {}
|
||||
|
||||
|
||||
void TestAWScriptFormatter::test_values()
|
||||
@ -100,7 +97,7 @@ void TestAWScriptFormatter::test_copy()
|
||||
QCOMPARE(newFormatter->program(), formatter->program());
|
||||
QCOMPARE(newFormatter->number(), 1);
|
||||
|
||||
delete newFormatter;
|
||||
newFormatter->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
|
@ -26,14 +26,11 @@
|
||||
void TestAWStringFormatter::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
formatter = new AWStringFormatter(nullptr);
|
||||
formatter = new AWStringFormatter(this);
|
||||
}
|
||||
|
||||
|
||||
void TestAWStringFormatter::cleanupTestCase()
|
||||
{
|
||||
delete formatter;
|
||||
}
|
||||
void TestAWStringFormatter::cleanupTestCase() {}
|
||||
|
||||
|
||||
void TestAWStringFormatter::test_values() {}
|
||||
@ -104,7 +101,7 @@ void TestAWStringFormatter::test_copy()
|
||||
QCOMPARE(newFormatter->forceWidth(), formatter->forceWidth());
|
||||
QCOMPARE(newFormatter->number(), 1);
|
||||
|
||||
delete newFormatter;
|
||||
newFormatter->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user