qt 6.6.0 clean

This commit is contained in:
kleuter
2023-11-01 22:23:55 +01:00
parent 7b5ada15e7
commit 5d8194efa7
1449 changed files with 134276 additions and 31391 deletions

View File

@ -10,6 +10,7 @@
#include <QJsonObject>
#include <QJsonDocument>
#include <QStringView>
#include <QSignalSpy>
Q_LOGGING_CATEGORY(lcTests, "qt.gui.tests")
@ -35,6 +36,7 @@ private slots:
void screenDpiAndDpr_data();
void screenDpiAndDpr();
void screenDpiChange();
void screenDpiChangeWithWindow();
void environment_QT_SCALE_FACTOR();
void environment_QT_SCREEN_SCALE_FACTORS_data();
void environment_QT_SCREEN_SCALE_FACTORS();
@ -55,6 +57,8 @@ private slots:
void mouseVelocity_data();
void setCursor();
void setCursor_data();
void setGlobalFactorEmits();
void setScreenFactorEmits();
};
/// Offscreen platform plugin test setup
@ -235,6 +239,9 @@ void tst_QHighDpi::screenDpiAndDpr()
QWindow window(screen);
QCOMPARE(window.devicePixelRatio(), screen->devicePixelRatio());
window.setGeometry(QRect(screen->geometry().center(), QSize(10, 10)));
window.create();
QCOMPARE(window.devicePixelRatio(), screen->devicePixelRatio());
}
}
@ -261,12 +268,48 @@ void tst_QHighDpi::screenDpiChange()
for (QScreen *screen : app->screens()) {
QCOMPARE(screen->devicePixelRatio(), newDpi / standardBaseDpi);
QCOMPARE(screen->logicalDotsPerInch(), newDpi / screen->devicePixelRatio());
QWindow window(screen);
QCOMPARE(window.devicePixelRatio(), screen->devicePixelRatio());
window.create();
QCOMPARE(window.devicePixelRatio(), screen->devicePixelRatio());
}
QCOMPARE(app->devicePixelRatio(), newDpi / standardBaseDpi);
}
void tst_QHighDpi::screenDpiChangeWithWindow()
{
QList<qreal> dpiValues = { 96, 192, 288 };
std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(dpiValues));
// Create windows for screens
QList<QScreen *> screens = app->screens();
QList<QWindow *> windows;
for (int i = 0; i < screens.count(); ++i) {
QScreen *screen = screens[i];
QWindow *window = new QWindow();
windows.append(window);
window->setGeometry(QRect(screen->geometry().center(), QSize(10, 10)));
window->create();
QCOMPARE(window->devicePixelRatio(), dpiValues[i] / standardBaseDpi);
}
// Change screen DPI
QList<qreal> newDpiValues = { 288, 192, 96 };
QJsonValue config = offscreenConfiguration();
QCborMap map = QCborMap::fromJsonObject(config.toObject());
for (int i = 0; i < screens.count(); ++i) {
map[QLatin1String("screens")][i][QLatin1String("logicalDpi")] = newDpiValues[i];
}
setOffscreenConfiguration(map.toJsonObject());
// Verify that window DPR changes on Screen DPI change.
for (int i = 0; i < screens.count(); ++i) {
QWindow *window = windows[i];
QCOMPARE(window->devicePixelRatio(), newDpiValues[i] / standardBaseDpi);
}
}
void tst_QHighDpi::environment_QT_SCALE_FACTOR()
{
qreal factor = 3.1415;
@ -313,9 +356,10 @@ void tst_QHighDpi::environment_QT_SCREEN_SCALE_FACTORS()
QFETCH(QByteArray, environment);
QFETCH(QList<qreal>, expectedDprValues);
qputenv("QT_SCREEN_SCALE_FACTORS", environment);
// Verify that setting QT_SCREEN_SCALE_FACTORS overrides the from-platform-screen-DPI DPR.
{
qputenv("QT_SCREEN_SCALE_FACTORS", environment);
std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(platformScreenDpi));
int i = 0;
for (QScreen *screen : app->screens()) {
@ -327,6 +371,18 @@ void tst_QHighDpi::environment_QT_SCREEN_SCALE_FACTORS()
QCOMPARE(window.devicePixelRatio(), expextedDpr);
}
}
// Verify that setHighDpiScaleFactorRoundingPolicy applies to QT_SCREEN_SCALE_FACTORS as well
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Round);
{
std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(platformScreenDpi));
int i = 0;
for (QScreen *screen : app->screens()) {
qreal expectedRounderDpr = qRound(expectedDprValues[i++]);
qreal windowDpr = QWindow(screen).devicePixelRatio();
QCOMPARE(windowDpr, expectedRounderDpr);
}
}
}
void tst_QHighDpi::environment_QT_USE_PHYSICAL_DPI()
@ -798,5 +854,34 @@ void tst_QHighDpi::setCursor()
}
}
void tst_QHighDpi::setGlobalFactorEmits()
{
QList<qreal> dpiValues { 96, 96, 96 };
std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(dpiValues));
std::vector<std::unique_ptr<QSignalSpy>> spies;
for (QScreen *screen : app->screens())
spies.push_back(std::make_unique<QSignalSpy>(screen, &QScreen::geometryChanged));
QHighDpiScaling::setGlobalFactor(2);
for (const auto &spy : spies)
QCOMPARE(spy->count(), 1);
QHighDpiScaling::setGlobalFactor(1);
}
void tst_QHighDpi::setScreenFactorEmits()
{
QList<qreal> dpiValues { 96, 96, 96 };
std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(dpiValues));
for (QScreen *screen : app->screens()) {
QSignalSpy spy(screen, &QScreen::geometryChanged);
QHighDpiScaling::setScreenFactor(screen, 2);
QCOMPARE(spy.count(), 1);
}
}
#include "tst_qhighdpi.moc"
QTEST_APPLESS_MAIN(tst_QHighDpi);