summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2019-08-13 09:46:17 +0200
committerLiang Qi <liang.qi@qt.io>2019-08-13 10:20:13 +0200
commit275ad4ce4cc568c5bb07c00dcffb28a096d45c2b (patch)
tree883f978cb9479614a016be485862c9f62e9f2f0a /tests
parent42d32e468aa89631161884f07b3e25814c47b879 (diff)
parent1dade1bd8ad13a16152aff36351ac570b5b9fdf6 (diff)
Merge "Merge remote-tracking branch 'origin/5.13' into dev"
Diffstat (limited to 'tests')
-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/painting/qpainterpath/BLACKLIST2
-rw-r--r--tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp12
-rw-r--r--tests/auto/network/access/http2/tst_http2.cpp16
-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
10 files changed, 199 insertions, 15 deletions
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/painting/qpainterpath/BLACKLIST b/tests/auto/gui/painting/qpainterpath/BLACKLIST
new file mode 100644
index 0000000000..b3e6d3bfe4
--- /dev/null
+++ b/tests/auto/gui/painting/qpainterpath/BLACKLIST
@@ -0,0 +1,2 @@
+[contains_QPointF]
+msvc-2019
diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
index 591fafc7fb..58810f73c1 100644
--- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
+++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
@@ -191,6 +191,7 @@ private slots:
void fontTagFace();
+ void clearUndoRedoStacks();
private:
void backgroundImage_checkExpectedHtml(const QTextDocument &doc);
void buildRegExpData();
@@ -3522,5 +3523,16 @@ void tst_QTextDocument::fontTagFace()
}
}
+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/network/access/http2/tst_http2.cpp b/tests/auto/network/access/http2/tst_http2.cpp
index bf3d936446..945ea1b448 100644
--- a/tests/auto/network/access/http2/tst_http2.cpp
+++ b/tests/auto/network/access/http2/tst_http2.cpp
@@ -592,6 +592,19 @@ void tst_Http2::connectToHost()
#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());
@@ -636,9 +649,6 @@ void tst_Http2::connectToHost()
eventLoop.exitLoop();
QCOMPARE(reply->error(), QNetworkReply::NoError);
QVERIFY(reply->isFinished());
- // Nothing must be sent yet:
- QVERIFY(!prefaceOK);
- QVERIFY(!serverGotSettingsACK);
// Nothing received back:
QVERIFY(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).isNull());
QCOMPARE(reply->readAll().size(), 0);
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 4709499cd6..5ac3834aef 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 4f94e83c1c..367a5767c4 100644
--- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
@@ -491,7 +491,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);