summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@qt.io>2020-06-11 14:51:58 +0200
committerMorten Johan Sørvig <morten.sorvig@qt.io>2020-10-20 07:27:04 +0200
commit3df2448f6322bd6ecc8c11aa05e935223ef96dd3 (patch)
treed7af3953931cf2e723ac4d68151f244d45fc798e
parentd023da86399b99d365f1e745fb0d9424afc8194b (diff)
Merge existing tst_qhighdpiscaling into tst_qhgihdpi
Move the factor() test, drop scale() which should be covered already. Change-Id: Id2079536a91c7e9f7199960bdf6b33489d0a6670 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--tests/auto/gui/kernel/CMakeLists.txt1
-rw-r--r--tests/auto/gui/kernel/kernel.pro1
-rw-r--r--tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp23
-rw-r--r--tests/auto/gui/kernel/qhighdpiscaling/qhighdpiscaling.pro6
-rw-r--r--tests/auto/gui/kernel/qhighdpiscaling/tst_qhighdpiscaling.cpp97
5 files changed, 23 insertions, 105 deletions
diff --git a/tests/auto/gui/kernel/CMakeLists.txt b/tests/auto/gui/kernel/CMakeLists.txt
index 2753007a95..a22c0262c5 100644
--- a/tests/auto/gui/kernel/CMakeLists.txt
+++ b/tests/auto/gui/kernel/CMakeLists.txt
@@ -37,7 +37,6 @@ if(QT_FEATURE_shortcut)
endif()
if(QT_FEATURE_highdpiscaling)
add_subdirectory(qhighdpi)
- add_subdirectory(qhighdpiscaling)
endif()
if(TARGET Qt::Widgets)
add_subdirectory(qmouseevent_modal)
diff --git a/tests/auto/gui/kernel/kernel.pro b/tests/auto/gui/kernel/kernel.pro
index 346c7fb3c4..82b7baba54 100644
--- a/tests/auto/gui/kernel/kernel.pro
+++ b/tests/auto/gui/kernel/kernel.pro
@@ -14,7 +14,6 @@ SUBDIRS=\
qguitimer \
qguivariant \
qhighdpi\
- qhighdpiscaling \
qinputdevice \
qinputmethod \
qkeyevent \
diff --git a/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp b/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp
index a7b18167ba..d771da7320 100644
--- a/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp
+++ b/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp
@@ -163,6 +163,29 @@ void tst_QHighDpi::initTestCase()
#endif
}
+void tst_QHighDpi::qhighdpiscaling_data()
+{
+ standardScreenDpiTestData();
+}
+
+// Tests the QHighDpiScaling API directly
+void tst_QHighDpi::qhighdpiscaling()
+{
+ QFETCH(QList<qreal>, dpiValues);
+ std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(dpiValues));
+
+ QHighDpiScaling::setGlobalFactor(2);
+
+ // Verfy that QHighDpiScaling::factor() does not crash on nullptr contexts.
+ QScreen *screenContext = nullptr;
+ QVERIFY(QHighDpiScaling::factor(screenContext) >= 0);
+ QPlatformScreen *platformScreenContext = nullptr;
+ QVERIFY(QHighDpiScaling::factor(platformScreenContext) >= 0);
+ QWindow *windowContext = nullptr;
+ QVERIFY(QHighDpiScaling::factor(windowContext) >= 0);
+ QHighDpiScaling::setGlobalFactor(1);
+}
+
void tst_QHighDpi::screenDpiAndDpr_data()
{
standardScreenDpiTestData();
diff --git a/tests/auto/gui/kernel/qhighdpiscaling/qhighdpiscaling.pro b/tests/auto/gui/kernel/qhighdpiscaling/qhighdpiscaling.pro
deleted file mode 100644
index 6cd7bb01f5..0000000000
--- a/tests/auto/gui/kernel/qhighdpiscaling/qhighdpiscaling.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-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
deleted file mode 100644
index 3fbaa0715a..0000000000
--- a/tests/auto/gui/kernel/qhighdpiscaling/tst_qhighdpiscaling.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
-**
-** 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(); }
-
- QDpi logicalDpi() const override { return logicalBaseDpi(); }
-
- 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);