From 174061f9f32ac76c6b8a6d155d772e37708d8cfc Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 31 Jul 2019 10:23:39 +0200 Subject: QHighDPI: Fix broken scaling of QPoint(F) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For some reason, the overload resolution of the High DPI scale() functions introduced by b6ded193ee64ffe67df6d22e7a23aa1ea9e02ec7 chose the wrong overloads for QPointF and/or QPoint; it fell back to the generic template intended for qreal, QSize, etc, ignoring the origin. Remove the template and spell out all overloads. Fixes: QTBUG-77255 Change-Id: I5661f16f7326f65156f646f430f5a0c71d5302d2 Reviewed-by: Tor Arne Vestbø --- tests/auto/gui/kernel/kernel.pro | 3 + .../gui/kernel/qhighdpiscaling/qhighdpiscaling.pro | 6 ++ .../kernel/qhighdpiscaling/tst_qhighdpiscaling.cpp | 77 ++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 tests/auto/gui/kernel/qhighdpiscaling/qhighdpiscaling.pro create mode 100644 tests/auto/gui/kernel/qhighdpiscaling/tst_qhighdpiscaling.cpp (limited to 'tests/auto') 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..969b2351ec --- /dev/null +++ b/tests/auto/gui/kernel/qhighdpiscaling/tst_qhighdpiscaling.cpp @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** 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 +#include + +#include + +class tst_QHighDpiScaling: public QObject +{ + Q_OBJECT + +private slots: + 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; } +}; + +// QTBUG-77255: Test some scaling overloads +void tst_QHighDpiScaling::scale() +{ + QHighDpiScaling::setGlobalFactor(2); + QScopedPointer 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); -- cgit v1.2.3 From bd8ef7fe24f80b193a3c47cc77795d766d35d25e Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Thu, 1 Aug 2019 13:58:48 +0200 Subject: Blacklist tst_http2::connectToHost MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test if flakey. Change-Id: I1f956f47ab4cf0602f3631e4f7908df35f5ce83f Reviewed-by: Tor Arne Vestbø --- tests/auto/network/access/http2/BLACKLIST | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/auto/network/access/http2/BLACKLIST (limited to 'tests/auto') diff --git a/tests/auto/network/access/http2/BLACKLIST b/tests/auto/network/access/http2/BLACKLIST new file mode 100644 index 0000000000..8f26c5b89e --- /dev/null +++ b/tests/auto/network/access/http2/BLACKLIST @@ -0,0 +1,3 @@ + See qtbase/src/testlib/qtestblacklist.cpp for format +[connectToHost] +* -- cgit v1.2.3 From ec62033bc25ed60a6bb9286d07e4f4485800b068 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Thu, 1 Aug 2019 15:01:27 +0200 Subject: tst_http2::connectToHost - add a fix for SecureTransport backend One of the tests above was unsetting a variable that enforces the use of a temporary keychain. We have to set it back, otherwise the test is failing. What surprises me though - why I had this problem only locally and not on CI? Apparently, SecureTransport is not covered by our configurations ... Change-Id: I0ff1e3e304632869391ed61213c245b949d8c778 Reviewed-by: Volker Hilsheimer --- tests/auto/network/access/http2/tst_http2.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/network/access/http2/tst_http2.cpp b/tests/auto/network/access/http2/tst_http2.cpp index ce685a1b1c..10dad25337 100644 --- a/tests/auto/network/access/http2/tst_http2.cpp +++ b/tests/auto/network/access/http2/tst_http2.cpp @@ -591,6 +591,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()); -- cgit v1.2.3