fix: remove deprecations from test cases

This commit is contained in:
Evgenii Alekseev 2024-03-28 01:57:18 +02:00
parent b0df3535a5
commit d71f85eaad
7 changed files with 23 additions and 23 deletions

View File

@ -35,7 +35,7 @@ bool AWTestLibrary::isKWinActive()
KWindowSystem::setShowingDesktop(true); KWindowSystem::setShowingDesktop(true);
spy.wait(5000); spy.wait(5000);
bool state = KWindowSystem::showingDesktop(); auto state = KWindowSystem::showingDesktop();
KWindowSystem::setShowingDesktop(false); KWindowSystem::setShowingDesktop(false);
return state; return state;
@ -50,11 +50,11 @@ char AWTestLibrary::randomChar()
QPair<QString, QString> AWTestLibrary::randomFilenames() QPair<QString, QString> AWTestLibrary::randomFilenames()
{ {
QString fileName = QString("%1/").arg(QStandardPaths::writableLocation(QStandardPaths::TempLocation)); auto fileName = QString("%1/").arg(QStandardPaths::writableLocation(QStandardPaths::TempLocation));
QString writeFileName auto writeFileName
= QString("%1/awesomewidgets/tmp/").arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)); = QString("%1/awesomewidgets/tmp/").arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation));
QString name = randomString(1, 20); auto name = randomString(1, 20);
fileName += name; fileName += name;
writeFileName += name; writeFileName += name;
@ -72,8 +72,8 @@ QString AWTestLibrary::randomString(const int _min, const int _max)
{ {
QString output; QString output;
int count = _min + randomInt(_max - _min); auto count = _min + randomInt(_max - _min);
for (int i = 0; i < count; i++) for (auto i = 0; i < count; i++)
output += randomChar(); output += randomChar();
return output; return output;
@ -84,8 +84,8 @@ QStringList AWTestLibrary::randomStringList(const int _max)
{ {
QStringList output; QStringList output;
int count = 1 + randomInt(_max); auto count = 1 + randomInt(_max);
for (int i = 0; i < count; i++) for (auto i = 0; i < count; i++)
output.append(randomString()); output.append(randomString());
return output; return output;
@ -96,9 +96,9 @@ QStringList AWTestLibrary::randomSelect(const QStringList &_available)
{ {
QSet<QString> output; QSet<QString> output;
int count = 1 + randomInt(_available.count()); auto count = 1 + randomInt(_available.count());
for (int i = 0; i < count; i++) { for (auto i = 0; i < count; i++) {
int index = randomInt(_available.count()); auto index = randomInt(_available.count());
output << _available.at(index); output << _available.at(index);
} }

View File

@ -42,7 +42,7 @@ void TestBatterySource::cleanupTestCase()
void TestBatterySource::test_sources() void TestBatterySource::test_sources()
{ {
// //
QVERIFY(source->sources().count() >= 6); QVERIFY(source->sources().length() >= 6);
} }
@ -54,9 +54,9 @@ void TestBatterySource::test_battery()
QStringList batteries = source->sources(); QStringList batteries = source->sources();
std::for_each(batteries.begin(), batteries.end(), [this](const QString &bat) { std::for_each(batteries.begin(), batteries.end(), [this](const QString &bat) {
QVariant value = source->data(bat); QVariant value = source->data(bat);
if (bat == "battery/ac") if (bat == "ac")
QCOMPARE(value.type(), QVariant::Bool); QCOMPARE(value.type(), QVariant::Bool);
else if (bat.startsWith("battery/batrate") || bat.startsWith("battery/batleft")) else if (bat.startsWith("batrate") || bat.startsWith("batleft"))
; ;
else else
QVERIFY((value.toFloat() >= battery.first) || (std::isnan(value.toFloat()))); QVERIFY((value.toFloat() >= battery.first) || (std::isnan(value.toFloat())));

View File

@ -47,7 +47,7 @@ void TestDesktopSource::test_values()
{ {
QSKIP("Tests are failing with current api"); QSKIP("Tests are failing with current api");
QVERIFY(source->data("desktop/current/name").toString().count() > 0); QVERIFY(source->data("desktop/current/name").toString().length() > 0);
QVERIFY(source->data("desktop/current/number").toInt() >= 0); QVERIFY(source->data("desktop/current/number").toInt() >= 0);
QVERIFY(source->data("desktop/total/name").toStringList().count() > 0); QVERIFY(source->data("desktop/total/name").toStringList().count() > 0);
QVERIFY(source->data("desktop/total/number").toInt() > 0); QVERIFY(source->data("desktop/total/number").toInt() > 0);

View File

@ -42,7 +42,7 @@ void TestExtItemAggregator::test_values()
{ {
QCOMPARE(aggregator->type(), type); QCOMPARE(aggregator->type(), type);
QCOMPARE(aggregator->uniqNumber(), 0); QCOMPARE(aggregator->uniqNumber(), 0);
QCOMPARE(aggregator->items().count(), 0); QCOMPARE(aggregator->items().length(), 0);
} }

View File

@ -120,7 +120,7 @@ void TestExtWeather::run()
// image should be only one symbol here // image should be only one symbol here
if (extWeather->jsonMapFile().isEmpty()) if (extWeather->jsonMapFile().isEmpty())
QSKIP("No json map found for weather, skip image test"); QSKIP("No json map found for weather, skip image test");
QCOMPARE(arguments[extWeather->tag("weather")].toString().count(), 1); QCOMPARE(arguments[extWeather->tag("weather")].toString().length(), 1);
} }

View File

@ -50,7 +50,7 @@ void TestAWFloatFormatter::test_count()
// test // test
QString output = formatter->convert(QRandomGenerator::global()->generateDouble()); QString output = formatter->convert(QRandomGenerator::global()->generateDouble());
QCOMPARE(output.count(), count); QCOMPARE(output.length(), count);
// reset // reset
formatter->setCount(0); formatter->setCount(0);
@ -85,7 +85,7 @@ void TestAWFloatFormatter::test_forceWidth()
// test // test
QString output = formatter->convert(QRandomGenerator::global()->generateDouble()); QString output = formatter->convert(QRandomGenerator::global()->generateDouble());
QCOMPARE(output.count(), count); QCOMPARE(output.length(), count);
// reset // reset
formatter->setForceWidth(false); formatter->setForceWidth(false);
@ -121,7 +121,7 @@ void TestAWFloatFormatter::test_precision()
// test // test
QString output = formatter->convert(QRandomGenerator::global()->generateDouble()); QString output = formatter->convert(QRandomGenerator::global()->generateDouble());
output.remove("0."); output.remove("0.");
QCOMPARE(output.count(), precision); QCOMPARE(output.length(), precision);
// reset // reset
formatter->setPrecision(-1); formatter->setPrecision(-1);

View File

@ -49,10 +49,10 @@ void TestAWStringFormatter::test_count()
// test // test
auto testString = AWTestLibrary::randomString(); auto testString = AWTestLibrary::randomString();
while (testString.count() > count) while (testString.length() > count)
testString = AWTestLibrary::randomString(); testString = AWTestLibrary::randomString();
QString output = formatter->convert(testString); QString output = formatter->convert(testString);
QCOMPARE(output.count(), count); QCOMPARE(output.length(), count);
// reset // reset
formatter->setCount(0); formatter->setCount(0);
@ -87,7 +87,7 @@ void TestAWStringFormatter::test_forceWidth()
// test // test
QString output = formatter->convert(AWTestLibrary::randomString()); QString output = formatter->convert(AWTestLibrary::randomString());
QCOMPARE(output.count(), count); QCOMPARE(output.length(), count);
// reset // reset
formatter->setForceWidth(false); formatter->setForceWidth(false);