Skip to content

Commit

Permalink
fix: remove deprecations from test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
arcan1s committed Mar 27, 2024
1 parent b0df353 commit d71f85e
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
22 changes: 11 additions & 11 deletions sources/test/awtestlibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ bool AWTestLibrary::isKWinActive()
KWindowSystem::setShowingDesktop(true);
spy.wait(5000);

bool state = KWindowSystem::showingDesktop();
auto state = KWindowSystem::showingDesktop();
KWindowSystem::setShowingDesktop(false);

return state;
Expand All @@ -50,11 +50,11 @@ char AWTestLibrary::randomChar()

QPair<QString, QString> AWTestLibrary::randomFilenames()
{
QString fileName = QString("%1/").arg(QStandardPaths::writableLocation(QStandardPaths::TempLocation));
QString writeFileName
auto fileName = QString("%1/").arg(QStandardPaths::writableLocation(QStandardPaths::TempLocation));
auto writeFileName
= QString("%1/awesomewidgets/tmp/").arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation));

QString name = randomString(1, 20);
auto name = randomString(1, 20);
fileName += name;
writeFileName += name;

Expand All @@ -72,8 +72,8 @@ QString AWTestLibrary::randomString(const int _min, const int _max)
{
QString output;

int count = _min + randomInt(_max - _min);
for (int i = 0; i < count; i++)
auto count = _min + randomInt(_max - _min);
for (auto i = 0; i < count; i++)
output += randomChar();

return output;
Expand All @@ -84,8 +84,8 @@ QStringList AWTestLibrary::randomStringList(const int _max)
{
QStringList output;

int count = 1 + randomInt(_max);
for (int i = 0; i < count; i++)
auto count = 1 + randomInt(_max);
for (auto i = 0; i < count; i++)
output.append(randomString());

return output;
Expand All @@ -96,9 +96,9 @@ QStringList AWTestLibrary::randomSelect(const QStringList &_available)
{
QSet<QString> output;

int count = 1 + randomInt(_available.count());
for (int i = 0; i < count; i++) {
int index = randomInt(_available.count());
auto count = 1 + randomInt(_available.count());
for (auto i = 0; i < count; i++) {
auto index = randomInt(_available.count());
output << _available.at(index);
}

Expand Down
6 changes: 3 additions & 3 deletions sources/test/testbatterysource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void TestBatterySource::cleanupTestCase()
void TestBatterySource::test_sources()
{
//
QVERIFY(source->sources().count() >= 6);
QVERIFY(source->sources().length() >= 6);
}


Expand All @@ -54,9 +54,9 @@ void TestBatterySource::test_battery()
QStringList batteries = source->sources();
std::for_each(batteries.begin(), batteries.end(), [this](const QString &bat) {
QVariant value = source->data(bat);
if (bat == "battery/ac")
if (bat == "ac")
QCOMPARE(value.type(), QVariant::Bool);
else if (bat.startsWith("battery/batrate") || bat.startsWith("battery/batleft"))
else if (bat.startsWith("batrate") || bat.startsWith("batleft"))
;
else
QVERIFY((value.toFloat() >= battery.first) || (std::isnan(value.toFloat())));
Expand Down
2 changes: 1 addition & 1 deletion sources/test/testdesktopsource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void TestDesktopSource::test_values()
{
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/total/name").toStringList().count() > 0);
QVERIFY(source->data("desktop/total/number").toInt() > 0);
Expand Down
2 changes: 1 addition & 1 deletion sources/test/testextitemaggregator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void TestExtItemAggregator::test_values()
{
QCOMPARE(aggregator->type(), type);
QCOMPARE(aggregator->uniqNumber(), 0);
QCOMPARE(aggregator->items().count(), 0);
QCOMPARE(aggregator->items().length(), 0);
}


Expand Down
2 changes: 1 addition & 1 deletion sources/test/testextweather.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void TestExtWeather::run()
// image should be only one symbol here
if (extWeather->jsonMapFile().isEmpty())
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);
}


Expand Down
6 changes: 3 additions & 3 deletions sources/test/testfloatformatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void TestAWFloatFormatter::test_count()

// test
QString output = formatter->convert(QRandomGenerator::global()->generateDouble());
QCOMPARE(output.count(), count);
QCOMPARE(output.length(), count);

// reset
formatter->setCount(0);
Expand Down Expand Up @@ -85,7 +85,7 @@ void TestAWFloatFormatter::test_forceWidth()

// test
QString output = formatter->convert(QRandomGenerator::global()->generateDouble());
QCOMPARE(output.count(), count);
QCOMPARE(output.length(), count);

// reset
formatter->setForceWidth(false);
Expand Down Expand Up @@ -121,7 +121,7 @@ void TestAWFloatFormatter::test_precision()
// test
QString output = formatter->convert(QRandomGenerator::global()->generateDouble());
output.remove("0.");
QCOMPARE(output.count(), precision);
QCOMPARE(output.length(), precision);

// reset
formatter->setPrecision(-1);
Expand Down
6 changes: 3 additions & 3 deletions sources/test/teststringformatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ void TestAWStringFormatter::test_count()

// test
auto testString = AWTestLibrary::randomString();
while (testString.count() > count)
while (testString.length() > count)
testString = AWTestLibrary::randomString();
QString output = formatter->convert(testString);
QCOMPARE(output.count(), count);
QCOMPARE(output.length(), count);

// reset
formatter->setCount(0);
Expand Down Expand Up @@ -87,7 +87,7 @@ void TestAWStringFormatter::test_forceWidth()

// test
QString output = formatter->convert(AWTestLibrary::randomString());
QCOMPARE(output.count(), count);
QCOMPARE(output.length(), count);

// reset
formatter->setForceWidth(false);
Expand Down

0 comments on commit d71f85e

Please sign in to comment.