mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 15:37:23 +00:00
add configuration for cron
This commit is contained in:
parent
1b4d1d6944
commit
6e99e262d4
@ -21,7 +21,6 @@ arch:
|
||||
- cd awesome-widgets/build; make
|
||||
- cd awesome-widgets/build; make cppcheck
|
||||
- cd awesome-widgets/build; make clangformat && ( [ `git status -s | wc -l` -eq 0 ] || exit 1 )
|
||||
- cd awesome-widgets/build; ./test/awesomewidgets-test-extweather || true
|
||||
- cd awesome-widgets/build; xvfb-run make test
|
||||
- sleep 3
|
||||
|
||||
|
@ -307,15 +307,10 @@ void AbstractExtItem::readConfiguration()
|
||||
setActive(
|
||||
settings.value(QString("X-AW-Active"), QVariant(isActive())).toString()
|
||||
== QString("true"));
|
||||
setInterval(settings.value(QString("X-AW-Interval"), interval()).toInt());
|
||||
setNumber(settings.value(QString("X-AW-Number"), number()).toInt());
|
||||
setCron(settings.value(QString("X-AW-Schedule"), cron()).toString());
|
||||
setSocket(settings.value(QString("X-AW-Socket"), socket()).toString());
|
||||
|
||||
// interval definition
|
||||
QVariant value = settings.value(QString("X-AW-Interval"), interval());
|
||||
if (value.type() == QVariant::Int)
|
||||
setInterval(value.toInt());
|
||||
else
|
||||
setCron(value.toString());
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
@ -344,6 +339,7 @@ void AbstractExtItem::writeConfiguration() const
|
||||
cron().isEmpty() ? QVariant(interval())
|
||||
: QVariant(cron()));
|
||||
settings.setValue(QString("X-AW-Number"), number());
|
||||
settings.setValue(QString("X-AW-Schedule"), cron());
|
||||
settings.setValue(QString("X-AW-Socket"), socket());
|
||||
settings.endGroup();
|
||||
|
||||
|
@ -137,6 +137,7 @@ int ExtNetworkRequest::showConfiguration(const QVariant args)
|
||||
ui->lineEdit_url->setText(stringUrl());
|
||||
ui->checkBox_active->setCheckState(isActive() ? Qt::Checked
|
||||
: Qt::Unchecked);
|
||||
ui->lineEdit_schedule->setText(cron());
|
||||
ui->lineEdit_socket->setText(socket());
|
||||
ui->spinBox_interval->setValue(interval());
|
||||
|
||||
@ -149,6 +150,7 @@ int ExtNetworkRequest::showConfiguration(const QVariant args)
|
||||
setApiVersion(AW_EXTNETREQUEST_API);
|
||||
setStringUrl(ui->lineEdit_url->text());
|
||||
setActive(ui->checkBox_active->checkState() == Qt::Checked);
|
||||
setCron(ui->lineEdit_schedule->text());
|
||||
setSocket(ui->lineEdit_socket->text());
|
||||
setInterval(ui->spinBox_interval->value());
|
||||
|
||||
@ -208,6 +210,7 @@ void ExtNetworkRequest::translate()
|
||||
ui->label_number->setText(i18n("Tag"));
|
||||
ui->label_url->setText(i18n("URL"));
|
||||
ui->checkBox_active->setText(i18n("Active"));
|
||||
ui->label_schedule->setText(i18n("Schedule"));
|
||||
ui->label_socket->setText(i18n("Socket"));
|
||||
ui->label_interval->setText(i18n("Interval"));
|
||||
}
|
||||
|
@ -134,6 +134,29 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_schedule">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_schedule">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Schedule</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_schedule"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_socket">
|
||||
<item>
|
||||
|
@ -146,6 +146,7 @@ int ExtQuotes::showConfiguration(const QVariant args)
|
||||
ui->lineEdit_ticker->setText(ticker());
|
||||
ui->checkBox_active->setCheckState(isActive() ? Qt::Checked
|
||||
: Qt::Unchecked);
|
||||
ui->lineEdit_schedule->setText(cron());
|
||||
ui->lineEdit_socket->setText(socket());
|
||||
ui->spinBox_interval->setValue(interval());
|
||||
|
||||
@ -158,6 +159,7 @@ int ExtQuotes::showConfiguration(const QVariant args)
|
||||
setApiVersion(AW_EXTQUOTES_API);
|
||||
setTicker(ui->lineEdit_ticker->text());
|
||||
setActive(ui->checkBox_active->checkState() == Qt::Checked);
|
||||
setCron(ui->lineEdit_schedule->text());
|
||||
setSocket(ui->lineEdit_socket->text());
|
||||
setInterval(ui->spinBox_interval->value());
|
||||
|
||||
@ -273,6 +275,7 @@ get quotes for the instrument. Refer to <a href=\"http://finance.yahoo.com/\">\
|
||||
</span></a></p></body></html>"));
|
||||
ui->label_ticker->setText(i18n("Ticker"));
|
||||
ui->checkBox_active->setText(i18n("Active"));
|
||||
ui->label_schedule->setText(i18n("Schedule"));
|
||||
ui->label_socket->setText(i18n("Socket"));
|
||||
ui->label_interval->setText(i18n("Interval"));
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>420</width>
|
||||
<height>301</height>
|
||||
<height>339</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -150,6 +150,29 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_schedule">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_schedule">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Schedule</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_schedule"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_socket">
|
||||
<item>
|
||||
|
@ -295,6 +295,7 @@ int ExtScript::showConfiguration(const QVariant args)
|
||||
ui->checkBox_active->setCheckState(isActive() ? Qt::Checked
|
||||
: Qt::Unchecked);
|
||||
ui->comboBox_redirect->setCurrentIndex(static_cast<int>(redirect()));
|
||||
ui->lineEdit_schedule->setText(cron());
|
||||
ui->lineEdit_socket->setText(socket());
|
||||
ui->spinBox_interval->setValue(interval());
|
||||
// filters
|
||||
@ -316,6 +317,7 @@ int ExtScript::showConfiguration(const QVariant args)
|
||||
setPrefix(ui->lineEdit_prefix->text());
|
||||
setActive(ui->checkBox_active->checkState() == Qt::Checked);
|
||||
setRedirect(static_cast<Redirect>(ui->comboBox_redirect->currentIndex()));
|
||||
setCron(ui->lineEdit_schedule->text());
|
||||
setSocket(ui->lineEdit_socket->text());
|
||||
setInterval(ui->spinBox_interval->value());
|
||||
// filters
|
||||
@ -402,6 +404,7 @@ void ExtScript::translate()
|
||||
ui->label_prefix->setText(i18n("Prefix"));
|
||||
ui->checkBox_active->setText(i18n("Active"));
|
||||
ui->label_redirect->setText(i18n("Redirect"));
|
||||
ui->label_schedule->setText(i18n("Schedule"));
|
||||
ui->label_socket->setText(i18n("Socket"));
|
||||
ui->label_interval->setText(i18n("Interval"));
|
||||
ui->groupBox_filters->setTitle(i18n("Additional filters"));
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>420</width>
|
||||
<height>442</height>
|
||||
<height>473</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -195,6 +195,29 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_schedule">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_schedule">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Schedule</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_schedule"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_socket">
|
||||
<item>
|
||||
|
@ -165,6 +165,7 @@ int ExtUpgrade::showConfiguration(const QVariant args)
|
||||
ui->checkBox_active->setCheckState(isActive() ? Qt::Checked
|
||||
: Qt::Unchecked);
|
||||
ui->spinBox_null->setValue(null());
|
||||
ui->lineEdit_schedule->setText(cron());
|
||||
ui->lineEdit_socket->setText(socket());
|
||||
ui->spinBox_interval->setValue(interval());
|
||||
|
||||
@ -179,6 +180,7 @@ int ExtUpgrade::showConfiguration(const QVariant args)
|
||||
setFilter(ui->lineEdit_filter->text());
|
||||
setActive(ui->checkBox_active->checkState() == Qt::Checked);
|
||||
setNull(ui->spinBox_null->value());
|
||||
setCron(ui->lineEdit_schedule->text());
|
||||
setSocket(ui->lineEdit_socket->text());
|
||||
setInterval(ui->spinBox_interval->value());
|
||||
|
||||
@ -242,6 +244,7 @@ void ExtUpgrade::translate()
|
||||
ui->label_filter->setText(i18n("Filter"));
|
||||
ui->checkBox_active->setText(i18n("Active"));
|
||||
ui->label_null->setText(i18n("Null"));
|
||||
ui->label_interval->setText(i18n("Interval"));
|
||||
ui->label_socket->setText(i18n("Socket"));
|
||||
ui->label_schedule->setText(i18n("Schedule"));
|
||||
ui->label_interval->setText(i18n("Interval"));
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>420</width>
|
||||
<height>321</height>
|
||||
<height>349</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -181,6 +181,29 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_schedule">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_schedule">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Schedule</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_schedule"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_socket">
|
||||
<item>
|
||||
|
@ -292,6 +292,7 @@ int ExtWeather::showConfiguration(const QVariant args)
|
||||
ui->checkBox_image->setCheckState(image() ? Qt::Checked : Qt::Unchecked);
|
||||
ui->checkBox_active->setCheckState(isActive() ? Qt::Checked
|
||||
: Qt::Unchecked);
|
||||
ui->lineEdit_schedule->setText(cron());
|
||||
ui->lineEdit_socket->setText(socket());
|
||||
ui->spinBox_interval->setValue(interval());
|
||||
|
||||
@ -308,6 +309,7 @@ int ExtWeather::showConfiguration(const QVariant args)
|
||||
setTs(ui->spinBox_timestamp->value());
|
||||
setImage(ui->checkBox_image->checkState() == Qt::Checked);
|
||||
setActive(ui->checkBox_active->checkState() == Qt::Checked);
|
||||
setCron(ui->lineEdit_schedule->text());
|
||||
setSocket(ui->lineEdit_socket->text());
|
||||
setInterval(ui->spinBox_interval->value());
|
||||
|
||||
@ -400,6 +402,7 @@ void ExtWeather::translate()
|
||||
ui->label_timestamp->setText(i18n("Timestamp"));
|
||||
ui->checkBox_image->setText(i18n("Use images"));
|
||||
ui->checkBox_active->setText(i18n("Active"));
|
||||
ui->label_schedule->setText(i18n("Schedule"));
|
||||
ui->label_socket->setText(i18n("Socket"));
|
||||
ui->label_interval->setText(i18n("Interval"));
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>420</width>
|
||||
<height>382</height>
|
||||
<height>413</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -248,6 +248,29 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_schedule">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_schedule">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Schedule</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_schedule"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_socket">
|
||||
<item>
|
||||
|
@ -56,11 +56,11 @@ void QCronScheduler::parse(const QString &timer)
|
||||
if (fields.count() != 5)
|
||||
return;
|
||||
|
||||
m_schedule.minutes = parseField(fields.at(1), 0, 59);
|
||||
m_schedule.hours = parseField(fields.at(2), 0, 23);
|
||||
m_schedule.days = parseField(fields.at(3), 1, 31);
|
||||
m_schedule.months = parseField(fields.at(4), 1, 12);
|
||||
m_schedule.weekdays = parseField(fields.at(5), 1, 7);
|
||||
m_schedule.minutes = parseField(fields.at(0), 0, 59);
|
||||
m_schedule.hours = parseField(fields.at(1), 0, 23);
|
||||
m_schedule.days = parseField(fields.at(2), 1, 31);
|
||||
m_schedule.months = parseField(fields.at(3), 1, 12);
|
||||
m_schedule.weekdays = parseField(fields.at(4), 1, 7);
|
||||
}
|
||||
|
||||
|
||||
@ -111,31 +111,31 @@ void QCronScheduler::QCronField::fromRange(const QString &range, const int min,
|
||||
<< "with corner values" << min << max;
|
||||
|
||||
if (range == '*') {
|
||||
this->min = min;
|
||||
this->max = max;
|
||||
minValue = min;
|
||||
maxValue = max;
|
||||
} else if (range.contains('-')) {
|
||||
auto interval = range.split('-', QString::SkipEmptyParts);
|
||||
if (interval.count() != 2)
|
||||
return;
|
||||
bool status;
|
||||
// minimal value
|
||||
this->min = std::max(min, interval.at(0).toInt(&status));
|
||||
minValue = std::max(min, interval.at(0).toInt(&status));
|
||||
if (!status)
|
||||
this->min = -1;
|
||||
minValue = -1;
|
||||
// maximal value
|
||||
this->max = std::min(max, interval.at(1).toInt(&status));
|
||||
maxValue = std::min(max, interval.at(1).toInt(&status));
|
||||
if (!status)
|
||||
this->max = -1;
|
||||
maxValue = -1;
|
||||
// error check
|
||||
if (this->min > this->max)
|
||||
std::swap(this->min, this->max);
|
||||
if (minValue > maxValue)
|
||||
std::swap(minValue, maxValue);
|
||||
} else {
|
||||
bool status;
|
||||
int value = range.toInt(&status);
|
||||
if (!status || (value < min) || (value > max))
|
||||
value = -1;
|
||||
this->min = value;
|
||||
this->max = value;
|
||||
minValue = value;
|
||||
maxValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,11 +143,11 @@ void QCronScheduler::QCronField::fromRange(const QString &range, const int min,
|
||||
QList<int> QCronScheduler::QCronField::toList()
|
||||
{
|
||||
// error checking
|
||||
if ((min == -1) || (max == -1))
|
||||
if ((minValue == -1) || (maxValue == -1))
|
||||
return QList<int>();
|
||||
|
||||
QList<int> output;
|
||||
for (auto i = min; i <= max; ++i) {
|
||||
for (auto i = minValue; i <= maxValue; ++i) {
|
||||
if (i % div != 0)
|
||||
continue;
|
||||
output.append(i);
|
||||
|
@ -36,8 +36,8 @@ public:
|
||||
QList<int> weekdays;
|
||||
} QCronRunSchedule;
|
||||
typedef struct {
|
||||
int min = -1;
|
||||
int max = -1;
|
||||
int minValue = -1;
|
||||
int maxValue = -1;
|
||||
int div = 1;
|
||||
void fromRange(const QString &range, const int min, const int max);
|
||||
QList<int> toList();
|
||||
|
@ -65,7 +65,7 @@ QPair<QString, QString> AWTestLibrary::randomFilenames()
|
||||
.arg(QStandardPaths::writableLocation(
|
||||
QStandardPaths::GenericDataLocation));
|
||||
|
||||
QString name = randomString(20);
|
||||
QString name = randomString(1, 20);
|
||||
fileName += name;
|
||||
writeFileName += name;
|
||||
|
||||
@ -79,11 +79,11 @@ int AWTestLibrary::randomInt(const int max)
|
||||
}
|
||||
|
||||
|
||||
QString AWTestLibrary::randomString(const int max)
|
||||
QString AWTestLibrary::randomString(const int min, const int max)
|
||||
{
|
||||
QString output;
|
||||
|
||||
int count = 1 + randomInt(max);
|
||||
int count = min + randomInt(max - min);
|
||||
for (int i = 0; i < count; i++)
|
||||
output += QChar(randomChar());
|
||||
|
||||
|
@ -31,7 +31,7 @@ char randomChar();
|
||||
double randomDouble();
|
||||
QPair<QString, QString> randomFilenames();
|
||||
int randomInt(const int max = 100);
|
||||
QString randomString(const int max = 100);
|
||||
QString randomString(const int min = 1, const int max = 100);
|
||||
QStringList randomStringList(const int max = 100);
|
||||
QStringList randomSelect(const QStringList available);
|
||||
};
|
||||
|
@ -39,6 +39,7 @@ void TestAbstractExtItem::initTestCase()
|
||||
extItem->setActive(false);
|
||||
extItem->setApiVersion(1);
|
||||
extItem->setComment(comment);
|
||||
extItem->setCron(cron);
|
||||
extItem->setName(name);
|
||||
extItem->setNumber(-1);
|
||||
extItem->setSocket(socket);
|
||||
@ -81,6 +82,7 @@ void TestAbstractExtItem::test_configuration()
|
||||
QCOMPARE(newExtItem->name(), extItem->name());
|
||||
QCOMPARE(newExtItem->number(), extItem->number());
|
||||
QCOMPARE(newExtItem->socket(), extItem->socket());
|
||||
QCOMPARE(newExtItem->cron(), extItem->cron());
|
||||
|
||||
delete newExtItem;
|
||||
}
|
||||
@ -114,6 +116,7 @@ void TestAbstractExtItem::test_copy()
|
||||
QCOMPARE(newExtItem->comment(), extItem->comment());
|
||||
QCOMPARE(newExtItem->name(), extItem->name());
|
||||
QCOMPARE(newExtItem->socket(), extItem->socket());
|
||||
QCOMPARE(newExtItem->cron(), extItem->cron());
|
||||
|
||||
delete newExtItem;
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ private slots:
|
||||
private:
|
||||
ExtUpgrade *extItem = nullptr;
|
||||
QString comment;
|
||||
QString cron = "* * * * *";
|
||||
QString name;
|
||||
QString socket;
|
||||
QString fileName;
|
||||
|
@ -37,8 +37,8 @@ void TestAWPatternFunctions::cleanupTestCase()
|
||||
|
||||
void TestAWPatternFunctions::test_findFunctionCalls()
|
||||
{
|
||||
QString name = QString("aw_%1").arg(AWTestLibrary::randomString(10));
|
||||
QString code = AWTestLibrary::randomString(20);
|
||||
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)
|
||||
@ -63,9 +63,9 @@ void TestAWPatternFunctions::test_findKeys()
|
||||
int count = AWTestLibrary::randomInt(200);
|
||||
QStringList allKeys;
|
||||
for (int i = 0; i < count; i++) {
|
||||
auto key = AWTestLibrary::randomString(20);
|
||||
auto key = AWTestLibrary::randomString(1, 20);
|
||||
while (allKeys.indexOf(QRegExp(QString("^%1.*").arg(key))) != -1)
|
||||
key = AWTestLibrary::randomString(20);
|
||||
key = AWTestLibrary::randomString(1, 20);
|
||||
allKeys.append(key);
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
void TestAWListFormatter::initTestCase()
|
||||
{
|
||||
AWTestLibrary::init();
|
||||
separator = AWTestLibrary::randomString(10);
|
||||
separator = AWTestLibrary::randomString(9, 10);
|
||||
|
||||
formatter = new AWListFormatter(nullptr);
|
||||
formatter->setSeparator(separator);
|
||||
|
@ -43,15 +43,15 @@ void TestPlayerSource::_test_sources(const PlayerSource *source)
|
||||
|
||||
void TestPlayerSource::test_buildString()
|
||||
{
|
||||
QString randomString = AWTestLibrary::randomString(40);
|
||||
QString randomString = AWTestLibrary::randomString(1, 40);
|
||||
QString str = PlayerSource::buildString(QString(), randomString, 20);
|
||||
QCOMPARE(str.count(), 20);
|
||||
|
||||
str = PlayerSource::buildString(str, randomString, 20);
|
||||
QCOMPARE(str.count(), 20);
|
||||
|
||||
str = PlayerSource::buildString(QString(), AWTestLibrary::randomString(10),
|
||||
20);
|
||||
str = PlayerSource::buildString(QString(),
|
||||
AWTestLibrary::randomString(1, 10), 20);
|
||||
QCOMPARE(str.count(), 20);
|
||||
}
|
||||
|
||||
@ -59,11 +59,11 @@ void TestPlayerSource::test_buildString()
|
||||
void TestPlayerSource::test_stripString()
|
||||
{
|
||||
QString str = PlayerSource::buildString(
|
||||
QString(), AWTestLibrary::randomString(40), 20);
|
||||
QString(), AWTestLibrary::randomString(1, 40), 20);
|
||||
QCOMPARE(str.count(), 20);
|
||||
|
||||
str = PlayerSource::buildString(QString(), AWTestLibrary::randomString(10),
|
||||
20);
|
||||
str = PlayerSource::buildString(QString(),
|
||||
AWTestLibrary::randomString(1, 10), 20);
|
||||
QCOMPARE(str.count(), 20);
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,10 @@ void TestAWStringFormatter::test_count()
|
||||
QCOMPARE(formatter->count(), count);
|
||||
|
||||
// test
|
||||
QString output = formatter->convert(AWTestLibrary::randomString());
|
||||
auto testString = AWTestLibrary::randomString();
|
||||
while (testString.count() > count)
|
||||
testString = AWTestLibrary::randomString();
|
||||
QString output = formatter->convert(testString);
|
||||
QCOMPARE(output.count(), count);
|
||||
|
||||
// reset
|
||||
|
Loading…
Reference in New Issue
Block a user