From 38c5589c10f8acbe7d269be9b36d3ae62bcbab9d Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Tue, 14 Feb 2017 03:48:11 +0300 Subject: [PATCH] one more iteration to try to fix tests on travis --- .travis.yml | 6 ++++++ sources/awesome-widget/plugin/awkeys.cpp | 12 +++++++++++- sources/awesome-widget/plugin/awkeys.h | 2 ++ sources/awesomewidgets/extscript.cpp | 18 +++++++++++++----- sources/awesomewidgets/extscript.h | 1 + sources/awesomewidgets/extweather.cpp | 16 ++++++++++++---- sources/awesomewidgets/extweather.h | 1 + sources/test/testawkeys.cpp | 7 +++++++ sources/test/testdpplugin.cpp | 10 +++++----- sources/test/testextscript.cpp | 3 +++ sources/test/testextweather.cpp | 5 +++++ 11 files changed, 66 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index e0d2fbd..a68988a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,11 +17,17 @@ 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 || true + - sleep 3 - cd awesome-widgets/build && xvfb-run ./test/awesomewidgets-test-extscript || true + - sleep 3 - cd awesome-widgets/build && xvfb-run ./test/awesomewidgets-test-extweather || true + - sleep 3 - cd awesome-widgets/build && xvfb-run ./test/awesomewidgets-test-playersource || true + - sleep 3 - cd awesome-widgets/build && xvfb-run ./test/awesomewidgets-test-awkeys || true + - sleep 3 - cd awesome-widgets/build && xvfb-run ./test/awesomewidgets-test-dpplugin || true + - sleep 3 script: - "curl -s https://raw.githubusercontent.com/mikkeloscar/arch-travis/master/arch-travis.sh | bash" diff --git a/sources/awesome-widget/plugin/awkeys.cpp b/sources/awesome-widget/plugin/awkeys.cpp index e420e7b..c9d4b1b 100644 --- a/sources/awesome-widget/plugin/awkeys.cpp +++ b/sources/awesome-widget/plugin/awkeys.cpp @@ -91,6 +91,12 @@ AWKeys::~AWKeys() } +bool AWKeys::isDBusActive() const +{ + return m_dbusActive; +} + + void AWKeys::initDataAggregator(const QVariantMap tooltipParams) { qCDebug(LOG_AW) << "Tooltip parameters" << tooltipParams; @@ -338,9 +344,13 @@ void AWKeys::createDBusInterface() qCWarning(LOG_AW) << "Could not register DBus service, last error" << bus.lastError().message(); if (!bus.registerObject(QString("/%1").arg(id), new AWDBusAdaptor(this), - QDBusConnection::ExportAllContents)) + QDBusConnection::ExportAllContents)) { qCWarning(LOG_AW) << "Could not register DBus object, last error" << bus.lastError().message(); + m_dbusActive = false; + } else { + m_dbusActive = true; + } } diff --git a/sources/awesome-widget/plugin/awkeys.h b/sources/awesome-widget/plugin/awkeys.h index 75a6423..6b3cb4e 100644 --- a/sources/awesome-widget/plugin/awkeys.h +++ b/sources/awesome-widget/plugin/awkeys.h @@ -39,6 +39,7 @@ class AWKeys : public QObject public: explicit AWKeys(QObject *parent = nullptr); virtual ~AWKeys(); + bool isDBusActive() const; Q_INVOKABLE void initDataAggregator(const QVariantMap tooltipParams); Q_INVOKABLE void initKeys(const QString currentPattern, const int interval, const int limit, const bool optimize); @@ -86,6 +87,7 @@ private: AWKeyOperations *m_keyOperator = nullptr; QTimer *m_timer = nullptr; // variables + bool m_dbusActive = false; QVariantMap m_tooltipParams; QStringList m_foundBars, m_foundKeys, m_foundLambdas, m_requiredKeys; QVariantHash m_values; diff --git a/sources/awesomewidgets/extscript.cpp b/sources/awesomewidgets/extscript.cpp index c1557ff..2f4fcfa 100644 --- a/sources/awesomewidgets/extscript.cpp +++ b/sources/awesomewidgets/extscript.cpp @@ -83,6 +83,18 @@ ExtScript *ExtScript::copy(const QString _fileName, const int _number) } +QString ExtScript::jsonFiltersFile() const +{ + QString fileName = QStandardPaths::locate( + QStandardPaths::GenericDataLocation, + QString( + "awesomewidgets/scripts/awesomewidgets-extscripts-filters.json")); + qCInfo(LOG_LIB) << "Filters file" << fileName; + + return filename; +} + + QString ExtScript::executable() const { return m_executable; @@ -240,11 +252,7 @@ void ExtScript::readConfiguration() void ExtScript::readJsonFilters() { - QString fileName = QStandardPaths::locate( - QStandardPaths::GenericDataLocation, - QString( - "awesomewidgets/scripts/awesomewidgets-extscripts-filters.json")); - qCInfo(LOG_LIB) << "Filters file" << fileName; + QString fileName = jsonFiltersFile(); QFile jsonFile(fileName); if (!jsonFile.open(QIODevice::ReadOnly | QIODevice::Text)) { qCWarning(LOG_LIB) << "Could not open" << fileName; diff --git a/sources/awesomewidgets/extscript.h b/sources/awesomewidgets/extscript.h index 79c6bcf..42bdf4b 100644 --- a/sources/awesomewidgets/extscript.h +++ b/sources/awesomewidgets/extscript.h @@ -47,6 +47,7 @@ public: explicit ExtScript(QWidget *parent, const QString filePath = QString()); virtual ~ExtScript(); ExtScript *copy(const QString _fileName, const int _number); + QString jsonFiltersFile() const; // get methods QString executable() const; QStringList filters() const; diff --git a/sources/awesomewidgets/extweather.cpp b/sources/awesomewidgets/extweather.cpp index 1692570..f8b110d 100644 --- a/sources/awesomewidgets/extweather.cpp +++ b/sources/awesomewidgets/extweather.cpp @@ -95,6 +95,17 @@ ExtWeather *ExtWeather::copy(const QString _fileName, const int _number) } +QString ExtWeather::jsonMapFile() const +{ + QString fileName = QStandardPaths::locate( + QStandardPaths::GenericDataLocation, + QString("awesomewidgets/weather/awesomewidgets-extweather-ids.json")) + qCInfo(LOG_LIB) << "Map file" << fileName; + + return fileName +} + + QString ExtWeather::weatherFromInt(const int _id) const { qCDebug(LOG_LIB) << "Weather ID" << _id; @@ -236,10 +247,7 @@ void ExtWeather::readConfiguration() void ExtWeather::readJsonMap() { - QString fileName = QStandardPaths::locate( - QStandardPaths::GenericDataLocation, - QString("awesomewidgets/weather/awesomewidgets-extweather-ids.json")); - qCInfo(LOG_LIB) << "Map file" << fileName; + QString fileName = jsonMapFile(); QFile jsonFile(fileName); if (!jsonFile.open(QIODevice::ReadOnly | QIODevice::Text)) { qCWarning(LOG_LIB) << "Could not open" << fileName; diff --git a/sources/awesomewidgets/extweather.h b/sources/awesomewidgets/extweather.h index ea479d2..873632c 100644 --- a/sources/awesomewidgets/extweather.h +++ b/sources/awesomewidgets/extweather.h @@ -45,6 +45,7 @@ public: explicit ExtWeather(QWidget *parent, const QString filePath = QString()); virtual ~ExtWeather(); ExtWeather *copy(const QString _fileName, const int _number); + QString jsonMapFile() const; QString weatherFromInt(const int _id) const; // get methods QString city() const; diff --git a/sources/test/testawkeys.cpp b/sources/test/testawkeys.cpp index 614a499..8bec0cd 100644 --- a/sources/test/testawkeys.cpp +++ b/sources/test/testawkeys.cpp @@ -18,6 +18,7 @@ #include "testawkeys.h" +#include #include #include #include @@ -112,6 +113,9 @@ void TestAWKeys::test_pattern() void TestAWKeys::test_tooltip() { + if (!KWindowSystem::workArea().isValid()) + QSKIP("KWin inactive, skip tooltip test"); + QSignalSpy spy(plugin, SIGNAL(needToolTipToBeUpdated(const QString))); QVERIFY(spy.wait(5 * interval)); @@ -164,6 +168,9 @@ void TestAWKeys::test_valueByKey() void TestAWKeys::test_dbus() { + if (!plugin->isDBusActive()) + QSKIP("No DBus session created, skip DBus test"); + // get id qlonglong id = reinterpret_cast(plugin); diff --git a/sources/test/testdpplugin.cpp b/sources/test/testdpplugin.cpp index cf1dcfd..51387e8 100644 --- a/sources/test/testdpplugin.cpp +++ b/sources/test/testdpplugin.cpp @@ -41,7 +41,7 @@ void TestDPPlugin::cleanupTestCase() void TestDPPlugin::test_desktops() { if (!m_isKwinActive) - QSKIP("KWin inactive, skip tests"); + QSKIP("KWin inactive, skip Destkop panel tests"); int current = plugin->currentDesktop(); int total = plugin->numberOfDesktops(); @@ -67,7 +67,7 @@ void TestDPPlugin::test_desktops() void TestDPPlugin::test_dictKeys() { if (!m_isKwinActive) - QSKIP("KWin inactive, skip tests"); + QSKIP("KWin inactive, skip Destkop panel tests"); QCOMPARE(plugin->dictKeys().count(), 4); pattern += plugin->dictKeys().join(QString(" $")); @@ -77,7 +77,7 @@ void TestDPPlugin::test_dictKeys() void TestDPPlugin::test_infoByKey() { if (!m_isKwinActive) - QSKIP("KWin inactive, skip tests"); + QSKIP("KWin inactive, skip Destkop panel tests"); // nothing to test here yet QVERIFY(true); @@ -87,7 +87,7 @@ void TestDPPlugin::test_infoByKey() void TestDPPlugin::test_parsePattern() { if (!m_isKwinActive) - QSKIP("KWin inactive, skip tests"); + QSKIP("KWin inactive, skip Destkop panel tests"); QString result = plugin->parsePattern(pattern, plugin->currentDesktop()); QVERIFY(!result.isEmpty()); @@ -100,7 +100,7 @@ void TestDPPlugin::test_parsePattern() void TestDPPlugin::test_tooltipImage() { if (!m_isKwinActive) - QSKIP("KWin inactive, skip tests"); + QSKIP("KWin inactive, skip Destkop panel tests"); QVariantMap data; data[QString("tooltipColor")] = QString("#000000"); diff --git a/sources/test/testextscript.cpp b/sources/test/testextscript.cpp index 959593f..d482eba 100644 --- a/sources/test/testextscript.cpp +++ b/sources/test/testextscript.cpp @@ -75,6 +75,9 @@ void TestExtScript::test_run() void TestExtScript::test_filters() { + if (extScript->jsonFiltersFile().isEmpty()) + QSKIP("No json filters found for scripts, skip fitlers test"); + extScript->setFilters(QStringList() << QString("newline")); // init spy QSignalSpy spy(extScript, SIGNAL(dataReceived(const QVariantHash &))); diff --git a/sources/test/testextweather.cpp b/sources/test/testextweather.cpp index bfc83b5..90a108c 100644 --- a/sources/test/testextweather.cpp +++ b/sources/test/testextweather.cpp @@ -75,6 +75,9 @@ void TestExtWeather::test_ts() void TestExtWeather::test_image() { + if (extWeather->jsonMapFile().isEmpty()) + QSKIP("No json map found for weather, skip image test"); + extWeather->setImage(true); // init spy QSignalSpy spy(extWeather, SIGNAL(dataReceived(const QVariantHash &))); @@ -129,6 +132,8 @@ void TestExtWeather::run() && (arguments[extWeather->tag(QString("temperature"))].toFloat() < temp.second)); // 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(QString("weather"))].toString().count(), 1); }