diff options
author | Bernd Weimer <bernd.weimer@pelagicore.com> | 2020-08-03 11:52:36 +0200 |
---|---|---|
committer | Bernd Weimer <bernd.weimer@pelagicore.com> | 2020-08-03 18:23:41 +0200 |
commit | 73f48d422923a33c38106de769f0ad94a77355ad (patch) | |
tree | 786f66df9fad897756cc35c0ad9a799a3539caf0 | |
parent | 520d102c20db7975a9f12831442cb3ccd6a9439d (diff) |
Improve auto tests
If AM_BACKGROUND_TEST is set, windows stay at bottom and don't take
focus (at least on Linux) to permit working while tests are running.
Also renamed VERBOSE_TEST to AM_VERBOSE_TEST, run single-process
tests only were applicable, etc.
Change-Id: I74d7245a2faa3ffcd072de7fc5b7822768f53c35
Reviewed-by: Robert Griebl <robert.griebl@qt.io>
-rw-r--r-- | src/dbus-lib/dbus-lib.pro | 2 | ||||
-rw-r--r-- | src/main-lib/configuration.cpp | 2 | ||||
-rw-r--r-- | src/tools/appman/appman.cpp | 10 | ||||
-rw-r--r-- | src/window-lib/window.cpp | 1 | ||||
-rw-r--r-- | src/window-lib/window.h | 5 | ||||
-rw-r--r-- | tests/applicationinstaller/tst_applicationinstaller.cpp | 4 | ||||
-rw-r--r-- | tests/main/tst_main.cpp | 4 | ||||
-rw-r--r-- | tests/qml/crash/crash.pro | 3 | ||||
-rw-r--r-- | tests/qml/crash/tst_crash.qml | 3 | ||||
-rw-r--r-- | tests/qml/processtitle/processtitle.pro | 9 | ||||
-rw-r--r-- | tests/qml/qml.pro | 6 | ||||
-rw-r--r-- | tests/qml/windowitem/tst_windowitem.qml | 18 | ||||
-rw-r--r-- | tests/qml/windowmapping/tst_windowmapping.qml | 3 |
13 files changed, 30 insertions, 40 deletions
diff --git a/src/dbus-lib/dbus-lib.pro b/src/dbus-lib/dbus-lib.pro index 5635fdf0..845fe7cc 100644 --- a/src/dbus-lib/dbus-lib.pro +++ b/src/dbus-lib/dbus-lib.pro @@ -59,7 +59,7 @@ recreate-applicationmanager-dbus-xml.CONFIG = phony recreate-applicationmanager-dbus-xml.commands = $$QDBUSCPP2XML -a $$PWD/../manager-lib/applicationmanager.h -o $$PWD/io.qt.applicationmanager.xml recreate-packagemanager-dbus-xml.CONFIG = phony -recreate-packagemanager-dbus-xml.commands = $$QDBUSCPP2XML -a $$PWD/../installer-lib/packagemanager.h -o $$PWD/io.qt.packagemanager.xml +recreate-packagemanager-dbus-xml.commands = $$QDBUSCPP2XML -a $$PWD/../manager-lib/packagemanager.h -o $$PWD/io.qt.packagemanager.xml recreate-windowmanager-dbus-xml.CONFIG = phony recreate-windowmanager-dbus-xml.commands = $$QDBUSCPP2XML -a $$PWD/../manager/windowmanager.h -o $$PWD/io.qt.windowmanager.xml diff --git a/src/main-lib/configuration.cpp b/src/main-lib/configuration.cpp index 0b6d0fe3..b85299c4 100644 --- a/src/main-lib/configuration.cpp +++ b/src/main-lib/configuration.cpp @@ -177,7 +177,7 @@ Configuration::Configuration(const QStringList &defaultConfigFilePaths, m_clp.addOption({ qSL("build-config"), qSL("Dumps the build configuration and exits.") }); m_clp.addPositionalArgument(qSL("qml-file"), qSL("The main QML file.")); - m_clp.addOption({ qSL("log-instant"), qSL("Log instantly at start-up, neglect configuration") }); + m_clp.addOption({ qSL("log-instant"), qSL("Log instantly at start-up, neglect logging configuration.") }); m_clp.addOption({ qSL("database"), qSL("Deprecated (ingored)."), qSL("file") }); m_clp.addOption({ qSL("builtin-apps-manifest-dir"), qSL("Base directory for built-in application manifests."), qSL("dir") }); m_clp.addOption({ qSL("installation-dir"), qSL("Base directory for package installations."), qSL("dir") }); diff --git a/src/tools/appman/appman.cpp b/src/tools/appman/appman.cpp index 24c8017e..03572fb1 100644 --- a/src/tools/appman/appman.cpp +++ b/src/tools/appman/appman.cpp @@ -58,6 +58,7 @@ #include "qtyaml.h" #if defined(AM_TESTRUNNER) +# include <QWindow> # include "testrunner.h" #endif @@ -104,7 +105,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) StartupTimer::instance()->checkpoint("after command line parse"); #if defined(AM_TESTRUNNER) TestRunner::initialize(cfg.mainQmlFile(), cfg.testRunnerArguments()); - cfg.setForceVerbose(qEnvironmentVariableIsSet("VERBOSE_TEST")); + cfg.setForceVerbose(qEnvironmentVariableIsSet("AM_VERBOSE_TEST")); #endif a.setup(&cfg); #if defined(AM_TESTRUNNER) @@ -114,8 +115,13 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) a.showWindow(cfg.fullscreen() && !cfg.noFullscreen()); #if defined(AM_TESTRUNNER) + if (qEnvironmentVariableIsSet("AM_BACKGROUND_TEST") && !a.topLevelWindows().isEmpty()) { + QWindow *w = a.topLevelWindows().first(); + w->setFlag(Qt::WindowStaysOnBottomHint); + w->setFlag(Qt::WindowDoesNotAcceptFocus); + } qInfo().nospace().noquote() << "Verbose mode is " << (cfg.verbose() ? "on" : "off") - << " (change by (un)setting $VERBOSE_TEST)\n TEST: " << cfg.mainQmlFile() + << " (change by (un)setting $AM_VERBOSE_TEST)\n TEST: " << cfg.mainQmlFile() << " in " << (cfg.forceMultiProcess() ? "multi" : "single") << "-process mode"; return TestRunner::exec(); #else diff --git a/src/window-lib/window.cpp b/src/window-lib/window.cpp index 4b7fabeb..bcd58e38 100644 --- a/src/window-lib/window.cpp +++ b/src/window-lib/window.cpp @@ -193,7 +193,6 @@ Window::Window(Application *app) Window::~Window() { - emit _windowDestroyed(); } Application *Window::application() const diff --git a/src/window-lib/window.h b/src/window-lib/window.h index b1932f6e..b6dc7b6f 100644 --- a/src/window-lib/window.h +++ b/src/window-lib/window.h @@ -119,11 +119,6 @@ signals: void contentStateChanged(); void requestedPopupPositionChanged(); - // Emitted when this window is destroyed. This signal exists because QObject::destroyed - // doesn't reach the QML/Javascript side. This exists just for testing purposes and - // is not considered part of the public API (hence the '_' prefix). - void _windowDestroyed(); - protected: QPointer<Application> m_application; diff --git a/tests/applicationinstaller/tst_applicationinstaller.cpp b/tests/applicationinstaller/tst_applicationinstaller.cpp index c08fa224..13cfd84d 100644 --- a/tests/applicationinstaller/tst_applicationinstaller.cpp +++ b/tests/applicationinstaller/tst_applicationinstaller.cpp @@ -226,10 +226,10 @@ void tst_PackageManager::initTestCase() if (!QDir(qL1S(AM_TESTDATA_DIR "/packages")).exists()) QSKIP("No test packages available in the data/ directory"); - bool verbose = qEnvironmentVariableIsSet("VERBOSE_TEST"); + bool verbose = qEnvironmentVariableIsSet("AM_VERBOSE_TEST"); if (!verbose) QLoggingCategory::setFilterRules(qSL("am.installer.debug=false")); - qInfo() << "Verbose mode is" << (verbose ? "on" : "off") << "(changed by (un)setting $VERBOSE_TEST)"; + qInfo() << "Verbose mode is" << (verbose ? "on" : "off") << "(change by (un)setting $AM_VERBOSE_TEST)"; spyTimeout *= timeoutFactor(); diff --git a/tests/main/tst_main.cpp b/tests/main/tst_main.cpp index be8e0dd6..1ad2a7d5 100644 --- a/tests/main/tst_main.cpp +++ b/tests/main/tst_main.cpp @@ -99,8 +99,8 @@ void tst_Main::initTestCase() if (!QDir(qL1S(AM_TESTDATA_DIR "/packages")).exists()) QSKIP("No test packages available in the data/ directory"); - m_verbose = qEnvironmentVariableIsSet("VERBOSE_TEST"); - qInfo() << "Verbose mode is" << (m_verbose ? "on" : "off") << "(changed by (un)setting $VERBOSE_TEST)"; + m_verbose = qEnvironmentVariableIsSet("AM_VERBOSE_TEST"); + qInfo() << "Verbose mode is" << (m_verbose ? "on" : "off") << "(change by (un)setting $AM_VERBOSE_TEST)"; } void tst_Main::copyRecursively(const QString &sourcePath, const QString &destPath) diff --git a/tests/qml/crash/crash.pro b/tests/qml/crash/crash.pro index b3bff364..c1c7d869 100644 --- a/tests/qml/crash/crash.pro +++ b/tests/qml/crash/crash.pro @@ -1,6 +1,5 @@ AM_CONFIG = am-config.yaml TEST_FILES = tst_crash.qml TEST_APPS = tld.test.crash - +TEST_CONFIGURATIONS = "--force-multi-process" load(am-qml-testcase) - diff --git a/tests/qml/crash/tst_crash.qml b/tests/qml/crash/tst_crash.qml index eacc66b3..e41b0c39 100644 --- a/tests/qml/crash/tst_crash.qml +++ b/tests/qml/crash/tst_crash.qml @@ -74,9 +74,6 @@ TestCase { } function test_crash(data) { - if (ApplicationManager.singleProcess) - skip("Application crash recovery not supported in single-process mode"); - ApplicationManager.startApplication(appId); runStateChangedSpy.wait(3000); runStateChangedSpy.wait(3000); diff --git a/tests/qml/processtitle/processtitle.pro b/tests/qml/processtitle/processtitle.pro index f2dd589d..e78b54a1 100644 --- a/tests/qml/processtitle/processtitle.pro +++ b/tests/qml/processtitle/processtitle.pro @@ -1,12 +1,7 @@ -load(am-config) - AM_CONFIG = am-config.yaml TEST_FILES = tst_processtitle.qml TEST_APPS = test.processtitle.app - -multi-process { - TEST_CONFIGURATIONS += "--force-multi-process" \ - "--force-multi-process -c $$_PRO_FILE_PWD_/am-config-quick.yaml" -} +TEST_CONFIGURATIONS = "--force-multi-process" \ + "--force-multi-process -c $$_PRO_FILE_PWD_/am-config-quick.yaml" load(am-qml-testcase) diff --git a/tests/qml/qml.pro b/tests/qml/qml.pro index 06665bd4..08fa474a 100644 --- a/tests/qml/qml.pro +++ b/tests/qml/qml.pro @@ -12,11 +12,11 @@ SUBDIRS = \ installer \ quicklaunch \ intents \ - crash/apps/tld.test.crash/terminator2 \ - crash \ configs \ lifecycle \ resources -linux: SUBDIRS += \ +multi-process: SUBDIRS += \ + crash/apps/tld.test.crash/terminator2 \ + crash \ processtitle diff --git a/tests/qml/windowitem/tst_windowitem.qml b/tests/qml/windowitem/tst_windowitem.qml index 8856fd9e..2a144667 100644 --- a/tests/qml/windowitem/tst_windowitem.qml +++ b/tests/qml/windowitem/tst_windowitem.qml @@ -42,6 +42,7 @@ import QtQuick 2.3 import QtTest 1.0 +import QtApplicationManager 2.0 import QtApplicationManager.SystemUI 2.0 Item { @@ -109,9 +110,10 @@ Item { } SignalSpy { - id: spyDestroyed - signalName: "_windowDestroyed" - } + id: objectDestroyedSpy + target: AmTest + signalName: "objectDestroyed" + } TestCase { id: testCase @@ -262,8 +264,8 @@ Item { var secondWindowItem = windowItemsRepeater.itemAt(1); var window = WindowManager.get(0).window; - spyDestroyed.target = window; - spyDestroyed.clear(); + objectDestroyedSpy.clear(); + var destroyId = AmTest.observeObjectDestroyed(window); compare(window.contentState, WindowObject.SurfaceWithContent); app.stop(); @@ -271,7 +273,7 @@ Item { // The WindowObject should still exist, albeit without a surface, even though // no longer present in WindowManager's model. tryCompare(WindowManager, "count", 0); - compare(spyDestroyed.count, 0); + compare(objectDestroyedSpy.count, 0) tryCompare(window, "contentState", WindowObject.NoSurface); // Destroy all WindowItems @@ -281,8 +283,8 @@ Item { // Now that there are no WindowItems using that WindowObject anymore, it should // eventually be deleted by WindowManager - spyDestroyed.wait(); - compare(spyDestroyed.count, 1); + objectDestroyedSpy.wait(); + compare(objectDestroyedSpy.signalArguments[0][0], destroyId); } /* diff --git a/tests/qml/windowmapping/tst_windowmapping.qml b/tests/qml/windowmapping/tst_windowmapping.qml index 37cc7955..05ae5bbf 100644 --- a/tests/qml/windowmapping/tst_windowmapping.qml +++ b/tests/qml/windowmapping/tst_windowmapping.qml @@ -160,9 +160,6 @@ TestCase { } function test_amwin_loader() { - if (!ApplicationManager.singleProcess) - skip("Sporadically crashes in QtWaylandClient::QWaylandDisplay::flushRequests()"); - tryCompare(WindowManager, "count", 0); var app = ApplicationManager.application("test.winmap.loader"); |