aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEirik Aavitsland <eirik.aavitsland@qt.io>2019-09-17 13:55:41 +0200
committerEirik Aavitsland <eirik.aavitsland@qt.io>2019-09-23 11:09:05 +0200
commit72b95fc8cac5b9275317f4e5fe74f64aa97a3437 (patch)
tree8950c857a27c2a9a91107238c21c44d57f64be7f /tests
parent44600c6b5da91a6b28f642486ca898b68fbdb675 (diff)
lancelot graphics test: various fixes
Prepare for new host info mechanism, support shadow build and install, and fix screengrabs being distorted on Windows. Squashed cherry pick of: ac3698ae6aaac437e21f3ce08117ea6eedb148dc 04d92f9f9c16ace63a33ee18756ab8d40a1c1a66 144193549a3a47ea3ade74289e3adc55c2bd65e6 Change-Id: Icc382c0d59e8c68613d1f0aea2a60be712615e01 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/manual/scenegraph_lancelot/hostinfo.sh76
-rw-r--r--tests/manual/scenegraph_lancelot/scenegrabber/main.cpp9
-rw-r--r--tests/manual/scenegraph_lancelot/scenegraph/scenegraph.pro4
-rw-r--r--tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp24
4 files changed, 28 insertions, 85 deletions
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_<varname>".
-# 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 "<key>-On"; otherwise "<key>-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/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 <QtQuick/QQuickView>
#include <QtQuick/QQuickItem>
+#ifdef Q_OS_WIN
+# include <fcntl.h>
+# include <io.h>
+#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);
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 3f28d90e7b..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,18 @@ 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);
+
QByteArray msg;
if (!QBaselineTest::connectToBaselineServer(&msg))
QSKIP(msg);
@@ -91,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()
@@ -127,13 +140,6 @@ void tst_Scenegraph::setupTestSuite(const QByteArray& filter)
QTest::addColumn<QString>("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)) {
@@ -233,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";