From ac3698ae6aaac437e21f3ce08117ea6eedb148dc Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Wed, 4 Sep 2019 14:46:29 +0200 Subject: lancelot graphics test: prepare for new host info mechanism The old hacky way of the test running a "hostinfo.sh" script is about to be removed, see https://codereview.qt-project.org/c/qt/qtbase/+/272694 Insted add the value of QT_QUICK_BACKEND (the only not-automatically-gathered important piece of host information) programmatically. As a driveby, update it from the obsolete name "QMLSCENE_DEVICE". Change-Id: If95a4ccc89ec1c32bf03743071261dfa1b8f5b4d Reviewed-by: Allan Sandfeld Jensen --- tests/manual/scenegraph_lancelot/hostinfo.sh | 76 ---------------------- .../scenegraph/tst_scenegraph.cpp | 4 ++ 2 files changed, 4 insertions(+), 76 deletions(-) delete mode 100644 tests/manual/scenegraph_lancelot/hostinfo.sh (limited to 'tests/manual/scenegraph_lancelot') diff --git a/tests/manual/scenegraph_lancelot/hostinfo.sh b/tests/manual/scenegraph_lancelot/hostinfo.sh deleted file mode 100644 index 6bad2ba467..0000000000 --- a/tests/manual/scenegraph_lancelot/hostinfo.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/sh -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the QtQml module of the Qt Toolkit. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## Commercial License Usage -## Licensees holding valid commercial Qt licenses may use this file in -## accordance with the commercial license agreement provided with the -## Software or, alternatively, in accordance with the terms contained in -## a written agreement between you and The Qt Company. For licensing terms -## and conditions see https://www.qt.io/terms-conditions. For further -## information use the contact form at https://www.qt.io/contact-us. -## -## GNU General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## included in the packaging of this file. Please review the following -## information to ensure the GNU General Public License requirements will -## be met: https://www.gnu.org/licenses/gpl-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# - -# printProperty(): prints a key-value pair from given key and cmd list. -# If running cmd fails, or does not produce any stdout, nothing is printed. -# Arguments: $1: key, $2: cmd, $3: optional, field specification as to cut(1) -f -printProperty () -{ - key=$1 - val=`{ eval $2 ; } 2>/dev/null` - [ -n "$3" ] && val=`echo $val | tr -s '[:blank:]' '\t' | cut -f$3` - [ -n "$val" ] && echo $key: $val -} - -# printEnvVar(): prints a key-value pair from given environment variable name. -# key is printed as "Env_". -# If the variable is undefined, nothing is printed. -# Arguments: $1: varname - -printEnvVar () -{ - key=Env_$1 - val=`eval 'echo $'$1` - [ -n "$val" ] && echo $key: $val -} - - -# printOnOff(): prints a key-value pair from given environment variable name. -# If variable is defined, value is printed as "-On"; otherwise "-Off". -# Arguments: $1: key $2: varname - -printOnOff () -{ - key=$1 - val=`eval 'echo $'$2` - if [ -z "$val" ] ; then - val=Off - else - val=On - fi - echo $key: $key-$val -} - -# ------------ - -printProperty Uname "uname -a" - -printProperty WlanMAC "ifconfig wlan0 | grep HWaddr" 5 - -printEnvVar QMLSCENE_DEVICE diff --git a/tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp b/tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp index 3f28d90e7b..95188ec0f8 100644 --- a/tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp +++ b/tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp @@ -81,6 +81,10 @@ tst_Scenegraph::tst_Scenegraph() void tst_Scenegraph::initTestCase() { + const char *backendVarName = "QT_QUICK_BACKEND"; + const QString backend = qEnvironmentVariable(backendVarName, QString::fromLatin1("default")); + QBaselineTest::addClientProperty(QString::fromLatin1(backendVarName), backend); + QByteArray msg; if (!QBaselineTest::connectToBaselineServer(&msg)) QSKIP(msg); -- cgit v1.2.3 From 04d92f9f9c16ace63a33ee18756ab8d40a1c1a66 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Thu, 5 Sep 2019 15:17:53 +0200 Subject: lancelot graphics test: support shadow build and install Use the QFINDTESTDATA mechanism to locate the test suite directory, and add the data directory and qmlscenegrabber to the installs. As a driveby, improve runtime by cutting down on needlessly long waiting time between test scenes. Change-Id: Id8452c843eef198d8548b196b0a2b5f0bc6be8ba Reviewed-by: Andy Nichols --- .../scenegraph_lancelot/scenegraph/scenegraph.pro | 4 ++++ .../scenegraph/tst_scenegraph.cpp | 20 +++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'tests/manual/scenegraph_lancelot') diff --git a/tests/manual/scenegraph_lancelot/scenegraph/scenegraph.pro b/tests/manual/scenegraph_lancelot/scenegraph/scenegraph.pro index 65819ab5bf..dd0ef268b1 100644 --- a/tests/manual/scenegraph_lancelot/scenegraph/scenegraph.pro +++ b/tests/manual/scenegraph_lancelot/scenegraph/scenegraph.pro @@ -9,3 +9,7 @@ SOURCES += tst_scenegraph.cpp # Include Lancelot protocol code to communicate with baseline server. # Assuming that we are in a normal Qt5 source code tree include(../../../../../qtbase/tests/baselineserver/shared/qbaselinetest.pri) + +TEST_HELPER_INSTALLS += .././qmlscenegrabber + +TESTDATA += ../data diff --git a/tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp b/tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp index 95188ec0f8..40b17ec2a2 100644 --- a/tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp +++ b/tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp @@ -68,6 +68,7 @@ private: bool renderAndGrab(const QString& qmlFile, const QStringList& extraArgs, QImage *screenshot, QString *errMsg); quint16 checksumFileOrDir(const QString &path); + QString testSuitePath; int consecutiveErrors; // Not test failures (image mismatches), but system failures (so no image at all) bool aborted; // This run given up because of too many system failures }; @@ -81,6 +82,14 @@ tst_Scenegraph::tst_Scenegraph() void tst_Scenegraph::initTestCase() { + QString dataDir = QFINDTESTDATA("../data/."); + if (dataDir.isEmpty()) + dataDir = QStringLiteral("data"); + QFileInfo fi(dataDir); + if (!fi.exists() || !fi.isDir() || !fi.isReadable()) + QSKIP("Test suite data directory missing or unreadable: " + fi.canonicalFilePath().toLatin1()); + testSuitePath = fi.canonicalFilePath(); + const char *backendVarName = "QT_QUICK_BACKEND"; const QString backend = qEnvironmentVariable(backendVarName, QString::fromLatin1("default")); QBaselineTest::addClientProperty(QString::fromLatin1(backendVarName), backend); @@ -95,7 +104,7 @@ void tst_Scenegraph::cleanup() { // Allow subsystems time to settle if (!aborted) - QTest::qWait(200); + QTest::qWait(20); } void tst_Scenegraph::testNoTextRendering_data() @@ -131,13 +140,6 @@ void tst_Scenegraph::setupTestSuite(const QByteArray& filter) QTest::addColumn("qmlFile"); int numItems = 0; - QString testSuiteDir = QLatin1String("data"); - QString testSuiteLocation = QCoreApplication::applicationDirPath(); - QString testSuitePath = testSuiteLocation + QDir::separator() + testSuiteDir; - QFileInfo fi(testSuitePath); - if (!fi.exists() || !fi.isDir() || !fi.isReadable()) - QSKIP("Test suite data directory missing or unreadable: " + testSuitePath.toLatin1()); - QStringList ignoreItems; QFile ignoreFile(testSuitePath + "/Ignore"); if (ignoreFile.open(QIODevice::ReadOnly)) { @@ -237,7 +239,7 @@ quint16 tst_Scenegraph::checksumFileOrDir(const QString &path) QFile f(path); f.open(QIODevice::ReadOnly); QByteArray contents = f.readAll(); - return qChecksum(contents.constData(), contents.size()); + return qChecksum(contents.constData(), uint(contents.size())); } if (fi.isDir()) { static const QStringList nameFilters = QStringList() << "*.qml" << "*.cpp" << "*.png" << "*.jpg"; -- cgit v1.2.3 From 144193549a3a47ea3ade74289e3adc55c2bd65e6 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Fri, 6 Sep 2019 16:13:30 +0200 Subject: lancelot graphics test: Fix screengrabs being distorted on Windows The grabbing process transports the image data to the main process over the stdout stream. Windows by default applies LF->CRLF conversion on that stream. Avoid by setting the binary mode flag on it. Change-Id: Ieec0911e24e21c111caeb35e35259833e1fdd639 Reviewed-by: Laszlo Agocs Reviewed-by: Andy Nichols --- tests/manual/scenegraph_lancelot/scenegrabber/main.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/manual/scenegraph_lancelot') diff --git a/tests/manual/scenegraph_lancelot/scenegrabber/main.cpp b/tests/manual/scenegraph_lancelot/scenegrabber/main.cpp index 6da0799bbc..23c678380c 100644 --- a/tests/manual/scenegraph_lancelot/scenegrabber/main.cpp +++ b/tests/manual/scenegraph_lancelot/scenegrabber/main.cpp @@ -36,6 +36,11 @@ #include #include +#ifdef Q_OS_WIN +# include +# include +#endif // Q_OS_WIN + // Timeout values: // A valid screen grab requires the scene to not change @@ -101,6 +106,10 @@ private slots: #endif if (ofile == "-") { // Write to stdout QFile of; +#ifdef Q_OS_WIN + // Make sure write to stdout doesn't do LF->CRLF + _setmode(_fileno(stdout), _O_BINARY); +#endif // Q_OS_WIN if (!of.open(1, QIODevice::WriteOnly) || !lastGrab.save(&of, "ppm")) { qWarning() << "Error: failed to write grabbed image to stdout."; QGuiApplication::exit(2); -- cgit v1.2.3