summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/serialization/qcborstreamreader/tst_qcborstreamreader.cpp108
-rw-r--r--tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp79
-rw-r--r--tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp57
-rw-r--r--tests/auto/gui/kernel/kernel.pro3
-rw-r--r--tests/auto/gui/kernel/qhighdpiscaling/qhighdpiscaling.pro6
-rw-r--r--tests/auto/gui/kernel/qhighdpiscaling/tst_qhighdpiscaling.cpp95
-rw-r--r--tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp13
-rw-r--r--tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp17
-rw-r--r--tests/auto/gui/util/qtexturefilereader/qtexturefilereader.qrc2
-rw-r--r--tests/auto/gui/util/qtexturefilereader/texturefiles/newlogo.astcbin0 -> 2512 bytes
-rw-r--r--tests/auto/gui/util/qtexturefilereader/texturefiles/newlogo_srgb.astcbin0 -> 2512 bytes
-rw-r--r--tests/auto/gui/util/qtexturefilereader/tst_qtexturefilereader.cpp73
-rw-r--r--tests/auto/network/access/http2/tst_http2.cpp187
-rw-r--r--tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp13
-rw-r--r--tests/auto/other/lancelot/paintcommands.cpp10
-rw-r--r--tests/auto/tools/qmake/testcompiler.cpp7
-rw-r--r--tests/auto/tools/qmake/testcompiler.h2
-rw-r--r--tests/auto/tools/qmake/tst_qmake.cpp96
-rw-r--r--tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp19
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp2
-rw-r--r--tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp2
-rw-r--r--tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp10
-rw-r--r--tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp4
-rw-r--r--tests/benchmarks/gui/painting/lancebench/tst_lancebench.cpp20
24 files changed, 747 insertions, 78 deletions
diff --git a/tests/auto/corelib/serialization/qcborstreamreader/tst_qcborstreamreader.cpp b/tests/auto/corelib/serialization/qcborstreamreader/tst_qcborstreamreader.cpp
index 3dd4b5114c..28d29168fb 100644
--- a/tests/auto/corelib/serialization/qcborstreamreader/tst_qcborstreamreader.cpp
+++ b/tests/auto/corelib/serialization/qcborstreamreader/tst_qcborstreamreader.cpp
@@ -80,6 +80,11 @@ private Q_SLOTS:
void addData_singleElement();
void addData_complex_data() { arrays_data(); }
void addData_complex();
+
+ void duplicatedData_data() { arrays_data(); }
+ void duplicatedData();
+ void extraData_data() { arrays_data(); }
+ void extraData();
};
#define FOR_CBOR_TYPE(F) \
@@ -480,6 +485,28 @@ static QString parseOne(QCborStreamReader &reader)
return result;
}
+static QString parse(QCborStreamReader &reader, const QByteArray &data)
+{
+ qint64 oldPos = 0;
+ if (QIODevice *dev = reader.device())
+ oldPos = dev->pos();
+
+ QString r = parseOne(reader);
+ if (r.isEmpty())
+ return r;
+
+ if (reader.currentOffset() - oldPos != data.size())
+ r = QString("Number of parsed bytes (%1) not expected (%2)")
+ .arg(reader.currentOffset()).arg(data.size());
+ if (QIODevice *dev = reader.device()) {
+ if (dev->pos() - oldPos != data.size())
+ r = QString("QIODevice not advanced (%1) as expected (%2)")
+ .arg(dev->pos()).arg(data.size());
+ }
+
+ return r;
+}
+
bool parseNonRecursive(QString &result, bool &printingStringChunks, QCborStreamReader &reader)
{
while (reader.lastError() == QCborError::NoError) {
@@ -612,13 +639,13 @@ void tst_QCborStreamReader::fixed()
}
QVERIFY(reader.isValid());
QCOMPARE(reader.lastError(), QCborError::NoError);
- QCOMPARE(parseOne(reader), expected);
+ QCOMPARE(parse(reader, data), expected);
// verify that we can re-read
reader.reset();
QVERIFY(reader.isValid());
QCOMPARE(reader.lastError(), QCborError::NoError);
- QCOMPARE(parseOne(reader), expected);
+ QCOMPARE(parse(reader, data), expected);
}
void tst_QCborStreamReader::strings_data()
@@ -721,7 +748,7 @@ void tst_QCborStreamReader::emptyContainers()
QCOMPARE(reader.lastError(), QCborError::NoError);
if (reader.isLengthKnown())
QCOMPARE(reader.length(), 0U);
- QCOMPARE(parseOne(reader), expected);
+ QCOMPARE(parse(reader, data), expected);
// verify that we can re-read
reader.reset();
@@ -729,7 +756,7 @@ void tst_QCborStreamReader::emptyContainers()
QCOMPARE(reader.lastError(), QCborError::NoError);
if (reader.isLengthKnown())
QCOMPARE(reader.length(), 0U);
- QCOMPARE(parseOne(reader), expected);
+ QCOMPARE(parse(reader, data), expected);
}
void tst_QCborStreamReader::arrays_data()
@@ -758,7 +785,7 @@ static void checkContainer(int len, const QByteArray &data, const QString &expec
QVERIFY(reader.isLengthKnown());
QCOMPARE(reader.length(), uint(len));
}
- QCOMPARE(parseOne(reader), expected);
+ QCOMPARE(parse(reader, data), expected);
// verify that we can re-read
reader.reset();
@@ -768,7 +795,7 @@ static void checkContainer(int len, const QByteArray &data, const QString &expec
QVERIFY(reader.isLengthKnown());
QCOMPARE(reader.length(), uint(len));
}
- QCOMPARE(parseOne(reader), expected);
+ QCOMPARE(parse(reader, data), expected);
}
void tst_QCborStreamReader::arrays()
@@ -892,7 +919,7 @@ void tst_QCborStreamReader::validation()
buffer.open(QIODevice::ReadOnly);
reader.setDevice(&buffer);
}
- parseOne(reader);
+ parse(reader, data);
QVERIFY(reader.lastError() != QCborError::NoError);
// next() should fail
@@ -997,7 +1024,7 @@ void tst_QCborStreamReader::addData_singleElement()
reader.addData(data.constData() + i, 1);
}
- parseOne(reader);
+ parse(reader, data);
QCOMPARE(reader.lastError(), QCborError::EndOfFile);
}
@@ -1009,7 +1036,7 @@ void tst_QCborStreamReader::addData_singleElement()
reader.addData(data.right(1));
}
QCOMPARE(reader.lastError(), QCborError::NoError);
- QCOMPARE(parseOne(reader), expected);
+ QCOMPARE(parse(reader, data), expected);
}
void tst_QCborStreamReader::addData_complex()
@@ -1085,6 +1112,69 @@ void tst_QCborStreamReader::addData_complex()
"{1, [" + expected + ", " + expected + "]}");
}
+void tst_QCborStreamReader::duplicatedData()
+{
+ QFETCH_GLOBAL(bool, useDevice);
+ QFETCH(QByteArray, data);
+ QFETCH(QString, expected);
+ removeIndicators(expected);
+
+ // double the data up
+ QByteArray doubledata = data + data;
+
+ QBuffer buffer(&doubledata);
+ QCborStreamReader reader(doubledata);
+ if (useDevice) {
+ buffer.open(QIODevice::ReadOnly);
+ reader.setDevice(&buffer);
+ }
+ QVERIFY(reader.isValid());
+ QCOMPARE(reader.lastError(), QCborError::NoError);
+ QCOMPARE(parse(reader, data), expected); // yes, data
+
+ QVERIFY(reader.currentOffset() < doubledata.size());
+ if (useDevice) {
+ reader.setDevice(&buffer);
+ QVERIFY(reader.isValid());
+ QCOMPARE(reader.lastError(), QCborError::NoError);
+ QCOMPARE(parse(reader, data), expected);
+ QCOMPARE(buffer.pos(), doubledata.size());
+ } else {
+ // there's no reader.setData()
+ }
+}
+
+void tst_QCborStreamReader::extraData()
+{
+ QFETCH_GLOBAL(bool, useDevice);
+ QFETCH(QByteArray, data);
+ QFETCH(QString, expected);
+ removeIndicators(expected);
+
+ QByteArray extension(9, '\0');
+
+ // stress test everything with extra bytes (just one byte changing;
+ // TinyCBOR used to have a bug where the next byte got sometimes read)
+ for (int c = '\0'; c < 0x100; ++c) {
+ extension[0] = c;
+ QByteArray extendeddata = data + extension;
+
+ QBuffer buffer(&extendeddata);
+ QCborStreamReader reader(extendeddata);
+ if (useDevice) {
+ buffer.open(QIODevice::ReadOnly);
+ reader.setDevice(&buffer);
+ }
+ QVERIFY(reader.isValid());
+ QCOMPARE(reader.lastError(), QCborError::NoError);
+ QCOMPARE(parse(reader, data), expected); // yes, data
+
+ // if we were a parser, we could parse the next payload
+ if (useDevice)
+ QCOMPARE(buffer.readAll(), extension);
+ }
+}
+
QTEST_MAIN(tst_QCborStreamReader)
diff --git a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
index 4b753eab6b..9d453bd38e 100644
--- a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
+++ b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
@@ -91,8 +91,14 @@ private slots:
void toCbor_data();
void toCbor();
+ void toCborStreamWriter_data() { toCbor_data(); }
+ void toCborStreamWriter();
void fromCbor_data();
void fromCbor();
+ void fromCborStreamReaderByteArray_data() { fromCbor_data(); }
+ void fromCborStreamReaderByteArray();
+ void fromCborStreamReaderIODevice_data() { fromCbor_data(); }
+ void fromCborStreamReaderIODevice();
void validation_data();
void validation();
void toDiagnosticNotation_data();
@@ -1395,6 +1401,22 @@ void tst_QCborValue::toCbor()
"\xa1\x01\xd9\xd9\xf7" + result);
}
+void tst_QCborValue::toCborStreamWriter()
+{
+ QFETCH(QCborValue, v);
+ QFETCH(QByteArray, result);
+ QFETCH(QCborValue::EncodingOptions, options);
+
+ QByteArray output;
+ QBuffer buffer(&output);
+ buffer.open(QIODevice::WriteOnly);
+ QCborStreamWriter writer(&buffer);
+
+ v.toCbor(writer, options);
+ QCOMPARE(buffer.pos(), result.size());
+ QCOMPARE(output, result);
+}
+
void tst_QCborValue::fromCbor_data()
{
addCommonCborData();
@@ -1425,20 +1447,11 @@ void tst_QCborValue::fromCbor_data()
<< raw("\xd8\x25\x51" "\1\2\3\4""\4\3\2\0""\0\0\0\0""\0\0\0\1""\2");
}
-void tst_QCborValue::fromCbor()
+void fromCbor_common(void (*doCheck)(const QCborValue &, const QByteArray &))
{
QFETCH(QCborValue, v);
QFETCH(QByteArray, result);
- auto doCheck = [](const QCborValue &v, const QByteArray &result) {
- QCborParserError error;
- QCborValue decoded = QCborValue::fromCbor(result, &error);
- QVERIFY2(error.error == QCborError(), qPrintable(error.errorString()));
- QCOMPARE(error.offset, result.size());
- QVERIFY(decoded == v);
- QVERIFY(v == decoded);
- };
-
doCheck(v, result);
if (QTest::currentTestFailed())
return;
@@ -1489,6 +1502,52 @@ void tst_QCborValue::fromCbor()
return;
}
+void tst_QCborValue::fromCbor()
+{
+ auto doCheck = [](const QCborValue &v, const QByteArray &result) {
+ QCborParserError error;
+ QCborValue decoded = QCborValue::fromCbor(result, &error);
+ QVERIFY2(error.error == QCborError(), qPrintable(error.errorString()));
+ QCOMPARE(error.offset, result.size());
+ QVERIFY(decoded == v);
+ QVERIFY(v == decoded);
+ };
+
+ fromCbor_common(doCheck);
+}
+
+void tst_QCborValue::fromCborStreamReaderByteArray()
+{
+ auto doCheck = [](const QCborValue &expected, const QByteArray &data) {
+ QCborStreamReader reader(data);
+ QCborValue decoded = QCborValue::fromCbor(reader);
+ QCOMPARE(reader.lastError(), QCborError());
+ QCOMPARE(reader.currentOffset(), data.size());
+ QVERIFY(decoded == expected);
+ QVERIFY(expected == decoded);
+ };
+
+ fromCbor_common(doCheck);
+}
+
+void tst_QCborValue::fromCborStreamReaderIODevice()
+{
+ auto doCheck = [](const QCborValue &expected, const QByteArray &data) {
+ QBuffer buffer;
+ buffer.setData(data);
+ buffer.open(QIODevice::ReadOnly);
+ QCborStreamReader reader(&buffer);
+ QCborValue decoded = QCborValue::fromCbor(reader);
+ QCOMPARE(reader.lastError(), QCborError());
+ QCOMPARE(reader.currentOffset(), data.size());
+ QVERIFY(decoded == expected);
+ QVERIFY(expected == decoded);
+ QCOMPARE(buffer.pos(), reader.currentOffset());
+ };
+
+ fromCbor_common(doCheck);
+}
+
void tst_QCborValue::validation_data()
{
addValidationColumns();
diff --git a/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp b/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp
index d19eac7530..9a7c099228 100644
--- a/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp
+++ b/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp
@@ -84,6 +84,8 @@ private slots:
void operator_noteq();
void resize();
+ void fromBits_data();
+ void fromBits();
};
void tst_QBitArray::size_data()
@@ -610,5 +612,60 @@ void tst_QBitArray::resize()
}
+void tst_QBitArray::fromBits_data()
+{
+ QTest::addColumn<QByteArray>("data");
+ QTest::addColumn<int>("size");
+ QTest::addColumn<QBitArray>("expected");
+
+ QTest::newRow("empty") << QByteArray() << 0 << QBitArray();
+
+ auto add = [](const QByteArray &tag, const char *data) {
+ QTest::newRow(tag) << QByteArray(data, (tag.size() + 7) / 8) << tag.size()
+ << QStringToQBitArray(tag);
+ };
+
+ // "0" to "0000000000000000"
+ for (int i = 1; i < 16; ++i) {
+ char zero[2] = { 0, 0 };
+ QByteArray pattern(i, '0');
+ add(pattern, zero);
+ }
+
+ // "1" to "1111111111111111"
+ for (int i = 1; i < 16; ++i) {
+ char one[2] = { '\xff', '\xff' };
+ QByteArray pattern(i, '1');
+ add(pattern, one);
+ }
+
+ // trailing 0 and 1
+ char zero = 1;
+ char one = 0;
+ QByteArray pzero = "1";
+ QByteArray pone = "0";
+ for (int i = 2; i < 8; ++i) {
+ zero <<= 1;
+ pzero.prepend('0');
+ add(pzero, &zero);
+
+ one = (one << 1) | 1;
+ pone.prepend('1');
+ add(pone, &one);
+ }
+}
+
+void tst_QBitArray::fromBits()
+{
+ QFETCH(QByteArray, data);
+ QFETCH(int, size);
+ QFETCH(QBitArray, expected);
+
+ QBitArray fromBits = QBitArray::fromBits(data, size);
+ QCOMPARE(fromBits, expected);
+
+ QCOMPARE(QBitArray::fromBits(fromBits.bits(), fromBits.size()), expected);
+}
+
QTEST_APPLESS_MAIN(tst_QBitArray)
#include "tst_qbitarray.moc"
diff --git a/tests/auto/gui/kernel/kernel.pro b/tests/auto/gui/kernel/kernel.pro
index fbd3b1b371..42135dae24 100644
--- a/tests/auto/gui/kernel/kernel.pro
+++ b/tests/auto/gui/kernel/kernel.pro
@@ -11,6 +11,7 @@ SUBDIRS=\
qguimetatype \
qguitimer \
qguivariant \
+ qhighdpiscaling \
qinputmethod \
qkeyevent \
qkeysequence \
@@ -35,6 +36,8 @@ win32:!winrt:qtHaveModule(network): SUBDIRS += noqteventloop
!qtHaveModule(network): SUBDIRS -= \
qguieventloop
+!qtConfig(highdpiscaling): SUBDIRS -= qhighdpiscaling
+
!qtConfig(opengl): SUBDIRS -= qopenglwindow
android|uikit: SUBDIRS -= qclipboard
diff --git a/tests/auto/gui/kernel/qhighdpiscaling/qhighdpiscaling.pro b/tests/auto/gui/kernel/qhighdpiscaling/qhighdpiscaling.pro
new file mode 100644
index 0000000000..6cd7bb01f5
--- /dev/null
+++ b/tests/auto/gui/kernel/qhighdpiscaling/qhighdpiscaling.pro
@@ -0,0 +1,6 @@
+CONFIG += testcase
+TARGET = tst_qhighdpiscaling
+
+QT += core-private gui-private testlib
+
+SOURCES += tst_qhighdpiscaling.cpp
diff --git a/tests/auto/gui/kernel/qhighdpiscaling/tst_qhighdpiscaling.cpp b/tests/auto/gui/kernel/qhighdpiscaling/tst_qhighdpiscaling.cpp
new file mode 100644
index 0000000000..ec80c2d02c
--- /dev/null
+++ b/tests/auto/gui/kernel/qhighdpiscaling/tst_qhighdpiscaling.cpp
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite 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$
+**
+****************************************************************************/
+
+#include <private/qhighdpiscaling_p.h>
+#include <qpa/qplatformscreen.h>
+
+#include <QtTest/QtTest>
+
+class tst_QHighDpiScaling: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void factor();
+ void scale();
+};
+
+// Emulate the case of a High DPI secondary screen
+class MyPlatformScreen : public QPlatformScreen
+{
+public:
+ QRect geometry() const override { return QRect(3840, 0, 3840, 1920); }
+ QRect availableGeometry() const override { return geometry(); }
+
+ int depth() const override { return 32; }
+ QImage::Format format() const override { return QImage::Format_ARGB32_Premultiplied; }
+};
+
+void tst_QHighDpiScaling::factor()
+{
+ QHighDpiScaling::setGlobalFactor(2);
+
+ // Verfy that QHighDpiScaling::factor() does not crash on nullptr contexts.
+ QPoint fakeNativePosition = QPoint(5, 5);
+ QPlatformScreen *screenContext = nullptr;
+ QVERIFY(QHighDpiScaling::factor(screenContext) >= 0);
+ QVERIFY(QHighDpiScaling::factor(screenContext, &fakeNativePosition) >= 0);
+ QPlatformScreen *platformScreenContext = nullptr;
+ QVERIFY(QHighDpiScaling::factor(platformScreenContext) >= 0);
+ QVERIFY(QHighDpiScaling::factor(platformScreenContext, &fakeNativePosition) >= 0);
+ QWindow *windowContext = nullptr;
+ QVERIFY(QHighDpiScaling::factor(windowContext) >= 0);
+ QVERIFY(QHighDpiScaling::factor(windowContext, &fakeNativePosition) >= 0);
+}
+
+// QTBUG-77255: Test some scaling overloads
+void tst_QHighDpiScaling::scale()
+{
+ QHighDpiScaling::setGlobalFactor(2);
+ QScopedPointer<QPlatformScreen> screen(new MyPlatformScreen);
+
+ qreal nativeValue = 10;
+ const qreal value = QHighDpi::fromNativePixels(nativeValue, screen.data());
+ QCOMPARE(value, qreal(5));
+ QCOMPARE(QHighDpi::toNativePixels(value, screen.data()), nativeValue);
+
+ // 10, 10 within screen should translate to 5,5 with origin preserved
+ const QPoint nativePoint = screen->geometry().topLeft() + QPoint(10, 10);
+ const QPoint point = QHighDpi::fromNativePixels(nativePoint, screen.data());
+ QCOMPARE(point, QPoint(3845, 5));
+ QCOMPARE(QHighDpi::toNativePixels(point, screen.data()), nativePoint);
+
+ const QPointF nativePointF(nativePoint);
+ const QPointF pointF = QHighDpi::fromNativePixels(nativePointF, screen.data());
+ QCOMPARE(pointF, QPointF(3845, 5));
+ QCOMPARE(QHighDpi::toNativePixels(pointF, screen.data()), nativePointF);
+}
+
+#include "tst_qhighdpiscaling.moc"
+QTEST_MAIN(tst_QHighDpiScaling);
diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
index 32131352c3..c04c841376 100644
--- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
+++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
@@ -188,6 +188,8 @@ private slots:
void lineHeightType();
void cssLineHeightMultiplier();
+
+ void clearUndoRedoStacks();
private:
void backgroundImage_checkExpectedHtml(const QTextDocument &doc);
void buildRegExpData();
@@ -3486,5 +3488,16 @@ void tst_QTextDocument::cssLineHeightMultiplier()
}
}
+void tst_QTextDocument::clearUndoRedoStacks()
+{
+ QTextDocument doc;
+ QTextCursor c(&doc);
+ c.insertText(QStringLiteral("lorem ipsum"));
+ QVERIFY(doc.isUndoAvailable());
+ doc.clearUndoRedoStacks(QTextDocument::UndoStack); // Don't crash
+ QVERIFY(!doc.isUndoAvailable());
+}
+
+
QTEST_MAIN(tst_QTextDocument)
#include "tst_qtextdocument.moc"
diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
index 9c477589f9..f0a32c2ed4 100644
--- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
+++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
@@ -138,6 +138,7 @@ private slots:
void noModificationOfInputString();
void superscriptCrash_qtbug53911();
void showLineAndParagraphSeparatorsCrash();
+ void tooManyDirectionalCharctersCrash_qtbug77819();
private:
QFont testFont;
@@ -2309,5 +2310,21 @@ void tst_QTextLayout::nbspWithFormat()
QCOMPARE(layout.lineAt(1).textLength(), s2.length() + 1 + s3.length());
}
+void tst_QTextLayout::tooManyDirectionalCharctersCrash_qtbug77819()
+{
+ QString data;
+ data += QString::fromUtf8("\xe2\x81\xa8"); // U+2068 FSI character
+ data += QString::fromUtf8("\xe2\x81\xa7"); // U+2067 RLI character
+
+ // duplicating the text
+ for (int i = 0; i < 10; i++)
+ data += data;
+
+ // Nothing to test. It must not crash in beginLayout().
+ QTextLayout tl(data);
+ tl.beginLayout();
+ tl.endLayout();
+}
+
QTEST_MAIN(tst_QTextLayout)
#include "tst_qtextlayout.moc"
diff --git a/tests/auto/gui/util/qtexturefilereader/qtexturefilereader.qrc b/tests/auto/gui/util/qtexturefilereader/qtexturefilereader.qrc
index ab882b5db2..8aab86e1ff 100644
--- a/tests/auto/gui/util/qtexturefilereader/qtexturefilereader.qrc
+++ b/tests/auto/gui/util/qtexturefilereader/qtexturefilereader.qrc
@@ -3,5 +3,7 @@
<file>texturefiles/car.ktx</file>
<file>texturefiles/pattern.pkm</file>
<file>texturefiles/car_mips.ktx</file>
+ <file>texturefiles/newlogo_srgb.astc</file>
+ <file>texturefiles/newlogo.astc</file>
</qresource>
</RCC>
diff --git a/tests/auto/gui/util/qtexturefilereader/texturefiles/newlogo.astc b/tests/auto/gui/util/qtexturefilereader/texturefiles/newlogo.astc
new file mode 100644
index 0000000000..39bf3f1734
--- /dev/null
+++ b/tests/auto/gui/util/qtexturefilereader/texturefiles/newlogo.astc
Binary files differ
diff --git a/tests/auto/gui/util/qtexturefilereader/texturefiles/newlogo_srgb.astc b/tests/auto/gui/util/qtexturefilereader/texturefiles/newlogo_srgb.astc
new file mode 100644
index 0000000000..38e876829b
--- /dev/null
+++ b/tests/auto/gui/util/qtexturefilereader/texturefiles/newlogo_srgb.astc
Binary files differ
diff --git a/tests/auto/gui/util/qtexturefilereader/tst_qtexturefilereader.cpp b/tests/auto/gui/util/qtexturefilereader/tst_qtexturefilereader.cpp
index 9ff4f0ccf2..7939b688af 100644
--- a/tests/auto/gui/util/qtexturefilereader/tst_qtexturefilereader.cpp
+++ b/tests/auto/gui/util/qtexturefilereader/tst_qtexturefilereader.cpp
@@ -27,6 +27,7 @@
****************************************************************************/
#include <private/qtexturefilereader_p.h>
+#include <private/qtguiglobal_p.h>
#include <QtTest>
class tst_qtexturefilereader : public QObject
@@ -49,33 +50,57 @@ void tst_qtexturefilereader::checkHandlers_data()
QTest::addColumn<QList<int>>("dataOffsets");
QTest::addColumn<QList<int>>("dataLengths");
- QTest::addRow("pattern.pkm") << QStringLiteral(":/texturefiles/pattern.pkm")
- << QSize(64, 64)
- << quint32(0x0)
- << quint32(0x8d64)
- << quint32(0x0)
- << 1
- << (QList<int>() << 16)
- << (QList<int>() << 2048);
+ QTest::addRow("pattern.pkm")
+ << QStringLiteral(":/texturefiles/pattern.pkm")
+ << QSize(64, 64)
+ << quint32(0x0)
+ << quint32(0x8d64)
+ << quint32(0x0)
+ << 1
+ << (QList<int>() << 16)
+ << (QList<int>() << 2048);
- QTest::addRow("car.ktx") << QStringLiteral(":/texturefiles/car.ktx")
- << QSize(146, 80)
- << quint32(0x0)
- << quint32(0x9278)
- << quint32(0x1908)
- << 1
- << (QList<int>() << 68)
- << (QList<int>() << 11840);
+ QTest::addRow("car.ktx")
+ << QStringLiteral(":/texturefiles/car.ktx")
+ << QSize(146, 80)
+ << quint32(0x0)
+ << quint32(0x9278)
+ << quint32(0x1908)
+ << 1
+ << (QList<int>() << 68)
+ << (QList<int>() << 11840);
- QTest::addRow("car_mips.ktx") << QStringLiteral(":/texturefiles/car_mips.ktx")
- << QSize(146, 80)
- << quint32(0x0)
- << quint32(0x9274)
- << quint32(0x1907)
- << 8
- << (QList<int>() << 68 << 5992 << 7516 << 7880 << 8004 << 8056 << 8068 << 8080)
- << (QList<int>() << 5920 << 1520 << 360 << 120 << 48 << 8 << 8 << 8);
+ QTest::addRow("car_mips.ktx")
+ << QStringLiteral(":/texturefiles/car_mips.ktx")
+ << QSize(146, 80)
+ << quint32(0x0)
+ << quint32(0x9274)
+ << quint32(0x1907)
+ << 8
+ << (QList<int>() << 68 << 5992 << 7516 << 7880 << 8004 << 8056 << 8068 << 8080)
+ << (QList<int>() << 5920 << 1520 << 360 << 120 << 48 << 8 << 8 << 8);
+#if QT_CONFIG(texture_format_astc_experimental)
+ QTest::addRow("newlogo.astc")
+ << QStringLiteral(":/texturefiles/newlogo.astc")
+ << QSize(111, 78)
+ << quint32(0x0)
+ << quint32(0x93b9)
+ << quint32(0x0)
+ << 1
+ << (QList<int>() << 16)
+ << (QList<int>() << 2496);
+
+ QTest::addRow("newlogo_srgb.astc")
+ << QStringLiteral(":/texturefiles/newlogo_srgb.astc")
+ << QSize(111, 78)
+ << quint32(0x0)
+ << quint32(0x93d9)
+ << quint32(0x0)
+ << 1
+ << (QList<int>() << 16)
+ << (QList<int>() << 2496);
+#endif // QT_CONFIG(texture_format_astc_experimental)
}
void tst_qtexturefilereader::checkHandlers()
diff --git a/tests/auto/network/access/http2/tst_http2.cpp b/tests/auto/network/access/http2/tst_http2.cpp
index 579eb89c0a..fe40d1c723 100644
--- a/tests/auto/network/access/http2/tst_http2.cpp
+++ b/tests/auto/network/access/http2/tst_http2.cpp
@@ -46,6 +46,7 @@
#endif // NO_SSL
#include <cstdlib>
+#include <memory>
#include <string>
#include "emulationdetector.h"
@@ -83,6 +84,8 @@ private slots:
void goaway_data();
void goaway();
void earlyResponse();
+ void connectToHost_data();
+ void connectToHost();
protected slots:
// Slots to listen to our in-process server:
@@ -116,7 +119,7 @@ private:
quint16 serverPort = 0;
QThread *workerThread = nullptr;
- QNetworkAccessManager manager;
+ std::unique_ptr<QNetworkAccessManager> manager;
QTestEventLoop eventLoop;
@@ -130,6 +133,10 @@ private:
static const Http2::RawSettings defaultServerSettings;
};
+#define STOP_ON_FAILURE \
+ if (QTest::currentTestFailed()) \
+ return;
+
const Http2::RawSettings tst_Http2::defaultServerSettings{{Http2::Settings::MAX_CONCURRENT_STREAMS_ID, 100}};
namespace {
@@ -177,7 +184,7 @@ tst_Http2::~tst_Http2()
void tst_Http2::init()
{
- manager.clearConnectionCache();
+ manager.reset(new QNetworkAccessManager);
}
void tst_Http2::singleRequest_data()
@@ -234,13 +241,14 @@ void tst_Http2::singleRequest()
QFETCH(const QNetworkRequest::Attribute, h2Attribute);
request.setAttribute(h2Attribute, QVariant(true));
- auto reply = manager.get(request);
+ auto reply = manager->get(request);
connect(reply, &QNetworkReply::finished, this, &tst_Http2::replyFinished);
// Since we're using self-signed certificates,
// ignore SSL errors:
reply->ignoreSslErrors();
runEventLoop();
+ STOP_ON_FAILURE
QVERIFY(nRequests == 0);
QVERIFY(prefaceOK);
@@ -276,6 +284,7 @@ void tst_Http2::multipleRequests()
sendRequest(i, priorities[QRandomGenerator::global()->bounded(3)]);
runEventLoop();
+ STOP_ON_FAILURE
QVERIFY(nRequests == 0);
QVERIFY(prefaceOK);
@@ -305,7 +314,7 @@ void tst_Http2::flowControlClientSide()
params.maxSessionReceiveWindowSize = Http2::defaultSessionWindowSize * 5;
params.settingsFrameData[Settings::INITIAL_WINDOW_SIZE_ID] = Http2::defaultSessionWindowSize;
// Inform our manager about non-default settings:
- manager.setProperty(Http2::http2ParametersPropertyName, QVariant::fromValue(params));
+ manager->setProperty(Http2::http2ParametersPropertyName, QVariant::fromValue(params));
const Http2::RawSettings serverSettings = {{Settings::MAX_CONCURRENT_STREAMS_ID, quint32(3)}};
ServerPtr srv(newServer(serverSettings, defaultConnectionType(), params));
@@ -323,6 +332,7 @@ void tst_Http2::flowControlClientSide()
sendRequest(i);
runEventLoop(120000);
+ STOP_ON_FAILURE
QVERIFY(nRequests == 0);
QVERIFY(prefaceOK);
@@ -363,6 +373,7 @@ void tst_Http2::flowControlServerSide()
sendRequest(i, QNetworkRequest::NormalPriority, payload);
runEventLoop(120000);
+ STOP_ON_FAILURE
QVERIFY(nRequests == 0);
QVERIFY(prefaceOK);
@@ -383,7 +394,7 @@ void tst_Http2::pushPromise()
Http2::ProtocolParameters params;
// Defaults are good, except ENABLE_PUSH:
params.settingsFrameData[Settings::ENABLE_PUSH_ID] = 1;
- manager.setProperty(Http2::http2ParametersPropertyName, QVariant::fromValue(params));
+ manager->setProperty(Http2::http2ParametersPropertyName, QVariant::fromValue(params));
ServerPtr srv(newServer(defaultServerSettings, defaultConnectionType(), params));
srv->enablePushPromise(true, QByteArray("/script.js"));
@@ -399,12 +410,13 @@ void tst_Http2::pushPromise()
QNetworkRequest request(url);
request.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, QVariant(true));
- auto reply = manager.get(request);
+ auto reply = manager->get(request);
connect(reply, &QNetworkReply::finished, this, &tst_Http2::replyFinished);
// Since we're using self-signed certificates, ignore SSL errors:
reply->ignoreSslErrors();
runEventLoop();
+ STOP_ON_FAILURE
QVERIFY(nRequests == 0);
QVERIFY(prefaceOK);
@@ -422,7 +434,7 @@ void tst_Http2::pushPromise()
url.setPath("/script.js");
QNetworkRequest promisedRequest(url);
promisedRequest.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, QVariant(true));
- reply = manager.get(promisedRequest);
+ reply = manager->get(promisedRequest);
connect(reply, &QNetworkReply::finished, this, &tst_Http2::replyFinished);
reply->ignoreSslErrors();
@@ -443,6 +455,9 @@ void tst_Http2::goaway_data()
// - server waits for some time (enough for ur to init several streams on a
// client side); then suddenly it replies with GOAWAY, never processing any
// request.
+ if (clearTextHTTP2)
+ QSKIP("This test requires TLS with ALPN to work");
+
QTest::addColumn<int>("responseTimeoutMS");
QTest::newRow("ImmediateGOAWAY") << 0;
QTest::newRow("DelayedGOAWAY") << 1000;
@@ -473,7 +488,7 @@ void tst_Http2::goaway()
url.setPath(QString("/%1").arg(i));
QNetworkRequest request(url);
request.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, QVariant(true));
- replies[i] = manager.get(request);
+ replies[i] = manager->get(request);
QCOMPARE(replies[i]->error(), QNetworkReply::NoError);
void (QNetworkReply::*errorSignal)(QNetworkReply::NetworkError) =
&QNetworkReply::error;
@@ -483,6 +498,7 @@ void tst_Http2::goaway()
}
runEventLoop(5000 + responseTimeoutMS);
+ STOP_ON_FAILURE
// No request processed, no 'replyFinished' slot calls:
QCOMPARE(nRequests, 0);
@@ -526,10 +542,142 @@ void tst_Http2::earlyResponse()
sendRequest(1, QNetworkRequest::NormalPriority, {1000000, Qt::Uninitialized});
runEventLoop();
+ STOP_ON_FAILURE
+
+ QVERIFY(nRequests == 0);
+ QVERIFY(prefaceOK);
+ QVERIFY(serverGotSettingsACK);
+}
+
+void tst_Http2::connectToHost_data()
+{
+ // The attribute to set on a new request:
+ QTest::addColumn<QNetworkRequest::Attribute>("requestAttribute");
+ // The corresponding (to the attribute above) connection type the
+ // server will use:
+ QTest::addColumn<H2Type>("connectionType");
+
+#if QT_CONFIG(ssl)
+ QTest::addRow("encrypted-h2-direct") << QNetworkRequest::Http2DirectAttribute << H2Type::h2Direct;
+ if (!clearTextHTTP2)
+ QTest::addRow("encrypted-h2-ALPN") << QNetworkRequest::HTTP2AllowedAttribute << H2Type::h2Alpn;
+#endif // QT_CONFIG(ssl)
+ // This works for all configurations, tests 'preconnect-http' scheme:
+ // h2 with protocol upgrade is not working for now (the logic is a bit
+ // complicated there ...).
+ QTest::addRow("h2-direct") << QNetworkRequest::Http2DirectAttribute << H2Type::h2cDirect;
+}
+
+void tst_Http2::connectToHost()
+{
+ // QNetworkAccessManager::connectToHostEncrypted() and connectToHost()
+ // creates a special request with 'preconnect-https' or 'preconnect-http'
+ // schemes. At the level of the protocol handler we are supposed to report
+ // these requests as finished and wait for the real requests. This test will
+ // connect to a server with the first reply 'finished' signal meaning we
+ // indeed connected. At this point we check that a client preface was not
+ // sent yet, and no response received. Then we send the second (the real)
+ // request and do our usual checks. Since our server closes its listening
+ // socket on the first incoming connection (would not accept a new one),
+ // the successful completion of the second requests also means we were able
+ // to find a cached connection and re-use it.
+
+ QFETCH(const QNetworkRequest::Attribute, requestAttribute);
+ QFETCH(const H2Type, connectionType);
+
+ clearHTTP2State();
+
+ serverPort = 0;
+ nRequests = 2;
+
+ ServerPtr targetServer(newServer(defaultServerSettings, connectionType));
+
+#if QT_CONFIG(ssl)
+ Q_ASSERT(!clearTextHTTP2 || connectionType != H2Type::h2Alpn);
+
+#if QT_CONFIG(securetransport)
+ // Normally on macOS we use plain text only for SecureTransport
+ // does not support ALPN on the server side. With 'direct encrytped'
+ // we have to use TLS sockets (== private key) and thus suppress a
+ // keychain UI asking for permission to use a private key.
+ // Our CI has this, but somebody testing locally - will have a problem.
+ qputenv("QT_SSL_USE_TEMPORARY_KEYCHAIN", QByteArray("1"));
+ auto envRollback = qScopeGuard([](){
+ qunsetenv("QT_SSL_USE_TEMPORARY_KEYCHAIN");
+ });
+#endif // QT_CONFIG(securetransport)
+
+#else
+ Q_ASSERT(connectionType == H2Type::h2c || connectionType == H2Type::h2cDirect);
+ Q_ASSERT(targetServer->isClearText());
+#endif // QT_CONFIG(ssl)
+
+ QMetaObject::invokeMethod(targetServer.data(), "startServer", Qt::QueuedConnection);
+ runEventLoop();
+
+ QVERIFY(serverPort != 0);
+
+ auto url = requestUrl(connectionType);
+ url.setPath("/index.html");
+
+ QNetworkReply *reply = nullptr;
+ // Here some mess with how we create this first reply:
+#if QT_CONFIG(ssl)
+ if (!targetServer->isClearText()) {
+ // Let's emulate what QNetworkAccessManager::connectToHostEncrypted() does.
+ // Alas, we cannot use it directly, since it does not return the reply and
+ // also does not know the difference between H2 with ALPN or direct.
+ auto copyUrl = url;
+ copyUrl.setScheme(QLatin1String("preconnect-https"));
+ QNetworkRequest request(copyUrl);
+ request.setAttribute(requestAttribute, true);
+ reply = manager->get(request);
+ // Since we're using self-signed certificates, ignore SSL errors:
+ reply->ignoreSslErrors();
+ } else
+#endif // QT_CONFIG(ssl)
+ {
+ // Emulating what QNetworkAccessManager::connectToHost() does with
+ // additional information that it cannot provide (the attribute).
+ auto copyUrl = url;
+ copyUrl.setScheme(QLatin1String("preconnect-http"));
+ QNetworkRequest request(copyUrl);
+ request.setAttribute(requestAttribute, true);
+ reply = manager->get(request);
+ }
+
+ connect(reply, &QNetworkReply::finished, [this, reply]() {
+ --nRequests;
+ eventLoop.exitLoop();
+ QCOMPARE(reply->error(), QNetworkReply::NoError);
+ QVERIFY(reply->isFinished());
+ // Nothing received back:
+ QVERIFY(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).isNull());
+ QCOMPARE(reply->readAll().size(), 0);
+ });
+
+ runEventLoop();
+ STOP_ON_FAILURE
+
+ QCOMPARE(nRequests, 1);
+
+ QNetworkRequest request(url);
+ request.setAttribute(requestAttribute, QVariant(true));
+ reply = manager->get(request);
+ connect(reply, &QNetworkReply::finished, this, &tst_Http2::replyFinished);
+ // Note, unlike the first request, when the connection is ecnrytped, we
+ // do not ignore TLS errors on this reply - we should re-use existing
+ // connection, there TLS errors were already ignored.
+
+ runEventLoop();
+ STOP_ON_FAILURE
QVERIFY(nRequests == 0);
QVERIFY(prefaceOK);
QVERIFY(serverGotSettingsACK);
+
+ QCOMPARE(reply->error(), QNetworkReply::NoError);
+ QVERIFY(reply->isFinished());
}
void tst_Http2::serverStarted(quint16 port)
@@ -543,7 +691,7 @@ void tst_Http2::clearHTTP2State()
windowUpdates = 0;
prefaceOK = false;
serverGotSettingsACK = false;
- manager.setProperty(Http2::http2ParametersPropertyName, QVariant());
+ manager->setProperty(Http2::http2ParametersPropertyName, QVariant());
}
void tst_Http2::runEventLoop(int ms)
@@ -596,9 +744,9 @@ void tst_Http2::sendRequest(int streamNumber,
QNetworkReply *reply = nullptr;
if (payload.size())
- reply = manager.post(request, payload);
+ reply = manager->post(request, payload);
else
- reply = manager.get(request);
+ reply = manager->get(request);
reply->ignoreSslErrors();
connect(reply, &QNetworkReply::finished, this, &tst_Http2::replyFinished);
@@ -690,14 +838,29 @@ void tst_Http2::replyFinished()
QVERIFY(nRequests);
if (const auto reply = qobject_cast<QNetworkReply *>(sender())) {
+ if (reply->error() != QNetworkReply::NoError)
+ stopEventLoop();
+
QCOMPARE(reply->error(), QNetworkReply::NoError);
+
const QVariant http2Used(reply->attribute(QNetworkRequest::HTTP2WasUsedAttribute));
+ if (!http2Used.isValid() || !http2Used.toBool())
+ stopEventLoop();
+
QVERIFY(http2Used.isValid());
QVERIFY(http2Used.toBool());
+
const QVariant spdyUsed(reply->attribute(QNetworkRequest::SpdyWasUsedAttribute));
+ if (!spdyUsed.isValid() || spdyUsed.toBool())
+ stopEventLoop();
+
QVERIFY(spdyUsed.isValid());
QVERIFY(!spdyUsed.toBool());
+
const QVariant code(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute));
+ if (!code.isValid() || !code.canConvert<int>() || code.value<int>() != 200)
+ stopEventLoop();
+
QVERIFY(code.isValid());
QVERIFY(code.canConvert<int>());
QCOMPARE(code.value<int>(), 200);
@@ -715,6 +878,8 @@ void tst_Http2::replyFinishedWithError()
if (const auto reply = qobject_cast<QNetworkReply *>(sender())) {
// For now this is a 'generic' code, it just verifies some error was
// reported without testing its type.
+ if (reply->error() == QNetworkReply::NoError)
+ stopEventLoop();
QVERIFY(reply->error() != QNetworkReply::NoError);
}
diff --git a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp
index 0a130d363e..9905cfe075 100644
--- a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp
+++ b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp
@@ -92,6 +92,7 @@ private slots:
void lookupIPv6();
void lookupConnectToFunctionPointer_data();
void lookupConnectToFunctionPointer();
+ void lookupConnectToFunctionPointerDeleted();
void lookupConnectToLambda_data();
void lookupConnectToLambda();
void reverseLookup_data();
@@ -361,6 +362,17 @@ void tst_QHostInfo::lookupConnectToFunctionPointer()
QCOMPARE(tmp.join(' '), expected.join(' '));
}
+void tst_QHostInfo::lookupConnectToFunctionPointerDeleted()
+{
+ {
+ QObject contextObject;
+ QHostInfo::lookupHost("localhost", &contextObject, [](const QHostInfo){
+ QFAIL("This should never be called!");
+ });
+ }
+ QTestEventLoop::instance().enterLoop(3);
+}
+
void tst_QHostInfo::lookupConnectToLambda_data()
{
lookupIPv4_data();
@@ -708,6 +720,7 @@ void tst_QHostInfo::cache()
void tst_QHostInfo::resultsReady(const QHostInfo &hi)
{
+ QVERIFY(QThread::currentThread() == thread());
lookupDone = true;
lookupResults = hi;
lookupsDoneCounter++;
diff --git a/tests/auto/other/lancelot/paintcommands.cpp b/tests/auto/other/lancelot/paintcommands.cpp
index 8aa3a035e3..60f95ed2ae 100644
--- a/tests/auto/other/lancelot/paintcommands.cpp
+++ b/tests/auto/other/lancelot/paintcommands.cpp
@@ -1010,7 +1010,10 @@ void PaintCommands::command_drawPixmap(QRegularExpressionMatch re)
qPrintable(re.captured(1)), pm.width(), pm.height(), pm.depth(),
tx, ty, tw, th, sx, sy, sw, sh);
- m_painter->drawPixmap(QRectF(tx, ty, tw, th), pm, QRectF(sx, sy, sw, sh));
+ if (!re.capturedLength(4)) // at most two coordinates specified
+ m_painter->drawPixmap(QPointF(tx, ty), pm);
+ else
+ m_painter->drawPixmap(QRectF(tx, ty, tw, th), pm, QRectF(sx, sy, sw, sh));
}
/***************************************************************************************************/
@@ -1057,7 +1060,10 @@ void PaintCommands::command_drawImage(QRegularExpressionMatch re)
printf(" -(lance) drawImage('%s' dim=(%d, %d), (%f, %f, %f, %f), (%f, %f, %f, %f)\n",
qPrintable(re.captured(1)), im.width(), im.height(), tx, ty, tw, th, sx, sy, sw, sh);
- m_painter->drawImage(QRectF(tx, ty, tw, th), im, QRectF(sx, sy, sw, sh), Qt::OrderedDither | Qt::OrderedAlphaDither);
+ if (!re.capturedLength(4)) // at most two coordinates specified
+ m_painter->drawImage(QPointF(tx, ty), im);
+ else
+ m_painter->drawImage(QRectF(tx, ty, tw, th), im, QRectF(sx, sy, sw, sh));
}
/***************************************************************************************************/
diff --git a/tests/auto/tools/qmake/testcompiler.cpp b/tests/auto/tools/qmake/testcompiler.cpp
index 0a7ba3b40b..e769f955c4 100644
--- a/tests/auto/tools/qmake/testcompiler.cpp
+++ b/tests/auto/tools/qmake/testcompiler.cpp
@@ -279,6 +279,13 @@ bool TestCompiler::qmake(const QString &workDir, const QString &proName, const Q
<< additionalArguments);
}
+bool TestCompiler::qmake(const QString &workDir, const QStringList &arguments)
+{
+ QDir d;
+ d.setCurrent(workDir); // ### runCommand should take a workingDir argument instead
+ return runCommand(qmakeCmd_, arguments);
+}
+
bool TestCompiler::make( const QString &workPath, const QString &target, bool expectFail )
{
QDir D;
diff --git a/tests/auto/tools/qmake/testcompiler.h b/tests/auto/tools/qmake/testcompiler.h
index 50232669c0..e22a2c6c3d 100644
--- a/tests/auto/tools/qmake/testcompiler.h
+++ b/tests/auto/tools/qmake/testcompiler.h
@@ -60,6 +60,8 @@ public:
// executes a qmake on proName in the specified workDir, output goes to buildDir or workDir if it's null
bool qmake(const QString &workDir, const QString &proName, const QString &buildDir = QString(),
const QStringList &additionalArguments = QStringList());
+ // executes qmake in workDir with the specified arguments
+ bool qmake(const QString &workDir, const QStringList &arguments);
// executes a make in the specified workPath, with an optional target (eg. install)
bool make( const QString &workPath, const QString &target = QString(), bool expectFail = false );
// checks if the executable exists in destDir
diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp
index cacee30c86..09e725f98a 100644
--- a/tests/auto/tools/qmake/tst_qmake.cpp
+++ b/tests/auto/tools/qmake/tst_qmake.cpp
@@ -81,6 +81,7 @@ private slots:
void substitutes();
void project();
void proFileCache();
+ void qinstall();
void resources();
private:
@@ -588,6 +589,101 @@ void tst_qmake::proFileCache()
QVERIFY( test_compiler.qmake( workDir, "pro_file_cache" ));
}
+void tst_qmake::qinstall()
+{
+ const QString testName = "qinstall";
+ QDir testDataDir = base_path + "/testdata";
+ if (testDataDir.exists(testName))
+ testDataDir.rmdir(testName);
+ QVERIFY(testDataDir.mkdir(testName));
+ const QString workDir = testDataDir.filePath(testName);
+ auto qinstall = [&](const QString &src, const QString &dst, bool executable = false) {
+ QStringList args = {"-install", "qinstall"};
+ if (executable)
+ args << "-exe";
+ args << src << dst;
+ return test_compiler.qmake(workDir, args);
+ };
+ const QFileDevice::Permissions readFlags
+ = QFileDevice::ReadOwner | QFileDevice::ReadUser
+ | QFileDevice::ReadGroup | QFileDevice::ReadOther;
+ const QFileDevice::Permissions writeFlags
+ = QFileDevice::WriteOwner | QFileDevice::WriteUser
+ | QFileDevice::WriteGroup | QFileDevice::WriteOther;
+ const QFileDevice::Permissions exeFlags
+ = QFileDevice::ExeOwner | QFileDevice::ExeUser
+ | QFileDevice::ExeGroup | QFileDevice::ExeOther;
+
+ // install a regular file
+ {
+ QFileInfo src(testDataDir.filePath("project/main.cpp"));
+ QFileInfo dst("foo.cpp");
+ QVERIFY(qinstall(src.filePath(), dst.filePath()));
+ QVERIFY(dst.exists());
+ QCOMPARE(src.size(), dst.size());
+ QVERIFY(dst.permissions() & readFlags);
+ QVERIFY(dst.permissions() & writeFlags);
+ QVERIFY(!(dst.permissions() & exeFlags));
+ test_compiler.clearCommandOutput();
+ }
+
+ // install an executable file
+ {
+ const QString mocFilePath = QLibraryInfo::location(QLibraryInfo::BinariesPath)
+ + "/moc"
+#ifdef Q_OS_WIN
+ + ".exe"
+#endif
+ ;
+ QFileInfo src(mocFilePath);
+ QVERIFY(src.exists());
+ QVERIFY(src.permissions() & exeFlags);
+ QFileInfo dst("copied_" + src.fileName());
+ QVERIFY(qinstall(src.filePath(), dst.filePath(), true));
+ QVERIFY(dst.exists());
+ QCOMPARE(src.size(), dst.size());
+ QVERIFY(dst.permissions() & readFlags);
+ QVERIFY(dst.permissions() & writeFlags);
+ QVERIFY(dst.permissions() & exeFlags);
+ test_compiler.clearCommandOutput();
+ }
+
+ // install a read-only file
+ {
+ QFile srcfile("foo.cpp");
+ QVERIFY(srcfile.setPermissions(srcfile.permissions() & ~writeFlags));
+ QFileInfo src(srcfile);
+ QFileInfo dst("bar.cpp");
+ QVERIFY(qinstall(src.filePath(), dst.filePath()));
+ QVERIFY(dst.exists());
+ QCOMPARE(src.size(), dst.size());
+ QVERIFY(dst.permissions() & readFlags);
+ QVERIFY(dst.permissions() & writeFlags);
+ QVERIFY(!(dst.permissions() & exeFlags));
+ test_compiler.clearCommandOutput();
+ }
+
+ // install a directory
+ {
+ QDir src = testDataDir;
+ src.cd("project");
+ QDir dst("narf");
+ QVERIFY(qinstall(src.absolutePath(), dst.absolutePath()));
+ QCOMPARE(src.entryList(QDir::Files, QDir::Name), dst.entryList(QDir::Files, QDir::Name));
+ test_compiler.clearCommandOutput();
+ }
+
+ // install a directory with a read-only file
+ {
+ QDir src("narf");
+ QFile srcfile(src.filePath("main.cpp"));
+ QVERIFY(srcfile.setPermissions(srcfile.permissions() & ~writeFlags));
+ QDir dst("zort");
+ QVERIFY(qinstall(src.absolutePath(), dst.absolutePath()));
+ QCOMPARE(src.entryList(QDir::Files, QDir::Name), dst.entryList(QDir::Files, QDir::Name));
+ }
+}
+
void tst_qmake::resources()
{
QString workDir = base_path + "/testdata/resources";
diff --git a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
index 63f6e67a3e..da75e64d1e 100644
--- a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
+++ b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
@@ -417,20 +417,19 @@ void tst_QWizard::setPixmap()
QVERIFY(wizard.pixmap(QWizard::BannerPixmap).isNull());
QVERIFY(wizard.pixmap(QWizard::LogoPixmap).isNull());
QVERIFY(wizard.pixmap(QWizard::WatermarkPixmap).isNull());
-#ifdef Q_OS_OSX
- QVERIFY(!wizard.pixmap(QWizard::BackgroundPixmap).isNull());
-#else
- QVERIFY(wizard.pixmap(QWizard::BackgroundPixmap).isNull());
-#endif
+ if (QSysInfo::macVersion() <= Q_MV_OSX(10, 13))
+ QVERIFY(!wizard.pixmap(QWizard::BackgroundPixmap).isNull());
+ else
+ QVERIFY(wizard.pixmap(QWizard::BackgroundPixmap).isNull());
QVERIFY(page->pixmap(QWizard::BannerPixmap).isNull());
QVERIFY(page->pixmap(QWizard::LogoPixmap).isNull());
QVERIFY(page->pixmap(QWizard::WatermarkPixmap).isNull());
-#ifdef Q_OS_OSX
- QVERIFY(!wizard.pixmap(QWizard::BackgroundPixmap).isNull());
-#else
- QVERIFY(page->pixmap(QWizard::BackgroundPixmap).isNull());
-#endif
+ if (QSysInfo::macVersion() <= Q_MV_OSX(10, 13))
+ QVERIFY(!wizard.pixmap(QWizard::BackgroundPixmap).isNull());
+ else
+ QVERIFY(page->pixmap(QWizard::BackgroundPixmap).isNull());
+
wizard.setPixmap(QWizard::BannerPixmap, p1);
wizard.setPixmap(QWizard::LogoPixmap, p2);
wizard.setPixmap(QWizard::WatermarkPixmap, p3);
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
index 28df3a3c38..1456b9e35c 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
@@ -88,7 +88,7 @@ static void sendMousePress(QWidget *widget, const QPoint &point, Qt::MouseButton
static void sendMouseMove(QWidget *widget, const QPoint &point, Qt::MouseButton button = Qt::NoButton, Qt::MouseButtons buttons = 0)
{
QTest::mouseMove(widget, point);
- QMouseEvent event(QEvent::MouseMove, point, button, buttons, 0);
+ QMouseEvent event(QEvent::MouseMove, point, widget->mapToGlobal(point), button, buttons, 0);
QApplication::sendEvent(widget, &event);
QApplication::processEvents();
}
diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
index 5b4a5d30a5..d13c145189 100644
--- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
@@ -486,7 +486,7 @@ void tst_QApplication::lastWindowClosed()
QPointer<QDialog> dialog = new QDialog;
dialog->setWindowTitle(QLatin1String(QTest::currentTestFunction()) + QLatin1String("Dialog"));
QVERIFY(dialog->testAttribute(Qt::WA_QuitOnClose));
- QTimer::singleShot(1000, dialog, &QDialog::accept);
+ QTimer::singleShot(1000, dialog.data(), &QDialog::accept);
dialog->exec();
QVERIFY(dialog);
QCOMPARE(spy.count(), 0);
diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
index 2c9295d995..53753e195a 100644
--- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
+++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
@@ -123,6 +123,7 @@ private slots:
void context();
void duplicatedShortcutOverride();
void shortcutToFocusProxy();
+ void deleteLater();
protected:
static Qt::KeyboardModifiers toButtons( int key );
@@ -1305,5 +1306,14 @@ void tst_QShortcut::shortcutToFocusProxy()
QCOMPARE(le.text(), QString());
}
+void tst_QShortcut::deleteLater()
+{
+ QWidget w;
+ QPointer<QShortcut> sc(new QShortcut(QKeySequence(Qt::Key_1), &w));
+ sc->deleteLater();
+ QTRY_VERIFY(!sc);
+}
+
+
QTEST_MAIN(tst_QShortcut)
#include "tst_qshortcut.moc"
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
index 95799905de..27cc385df4 100644
--- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
@@ -4842,6 +4842,7 @@ void tst_QLineEdit::inputRejected()
QCOMPARE(spyInputRejected.count(), 0);
QTest::keyClicks(testWidget, "fgh");
QCOMPARE(spyInputRejected.count(), 3);
+#if QT_CONFIG(clipboard)
testWidget->clear();
spyInputRejected.clear();
QApplication::clipboard()->setText("ijklmno");
@@ -4849,6 +4850,7 @@ void tst_QLineEdit::inputRejected()
// The first 5 characters are accepted, but
// the last 2 are not.
QCOMPARE(spyInputRejected.count(), 1);
+#endif
testWidget->setMaxLength(INT_MAX);
testWidget->clear();
@@ -4859,11 +4861,13 @@ void tst_QLineEdit::inputRejected()
QCOMPARE(spyInputRejected.count(), 0);
QTest::keyClicks(testWidget, "a#");
QCOMPARE(spyInputRejected.count(), 2);
+#if QT_CONFIG(clipboard)
testWidget->clear();
spyInputRejected.clear();
QApplication::clipboard()->setText("a#");
testWidget->paste();
QCOMPARE(spyInputRejected.count(), 1);
+#endif
testWidget->clear();
testWidget->setValidator(0);
diff --git a/tests/benchmarks/gui/painting/lancebench/tst_lancebench.cpp b/tests/benchmarks/gui/painting/lancebench/tst_lancebench.cpp
index bd0889bf4a..d26ac016b9 100644
--- a/tests/benchmarks/gui/painting/lancebench/tst_lancebench.cpp
+++ b/tests/benchmarks/gui/painting/lancebench/tst_lancebench.cpp
@@ -305,17 +305,17 @@ void tst_LanceBench::runTestSuite(GraphicsEngine engine, QImage::Format format,
void tst_LanceBench::paint(QPaintDevice *device, GraphicsEngine engine, QImage::Format format, const QStringList &script, const QString &filePath)
{
- PaintCommands pcmd(script, 800, 800, format);
- switch (engine) {
- case OpenGL:
- pcmd.setType(OpenGLBufferType); // version/profile is communicated through the context's format()
- break;
- case Raster:
- pcmd.setType(ImageType);
- break;
- }
- pcmd.setFilePath(filePath);
QBENCHMARK {
+ PaintCommands pcmd(script, 800, 800, format);
+ switch (engine) {
+ case OpenGL:
+ pcmd.setType(OpenGLBufferType); // version/profile is communicated through the context's format()
+ break;
+ case Raster:
+ pcmd.setType(ImageType);
+ break;
+ }
+ pcmd.setFilePath(filePath);
QPainter p(device);
pcmd.setPainter(&p);
pcmd.runCommands();