mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-14 22:35:49 +00:00
implement qcronscheduler, tests update
This commit is contained in:
@ -22,9 +22,16 @@
|
||||
#include <QEventLoop>
|
||||
#include <QSet>
|
||||
#include <QStandardPaths>
|
||||
#include <QTime>
|
||||
#include <QtTest>
|
||||
|
||||
|
||||
void AWTestLibrary::init()
|
||||
{
|
||||
qsrand(static_cast<uint>(QTime::currentTime().msec()));
|
||||
}
|
||||
|
||||
|
||||
bool AWTestLibrary::isKWinActive()
|
||||
{
|
||||
QSignalSpy spy(KWindowSystem::self(), SIGNAL(showingDesktopChanged(bool)));
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
namespace AWTestLibrary
|
||||
{
|
||||
void init();
|
||||
bool isKWinActive();
|
||||
char randomChar();
|
||||
double randomDouble();
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
void TestAbstractExtItem::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
auto names = AWTestLibrary::randomFilenames();
|
||||
fileName = names.first;
|
||||
writeFileName = names.second;
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
void TestAbstractFormatter::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
formatter = new AWNoFormatter(nullptr);
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
void TestAWBugReporter::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
plugin = new AWBugReporter(this);
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
void TestAWConfigHelper::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
plugin = new AWConfigHelper(this);
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
void TestAWKeyCache::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
}
|
||||
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
void TestAWKeys::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
plugin = new AWKeys(this);
|
||||
|
||||
// tooltip init
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
void TestAWPatternFunctions::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
}
|
||||
|
||||
|
||||
@ -59,18 +60,29 @@ void TestAWPatternFunctions::test_findFunctionCalls()
|
||||
|
||||
void TestAWPatternFunctions::test_findKeys()
|
||||
{
|
||||
QStringList keys = AWTestLibrary::randomStringList(20);
|
||||
QStringList bars = AWTestLibrary::randomStringList(20);
|
||||
int count = AWTestLibrary::randomInt(200);
|
||||
QStringList allKeys;
|
||||
for (int i = 0; i < count; i++) {
|
||||
auto key = AWTestLibrary::randomString(20);
|
||||
while (allKeys.indexOf(QRegExp(QString("^%1.*").arg(key))) != -1)
|
||||
key = AWTestLibrary::randomString(20);
|
||||
allKeys.append(key);
|
||||
}
|
||||
|
||||
auto keys = AWTestLibrary::randomSelect(allKeys);
|
||||
auto bars = AWTestLibrary::randomSelect(allKeys);
|
||||
std::for_each(bars.begin(), bars.end(),
|
||||
[](QString &bar) { bar.prepend(QString("bar")); });
|
||||
QStringList noise = AWTestLibrary::randomStringList(200);
|
||||
QStringList allKeys = keys + bars + noise;
|
||||
QString pattern = QString("$%1 $%2")
|
||||
.arg(keys.join(QString(" $")))
|
||||
.arg(bars.join(QString(" $")));
|
||||
|
||||
allKeys.append(bars);
|
||||
allKeys.sort();
|
||||
std::reverse(allKeys.begin(), allKeys.end());
|
||||
keys.sort();
|
||||
bars.sort();
|
||||
|
||||
QStringList foundKeys
|
||||
= AWPatternFunctions::findKeys(pattern, allKeys, false);
|
||||
foundKeys.sort();
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
void TestAWTelemetryHandler::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
plugin = new AWTelemetryHandler(this);
|
||||
plugin->init(1, true, telemetryId);
|
||||
telemetryData = AWTestLibrary::randomString();
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
void TestAWUpdateHelper::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
plugin = new AWUpdateHelper(this);
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
void TestBatterySource::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
source = new BatterySource(this, QStringList() << acpiPath);
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
void TestAWDateTimeFormatter::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
format = AWTestLibrary::randomSelect(QString(TIME_KEYS).split(QChar(',')))
|
||||
.join(QChar(' '));
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
void TestDesktopSource::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
source = new DesktopSource(this, QStringList());
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
void TestDPPlugin::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
plugin = new DPAdds(this);
|
||||
m_isKwinActive = AWTestLibrary::isKWinActive();
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
void TestExtItemAggregator::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
aggregator = new ExtItemAggregator<AWNoFormatter>(nullptr, type);
|
||||
}
|
||||
|
||||
|
@ -20,11 +20,13 @@
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
#include "awtestlibrary.h"
|
||||
#include "extquotes.h"
|
||||
|
||||
|
||||
void TestExtQuotes::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
extQuotes = new ExtQuotes(nullptr);
|
||||
extQuotes->setInterval(1);
|
||||
extQuotes->setTicker(ticker);
|
||||
|
@ -43,8 +43,8 @@ private:
|
||||
ExtQuotes *extQuotes = nullptr;
|
||||
QVariantHash cache;
|
||||
QString ticker = QString("EURUSD=X");
|
||||
QStringList types = QStringList() << QString("ask") << QString("bid")
|
||||
<< QString("price");
|
||||
QStringList types = QStringList()
|
||||
<< QString("ask") << QString("bid") << QString("price");
|
||||
// we assume that price will not be differ more than in 2 times
|
||||
QPair<double, double> price = QPair<double, double>(0.5, 2.0);
|
||||
};
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
void TestExtScript::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
randomString = AWTestLibrary::randomString();
|
||||
|
||||
extScript = new ExtScript(nullptr);
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
void TestExtUpgrade::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
randomStrings = AWTestLibrary::randomStringList();
|
||||
cmd = QString("echo -e '%1'").arg(randomStrings.join(QString("\n")));
|
||||
|
||||
|
@ -20,11 +20,13 @@
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
#include "awtestlibrary.h"
|
||||
#include "extweather.h"
|
||||
|
||||
|
||||
void TestExtWeather::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
extWeather = new ExtWeather(nullptr);
|
||||
extWeather->setInterval(1);
|
||||
extWeather->setCity(city);
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
void TestAWFloatFormatter::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
formatter = new AWFloatFormatter(nullptr);
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
void TestGPULoadSource::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
device = GPULoadSource::autoGpu();
|
||||
QVERIFY(!device.isEmpty());
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
void TestGPUTemperatureSource::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
device = GPUTemperatureSource::autoGpu();
|
||||
QVERIFY(!device.isEmpty());
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
void TestHDDTemperatureSource::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
devices = HDDTemperatureSource::allHdd();
|
||||
QVERIFY(devices.count() > 0);
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
void TestAWJsonFormatter::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
formatter = new AWJsonFormatter(nullptr);
|
||||
|
||||
generate();
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
void TestAWListFormatter::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
separator = AWTestLibrary::randomString(10);
|
||||
|
||||
formatter = new AWListFormatter(nullptr);
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
void TestNetworkSource::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
source = new NetworkSource(this, QStringList());
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
void TestAWNoFormatter::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
formatter = new AWNoFormatter(nullptr);
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
void TestPlayerSource::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
}
|
||||
|
||||
|
||||
@ -48,7 +49,6 @@ void TestPlayerSource::test_buildString()
|
||||
|
||||
str = PlayerSource::buildString(str, randomString, 20);
|
||||
QCOMPARE(str.count(), 20);
|
||||
QCOMPARE(randomString.indexOf(str), 1);
|
||||
|
||||
str = PlayerSource::buildString(QString(), AWTestLibrary::randomString(10),
|
||||
20);
|
||||
@ -85,9 +85,9 @@ void TestPlayerSource::test_autoMpris()
|
||||
|
||||
void TestPlayerSource::test_mpd()
|
||||
{
|
||||
QStringList args(QStringList() << QString("mpd") << mpdAddress
|
||||
<< QString::number(mpdPort)
|
||||
<< QString("auto") << QString::number(10));
|
||||
QStringList args(QStringList()
|
||||
<< QString("mpd") << mpdAddress << QString::number(mpdPort)
|
||||
<< QString("auto") << QString::number(10));
|
||||
PlayerSource *source = new PlayerSource(this, args);
|
||||
_test_sources(source);
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
void TestProcessesSource::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
source = new ProcessesSource(this, QStringList());
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
void TestAWScriptFormatter::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
formatter = new AWScriptFormatter(nullptr);
|
||||
formatter->setCode(fullCode);
|
||||
formatter->setAppendCode(false);
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
void TestAWStringFormatter::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
formatter = new AWStringFormatter(nullptr);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user