mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-15 06:45:48 +00:00
refactor: simplify sources processing
Also fix desktop source
This commit is contained in:
@ -15,7 +15,6 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "testabstractextitem.h"
|
||||
|
||||
#include <QtTest>
|
||||
@ -75,7 +74,7 @@ void TestAbstractExtItem::test_configuration()
|
||||
{
|
||||
extItem->writeConfiguration();
|
||||
|
||||
ExtUpgrade *newExtItem = new ExtUpgrade(nullptr, writeFileName);
|
||||
auto newExtItem = new ExtUpgrade(nullptr, writeFileName);
|
||||
QCOMPARE(newExtItem->isActive(), extItem->isActive());
|
||||
QCOMPARE(newExtItem->comment(), extItem->comment());
|
||||
QCOMPARE(newExtItem->fileName(), writeFileName);
|
||||
@ -98,7 +97,7 @@ void TestAbstractExtItem::test_bumpApi()
|
||||
|
||||
void TestAbstractExtItem::test_delete()
|
||||
{
|
||||
ExtUpgrade *newExtItem = new ExtUpgrade(nullptr, writeFileName);
|
||||
auto newExtItem = new ExtUpgrade(nullptr, writeFileName);
|
||||
|
||||
QVERIFY(newExtItem->tryDelete());
|
||||
QVERIFY(!QFile::exists(writeFileName));
|
||||
@ -109,7 +108,7 @@ void TestAbstractExtItem::test_delete()
|
||||
|
||||
void TestAbstractExtItem::test_copy()
|
||||
{
|
||||
ExtUpgrade *newExtItem = extItem->copy("/dev/null", 1);
|
||||
auto newExtItem = extItem->copy("/dev/null", 1);
|
||||
|
||||
QCOMPARE(newExtItem->isActive(), extItem->isActive());
|
||||
QCOMPARE(newExtItem->apiVersion(), extItem->apiVersion());
|
||||
|
@ -15,7 +15,6 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "testabstractformatter.h"
|
||||
|
||||
#include <QtTest>
|
||||
@ -42,7 +41,7 @@ void TestAbstractFormatter::test_values() {}
|
||||
|
||||
void TestAbstractFormatter::test_type()
|
||||
{
|
||||
QString type = AWTestLibrary::randomString();
|
||||
auto type = AWTestLibrary::randomString();
|
||||
QEXPECT_FAIL("", "Will fail because of invalid format", Continue);
|
||||
formatter->setStrType(type);
|
||||
QCOMPARE(formatter->strType(), type);
|
||||
@ -54,7 +53,7 @@ void TestAbstractFormatter::test_type()
|
||||
|
||||
void TestAbstractFormatter::test_copy()
|
||||
{
|
||||
AWNoFormatter *newFormatter = formatter->copy("/dev/null", 1);
|
||||
auto newFormatter = formatter->copy("/dev/null", 1);
|
||||
|
||||
QCOMPARE(newFormatter->type(), formatter->type());
|
||||
QCOMPARE(newFormatter->name(), formatter->name());
|
||||
|
@ -40,7 +40,7 @@ void TestAWBugReporter::cleanupTestCase()
|
||||
void TestAWBugReporter::test_generateText()
|
||||
{
|
||||
data = AWTestLibrary::randomStringList(4);
|
||||
QString output = plugin->generateText(data.at(0), data.at(1), data.at(2), data.at(3));
|
||||
auto output = plugin->generateText(data.at(0), data.at(1), data.at(2), data.at(3));
|
||||
|
||||
for (auto &string : data)
|
||||
QVERIFY(output.contains(string));
|
||||
|
@ -15,7 +15,6 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "testawconfighelper.h"
|
||||
|
||||
#include <QtTest>
|
||||
@ -45,7 +44,7 @@ void TestAWConfigHelper::test_configurationDirectory()
|
||||
|
||||
void TestAWConfigHelper::test_exportConfiguration()
|
||||
{
|
||||
QStringList keys = AWTestLibrary::randomStringList();
|
||||
auto keys = AWTestLibrary::randomStringList();
|
||||
for (auto &key : keys)
|
||||
map[key] = AWTestLibrary::randomString();
|
||||
filename = AWTestLibrary::randomFilenames().first;
|
||||
@ -56,7 +55,7 @@ void TestAWConfigHelper::test_exportConfiguration()
|
||||
|
||||
void TestAWConfigHelper::test_importConfiguration()
|
||||
{
|
||||
QVariantMap imported = plugin->importConfiguration(filename, true, true, true);
|
||||
auto imported = plugin->importConfiguration(filename, true, true, true);
|
||||
QVariantMap converted;
|
||||
for (auto &key : map.keys())
|
||||
converted[key] = map.value(key);
|
||||
|
@ -15,7 +15,6 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "testawkeycache.h"
|
||||
|
||||
#include <QtTest>
|
||||
|
@ -15,7 +15,6 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "testawkeys.h"
|
||||
|
||||
#include <QDBusConnection>
|
||||
@ -82,10 +81,10 @@ void TestAWKeys::test_hddDevices()
|
||||
|
||||
void TestAWKeys::test_dictKeys()
|
||||
{
|
||||
QStringList keys = plugin->dictKeys();
|
||||
auto keys = plugin->dictKeys();
|
||||
QVERIFY(!keys.isEmpty());
|
||||
|
||||
QStringList sorted = plugin->dictKeys(true);
|
||||
auto sorted = plugin->dictKeys(true);
|
||||
QVERIFY(!sorted.isEmpty());
|
||||
QEXPECT_FAIL("", "Sorted and non-sorted lists should differ", Continue);
|
||||
QCOMPARE(keys, sorted);
|
||||
@ -101,11 +100,11 @@ void TestAWKeys::test_pattern()
|
||||
|
||||
QVERIFY(spy.wait(5 * interval));
|
||||
QVERIFY(spy.wait(5 * interval));
|
||||
QString text = spy.takeFirst().at(0).toString();
|
||||
auto text = spy.takeFirst().at(0).toString();
|
||||
|
||||
QEXPECT_FAIL("", "Pattern should be parsed", Continue);
|
||||
QCOMPARE(text, pattern);
|
||||
QStringList keys = plugin->dictKeys(true);
|
||||
auto keys = plugin->dictKeys(true);
|
||||
for (auto &key : keys)
|
||||
QVERIFY(!text.contains(key));
|
||||
}
|
||||
@ -119,7 +118,7 @@ void TestAWKeys::test_tooltip()
|
||||
QSignalSpy spy(plugin, SIGNAL(needToolTipToBeUpdated(const QString)));
|
||||
|
||||
QVERIFY(spy.wait(5 * interval));
|
||||
QString text = spy.takeFirst().at(0).toString();
|
||||
auto text = spy.takeFirst().at(0).toString();
|
||||
QVERIFY(text.startsWith("<img"));
|
||||
}
|
||||
|
||||
@ -129,7 +128,7 @@ void TestAWKeys::test_wrapNewLines()
|
||||
QSignalSpy spy(plugin, SIGNAL(needTextToBeUpdated(const QString)));
|
||||
|
||||
QVERIFY(spy.wait(5 * interval));
|
||||
QString text = spy.takeFirst().at(0).toString();
|
||||
auto text = spy.takeFirst().at(0).toString();
|
||||
QVERIFY(!text.contains("<br>") && text.contains("\n"));
|
||||
|
||||
plugin->setWrapNewLines(true);
|
||||
@ -141,10 +140,10 @@ void TestAWKeys::test_wrapNewLines()
|
||||
|
||||
void TestAWKeys::test_infoByKey()
|
||||
{
|
||||
int notEmpty = 0;
|
||||
QStringList keys = plugin->dictKeys(true);
|
||||
auto notEmpty = 0;
|
||||
auto keys = plugin->dictKeys(true);
|
||||
for (auto &key : keys) {
|
||||
QString info = plugin->infoByKey(key);
|
||||
auto info = plugin->infoByKey(key);
|
||||
QVERIFY(!info.isEmpty());
|
||||
// append non-empty field count
|
||||
if (info != "(none)")
|
||||
@ -156,8 +155,8 @@ void TestAWKeys::test_infoByKey()
|
||||
|
||||
void TestAWKeys::test_valueByKey()
|
||||
{
|
||||
int notEmpty = 0;
|
||||
QStringList keys = plugin->dictKeys(true);
|
||||
auto notEmpty = 0;
|
||||
auto keys = plugin->dictKeys(true);
|
||||
for (auto &key : keys) {
|
||||
if (!plugin->valueByKey(key).isEmpty())
|
||||
notEmpty++;
|
||||
@ -169,26 +168,25 @@ void TestAWKeys::test_valueByKey()
|
||||
void TestAWKeys::test_dbus()
|
||||
{
|
||||
// get id
|
||||
qlonglong id = reinterpret_cast<qlonglong>(plugin);
|
||||
auto id = reinterpret_cast<qlonglong>(plugin);
|
||||
|
||||
// create connection and message
|
||||
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||
auto bus = QDBusConnection::sessionBus();
|
||||
|
||||
// check if there is active sessions first
|
||||
QDBusMessage sessions
|
||||
= QDBusMessage::createMethodCall(AWDBUS_SERVICE, AWDBUS_PATH, AWDBUS_SERVICE, "ActiveServices");
|
||||
QDBusMessage sessionsResponse = bus.call(sessions, QDBus::BlockWithGui);
|
||||
auto sessions = QDBusMessage::createMethodCall(AWDBUS_SERVICE, AWDBUS_PATH, AWDBUS_SERVICE, "ActiveServices");
|
||||
auto sessionsResponse = bus.call(sessions, QDBus::BlockWithGui);
|
||||
if (sessionsResponse.arguments().isEmpty())
|
||||
QSKIP("No active sessions found, skip DBus tests");
|
||||
|
||||
// dbus checks
|
||||
QDBusMessage request = QDBusMessage::createMethodCall(QString("%1.i%2").arg(AWDBUS_SERVICE).arg(id), AWDBUS_PATH,
|
||||
AWDBUS_SERVICE, "WhoAmI");
|
||||
auto request = QDBusMessage::createMethodCall(QString("%1.i%2").arg(AWDBUS_SERVICE).arg(id), AWDBUS_PATH,
|
||||
AWDBUS_SERVICE, "WhoAmI");
|
||||
// send message to dbus
|
||||
QDBusMessage response = bus.call(request, QDBus::BlockWithGui);
|
||||
auto response = bus.call(request, QDBus::BlockWithGui);
|
||||
|
||||
// parse result
|
||||
QList<QVariant> arguments = response.arguments();
|
||||
auto arguments = response.arguments();
|
||||
QVERIFY(!arguments.isEmpty());
|
||||
QCOMPARE(arguments.at(0).toLongLong(), id);
|
||||
}
|
||||
|
@ -15,7 +15,6 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "testawpatternfunctions.h"
|
||||
|
||||
#include <QRegularExpression>
|
||||
@ -36,12 +35,12 @@ void TestAWPatternFunctions::cleanupTestCase() {}
|
||||
|
||||
void TestAWPatternFunctions::test_findFunctionCalls()
|
||||
{
|
||||
QString name = QString("aw_%1").arg(AWTestLibrary::randomString(1, 10));
|
||||
QString code = AWTestLibrary::randomString(1, 20);
|
||||
QStringList args = AWTestLibrary::randomStringList(20);
|
||||
QString function = QString("$%1<%2>{{%3}}").arg(name).arg(args.join(',')).arg(code);
|
||||
auto name = QString("aw_%1").arg(AWTestLibrary::randomString(1, 10));
|
||||
auto code = AWTestLibrary::randomString(1, 20);
|
||||
auto args = AWTestLibrary::randomStringList(20);
|
||||
auto function = QString("$%1<%2>{{%3}}").arg(name).arg(args.join(',')).arg(code);
|
||||
|
||||
QString pattern = AWTestLibrary::randomString() + function + AWTestLibrary::randomString();
|
||||
auto pattern = AWTestLibrary::randomString() + function + AWTestLibrary::randomString();
|
||||
|
||||
QList<AWPatternFunctions::AWFunction> found = AWPatternFunctions::findFunctionCalls(name, pattern);
|
||||
QCOMPARE(found.count(), 1);
|
||||
@ -54,9 +53,9 @@ void TestAWPatternFunctions::test_findFunctionCalls()
|
||||
|
||||
void TestAWPatternFunctions::test_findKeys()
|
||||
{
|
||||
int count = AWTestLibrary::randomInt(200);
|
||||
auto count = AWTestLibrary::randomInt(200);
|
||||
QStringList allKeys;
|
||||
for (int i = 0; i < count; i++) {
|
||||
for (auto i = 0; i < count; i++) {
|
||||
auto key = AWTestLibrary::randomString(1, 20);
|
||||
while (allKeys.indexOf(QRegularExpression(QString("^%1.*").arg(key))) != -1)
|
||||
key = AWTestLibrary::randomString(1, 20);
|
||||
@ -65,8 +64,8 @@ void TestAWPatternFunctions::test_findKeys()
|
||||
|
||||
auto keys = AWTestLibrary::randomSelect(allKeys);
|
||||
auto bars = AWTestLibrary::randomSelect(allKeys);
|
||||
std::for_each(bars.begin(), bars.end(), [](QString &bar) { bar.prepend("bar"); });
|
||||
QString pattern = QString("$%1 $%2").arg(keys.join(" $")).arg(bars.join(" $"));
|
||||
std::for_each(bars.begin(), bars.end(), [](auto &bar) { bar.prepend("bar"); });
|
||||
auto pattern = QString("$%1 $%2").arg(keys.join(" $")).arg(bars.join(" $"));
|
||||
|
||||
allKeys.append(bars);
|
||||
allKeys.sort();
|
||||
@ -74,9 +73,9 @@ void TestAWPatternFunctions::test_findKeys()
|
||||
keys.sort();
|
||||
bars.sort();
|
||||
|
||||
QStringList foundKeys = AWPatternFunctions::findKeys(pattern, allKeys, false);
|
||||
auto foundKeys = AWPatternFunctions::findKeys(pattern, allKeys, false);
|
||||
foundKeys.sort();
|
||||
QStringList foundBars = AWPatternFunctions::findKeys(pattern, allKeys, true);
|
||||
auto foundBars = AWPatternFunctions::findKeys(pattern, allKeys, true);
|
||||
foundBars.sort();
|
||||
|
||||
QCOMPARE(foundKeys, keys);
|
||||
@ -86,8 +85,8 @@ void TestAWPatternFunctions::test_findKeys()
|
||||
|
||||
void TestAWPatternFunctions::test_findLambdas()
|
||||
{
|
||||
QStringList lambdas = AWTestLibrary::randomStringList(20);
|
||||
QString pattern
|
||||
auto lambdas = AWTestLibrary::randomStringList(20);
|
||||
auto pattern
|
||||
= AWTestLibrary::randomString() + QString("${{%1}}").arg(lambdas.join("}}${{")) + AWTestLibrary::randomString();
|
||||
|
||||
QCOMPARE(AWPatternFunctions::findLambdas(pattern), lambdas);
|
||||
@ -96,12 +95,12 @@ void TestAWPatternFunctions::test_findLambdas()
|
||||
|
||||
void TestAWPatternFunctions::test_expandTemplates()
|
||||
{
|
||||
int firstValue = AWTestLibrary::randomInt();
|
||||
int secondValue = AWTestLibrary::randomInt();
|
||||
int result = firstValue + secondValue;
|
||||
QString code = QString("$template{{%1+%2}}").arg(firstValue).arg(secondValue);
|
||||
QString prefix = AWTestLibrary::randomString();
|
||||
QString pattern = prefix + code;
|
||||
auto firstValue = AWTestLibrary::randomInt();
|
||||
auto secondValue = AWTestLibrary::randomInt();
|
||||
auto result = firstValue + secondValue;
|
||||
auto code = QString("$template{{%1+%2}}").arg(firstValue).arg(secondValue);
|
||||
auto prefix = AWTestLibrary::randomString();
|
||||
auto pattern = prefix + code;
|
||||
|
||||
QCOMPARE(AWPatternFunctions::expandTemplates(pattern), QString("%1%2").arg(prefix).arg(result));
|
||||
}
|
||||
|
@ -15,7 +15,6 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "testawtelemetryhandler.h"
|
||||
|
||||
#include <QtTest>
|
||||
@ -48,7 +47,7 @@ void TestAWTelemetryHandler::test_put()
|
||||
|
||||
void TestAWTelemetryHandler::test_get()
|
||||
{
|
||||
QStringList output = plugin->get(telemetryGroup);
|
||||
auto output = plugin->get(telemetryGroup);
|
||||
|
||||
QVERIFY(!output.isEmpty());
|
||||
QCOMPARE(QSet<QString>(output.cbegin(), output.cend()).count(), output.count());
|
||||
@ -70,7 +69,7 @@ void TestAWTelemetryHandler::test_uploadTelemetry()
|
||||
plugin->uploadTelemetry(telemetryValidGroup, telemetryData);
|
||||
|
||||
QVERIFY(spy.wait(5000));
|
||||
QVariantList arguments = spy.takeFirst();
|
||||
auto arguments = spy.takeFirst();
|
||||
|
||||
QCOMPARE(arguments.at(0).toString(), telemetryStatus);
|
||||
}
|
||||
|
@ -15,7 +15,6 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "testawupdatehelper.h"
|
||||
|
||||
#include <QtTest>
|
||||
|
@ -15,7 +15,6 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "testbatterysource.h"
|
||||
|
||||
#include <QtTest>
|
||||
@ -29,7 +28,7 @@
|
||||
void TestBatterySource::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
source = new BatterySource(this, QStringList() << acpiPath);
|
||||
source = new BatterySource(this, acpiPath);
|
||||
}
|
||||
|
||||
|
||||
@ -41,8 +40,7 @@ void TestBatterySource::cleanupTestCase()
|
||||
|
||||
void TestBatterySource::test_sources()
|
||||
{
|
||||
//
|
||||
QVERIFY(source->sources().length() >= 6);
|
||||
QVERIFY(source->sources().count() >= 6);
|
||||
}
|
||||
|
||||
|
||||
@ -51,9 +49,9 @@ void TestBatterySource::test_battery()
|
||||
if (source->sources().count() == 6)
|
||||
QSKIP("No battery found, test will be skipped");
|
||||
|
||||
QStringList batteries = source->sources();
|
||||
std::for_each(batteries.begin(), batteries.end(), [this](const QString &bat) {
|
||||
QVariant value = source->data(bat);
|
||||
auto batteries = source->sources().keys();
|
||||
std::for_each(batteries.cbegin(), batteries.cend(), [this](auto bat) {
|
||||
auto value = source->data(bat);
|
||||
if (bat == "ac")
|
||||
QCOMPARE(value.type(), QVariant::Bool);
|
||||
else if (bat.startsWith("batrate") || bat.startsWith("batleft"))
|
||||
|
@ -15,7 +15,6 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "testdatetimeformatter.h"
|
||||
|
||||
#include <QtTest>
|
||||
@ -57,7 +56,7 @@ void TestAWDateTimeFormatter::test_conversion()
|
||||
void TestAWDateTimeFormatter::test_copy()
|
||||
{
|
||||
formatter->setTranslateString(false);
|
||||
auto *newFormatter = formatter->copy("/dev/null", 1);
|
||||
auto newFormatter = formatter->copy("/dev/null", 1);
|
||||
|
||||
QCOMPARE(newFormatter->format(), formatter->format());
|
||||
QCOMPARE(newFormatter->translateString(), formatter->translateString());
|
||||
|
@ -15,7 +15,6 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "testdesktopsource.h"
|
||||
|
||||
#include <QtTest>
|
||||
@ -27,7 +26,8 @@
|
||||
void TestDesktopSource::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
source = new DesktopSource(this, QStringList());
|
||||
source = new DesktopSource(this);
|
||||
m_isKwinActive = AWTestLibrary::isKWinActive();
|
||||
}
|
||||
|
||||
|
||||
@ -39,18 +39,18 @@ void TestDesktopSource::cleanupTestCase()
|
||||
|
||||
void TestDesktopSource::test_sources()
|
||||
{
|
||||
QCOMPARE(source->sources().count(), 4);
|
||||
QCOMPARE(source->sources().count(), 3);
|
||||
}
|
||||
|
||||
|
||||
void TestDesktopSource::test_values()
|
||||
{
|
||||
QSKIP("Tests are failing with current api");
|
||||
if (!m_isKwinActive)
|
||||
QSKIP("KWin inactive, skip desktop tests");
|
||||
|
||||
QVERIFY(source->data("desktop/current/name").toString().length() > 0);
|
||||
QVERIFY(source->data("desktop/current/number").toInt() >= 0);
|
||||
QVERIFY(source->data("desktop/total/name").toStringList().count() > 0);
|
||||
QVERIFY(source->data("desktop/total/number").toInt() > 0);
|
||||
QVERIFY(source->data("name").toString().length() > 0);
|
||||
QVERIFY(source->data("number").toInt() >= 0);
|
||||
QVERIFY(source->data("count").toInt() > 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -36,4 +36,5 @@ private slots:
|
||||
|
||||
private:
|
||||
DesktopSource *source = nullptr;
|
||||
bool m_isKwinActive = false;
|
||||
};
|
||||
|
@ -15,7 +15,6 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "testdpplugin.h"
|
||||
|
||||
#include <KWindowSystem>
|
||||
@ -44,8 +43,8 @@ void TestDPPlugin::test_desktops()
|
||||
if (!m_isKwinActive)
|
||||
QSKIP("KWin inactive, skip Destkop panel tests");
|
||||
|
||||
int current = plugin->currentDesktop();
|
||||
int total = plugin->numberOfDesktops();
|
||||
auto current = plugin->currentDesktop();
|
||||
auto total = plugin->numberOfDesktops();
|
||||
QVERIFY(total != 0);
|
||||
QVERIFY(current <= total);
|
||||
|
||||
@ -90,7 +89,7 @@ void TestDPPlugin::test_parsePattern()
|
||||
if (!m_isKwinActive)
|
||||
QSKIP("KWin inactive, skip Destkop panel tests");
|
||||
|
||||
QString result = plugin->parsePattern(pattern, plugin->currentDesktop());
|
||||
auto result = plugin->parsePattern(pattern, plugin->currentDesktop());
|
||||
QVERIFY(!result.isEmpty());
|
||||
QVERIFY(result != pattern);
|
||||
for (auto &key : plugin->dictKeys())
|
||||
@ -109,7 +108,7 @@ void TestDPPlugin::test_tooltipImage()
|
||||
data["tooltipWidth"] = 300;
|
||||
plugin->setToolTipData(data);
|
||||
|
||||
QString image = plugin->toolTipImage(plugin->currentDesktop());
|
||||
auto image = plugin->toolTipImage(plugin->currentDesktop());
|
||||
QVERIFY(image.startsWith("<img src=\""));
|
||||
QVERIFY(image.endsWith("\"/>"));
|
||||
}
|
||||
|
@ -15,7 +15,6 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "testextitemaggregator.h"
|
||||
|
||||
#include <QtTest>
|
||||
|
@ -15,7 +15,6 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "testextquotes.h"
|
||||
|
||||
#include <QtTest>
|
||||
@ -54,11 +53,11 @@ void TestExtQuotes::test_run()
|
||||
{
|
||||
// init spy
|
||||
QSignalSpy spy(extQuotes, SIGNAL(dataReceived(const QVariantHash &)));
|
||||
QVariantHash firstValue = extQuotes->run();
|
||||
auto firstValue = extQuotes->run();
|
||||
|
||||
// check values
|
||||
QVERIFY(spy.wait(5000));
|
||||
QList<QVariant> arguments = spy.takeFirst();
|
||||
auto arguments = spy.takeFirst();
|
||||
for (auto &type : types)
|
||||
cache[type] = arguments.at(0).toHash()[extQuotes->tag(type)];
|
||||
|
||||
@ -73,11 +72,11 @@ void TestExtQuotes::test_derivatives()
|
||||
{
|
||||
// init spy
|
||||
QSignalSpy spy(extQuotes, SIGNAL(dataReceived(const QVariantHash &)));
|
||||
QVariantHash firstValue = extQuotes->run();
|
||||
auto firstValue = extQuotes->run();
|
||||
|
||||
// check values
|
||||
QVERIFY(spy.wait(5000));
|
||||
QList<QVariant> arguments = spy.takeFirst();
|
||||
auto arguments = spy.takeFirst();
|
||||
QVariantHash values;
|
||||
for (auto &type : types)
|
||||
values[type] = arguments.at(0).toHash()[extQuotes->tag(type)];
|
||||
@ -91,7 +90,7 @@ void TestExtQuotes::test_derivatives()
|
||||
|
||||
void TestExtQuotes::test_copy()
|
||||
{
|
||||
ExtQuotes *newExtQuotes = extQuotes->copy("/dev/null", 1);
|
||||
auto newExtQuotes = extQuotes->copy("/dev/null", 1);
|
||||
|
||||
QCOMPARE(newExtQuotes->interval(), extQuotes->interval());
|
||||
QCOMPARE(newExtQuotes->ticker(), extQuotes->ticker());
|
||||
|
@ -15,7 +15,6 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "testextscript.h"
|
||||
|
||||
#include <QtTest>
|
||||
@ -58,11 +57,11 @@ void TestExtScript::test_run()
|
||||
{
|
||||
// init spy
|
||||
QSignalSpy spy(extScript, SIGNAL(dataReceived(const QVariantHash &)));
|
||||
QVariantHash firstValue = extScript->run();
|
||||
auto firstValue = extScript->run();
|
||||
|
||||
// check values
|
||||
QVERIFY(spy.wait(5000));
|
||||
QList<QVariant> arguments = spy.takeFirst();
|
||||
auto arguments = spy.takeFirst();
|
||||
|
||||
QCOMPARE(firstValue[extScript->tag("custom")].toString(), QString());
|
||||
QCOMPARE(arguments.at(0).toHash()[extScript->tag("custom")].toString(), QString("\n%1").arg(randomString));
|
||||
@ -81,14 +80,14 @@ void TestExtScript::test_filters()
|
||||
|
||||
// check values
|
||||
QVERIFY(spy.wait(5000));
|
||||
QList<QVariant> arguments = spy.takeFirst();
|
||||
auto arguments = spy.takeFirst();
|
||||
QCOMPARE(arguments.at(0).toHash()[extScript->tag("custom")].toString(), QString("<br>%1").arg(randomString));
|
||||
}
|
||||
|
||||
|
||||
void TestExtScript::test_copy()
|
||||
{
|
||||
ExtScript *newExtScript = extScript->copy("/dev/null", 1);
|
||||
auto newExtScript = extScript->copy("/dev/null", 1);
|
||||
|
||||
QCOMPARE(newExtScript->interval(), extScript->interval());
|
||||
QCOMPARE(newExtScript->executable(), extScript->executable());
|
||||
|
@ -15,7 +15,6 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "testextupgrade.h"
|
||||
|
||||
#include <QtTest>
|
||||
@ -57,11 +56,11 @@ void TestExtUpgrade::test_run()
|
||||
{
|
||||
// init spy
|
||||
QSignalSpy spy(extUpgrade, SIGNAL(dataReceived(const QVariantHash &)));
|
||||
QVariantHash firstValue = extUpgrade->run();
|
||||
auto firstValue = extUpgrade->run();
|
||||
|
||||
// check values
|
||||
QVERIFY(spy.wait(5000));
|
||||
QList<QVariant> arguments = spy.takeFirst();
|
||||
auto arguments = spy.takeFirst();
|
||||
|
||||
QCOMPARE(firstValue[extUpgrade->tag("pkgcount")].toInt(), 0);
|
||||
QCOMPARE(arguments.at(0).toHash()[extUpgrade->tag("pkgcount")].toInt(), randomStrings.count());
|
||||
@ -70,21 +69,21 @@ void TestExtUpgrade::test_run()
|
||||
|
||||
void TestExtUpgrade::test_null()
|
||||
{
|
||||
int null = AWTestLibrary::randomInt(randomStrings.count());
|
||||
auto null = AWTestLibrary::randomInt(randomStrings.count());
|
||||
extUpgrade->setNull(null);
|
||||
QSignalSpy spy(extUpgrade, SIGNAL(dataReceived(const QVariantHash &)));
|
||||
extUpgrade->run();
|
||||
|
||||
// check values
|
||||
QVERIFY(spy.wait(5000));
|
||||
QList<QVariant> arguments = spy.takeFirst();
|
||||
auto arguments = spy.takeFirst();
|
||||
QCOMPARE(arguments.at(0).toHash()[extUpgrade->tag("pkgcount")].toInt(), randomStrings.count() - null);
|
||||
}
|
||||
|
||||
|
||||
void TestExtUpgrade::test_filter()
|
||||
{
|
||||
QStringList filters = AWTestLibrary::randomSelect(randomStrings);
|
||||
auto filters = AWTestLibrary::randomSelect(randomStrings);
|
||||
extUpgrade->setFilter(QString("(^%1$)").arg(filters.join("$|^")));
|
||||
// init spy
|
||||
QSignalSpy spy(extUpgrade, SIGNAL(dataReceived(const QVariantHash &)));
|
||||
@ -92,14 +91,14 @@ void TestExtUpgrade::test_filter()
|
||||
|
||||
// check values
|
||||
QVERIFY(spy.wait(5000));
|
||||
QList<QVariant> arguments = spy.takeFirst();
|
||||
auto arguments = spy.takeFirst();
|
||||
QCOMPARE(arguments.at(0).toHash()[extUpgrade->tag("pkgcount")].toInt(), filters.count());
|
||||
}
|
||||
|
||||
|
||||
void TestExtUpgrade::test_copy()
|
||||
{
|
||||
ExtUpgrade *newExtUpgrade = extUpgrade->copy("/dev/null", 1);
|
||||
auto newExtUpgrade = extUpgrade->copy("/dev/null", 1);
|
||||
|
||||
QCOMPARE(newExtUpgrade->interval(), extUpgrade->interval());
|
||||
QCOMPARE(newExtUpgrade->executable(), extUpgrade->executable());
|
||||
|
@ -15,7 +15,6 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "testextweather.h"
|
||||
|
||||
#include <QtTest>
|
||||
@ -75,18 +74,18 @@ void TestExtWeather::test_image()
|
||||
extWeather->setImage(true);
|
||||
// init spy
|
||||
QSignalSpy spy(extWeather, SIGNAL(dataReceived(const QVariantHash &)));
|
||||
QVariantHash firstValue = extWeather->run();
|
||||
auto firstValue = extWeather->run();
|
||||
|
||||
// check values
|
||||
QVERIFY(spy.wait(5000));
|
||||
QVariantHash arguments = spy.takeFirst().at(0).toHash();
|
||||
auto arguments = spy.takeFirst().at(0).toHash();
|
||||
QVERIFY(arguments[extWeather->tag("weather")].toString().startsWith("<img"));
|
||||
}
|
||||
|
||||
|
||||
void TestExtWeather::test_copy()
|
||||
{
|
||||
ExtWeather *newExtWeather = extWeather->copy("/dev/null", 1);
|
||||
auto newExtWeather = extWeather->copy("/dev/null", 1);
|
||||
|
||||
QCOMPARE(newExtWeather->interval(), extWeather->interval());
|
||||
QCOMPARE(newExtWeather->city(), extWeather->city());
|
||||
@ -104,11 +103,11 @@ void TestExtWeather::run()
|
||||
{
|
||||
// init spy
|
||||
QSignalSpy spy(extWeather, SIGNAL(dataReceived(const QVariantHash &)));
|
||||
QVariantHash firstValue = extWeather->run();
|
||||
auto firstValue = extWeather->run();
|
||||
|
||||
// check values
|
||||
QVERIFY(spy.wait(5000));
|
||||
QVariantHash arguments = spy.takeFirst().at(0).toHash();
|
||||
auto arguments = spy.takeFirst().at(0).toHash();
|
||||
QEXPECT_FAIL("", "WeatherID should not be 0", Continue);
|
||||
QCOMPARE(arguments[extWeather->tag("weatherId")].toInt(), 0);
|
||||
QVERIFY((arguments[extWeather->tag("humidity")].toInt() >= humidity.first)
|
||||
|
@ -15,7 +15,6 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "testfloatformatter.h"
|
||||
|
||||
#include <QRandomGenerator>
|
||||
@ -44,12 +43,12 @@ void TestAWFloatFormatter::test_values() {}
|
||||
void TestAWFloatFormatter::test_count()
|
||||
{
|
||||
// assign
|
||||
int count = 10 + AWTestLibrary::randomInt();
|
||||
auto count = 10 + AWTestLibrary::randomInt();
|
||||
formatter->setCount(count);
|
||||
QCOMPARE(formatter->count(), count);
|
||||
|
||||
// test
|
||||
QString output = formatter->convert(QRandomGenerator::global()->generateDouble());
|
||||
auto output = formatter->convert(QRandomGenerator::global()->generateDouble());
|
||||
QCOMPARE(output.length(), count);
|
||||
|
||||
// reset
|
||||
@ -60,13 +59,13 @@ void TestAWFloatFormatter::test_count()
|
||||
void TestAWFloatFormatter::test_fillChar()
|
||||
{
|
||||
// assign
|
||||
char c = AWTestLibrary::randomChar();
|
||||
auto c = AWTestLibrary::randomChar();
|
||||
formatter->setFillChar(c);
|
||||
QCOMPARE(formatter->fillChar(), QChar(c));
|
||||
formatter->setCount(101);
|
||||
|
||||
// test
|
||||
QString output = formatter->convert(AWTestLibrary::randomInt());
|
||||
auto output = formatter->convert(AWTestLibrary::randomInt());
|
||||
QVERIFY(output.startsWith(c));
|
||||
|
||||
// reset
|
||||
@ -78,13 +77,13 @@ void TestAWFloatFormatter::test_fillChar()
|
||||
void TestAWFloatFormatter::test_forceWidth()
|
||||
{
|
||||
// assign
|
||||
int count = AWTestLibrary::randomInt(6);
|
||||
auto count = AWTestLibrary::randomInt(6);
|
||||
formatter->setForceWidth(true);
|
||||
formatter->setCount(count);
|
||||
QCOMPARE(formatter->forceWidth(), true);
|
||||
|
||||
// test
|
||||
QString output = formatter->convert(QRandomGenerator::global()->generateDouble());
|
||||
auto output = formatter->convert(QRandomGenerator::global()->generateDouble());
|
||||
QCOMPARE(output.length(), count);
|
||||
|
||||
// reset
|
||||
@ -103,7 +102,7 @@ void TestAWFloatFormatter::test_format()
|
||||
QCOMPARE(formatter->format(), 'e');
|
||||
|
||||
// test
|
||||
QString output = formatter->convert(QRandomGenerator::global()->generateDouble());
|
||||
auto output = formatter->convert(QRandomGenerator::global()->generateDouble());
|
||||
QVERIFY(output.contains('e'));
|
||||
|
||||
// reset
|
||||
@ -114,12 +113,12 @@ void TestAWFloatFormatter::test_format()
|
||||
void TestAWFloatFormatter::test_precision()
|
||||
{
|
||||
// assign
|
||||
int precision = 1 + AWTestLibrary::randomInt(5);
|
||||
auto precision = 1 + AWTestLibrary::randomInt(5);
|
||||
formatter->setPrecision(precision);
|
||||
QCOMPARE(formatter->precision(), precision);
|
||||
|
||||
// test
|
||||
QString output = formatter->convert(QRandomGenerator::global()->generateDouble());
|
||||
auto output = formatter->convert(QRandomGenerator::global()->generateDouble());
|
||||
output.remove("0.");
|
||||
QCOMPARE(output.length(), precision);
|
||||
|
||||
@ -133,12 +132,12 @@ void TestAWFloatFormatter::test_multiplier()
|
||||
formatter->setPrecision(6);
|
||||
|
||||
// assign
|
||||
double multiplier = QRandomGenerator::global()->generateDouble();
|
||||
auto multiplier = QRandomGenerator::global()->generateDouble();
|
||||
formatter->setMultiplier(multiplier);
|
||||
QCOMPARE(formatter->multiplier(), multiplier);
|
||||
|
||||
// test
|
||||
double value = QRandomGenerator::global()->generateDouble();
|
||||
auto value = QRandomGenerator::global()->generateDouble();
|
||||
QCOMPARE(formatter->convert(value), QString::number(value * multiplier, 'f', 6));
|
||||
|
||||
// reset
|
||||
@ -149,12 +148,12 @@ void TestAWFloatFormatter::test_multiplier()
|
||||
void TestAWFloatFormatter::test_summand()
|
||||
{
|
||||
// assign
|
||||
double summand = QRandomGenerator::global()->generateDouble();
|
||||
auto summand = QRandomGenerator::global()->generateDouble();
|
||||
formatter->setSummand(summand);
|
||||
QCOMPARE(formatter->summand(), summand);
|
||||
|
||||
// test
|
||||
double value = QRandomGenerator::global()->generateDouble();
|
||||
auto value = QRandomGenerator::global()->generateDouble();
|
||||
QCOMPARE(formatter->convert(value), QString::number(value + summand, 'f', 6));
|
||||
|
||||
// reset
|
||||
@ -165,7 +164,7 @@ void TestAWFloatFormatter::test_summand()
|
||||
void TestAWFloatFormatter::test_copy()
|
||||
{
|
||||
doRandom();
|
||||
AWFloatFormatter *newFormatter = formatter->copy("/dev/null", 1);
|
||||
auto newFormatter = formatter->copy("/dev/null", 1);
|
||||
|
||||
QCOMPARE(newFormatter->count(), formatter->count());
|
||||
QCOMPARE(newFormatter->fillChar(), formatter->fillChar());
|
||||
|
@ -15,7 +15,6 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "testjsonformatter.h"
|
||||
|
||||
#include <QtTest>
|
||||
@ -54,7 +53,7 @@ void TestAWJsonFormatter::test_conversion()
|
||||
|
||||
void TestAWJsonFormatter::test_copy()
|
||||
{
|
||||
AWJsonFormatter *newFormatter = formatter->copy("/dev/null", 1);
|
||||
auto newFormatter = formatter->copy("/dev/null", 1);
|
||||
|
||||
QCOMPARE(newFormatter->path(), formatter->path());
|
||||
QCOMPARE(newFormatter->number(), 1);
|
||||
@ -68,25 +67,25 @@ void TestAWJsonFormatter::generate()
|
||||
value = AWTestLibrary::randomString();
|
||||
|
||||
QVariantMap first;
|
||||
QString firstKey = AWTestLibrary::randomString();
|
||||
auto firstKey = AWTestLibrary::randomString();
|
||||
first[firstKey] = value;
|
||||
|
||||
int listCount = AWTestLibrary::randomInt(5) + 1;
|
||||
int validCount = AWTestLibrary::randomInt(listCount);
|
||||
auto listCount = AWTestLibrary::randomInt(5) + 1;
|
||||
auto validCount = AWTestLibrary::randomInt(listCount);
|
||||
QVariantList second;
|
||||
for (int i = 0; i < listCount; i++) {
|
||||
for (auto i = 0; i < listCount; i++) {
|
||||
if (i == validCount) {
|
||||
second.append(first);
|
||||
} else {
|
||||
QString key = AWTestLibrary::randomString();
|
||||
QString val = AWTestLibrary::randomString();
|
||||
auto key = AWTestLibrary::randomString();
|
||||
auto val = AWTestLibrary::randomString();
|
||||
QVariantMap dict;
|
||||
dict[key] = val;
|
||||
second.append(dict);
|
||||
}
|
||||
}
|
||||
|
||||
QString thirdKey = AWTestLibrary::randomString();
|
||||
auto thirdKey = AWTestLibrary::randomString();
|
||||
QVariantMap output;
|
||||
output[thirdKey] = second;
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "testlistformatter.h"
|
||||
|
||||
#include <QtTest>
|
||||
@ -50,7 +49,7 @@ void TestAWListFormatter::test_values()
|
||||
|
||||
void TestAWListFormatter::test_conversion()
|
||||
{
|
||||
QStringList value = AWTestLibrary::randomStringList();
|
||||
auto value = AWTestLibrary::randomStringList();
|
||||
QCOMPARE(formatter->convert(value), value.join(separator));
|
||||
}
|
||||
|
||||
@ -58,8 +57,8 @@ void TestAWListFormatter::test_conversion()
|
||||
void TestAWListFormatter::test_sorted()
|
||||
{
|
||||
formatter->setSorted(true);
|
||||
QStringList value = AWTestLibrary::randomStringList();
|
||||
QString received = formatter->convert(value);
|
||||
auto value = AWTestLibrary::randomStringList();
|
||||
auto received = formatter->convert(value);
|
||||
|
||||
value.sort();
|
||||
QCOMPARE(received, value.join(separator));
|
||||
@ -68,8 +67,8 @@ void TestAWListFormatter::test_sorted()
|
||||
|
||||
void TestAWListFormatter::test_filter()
|
||||
{
|
||||
QStringList value = AWTestLibrary::randomStringList();
|
||||
QStringList filters = AWTestLibrary::randomSelect(value);
|
||||
auto value = AWTestLibrary::randomStringList();
|
||||
auto filters = AWTestLibrary::randomSelect(value);
|
||||
value.sort();
|
||||
formatter->setFilter(QString("(^%1$)").arg(filters.join("$|^")));
|
||||
|
||||
@ -79,7 +78,7 @@ void TestAWListFormatter::test_filter()
|
||||
|
||||
void TestAWListFormatter::test_copy()
|
||||
{
|
||||
AWListFormatter *newFormatter = formatter->copy("/dev/null", 1);
|
||||
auto newFormatter = formatter->copy("/dev/null", 1);
|
||||
|
||||
QCOMPARE(newFormatter->number(), 1);
|
||||
QCOMPARE(newFormatter->filter(), formatter->filter());
|
||||
|
@ -15,7 +15,6 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "testnetworksource.h"
|
||||
|
||||
#include <QtTest>
|
||||
@ -27,7 +26,7 @@
|
||||
void TestNetworkSource::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
source = new NetworkSource(this, QStringList());
|
||||
source = new NetworkSource(this);
|
||||
}
|
||||
|
||||
|
||||
@ -39,7 +38,9 @@ void TestNetworkSource::cleanupTestCase()
|
||||
|
||||
void TestNetworkSource::test_sources()
|
||||
{
|
||||
QCOMPARE(source->sources(), QStringList({"device", "ssid"}));
|
||||
auto sources = source->sources();
|
||||
QVERIFY(sources.contains("device"));
|
||||
QVERIFY(sources.contains("ssid"));
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "testnoformatter.h"
|
||||
|
||||
#include <QtTest>
|
||||
@ -43,19 +42,19 @@ void TestAWNoFormatter::test_values() {}
|
||||
void TestAWNoFormatter::test_conversion()
|
||||
{
|
||||
// integer
|
||||
int randomInt = AWTestLibrary::randomInt();
|
||||
auto randomInt = AWTestLibrary::randomInt();
|
||||
QCOMPARE(formatter->convert(randomInt), QString::number(randomInt));
|
||||
// float
|
||||
QWARN("Float conversion isn't tested here due to possible rounding errors");
|
||||
// string
|
||||
QString randomString = AWTestLibrary::randomString();
|
||||
auto randomString = AWTestLibrary::randomString();
|
||||
QCOMPARE(formatter->convert(randomString), randomString);
|
||||
}
|
||||
|
||||
|
||||
void TestAWNoFormatter::test_copy()
|
||||
{
|
||||
AWNoFormatter *newFormatter = formatter->copy("/dev/null", 1);
|
||||
auto newFormatter = formatter->copy("/dev/null", 1);
|
||||
|
||||
QCOMPARE(newFormatter->number(), 1);
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "testplayersource.h"
|
||||
|
||||
#include <QtTest>
|
||||
@ -41,8 +40,8 @@ void TestPlayerSource::_test_sources(const PlayerSource *_source)
|
||||
|
||||
void TestPlayerSource::test_buildString()
|
||||
{
|
||||
QString randomString = AWTestLibrary::randomString(1, 40);
|
||||
QString str = PlayerSource::buildString("", randomString, 20);
|
||||
auto randomString = AWTestLibrary::randomString(1, 40);
|
||||
auto str = PlayerSource::buildString("", randomString, 20);
|
||||
QCOMPARE(str.length(), 20);
|
||||
|
||||
str = PlayerSource::buildString(str, randomString, 20);
|
||||
@ -55,7 +54,7 @@ void TestPlayerSource::test_buildString()
|
||||
|
||||
void TestPlayerSource::test_stripString()
|
||||
{
|
||||
QString str = PlayerSource::buildString("", AWTestLibrary::randomString(1, 40), 20);
|
||||
auto str = PlayerSource::buildString("", AWTestLibrary::randomString(1, 40), 20);
|
||||
QCOMPARE(str.length(), 20);
|
||||
|
||||
str = PlayerSource::buildString("", AWTestLibrary::randomString(1, 10), 20);
|
||||
@ -65,11 +64,9 @@ void TestPlayerSource::test_stripString()
|
||||
|
||||
void TestPlayerSource::test_autoMpris()
|
||||
{
|
||||
QStringList args(QStringList() << "mpris" << mpdAddress << QString::number(mpdPort) << "auto"
|
||||
<< QString::number(10));
|
||||
PlayerSource *source = new PlayerSource(this, args);
|
||||
auto source = new PlayerSource(this, "mpris", mpdAddress, mpdPort, "auto", 10);
|
||||
|
||||
bool empty = source->getAutoMpris().isEmpty();
|
||||
auto empty = source->getAutoMpris().isEmpty();
|
||||
if (empty)
|
||||
QWARN("No MPRIS found, manual check required");
|
||||
else
|
||||
@ -79,20 +76,19 @@ void TestPlayerSource::test_autoMpris()
|
||||
|
||||
void TestPlayerSource::test_mpd()
|
||||
{
|
||||
QStringList args(QStringList() << "mpd" << mpdAddress << QString::number(mpdPort) << "auto" << QString::number(10));
|
||||
PlayerSource *source = new PlayerSource(this, args);
|
||||
auto source = new PlayerSource(this, "mpd", mpdAddress, mpdPort, "auto", 10);
|
||||
_test_sources(source);
|
||||
|
||||
// init spy
|
||||
QSignalSpy spy(source, SIGNAL(dataReceived(const QVariantHash &)));
|
||||
QVariant firstValue = source->data("title");
|
||||
auto firstValue = source->data("title");
|
||||
if (!source->isMpdSocketConnected())
|
||||
QSKIP("No mpd found");
|
||||
|
||||
// check values
|
||||
QVERIFY(spy.wait(5000));
|
||||
QList<QVariant> arguments = spy.takeFirst();
|
||||
QVariantHash secondValue = arguments.at(0).toHash();
|
||||
auto arguments = spy.takeFirst();
|
||||
auto secondValue = arguments.at(0).toHash();
|
||||
|
||||
// actually nothing to test here just print warning if no information found
|
||||
if (secondValue["title"].toString() == "unknown")
|
||||
@ -104,14 +100,12 @@ void TestPlayerSource::test_mpd()
|
||||
|
||||
void TestPlayerSource::test_mpris()
|
||||
{
|
||||
QStringList args(QStringList() << "mpris" << mpdAddress << QString::number(mpdPort) << "auto"
|
||||
<< QString::number(10));
|
||||
PlayerSource *source = new PlayerSource(this, args);
|
||||
auto source = new PlayerSource(this, "mpris", mpdAddress, mpdPort, "auto", 10);
|
||||
_test_sources(source);
|
||||
|
||||
QString value = source->data("title").toString();
|
||||
int progress = source->data("progress").toInt();
|
||||
int duration = source->data("duration").toInt();
|
||||
auto value = source->data("title").toString();
|
||||
auto progress = source->data("progress").toInt();
|
||||
auto duration = source->data("duration").toInt();
|
||||
|
||||
// actually nothing to test here just print warning if no information found
|
||||
if (value == "unknown")
|
||||
|
@ -15,7 +15,6 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "testprocessessource.h"
|
||||
|
||||
#include <QtTest>
|
||||
@ -27,7 +26,7 @@
|
||||
void TestProcessesSource::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
source = new ProcessesSource(this, QStringList());
|
||||
source = new ProcessesSource(this);
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "testscriptformatter.h"
|
||||
|
||||
#include <QtTest>
|
||||
@ -52,7 +51,7 @@ void TestAWScriptFormatter::test_values()
|
||||
|
||||
void TestAWScriptFormatter::test_conversion()
|
||||
{
|
||||
QString string = AWTestLibrary::randomString();
|
||||
auto string = AWTestLibrary::randomString();
|
||||
QCOMPARE(formatter->convert(string), string);
|
||||
}
|
||||
|
||||
@ -93,7 +92,7 @@ void TestAWScriptFormatter::test_hasReturn()
|
||||
|
||||
void TestAWScriptFormatter::test_copy()
|
||||
{
|
||||
AWScriptFormatter *newFormatter = formatter->copy("/dev/null", 1);
|
||||
auto newFormatter = formatter->copy("/dev/null", 1);
|
||||
|
||||
QCOMPARE(newFormatter->appendCode(), formatter->appendCode());
|
||||
QCOMPARE(newFormatter->code(), formatter->code());
|
||||
|
@ -15,7 +15,6 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "teststringformatter.h"
|
||||
|
||||
#include <QtTest>
|
||||
@ -43,7 +42,7 @@ void TestAWStringFormatter::test_values() {}
|
||||
void TestAWStringFormatter::test_count()
|
||||
{
|
||||
// assign
|
||||
int count = 10 + AWTestLibrary::randomInt();
|
||||
auto count = 10 + AWTestLibrary::randomInt();
|
||||
formatter->setCount(count);
|
||||
QCOMPARE(formatter->count(), count);
|
||||
|
||||
@ -51,7 +50,7 @@ void TestAWStringFormatter::test_count()
|
||||
auto testString = AWTestLibrary::randomString();
|
||||
while (testString.length() > count)
|
||||
testString = AWTestLibrary::randomString();
|
||||
QString output = formatter->convert(testString);
|
||||
auto output = formatter->convert(testString);
|
||||
QCOMPARE(output.length(), count);
|
||||
|
||||
// reset
|
||||
@ -62,13 +61,13 @@ void TestAWStringFormatter::test_count()
|
||||
void TestAWStringFormatter::test_fillChar()
|
||||
{
|
||||
// assign
|
||||
char c = AWTestLibrary::randomChar();
|
||||
auto c = AWTestLibrary::randomChar();
|
||||
formatter->setFillChar(c);
|
||||
QCOMPARE(formatter->fillChar(), QChar(c));
|
||||
formatter->setCount(101);
|
||||
|
||||
// test
|
||||
QString output = formatter->convert(AWTestLibrary::randomString());
|
||||
auto output = formatter->convert(AWTestLibrary::randomString());
|
||||
QVERIFY(output.startsWith(c));
|
||||
|
||||
// reset
|
||||
@ -80,13 +79,13 @@ void TestAWStringFormatter::test_fillChar()
|
||||
void TestAWStringFormatter::test_forceWidth()
|
||||
{
|
||||
// assign
|
||||
int count = AWTestLibrary::randomInt();
|
||||
auto count = AWTestLibrary::randomInt();
|
||||
formatter->setForceWidth(true);
|
||||
formatter->setCount(count);
|
||||
QCOMPARE(formatter->forceWidth(), true);
|
||||
|
||||
// test
|
||||
QString output = formatter->convert(AWTestLibrary::randomString());
|
||||
auto output = formatter->convert(AWTestLibrary::randomString());
|
||||
QCOMPARE(output.length(), count);
|
||||
|
||||
// reset
|
||||
@ -98,7 +97,7 @@ void TestAWStringFormatter::test_forceWidth()
|
||||
void TestAWStringFormatter::test_copy()
|
||||
{
|
||||
doRandom();
|
||||
AWStringFormatter *newFormatter = formatter->copy("/dev/null", 1);
|
||||
auto newFormatter = formatter->copy("/dev/null", 1);
|
||||
|
||||
QCOMPARE(newFormatter->count(), formatter->count());
|
||||
QCOMPARE(newFormatter->fillChar(), formatter->fillChar());
|
||||
|
Reference in New Issue
Block a user