summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-04-02 01:00:25 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-04-02 01:00:26 +0200
commitffe9c395dc5a8a3f1dfdd820557d0eadeca24f22 (patch)
treefc823fb5afd857be67fa86af8d019f8d9fa024e6 /tests
parent69beb5f5a04bbb5b7fd64e69d1a655c0f5d956cb (diff)
parent011794130c8e4bb64dbc3c8c9b50849b278cdda3 (diff)
Merge remote-tracking branch 'origin/5.12' into 5.13
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/tools/qlocale/tst_qlocale.cpp43
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp35
-rw-r--r--tests/auto/gui/image/qpixmap/tst_qpixmap.cpp34
-rw-r--r--tests/auto/gui/painting/qbrush/tst_qbrush.cpp2
-rw-r--r--tests/auto/tools/qmake/tst_qmake.cpp5
5 files changed, 100 insertions, 19 deletions
diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
index 9bb0c6811d..0b41af3371 100644
--- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
@@ -952,29 +952,42 @@ void tst_QLocale::stringToDouble()
void tst_QLocale::stringToFloat_data()
{
+ using Bounds = std::numeric_limits<float>;
toReal_data();
- if (std::numeric_limits<float>::has_infinity) {
- double huge = std::numeric_limits<float>::infinity();
- QTest::newRow("C inf") << QString("C") << QString("inf") << true << huge;
- QTest::newRow("C +inf") << QString("C") << QString("+inf") << true << +huge;
- QTest::newRow("C -inf") << QString("C") << QString("-inf") << true << -huge;
+ const QString C(QStringLiteral("C"));
+ if (Bounds::has_infinity) {
+ double huge = Bounds::infinity();
+ QTest::newRow("C inf") << C << QString("inf") << true << huge;
+ QTest::newRow("C +inf") << C << QString("+inf") << true << +huge;
+ QTest::newRow("C -inf") << C << QString("-inf") << true << -huge;
// Overflow float, but not double:
- QTest::newRow("C big") << QString("C") << QString("3.5e38") << false << huge;
- QTest::newRow("C -big") << QString("C") << QString("-3.5e38") << false << -huge;
+ QTest::newRow("C big") << C << QString("3.5e38") << false << huge;
+ QTest::newRow("C -big") << C << QString("-3.5e38") << false << -huge;
// Overflow double, too:
- QTest::newRow("C huge") << QString("C") << QString("2e308") << false << huge;
- QTest::newRow("C -huge") << QString("C") << QString("-2e308") << false << -huge;
+ QTest::newRow("C huge") << C << QString("2e308") << false << huge;
+ QTest::newRow("C -huge") << C << QString("-2e308") << false << -huge;
}
- if (std::numeric_limits<float>::has_quiet_NaN)
- QTest::newRow("C qnan") << QString("C") << QString("NaN") << true << double(std::numeric_limits<float>::quiet_NaN());
+ if (Bounds::has_quiet_NaN)
+ QTest::newRow("C qnan") << C << QString("NaN") << true << double(Bounds::quiet_NaN());
+
+ // Minimal float: shouldn't underflow
+ QTest::newRow("C float min")
+ << C << QLocale::c().toString(Bounds::denorm_min()) << true << double(Bounds::denorm_min());
+ QTest::newRow("C float -min")
+ << C << QLocale::c().toString(-Bounds::denorm_min()) << true << -double(Bounds::denorm_min());
// Underflow float, but not double:
- QTest::newRow("C small") << QString("C") << QString("1e-45") << false << 0.;
- QTest::newRow("C -small") << QString("C") << QString("-1e-45") << false << 0.;
+ QTest::newRow("C small") << C << QString("7e-46") << false << 0.;
+ QTest::newRow("C -small") << C << QString("-7e-46") << false << 0.;
+ using Double = std::numeric_limits<double>;
+ QTest::newRow("C double min")
+ << C << QLocale::c().toString(Double::denorm_min()) << false << 0.0;
+ QTest::newRow("C double -min")
+ << C << QLocale::c().toString(-Double::denorm_min()) << false << 0.0;
// Underflow double, too:
- QTest::newRow("C tiny") << QString("C") << QString("2e-324") << false << 0.;
- QTest::newRow("C -tiny") << QString("C") << QString("-2e-324") << false << 0.;
+ QTest::newRow("C tiny") << C << QString("2e-324") << false << 0.;
+ QTest::newRow("C -tiny") << C << QString("-2e-324") << false << 0.;
}
void tst_QLocale::stringToFloat()
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index 302180586e..4d41b5e873 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -3284,11 +3284,46 @@ void tst_QImage::metadataPassthrough()
QCOMPARE(mirrored.dotsPerMeterY(), a.dotsPerMeterY());
QCOMPARE(mirrored.devicePixelRatio(), a.devicePixelRatio());
+ QTransform t;
+ t.rotate(90);
+ QImage rotated = a.transformed(t);
+ QCOMPARE(rotated.text(QStringLiteral("Test")), a.text(QStringLiteral("Test")));
+ QCOMPARE(rotated.dotsPerMeterX(), a.dotsPerMeterX());
+ QCOMPARE(rotated.dotsPerMeterY(), a.dotsPerMeterY());
+ QCOMPARE(rotated.devicePixelRatio(), a.devicePixelRatio());
+
QImage swapped = a.rgbSwapped();
QCOMPARE(swapped.text(QStringLiteral("Test")), a.text(QStringLiteral("Test")));
QCOMPARE(swapped.dotsPerMeterX(), a.dotsPerMeterX());
QCOMPARE(swapped.dotsPerMeterY(), a.dotsPerMeterY());
QCOMPARE(swapped.devicePixelRatio(), a.devicePixelRatio());
+
+ QImage converted = a.convertToFormat(QImage::Format_RGB32);
+ QCOMPARE(converted.text(QStringLiteral("Test")), a.text(QStringLiteral("Test")));
+ QCOMPARE(converted.dotsPerMeterX(), a.dotsPerMeterX());
+ QCOMPARE(converted.dotsPerMeterY(), a.dotsPerMeterY());
+ QCOMPARE(converted.devicePixelRatio(), a.devicePixelRatio());
+
+ QImage copied = a.copy(0, 0, a.width() / 2, a.height() / 2);
+ QCOMPARE(copied.text(QStringLiteral("Test")), a.text(QStringLiteral("Test")));
+ QCOMPARE(copied.dotsPerMeterX(), a.dotsPerMeterX());
+ QCOMPARE(copied.dotsPerMeterY(), a.dotsPerMeterY());
+ QCOMPARE(copied.devicePixelRatio(), a.devicePixelRatio());
+
+ QImage alphaMask = a.createAlphaMask();
+ QCOMPARE(alphaMask.dotsPerMeterX(), a.dotsPerMeterX());
+ QCOMPARE(alphaMask.dotsPerMeterY(), a.dotsPerMeterY());
+ QCOMPARE(alphaMask.devicePixelRatio(), a.devicePixelRatio());
+
+ QImage heuristicMask = a.createHeuristicMask();
+ QCOMPARE(heuristicMask.dotsPerMeterX(), a.dotsPerMeterX());
+ QCOMPARE(heuristicMask.dotsPerMeterY(), a.dotsPerMeterY());
+ QCOMPARE(heuristicMask.devicePixelRatio(), a.devicePixelRatio());
+
+ QImage maskFromColor = a.createMaskFromColor(qRgb(0, 0, 0));
+ QCOMPARE(maskFromColor.dotsPerMeterX(), a.dotsPerMeterX());
+ QCOMPARE(maskFromColor.dotsPerMeterY(), a.dotsPerMeterY());
+ QCOMPARE(maskFromColor.devicePixelRatio(), a.devicePixelRatio());
}
void tst_QImage::pixelColor()
diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
index 9a338ad55a..4d31d80246 100644
--- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
@@ -121,6 +121,7 @@ private slots:
void copy();
void deepCopyPreservesDpr();
+ void dprPassthrough();
void depthOfNullObjects();
void transformed();
@@ -1169,6 +1170,39 @@ void tst_QPixmap::deepCopyPreservesDpr()
QCOMPARE(dest.devicePixelRatio(), dpr);
}
+void tst_QPixmap::dprPassthrough()
+{
+ const qreal dpr = 2;
+ QPixmap src(32, 32);
+ src.setDevicePixelRatio(dpr);
+ src.fill(Qt::transparent);
+ QCOMPARE(src.devicePixelRatio(), dpr);
+
+ QImage img = src.toImage();
+ QCOMPARE(img.devicePixelRatio(), dpr);
+
+ QPixmap pm(1, 1);
+ pm.convertFromImage(img);
+ QCOMPARE(pm.devicePixelRatio(), dpr);
+
+ QBitmap heuristicMask = src.createHeuristicMask();
+ QCOMPARE(heuristicMask.devicePixelRatio(), dpr);
+
+ QBitmap maskFromColor = src.createMaskFromColor(Qt::white);
+ QCOMPARE(maskFromColor.devicePixelRatio(), dpr);
+
+ QBitmap mask = src.mask();
+ QCOMPARE(mask.devicePixelRatio(), dpr);
+
+ QPixmap scaled = src.scaled(16, 16);
+ QCOMPARE(scaled.devicePixelRatio(), dpr);
+
+ QTransform t;
+ t.rotate(90);
+ QPixmap transformed = src.transformed(t);
+ QCOMPARE(transformed.devicePixelRatio(), dpr);
+}
+
void tst_QPixmap::depthOfNullObjects()
{
QBitmap b1;
diff --git a/tests/auto/gui/painting/qbrush/tst_qbrush.cpp b/tests/auto/gui/painting/qbrush/tst_qbrush.cpp
index cd3eaa1478..ce6ce15767 100644
--- a/tests/auto/gui/painting/qbrush/tst_qbrush.cpp
+++ b/tests/auto/gui/painting/qbrush/tst_qbrush.cpp
@@ -345,6 +345,8 @@ void tst_QBrush::gradientPresets()
QGradient invalidPreset(QGradient::Preset(-1));
QCOMPARE(invalidPreset.type(), QGradient::NoGradient);
+ QBrush brush(invalidPreset);
+ QCOMPARE(brush.style(), Qt::NoBrush);
}
void fill(QPaintDevice *pd) {
diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp
index 1eaf66311c..cacee30c86 100644
--- a/tests/auto/tools/qmake/tst_qmake.cpp
+++ b/tests/auto/tools/qmake/tst_qmake.cpp
@@ -244,7 +244,6 @@ void tst_qmake::simple_app_versioned()
QVERIFY2(QFile::exists(pdbFilePath), qPrintable(pdbFilePath));
QVERIFY(test_compiler.make(buildDir, "install"));
QString installedPdbFilePath = installDir + '/' + targetBase + ".pdb";
- QEXPECT_FAIL("", "QTBUG-74265", Continue);
QVERIFY2(QFile::exists(installedPdbFilePath), qPrintable(installedPdbFilePath));
}
@@ -252,10 +251,8 @@ void tst_qmake::simple_app_versioned()
QVERIFY(test_compiler.exists(destDir, "simple app", Exe, version));
QVERIFY(test_compiler.makeDistClean(buildDir));
QVERIFY(!test_compiler.exists(destDir, "simple app", Exe, version));
- if (checkPdb) {
- QEXPECT_FAIL("", "QTBUG-74265", Continue);
+ if (checkPdb)
QVERIFY(!QFile::exists(pdbFilePath));
- }
QVERIFY(test_compiler.removeMakefile(buildDir));
}