diff --git a/.travis.yml b/.travis.yml index 1f0126c..88ba0d8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,11 @@ arch: - cd awesome-widgets/build && cmake -DKDE_INSTALL_USE_QT_SYS_PATHS=ON -DCMAKE_BUILD_TYPE=Optimization -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_FUTURE=ON -DBUILD_TESTING=ON ../sources - cd awesome-widgets/build && make - cd awesome-widgets/build && xvfb-run make test + - cd awesome-widgets/build && xvfb-run ./test/awesomewidgets-test-extscript + - cd awesome-widgets/build && xvfb-run ./test/awesomewidgets-test-extweather + - cd awesome-widgets/build && xvfb-run ./test/awesomewidgets-test-playersource + - cd awesome-widgets/build && xvfb-run ./test/awesomewidgets-test-awkeys + - cd awesome-widgets/build && xvfb-run ./test/awesomewidgets-test-dpplugin script: - "curl -s https://raw.githubusercontent.com/mikkeloscar/arch-travis/master/arch-travis.sh | bash" diff --git a/sources/awesomewidgets/yahooweatherprovider.cpp b/sources/awesomewidgets/yahooweatherprovider.cpp index 569a269..6635179 100644 --- a/sources/awesomewidgets/yahooweatherprovider.cpp +++ b/sources/awesomewidgets/yahooweatherprovider.cpp @@ -93,8 +93,9 @@ YahooWeatherProvider::parseCurrent(const QVariantMap &json, = json[QString("condition")].toMap()[QString("date")].toString(); values[QString("humidity%1").arg(number())] = atmosphere[QString("humidity")].toInt(); + // HACK temporary fix of invalid values on Yahoo! side values[QString("pressure%1").arg(number())] - = static_cast(atmosphere[QString("pressure")].toFloat()); + = static_cast(atmosphere[QString("pressure")].toFloat() / 33.863753); return values; } diff --git a/sources/extsysmonsources/playersource.cpp b/sources/extsysmonsources/playersource.cpp index 9a7b85e..9fc3c86 100644 --- a/sources/extsysmonsources/playersource.cpp +++ b/sources/extsysmonsources/playersource.cpp @@ -255,6 +255,12 @@ QString PlayerSource::stripString(const QString &value, const int s) } +bool PlayerSource::isMpdSocketConnected() const +{ + return (m_mpdSocket.state() == QAbstractSocket::ConnectedState); +} + + void PlayerSource::mpdSocketConnected() { qCDebug(LOG_ESS) << "MPD socket connected to" << m_mpdSocket.peerName() diff --git a/sources/extsysmonsources/playersource.h b/sources/extsysmonsources/playersource.h index af620cc..8fd6f99 100644 --- a/sources/extsysmonsources/playersource.h +++ b/sources/extsysmonsources/playersource.h @@ -45,6 +45,8 @@ public: static QString buildString(const QString ¤t, const QString &value, const int s); static QString stripString(const QString &value, const int s); + // additional test method + bool isMpdSocketConnected() const; private slots: void mpdSocketConnected(); diff --git a/sources/test/testdpplugin.cpp b/sources/test/testdpplugin.cpp index 652ba0f..cf1dcfd 100644 --- a/sources/test/testdpplugin.cpp +++ b/sources/test/testdpplugin.cpp @@ -28,6 +28,7 @@ void TestDPPlugin::initTestCase() { plugin = new DPAdds(this); + m_isKwinActive = checkKwinStatus(); } @@ -39,6 +40,9 @@ void TestDPPlugin::cleanupTestCase() void TestDPPlugin::test_desktops() { + if (!m_isKwinActive) + QSKIP("KWin inactive, skip tests"); + int current = plugin->currentDesktop(); int total = plugin->numberOfDesktops(); QVERIFY(total != 0); @@ -62,6 +66,9 @@ void TestDPPlugin::test_desktops() void TestDPPlugin::test_dictKeys() { + if (!m_isKwinActive) + QSKIP("KWin inactive, skip tests"); + QCOMPARE(plugin->dictKeys().count(), 4); pattern += plugin->dictKeys().join(QString(" $")); } @@ -69,6 +76,9 @@ void TestDPPlugin::test_dictKeys() void TestDPPlugin::test_infoByKey() { + if (!m_isKwinActive) + QSKIP("KWin inactive, skip tests"); + // nothing to test here yet QVERIFY(true); } @@ -76,6 +86,9 @@ void TestDPPlugin::test_infoByKey() void TestDPPlugin::test_parsePattern() { + if (!m_isKwinActive) + QSKIP("KWin inactive, skip tests"); + QString result = plugin->parsePattern(pattern, plugin->currentDesktop()); QVERIFY(!result.isEmpty()); QVERIFY(result != pattern); @@ -86,6 +99,9 @@ void TestDPPlugin::test_parsePattern() void TestDPPlugin::test_tooltipImage() { + if (!m_isKwinActive) + QSKIP("KWin inactive, skip tests"); + QVariantMap data; data[QString("tooltipColor")] = QString("#000000"); data[QString("tooltipType")] = QString("windows"); @@ -98,4 +114,10 @@ void TestDPPlugin::test_tooltipImage() } +bool TestDPPlugin::checkKwinStatus() const +{ + return KWindowSystem::workArea().isValid(); +} + + QTEST_MAIN(TestDPPlugin); diff --git a/sources/test/testdpplugin.h b/sources/test/testdpplugin.h index fd2cb93..6c5b1af 100644 --- a/sources/test/testdpplugin.h +++ b/sources/test/testdpplugin.h @@ -40,7 +40,9 @@ private slots: void test_parsePattern(); private: + bool checkKwinStatus() const; DPAdds *plugin = nullptr; + bool m_isKwinActive = false; QString pattern = QString("$"); }; diff --git a/sources/test/testextweather.cpp b/sources/test/testextweather.cpp index 825ee26..bfc83b5 100644 --- a/sources/test/testextweather.cpp +++ b/sources/test/testextweather.cpp @@ -120,9 +120,6 @@ void TestExtWeather::run() >= humidity.first) && (arguments[extWeather->tag(QString("humidity"))].toInt() <= humidity.second)); - QWARN("May fail here for Yahoo! Weather, see " - "https://yahoo.uservoice.com/forums/207813-us-weather/suggestions/" - "14209233-invalid-pressure-calculation"); QVERIFY((arguments[extWeather->tag(QString("pressure"))].toInt() > pressure.first) && (arguments[extWeather->tag(QString("pressure"))].toInt() diff --git a/sources/test/testplayersource.cpp b/sources/test/testplayersource.cpp index b7c968e..440bd38 100644 --- a/sources/test/testplayersource.cpp +++ b/sources/test/testplayersource.cpp @@ -75,8 +75,11 @@ void TestPlayerSource::test_autoMpris() << QString("auto") << QString::number(10)); PlayerSource *source = new PlayerSource(this, args); - QWARN("Will fail if no MPRIS supported player is run"); - QVERIFY(!source->getAutoMpris().isEmpty()); + bool empty = source->getAutoMpris().isEmpty(); + if (empty) + QWARN("No MPRIS found, manual check required"); + else + QVERIFY(!empty); } @@ -91,6 +94,8 @@ void TestPlayerSource::test_mpd() // init spy QSignalSpy spy(source, SIGNAL(dataReceived(const QVariantHash &))); QVariant firstValue = source->data(QString("player/title")); + if (!source->isMpdSocketConnected()) + QSKIP("No mpd found"); // check values QVERIFY(spy.wait(5000)); @@ -98,12 +103,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[QString("player/title")].toString() == QString("unknown")) { - QWARN("No mpd found"); - } else { - QVERIFY(secondValue[QString("player/progress")].toInt() - < secondValue[QString("player/duration")].toInt()); - } + if (secondValue[QString("player/title")].toString() == QString("unknown")) + QSKIP("No mpd found"); + + QVERIFY(secondValue[QString("player/progress")].toInt() < secondValue[QString("player/duration")].toInt()); } @@ -120,11 +123,10 @@ void TestPlayerSource::test_mpris() int duration = source->data(QString("player/duration")).toInt(); // actually nothing to test here just print warning if no information found - if (value == QString("unknown")) { - QWARN("No mpris found"); - } else { - QVERIFY(progress < duration); - } + if (value == QString("unknown")) + QSKIP("No mpris found"); + + QVERIFY(progress < duration); }