summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-09-06 09:44:09 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-09-06 09:44:10 +0200
commitcaf123a28805f6de1de3144ea496712543b878cd (patch)
tree9eae94d6bee228c62c942c37296f96a91349c4c9 /tests
parentbf8fcab8bb92ff534c5cec048d6dbebb3b73a348 (diff)
parentd2894d968d50619c894e06b1e9f8b0f52e434222 (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp18
-rw-r--r--tests/auto/corelib/time/qcalendar/tst_qcalendar.cpp4
-rw-r--r--tests/auto/gui/image/qimagereader/tst_qimagereader.cpp7
-rw-r--r--tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp54
-rw-r--r--tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp70
-rw-r--r--tests/auto/tools/qmake/tst_qmake.cpp3
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp2
-rw-r--r--tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp2
-rw-r--r--tests/auto/widgets/styles/qstyle/tst_qstyle.cpp262
-rw-r--r--tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp407
-rw-r--r--tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp15
-rw-r--r--tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp4
12 files changed, 456 insertions, 392 deletions
diff --git a/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp b/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp
index 354190e754..d61d45bc52 100644
--- a/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp
+++ b/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp
@@ -90,7 +90,9 @@ ModelsToTest::ModelsToTest()
{
setupDatabase();
+#if QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15)
tests.append(test("QDirModel", ReadOnly, HasData));
+#endif
tests.append(test("QStringListModel", ReadWrite, HasData));
tests.append(test("QStringListModelEmpty", ReadWrite, Empty));
@@ -165,11 +167,16 @@ QAbstractItemModel *ModelsToTest::createModel(const QString &modelType)
return model;
}
+#if QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
if (modelType == "QDirModel") {
QDirModel *model = new QDirModel();
model->setReadOnly(false);
return model;
}
+QT_WARNING_POP
+#endif
if (modelType == "QSqlQueryModel") {
QSqlQueryModel *model = new QSqlQueryModel();
@@ -287,6 +294,7 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model)
return returnIndex;
}
+#if QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15)
if (QDirModel *dirModel = qobject_cast<QDirModel *>(model)) {
m_dirModelTempDir.reset(new QTemporaryDir);
if (!m_dirModelTempDir->isValid())
@@ -303,6 +311,7 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model)
}
return dirModel->index(tempDir.path());
}
+#endif // QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15)
if (QSqlQueryModel *queryModel = qobject_cast<QSqlQueryModel *>(model)) {
QSqlQuery q;
@@ -359,11 +368,12 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model)
*/
void ModelsToTest::cleanupTestArea(QAbstractItemModel *model)
{
- if (qobject_cast<QDirModel *>(model)) {
- m_dirModelTempDir.reset();
- } else if (qobject_cast<QSqlQueryModel *>(model)) {
+ if (qobject_cast<QSqlQueryModel *>(model))
QSqlQuery q("DROP TABLE test");
- }
+#if QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15)
+ if (qobject_cast<QDirModel *>(model))
+ m_dirModelTempDir.reset();
+#endif
}
void ModelsToTest::setupDatabase()
diff --git a/tests/auto/corelib/time/qcalendar/tst_qcalendar.cpp b/tests/auto/corelib/time/qcalendar/tst_qcalendar.cpp
index 5cfdb6daf4..9b41014394 100644
--- a/tests/auto/corelib/time/qcalendar/tst_qcalendar.cpp
+++ b/tests/auto/corelib/time/qcalendar/tst_qcalendar.cpp
@@ -55,13 +55,13 @@ void tst_QCalendar::checkYear(const QCalendar &cal, int year, bool normal)
QVERIFY(moons > 0);
QVERIFY(!cal.isDateValid(year, moons + 1, 1));
QVERIFY(!cal.isDateValid(year, 0, 1));
- QVERIFY(moons <= cal.maxMonthsInYear());
+ QVERIFY(moons <= cal.maximumMonthsInYear());
const int days = cal.daysInYear(year);
QVERIFY(days > 0);
int sum = 0;
- const int longest = cal.maxDaysInMonth();
+ const int longest = cal.maximumDaysInMonth();
for (int i = moons; i > 0; i--) {
const int last = cal.daysInMonth(i, year);
sum += last;
diff --git a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
index f6ffd7b7c5..22d96e76f9 100644
--- a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
+++ b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
@@ -1890,9 +1890,8 @@ void tst_QImageReader::saveFormat()
void tst_QImageReader::saveColorSpace_data()
{
- QTest::addColumn<QColorSpace::ColorSpaceId>("colorspaceId");
+ QTest::addColumn<QColorSpace::NamedColorSpace>("namedColorSpace");
- QTest::newRow("Undefined") << QColorSpace::Undefined;
QTest::newRow("sRGB") << QColorSpace::SRgb;
QTest::newRow("sRGB(linear)") << QColorSpace::SRgbLinear;
QTest::newRow("AdobeRGB") << QColorSpace::AdobeRgb;
@@ -1902,11 +1901,11 @@ void tst_QImageReader::saveColorSpace_data()
void tst_QImageReader::saveColorSpace()
{
- QFETCH(QColorSpace::ColorSpaceId, colorspaceId);
+ QFETCH(QColorSpace::NamedColorSpace, namedColorSpace);
QImage orig(":/images/kollada.png");
- orig.setColorSpace(colorspaceId);
+ orig.setColorSpace(namedColorSpace);
QBuffer buf;
buf.open(QIODevice::WriteOnly);
QVERIFY(orig.save(&buf, "png"));
diff --git a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp
index 9e13dc80b4..d51cfdee2f 100644
--- a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp
+++ b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp
@@ -35,7 +35,7 @@
#include <private/qcolorspace_p.h>
-Q_DECLARE_METATYPE(QColorSpace::ColorSpaceId)
+Q_DECLARE_METATYPE(QColorSpace::NamedColorSpace)
Q_DECLARE_METATYPE(QColorSpace::Primaries)
Q_DECLARE_METATYPE(QColorSpace::TransferFunction)
@@ -64,8 +64,12 @@ private slots:
void primaries();
void primariesXyz();
+
+#ifdef QT_BUILD_INTERNAL
void primaries2_data();
void primaries2();
+#endif
+
void invalidPrimaries();
void changeTransferFunction();
@@ -82,25 +86,25 @@ void tst_QColorSpace::movable()
QColorSpace cs2 = QColorSpace::SRgbLinear;
QVERIFY(cs1.isValid());
QVERIFY(cs2.isValid());
- QCOMPARE(cs1.colorSpaceId(), QColorSpace::SRgb);
+ QCOMPARE(cs1, QColorSpace::SRgb);
cs2 = std::move(cs1);
QVERIFY(!cs1.isValid());
QVERIFY(cs2.isValid());
- QCOMPARE(cs2.colorSpaceId(), QColorSpace::SRgb);
- QCOMPARE(cs1.colorSpaceId(), QColorSpace::Undefined);
+ QCOMPARE(cs2, QColorSpace::SRgb);
+ QVERIFY(cs1 != QColorSpace::SRgb);
QCOMPARE(cs1, QColorSpace());
QColorSpace cs3(std::move(cs2));
QVERIFY(!cs2.isValid());
QVERIFY(cs3.isValid());
- QCOMPARE(cs3.colorSpaceId(), QColorSpace::SRgb);
- QCOMPARE(cs2.colorSpaceId(), QColorSpace::Undefined);
+ QCOMPARE(cs3, QColorSpace::SRgb);
+ QCOMPARE(cs2, QColorSpace());
}
void tst_QColorSpace::namedColorSpaces_data()
{
- QTest::addColumn<QColorSpace::ColorSpaceId>("colorSpaceId");
+ QTest::addColumn<QColorSpace::NamedColorSpace>("namedColorSpace");
QTest::addColumn<QColorSpace::Primaries>("primariesId");
QTest::addColumn<QColorSpace::TransferFunction>("transferFunctionId");
@@ -126,15 +130,15 @@ void tst_QColorSpace::namedColorSpaces_data()
void tst_QColorSpace::namedColorSpaces()
{
- QFETCH(QColorSpace::ColorSpaceId, colorSpaceId);
+ QFETCH(QColorSpace::NamedColorSpace, namedColorSpace);
QFETCH(QColorSpace::Primaries, primariesId);
QFETCH(QColorSpace::TransferFunction, transferFunctionId);
- QColorSpace colorSpace = colorSpaceId;
+ QColorSpace colorSpace = namedColorSpace;
QVERIFY(colorSpace.isValid());
- QCOMPARE(colorSpace.colorSpaceId(), colorSpaceId);
+ QCOMPARE(colorSpace, namedColorSpace);
QCOMPARE(colorSpace.primaries(), primariesId);
QCOMPARE(colorSpace.transferFunction(), transferFunctionId);
}
@@ -147,14 +151,14 @@ void tst_QColorSpace::toIccProfile_data()
void tst_QColorSpace::toIccProfile()
{
- QFETCH(QColorSpace::ColorSpaceId, colorSpaceId);
+ QFETCH(QColorSpace::NamedColorSpace, namedColorSpace);
QFETCH(QColorSpace::Primaries, primariesId);
QFETCH(QColorSpace::TransferFunction, transferFunctionId);
Q_UNUSED(primariesId);
Q_UNUSED(transferFunctionId);
- QColorSpace colorSpace = colorSpaceId;
+ QColorSpace colorSpace = namedColorSpace;
QByteArray iccProfile = colorSpace.iccProfile();
QVERIFY(!iccProfile.isEmpty());
@@ -172,7 +176,7 @@ void tst_QColorSpace::toIccProfile()
void tst_QColorSpace::fromIccProfile_data()
{
QTest::addColumn<QString>("testProfile");
- QTest::addColumn<QColorSpace::ColorSpaceId>("colorSpaceId");
+ QTest::addColumn<QColorSpace::NamedColorSpace>("namedColorSpace");
QTest::addColumn<QColorSpace::TransferFunction>("transferFunction");
QTest::addColumn<QString>("description");
@@ -181,14 +185,14 @@ void tst_QColorSpace::fromIccProfile_data()
QTest::newRow("sRGB2014 (ICCv2)") << prefix + "sRGB2014.icc" << QColorSpace::SRgb
<< QColorSpace::TransferFunction::SRgb << QString("sRGB2014");
// My monitor's profile:
- QTest::newRow("HP ZR30w (ICCv4)") << prefix + "HP_ZR30w.icc" << QColorSpace::Unknown
+ QTest::newRow("HP ZR30w (ICCv4)") << prefix + "HP_ZR30w.icc" << QColorSpace::NamedColorSpace(0)
<< QColorSpace::TransferFunction::Gamma << QString("HP Z30i");
}
void tst_QColorSpace::fromIccProfile()
{
QFETCH(QString, testProfile);
- QFETCH(QColorSpace::ColorSpaceId, colorSpaceId);
+ QFETCH(QColorSpace::NamedColorSpace, namedColorSpace);
QFETCH(QColorSpace::TransferFunction, transferFunction);
QFETCH(QString, description);
@@ -198,15 +202,17 @@ void tst_QColorSpace::fromIccProfile()
QColorSpace fileColorSpace = QColorSpace::fromIccProfile(iccProfile);
QVERIFY(fileColorSpace.isValid());
- QCOMPARE(fileColorSpace.colorSpaceId(), colorSpaceId);
+ if (namedColorSpace)
+ QCOMPARE(fileColorSpace, namedColorSpace);
+
QCOMPARE(fileColorSpace.transferFunction(), transferFunction);
QCOMPARE(QColorSpacePrivate::get(fileColorSpace)->description, description);
}
void tst_QColorSpace::imageConversion_data()
{
- QTest::addColumn<QColorSpace::ColorSpaceId>("fromColorSpace");
- QTest::addColumn<QColorSpace::ColorSpaceId>("toColorSpace");
+ QTest::addColumn<QColorSpace::NamedColorSpace>("fromColorSpace");
+ QTest::addColumn<QColorSpace::NamedColorSpace>("toColorSpace");
QTest::addColumn<int>("tolerance");
QTest::newRow("sRGB -> Display-P3") << QColorSpace::SRgb << QColorSpace::DisplayP3 << 0;
@@ -220,8 +226,8 @@ void tst_QColorSpace::imageConversion_data()
void tst_QColorSpace::imageConversion()
{
- QFETCH(QColorSpace::ColorSpaceId, fromColorSpace);
- QFETCH(QColorSpace::ColorSpaceId, toColorSpace);
+ QFETCH(QColorSpace::NamedColorSpace, fromColorSpace);
+ QFETCH(QColorSpace::NamedColorSpace, toColorSpace);
QFETCH(int, tolerance);
QImage testImage(256, 1, QImage::Format_RGB32);
@@ -275,7 +281,7 @@ void tst_QColorSpace::loadImage()
QVERIFY(!image.isNull());
QVERIFY(image.colorSpace().isValid());
- QCOMPARE(image.colorSpace().colorSpaceId(), QColorSpace::ProPhotoRgb);
+ QCOMPARE(image.colorSpace(), QColorSpace::ProPhotoRgb);
QVERIFY(!image.colorSpace().iccProfile().isEmpty());
QColorSpace defaultProPhotoRgb = QColorSpace::ProPhotoRgb;
@@ -355,6 +361,7 @@ void tst_QColorSpace::primariesXyz()
QCOMPARE(QColorSpacePrivate::get(bt2020)->toXyz, QColorMatrix::toXyzFromBt2020());
}
+#ifdef QT_BUILD_INTERNAL
void tst_QColorSpace::primaries2_data()
{
QTest::addColumn<QColorSpace::Primaries>("primariesId");
@@ -393,12 +400,12 @@ void tst_QColorSpace::primaries2()
QCOMPARE(color3.blue(), color1.blue());
QCOMPARE(color3.alpha(), color1.alpha());
}
+#endif
void tst_QColorSpace::invalidPrimaries()
{
QColorSpace custom(QPointF(), QPointF(), QPointF(), QPointF(), QColorSpace::TransferFunction::Linear);
QVERIFY(!custom.isValid());
- QCOMPARE(custom.colorSpaceId(), QColorSpace::Undefined);
}
void tst_QColorSpace::changeTransferFunction()
@@ -409,7 +416,7 @@ void tst_QColorSpace::changeTransferFunction()
QCOMPARE(sRgbLinear.transferFunction(), QColorSpace::TransferFunction::Linear);
QCOMPARE(sRgbLinear.gamma(), 1.0f);
QCOMPARE(sRgbLinear.primaries(), QColorSpace::Primaries::SRgb);
- QCOMPARE(sRgbLinear.colorSpaceId(), QColorSpace::SRgbLinear);
+ QCOMPARE(sRgbLinear, QColorSpace::SRgbLinear);
QCOMPARE(sRgbLinear, QColorSpace(QColorSpace::SRgbLinear));
QVERIFY(sRgbLinear != sRgb);
QCOMPARE(sRgbLinear.withTransferFunction(QColorSpace::TransferFunction::SRgb), sRgb);
@@ -418,7 +425,6 @@ void tst_QColorSpace::changeTransferFunction()
aRgb.setTransferFunction(QColorSpace::TransferFunction::SRgb);
QCOMPARE(aRgb.transferFunction(), QColorSpace::TransferFunction::SRgb);
QCOMPARE(aRgb.primaries(), QColorSpace::Primaries::AdobeRgb);
- QCOMPARE(aRgb.colorSpaceId(), QColorSpace::Unknown);
QVERIFY(aRgb != QColorSpace(QColorSpace::AdobeRgb));
QVERIFY(aRgb != sRgb);
QCOMPARE(aRgb.withTransferFunction(QColorSpace::TransferFunction::Gamma, 2.2f),
diff --git a/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp b/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp
index 9e9b0db366..b2b2b685ae 100644
--- a/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp
+++ b/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp
@@ -73,12 +73,12 @@ void tst_QPdfWriter::basics()
QCOMPARE(writer.pageSize(), QPdfWriter::A5);
QCOMPARE(writer.pageSizeMM(), QSizeF(148, 210));
- writer.setPageSize(QPdfWriter::A3);
+ writer.setPageSize(QPageSize(QPageSize::A3));
QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::A3);
QCOMPARE(writer.pageSize(), QPdfWriter::A3);
QCOMPARE(writer.pageSizeMM(), QSizeF(297, 420));
- writer.setPageSizeMM(QSize(210, 297));
+ writer.setPageSize(QPageSize(QSize(210, 297), QPageSize::Millimeter));
QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::A4);
QCOMPARE(writer.pageSize(), QPdfWriter::A4);
QCOMPARE(writer.pageSizeMM(), QSizeF(210, 297));
@@ -101,9 +101,9 @@ void tst_QPdfWriter::basics()
QCOMPARE(writer.margins().right, 20.0);
QCOMPARE(writer.margins().top, 20.0);
QCOMPARE(writer.margins().bottom, 20.0);
- QPdfWriter::Margins margins = {50, 50, 50, 50};
- writer.setMargins(margins);
- QCOMPARE(writer.pageLayout().margins(), QMarginsF(50, 50, 50, 50));
+ const QMarginsF margins = {50, 50, 50, 50};
+ writer.setPageMargins(margins, QPageLayout::Millimeter);
+ QCOMPARE(writer.pageLayout().margins(), margins);
QCOMPARE(writer.pageLayout().units(), QPageLayout::Millimeter);
QCOMPARE(writer.margins().left, 50.0);
QCOMPARE(writer.margins().right, 50.0);
@@ -117,7 +117,7 @@ void tst_QPdfWriter::basics()
// Test the old page metrics methods, see also QPrinter tests for the same.
void tst_QPdfWriter::testPageMetrics_data()
{
- QTest::addColumn<int>("pageSize");
+ QTest::addColumn<QPageSize::PageSizeId>("pageSizeId");
QTest::addColumn<qreal>("widthMMf");
QTest::addColumn<qreal>("heightMMf");
QTest::addColumn<bool>("setMargins");
@@ -126,17 +126,24 @@ void tst_QPdfWriter::testPageMetrics_data()
QTest::addColumn<qreal>("topMMf");
QTest::addColumn<qreal>("bottomMMf");
- QTest::newRow("A4") << int(QPdfWriter::A4) << 210.0 << 297.0 << false << 3.53 << 3.53 << 3.53 << 3.53;
- QTest::newRow("A4 Margins") << int(QPdfWriter::A4) << 210.0 << 297.0 << true << 20.0 << 30.0 << 40.0 << 50.0;
- QTest::newRow("Portrait") << -1 << 345.0 << 678.0 << false << 3.53 << 3.53 << 3.53 << 3.53;
- QTest::newRow("Portrait Margins") << -1 << 345.0 << 678.0 << true << 20.0 << 30.0 << 40.0 << 50.0;
- QTest::newRow("Landscape") << -1 << 678.0 << 345.0 << false << 3.53 << 3.53 << 3.53 << 3.53;
- QTest::newRow("Landscape Margins") << -1 << 678.0 << 345.0 << true << 20.0 << 30.0 << 40.0 << 50.0;
+ QTest::newRow("A4") << QPageSize::A4 << 210.0 << 297.0 << false
+ << 3.53 << 3.53 << 3.53 << 3.53;
+ QTest::newRow("A4 Margins") << QPageSize::A4 << 210.0 << 297.0 << true
+ << 20.0 << 30.0 << 40.0 << 50.0;
+
+ QTest::newRow("Portrait") << QPageSize::Custom << 345.0 << 678.0 << false
+ << 3.53 << 3.53 << 3.53 << 3.53;
+ QTest::newRow("Portrait Margins") << QPageSize::Custom << 345.0 << 678.0 << true
+ << 20.0 << 30.0 << 40.0 << 50.0;
+ QTest::newRow("Landscape") << QPageSize::Custom << 678.0 << 345.0 << false
+ << 3.53 << 3.53 << 3.53 << 3.53;
+ QTest::newRow("Landscape Margins") << QPageSize::Custom << 678.0 << 345.0 << true
+ << 20.0 << 30.0 << 40.0 << 50.0;
}
void tst_QPdfWriter::testPageMetrics()
{
- QFETCH(int, pageSize);
+ QFETCH(QPageSize::PageSizeId, pageSizeId);
QFETCH(qreal, widthMMf);
QFETCH(qreal, heightMMf);
QFETCH(bool, setMargins);
@@ -161,17 +168,13 @@ void tst_QPdfWriter::testPageMetrics()
QCOMPARE(writer.margins().bottom, bottomMMf);
}
-
// Set the given size, in Portrait mode
- if (pageSize < 0) {
- writer.setPageSize(QPageSize(sizeMMf, QPageSize::Millimeter));
- QCOMPARE(writer.pageSize(), QPdfWriter::Custom);
- QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::Custom);
- } else {
- writer.setPageSize(QPdfWriter::PageSize(pageSize));
- QCOMPARE(writer.pageSize(), QPdfWriter::PageSize(pageSize));
- QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::PageSizeId(pageSize));
- }
+ const QPageSize pageSize = pageSizeId == QPageSize::Custom
+ ? QPageSize(sizeMMf, QPageSize::Millimeter) : QPageSize(pageSizeId);
+ writer.setPageSize(pageSize);
+ QCOMPARE(writer.pageLayout().pageSize().id(), pageSizeId);
+ QCOMPARE(int(writer.pageSize()), int(pageSizeId));
+
QCOMPARE(writer.pageLayout().orientation(), QPageLayout::Portrait);
QCOMPARE(writer.margins().left, leftMMf);
QCOMPARE(writer.margins().right, rightMMf);
@@ -187,13 +190,8 @@ void tst_QPdfWriter::testPageMetrics()
// Now switch to Landscape mode, size should be unchanged, but rect and metrics should change
writer.setPageOrientation(QPageLayout::Landscape);
- if (pageSize < 0) {
- QCOMPARE(writer.pageSize(), QPdfWriter::Custom);
- QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::Custom);
- } else {
- QCOMPARE(writer.pageSize(), QPdfWriter::PageSize(pageSize));
- QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::PageSizeId(pageSize));
- }
+ QCOMPARE(writer.pageLayout().pageSize().id(), pageSizeId);
+ QCOMPARE(int(writer.pageSize()), int(pageSizeId));
QCOMPARE(writer.pageLayout().orientation(), QPageLayout::Landscape);
QCOMPARE(writer.margins().left, leftMMf);
QCOMPARE(writer.margins().right, rightMMf);
@@ -215,15 +213,9 @@ void tst_QPdfWriter::testPageMetrics()
// Now while in Landscape mode, set the size again, results should be the same
- if (pageSize < 0) {
- writer.setPageSize(QPageSize(sizeMMf, QPageSize::Millimeter));
- QCOMPARE(writer.pageSize(), QPdfWriter::Custom);
- QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::Custom);
- } else {
- writer.setPageSize(QPdfWriter::PageSize(pageSize));
- QCOMPARE(writer.pageSize(), QPdfWriter::PageSize(pageSize));
- QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::PageSizeId(pageSize));
- }
+ writer.setPageSize(pageSize);
+ QCOMPARE(writer.pageLayout().pageSize().id(), pageSizeId);
+ QCOMPARE(int(writer.pageSize()), int(pageSizeId));
QCOMPARE(writer.pageLayout().orientation(), QPageLayout::Landscape);
QCOMPARE(writer.margins().left, leftMMf);
QCOMPARE(writer.margins().right, rightMMf);
diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp
index 99d41d3583..9b434a7b5b 100644
--- a/tests/auto/tools/qmake/tst_qmake.cpp
+++ b/tests/auto/tools/qmake/tst_qmake.cpp
@@ -711,9 +711,6 @@ void tst_qmake::qinstall()
QFile srcfile(src.filePath("main.cpp"));
QVERIFY(srcfile.setPermissions(srcfile.permissions() & ~writeFlags));
QDir dst("zort");
-#ifdef Q_OS_WIN
- QEXPECT_FAIL("", "QTBUG-77299", Abort);
-#endif
QVERIFY(qinstall(src.absolutePath(), dst.absolutePath()));
QCOMPARE(src.entryList(QDir::Files, QDir::Name), dst.entryList(QDir::Files, QDir::Name));
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
index 72ea2ae31a..0b08586f7d 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -4451,6 +4451,7 @@ protected:
break;
case QGraphicsItem::ItemPositionHasChanged:
break;
+#if QT_DEPRECATED_SINCE(5, 14)
case QGraphicsItem::ItemMatrixChange: {
#if QT_DEPRECATED_SINCE(5, 13)
QT_WARNING_PUSH
@@ -4462,6 +4463,7 @@ QT_WARNING_POP
#endif
}
break;
+#endif
case QGraphicsItem::ItemTransformChange: {
QVariant variant;
variant.setValue<QTransform>(transform());
diff --git a/tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp b/tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp
index d401154228..5097f2e356 100644
--- a/tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp
+++ b/tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp
@@ -34,6 +34,8 @@
#include <qdebug.h>
#include "emulationdetector.h"
+QT_WARNING_DISABLE_DEPRECATED
+
class tst_QDirModel : public QObject
{
Q_OBJECT
diff --git a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp
index ae084310b1..4cec54856f 100644
--- a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp
+++ b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** 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.
@@ -67,15 +67,9 @@ using namespace QTestPrivate;
class tst_QStyle : public QObject
{
Q_OBJECT
-public:
- tst_QStyle();
-private:
- bool testAllFunctions(QStyle *);
- bool testScrollBarSubControls();
private slots:
void drawItemPixmap();
- void init();
void cleanup();
#ifndef QT_NO_STYLE_FUSION
void testFusionStyle();
@@ -100,38 +94,29 @@ private slots:
void testProxyCalled();
void testStyleOptionInit();
private:
+ bool testAllFunctions(QStyle *);
+ bool testScrollBarSubControls(const QStyle *style);
+ void testPainting(QStyle *style, const QString &platform);
void lineUpLayoutTest(QStyle *);
- QWidget *testWidget;
};
-
-tst_QStyle::tst_QStyle()
-{
- testWidget = 0;
-}
-
class MyWidget : public QWidget
{
public:
- MyWidget( QWidget* QWidget=0, const char* name=0 );
+ using QWidget::QWidget;
+
protected:
- void paintEvent( QPaintEvent* );
+ void paintEvent(QPaintEvent *) override;
};
-void tst_QStyle::init()
-{
- testWidget = new MyWidget( 0, "testObject");
-}
-
void tst_QStyle::cleanup()
{
- delete testWidget;
- testWidget = 0;
+ QVERIFY(QApplication::topLevelWidgets().isEmpty());
}
void tst_QStyle::testStyleFactory()
{
- QStringList keys = QStyleFactory::keys();
+ const QStringList keys = QStyleFactory::keys();
#ifndef QT_NO_STYLE_FUSION
QVERIFY(keys.contains("Fusion"));
#endif
@@ -139,17 +124,17 @@ void tst_QStyle::testStyleFactory()
QVERIFY(keys.contains("Windows"));
#endif
- foreach (QString styleName , keys) {
- QStyle *style = QStyleFactory::create(styleName);
- QVERIFY2(style != 0, qPrintable(QString::fromLatin1("Fail to load style '%1'").arg(styleName)));
- delete style;
+ for (const QString &styleName : keys) {
+ QScopedPointer<QStyle> style(QStyleFactory::create(styleName));
+ QVERIFY2(!style.isNull(),
+ qPrintable(QString::fromLatin1("Fail to load style '%1'").arg(styleName)));
}
}
class CustomProxy : public QProxyStyle
{
- virtual int pixelMetric(PixelMetric metric, const QStyleOption *option = 0,
- const QWidget *widget = 0) const
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr,
+ const QWidget *widget = nullptr) const override
{
if (metric == QStyle::PM_ButtonIconSize)
return 13;
@@ -170,9 +155,9 @@ void tst_QStyle::testProxyStyle()
QCOMPARE(proxyStyle->baseStyle(), style);
QVERIFY(testAllFunctions(proxyStyle));
- proxyStyle->setBaseStyle(0);
+ proxyStyle->setBaseStyle(nullptr);
QVERIFY(proxyStyle->baseStyle());
- qApp->setStyle(proxyStyle);
+ QApplication::setStyle(proxyStyle);
QProxyStyle* baseStyle = new QProxyStyle("Windows");
QCOMPARE(baseStyle->baseStyle()->objectName(), style->objectName());
@@ -189,10 +174,12 @@ void tst_QStyle::testProxyStyle()
void tst_QStyle::drawItemPixmap()
{
- testWidget->resize(300, 300);
- testWidget->showNormal();
+ MyWidget testWidget;
+ testWidget.setObjectName("testObject");
+ testWidget.resize(300, 300);
+ testWidget.showNormal();
- QImage image = testWidget->grab().toImage();
+ QImage image = testWidget.grab().toImage();
const QRgb green = QColor(Qt::green).rgb();
QVERIFY(image.reinterpretAsFormat(QImage::Format_RGB32));
const QRgb *bits = reinterpret_cast<const QRgb *>(image.constBits());
@@ -201,33 +188,33 @@ void tst_QStyle::drawItemPixmap()
QEXPECT_FAIL("", "QWidget::resize does not work on WinRT", Continue);
#endif
QVERIFY(std::all_of(bits, end, [green] (QRgb r) { return r == green; }));
- testWidget->hide();
}
bool tst_QStyle::testAllFunctions(QStyle *style)
{
QStyleOption opt;
- opt.init(testWidget);
+ QWidget testWidget;
+ opt.init(&testWidget);
- testWidget->setStyle(style);
+ testWidget.setStyle(style);
//Tests styleHint with default arguments for potential crashes
for ( int hint = 0 ; hint < int(QStyle::SH_Menu_Mask); ++hint) {
style->styleHint(QStyle::StyleHint(hint));
- style->styleHint(QStyle::StyleHint(hint), &opt, testWidget);
+ style->styleHint(QStyle::StyleHint(hint), &opt, &testWidget);
}
//Tests pixelMetric with default arguments for potential crashes
for ( int pm = 0 ; pm < int(QStyle::PM_LayoutVerticalSpacing); ++pm) {
style->pixelMetric(QStyle::PixelMetric(pm));
- style->pixelMetric(QStyle::PixelMetric(pm), &opt, testWidget);
+ style->pixelMetric(QStyle::PixelMetric(pm), &opt, &testWidget);
}
//Tests drawControl with default arguments for potential crashes
for ( int control = 0 ; control < int(QStyle::CE_ColumnViewGrip); ++control) {
QPixmap surface(QSize(200, 200));
QPainter painter(&surface);
- style->drawControl(QStyle::ControlElement(control), &opt, &painter, 0);
+ style->drawControl(QStyle::ControlElement(control), &opt, &painter, nullptr);
}
//Tests drawComplexControl with default arguments for potential crashes
@@ -235,35 +222,35 @@ bool tst_QStyle::testAllFunctions(QStyle *style)
QPixmap surface(QSize(200, 200));
QPainter painter(&surface);
QStyleOptionComboBox copt1;
- copt1.init(testWidget);
+ copt1.init(&testWidget);
QStyleOptionGroupBox copt2;
- copt2.init(testWidget);
+ copt2.init(&testWidget);
QStyleOptionSizeGrip copt3;
- copt3.init(testWidget);
+ copt3.init(&testWidget);
QStyleOptionSlider copt4;
- copt4.init(testWidget);
+ copt4.init(&testWidget);
copt4.minimum = 0;
copt4.maximum = 100;
copt4.tickInterval = 25;
copt4.sliderValue = 50;
QStyleOptionSpinBox copt5;
- copt5.init(testWidget);
+ copt5.init(&testWidget);
QStyleOptionTitleBar copt6;
- copt6.init(testWidget);
+ copt6.init(&testWidget);
QStyleOptionToolButton copt7;
- copt7.init(testWidget);
+ copt7.init(&testWidget);
QStyleOptionComplex copt9;
- copt9.initFrom(testWidget);
-
- style->drawComplexControl(QStyle::CC_SpinBox, &copt5, &painter, 0);
- style->drawComplexControl(QStyle::CC_ComboBox, &copt1, &painter, 0);
- style->drawComplexControl(QStyle::CC_ScrollBar, &copt4, &painter, 0);
- style->drawComplexControl(QStyle::CC_Slider, &copt4, &painter, 0);
- style->drawComplexControl(QStyle::CC_ToolButton, &copt7, &painter, 0);
- style->drawComplexControl(QStyle::CC_TitleBar, &copt6, &painter, 0);
- style->drawComplexControl(QStyle::CC_GroupBox, &copt2, &painter, 0);
- style->drawComplexControl(QStyle::CC_Dial, &copt4, &painter, 0);
+ copt9.initFrom(&testWidget);
+
+ style->drawComplexControl(QStyle::CC_SpinBox, &copt5, &painter, nullptr);
+ style->drawComplexControl(QStyle::CC_ComboBox, &copt1, &painter, nullptr);
+ style->drawComplexControl(QStyle::CC_ScrollBar, &copt4, &painter, nullptr);
+ style->drawComplexControl(QStyle::CC_Slider, &copt4, &painter, nullptr);
+ style->drawComplexControl(QStyle::CC_ToolButton, &copt7, &painter, nullptr);
+ style->drawComplexControl(QStyle::CC_TitleBar, &copt6, &painter, nullptr);
+ style->drawComplexControl(QStyle::CC_GroupBox, &copt2, &painter, nullptr);
+ style->drawComplexControl(QStyle::CC_Dial, &copt4, &painter, nullptr);
}
//Check standard pixmaps/icons
@@ -279,20 +266,21 @@ bool tst_QStyle::testAllFunctions(QStyle *style)
}
style->itemPixmapRect(QRect(0, 0, 100, 100), Qt::AlignHCenter, QPixmap(200, 200));
- style->itemTextRect(QFontMetrics(qApp->font()), QRect(0, 0, 100, 100), Qt::AlignHCenter, true, QString("Test"));
+ style->itemTextRect(QFontMetrics(QApplication::font()), QRect(0, 0, 100, 100),
+ Qt::AlignHCenter, true, QLatin1String("Test"));
- return testScrollBarSubControls();
+ return testScrollBarSubControls(style);
}
-bool tst_QStyle::testScrollBarSubControls()
+bool tst_QStyle::testScrollBarSubControls(const QStyle *style)
{
- const auto *style = testWidget->style();
- const bool isMacStyle = style->objectName().toLower() == "macintosh";
+ const bool isMacStyle = style->objectName().compare(QLatin1String("macintosh"),
+ Qt::CaseInsensitive) == 0;
QScrollBar scrollBar;
setFrameless(&scrollBar);
scrollBar.show();
const QStyleOptionSlider opt = qt_qscrollbarStyleOption(&scrollBar);
- foreach (int sc, QList<int>() << 1 << 2 << 4 << 8) {
+ for (int sc : {1, 2, 4, 8}) {
const auto subControl = static_cast<QStyle::SubControl>(sc);
const QRect sr = style->subControlRect(QStyle::CC_ScrollBar, &opt, subControl, &scrollBar);
if (sr.isNull()) {
@@ -310,34 +298,34 @@ bool tst_QStyle::testScrollBarSubControls()
#ifndef QT_NO_STYLE_FUSION
void tst_QStyle::testFusionStyle()
{
- QStyle *fstyle = QStyleFactory::create("Fusion");
- QVERIFY(testAllFunctions(fstyle));
- lineUpLayoutTest(fstyle);
- delete fstyle;
+ QScopedPointer<QStyle> fstyle(QStyleFactory::create("Fusion"));
+ QVERIFY(!fstyle.isNull());
+ QVERIFY(testAllFunctions(fstyle.data()));
+ lineUpLayoutTest(fstyle.data());
}
#endif
void tst_QStyle::testWindowsStyle()
{
- QStyle *wstyle = QStyleFactory::create("Windows");
- QVERIFY(testAllFunctions(wstyle));
- lineUpLayoutTest(wstyle);
+ QScopedPointer<QStyle> wstyle(QStyleFactory::create("Windows"));
+ QVERIFY(!wstyle.isNull());
+ QVERIFY(testAllFunctions(wstyle.data()));
+ lineUpLayoutTest(wstyle.data());
// Tests drawing indeterminate progress with 0 size: QTBUG-15973
QStyleOptionProgressBar pb;
pb.rect = QRect(0,0,-9,0);
QPixmap surface(QSize(200, 200));
QPainter painter(&surface);
- wstyle->drawControl(QStyle::CE_ProgressBar, &pb, &painter, 0);
- delete wstyle;
+ wstyle->drawControl(QStyle::CE_ProgressBar, &pb, &painter, nullptr);
}
#if defined(Q_OS_WIN) && !defined(QT_NO_STYLE_WINDOWSVISTA) && !defined(Q_OS_WINRT)
void tst_QStyle::testWindowsVistaStyle()
{
- QStyle *vistastyle = QStyleFactory::create("WindowsVista");
- QVERIFY(testAllFunctions(vistastyle));
- delete vistastyle;
+ QScopedPointer<QStyle> vistastyle(QStyleFactory::create("WindowsVista"));
+ QVERIFY(!vistastyle.isNull());
+ QVERIFY(testAllFunctions(vistastyle.data()));
}
#endif
@@ -351,14 +339,7 @@ void tst_QStyle::testMacStyle()
#endif
// Helper class...
-
-MyWidget::MyWidget( QWidget* parent, const char* name )
- : QWidget( parent )
-{
- setObjectName(name);
-}
-
-void MyWidget::paintEvent( QPaintEvent* )
+void MyWidget::paintEvent(QPaintEvent *)
{
QPainter p(this);
QPixmap big(400,400);
@@ -371,20 +352,12 @@ class Qt42Style : public QCommonStyle
{
Q_OBJECT
public:
- Qt42Style() : QCommonStyle()
- {
- margin_toplevel = 10;
- margin = 5;
- spacing = 0;
- }
-
- virtual int pixelMetric(PixelMetric metric, const QStyleOption * option = 0,
- const QWidget * widget = 0 ) const;
-
- int margin_toplevel;
- int margin;
- int spacing;
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr,
+ const QWidget *widget = nullptr) const override;
+ int margin_toplevel = 10;
+ int margin = 5;
+ int spacing = 0;
};
int Qt42Style::pixelMetric(PixelMetric metric, const QStyleOption * /* option = 0*/,
@@ -393,13 +366,10 @@ int Qt42Style::pixelMetric(PixelMetric metric, const QStyleOption * /* option =
switch (metric) {
case QStyle::PM_DefaultTopLevelMargin:
return margin_toplevel;
- break;
case QStyle::PM_DefaultChildMargin:
return margin;
- break;
case QStyle::PM_DefaultLayoutSpacing:
return spacing;
- break;
default:
break;
}
@@ -409,7 +379,7 @@ int Qt42Style::pixelMetric(PixelMetric metric, const QStyleOption * /* option =
void tst_QStyle::pixelMetric()
{
- Qt42Style *style = new Qt42Style();
+ QScopedPointer<Qt42Style> style(new Qt42Style);
QCOMPARE(style->pixelMetric(QStyle::PM_DefaultTopLevelMargin), 10);
QCOMPARE(style->pixelMetric(QStyle::PM_DefaultChildMargin), 5);
QCOMPARE(style->pixelMetric(QStyle::PM_DefaultLayoutSpacing), 0);
@@ -427,8 +397,6 @@ void tst_QStyle::pixelMetric()
QCOMPARE(style->pixelMetric(QStyle::PM_DefaultTopLevelMargin), -1);
QCOMPARE(style->pixelMetric(QStyle::PM_DefaultChildMargin), -1);
QCOMPARE(style->pixelMetric(QStyle::PM_DefaultLayoutSpacing), -1);
-
- delete style;
}
#if !defined(QT_NO_STYLE_WINDOWS) && !defined(QT_NO_STYLE_FUSION)
@@ -474,10 +442,11 @@ void tst_QStyle::lineUpLayoutTest(QStyle *style)
layout.addWidget(&lineedit);
layout.addWidget(&combo);
widget.setLayout(&layout);
- widget.setStyle(style);
- // propagate the style.
- foreach (QWidget *w, widget.findChildren<QWidget *>())
- w->setStyle(style);
+ widget.setStyle(style);
+ // propagate the style.
+ const auto children = widget.findChildren<QWidget *>();
+ for (QWidget *w : children)
+ w->setStyle(style);
widget.show();
QVERIFY(QTest::qWaitForWindowExposed(&widget));
@@ -498,31 +467,32 @@ void tst_QStyle::lineUpLayoutTest(QStyle *style)
void tst_QStyle::defaultFont()
{
- QFont defaultFont = qApp->font();
+ QFont defaultFont = QApplication::font();
QFont pointFont = defaultFont;
pointFont.setPixelSize(9);
- qApp->setFont(pointFont);
+ QApplication::setFont(pointFont);
QPushButton button;
setFrameless(&button);
button.show();
- qApp->processEvents();
- qApp->setFont(defaultFont);
+ QCoreApplication::processEvents();
+ QApplication::setFont(defaultFont);
}
class DrawTextStyle : public QProxyStyle
{
Q_OBJECT
public:
- DrawTextStyle(QStyle *base = 0) : QProxyStyle(), alignment(0) { setBaseStyle(base); }
+ using QProxyStyle::QProxyStyle;
+
void drawItemText(QPainter *painter, const QRect &rect,
- int flags, const QPalette &pal, bool enabled,
- const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const
+ int flags, const QPalette &pal, bool enabled,
+ const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const override
{
- DrawTextStyle *that = (DrawTextStyle *)this;
- that->alignment = flags;
+ alignment = flags;
QProxyStyle::drawItemText(painter, rect, flags, pal, enabled, text, textRole);
}
- int alignment;
+
+ mutable int alignment = 0;
};
@@ -533,46 +503,48 @@ void tst_QStyle::testDrawingShortcuts()
setFrameless(&w);
QToolButton *tb = new QToolButton(&w);
tb->setText("&abc");
- DrawTextStyle *dts = new DrawTextStyle;
+ QScopedPointer<DrawTextStyle> dts(new DrawTextStyle);
w.show();
- tb->setStyle(dts);
+ tb->setStyle(dts.data());
tb->grab();
QStyleOptionToolButton sotb;
sotb.initFrom(tb);
bool showMnemonic = dts->styleHint(QStyle::SH_UnderlineShortcut, &sotb, tb);
QVERIFY(dts->alignment & (showMnemonic ? Qt::TextShowMnemonic : Qt::TextHideMnemonic));
- delete dts;
}
{
QToolBar w;
setFrameless(&w);
QToolButton *tb = new QToolButton(&w);
tb->setText("&abc");
- DrawTextStyle *dts = new DrawTextStyle;
+ QScopedPointer<DrawTextStyle> dts(new DrawTextStyle);
w.addWidget(tb);
w.show();
- tb->setStyle(dts);
+ tb->setStyle(dts.data());
tb->grab();
QStyleOptionToolButton sotb;
sotb.initFrom(tb);
bool showMnemonic = dts->styleHint(QStyle::SH_UnderlineShortcut, &sotb, tb);
QVERIFY(dts->alignment & (showMnemonic ? Qt::TextShowMnemonic : Qt::TextHideMnemonic));
- delete dts;
}
}
-#define SCROLLBAR_SPACING 33
+static const int SCROLLBAR_SPACING = 33;
class FrameTestStyle : public QProxyStyle {
public:
FrameTestStyle() : QProxyStyle("Windows") { }
- int styleHint(StyleHint hint, const QStyleOption *opt, const QWidget *widget, QStyleHintReturn *returnData) const {
+
+ int styleHint(StyleHint hint, const QStyleOption *opt, const QWidget *widget,
+ QStyleHintReturn *returnData) const override
+ {
if (hint == QStyle::SH_ScrollView_FrameOnlyAroundContents)
return 1;
return QProxyStyle ::styleHint(hint, opt, widget, returnData);
}
- int pixelMetric(PixelMetric pm, const QStyleOption *option, const QWidget *widget) const {
+ int pixelMetric(PixelMetric pm, const QStyleOption *option, const QWidget *widget) const override
+ {
if (pm == QStyle::PM_ScrollView_ScrollBarSpacing)
return SCROLLBAR_SPACING;
return QProxyStyle ::pixelMetric(pm, option ,widget);
@@ -583,12 +555,12 @@ void tst_QStyle::testFrameOnlyAroundContents()
{
QScrollArea area;
area.setGeometry(0, 0, 200, 200);
- QStyle *winStyle = QStyleFactory::create("Windows");
+ QScopedPointer<QStyle> winStyle(QStyleFactory::create("Windows"));
FrameTestStyle frameStyle;
QWidget *widget = new QWidget(&area);
widget->setGeometry(0, 0, 400, 400);
- area.setStyle(winStyle);
- area.verticalScrollBar()->setStyle(winStyle);
+ area.setStyle(winStyle.data());
+ area.verticalScrollBar()->setStyle(winStyle.data());
area.setWidget(widget);
area.setVisible(true);
int viewPortWidth = area.viewport()->width();
@@ -598,8 +570,7 @@ void tst_QStyle::testFrameOnlyAroundContents()
#ifdef Q_OS_WINRT
QEXPECT_FAIL("", "QWidget::setGeometry does not work on WinRT", Continue);
#endif
- QVERIFY(viewPortWidth == area.viewport()->width() + SCROLLBAR_SPACING);
- delete winStyle;
+ QCOMPARE(viewPortWidth, area.viewport()->width() + SCROLLBAR_SPACING);
}
@@ -607,16 +578,16 @@ class ProxyTest: public QProxyStyle
{
Q_OBJECT
public:
- ProxyTest(QStyle *style = 0)
- :QProxyStyle(style)
- , called(false)
- {}
+ using QProxyStyle::QProxyStyle;
- void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w) const override {
+ void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
+ const QWidget *w) const override
+ {
called = true;
return QProxyStyle::drawPrimitive(pe, opt, p, w);
}
- mutable bool called;
+
+ mutable bool called = false;
};
@@ -630,17 +601,16 @@ void tst_QStyle::testProxyCalled()
QPixmap surface(QSize(200, 200));
QPainter painter(&surface);
- QStringList keys = QStyleFactory::keys();
+ const QStringList keys = QStyleFactory::keys();
QVector<QStyle*> styles;
styles.reserve(keys.size() + 1);
styles << new QCommonStyle();
- Q_FOREACH (const QString &key, keys) {
+ for (const QString &key : keys)
styles << QStyleFactory::create(key);
- }
- Q_FOREACH (QStyle *style, styles) {
+ for (QStyle *style : styles) {
ProxyTest testStyle;
testStyle.setBaseStyle(style);
style->drawControl(QStyle::CE_ToolButtonLabel, &opt, &painter, &b);
@@ -654,11 +624,9 @@ class TestStyleOptionInitProxy: public QProxyStyle
{
Q_OBJECT
public:
- mutable bool invalidOptionsDetected;
- explicit TestStyleOptionInitProxy(QStyle *style = nullptr)
- : QProxyStyle(style),
- invalidOptionsDetected(false)
- {}
+ mutable bool invalidOptionsDetected = false;
+
+ using QProxyStyle::QProxyStyle;
void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w) const override {
checkStyleEnum<QStyle::PrimitiveElement>(pe, opt);
@@ -743,7 +711,7 @@ void tst_QStyle::testStyleOptionInit()
QStringList keys = QStyleFactory::keys();
keys.prepend(QString()); // QCommonStyle marker
- Q_FOREACH (const QString &key, keys) {
+ for (const QString &key : qAsConst(keys)) {
QStyle* style = key.isEmpty() ? new QCommonStyle : QStyleFactory::create(key);
TestStyleOptionInitProxy testStyle;
testStyle.setBaseStyle(style);
diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
index a671a6c4d8..400e46cb97 100644
--- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
+++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** 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.
@@ -25,12 +25,40 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include <QtCore>
-#include <QtGui>
-#include <QtWidgets>
+
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QCheckBox>
+#include <QtWidgets/QComboBox>
+#include <QtWidgets/QDateEdit>
+#include <QtWidgets/QDialog>
+#include <QtWidgets/QDialogButtonBox>
+#include <QtWidgets/QGridLayout>
+#include <QtWidgets/QGroupBox>
+#include <QtWidgets/QLabel>
+#include <QtWidgets/QHeaderView>
+#include <QtWidgets/QLineEdit>
+#include <QtWidgets/QMainWindow>
+#include <QtWidgets/QMenu>
+#include <QtWidgets/QPushButton>
+#include <QtWidgets/QProgressBar>
+#include <QtWidgets/QSpinBox>
+#include <QtWidgets/QSplitter>
+#include <QtWidgets/QStyle>
+#include <QtWidgets/QStyleFactory>
+#include <QtWidgets/QTableWidget>
+#include <QtWidgets/QToolButton>
+#include <QtWidgets/QToolTip>
+#include <QtWidgets/QTreeView>
+#include <QtWidgets/QVBoxLayout>
+
+#include <QtGui/QPainter>
+#include <QtGui/QScreen>
+
#include <QtTest/QtTest>
-#include <QtDebug>
-#include <QMetaObject>
+
+#include <QtCore/QDebug>
+#include <QtCore/QMetaObject>
+#include <QtCore/QScopedPointer>
#include <private/qstylesheetstyle_p.h>
#include <private/qhighdpiscaling_p.h>
@@ -43,10 +71,12 @@ class tst_QStyleSheetStyle : public QObject
Q_OBJECT
public:
tst_QStyleSheetStyle();
- ~tst_QStyleSheetStyle();
+
+ static void initMain();
private slots:
void init();
+ void cleanup();
void repolish();
void repolish_without_crashing();
void numinstances();
@@ -77,7 +107,7 @@ private slots:
void hoverColors();
#endif
void background();
- void tabAlignement();
+ void tabAlignment();
void attributesList();
void minmaxSizes();
void task206238_twice();
@@ -107,37 +137,53 @@ private slots:
void highdpiImages();
private:
- QColor COLOR(const QWidget& w) {
+ static QColor COLOR(const QWidget &w)
+ {
w.ensurePolished();
return w.palette().color(w.foregroundRole());
}
- QColor APPCOLOR(const QWidget& w) {
+
+ static QColor APPCOLOR(const QWidget &w)
+ {
w.ensurePolished();
- return qApp->palette(&w).color(w.foregroundRole());
+ return QApplication::palette(&w).color(w.foregroundRole());
}
- QColor BACKGROUND(const QWidget& w) {
+
+ static QColor BACKGROUND(const QWidget &w)
+ {
w.ensurePolished();
return w.palette().color(w.backgroundRole());
}
- QColor APPBACKGROUND(const QWidget& w) {
+
+ static QColor APPBACKGROUND(const QWidget &w)
+ {
w.ensurePolished();
- return qApp->palette(&w).color(w.backgroundRole());
+ return QApplication::palette(&w).color(w.backgroundRole());
}
- int FONTSIZE(const QWidget &w) {
+
+ static int FONTSIZE(const QWidget &w)
+ {
w.ensurePolished();
return w.font().pointSize();
}
- int APPFONTSIZE(const QWidget &w) {
- return qApp->font(&w).pointSize();
- }
+
+ static int APPFONTSIZE(const QWidget &w) { return QApplication::font(&w).pointSize(); }
+
+ const QRect m_availableGeometry = QGuiApplication::primaryScreen()->availableGeometry();
+ QSize m_testSize;
};
-tst_QStyleSheetStyle::tst_QStyleSheetStyle()
+// highdpiImages() tests HighDPI scaling; disable initially.
+void tst_QStyleSheetStyle::initMain()
{
+ QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
}
-tst_QStyleSheetStyle::~tst_QStyleSheetStyle()
+tst_QStyleSheetStyle::tst_QStyleSheetStyle()
{
+ const int testSize = qMax(200, m_availableGeometry.width() / 10);
+ m_testSize.setWidth(testSize);
+ m_testSize.setHeight(testSize);
}
void tst_QStyleSheetStyle::init()
@@ -146,10 +192,16 @@ void tst_QStyleSheetStyle::init()
QCoreApplication::setAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles, false);
}
+void tst_QStyleSheetStyle::cleanup()
+{
+ QTRY_VERIFY(QApplication::topLevelWidgets().isEmpty());
+}
+
void tst_QStyleSheetStyle::numinstances()
{
QWidget w;
- w.resize(200, 200);
+ w.setWindowTitle(QTest::currentTestFunction());
+ w.resize(m_testSize);
centerOnScreen(&w);
QCommonStyle *style = new QCommonStyle;
style->setParent(&w);
@@ -175,7 +227,7 @@ void tst_QStyleSheetStyle::numinstances()
QCOMPARE(QStyleSheetStyle::numinstances, 0);
// set and unset widget stylesheet
- w.setStyle(0);
+ w.setStyle(nullptr);
w.setStyleSheet("color: red");
QCOMPARE(QStyleSheetStyle::numinstances, 1);
c.setStyle(style);
@@ -325,7 +377,7 @@ void tst_QStyleSheetStyle::reparentWithNoChildStyleSheet()
QCOMPARE(COLOR(c1), red);
qApp->setStyleSheet("* { color: blue }");
- c1.setParent(0);
+ c1.setParent(nullptr);
QCOMPARE(COLOR(c1), blue);
delete pb;
}
@@ -372,6 +424,8 @@ void tst_QStyleSheetStyle::repolish_without_crashing()
{
// This used to crash, QTBUG-69204
QMainWindow w;
+ w.resize(m_testSize);
+ w.setWindowTitle(QTest::currentTestFunction());
QScopedPointer<QSplitter> splitter1(new QSplitter(w.centralWidget()));
QScopedPointer<QSplitter> splitter2(new QSplitter);
QScopedPointer<QSplitter> splitter3(new QSplitter);
@@ -408,7 +462,7 @@ void tst_QStyleSheetStyle::widgetStyle()
QPointer<QStyle> style1 = QStyleFactory::create("Windows");
QPointer<QStyle> style2 = QStyleFactory::create("Windows");
- QStyle *appStyle = qApp->style();
+ QStyle *appStyle = QApplication::style();
// Sanity: By default, a window inherits the application style
QCOMPARE(appStyle, window1->style());
@@ -423,7 +477,7 @@ void tst_QStyleSheetStyle::widgetStyle()
QVERIFY(!style1.isNull()); // case we have not already crashed
// Setting null style must make it follow the qApp style
- window1->setStyle(0);
+ window1->setStyle(nullptr);
QCOMPARE(window1->style(), appStyle);
QVERIFY(!style2.isNull()); // case we have not already crashed
QVERIFY(!style2.isNull()); // case we have not already crashed
@@ -431,16 +485,15 @@ void tst_QStyleSheetStyle::widgetStyle()
// Sanity: Set the stylesheet
window1->setStyleSheet(":x { }");
- QPointer<QStyleSheetStyle> proxy = (QStyleSheetStyle *)window1->style();
+ QPointer<QStyleSheetStyle> proxy = qobject_cast<QStyleSheetStyle *>(window1->style());
QVERIFY(!proxy.isNull());
- QCOMPARE(proxy->metaObject()->className(), "QStyleSheetStyle"); // must be our proxy
- QVERIFY(proxy->base == 0); // and follows the application
+ QCOMPARE(proxy->base, nullptr); // and follows the application
// Set the stylesheet
window1->setStyle(style1);
QVERIFY(proxy.isNull()); // we create a new one each time
- proxy = (QStyleSheetStyle *)window1->style();
- QCOMPARE(proxy->metaObject()->className(), "QStyleSheetStyle"); // it is a proxy
+ proxy = qobject_cast<QStyleSheetStyle *>(window1->style());
+ QVERIFY(!proxy.isNull()); // it is a proxy
QCOMPARE(proxy->baseStyle(), style1.data()); // must have been replaced with the new one
// Update the stylesheet and check nothing changes
@@ -449,15 +502,15 @@ void tst_QStyleSheetStyle::widgetStyle()
QCOMPARE(proxy->baseStyle(), style1.data()); // the same guy
// Remove the stylesheet
- proxy = (QStyleSheetStyle *)window1->style();
+ proxy = qobject_cast<QStyleSheetStyle *>(window1->style());
window1->setStyleSheet(QString());
QVERIFY(proxy.isNull()); // should have disappeared
QCOMPARE(window1->style(), style1.data()); // its restored
// Style Sheet existing children propagation
window1->setStyleSheet(":z { }");
- proxy = (QStyleSheetStyle *)window1->style();
- QCOMPARE(proxy->metaObject()->className(), "QStyleSheetStyle");
+ proxy = qobject_cast<QStyleSheetStyle *>(window1->style());
+ QVERIFY(!proxy.isNull()); // it is a proxy
QCOMPARE(window1->style(), widget1->style()); // proxy must have propagated
QCOMPARE(widget2->style(), appStyle); // widget2 is following the app style
@@ -473,55 +526,57 @@ void tst_QStyleSheetStyle::widgetStyle()
// Style Sheet propagation on a child widget with a custom style
widget2->setStyle(style1);
window2->setStyleSheet(":x { }");
- proxy = (QStyleSheetStyle *)widget2->style();
- QCOMPARE(proxy->metaObject()->className(), "QStyleSheetStyle");
+ proxy = qobject_cast<QStyleSheetStyle *>(widget2->style());
+ QVERIFY(!proxy.isNull()); // it is a proxy
QCOMPARE(proxy->baseStyle(), style1.data());
// Style Sheet propagation on a child widget with a custom style already set
window2->setStyleSheet(QString());
QCOMPARE(window2->style(), style2.data());
QCOMPARE(widget2->style(), style1.data());
- widget2->setStyle(0);
+ widget2->setStyle(nullptr);
window2->setStyleSheet(":x { }");
widget2->setStyle(style1);
- proxy = (QStyleSheetStyle *)widget2->style();
- QCOMPARE(proxy->metaObject()->className(), "QStyleSheetStyle");
+ proxy = qobject_cast<QStyleSheetStyle *>(widget2->style());
+ QVERIFY(!proxy.isNull()); // it is a proxy
// QApplication, QWidget both having a style sheet
// clean everything out
- window1->setStyle(0);
+ window1->setStyle(nullptr);
window1->setStyleSheet(QString());
- window2->setStyle(0);
+ window2->setStyle(nullptr);
window2->setStyleSheet(QString());
- qApp->setStyle(0);
+ QApplication::setStyle(nullptr);
qApp->setStyleSheet("may_insanity_prevail { }"); // app has stylesheet
- QCOMPARE(window1->style(), qApp->style());
+ QCOMPARE(window1->style(), QApplication::style());
QCOMPARE(window1->style()->metaObject()->className(), "QStyleSheetStyle");
QCOMPARE(widget1->style()->metaObject()->className(), "QStyleSheetStyle"); // check the child
window1->setStyleSheet("may_more_insanity_prevail { }"); // window has stylesheet
QCOMPARE(window1->style()->metaObject()->className(), "QStyleSheetStyle"); // a new one
QCOMPARE(widget1->style(), window1->style()); // child follows...
- proxy = (QStyleSheetStyle *) window1->style();
+ proxy = qobject_cast<QStyleSheetStyle *>(window1->style());
+ QVERIFY(!proxy.isNull());
QStyle *newStyle = QStyleFactory::create("Windows");
- qApp->setStyle(newStyle); // set a custom style on app
- proxy = (QStyleSheetStyle *) window1->style();
+ QApplication::setStyle(newStyle); // set a custom style on app
+ proxy = qobject_cast<QStyleSheetStyle *>(window1->style());
+ QVERIFY(!proxy.isNull()); // it is a proxy
QCOMPARE(proxy->baseStyle(), newStyle); // magic ;) the widget still follows the application
QCOMPARE(static_cast<QStyle *>(proxy), widget1->style()); // child still follows...
window1->setStyleSheet(QString()); // remove stylesheet
- QCOMPARE(window1->style(), qApp->style()); // is this cool or what
- QCOMPARE(widget1->style(), qApp->style()); // annoying child follows...
+ QCOMPARE(window1->style(), QApplication::style()); // is this cool or what
+ QCOMPARE(widget1->style(), QApplication::style()); // annoying child follows...
QScopedPointer<QStyle> wndStyle(QStyleFactory::create("Windows"));
window1->setStyle(wndStyle.data());
QCOMPARE(window1->style()->metaObject()->className(), "QStyleSheetStyle"); // auto wraps it
QCOMPARE(widget1->style(), window1->style()); // and auto propagates to child
qApp->setStyleSheet(QString()); // remove the app stylesheet
QCOMPARE(window1->style(), wndStyle.data()); // auto dewrap
- QCOMPARE(widget1->style(), qApp->style()); // and child state is restored
- window1->setStyle(0); // let sanity prevail
- qApp->setStyle(0);
+ QCOMPARE(widget1->style(), QApplication::style()); // and child state is restored
+ window1->setStyle(nullptr); // let sanity prevail
+ QApplication::setStyle(nullptr);
delete window1;
delete widget2;
@@ -534,32 +589,32 @@ void tst_QStyleSheetStyle::appStyle()
{
qApp->setStyleSheet(QString());
// qApp style can never be 0
- QVERIFY(QApplication::style() != 0);
+ QVERIFY(QApplication::style() != nullptr);
QPointer<QStyle> style1 = QStyleFactory::create("Windows");
QPointer<QStyle> style2 = QStyleFactory::create("Windows");
- qApp->setStyle(style1);
+ QApplication::setStyle(style1);
// Basic sanity
QCOMPARE(QApplication::style(), style1.data());
- qApp->setStyle(style2);
+ QApplication::setStyle(style2);
QVERIFY(style1.isNull()); // qApp must have taken ownership and deleted it
// Setting null should not crash
- qApp->setStyle(0);
+ QApplication::setStyle(nullptr);
QCOMPARE(QApplication::style(), style2.data());
// Set the stylesheet
qApp->setStyleSheet("whatever");
- QPointer<QStyleSheetStyle> sss = (QStyleSheetStyle *)qApp->style();
+ QPointer<QStyleSheetStyle> sss = static_cast<QStyleSheetStyle *>(QApplication::style());
QVERIFY(!sss.isNull());
QCOMPARE(sss->metaObject()->className(), "QStyleSheetStyle"); // must be our proxy now
QVERIFY(!style2.isNull()); // this should exist as it is the base of the proxy
QCOMPARE(sss->baseStyle(), style2.data());
style1 = QStyleFactory::create("Windows");
- qApp->setStyle(style1);
+ QApplication::setStyle(style1);
QVERIFY(style2.isNull()); // should disappear automatically
QVERIFY(sss.isNull()); // should disappear automatically
// Update the stylesheet and check nothing changes
- sss = (QStyleSheetStyle *)qApp->style();
+ sss = static_cast<QStyleSheetStyle *>(QApplication::style());
qApp->setStyleSheet("whatever2");
QCOMPARE(QApplication::style(), sss.data());
QCOMPARE(sss->baseStyle(), style1.data());
@@ -577,14 +632,15 @@ void tst_QStyleSheetStyle::dynamicProperty()
{
qApp->setStyleSheet(QString());
- QString appStyle = qApp->style()->metaObject()->className();
+ QString appStyle = QApplication::style()->metaObject()->className();
QPushButton pb1(QStringLiteral("dynamicProperty_pb1"));
- pb1.setMinimumWidth(160);
- pb1.move(QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(20, 100));
+ pb1.setMinimumWidth(m_testSize.width());
+ pb1.move(m_availableGeometry.topLeft() + QPoint(20, 100));
QPushButton pb2(QStringLiteral("dynamicProperty_pb2"));
- pb2.setMinimumWidth(160);
- pb2.move(QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(20, 200));
+ pb2.setWindowTitle(QTest::currentTestFunction());
+ pb2.setMinimumWidth(m_testSize.width());
+ pb2.move(m_availableGeometry.topLeft() + QPoint(20, m_testSize.width() + 40));
pb1.setProperty("type", "critical");
qApp->setStyleSheet("*[class~=\"QPushButton\"] { color: red; } *[type=\"critical\"] { background: white; }");
@@ -625,7 +681,7 @@ namespace ns {
class PushButton1 : public QPushButton {
Q_OBJECT
public:
- PushButton1() { }
+ using QPushButton::QPushButton;
};
class PushButton2 : public PushButton1 {
Q_OBJECT
@@ -781,7 +837,7 @@ void tst_QStyleSheetStyle::onWidgetDestroyed()
qApp->setStyleSheet(QString());
QLabel *l = new QLabel;
l->setStyleSheet("QLabel { color: red }");
- QPointer<QStyleSheetStyle> ss = (QStyleSheetStyle *) l->style();
+ QPointer<QStyleSheetStyle> ss = static_cast<QStyleSheetStyle *>(l->style());
delete l;
QVERIFY(ss.isNull());
}
@@ -789,7 +845,8 @@ void tst_QStyleSheetStyle::onWidgetDestroyed()
void tst_QStyleSheetStyle::fontPrecedence()
{
QLineEdit edit;
- edit.setMinimumWidth(200);
+ edit.setWindowTitle(QTest::currentTestFunction());
+ edit.setMinimumWidth(m_testSize.width());
centerOnScreen(&edit);
edit.show();
QFont font;
@@ -817,23 +874,23 @@ void tst_QStyleSheetStyle::fontPrecedence()
}
// Ensure primary will only return true if the color covers more than 50% of pixels
-static bool testForColors(const QImage& image, const QColor& color, bool ensurePrimary=false)
+static bool testForColors(const QImage& image, const QColor &color, bool ensurePrimary = false)
{
int count = 0;
QRgb rgb = color.rgba();
- int totalCount = image.height()*image.width();
+ int totalCount = image.height() * image.width();
for (int y = 0; y < image.height(); ++y) {
for (int x = 0; x < image.width(); ++x) {
// Because of antialiasing we allow a certain range of errors here.
QRgb pixel = image.pixel(x, y);
- if (qAbs((int)(pixel & 0xff) - (int)(rgb & 0xff)) +
- qAbs((int)((pixel & 0xff00) >> 8) - (int)((rgb & 0xff00) >> 8)) +
- qAbs((int)((pixel & 0xff0000) >> 16) - (int)((rgb & 0xff0000) >> 16)) <= 50) {
+ if (qAbs(int(pixel & 0xff) - int(rgb & 0xff)) +
+ qAbs(int((pixel & 0xff00) >> 8) - int((rgb & 0xff00) >> 8)) +
+ qAbs(int((pixel & 0xff0000) >> 16) - int((rgb & 0xff0000) >> 16)) <= 50) {
count++;
if (!ensurePrimary && count >=10 )
return true;
- else if (count > totalCount/2)
+ if (count > totalCount / 2)
return true;
}
}
@@ -842,7 +899,8 @@ static bool testForColors(const QImage& image, const QColor& color, bool ensureP
return false;
}
-class TestDialog : public QDialog {
+class TestDialog : public QDialog
+{
public:
explicit TestDialog(const QString &styleSheet);
@@ -878,8 +936,8 @@ TestDialog::TestDialog(const QString &styleSheet) :
addWidget(spinbox);
QComboBox *combobox = new QComboBox;
combobox->setEditable(true);
- combobox->addItems(QStringList() << "TESTING TESTING");
- addWidget(spinbox);
+ combobox->addItems(QStringList{"TESTING TESTING"});
+ addWidget(combobox);
addWidget(new QLabel("<b>TESTING TESTING</b>"));
}
@@ -921,12 +979,12 @@ void tst_QStyleSheetStyle::focusColors()
QVERIFY2(testForColors(image, QColor(0xe8, 0xff, 0x66)),
(QString::fromLatin1(widget->metaObject()->className())
+ " did not contain background color #e8ff66, using style "
- + QString::fromLatin1(qApp->style()->metaObject()->className()))
+ + QString::fromLatin1(QApplication::style()->metaObject()->className()))
.toLocal8Bit().constData());
QVERIFY2(testForColors(image, QColor(0xff, 0x00, 0x84)),
(QString::fromLatin1(widget->metaObject()->className())
+ " did not contain text color #ff0084, using style "
- + QString::fromLatin1(qApp->style()->metaObject()->className()))
+ + QString::fromLatin1(QApplication::style()->metaObject()->className()))
.toLocal8Bit().constData());
}
}
@@ -1007,20 +1065,14 @@ class SingleInheritanceDialog : public QDialog
{
Q_OBJECT
public:
- SingleInheritanceDialog(QWidget *w = 0) :
- QDialog(w)
- {
- }
+ using QDialog::QDialog;
};
class DoubleInheritanceDialog : public SingleInheritanceDialog
{
Q_OBJECT
public:
- DoubleInheritanceDialog(QWidget *w = 0) :
- SingleInheritanceDialog(w)
- {
- }
+ using SingleInheritanceDialog::SingleInheritanceDialog;
};
void tst_QStyleSheetStyle::background()
@@ -1029,24 +1081,25 @@ void tst_QStyleSheetStyle::background()
const QString styleSheet = QStringLiteral("* { background-color: #e8ff66; }");
QVector<WidgetPtr> widgets;
- const QPoint topLeft = QGuiApplication::primaryScreen()->availableGeometry().topLeft();
+ const QPoint topLeft = m_availableGeometry.topLeft();
// Testing inheritance styling of QDialog.
WidgetPtr toplevel(new SingleInheritanceDialog);
- toplevel->resize(200, 200);
+ toplevel->resize(m_testSize);
toplevel->move(topLeft + QPoint(20, 20));
toplevel->setStyleSheet(styleSheet);
widgets.append(toplevel);
toplevel = WidgetPtr(new DoubleInheritanceDialog);
- toplevel->resize(200, 200);
- toplevel->move(topLeft + QPoint(20, 320));
+ toplevel->resize(m_testSize);
+ toplevel->move(topLeft + QPoint(20, m_testSize.height() + 120));
toplevel->setStyleSheet(styleSheet);
widgets.append(toplevel);
// Testing gradients in QComboBox.
// First color
toplevel = WidgetPtr(new QDialog);
- toplevel->move(topLeft + QPoint(320, 20));
+ toplevel->resize(m_testSize);
+ toplevel->move(topLeft + QPoint(m_testSize.width() + 120, 20));
QGridLayout *layout = new QGridLayout(toplevel.data());
QComboBox* cb = new QComboBox;
cb->setMinimumWidth(160);
@@ -1055,7 +1108,8 @@ void tst_QStyleSheetStyle::background()
widgets.append(toplevel);
// Second color
toplevel = WidgetPtr(new QDialog);
- toplevel->move(topLeft + QPoint(320, 320));
+ toplevel->resize(m_testSize);
+ toplevel->move(topLeft + QPoint(m_testSize.width() + 120, m_testSize.height() + 120));
layout = new QGridLayout(toplevel.data());
cb = new QComboBox;
cb->setMinimumWidth(160);
@@ -1086,9 +1140,10 @@ void tst_QStyleSheetStyle::background()
}
}
-void tst_QStyleSheetStyle::tabAlignement()
+void tst_QStyleSheetStyle::tabAlignment()
{
QWidget topLevel;
+ topLevel.setWindowTitle(QTest::currentTestFunction());
QTabWidget tabWidget(&topLevel);
tabWidget.addTab(new QLabel("tab1"),"tab1");
tabWidget.resize(QSize(400,400));
@@ -1148,6 +1203,8 @@ void tst_QStyleSheetStyle::attributesList()
void tst_QStyleSheetStyle::minmaxSizes()
{
QTabWidget tabWidget;
+ tabWidget.resize(m_testSize);
+ tabWidget.setWindowTitle(QTest::currentTestFunction());
tabWidget.setObjectName("tabWidget");
int index1 = tabWidget.addTab(new QLabel("Tab1"),"a");
@@ -1187,6 +1244,8 @@ void tst_QStyleSheetStyle::task206238_twice()
{
const QColor red(Qt::red);
QMainWindow w;
+ w.resize(m_testSize);
+ w.setWindowTitle(QTest::currentTestFunction());
QTabWidget* tw = new QTabWidget;
tw->addTab(new QLabel("foo"), "test");
w.setCentralWidget(tw);
@@ -1220,6 +1279,8 @@ void tst_QStyleSheetStyle::transparent()
class ProxyStyle : public QStyle
{
+ Q_OBJECT
+
public:
ProxyStyle(QStyle *s)
{
@@ -1227,19 +1288,19 @@ class ProxyStyle : public QStyle
}
void drawControl(ControlElement ce, const QStyleOption *opt,
- QPainter *painter, const QWidget *widget = 0) const;
+ QPainter *painter, const QWidget *widget = nullptr) const override;
void drawPrimitive(QStyle::PrimitiveElement pe,
const QStyleOption* opt,
- QPainter* p ,
- const QWidget* w) const
+ QPainter *p,
+ const QWidget *w) const override
{
style->drawPrimitive(pe, opt, p, w);
}
QRect subElementRect(QStyle::SubElement se,
- const QStyleOption* opt,
- const QWidget* w) const
+ const QStyleOption *opt,
+ const QWidget *w) const override
{
Q_UNUSED(se);
Q_UNUSED(opt);
@@ -1248,64 +1309,64 @@ class ProxyStyle : public QStyle
}
void drawComplexControl(QStyle::ComplexControl cc,
- const QStyleOptionComplex* opt,
- QPainter* p,
- const QWidget* w) const
+ const QStyleOptionComplex *opt,
+ QPainter *p,
+ const QWidget *w) const override
{
style->drawComplexControl(cc, opt, p, w);
}
SubControl hitTestComplexControl(QStyle::ComplexControl cc,
- const QStyleOptionComplex* opt,
- const QPoint& pt,
- const QWidget* w) const
+ const QStyleOptionComplex *opt,
+ const QPoint &pt,
+ const QWidget *w) const override
{
return style->hitTestComplexControl(cc, opt, pt, w);
}
QRect subControlRect(QStyle::ComplexControl cc,
- const QStyleOptionComplex* opt,
+ const QStyleOptionComplex *opt,
QStyle::SubControl sc,
- const QWidget* w) const
+ const QWidget *w) const override
{
return style->subControlRect(cc, opt, sc, w);
}
int pixelMetric(QStyle::PixelMetric pm,
- const QStyleOption* opt,
- const QWidget* w) const
+ const QStyleOption *opt,
+ const QWidget *w) const override
{
return style->pixelMetric(pm, opt, w);
}
QSize sizeFromContents(QStyle::ContentsType ct,
- const QStyleOption* opt,
- const QSize& size,
- const QWidget* w) const
+ const QStyleOption *opt,
+ const QSize &size,
+ const QWidget *w) const override
{
return style->sizeFromContents(ct, opt, size, w);
}
int styleHint(QStyle::StyleHint sh,
- const QStyleOption* opt,
- const QWidget* w,
- QStyleHintReturn* shr) const
+ const QStyleOption *opt,
+ const QWidget *w,
+ QStyleHintReturn *shr) const override
{
return style->styleHint(sh, opt, w, shr);
}
QPixmap standardPixmap(QStyle::StandardPixmap spix,
- const QStyleOption* opt,
- const QWidget* w) const
+ const QStyleOption *opt,
+ const QWidget *w) const override
{
return style->standardPixmap(spix, opt, w);
}
QPixmap generatedIconPixmap(QIcon::Mode mode,
- const QPixmap& pix,
- const QStyleOption* opt) const
+ const QPixmap &pix,
+ const QStyleOption *opt) const override
{
return style->generatedIconPixmap(mode, pix, opt);
}
@@ -1314,14 +1375,14 @@ class ProxyStyle : public QStyle
QSizePolicy::ControlType c2,
Qt::Orientation ori,
const QStyleOption *opt,
- const QWidget *w) const
+ const QWidget *w) const override
{
return style->layoutSpacing(c1, c2, ori, opt, w);
}
QIcon standardIcon(StandardPixmap si,
const QStyleOption *opt,
- const QWidget *w) const
+ const QWidget *w) const override
{
return style->standardIcon(si, opt, w);
}
@@ -1357,15 +1418,15 @@ void tst_QStyleSheetStyle::proxyStyle()
{
//Should not crash; task 158984
- ProxyStyle *proxy = new ProxyStyle(qApp->style());
+ ProxyStyle *proxy = new ProxyStyle(QApplication::style());
QString styleSheet("QPushButton {background-color: red; }");
QWidget *w = new QWidget;
- w->setMinimumWidth(160);
+ w->setMinimumWidth(m_testSize.width());
centerOnScreen(w);
QVBoxLayout *layout = new QVBoxLayout(w);
- QPushButton *pb1 = new QPushButton(qApp->style()->objectName(), w);
+ QPushButton *pb1 = new QPushButton(QApplication::style()->objectName(), w);
layout->addWidget(pb1);
QPushButton *pb2 = new QPushButton("ProxyStyle", w);
@@ -1383,7 +1444,7 @@ void tst_QStyleSheetStyle::proxyStyle()
// In this case it would be the QStyleSheetStyle that is deleted
// later on. We need to get access to the "real" QStyle to be able to
// draw correctly.
- ProxyStyle* newProxy = new ProxyStyle(qApp->style());
+ ProxyStyle *newProxy = new ProxyStyle(QApplication::style());
pb4->setStyle(newProxy);
layout->addWidget(pb4);
@@ -1421,6 +1482,7 @@ void tst_QStyleSheetStyle::emptyStyleSheet()
//empty stylesheet should not change anything
qApp->setStyleSheet(QString());
QWidget w;
+ w.setWindowTitle(QTest::currentTestFunction());
QHBoxLayout layout(&w);
w.setLayout(&layout);
layout.addWidget(new QPushButton("push", &w));
@@ -1479,6 +1541,8 @@ void tst_QStyleSheetStyle::toolTip()
{
qApp->setStyleSheet(QString());
QWidget w;
+ w.resize(m_testSize);
+ w.setWindowTitle(QTest::currentTestFunction());
// Use "Fusion" to prevent the Vista style from clobbering the tooltip palette in polish().
QStyle *fusionStyle = QStyleFactory::create(QLatin1String("Fusion"));
QVERIFY(fusionStyle);
@@ -1512,28 +1576,27 @@ void tst_QStyleSheetStyle::toolTip()
centerOnScreen(&w);
w.show();
- qApp->setActiveWindow(&w);
+ QApplication::setActiveWindow(&w);
QVERIFY(QTest::qWaitForWindowActive(&w));
const QColor normalToolTip = QToolTip::palette().color(QPalette::Inactive, QPalette::ToolTipBase);
- QList<QWidget *> widgets;
- QList<QColor> colors;
-
-
- //tooltip on the widget without stylesheet, then to othes widget, including one without stylesheet
- //(the tooltip will be reused but his colour must change)
- widgets << wid4 << wid1 << wid2 << wid3 << wid4;
- colors << normalToolTip << "#ae2" << "#f81" << "#0b8" << normalToolTip;
-
- for (int i = 0; i < widgets.count() ; i++)
- {
+ // Tooltip on the widget without stylesheet, then to other widget,
+ // including one without stylesheet (the tooltip will be reused,
+ // but its color must change)
+ const QWidgetList widgets{wid4, wid1, wid2, wid3, wid4};
+ const QVector<QColor> colors{normalToolTip, QColor("#ae2"), QColor("#f81"),
+ QColor("#0b8"), normalToolTip};
+
+ QWidgetList topLevels;
+ for (int i = 0; i < widgets.count() ; ++i) {
QWidget *wid = widgets.at(i);
QColor col = colors.at(i);
QToolTip::showText( QPoint(0,0) , "This is " + wid->objectName(), wid);
- QWidget *tooltip = 0;
- foreach (QWidget *widget, QApplication::topLevelWidgets()) {
+ topLevels = QApplication::topLevelWidgets();
+ QWidget *tooltip = nullptr;
+ for (QWidget *widget : qAsConst(topLevels)) {
if (widget->inherits("QTipLabel")) {
tooltip = widget;
break;
@@ -1548,17 +1611,18 @@ void tst_QStyleSheetStyle::toolTip()
QTest::qWait(100);
delete wid3; //should not crash;
QTest::qWait(10);
- foreach (QWidget *widget, QApplication::topLevelWidgets()) {
+ topLevels = QApplication::topLevelWidgets();
+ for (QWidget *widget : qAsConst(topLevels))
widget->update(); //should not crash either
- }
}
void tst_QStyleSheetStyle::embeddedFonts()
{
//task 235622 and 210551
QSpinBox spin;
- spin.setMinimumWidth(160);
- spin.move(QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(20, 20));
+ spin.setWindowTitle(QTest::currentTestFunction());
+ spin.setMinimumWidth(m_testSize.width());
+ spin.move(m_availableGeometry.topLeft() + QPoint(20, 20));
spin.show();
spin.setStyleSheet("QSpinBox { font-size: 32px; }");
QTest::qWait(20);
@@ -1579,7 +1643,7 @@ void tst_QStyleSheetStyle::embeddedFonts()
//task 242556
QComboBox box;
box.setMinimumWidth(160);
- box.move(QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(20, 120));
+ box.move(m_availableGeometry.topLeft() + QPoint(20, 120));
box.setEditable(true);
box.addItems(QStringList() << "First" << "Second" << "Third");
box.setStyleSheet("QComboBox { font-size: 32px; }");
@@ -1636,19 +1700,17 @@ void tst_QStyleSheetStyle::complexWidgetFocus()
// For this reason, we use unusual and extremely ugly colors! :-)
QDialog frame;
+ frame.setWindowTitle(QTest::currentTestFunction());
frame.setStyleSheet("*:focus { background: black; color: black } "
"QSpinBox::up-arrow:focus, QSpinBox::down-arrow:focus { width: 7px; height: 7px; background: #ff0084 } "
"QComboBox::down-arrow:focus { width: 7px; height: 7px; background: #ff0084 }"
"QSlider::handle:horizontal:focus { width: 7px; height: 7px; background: #ff0084 } ");
- QList<QWidget *> widgets;
- widgets << new QSpinBox;
- widgets << new QComboBox;
- widgets << new QSlider(Qt::Horizontal);
+ const QWidgetList widgets{new QSpinBox, new QComboBox, new QSlider(Qt::Horizontal)};
QLayout* layout = new QGridLayout;
layout->addWidget(new QLineEdit); // Avoids initial focus.
- foreach (QWidget *widget, widgets)
+ for (QWidget *widget : widgets)
layout->addWidget(widget);
frame.setLayout(layout);
@@ -1656,7 +1718,7 @@ void tst_QStyleSheetStyle::complexWidgetFocus()
frame.show();
QApplication::setActiveWindow(&frame);
QVERIFY(QTest::qWaitForWindowActive(&frame));
- foreach (QWidget *widget, widgets) {
+ for (QWidget *widget : widgets) {
widget->setFocus();
QApplication::processEvents();
@@ -1668,7 +1730,7 @@ void tst_QStyleSheetStyle::complexWidgetFocus()
QVERIFY2(testForColors(image, QColor(0xff, 0x00, 0x84)),
(QString::fromLatin1(widget->metaObject()->className())
+ " did not contain text color #ff0084, using style "
- + QString::fromLatin1(qApp->style()->metaObject()->className()))
+ + QString::fromLatin1(QApplication::style()->metaObject()->className()))
.toLocal8Bit().constData());
}
}
@@ -1676,8 +1738,9 @@ void tst_QStyleSheetStyle::complexWidgetFocus()
void tst_QStyleSheetStyle::task188195_baseBackground()
{
QTreeView tree;
+ tree.setWindowTitle(QTest::currentTestFunction());
tree.setStyleSheet( "QTreeView:disabled { background-color:#ab1251; }" );
- tree.move(QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(20, 100));
+ tree.setGeometry(QRect(m_availableGeometry.topLeft() + QPoint(20, 100), m_testSize));
tree.show();
QVERIFY(QTest::qWaitForWindowActive(&tree));
QImage image(tree.width(), tree.height(), QImage::Format_ARGB32);
@@ -1698,7 +1761,8 @@ void tst_QStyleSheetStyle::task188195_baseBackground()
QTableWidget table(12, 12);
table.setItem(0, 0, new QTableWidgetItem());
table.setStyleSheet( "QTableView {background-color: #ff0000}" );
- table.move(QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(300, 100));
+ // This needs to be large so that >50% (excluding header rows/columns) are red.
+ table.setGeometry(QRect(m_availableGeometry.topLeft() + QPoint(300, 100), m_testSize * 2));
table.show();
QVERIFY(QTest::qWaitForWindowActive(&table));
image = QImage(table.width(), table.height(), QImage::Format_ARGB32);
@@ -1720,6 +1784,7 @@ void tst_QStyleSheetStyle::task232085_spinBoxLineEditBg()
spinbox->setValue(8888);
QDialog frame;
+ frame.setWindowTitle(QTest::currentTestFunction());
QLayout* layout = new QGridLayout;
QLineEdit* dummy = new QLineEdit; // Avoids initial focus.
@@ -1746,18 +1811,19 @@ void tst_QStyleSheetStyle::task232085_spinBoxLineEditBg()
QVERIFY2(testForColors(image, QColor(0xe8, 0xff, 0x66)),
(QString::fromLatin1(spinbox->metaObject()->className())
+ " did not contain background color #e8ff66, using style "
- + QString::fromLatin1(qApp->style()->metaObject()->className()))
+ + QString::fromLatin1(QApplication::style()->metaObject()->className()))
.toLocal8Bit().constData());
QVERIFY2(testForColors(image, QColor(0xff, 0x00, 0x84)),
(QString::fromLatin1(spinbox->metaObject()->className())
+ " did not contain text color #ff0084, using style "
- + QString::fromLatin1(qApp->style()->metaObject()->className()))
+ + QString::fromLatin1(QApplication::style()->metaObject()->className()))
.toLocal8Bit().constData());
}
class ChangeEventWidget : public QWidget
-{ public:
- void changeEvent(QEvent * event)
+{
+protected:
+ void changeEvent(QEvent *event) override
{
if(event->type() == QEvent::StyleChange) {
static bool recurse = false;
@@ -1789,10 +1855,10 @@ void tst_QStyleSheetStyle::QTBUG11658_cachecrash()
class Widget : public QWidget
{
public:
- Widget(QWidget *parent = 0)
+ Widget(int minimumWidth, QWidget *parent = nullptr)
: QWidget(parent)
{
- setMinimumWidth(160);
+ setMinimumWidth(minimumWidth);
QVBoxLayout* pLayout = new QVBoxLayout(this);
QCheckBox* pCheckBox = new QCheckBox(this);
pLayout->addWidget(pCheckBox);
@@ -1800,13 +1866,14 @@ void tst_QStyleSheetStyle::QTBUG11658_cachecrash()
QString szStyleSheet = QLatin1String("* { color: red; }");
qApp->setStyleSheet(szStyleSheet);
- qApp->setStyle(QStyleFactory::create(QLatin1String("Windows")));
+ QApplication::setStyle(QStyleFactory::create(QLatin1String("Windows")));
}
};
- Widget *w = new Widget();
+ Widget *w = new Widget(m_testSize.width());
delete w;
- w = new Widget();
+ w = new Widget(m_testSize.width());
+ w->setWindowTitle(QTest::currentTestFunction());
centerOnScreen(w);
w->show();
@@ -1818,15 +1885,17 @@ void tst_QStyleSheetStyle::QTBUG11658_cachecrash()
void tst_QStyleSheetStyle::QTBUG15910_crashNullWidget()
{
struct Widget : QWidget {
- virtual void paintEvent(QPaintEvent* ) {
+ void paintEvent(QPaintEvent *) override
+ {
QStyleOption opt;
opt.init(this);
QPainter p(this);
- style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, 0);
- style()->drawPrimitive(QStyle::PE_Frame, &opt, &p, 0);
- style()->drawControl(QStyle::CE_PushButton, &opt, &p, 0);
+ style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, nullptr);
+ style()->drawPrimitive(QStyle::PE_Frame, &opt, &p, nullptr);
+ style()->drawControl(QStyle::CE_PushButton, &opt, &p, nullptr);
}
} w;
+ w.setWindowTitle(QTest::currentTestFunction());
w.setStyleSheet("* { background-color: white; color:black; border 3px solid yellow }");
w.setMinimumWidth(160);
centerOnScreen(&w);
@@ -1840,10 +1909,13 @@ void tst_QStyleSheetStyle::QTBUG36933_brokenPseudoClassLookup()
const int columnCount = 10;
QTableWidget widget(rowCount, columnCount);
+ widget.resize(m_testSize);
+ widget.setWindowTitle(QTest::currentTestFunction());
for (int row = 0; row < rowCount; ++row) {
+ const QString rowNumber = QLatin1String("row ") + QString::number(row + 1);
for (int column = 0; column < columnCount; ++column) {
- const QString t = QLatin1String("row ") + QString::number(row + 1)
+ const QString t = rowNumber
+ QLatin1String(" column ") + QString::number(column + 1);
widget.setItem(row, column, new QTableWidgetItem(t));
}
@@ -1874,14 +1946,15 @@ void tst_QStyleSheetStyle::QTBUG36933_brokenPseudoClassLookup()
void tst_QStyleSheetStyle::styleSheetChangeBeforePolish()
{
QWidget widget;
+ widget.setWindowTitle(QTest::currentTestFunction());
QVBoxLayout *vbox = new QVBoxLayout(&widget);
QFrame *frame = new QFrame(&widget);
- frame->setFixedSize(200, 200);
+ frame->setFixedSize(m_testSize);
frame->setStyleSheet("background-color: #FF0000;");
frame->setStyleSheet("background-color: #00FF00;");
vbox->addWidget(frame);
QFrame *frame2 = new QFrame(&widget);
- frame2->setFixedSize(200, 200);
+ frame2->setFixedSize(m_testSize);
frame2->setStyleSheet("background-color: #FF0000;");
frame2->setStyleSheet("background-color: #00FF00;");
vbox->addWidget(frame);
@@ -2106,6 +2179,8 @@ void tst_QStyleSheetStyle::highdpiImages()
QFETCH(QColor, color);
QWidget w;
+ w.setWindowTitle(QLatin1String(QTest::currentTestFunction()) + QLatin1String("::")
+ + QLatin1String(QTest::currentDataTag()));
QScreen *screen = QGuiApplication::primaryScreen();
w.move(screen->availableGeometry().topLeft());
QHighDpiScaling::setScreenFactor(screen, screenFactor);
diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
index 5a51f15008..4ccbe42353 100644
--- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
@@ -107,8 +107,10 @@ private slots:
void csMatchingOnCiSortedModel_data();
void csMatchingOnCiSortedModel();
+#if QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15)
void directoryModel_data();
void directoryModel();
+#endif
void fileSystemModel_data();
void fileSystemModel();
@@ -224,9 +226,14 @@ void tst_QCompleter::setSourceModel(ModelType type)
parent->setText(completionColumn, QLatin1String("p2,c4p2"));
break;
case DIRECTORY_MODEL:
+#if QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
completer->setCsvCompletion(false);
completer->setModel(new QDirModel(completer));
completer->setCompletionColumn(0);
+QT_WARNING_POP
+#endif // QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15)
break;
case FILESYSTEM_MODEL:
completer->setCsvCompletion(false);
@@ -590,6 +597,7 @@ void tst_QCompleter::csMatchingOnCiSortedModel()
filter();
}
+#if QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15)
void tst_QCompleter::directoryModel_data()
{
delete completer;
@@ -639,6 +647,7 @@ void tst_QCompleter::directoryModel()
#endif
filter();
}
+#endif // QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15)
void tst_QCompleter::fileSystemModel_data()
{
@@ -1057,15 +1066,15 @@ void tst_QCompleter::setters()
delete completer;
completer = new CsvCompleter;
QVERIFY(completer->popup() != nullptr);
- QPointer<QDirModel> dirModel = new QDirModel(completer);
+ QPointer<QStandardItemModel> itemModel(new QStandardItemModel(1, 0, completer));
QAbstractItemModel *oldModel = completer->model();
- completer->setModel(dirModel);
+ completer->setModel(itemModel.data());
QVERIFY(completer->popup()->model() != oldModel);
QCOMPARE(completer->popup()->model(), completer->completionModel());
completer->setPopup(new QListView);
QCOMPARE(completer->popup()->model(), completer->completionModel());
completer->setModel(new QStringListModel(completer));
- QVERIFY(dirModel == nullptr); // must have been deleted
+ QVERIFY(itemModel.isNull()); // must have been deleted
completer->setModel(nullptr);
completer->setWidget(nullptr);
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
index 1c68a5f752..0cfbc651ad 100644
--- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
@@ -4860,6 +4860,7 @@ void tst_QLineEdit::inputRejected()
QCOMPARE(spyInputRejected.count(), 0);
QTest::keyClicks(testWidget, "fgh");
QCOMPARE(spyInputRejected.count(), 3);
+#if QT_CONFIG(clipboard)
testWidget->clear();
spyInputRejected.clear();
QApplication::clipboard()->setText("ijklmno");
@@ -4867,6 +4868,7 @@ void tst_QLineEdit::inputRejected()
// The first 5 characters are accepted, but
// the last 2 are not.
QCOMPARE(spyInputRejected.count(), 1);
+#endif
testWidget->setMaxLength(INT_MAX);
testWidget->clear();
@@ -4877,11 +4879,13 @@ void tst_QLineEdit::inputRejected()
QCOMPARE(spyInputRejected.count(), 0);
QTest::keyClicks(testWidget, "a#");
QCOMPARE(spyInputRejected.count(), 2);
+#if QT_CONFIG(clipboard)
testWidget->clear();
spyInputRejected.clear();
QApplication::clipboard()->setText("a#");
testWidget->paste();
QCOMPARE(spyInputRejected.count(), 1);
+#endif
testWidget->clear();
testWidget->setValidator(0);