Skip to content

Commit

Permalink
test cases update
Browse files Browse the repository at this point in the history
  • Loading branch information
arcan1s committed Mar 27, 2024
1 parent 3f20aa8 commit 079158e
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 23 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ jobs:
run: pacman -Sy --noconfirm base-devel cmake extra-cmake-modules python util-linux-libs xorg-server-xvfb

- name: install dependencies
run: pacman -S --noconfirm plasma-workspace ksysguard
run: pacman -S --noconfirm plasma-workspace

- name: configure cmake
run: cmake -B build -DKDE_INSTALL_USE_QT_SYS_PATHS=ON -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_FUTURE=ON -DBUILD_TESTING=ON sources
run: cmake -B build -S sources -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_FUTURE=ON -DBUILD_TESTING=ON

- name: build
working-directory: /repo/build
run: make
run: cmake --build build

- name: test
working-directory: /repo/build
Expand Down
6 changes: 3 additions & 3 deletions sources/test/testdatetimeformatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ void TestAWDateTimeFormatter::test_values()

void TestAWDateTimeFormatter::test_conversion()
{
QDateTime now = QDateTime::currentDateTime();
QCOMPARE(formatter->convert(now), now.toString(format));
auto now = QDateTime::currentDateTime();
QCOMPARE(formatter->convert(now), QLocale::system().toString(now, format));
}


void TestAWDateTimeFormatter::test_copy()
{
formatter->setTranslateString(false);
AWDateTimeFormatter *newFormatter = formatter->copy("/dev/null", 1);
auto *newFormatter = formatter->copy("/dev/null", 1);

QCOMPARE(newFormatter->format(), formatter->format());
QCOMPARE(newFormatter->translateString(), formatter->translateString());
Expand Down
4 changes: 2 additions & 2 deletions sources/test/testnetworksource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ void TestNetworkSource::cleanupTestCase()

void TestNetworkSource::test_sources()
{
QCOMPARE(source->sources(), QStringList() << src << "network/current/ssid");
QCOMPARE(source->sources(), QStringList({"device", "ssid"}));
}


void TestNetworkSource::test_values()
{
QVERIFY(source->data(src).toString().count() > 0);
QVERIFY(source->data("device").toString().length() > 0);
}


Expand Down
1 change: 0 additions & 1 deletion sources/test/testnetworksource.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ private slots:

private:
NetworkSource *source = nullptr;
QString src = "network/current/name";
};


Expand Down
22 changes: 11 additions & 11 deletions sources/test/testplayersource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,23 @@ void TestPlayerSource::test_buildString()
{
QString randomString = AWTestLibrary::randomString(1, 40);
QString str = PlayerSource::buildString("", randomString, 20);
QCOMPARE(str.count(), 20);
QCOMPARE(str.length(), 20);

str = PlayerSource::buildString(str, randomString, 20);
QCOMPARE(str.count(), 20);
QCOMPARE(str.length(), 20);

str = PlayerSource::buildString("", AWTestLibrary::randomString(1, 10), 20);
QCOMPARE(str.count(), 20);
QCOMPARE(str.length(), 20);
}


void TestPlayerSource::test_stripString()
{
QString str = PlayerSource::buildString("", AWTestLibrary::randomString(1, 40), 20);
QCOMPARE(str.count(), 20);
QCOMPARE(str.length(), 20);

str = PlayerSource::buildString("", AWTestLibrary::randomString(1, 10), 20);
QCOMPARE(str.count(), 20);
QCOMPARE(str.length(), 20);
}


Expand All @@ -85,7 +85,7 @@ void TestPlayerSource::test_mpd()

// init spy
QSignalSpy spy(source, SIGNAL(dataReceived(const QVariantHash &)));
QVariant firstValue = source->data("player/title");
QVariant firstValue = source->data("title");
if (!source->isMpdSocketConnected())
QSKIP("No mpd found");

Expand All @@ -95,10 +95,10 @@ void TestPlayerSource::test_mpd()
QVariantHash secondValue = arguments.at(0).toHash();

// actually nothing to test here just print warning if no information found
if (secondValue["player/title"].toString() == "unknown")
if (secondValue["title"].toString() == "unknown")
QSKIP("No mpd found");

QVERIFY(secondValue["player/progress"].toInt() < secondValue["player/duration"].toInt());
QVERIFY(secondValue["progress"].toInt() < secondValue["duration"].toInt());
}


Expand All @@ -109,9 +109,9 @@ void TestPlayerSource::test_mpris()
PlayerSource *source = new PlayerSource(this, args);
_test_sources(source);

QString value = source->data("player/title").toString();
int progress = source->data("player/progress").toInt();
int duration = source->data("player/duration").toInt();
QString value = source->data("title").toString();
int progress = source->data("progress").toInt();
int duration = source->data("duration").toInt();

// actually nothing to test here just print warning if no information found
if (value == "unknown")
Expand Down
6 changes: 3 additions & 3 deletions sources/test/testprocessessource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ void TestProcessesSource::test_sources()

void TestProcessesSource::test_values()
{
QVERIFY(source->data("ps/running/count").toInt() > 0);
QVERIFY(source->data("ps/running/list").toStringList().count() > 0);
QVERIFY(source->data("ps/total/count").toInt() > 0);
QVERIFY(source->data("running").toInt() > 0);
QVERIFY(source->data("list").toStringList().count() > 0);
QVERIFY(source->data("count").toInt() > 0);
}


Expand Down

0 comments on commit 079158e

Please sign in to comment.