From b818586a23ded89450caefcf3ffe7cc94e0256ba Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Tue, 14 Feb 2017 04:26:59 +0300 Subject: [PATCH] another iteration with fix travis tests --- .travis.yml | 6 ------ sources/test/awtestlibrary.cpp | 17 ++++++++++++++--- sources/test/awtestlibrary.h | 1 + sources/test/testawkeys.cpp | 3 +-- sources/test/testdpplugin.cpp | 9 +-------- sources/test/testdpplugin.h | 1 - 6 files changed, 17 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index a68988a..2c34c24 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,12 +18,6 @@ arch: - 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 diff --git a/sources/test/awtestlibrary.cpp b/sources/test/awtestlibrary.cpp index a36c589..57a8941 100644 --- a/sources/test/awtestlibrary.cpp +++ b/sources/test/awtestlibrary.cpp @@ -18,19 +18,30 @@ #include "awtestlibrary.h" +#include #include #include +bool AWTestLibrary::isKWinActive() +{ + KWindowSystem::setShowingDesktop(true); + bool state = KWindowSystem::showingDesktop(); + KWindowSystem::setShowingDesktop(false); + + return state; +} + + char AWTestLibrary::randomChar() { - return 'A' + (rand() % static_cast('Z' - 'A')); + return 'A' + (qrand() % static_cast('Z' - 'A')); } double AWTestLibrary::randomDouble() { - return static_cast(rand()) / static_cast(RAND_MAX); + return static_cast(qrand()) / static_cast(RAND_MAX); } @@ -52,7 +63,7 @@ QPair AWTestLibrary::randomFilenames() int AWTestLibrary::randomInt(const int max) { - return rand() % max; + return qrand() % max; } diff --git a/sources/test/awtestlibrary.h b/sources/test/awtestlibrary.h index a8e80bb..7595d86 100644 --- a/sources/test/awtestlibrary.h +++ b/sources/test/awtestlibrary.h @@ -25,6 +25,7 @@ namespace AWTestLibrary { +bool isKWinActive(); char randomChar(); double randomDouble(); QPair randomFilenames(); diff --git a/sources/test/testawkeys.cpp b/sources/test/testawkeys.cpp index 8bec0cd..9754102 100644 --- a/sources/test/testawkeys.cpp +++ b/sources/test/testawkeys.cpp @@ -18,7 +18,6 @@ #include "testawkeys.h" -#include #include #include #include @@ -113,7 +112,7 @@ void TestAWKeys::test_pattern() void TestAWKeys::test_tooltip() { - if (!KWindowSystem::workArea().isValid()) + if (!AWTestLibrary::isKWinActive()) QSKIP("KWin inactive, skip tooltip test"); QSignalSpy spy(plugin, SIGNAL(needToolTipToBeUpdated(const QString))); diff --git a/sources/test/testdpplugin.cpp b/sources/test/testdpplugin.cpp index 51387e8..7ad9d4c 100644 --- a/sources/test/testdpplugin.cpp +++ b/sources/test/testdpplugin.cpp @@ -18,7 +18,6 @@ #include "testdpplugin.h" -#include #include #include "awtestlibrary.h" @@ -28,7 +27,7 @@ void TestDPPlugin::initTestCase() { plugin = new DPAdds(this); - m_isKwinActive = checkKwinStatus(); + m_isKwinActive = AWTestLibrary::isKWinActive(); } @@ -114,10 +113,4 @@ 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 6c5b1af..65dd9b7 100644 --- a/sources/test/testdpplugin.h +++ b/sources/test/testdpplugin.h @@ -40,7 +40,6 @@ private slots: void test_parsePattern(); private: - bool checkKwinStatus() const; DPAdds *plugin = nullptr; bool m_isKwinActive = false; QString pattern = QString("$");