mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 15:37:23 +00:00
Try to fix test for automatic run with travis
* Additionally calculate valid pressure
This commit is contained in:
parent
d097e154ff
commit
10f556e41b
@ -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"
|
||||
|
@ -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<int>(atmosphere[QString("pressure")].toFloat());
|
||||
= static_cast<int>(atmosphere[QString("pressure")].toFloat() / 33.863753);
|
||||
|
||||
return values;
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -40,7 +40,9 @@ private slots:
|
||||
void test_parsePattern();
|
||||
|
||||
private:
|
||||
bool checkKwinStatus() const;
|
||||
DPAdds *plugin = nullptr;
|
||||
bool m_isKwinActive = false;
|
||||
QString pattern = QString("$");
|
||||
};
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user