diff options
Diffstat (limited to 'tests/auto')
74 files changed, 1284 insertions, 893 deletions
diff --git a/tests/auto/corelib/animation/qpauseanimation/BLACKLIST b/tests/auto/corelib/animation/qpauseanimation/BLACKLIST index 53372ce9ae..33cd53d788 100644 --- a/tests/auto/corelib/animation/qpauseanimation/BLACKLIST +++ b/tests/auto/corelib/animation/qpauseanimation/BLACKLIST @@ -1,9 +1,5 @@ [pauseAndPropertyAnimations] -osx-10.12 -osx-10.14 -osx-10.13 +osx [multipleSequentialGroups] -osx-10.12 -osx-10.14 -osx-10.13 +osx diff --git a/tests/auto/corelib/io/qfilesystemwatcher/BLACKLIST b/tests/auto/corelib/io/qfilesystemwatcher/BLACKLIST index 9b210b0d5f..457499591d 100644 --- a/tests/auto/corelib/io/qfilesystemwatcher/BLACKLIST +++ b/tests/auto/corelib/io/qfilesystemwatcher/BLACKLIST @@ -1,9 +1,7 @@ # QTBUG-33574 QTBUG-30943 [signalsEmittedAfterFileMoved] -windows-10 msvc-2017 -windows-10 msvc-2019 -windows-10 msvc-2015 windows-7sp1 +windows-10 [watchFileAndItsDirectory:native backend-testfile] osx windows diff --git a/tests/auto/corelib/io/qprocess/BLACKLIST b/tests/auto/corelib/io/qprocess/BLACKLIST index aa9fdab64d..682bcbc60c 100644 --- a/tests/auto/corelib/io/qprocess/BLACKLIST +++ b/tests/auto/corelib/io/qprocess/BLACKLIST @@ -2,6 +2,5 @@ redhatenterpriselinuxworkstation-6.6 # QTBUG-48455 [fileWriterProcess] -windows-10 msvc-2015 windows-10 msvc-2017 diff --git a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp index 3a4493474b..f305edb2c5 100644 --- a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp +++ b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp @@ -1830,7 +1830,7 @@ void ListenerObject::slotAboutToBeReset() void ListenerObject::slotReset() { - foreach (const QModelIndex &idx, m_persistentIndexes) { + for (const auto &idx : qAsConst(m_persistentIndexes)) { QVERIFY(!idx.isValid()); } } diff --git a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp index f78f5bc138..c74101928a 100644 --- a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp @@ -32,6 +32,9 @@ #include <algorithm> +Q_DECLARE_METATYPE(QItemSelectionModel::SelectionFlag) +Q_DECLARE_METATYPE(Qt::SortOrder) + class tst_QItemSelectionModel : public QObject { Q_OBJECT @@ -1463,7 +1466,7 @@ void tst_QItemSelectionModel::persistentselections() QFETCH(IntList, insertColumns); QFETCH(IntList, deleteRows); QFETCH(IntList, deleteColumns); - QFETCH(PairList, expectedList); + QFETCH(const PairList, expectedList); // make sure the model is sane (5x5) QCOMPARE(model->rowCount(QModelIndex()), 5); @@ -1504,7 +1507,7 @@ void tst_QItemSelectionModel::persistentselections() // check that the selected items are the correct number and indexes QModelIndexList selectedList = selection->selectedIndexes(); QCOMPARE(selectedList.count(), expectedList.count()); - foreach(IntPair pair, expectedList) { + for (const auto &pair : expectedList) { QModelIndex index = model->index(pair.first, pair.second, QModelIndex()); QVERIFY(selectedList.contains(index)); } @@ -1679,7 +1682,7 @@ void tst_QItemSelectionModel::modelLayoutChanged_data() { QTest::addColumn<IntListList>("items"); QTest::addColumn<IntPairPairList>("initialSelectedRanges"); - QTest::addColumn<int>("sortOrder"); + QTest::addColumn<Qt::SortOrder>("sortOrder"); QTest::addColumn<int>("sortColumn"); QTest::addColumn<IntPairPairList>("expectedSelectedRanges"); @@ -1689,7 +1692,7 @@ void tst_QItemSelectionModel::modelLayoutChanged_data() << (IntList() << 3 << 2 << 1 << 0)) << (IntPairPairList() << IntPairPair(IntPair(0, 0), IntPair(3, 1))) - << int(Qt::DescendingOrder) + << Qt::DescendingOrder << 0 << (IntPairPairList() << IntPairPair(IntPair(0, 0), IntPair(3, 1))); @@ -1699,7 +1702,7 @@ void tst_QItemSelectionModel::modelLayoutChanged_data() << (IntList() << 3 << 2 << 1 << 0)) << (IntPairPairList() << IntPairPair(IntPair(0, 0), IntPair(1, 1))) - << int(Qt::DescendingOrder) + << Qt::DescendingOrder << 0 << (IntPairPairList() << IntPairPair(IntPair(2, 0), IntPair(3, 1))); @@ -1709,7 +1712,7 @@ void tst_QItemSelectionModel::modelLayoutChanged_data() << (IntList() << 3 << 2 << 1 << 0)) << (IntPairPairList() << IntPairPair(IntPair(1, 0), IntPair(2, 1))) - << int(Qt::DescendingOrder) + << Qt::DescendingOrder << 0 << (IntPairPairList() << IntPairPair(IntPair(1, 0), IntPair(2, 1))); @@ -1720,7 +1723,7 @@ void tst_QItemSelectionModel::modelLayoutChanged_data() << (IntPairPairList() << IntPairPair(IntPair(1, 0), IntPair(1, 1)) << IntPairPair(IntPair(3, 0), IntPair(3, 1))) - << int(Qt::AscendingOrder) + << Qt::AscendingOrder << 0 << (IntPairPairList() << IntPairPair(IntPair(0, 0), IntPair(0, 1)) @@ -1730,8 +1733,8 @@ void tst_QItemSelectionModel::modelLayoutChanged_data() void tst_QItemSelectionModel::modelLayoutChanged() { QFETCH(IntListList, items); - QFETCH(IntPairPairList, initialSelectedRanges); - QFETCH(int, sortOrder); + QFETCH(const IntPairPairList, initialSelectedRanges); + QFETCH(Qt::SortOrder, sortOrder); QFETCH(int, sortColumn); QFETCH(IntPairPairList, expectedSelectedRanges); @@ -1746,9 +1749,9 @@ void tst_QItemSelectionModel::modelLayoutChanged() // select initial ranges QItemSelectionModel selectionModel(&model); - foreach (IntPairPair range, initialSelectedRanges) { - IntPair tl = range.first; - IntPair br = range.second; + for (const auto &range : initialSelectedRanges) { + const auto &tl = range.first; + const auto &br = range.second; QItemSelection selection( model.index(tl.first, tl.second), model.index(br.first, br.second)); @@ -1756,7 +1759,7 @@ void tst_QItemSelectionModel::modelLayoutChanged() } // sort the model - model.sort(sortColumn, Qt::SortOrder(sortOrder)); + model.sort(sortColumn, sortOrder); // verify that selection is as expected QItemSelection selection = selectionModel.selection(); @@ -2126,43 +2129,43 @@ void tst_QItemSelectionModel::merge_data() { QTest::addColumn<QItemSelection>("init"); QTest::addColumn<QItemSelection>("other"); - QTest::addColumn<int>("command"); + QTest::addColumn<QItemSelectionModel::SelectionFlag>("command"); QTest::addColumn<QItemSelection>("result"); QTest::newRow("Simple select") << QItemSelection() << QItemSelection(model->index(2, 1) , model->index(3, 4)) - << int(QItemSelectionModel::Select) + << QItemSelectionModel::Select << QItemSelection(model->index(2, 1) , model->index(3, 4)); QTest::newRow("Simple deselect") << QItemSelection(model->index(2, 1) , model->index(3, 4)) << QItemSelection(model->index(2, 1) , model->index(3, 4)) - << int(QItemSelectionModel::Deselect) + << QItemSelectionModel::Deselect << QItemSelection(); QTest::newRow("Simple Toggle deselect") << QItemSelection(model->index(2, 1) , model->index(3, 4)) << QItemSelection(model->index(2, 1) , model->index(3, 4)) - << int(QItemSelectionModel::Toggle) + << QItemSelectionModel::Toggle << QItemSelection(); QTest::newRow("Simple Toggle select") << QItemSelection() << QItemSelection(model->index(2, 1) , model->index(3, 4)) - << int(QItemSelectionModel::Toggle) + << QItemSelectionModel::Toggle << QItemSelection(model->index(2, 1) , model->index(3, 4)); QTest::newRow("Add select") << QItemSelection(model->index(2, 1) , model->index(3, 3)) << QItemSelection(model->index(2, 2) , model->index(3, 4)) - << int(QItemSelectionModel::Select) + << QItemSelectionModel::Select << QItemSelection(model->index(2, 1) , model->index(3, 4)); QTest::newRow("Deselect") << QItemSelection(model->index(2, 1) , model->index(3, 4)) << QItemSelection(model->index(2, 2) , model->index(3, 4)) - << int(QItemSelectionModel::Deselect) + << QItemSelectionModel::Deselect << QItemSelection(model->index(2, 1) , model->index(3, 1)); QItemSelection r1(model->index(2, 1) , model->index(3, 1)); @@ -2170,7 +2173,7 @@ void tst_QItemSelectionModel::merge_data() QTest::newRow("Toggle") << QItemSelection(model->index(2, 1) , model->index(3, 3)) << QItemSelection(model->index(2, 2) , model->index(3, 4)) - << int(QItemSelectionModel::Toggle) + << QItemSelectionModel::Toggle << r1; } @@ -2178,15 +2181,18 @@ void tst_QItemSelectionModel::merge() { QFETCH(QItemSelection, init); QFETCH(QItemSelection, other); - QFETCH(int, command); + QFETCH(QItemSelectionModel::SelectionFlag, command); QFETCH(QItemSelection, result); - init.merge(other, QItemSelectionModel::SelectionFlags(command)); + init.merge(other, command); - foreach(const QModelIndex &idx, init.indexes()) - QVERIFY(result.contains(idx)); - foreach(const QModelIndex &idx, result.indexes()) - QVERIFY(init.contains(idx)); + auto verify = [](const QModelIndexList &a, const QItemSelection &b) + { + for (const QModelIndex &idx : a) + QVERIFY(b.contains(idx)); + }; + verify(init.indexes(), result); + verify(result.indexes(), init); } void tst_QItemSelectionModel::isRowSelected() @@ -2267,13 +2273,12 @@ void tst_QItemSelectionModel::layoutChangedWithAllSelected1() proxy.setFilterRegularExpression(QRegularExpression("f")); QCOMPARE(proxy.rowCount(), 2); - QList<QPersistentModelIndex> indexList; - indexList << proxy.index(0,0) << proxy.index(1,0); - selection.select( QItemSelection(indexList.first(), indexList.last()), QItemSelectionModel::Select); + const QList<QPersistentModelIndex> indexList({proxy.index(0,0), proxy.index(1,0)}); + selection.select(QItemSelection(indexList.first(), indexList.last()), QItemSelectionModel::Select); //let's check the selection hasn't changed QCOMPARE(selection.selectedIndexes().count(), indexList.count()); - foreach(QPersistentModelIndex index, indexList) + for (const auto &index : indexList) QVERIFY(selection.isSelected(index)); proxy.setFilterRegularExpression(QRegularExpression()); @@ -2281,7 +2286,7 @@ void tst_QItemSelectionModel::layoutChangedWithAllSelected1() //let's check the selection hasn't changed QCOMPARE(selection.selectedIndexes().count(), indexList.count()); - foreach(QPersistentModelIndex index, indexList) + for (const auto &index : indexList) QVERIFY(selection.isSelected(index)); } @@ -2321,9 +2326,8 @@ void tst_QItemSelectionModel::layoutChangedWithAllSelected2() selection.select( QItemSelection(proxy.index(0,0), proxy.index(proxy.rowCount() - 1, proxy.columnCount() - 1)), QItemSelectionModel::Select); - QList<QPersistentModelIndex> indexList; - foreach(const QModelIndex &id, selection.selectedIndexes()) - indexList << id; + const auto selIndexes = selection.selectedIndexes(); + const QList<QPersistentModelIndex> indexList(selIndexes.begin(), selIndexes.end()); proxy.filtering = false; proxy.invalidate(); @@ -2331,7 +2335,7 @@ void tst_QItemSelectionModel::layoutChangedWithAllSelected2() //let's check the selection hasn't changed QCOMPARE(selection.selectedIndexes().count(), indexList.count()); - foreach(QPersistentModelIndex index, indexList) + for (const auto &index : indexList) QVERIFY(selection.isSelected(index)); } @@ -2375,7 +2379,8 @@ public: public slots: void selectionChanged(const QItemSelection & /* selected */, const QItemSelection &deselected) { - foreach(const QModelIndex &index, deselected.indexes()) { + const auto deselIndexes = deselected.indexes(); + for (const auto &index : deselIndexes) { QVERIFY(!m_itemSelectionModel->selection().contains(index)); } QCOMPARE(m_itemSelectionModel->selection().size(), 2); @@ -2633,9 +2638,9 @@ private slots: void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) { - foreach(const QItemSelectionRange &range, selected) + for (const auto &range : selected) QVERIFY(range.isValid()); - foreach(const QItemSelectionRange &range, deselected) + for (const auto &range : deselected) QVERIFY(range.isValid()); } diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp index 0f7588a71a..624187349b 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp @@ -829,7 +829,7 @@ void tst_QSortFilterProxyModel::removeRows_data() void tst_QSortFilterProxyModel::removeRows() { - QFETCH(QStringList, initial); + QFETCH(const QStringList, initial); QFETCH(int, sortOrder); QFETCH(QString, filter); QFETCH(int, position); @@ -843,7 +843,7 @@ void tst_QSortFilterProxyModel::removeRows() proxy.setSourceModel(&model); // prepare model - foreach (QString s, initial) + for (const auto &s : initial) model.appendRow(new QStandardItem(s)); if (sortOrder != -1) @@ -3035,15 +3035,15 @@ void tst_QSortFilterProxyModel::removeRowsRecursive() QList<QPersistentModelIndex> sourceIndexes; QList<QPersistentModelIndex> proxyIndexes; - foreach (QStandardItem *item, items) { + for (const auto item : qAsConst(items)) { QModelIndex idx = item->index(); sourceIndexes << idx; proxyIndexes << proxy.mapFromSource(idx); } - foreach (const QPersistentModelIndex &pidx, sourceIndexes) + for (const auto &pidx : qAsConst(sourceIndexes)) QVERIFY(pidx.isValid()); - foreach (const QPersistentModelIndex &pidx, proxyIndexes) + for (const auto &pidx : qAsConst(proxyIndexes)) QVERIFY(pidx.isValid()); QList<QStandardItem*> itemRow = pItem1->takeRow(0); @@ -3051,9 +3051,9 @@ void tst_QSortFilterProxyModel::removeRowsRecursive() QCOMPARE(itemRow.count(), 1); QCOMPARE(itemRow.first(), pItem11); - foreach (const QPersistentModelIndex &pidx, sourceIndexes) + for (const auto &pidx : qAsConst(sourceIndexes)) QVERIFY(!pidx.isValid()); - foreach (const QPersistentModelIndex &pidx, proxyIndexes) + for (const auto &pidx : qAsConst(proxyIndexes)) QVERIFY(!pidx.isValid()); delete pItem11; @@ -3280,10 +3280,8 @@ void tst_QSortFilterProxyModel::testMultipleProxiesWithSelection() static bool isValid(const QItemSelection &selection) { - foreach (const QItemSelectionRange &range, selection) - if (!range.isValid()) - return false; - return true; + return std::all_of(selection.begin(), selection.end(), + [](const QItemSelectionRange &range) { return range.isValid(); }); } void tst_QSortFilterProxyModel::mapSelectionFromSource() @@ -3737,14 +3735,16 @@ void tst_QSortFilterProxyModel::testParentLayoutChanged() QVERIFY(beforeParents.first() == proxy.mapFromSource(model.indexFromItem(model.invisibleRootItem()->child(1)))); - QList<QPersistentModelIndex> proxy2BeforeList = proxy2ParentsAboutToBeChangedSpy.first().first().value<QList<QPersistentModelIndex> >(); - QList<QPersistentModelIndex> proxy2AfterList = proxy2ParentsChangedSpy.first().first().value<QList<QPersistentModelIndex> >(); + const QList<QPersistentModelIndex> proxy2BeforeList = + proxy2ParentsAboutToBeChangedSpy.first().first().value<QList<QPersistentModelIndex> >(); + const QList<QPersistentModelIndex> proxy2AfterList = + proxy2ParentsChangedSpy.first().first().value<QList<QPersistentModelIndex> >(); QCOMPARE(proxy2BeforeList.size(), beforeParents.size()); QCOMPARE(proxy2AfterList.size(), afterParents.size()); - foreach (const QPersistentModelIndex &idx, proxy2BeforeList) + for (const QPersistentModelIndex &idx : proxy2BeforeList) QVERIFY(beforeParents.contains(proxy2.mapToSource(idx))); - foreach (const QPersistentModelIndex &idx, proxy2AfterList) + for (const QPersistentModelIndex &idx : proxy2AfterList) QVERIFY(afterParents.contains(proxy2.mapToSource(idx))); } diff --git a/tests/auto/corelib/kernel/qelapsedtimer/BLACKLIST b/tests/auto/corelib/kernel/qelapsedtimer/BLACKLIST index 4c9fe53c14..569880e1db 100644 --- a/tests/auto/corelib/kernel/qelapsedtimer/BLACKLIST +++ b/tests/auto/corelib/kernel/qelapsedtimer/BLACKLIST @@ -1,4 +1,3 @@ [elapsed] -windows-10 msvc-2015 osx-10.13 -windows-10 msvc-2017 +windows-10 diff --git a/tests/auto/corelib/kernel/qsocketnotifier/BLACKLIST b/tests/auto/corelib/kernel/qsocketnotifier/BLACKLIST index f3b7fc97b1..f2e5e78592 100644 --- a/tests/auto/corelib/kernel/qsocketnotifier/BLACKLIST +++ b/tests/auto/corelib/kernel/qsocketnotifier/BLACKLIST @@ -1,4 +1,3 @@ [unexpectedDisconnection] -osx-10.12 -windows-10 msvc-2015 windows-7sp1 +windows-10 msvc-2015 diff --git a/tests/auto/corelib/kernel/qtimer/BLACKLIST b/tests/auto/corelib/kernel/qtimer/BLACKLIST deleted file mode 100644 index dc8b8987e5..0000000000 --- a/tests/auto/corelib/kernel/qtimer/BLACKLIST +++ /dev/null @@ -1,9 +0,0 @@ -[remainingTime] -osx-10.12 -osx-10.14 -osx-10.13 -windows-10 msvc-2017 -[basic_chrono] -osx-10.14 -osx-10.13 - diff --git a/tests/auto/corelib/serialization/qtextstream/BLACKLIST b/tests/auto/corelib/serialization/qtextstream/BLACKLIST index b8c1b742f4..674569e204 100644 --- a/tests/auto/corelib/serialization/qtextstream/BLACKLIST +++ b/tests/auto/corelib/serialization/qtextstream/BLACKLIST @@ -1,4 +1,3 @@ [stillOpenWhenAtEnd] -windows-10 msvc-2017 -winrt windows-7sp1 +winrt diff --git a/tests/auto/corelib/thread/qsemaphore/BLACKLIST b/tests/auto/corelib/thread/qsemaphore/BLACKLIST index f61f4c1a3b..d7af5c420b 100644 --- a/tests/auto/corelib/thread/qsemaphore/BLACKLIST +++ b/tests/auto/corelib/thread/qsemaphore/BLACKLIST @@ -1,6 +1,5 @@ [tryAcquireWithTimeout] -osx-10.12 -osx-10.13 +osx [tryAcquireWithTimeout:0.2s] windows osx-10.12 diff --git a/tests/auto/corelib/thread/qthread/BLACKLIST b/tests/auto/corelib/thread/qthread/BLACKLIST index 87538a1048..c683154da1 100644 --- a/tests/auto/corelib/thread/qthread/BLACKLIST +++ b/tests/auto/corelib/thread/qthread/BLACKLIST @@ -1,7 +1,5 @@ [wait3_slowDestructor] -windows-10 msvc-2015 -windows-7sp1 -windows-10 msvc-2017 +windows-10 [sleep] windows-7sp1 diff --git a/tests/auto/corelib/thread/qthreadpool/BLACKLIST b/tests/auto/corelib/thread/qthreadpool/BLACKLIST index e4f2fcd822..b8c1f3bf3f 100644 --- a/tests/auto/corelib/thread/qthreadpool/BLACKLIST +++ b/tests/auto/corelib/thread/qthreadpool/BLACKLIST @@ -1,7 +1,4 @@ [expiryTimeoutRace] -rhel-7.6 opensuse-leap -osx-10.13 -ubuntu-18.04 -osx-10.12 -opensuse-42.3 +ubuntu +rhel diff --git a/tests/auto/corelib/tools/qsize/tst_qsize.cpp b/tests/auto/corelib/tools/qsize/tst_qsize.cpp index 385ff18ce5..6824bad9c8 100644 --- a/tests/auto/corelib/tools/qsize/tst_qsize.cpp +++ b/tests/auto/corelib/tools/qsize/tst_qsize.cpp @@ -29,6 +29,7 @@ #include <QtTest/QtTest> #include <qsize.h> +Q_DECLARE_METATYPE(QMargins) class tst_QSize : public QObject { @@ -43,6 +44,9 @@ private slots: void boundedTo_data(); void boundedTo(); + void grownOrShrunkBy_data(); + void grownOrShrunkBy(); + void transpose_data(); void transpose(); }; @@ -186,6 +190,46 @@ void tst_QSize::boundedTo() QCOMPARE( input1.boundedTo(input2), expected); } +void tst_QSize::grownOrShrunkBy_data() +{ + QTest::addColumn<QSize>("input"); + QTest::addColumn<QMargins>("margins"); + QTest::addColumn<QSize>("grown"); + QTest::addColumn<QSize>("shrunk"); + + auto row = [](QSize i, QMargins m, QSize g, QSize s) { + QTest::addRow("{%d,%d}/{%d,%d,%d,%d}", i.width(), i.height(), + m.left(), m.top(), m.right(), m.bottom()) + << i << m << g << s; + }; + + const QSize zero = {0, 0}; + const QSize some = {100, 200}; + const QMargins zeroMargins = {}; + const QMargins negative = {-1, -2, -3, -4}; + const QMargins positive = { 1, 2, 3, 4}; + + row(zero, zeroMargins, zero, zero); + row(zero, negative, {-4, -6}, { 4, 6}); + row(zero, positive, { 4, 6}, {-4, -6}); + row(some, zeroMargins, some, some); + row(some, negative, { 96, 194}, {104, 206}); + row(some, positive, {104, 206}, { 96, 194}); +} + +void tst_QSize::grownOrShrunkBy() +{ + QFETCH(const QSize, input); + QFETCH(const QMargins, margins); + QFETCH(const QSize, grown); + QFETCH(const QSize, shrunk); + + QCOMPARE(input.grownBy(margins), grown); + QCOMPARE(input.shrunkBy(margins), shrunk); + QCOMPARE(grown.shrunkBy(margins), input); + QCOMPARE(shrunk.grownBy(margins), input); +} + void tst_QSize::transpose_data() { QTest::addColumn<QSize>("input1"); diff --git a/tests/auto/corelib/tools/qsizef/tst_qsizef.cpp b/tests/auto/corelib/tools/qsizef/tst_qsizef.cpp index 42801d63a9..bbffa74a62 100644 --- a/tests/auto/corelib/tools/qsizef/tst_qsizef.cpp +++ b/tests/auto/corelib/tools/qsizef/tst_qsizef.cpp @@ -29,6 +29,7 @@ #include <QtTest/QtTest> #include <qsize.h> +Q_DECLARE_METATYPE(QMarginsF) class tst_QSizeF : public QObject { @@ -45,6 +46,9 @@ private slots: void boundedTo_data(); void boundedTo(); + void grownOrShrunkBy_data(); + void grownOrShrunkBy(); + void transpose_data(); void transpose(); }; @@ -152,6 +156,46 @@ void tst_QSizeF::boundedTo() { QCOMPARE( input1.boundedTo(input2), expected); } +void tst_QSizeF::grownOrShrunkBy_data() +{ + QTest::addColumn<QSizeF>("input"); + QTest::addColumn<QMarginsF>("margins"); + QTest::addColumn<QSizeF>("grown"); + QTest::addColumn<QSizeF>("shrunk"); + + auto row = [](QSizeF i, QMarginsF m, QSizeF g, QSizeF s) { + QTest::addRow("{%g,%g}/{%g,%g,%g,%g}", i.width(), i.height(), + m.left(), m.top(), m.right(), m.bottom()) + << i << m << g << s; + }; + + const QSizeF zero = {0, 0}; + const QSizeF some = {100, 200}; + const QMarginsF zeroMargins = {}; + const QMarginsF negative = {-1, -2, -3, -4}; + const QMarginsF positive = { 1, 2, 3, 4}; + + row(zero, zeroMargins, zero, zero); + row(zero, negative, {-4, -6}, { 4, 6}); + row(zero, positive, { 4, 6}, {-4, -6}); + row(some, zeroMargins, some, some); + row(some, negative, { 96, 194}, {104, 206}); + row(some, positive, {104, 206}, { 96, 194}); +} + +void tst_QSizeF::grownOrShrunkBy() +{ + QFETCH(const QSizeF, input); + QFETCH(const QMarginsF, margins); + QFETCH(const QSizeF, grown); + QFETCH(const QSizeF, shrunk); + + QCOMPARE(input.grownBy(margins), grown); + QCOMPARE(input.shrunkBy(margins), shrunk); + QCOMPARE(grown.shrunkBy(margins), input); + QCOMPARE(shrunk.grownBy(margins), input); +} + void tst_QSizeF::transpose_data() { QTest::addColumn<QSizeF>("input1"); QTest::addColumn<QSizeF>("expected"); diff --git a/tests/auto/corelib/tools/qtimeline/BLACKLIST b/tests/auto/corelib/tools/qtimeline/BLACKLIST index b60cab31fa..9794b0059f 100644 --- a/tests/auto/corelib/tools/qtimeline/BLACKLIST +++ b/tests/auto/corelib/tools/qtimeline/BLACKLIST @@ -1,8 +1,6 @@ [interpolation] -osx-10.12 windows-10 msvc-2015 -osx-10.13 -windows-7sp1 +osx [frameRate] osx-10.12 osx-10.13 diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 441ec17412..b84aa52465 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -303,6 +303,8 @@ static QLatin1String formatToString(QImage::Format format) return QLatin1String("RGBA64pm"); case QImage::Format_Grayscale16: return QLatin1String("Grayscale16"); + case QImage::Format_BGR888: + return QLatin1String("BGR888"); default: break; }; @@ -844,6 +846,13 @@ void tst_QImage::convertToFormat_data() QTest::newRow("blue rgb32 -> rgb888") << int(QImage::Format_RGB32) << 0xff0000ff << int(QImage::Format_RGB888) << 0xff0000ff; + QTest::newRow("red rgb32 -> bgr888") << int(QImage::Format_RGB32) << 0xffff0000 + << int(QImage::Format_BGR888) << 0xffff0000; + QTest::newRow("green rgb32 -> bgr888") << int(QImage::Format_RGB32) << 0xff00ff00 + << int(QImage::Format_BGR888) << 0xff00ff00; + QTest::newRow("blue rgb32 -> bgr888") << int(QImage::Format_RGB32) << 0xff0000ff + << int(QImage::Format_BGR888) << 0xff0000ff; + QTest::newRow("red rgb16 -> rgb888") << int(QImage::Format_RGB16) << 0xffff0000 << int(QImage::Format_RGB888) << 0xffff0000; QTest::newRow("green rgb16 -> rgb888") << int(QImage::Format_RGB16) << 0xff00ff00 @@ -858,6 +867,13 @@ void tst_QImage::convertToFormat_data() QTest::newRow("blue rgb888 -> argb32") << int(QImage::Format_RGB888) << 0xff0000ff << int(QImage::Format_ARGB32) << 0xff0000ff; + QTest::newRow("red bgr888 -> argb32") << int(QImage::Format_RGB888) << 0xffff0000 + << int(QImage::Format_ARGB32) << 0xffff0000; + QTest::newRow("green bgr888 -> argb32") << int(QImage::Format_RGB888) << 0xff00ff00 + << int(QImage::Format_ARGB32) << 0xff00ff00; + QTest::newRow("blue bgr888 -> argb32") << int(QImage::Format_RGB888) << 0xff0000ff + << int(QImage::Format_ARGB32) << 0xff0000ff; + QTest::newRow("red rgb888 -> rgbx8888") << int(QImage::Format_RGB888) << 0xffff0000 << int(QImage::Format_RGBX8888) << 0xffff0000; QTest::newRow("green rgb888 -> rgbx8888") << int(QImage::Format_RGB888) << 0xff00ff00 @@ -1338,6 +1354,12 @@ void tst_QImage::setPixel_data() << 0xff00ff00 << 0x00ff00u; QTest::newRow("RGB888 blue") << int(QImage::Format_RGB888) << 0xff0000ff << 0x0000ffu; + QTest::newRow("BGR888 red") << int(QImage::Format_BGR888) + << 0xffff0000 << 0x0000ffu; + QTest::newRow("BGR888 green") << int(QImage::Format_BGR888) + << 0xff00ff00 << 0x00ff00u; + QTest::newRow("BGR888 blue") << int(QImage::Format_BGR888) + << 0xff0000ff << 0xff0000u; #if Q_BYTE_ORDER == Q_BIG_ENDIAN QTest::newRow("RGBA8888 red") << int(QImage::Format_RGBA8888) << 0xffff0000u << 0xff0000ffu; @@ -1425,6 +1447,7 @@ void tst_QImage::setPixel() case int(QImage::Format_ARGB8565_Premultiplied): case int(QImage::Format_ARGB8555_Premultiplied): case int(QImage::Format_RGB888): + case int(QImage::Format_BGR888): { for (int y = 0; y < h; ++y) { const quint24 *row = (const quint24*)(img.scanLine(y)); @@ -2445,6 +2468,7 @@ void tst_QImage::mirrored_data() QTest::newRow("Format_RGB555, vertical") << QImage::Format_RGB555 << true << false << 16 << 16; QTest::newRow("Format_ARGB8555_Premultiplied, vertical") << QImage::Format_ARGB8555_Premultiplied << true << false << 16 << 16; QTest::newRow("Format_RGB888, vertical") << QImage::Format_RGB888 << true << false << 16 << 16; + QTest::newRow("Format_BGR888, vertical") << QImage::Format_BGR888 << true << false << 16 << 16; QTest::newRow("Format_RGB444, vertical") << QImage::Format_RGB444 << true << false << 16 << 16; QTest::newRow("Format_RGBX8888, vertical") << QImage::Format_RGBX8888 << true << false << 16 << 16; QTest::newRow("Format_RGBA8888_Premultiplied, vertical") << QImage::Format_RGBA8888_Premultiplied << true << false << 16 << 16; diff --git a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp index 866a41c3d1..f6ffd7b7c5 100644 --- a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp @@ -1863,6 +1863,7 @@ void tst_QImageReader::saveFormat_data() QTest::newRow("Format_RGB555") << QImage::Format_RGB555; QTest::newRow("Format_ARGB8555_Premultiplied") << QImage::Format_ARGB8555_Premultiplied; QTest::newRow("Format_RGB888") << QImage::Format_RGB888; + QTest::newRow("Format_BGR888") << QImage::Format_BGR888; QTest::newRow("Format_RGB444") << QImage::Format_RGB444; QTest::newRow("Format_ARGB4444_Premultiplied") << QImage::Format_ARGB4444_Premultiplied; QTest::newRow("Format_RGBA64") << QImage::Format_RGBA64; @@ -1914,6 +1915,13 @@ void tst_QImageReader::saveColorSpace() QCOMPARE(stored, orig); QCOMPARE(stored.colorSpace(), orig.colorSpace()); + + buf.open(QIODevice::WriteOnly); + QVERIFY(orig.save(&buf, "jpeg")); + buf.close(); + stored = QImage::fromData(buf.buffer(), "jpeg"); + + QCOMPARE(stored.colorSpace(), orig.colorSpace()); } void tst_QImageReader::readText_data() diff --git a/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp b/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp index 4fca9a07fc..19c5c8a4a0 100644 --- a/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp +++ b/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp @@ -258,8 +258,8 @@ void tst_NoQtEventLoop::consumeMouseEvents() ::SetWindowPos(mainWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); - Window *childWindow = new Window; - childWindow->setParent(QWindow::fromWinId((WId)mainWnd)); + QWindow *mainWindow = QWindow::fromWinId(reinterpret_cast<WId>(mainWnd)); + Window *childWindow = new Window(mainWindow); childWindow->setGeometry(margin, topVerticalMargin, width - 2 * margin, height - margin - topVerticalMargin); childWindow->show(); @@ -276,6 +276,7 @@ void tst_NoQtEventLoop::consumeMouseEvents() if (g_exit) break; } + delete mainWindow; QCOMPARE(testThread->passed(), true); diff --git a/tests/auto/gui/kernel/qguitimer/BLACKLIST b/tests/auto/gui/kernel/qguitimer/BLACKLIST deleted file mode 100644 index 6ab715b922..0000000000 --- a/tests/auto/gui/kernel/qguitimer/BLACKLIST +++ /dev/null @@ -1,8 +0,0 @@ -[basic_chrono] -osx-10.13 -[remainingTime] -osx-10.12 -windows-10 msvc-2015 -osx-10.14 -osx-10.13 - diff --git a/tests/auto/gui/kernel/qwindow/BLACKLIST b/tests/auto/gui/kernel/qwindow/BLACKLIST index 1bb3917948..27463adf99 100644 --- a/tests/auto/gui/kernel/qwindow/BLACKLIST +++ b/tests/auto/gui/kernel/qwindow/BLACKLIST @@ -1,7 +1,5 @@ [positioning] opensuse-leap -ubuntu-16.04 -opensuse-42.3 [positioning:default] linux osx-10.12 ci @@ -9,24 +7,17 @@ winrt [positioning:fake] osx-10.12 ci [modalWithChildWindow] -ubuntu-16.04 -opensuse-leap # QTBUG-66851 # QTBUG-69160 -opensuse-42.3 +opensuse-leap [setVisible] # QTBUG-69154 android [modalWindowEnterEventOnHide_QTBUG35109] -ubuntu-16.04 -osx-10.11 -osx-10.13 -osx-10.14 -osx-10.12 +osx [spuriousMouseMove] # QTBUG-69162 -windows-10 msvc-2015 -windows-10 msvc-2017 +windows-10 [testInputEvents] rhel-7.4 [exposeEventOnShrink_QTBUG54040] diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp index c1c231089a..07c820dc86 100644 --- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp +++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp @@ -64,6 +64,10 @@ private slots: void globalColors_data(); void globalColors(); +#if defined(Q_COMPILER_CONSTEXPR) & defined(Q_COMPILER_UNIFORM_INIT) + void colorConstants_data(); + void colorConstants(); +#endif void setRed(); void setGreen(); @@ -364,6 +368,191 @@ void tst_QColor::globalColors() QCOMPARE(color.rgba(), argb); } +#if defined(Q_COMPILER_CONSTEXPR) & defined(Q_COMPILER_UNIFORM_INIT) +void tst_QColor::colorConstants_data() +{ + QTest::addColumn<QColor>("color"); + QTest::addColumn<QRgb>("argb"); + + QTest::newRow("invalid") << QColor() << 0xff000000; + QTest::newRow("global color color0") << QColorConstants::Color0 << 0xff000000u; + QTest::newRow("global color color1") << QColorConstants::Color1 << 0xffffffffu; + QTest::newRow("global color black") << QColorConstants::Black << 0xff000000u; + QTest::newRow("global color white") << QColorConstants::White << 0xffffffffu; + QTest::newRow("global color darkGray") << QColorConstants::DarkGray << 0xff808080u; + QTest::newRow("global color gray") << QColorConstants::Gray << 0xffa0a0a4u; + QTest::newRow("global color lightGray") << QColorConstants::LightGray << 0xffc0c0c0u; + QTest::newRow("global color red") << QColorConstants::Red << 0xffff0000u; + QTest::newRow("global color green") << QColorConstants::Green << 0xff00ff00u; + QTest::newRow("global color blue") << QColorConstants::Blue << 0xff0000ffu; + QTest::newRow("global color cyan") << QColorConstants::Cyan << 0xff00ffffu; + QTest::newRow("global color magenta") << QColorConstants::Magenta << 0xffff00ffu; + QTest::newRow("global color yellow") << QColorConstants::Yellow << 0xffffff00u; + QTest::newRow("global color darkRed") << QColorConstants::DarkRed << 0xff800000u; + QTest::newRow("global color darkGreen") << QColorConstants::DarkGreen << 0xff008000u; + QTest::newRow("global color darkBlue") << QColorConstants::DarkBlue << 0xff000080u; + QTest::newRow("global color darkCyan") << QColorConstants::DarkCyan << 0xff008080u; + QTest::newRow("global color darkMagenta") << QColorConstants::DarkMagenta << 0xff800080u; + QTest::newRow("global color darkYellow") << QColorConstants::DarkYellow << 0xff808000u; + QTest::newRow("global color transparent") << QColorConstants::Transparent << 0x00000000u; + + QTest::newRow("SVG aliceblue") << QColorConstants::Svg::aliceblue << 0xfff0f8ffu; + QTest::newRow("SVG antiquewhite") << QColorConstants::Svg::antiquewhite << 0xfffaebd7u; + QTest::newRow("SVG aqua") << QColorConstants::Svg::aqua << 0xff00ffffu; + QTest::newRow("SVG aquamarine") << QColorConstants::Svg::aquamarine << 0xff7fffd4u; + QTest::newRow("SVG azure") << QColorConstants::Svg::azure << 0xfff0ffffu; + QTest::newRow("SVG beige") << QColorConstants::Svg::beige << 0xfff5f5dcu; + QTest::newRow("SVG bisque") << QColorConstants::Svg::bisque << 0xffffe4c4u; + QTest::newRow("SVG black") << QColorConstants::Svg::black << 0xff000000u; + QTest::newRow("SVG blanchedalmond") << QColorConstants::Svg::blanchedalmond << 0xffffebcdu; + QTest::newRow("SVG blue") << QColorConstants::Svg::blue << 0xff0000ffu; + QTest::newRow("SVG blueviolet") << QColorConstants::Svg::blueviolet << 0xff8a2be2u; + QTest::newRow("SVG brown") << QColorConstants::Svg::brown << 0xffa52a2au; + QTest::newRow("SVG burlywood") << QColorConstants::Svg::burlywood << 0xffdeb887u; + QTest::newRow("SVG cadetblue") << QColorConstants::Svg::cadetblue << 0xff5f9ea0u; + QTest::newRow("SVG chartreuse") << QColorConstants::Svg::chartreuse << 0xff7fff00u; + QTest::newRow("SVG chocolate") << QColorConstants::Svg::chocolate << 0xffd2691eu; + QTest::newRow("SVG coral") << QColorConstants::Svg::coral << 0xffff7f50u; + QTest::newRow("SVG cornflowerblue") << QColorConstants::Svg::cornflowerblue << 0xff6495edu; + QTest::newRow("SVG cornsilk") << QColorConstants::Svg::cornsilk << 0xfffff8dcu; + QTest::newRow("SVG crimson") << QColorConstants::Svg::crimson << 0xffdc143cu; + QTest::newRow("SVG cyan") << QColorConstants::Svg::cyan << 0xff00ffffu; + QTest::newRow("SVG darkblue") << QColorConstants::Svg::darkblue << 0xff00008bu; + QTest::newRow("SVG darkcyan") << QColorConstants::Svg::darkcyan << 0xff008b8bu; + QTest::newRow("SVG darkgoldenrod") << QColorConstants::Svg::darkgoldenrod << 0xffb8860bu; + QTest::newRow("SVG darkgray") << QColorConstants::Svg::darkgray << 0xffa9a9a9u; + QTest::newRow("SVG darkgreen") << QColorConstants::Svg::darkgreen << 0xff006400u; + QTest::newRow("SVG darkgrey") << QColorConstants::Svg::darkgrey << 0xffa9a9a9u; + QTest::newRow("SVG darkkhaki") << QColorConstants::Svg::darkkhaki << 0xffbdb76bu; + QTest::newRow("SVG darkmagenta") << QColorConstants::Svg::darkmagenta << 0xff8b008bu; + QTest::newRow("SVG darkolivegreen") << QColorConstants::Svg::darkolivegreen << 0xff556b2fu; + QTest::newRow("SVG darkorange") << QColorConstants::Svg::darkorange << 0xffff8c00u; + QTest::newRow("SVG darkorchid") << QColorConstants::Svg::darkorchid << 0xff9932ccu; + QTest::newRow("SVG darkred") << QColorConstants::Svg::darkred << 0xff8b0000u; + QTest::newRow("SVG darksalmon") << QColorConstants::Svg::darksalmon << 0xffe9967au; + QTest::newRow("SVG darkseagreen") << QColorConstants::Svg::darkseagreen << 0xff8fbc8fu; + QTest::newRow("SVG darkslateblue") << QColorConstants::Svg::darkslateblue << 0xff483d8bu; + QTest::newRow("SVG darkslategray") << QColorConstants::Svg::darkslategray << 0xff2f4f4fu; + QTest::newRow("SVG darkslategrey") << QColorConstants::Svg::darkslategrey << 0xff2f4f4fu; + QTest::newRow("SVG darkturquoise") << QColorConstants::Svg::darkturquoise << 0xff00ced1u; + QTest::newRow("SVG darkviolet") << QColorConstants::Svg::darkviolet << 0xff9400d3u; + QTest::newRow("SVG deeppink") << QColorConstants::Svg::deeppink << 0xffff1493u; + QTest::newRow("SVG deepskyblue") << QColorConstants::Svg::deepskyblue << 0xff00bfffu; + QTest::newRow("SVG dimgray") << QColorConstants::Svg::dimgray << 0xff696969u; + QTest::newRow("SVG dimgrey") << QColorConstants::Svg::dimgrey << 0xff696969u; + QTest::newRow("SVG dodgerblue") << QColorConstants::Svg::dodgerblue << 0xff1e90ffu; + QTest::newRow("SVG firebrick") << QColorConstants::Svg::firebrick << 0xffb22222u; + QTest::newRow("SVG floralwhite") << QColorConstants::Svg::floralwhite << 0xfffffaf0u; + QTest::newRow("SVG forestgreen") << QColorConstants::Svg::forestgreen << 0xff228b22u; + QTest::newRow("SVG fuchsia") << QColorConstants::Svg::fuchsia << 0xffff00ffu; + QTest::newRow("SVG gainsboro") << QColorConstants::Svg::gainsboro << 0xffdcdcdcu; + QTest::newRow("SVG ghostwhite") << QColorConstants::Svg::ghostwhite << 0xfff8f8ffu; + QTest::newRow("SVG gold") << QColorConstants::Svg::gold << 0xffffd700u; + QTest::newRow("SVG goldenrod") << QColorConstants::Svg::goldenrod << 0xffdaa520u; + QTest::newRow("SVG gray") << QColorConstants::Svg::gray << 0xff808080u; + QTest::newRow("SVG green") << QColorConstants::Svg::green << 0xff008000u; + QTest::newRow("SVG greenyellow") << QColorConstants::Svg::greenyellow << 0xffadff2fu; + QTest::newRow("SVG grey") << QColorConstants::Svg::grey << 0xff808080u; + QTest::newRow("SVG honeydew") << QColorConstants::Svg::honeydew << 0xfff0fff0u; + QTest::newRow("SVG hotpink") << QColorConstants::Svg::hotpink << 0xffff69b4u; + QTest::newRow("SVG indianred") << QColorConstants::Svg::indianred << 0xffcd5c5cu; + QTest::newRow("SVG indigo") << QColorConstants::Svg::indigo << 0xff4b0082u; + QTest::newRow("SVG ivory") << QColorConstants::Svg::ivory << 0xfffffff0u; + QTest::newRow("SVG khaki") << QColorConstants::Svg::khaki << 0xfff0e68cu; + QTest::newRow("SVG lavender") << QColorConstants::Svg::lavender << 0xffe6e6fau; + QTest::newRow("SVG lavenderblush") << QColorConstants::Svg::lavenderblush << 0xfffff0f5u; + QTest::newRow("SVG lawngreen") << QColorConstants::Svg::lawngreen << 0xff7cfc00u; + QTest::newRow("SVG lemonchiffon") << QColorConstants::Svg::lemonchiffon << 0xfffffacdu; + QTest::newRow("SVG lightblue") << QColorConstants::Svg::lightblue << 0xffadd8e6u; + QTest::newRow("SVG lightcoral") << QColorConstants::Svg::lightcoral << 0xfff08080u; + QTest::newRow("SVG lightcyan") << QColorConstants::Svg::lightcyan << 0xffe0ffffu; + QTest::newRow("SVG lightgoldenrodyellow") << QColorConstants::Svg::lightgoldenrodyellow << 0xfffafad2u; + QTest::newRow("SVG lightgray") << QColorConstants::Svg::lightgray << 0xffd3d3d3u; + QTest::newRow("SVG lightgreen") << QColorConstants::Svg::lightgreen << 0xff90ee90u; + QTest::newRow("SVG lightgrey") << QColorConstants::Svg::lightgrey << 0xffd3d3d3u; + QTest::newRow("SVG lightpink") << QColorConstants::Svg::lightpink << 0xffffb6c1u; + QTest::newRow("SVG lightsalmon") << QColorConstants::Svg::lightsalmon << 0xffffa07au; + QTest::newRow("SVG lightseagreen") << QColorConstants::Svg::lightseagreen << 0xff20b2aau; + QTest::newRow("SVG lightskyblue") << QColorConstants::Svg::lightskyblue << 0xff87cefau; + QTest::newRow("SVG lightslategray") << QColorConstants::Svg::lightslategray << 0xff778899u; + QTest::newRow("SVG lightslategrey") << QColorConstants::Svg::lightslategrey << 0xff778899u; + QTest::newRow("SVG lightsteelblue") << QColorConstants::Svg::lightsteelblue << 0xffb0c4deu; + QTest::newRow("SVG lightyellow") << QColorConstants::Svg::lightyellow << 0xffffffe0u; + QTest::newRow("SVG lime") << QColorConstants::Svg::lime << 0xff00ff00u; + QTest::newRow("SVG limegreen") << QColorConstants::Svg::limegreen << 0xff32cd32u; + QTest::newRow("SVG linen") << QColorConstants::Svg::linen << 0xfffaf0e6u; + QTest::newRow("SVG magenta") << QColorConstants::Svg::magenta << 0xffff00ffu; + QTest::newRow("SVG maroon") << QColorConstants::Svg::maroon << 0xff800000u; + QTest::newRow("SVG mediumaquamarine") << QColorConstants::Svg::mediumaquamarine << 0xff66cdaau; + QTest::newRow("SVG mediumblue") << QColorConstants::Svg::mediumblue << 0xff0000cdu; + QTest::newRow("SVG mediumorchid") << QColorConstants::Svg::mediumorchid << 0xffba55d3u; + QTest::newRow("SVG mediumpurple") << QColorConstants::Svg::mediumpurple << 0xff9370dbu; + QTest::newRow("SVG mediumseagreen") << QColorConstants::Svg::mediumseagreen << 0xff3cb371u; + QTest::newRow("SVG mediumslateblue") << QColorConstants::Svg::mediumslateblue << 0xff7b68eeu; + QTest::newRow("SVG mediumspringgreen") << QColorConstants::Svg::mediumspringgreen << 0xff00fa9au; + QTest::newRow("SVG mediumturquoise") << QColorConstants::Svg::mediumturquoise << 0xff48d1ccu; + QTest::newRow("SVG mediumvioletred") << QColorConstants::Svg::mediumvioletred << 0xffc71585u; + QTest::newRow("SVG midnightblue") << QColorConstants::Svg::midnightblue << 0xff191970u; + QTest::newRow("SVG mintcream") << QColorConstants::Svg::mintcream << 0xfff5fffau; + QTest::newRow("SVG mistyrose") << QColorConstants::Svg::mistyrose << 0xffffe4e1u; + QTest::newRow("SVG moccasin") << QColorConstants::Svg::moccasin << 0xffffe4b5u; + QTest::newRow("SVG navajowhite") << QColorConstants::Svg::navajowhite << 0xffffdeadu; + QTest::newRow("SVG navy") << QColorConstants::Svg::navy << 0xff000080u; + QTest::newRow("SVG oldlace") << QColorConstants::Svg::oldlace << 0xfffdf5e6u; + QTest::newRow("SVG olive") << QColorConstants::Svg::olive << 0xff808000u; + QTest::newRow("SVG olivedrab") << QColorConstants::Svg::olivedrab << 0xff6b8e23u; + QTest::newRow("SVG orange") << QColorConstants::Svg::orange << 0xffffa500u; + QTest::newRow("SVG orangered") << QColorConstants::Svg::orangered << 0xffff4500u; + QTest::newRow("SVG orchid") << QColorConstants::Svg::orchid << 0xffda70d6u; + QTest::newRow("SVG palegoldenrod") << QColorConstants::Svg::palegoldenrod << 0xffeee8aau; + QTest::newRow("SVG palegreen") << QColorConstants::Svg::palegreen << 0xff98fb98u; + QTest::newRow("SVG paleturquoise") << QColorConstants::Svg::paleturquoise << 0xffafeeeeu; + QTest::newRow("SVG palevioletred") << QColorConstants::Svg::palevioletred << 0xffdb7093u; + QTest::newRow("SVG papayawhip") << QColorConstants::Svg::papayawhip << 0xffffefd5u; + QTest::newRow("SVG peachpuff") << QColorConstants::Svg::peachpuff << 0xffffdab9u; + QTest::newRow("SVG peru") << QColorConstants::Svg::peru << 0xffcd853fu; + QTest::newRow("SVG pink") << QColorConstants::Svg::pink << 0xffffc0cbu; + QTest::newRow("SVG plum") << QColorConstants::Svg::plum << 0xffdda0ddu; + QTest::newRow("SVG powderblue") << QColorConstants::Svg::powderblue << 0xffb0e0e6u; + QTest::newRow("SVG purple") << QColorConstants::Svg::purple << 0xff800080u; + QTest::newRow("SVG red") << QColorConstants::Svg::red << 0xffff0000u; + QTest::newRow("SVG rosybrown") << QColorConstants::Svg::rosybrown << 0xffbc8f8fu; + QTest::newRow("SVG royalblue") << QColorConstants::Svg::royalblue << 0xff4169e1u; + QTest::newRow("SVG saddlebrown") << QColorConstants::Svg::saddlebrown << 0xff8b4513u; + QTest::newRow("SVG salmon") << QColorConstants::Svg::salmon << 0xfffa8072u; + QTest::newRow("SVG sandybrown") << QColorConstants::Svg::sandybrown << 0xfff4a460u; + QTest::newRow("SVG seagreen") << QColorConstants::Svg::seagreen << 0xff2e8b57u; + QTest::newRow("SVG seashell") << QColorConstants::Svg::seashell << 0xfffff5eeu; + QTest::newRow("SVG sienna") << QColorConstants::Svg::sienna << 0xffa0522du; + QTest::newRow("SVG silver") << QColorConstants::Svg::silver << 0xffc0c0c0u; + QTest::newRow("SVG skyblue") << QColorConstants::Svg::skyblue << 0xff87ceebu; + QTest::newRow("SVG slateblue") << QColorConstants::Svg::slateblue << 0xff6a5acdu; + QTest::newRow("SVG slategray") << QColorConstants::Svg::slategray << 0xff708090u; + QTest::newRow("SVG slategrey") << QColorConstants::Svg::slategrey << 0xff708090u; + QTest::newRow("SVG snow") << QColorConstants::Svg::snow << 0xfffffafau; + QTest::newRow("SVG springgreen") << QColorConstants::Svg::springgreen << 0xff00ff7fu; + QTest::newRow("SVG steelblue") << QColorConstants::Svg::steelblue << 0xff4682b4u; + QTest::newRow("SVG tan") << QColorConstants::Svg::tan << 0xffd2b48cu; + QTest::newRow("SVG teal") << QColorConstants::Svg::teal << 0xff008080u; + QTest::newRow("SVG thistle") << QColorConstants::Svg::thistle << 0xffd8bfd8u; + QTest::newRow("SVG tomato") << QColorConstants::Svg::tomato << 0xffff6347u; + QTest::newRow("SVG turquoise") << QColorConstants::Svg::turquoise << 0xff40e0d0u; + QTest::newRow("SVG violet") << QColorConstants::Svg::violet << 0xffee82eeu; + QTest::newRow("SVG wheat") << QColorConstants::Svg::wheat << 0xfff5deb3u; + QTest::newRow("SVG white") << QColorConstants::Svg::white << 0xffffffffu; + QTest::newRow("SVG whitesmoke") << QColorConstants::Svg::whitesmoke << 0xfff5f5f5u; + QTest::newRow("SVG yellow") << QColorConstants::Svg::yellow << 0xffffff00u; + QTest::newRow("SVG yellowgreen") << QColorConstants::Svg::yellowgreen << 0xff9acd32u; +} + +void tst_QColor::colorConstants() +{ + QFETCH(QColor, color); + QFETCH(QRgb, argb); + QCOMPARE(color.rgba(), argb); +} +#endif // defined(Q_COMPILER_CONSTEXPR) & defined(Q_COMPILER_UNIFORM_INIT) + /* CSS color names = SVG 1.0 color names + transparent (rgba(0,0,0,0)) */ diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 4cf23455e1..d2a4dfc3e9 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -1632,6 +1632,7 @@ void tst_QPainter::qimageFormats_data() QTest::newRow("Qimage::Format_RGB555") << QImage::Format_RGB555; QTest::newRow("Qimage::Format_ARGB8555_Premultiplied") << QImage::Format_ARGB8555_Premultiplied; QTest::newRow("Qimage::Format_RGB888") << QImage::Format_RGB888; + QTest::newRow("Qimage::Format_BGR888") << QImage::Format_BGR888; QTest::newRow("Qimage::Format_A2RGB30_Premultiplied") << QImage::Format_A2RGB30_Premultiplied; QTest::newRow("Qimage::Format_RGB30") << QImage::Format_RGB30; } diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp index 58810f73c1..52e56feb5a 100644 --- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp @@ -50,6 +50,7 @@ #include <QDomDocument> #include "common.h" +// #define DEBUG_WRITE_OUTPUT QT_FORWARD_DECLARE_CLASS(QTextDocument) @@ -196,6 +197,7 @@ private: void backgroundImage_checkExpectedHtml(const QTextDocument &doc); void buildRegExpData(); static QString cssFontSizeString(const QFont &font); + void writeActualAndExpected(const char* testTag, const QString &actual, const QString &expected); QTextDocument *doc; QTextCursor cursor; @@ -224,6 +226,27 @@ QString tst_QTextDocument::cssFontSizeString(const QFont &font) : QString::number(font.pixelSize()) + QStringLiteral("px"); } +void tst_QTextDocument::writeActualAndExpected(const char *testTag, const QString &actual, const QString &expected) +{ +#ifdef DEBUG_WRITE_OUTPUT + { + QFile out(QDir::temp().absoluteFilePath(QLatin1String(testTag) + QLatin1String("-actual.html"))); + out.open(QFile::WriteOnly); + out.write(actual.toUtf8()); + out.close(); + } { + QFile out(QDir::temp().absoluteFilePath(QLatin1String(testTag) + QLatin1String("-expected.html"))); + out.open(QFile::WriteOnly); + out.write(expected.toUtf8()); + out.close(); + } +#else + Q_UNUSED(testTag) + Q_UNUSED(actual) + Q_UNUSED(expected) +#endif +} + // Testing get/set functions void tst_QTextDocument::getSetCheck() { @@ -1765,6 +1788,8 @@ void tst_QTextDocument::toHtml() QString output = doc->toHtml(); + writeActualAndExpected(QTest::currentDataTag(), output, expectedOutput); + QCOMPARE(output, expectedOutput); QDomDocument document; @@ -1962,6 +1987,8 @@ void tst_QTextDocument::toHtmlRootFrameProperties() expectedOutput.replace("DEFAULTBLOCKSTYLE", "style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\""); expectedOutput.append(htmlTail); + writeActualAndExpected(QTest::currentTestFunction(), doc.toHtml(), expectedOutput); + QCOMPARE(doc.toHtml(), expectedOutput); } @@ -2734,6 +2761,8 @@ void tst_QTextDocument::backgroundImage_checkExpectedHtml(const QTextDocument &d .arg(defaultFont.weight() * 8) .arg((defaultFont.italic() ? "italic" : "normal")); + writeActualAndExpected(QTest::currentTestFunction(), doc.toHtml(), expectedHtml); + QCOMPARE(doc.toHtml(), expectedHtml); } diff --git a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp index c5243d1535..b6917f1208 100644 --- a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp +++ b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp @@ -181,6 +181,11 @@ private slots: void html_tableCellBackground(); void css_bodyBackground(); void css_tableCellBackground(); + void css_tableCellBorder(); + void css_tableCellBorderShorthand(); + void css_tableCellAllBordersShorthand(); + void css_tableCellOverrideOneBorder(); + void css_tableBorderCollapse(); void css_fontWeight(); void css_float(); void css_textIndent(); @@ -1753,6 +1758,135 @@ void tst_QTextDocumentFragment::css_tableCellBackground() QCOMPARE(cell.format().background().style(), Qt::TexturePattern); } +void tst_QTextDocumentFragment::css_tableCellBorder() +{ + const char html[] = "<body><table><tr><td style=\"border-width:8px;border-color:green;border-style:groove;border-left-style:dashed;border-left-color:red;border-left-width:4px\">Foo</td></tr></table></body>"; + doc->setHtml(html); + + cursor.movePosition(QTextCursor::Start); + cursor.movePosition(QTextCursor::NextBlock); + QTextTable *table = cursor.currentTable(); + QVERIFY(table); + + QTextTableCell cell = table->cellAt(0, 0); + QTextTableCellFormat cellFormat = cell.format().toTableCellFormat(); + QCOMPARE(cellFormat.leftBorder(), qreal(4)); + QCOMPARE(cellFormat.leftBorderBrush(), QBrush(QColor("red"))); + QCOMPARE(cellFormat.leftBorderStyle(), QTextFrameFormat::BorderStyle_Dashed); + + QCOMPARE(cellFormat.rightBorder(), qreal(8)); + QCOMPARE(cellFormat.rightBorderBrush(), QBrush(QColor("green"))); + QCOMPARE(cellFormat.rightBorderStyle(), QTextFrameFormat::BorderStyle_Groove); + + QCOMPARE(cellFormat.bottomBorder(), qreal(8)); + QCOMPARE(cellFormat.bottomBorderBrush(), QBrush(QColor("green"))); + QCOMPARE(cellFormat.bottomBorderStyle(), QTextFrameFormat::BorderStyle_Groove); + + QCOMPARE(cellFormat.topBorder(), qreal(8)); + QCOMPARE(cellFormat.topBorderBrush(), QBrush(QColor("green"))); + QCOMPARE(cellFormat.topBorderStyle(), QTextFrameFormat::BorderStyle_Groove); +} + +void tst_QTextDocumentFragment::css_tableCellBorderShorthand() +{ + const char html[] = "<body><table><tr><td style=\"border-left:1px solid green;border-right:2px dashed red;border-bottom:3px dotted yellow;border-top:4px dot-dash blue\">Foo</td></tr></table></body>"; + doc->setHtml(html); + + cursor.movePosition(QTextCursor::Start); + cursor.movePosition(QTextCursor::NextBlock); + QTextTable *table = cursor.currentTable(); + QVERIFY(table); + + QTextTableCell cell = table->cellAt(0, 0); + QTextTableCellFormat cellFormat = cell.format().toTableCellFormat(); + QCOMPARE(cellFormat.leftBorder(), qreal(1)); + QCOMPARE(cellFormat.leftBorderBrush(), QBrush(QColor("green"))); + QCOMPARE(cellFormat.leftBorderStyle(), QTextFrameFormat::BorderStyle_Solid); + + QCOMPARE(cellFormat.rightBorder(), qreal(2)); + QCOMPARE(cellFormat.rightBorderBrush(), QBrush(QColor("red"))); + QCOMPARE(cellFormat.rightBorderStyle(), QTextFrameFormat::BorderStyle_Dashed); + + QCOMPARE(cellFormat.bottomBorder(), qreal(3)); + QCOMPARE(cellFormat.bottomBorderBrush(), QBrush(QColor("yellow"))); + QCOMPARE(cellFormat.bottomBorderStyle(), QTextFrameFormat::BorderStyle_Dotted); + + QCOMPARE(cellFormat.topBorder(), qreal(4)); + QCOMPARE(cellFormat.topBorderBrush(), QBrush(QColor("blue"))); + QCOMPARE(cellFormat.topBorderStyle(), QTextFrameFormat::BorderStyle_DotDash); +} + +void tst_QTextDocumentFragment::css_tableCellAllBordersShorthand() +{ + const char html[] = "<body><table><tr><td style=\"border:2px dashed green\">Foo</td></tr></table></body>"; + doc->setHtml(html); + + cursor.movePosition(QTextCursor::Start); + cursor.movePosition(QTextCursor::NextBlock); + QTextTable *table = cursor.currentTable(); + QVERIFY(table); + + QTextTableCell cell = table->cellAt(0, 0); + QTextTableCellFormat cellFormat = cell.format().toTableCellFormat(); + QCOMPARE(cellFormat.leftBorder(), qreal(2)); + QCOMPARE(cellFormat.leftBorderBrush(), QBrush(QColor("green"))); + QCOMPARE(cellFormat.leftBorderStyle(), QTextFrameFormat::BorderStyle_Dashed); + + QCOMPARE(cellFormat.rightBorder(), qreal(2)); + QCOMPARE(cellFormat.rightBorderBrush(), QBrush(QColor("green"))); + QCOMPARE(cellFormat.rightBorderStyle(), QTextFrameFormat::BorderStyle_Dashed); + + QCOMPARE(cellFormat.bottomBorder(), qreal(2)); + QCOMPARE(cellFormat.bottomBorderBrush(), QBrush(QColor("green"))); + QCOMPARE(cellFormat.bottomBorderStyle(), QTextFrameFormat::BorderStyle_Dashed); + + QCOMPARE(cellFormat.topBorder(), qreal(2)); + QCOMPARE(cellFormat.topBorderBrush(), QBrush(QColor("green"))); + QCOMPARE(cellFormat.topBorderStyle(), QTextFrameFormat::BorderStyle_Dashed); +} + +void tst_QTextDocumentFragment::css_tableCellOverrideOneBorder() +{ + const char html[] = "<body><table><tr><td style=\"border:2px dashed green;border-left:4px solid red\">Foo</td></tr></table></body>"; + doc->setHtml(html); + + cursor.movePosition(QTextCursor::Start); + cursor.movePosition(QTextCursor::NextBlock); + QTextTable *table = cursor.currentTable(); + QVERIFY(table); + + QTextTableCell cell = table->cellAt(0, 0); + QTextTableCellFormat cellFormat = cell.format().toTableCellFormat(); + QCOMPARE(cellFormat.leftBorder(), qreal(4)); + QCOMPARE(cellFormat.leftBorderBrush(), QBrush(QColor("red"))); + QCOMPARE(cellFormat.leftBorderStyle(), QTextFrameFormat::BorderStyle_Solid); + + QCOMPARE(cellFormat.rightBorder(), qreal(2)); + QCOMPARE(cellFormat.rightBorderBrush(), QBrush(QColor("green"))); + QCOMPARE(cellFormat.rightBorderStyle(), QTextFrameFormat::BorderStyle_Dashed); + + QCOMPARE(cellFormat.bottomBorder(), qreal(2)); + QCOMPARE(cellFormat.bottomBorderBrush(), QBrush(QColor("green"))); + QCOMPARE(cellFormat.bottomBorderStyle(), QTextFrameFormat::BorderStyle_Dashed); + + QCOMPARE(cellFormat.topBorder(), qreal(2)); + QCOMPARE(cellFormat.topBorderBrush(), QBrush(QColor("green"))); + QCOMPARE(cellFormat.topBorderStyle(), QTextFrameFormat::BorderStyle_Dashed); +} + +void tst_QTextDocumentFragment::css_tableBorderCollapse() +{ + const char html[] = "<body><table style=\"border-collapse:collapse\"><tr><td>Foo</td></tr></table></body>"; + doc->setHtml(html); + + cursor.movePosition(QTextCursor::Start); + cursor.movePosition(QTextCursor::NextBlock); + QTextTable *table = cursor.currentTable(); + QVERIFY(table); + + QCOMPARE(table->format().borderCollapse(), true); +} + void tst_QTextDocumentFragment::css_cellPaddings() { const char html[] = "<body><table><tr><td style=\"padding-left:1\">Foo</td>" diff --git a/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp b/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp index f21b969aa7..7b2ff4cc10 100644 --- a/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp +++ b/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp @@ -50,6 +50,8 @@ typedef QList<int> IntList; QT_FORWARD_DECLARE_CLASS(QTextDocument) +Q_DECLARE_METATYPE(QTextFrameFormat::BorderStyle); + class tst_QTextTable : public QObject { Q_OBJECT @@ -95,6 +97,8 @@ private slots: #if !defined(QT_NO_PRINTER) && defined(QT_BUILD_INTERNAL) void QTBUG31330_renderBackground(); #endif + void checkBorderAttributes_data(); + void checkBorderAttributes(); private: QTextTable *create2x2Table(); @@ -1170,5 +1174,109 @@ void tst_QTextTable::QTBUG31330_renderBackground() } #endif +void tst_QTextTable::checkBorderAttributes_data() +{ + QTest::addColumn<QString>("html"); + QTest::addColumn<qreal>("topBorderWidth"); + QTest::addColumn<qreal>("bottomBorderWidth"); + QTest::addColumn<qreal>("leftBorderWidth"); + QTest::addColumn<qreal>("rightBorderWidth"); + QTest::addColumn<QTextFrameFormat::BorderStyle>("topBorderStyle"); + QTest::addColumn<QTextFrameFormat::BorderStyle>("bottomBorderStyle"); + QTest::addColumn<QTextFrameFormat::BorderStyle>("leftBorderStyle"); + QTest::addColumn<QTextFrameFormat::BorderStyle>("rightBorderStyle"); + QTest::addColumn<QBrush>("topBorderBrush"); + QTest::addColumn<QBrush>("bottomBorderBrush"); + QTest::addColumn<QBrush>("leftBorderBrush"); + QTest::addColumn<QBrush>("rightBorderBrush"); + + const QString tableHtmlStart = QStringLiteral("<html><head><style>"); + const QString tableHtmlEnd = QStringLiteral("</style></head><body>" + "<table border=\"1\"><tr><td>One</td><td>Two</td></tr>" + "<tr><td>Three</td><td>Four</td></tr></table></body></html>"); + QTest::newRow("1px-solid-colors") + << QString("%1" + "td {" + "border-top: 1px solid red;" + "border-bottom: 1px solid blue;" + "border-left: 1px solid green;" + "border-right: 1px solid yellow;" + "}" + "%2").arg(tableHtmlStart).arg(tableHtmlEnd) + << 1.0 << 1.0 << 1.0 << 1.0 + << QTextFrameFormat::BorderStyle_Solid << QTextFrameFormat::BorderStyle_Solid + << QTextFrameFormat::BorderStyle_Solid << QTextFrameFormat::BorderStyle_Solid + << QBrush(Qt::red) << QBrush(Qt::blue) << QBrush(Qt::darkGreen) << QBrush(Qt::yellow); + QTest::newRow("MixedWidth-solid-colors") + << QString("%1" + "td {" + "border-top: 1px solid red;" + "border-bottom: 2px solid blue;" + "border-left: 3px solid green;" + "border-right: 4px solid yellow;" + "}" + "%2").arg(tableHtmlStart).arg(tableHtmlEnd) + << 1.0 << 2.0 << 3.0 << 4.0 + << QTextFrameFormat::BorderStyle_Solid << QTextFrameFormat::BorderStyle_Solid + << QTextFrameFormat::BorderStyle_Solid << QTextFrameFormat::BorderStyle_Solid + << QBrush(Qt::red) << QBrush(Qt::blue) << QBrush(Qt::darkGreen) << QBrush(Qt::yellow); + QTest::newRow("MixedWidth-MixedStyle-colors") + << QString("%1" + "td {" + "border-top: 1px solid red;" + "border-bottom: 2px dotted blue;" + "border-left: 3px dashed green;" + "border-right: 4px inset yellow;" + "}" + "%2").arg(tableHtmlStart).arg(tableHtmlEnd) + << 1.0 << 2.0 << 3.0 << 4.0 + << QTextFrameFormat::BorderStyle_Solid << QTextFrameFormat::BorderStyle_Dotted + << QTextFrameFormat::BorderStyle_Dashed << QTextFrameFormat::BorderStyle_Inset + << QBrush(Qt::red) << QBrush(Qt::blue) << QBrush(Qt::darkGreen) << QBrush(Qt::yellow); +} + +void tst_QTextTable::checkBorderAttributes() +{ + QFETCH(QString, html); + QFETCH(qreal, topBorderWidth); + QFETCH(qreal, bottomBorderWidth); + QFETCH(qreal, leftBorderWidth); + QFETCH(qreal, rightBorderWidth); + QFETCH(QTextFrameFormat::BorderStyle, topBorderStyle); + QFETCH(QTextFrameFormat::BorderStyle, bottomBorderStyle); + QFETCH(QTextFrameFormat::BorderStyle, leftBorderStyle); + QFETCH(QTextFrameFormat::BorderStyle, rightBorderStyle); + QFETCH(QBrush, topBorderBrush); + QFETCH(QBrush, bottomBorderBrush); + QFETCH(QBrush, leftBorderBrush); + QFETCH(QBrush, rightBorderBrush); + + QTextDocument doc; + doc.setHtml(html); + QTextCursor cursor(doc.firstBlock()); + cursor.movePosition(QTextCursor::Right); + + QTextTable *currentTable = cursor.currentTable(); + QVERIFY(currentTable); + for (int row = 0; row < 2; row++) { + for (int column = 0; column < 2; column++) { + QTextTableCell cell = currentTable->cellAt(row, column); + QTextCharFormat cellFormat = cell.format(); + QCOMPARE(cellFormat.doubleProperty(QTextFormat::TableCellTopBorder), topBorderWidth); + QCOMPARE(cellFormat.doubleProperty(QTextFormat::TableCellBottomBorder), bottomBorderWidth); + QCOMPARE(cellFormat.doubleProperty(QTextFormat::TableCellLeftBorder), leftBorderWidth); + QCOMPARE(cellFormat.doubleProperty(QTextFormat::TableCellRightBorder), rightBorderWidth); + QCOMPARE(cellFormat.property(QTextFormat::TableCellTopBorderStyle), topBorderStyle); + QCOMPARE(cellFormat.property(QTextFormat::TableCellBottomBorderStyle), bottomBorderStyle); + QCOMPARE(cellFormat.property(QTextFormat::TableCellLeftBorderStyle), leftBorderStyle); + QCOMPARE(cellFormat.property(QTextFormat::TableCellRightBorderStyle), rightBorderStyle); + QCOMPARE(cellFormat.brushProperty(QTextFormat::TableCellTopBorderBrush), topBorderBrush); + QCOMPARE(cellFormat.brushProperty(QTextFormat::TableCellBottomBorderBrush), bottomBorderBrush); + QCOMPARE(cellFormat.brushProperty(QTextFormat::TableCellLeftBorderBrush), leftBorderBrush); + QCOMPARE(cellFormat.brushProperty(QTextFormat::TableCellRightBorderBrush), rightBorderBrush); + } + } +} + QTEST_MAIN(tst_QTextTable) #include "tst_qtexttable.moc" diff --git a/tests/auto/network/access/http2/http2srv.cpp b/tests/auto/network/access/http2/http2srv.cpp index 5a99d4e50c..a8eebf5a24 100644 --- a/tests/auto/network/access/http2/http2srv.cpp +++ b/tests/auto/network/access/http2/http2srv.cpp @@ -76,7 +76,7 @@ void fill_push_header(const HttpHeader &originalRequest, HttpHeader &promisedReq } -Http2Server::Http2Server(H2Type type, const Http2::RawSettings &ss, const Http2::RawSettings &cs) +Http2Server::Http2Server(H2Type type, const RawSettings &ss, const RawSettings &cs) : connectionType(type), serverSettings(ss), expectedClientSettings(cs) @@ -218,7 +218,7 @@ void Http2Server::sendDATA(quint32 streamID, quint32 windowSize) quint32 bytesToSend = std::min<quint32>(windowSize, responseBody.size() - offset); quint32 bytesSent = 0; - const quint32 frameSizeLimit(clientSetting(Settings::MAX_FRAME_SIZE_ID, Http2::maxFrameSize)); + const quint32 frameSizeLimit(clientSetting(Settings::MAX_FRAME_SIZE_ID, Http2::minPayloadLimit)); const uchar *src = reinterpret_cast<const uchar *>(responseBody.constData() + offset); const bool last = offset + bytesToSend == quint32(responseBody.size()); @@ -236,6 +236,10 @@ void Http2Server::sendDATA(quint32 streamID, quint32 windowSize) src += chunkSize; bytesToSend -= chunkSize; bytesSent += chunkSize; + if (frameSizeLimit != Http2::minPayloadLimit) { + // Our test is probably interested in how many DATA frames were sent. + emit sendingData(); + } } if (interrupted.loadAcquire()) @@ -767,7 +771,7 @@ void Http2Server::sendResponse(quint32 streamID, bool emptyBody) Q_ASSERT(activeRequests.find(streamID) != activeRequests.end()); const quint32 maxFrameSize(clientSetting(Settings::MAX_FRAME_SIZE_ID, - Http2::maxFrameSize)); + Http2::maxPayloadSize)); if (pushPromiseEnabled) { // A real server supporting PUSH_PROMISE will probably first send diff --git a/tests/auto/network/access/http2/http2srv.h b/tests/auto/network/access/http2/http2srv.h index 4ef4b25101..3105684d59 100644 --- a/tests/auto/network/access/http2/http2srv.h +++ b/tests/auto/network/access/http2/http2srv.h @@ -42,6 +42,7 @@ #include <QtCore/qbytearray.h> #include <QtCore/qatomic.h> #include <QtCore/qglobal.h> +#include <QtCore/qmap.h> #include <vector> #include <map> @@ -69,13 +70,15 @@ enum class H2Type { h2cDirect, // Clear text direct }; +using RawSettings = QMap<Http2::Settings, quint32>; + class Http2Server : public QTcpServer { Q_OBJECT public: - Http2Server(H2Type type, const Http2::RawSettings &serverSettings, - const Http2::RawSettings &clientSettings); + Http2Server(H2Type type, const RawSettings &serverSettings, + const RawSettings &clientSettings); ~Http2Server(); @@ -125,6 +128,7 @@ Q_SIGNALS: void receivedRequest(quint32 streamID); void receivedData(quint32 streamID); void windowUpdate(quint32 streamID); + void sendingData(); private slots: void connectionEstablished(); @@ -147,8 +151,8 @@ private: bool settingsSent = false; bool waitingClientAck = false; - Http2::RawSettings serverSettings; - Http2::RawSettings expectedClientSettings; + RawSettings serverSettings; + RawSettings expectedClientSettings; bool connectionError = false; diff --git a/tests/auto/network/access/http2/tst_http2.cpp b/tests/auto/network/access/http2/tst_http2.cpp index 945ea1b448..e24a06bc34 100644 --- a/tests/auto/network/access/http2/tst_http2.cpp +++ b/tests/auto/network/access/http2/tst_http2.cpp @@ -32,8 +32,10 @@ #include <QtNetwork/private/http2protocol_p.h> #include <QtNetwork/qnetworkaccessmanager.h> +#include <QtNetwork/qhttp2configuration.h> #include <QtNetwork/qnetworkrequest.h> #include <QtNetwork/qnetworkreply.h> + #include <QtCore/qglobal.h> #include <QtCore/qobject.h> #include <QtCore/qthread.h> @@ -66,6 +68,26 @@ Q_DECLARE_METATYPE(QNetworkRequest::Attribute) QT_BEGIN_NAMESPACE +QHttp2Configuration qt_defaultH2Configuration() +{ + QHttp2Configuration config; + config.setStreamReceiveWindowSize(Http2::qtDefaultStreamReceiveWindowSize); + config.setSessionReceiveWindowSize(Http2::maxSessionReceiveWindowSize); + config.setServerPushEnabled(false); + return config; +} + +RawSettings qt_H2ConfigurationToSettings(const QHttp2Configuration &config = qt_defaultH2Configuration()) +{ + RawSettings settings; + settings[Http2::Settings::ENABLE_PUSH_ID] = config.serverPushEnabled(); + settings[Http2::Settings::INITIAL_WINDOW_SIZE_ID] = config.streamReceiveWindowSize(); + if (config.maxFrameSize() != Http2::minPayloadLimit) + settings[Http2::Settings::MAX_FRAME_SIZE_ID] = config.maxFrameSize(); + return settings; +} + + class tst_Http2 : public QObject { Q_OBJECT @@ -87,6 +109,7 @@ private slots: void earlyResponse(); void connectToHost_data(); void connectToHost(); + void maxFrameSize(); protected slots: // Slots to listen to our in-process server: @@ -110,12 +133,13 @@ private: // small payload. void runEventLoop(int ms = 5000); void stopEventLoop(); - Http2Server *newServer(const Http2::RawSettings &serverSettings, H2Type connectionType, - const Http2::ProtocolParameters &clientSettings = {}); + Http2Server *newServer(const RawSettings &serverSettings, H2Type connectionType, + const RawSettings &clientSettings = qt_H2ConfigurationToSettings()); // Send a get or post request, depending on a payload (empty or not). void sendRequest(int streamNumber, QNetworkRequest::Priority priority = QNetworkRequest::NormalPriority, - const QByteArray &payload = QByteArray()); + const QByteArray &payload = QByteArray(), + const QHttp2Configuration &clientConfiguration = qt_defaultH2Configuration()); QUrl requestUrl(H2Type connnectionType) const; quint16 serverPort = 0; @@ -131,14 +155,14 @@ private: bool prefaceOK = false; bool serverGotSettingsACK = false; - static const Http2::RawSettings defaultServerSettings; + static const RawSettings defaultServerSettings; }; #define STOP_ON_FAILURE \ if (QTest::currentTestFailed()) \ return; -const Http2::RawSettings tst_Http2::defaultServerSettings{{Http2::Settings::MAX_CONCURRENT_STREAMS_ID, 100}}; +const RawSettings tst_Http2::defaultServerSettings{{Http2::Settings::MAX_CONCURRENT_STREAMS_ID, 100}}; namespace { @@ -308,18 +332,15 @@ void tst_Http2::flowControlClientSide() nRequests = 10; windowUpdates = 0; - Http2::ProtocolParameters params; + QHttp2Configuration params; // A small window size for a session, and even a smaller one per stream - // this will result in WINDOW_UPDATE frames both on connection stream and // per stream. - params.maxSessionReceiveWindowSize = Http2::defaultSessionWindowSize * 5; - params.settingsFrameData[Settings::INITIAL_WINDOW_SIZE_ID] = Http2::defaultSessionWindowSize; - // Inform our manager about non-default settings: - manager->setProperty(Http2::http2ParametersPropertyName, QVariant::fromValue(params)); - - const Http2::RawSettings serverSettings = {{Settings::MAX_CONCURRENT_STREAMS_ID, quint32(3)}}; - ServerPtr srv(newServer(serverSettings, defaultConnectionType(), params)); + params.setSessionReceiveWindowSize(Http2::defaultSessionWindowSize * 5); + params.setStreamReceiveWindowSize(Http2::defaultSessionWindowSize); + const RawSettings serverSettings = {{Settings::MAX_CONCURRENT_STREAMS_ID, quint32(3)}}; + ServerPtr srv(newServer(serverSettings, defaultConnectionType(), qt_H2ConfigurationToSettings(params))); const QByteArray respond(int(Http2::defaultSessionWindowSize * 10), 'x'); srv->setResponseBody(respond); @@ -330,7 +351,7 @@ void tst_Http2::flowControlClientSide() QVERIFY(serverPort != 0); for (int i = 0; i < nRequests; ++i) - sendRequest(i); + sendRequest(i, QNetworkRequest::NormalPriority, {}, params); runEventLoop(120000); STOP_ON_FAILURE @@ -359,7 +380,7 @@ void tst_Http2::flowControlServerSide() serverPort = 0; nRequests = 10; - const Http2::RawSettings serverSettings = {{Settings::MAX_CONCURRENT_STREAMS_ID, 7}}; + const RawSettings serverSettings = {{Settings::MAX_CONCURRENT_STREAMS_ID, 7}}; ServerPtr srv(newServer(serverSettings, defaultConnectionType())); @@ -392,12 +413,11 @@ void tst_Http2::pushPromise() serverPort = 0; nRequests = 1; - Http2::ProtocolParameters params; + QHttp2Configuration params; // Defaults are good, except ENABLE_PUSH: - params.settingsFrameData[Settings::ENABLE_PUSH_ID] = 1; - manager->setProperty(Http2::http2ParametersPropertyName, QVariant::fromValue(params)); + params.setServerPushEnabled(true); - ServerPtr srv(newServer(defaultServerSettings, defaultConnectionType(), params)); + ServerPtr srv(newServer(defaultServerSettings, defaultConnectionType(), qt_H2ConfigurationToSettings(params))); srv->enablePushPromise(true, QByteArray("/script.js")); QMetaObject::invokeMethod(srv.data(), "startServer", Qt::QueuedConnection); @@ -410,6 +430,7 @@ void tst_Http2::pushPromise() QNetworkRequest request(url); request.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, QVariant(true)); + request.setHttp2Configuration(params); auto reply = manager->get(request); connect(reply, &QNetworkReply::finished, this, &tst_Http2::replyFinished); @@ -678,6 +699,73 @@ void tst_Http2::connectToHost() QVERIFY(reply->isFinished()); } +void tst_Http2::maxFrameSize() +{ +#if !QT_CONFIG(ssl) + QSKIP("TLS support is needed for this test"); +#endif // QT_CONFIG(ssl) + + // Here we test we send 'MAX_FRAME_SIZE' setting in our + // 'SETTINGS'. If done properly, our server will not chunk + // the payload into several DATA frames. + +#if QT_CONFIG(securetransport) + // Normally on macOS we use plain text only for SecureTransport + // does not support ALPN on the server side. With 'direct encrytped' + // we have to use TLS sockets (== private key) and thus suppress a + // keychain UI asking for permission to use a private key. + // Our CI has this, but somebody testing locally - will have a problem. + qputenv("QT_SSL_USE_TEMPORARY_KEYCHAIN", QByteArray("1")); + auto envRollback = qScopeGuard([](){ + qunsetenv("QT_SSL_USE_TEMPORARY_KEYCHAIN"); + }); +#endif // QT_CONFIG(securetransport) + + auto connectionType = H2Type::h2Alpn; + auto attribute = QNetworkRequest::HTTP2AllowedAttribute; + if (clearTextHTTP2) { + connectionType = H2Type::h2Direct; + attribute = QNetworkRequest::Http2DirectAttribute; + } + + auto h2Config = qt_defaultH2Configuration(); + h2Config.setMaxFrameSize(Http2::minPayloadLimit * 3); + + serverPort = 0; + nRequests = 1; + + ServerPtr srv(newServer(defaultServerSettings, connectionType, + qt_H2ConfigurationToSettings(h2Config))); + srv->setResponseBody(QByteArray(Http2::minPayloadLimit * 2, 'q')); + QMetaObject::invokeMethod(srv.data(), "startServer", Qt::QueuedConnection); + runEventLoop(); + QVERIFY(serverPort != 0); + + const QSignalSpy frameCounter(srv.data(), &Http2Server::sendingData); + auto url = requestUrl(connectionType); + url.setPath(QString("/stream1.html")); + + QNetworkRequest request(url); + request.setAttribute(attribute, QVariant(true)); + request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("text/plain")); + request.setHttp2Configuration(h2Config); + + QNetworkReply *reply = manager->get(request); + reply->ignoreSslErrors(); + connect(reply, &QNetworkReply::finished, this, &tst_Http2::replyFinished); + + runEventLoop(); + STOP_ON_FAILURE + + // Normally, with a 16kb limit, our server would split such + // a response into 3 'DATA' frames (16kb + 16kb + 0|END_STREAM). + QCOMPARE(frameCounter.count(), 1); + + QVERIFY(nRequests == 0); + QVERIFY(prefaceOK); + QVERIFY(serverGotSettingsACK); +} + void tst_Http2::serverStarted(quint16 port) { serverPort = port; @@ -689,7 +777,6 @@ void tst_Http2::clearHTTP2State() windowUpdates = 0; prefaceOK = false; serverGotSettingsACK = false; - manager->setProperty(Http2::http2ParametersPropertyName, QVariant()); } void tst_Http2::runEventLoop(int ms) @@ -702,12 +789,11 @@ void tst_Http2::stopEventLoop() eventLoop.exitLoop(); } -Http2Server *tst_Http2::newServer(const Http2::RawSettings &serverSettings, H2Type connectionType, - const Http2::ProtocolParameters &clientSettings) +Http2Server *tst_Http2::newServer(const RawSettings &serverSettings, H2Type connectionType, + const RawSettings &clientSettings) { using namespace Http2; - auto srv = new Http2Server(connectionType, serverSettings, - clientSettings.settingsFrameData); + auto srv = new Http2Server(connectionType, serverSettings, clientSettings); using Srv = Http2Server; using Cl = tst_Http2; @@ -729,7 +815,8 @@ Http2Server *tst_Http2::newServer(const Http2::RawSettings &serverSettings, H2Ty void tst_Http2::sendRequest(int streamNumber, QNetworkRequest::Priority priority, - const QByteArray &payload) + const QByteArray &payload, + const QHttp2Configuration &h2Config) { auto url = requestUrl(defaultConnectionType()); url.setPath(QString("/stream%1.html").arg(streamNumber)); @@ -739,6 +826,7 @@ void tst_Http2::sendRequest(int streamNumber, request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, QVariant(true)); request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("text/plain")); request.setPriority(priority); + request.setHttp2Configuration(h2Config); QNetworkReply *reply = nullptr; if (payload.size()) diff --git a/tests/auto/network/access/qabstractnetworkcache/BLACKLIST b/tests/auto/network/access/qabstractnetworkcache/BLACKLIST deleted file mode 100644 index 12f45f0e12..0000000000 --- a/tests/auto/network/access/qabstractnetworkcache/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -[cacheControl] -windows-10 msvc-2015 diff --git a/tests/auto/network/access/qftp/BLACKLIST b/tests/auto/network/access/qftp/BLACKLIST index 463030a089..0a99f3eb00 100644 --- a/tests/auto/network/access/qftp/BLACKLIST +++ b/tests/auto/network/access/qftp/BLACKLIST @@ -7,15 +7,10 @@ redhatenterpriselinuxworkstation-6.6 redhatenterpriselinuxworkstation-6.6 [list] -ubuntu-16.04 opensuse-leap -osx-10.11 windows-7sp1 -ubuntu-18.04 -osx-10.14 -b2qt -osx-10.12 windows-10 msvc-2015 -opensuse-42.3 +ubuntu +osx [list:epsvNotSupported] * diff --git a/tests/auto/network/access/qnetworkreply/BLACKLIST b/tests/auto/network/access/qnetworkreply/BLACKLIST index f9bbdd96c3..2a0651f96f 100644 --- a/tests/auto/network/access/qnetworkreply/BLACKLIST +++ b/tests/auto/network/access/qnetworkreply/BLACKLIST @@ -1,106 +1,53 @@ # See qtbase/src/testlib/qtestblacklist.cpp for format [authenticationCacheAfterCancel] -windows-10 msvc-2017 -windows-10 msvc-2015 -osx-10.13 windows-7sp1 -[httpAbort] -ubuntu-16.04 -rhel-7.6 +windows-10 msvc-2015 [backgroundRequestInterruption] -ubuntu-16.04 opensuse-leap -ubuntu-18.04 -b2qt -osx-10.12 windows-10 msvc-2015 -opensuse-42.3 +b2qt +ubuntu +osx [backgroundRequestInterruption:ftp, bg, nobg] * -[getErrors] -osx-10.13 -# QTBUG-71953 [getErrors:ftp-host] linux # QTBUG-71953 [getFromHttp] -rhel-6.6 -ubuntu-16.04 -rhel-7.6 -opensuse-leap -osx-10.11 -osx-10.13 -windows-7sp1 -ubuntu-18.04 -osx-10.14 -rhel-7.4 -b2qt -windows-10 msvc-2017 -osx-10.12 -windows-10 msvc-2015 -opensuse-42.3 +* !android !winrt [getFromHttp:success-external] * [getFromHttpIntoBuffer] -osx-10.12 -osx-10.13 +osx [getFromHttpIntoBuffer2] -windows-10 msvc-2015 -windows-10 msvc-2017 +windows-10 [headFromHttp] -osx-10.13 windows-10 msvc-2017 -[ioGetFromHttpWithSocksProxy] -osx-10.12 [ioPostToHttpFromSocket] # QTBUG-66247 -osx-10.13 windows-7sp1 windows-10 msvc-2017 -osx-10.12 -windows-10 msvc-2015 +osx [ioHttpRedirect] -windows-10 msvc-2015 # QTBUG-66602 -windows-10 msvc-2017 +windows-10 [ioHttpRedirectMultipartPost] -ubuntu-16.04 -rhel-7.6 # QTBUG-66247 -opensuse-leap -osx-10.13 -ubuntu-18.04 -rhel-7.4 b2qt -osx-10.12 windows-10 msvc-2015 -opensuse-42.3 +ubuntu +rhel [ioHttpRedirectPolicy] -ubuntu-16.04 opensuse-leap -windows-7sp1 -ubuntu-18.04 b2qt -windows-10 msvc-2017 -windows-10 msvc-2015 -opensuse-42.3 -[ioHttpRedirectPostPut] -osx-10.12 -windows-10 msvc-2015 +ubuntu +windows-10 [putToFtp] -windows-10 msvc-2017 +windows-10 [putWithServerClosingConnectionImmediately] -osx-10.11 -osx-10.13 -windows-7sp1 -windows-10 msvc-2017 -osx-10.12 -windows-10 msvc-2015 -[qtbug28035browserDoesNotLoadQtProjectOrgCorrectly] -windows-10 msvc-2015 windows-7sp1 -[authenticationWithDifferentRealm] -osx-10.13 +windows-10 +osx [backgroundRequest] osx-10.12 [connectToIPv6Address] @@ -109,141 +56,73 @@ osx-10.12 osx-10.12 [downloadProgress] osx-10.12 -[emitErrorForAllReplies] -osx-10.12 [encrypted] osx-10.13 -[ftpAuthentication] -osx-10.13 [httpCanReadLine] osx-10.12 -osx-10.13 [httpRecursiveCreation] -osx-10.12 -osx-10.13 +osx [httpWithNoCredentialUsage] osx-10.12 [ignoreSslErrorsList] -osx-10.12 -osx-10.13 +osx [ignoreSslErrorsListWithSlot] -osx-10.12 -osx-10.13 +osx [ioGetFromBuiltinHttp] -osx-10.12 -osx-10.11 -osx-10.14 -osx-10.13 +osx [ioGetFromHttp] osx-10.12 -[ioGetFromHttpWithAuth] -osx-10.12 -osx-10.13 -[ioGetFromHttpWithAuthSynchronous] -osx-10.12 -[ioGetFromHttpWithProxyAuth] -osx-10.12 -[ioGetFromHttpWithReuseParallel] -osx-10.12 -osx-10.13 -[ioGetFromHttpWithReuseSequential] -osx-10.12 -osx-10.13 -[ioGetFromHttpsWithIgnoreSslErrors] -osx-10.12 -[ioGetFromHttpsWithSslErrors] -osx-10.12 -[ioGetFromHttpsWithSslHandshakeError] -osx-10.12 -[ioGetWithManyProxies] -osx-10.12 [ioPostToHttpFromFile] osx-10.13 -[ioPostToHttpFromMiddleOfFileFiveBytes] -osx-10.13 -[ioPostToHttpFromMiddleOfFileToEnd] -osx-10.13 -[ioPostToHttpFromMiddleOfQBufferFiveBytes] -osx-10.13 [ioPostToHttpFromSocketSynchronous] -osx-10.12 -osx-10.13 -[ioPostToHttpNoBufferFlag] -osx-10.13 +osx [ioPostToHttpUploadProgress] -osx-10.12 -osx-10.11 -osx-10.13 +osx [ioPutToHttpFromFile] osx-10.13 [lastModifiedHeaderForHttp] osx-10.12 -osx-10.13 [multipartSkipIndices] osx-10.12 -osx-10.13 [nestedEventLoops] -osx-10.12 -osx-10.13 -[pipelining] -osx-10.13 +osx [postToHttp] osx-10.12 -osx-10.13 [postToHttpMultipart] osx-10.12 -osx-10.13 [postToHttpSynchronous] osx-10.12 -osx-10.13 [postToHttps] -osx-10.12 -osx-10.13 +osx [postToHttpsMultipart] -osx-10.12 -osx-10.13 +osx [postToHttpsSynchronous] -osx-10.12 -osx-10.13 +osx [putGetDeleteGetFromHttp] osx-10.12 -[putToHttp] -osx-10.12 -osx-10.13 [putToHttpSynchronous] osx-10.12 -osx-10.13 [putToHttps] -osx-10.12 -osx-10.13 +osx [putToHttpsSynchronous] -osx-10.12 -osx-10.13 +osx [putWithRateLimiting] -osx-10.12 osx-10.13 [qtbug13431replyThrottling] osx-10.12 [receiveCookiesFromHttp] -osx-10.12 -osx-10.13 +osx [receiveCookiesFromHttpSynchronous] -osx-10.12 -osx-10.13 +osx [sendCookies] -osx-10.12 -osx-10.13 +osx [sendCookiesSynchronous] -osx-10.12 -osx-10.13 +osx [sendCustomRequestToHttp] osx-10.12 [sslConfiguration] -osx-10.12 -osx-10.13 +osx [synchronousRequest] -osx-10.12 -osx-10.13 +osx [backgroundRequestConnectInBackground] -osx-10.12 -osx-10.13 +osx diff --git a/tests/auto/network/access/spdy/BLACKLIST b/tests/auto/network/access/spdy/BLACKLIST index ce2f7f383f..5cf79327be 100644 --- a/tests/auto/network/access/spdy/BLACKLIST +++ b/tests/auto/network/access/spdy/BLACKLIST @@ -1,8 +1,5 @@ [download] opensuse-leap -ubuntu-18.04 -ubuntu-16.04 -b2qt [upload] opensuse-leap ubuntu-18.04 diff --git a/tests/auto/network/kernel/qdnslookup/BLACKLIST b/tests/auto/network/kernel/qdnslookup/BLACKLIST index 4461d8b5f7..f07a8ce9a3 100644 --- a/tests/auto/network/kernel/qdnslookup/BLACKLIST +++ b/tests/auto/network/kernel/qdnslookup/BLACKLIST @@ -1,12 +1,2 @@ [lookup] -rhel-7.6 -opensuse-leap -osx-10.13 -windows-7sp1 -ubuntu-18.04 -rhel-7.4 -b2qt -windows-10 msvc-2017 -osx-10.12 -windows-10 msvc-2015 -opensuse-42.3 +* diff --git a/tests/auto/network/socket/qsocks5socketengine/BLACKLIST b/tests/auto/network/socket/qsocks5socketengine/BLACKLIST index f769aafbdd..61fff6ee00 100644 --- a/tests/auto/network/socket/qsocks5socketengine/BLACKLIST +++ b/tests/auto/network/socket/qsocks5socketengine/BLACKLIST @@ -4,8 +4,7 @@ ubuntu-18.04 # QTBUG-74162 [passwordAuth2] -osx-10.12 -ubuntu-18.04 +ubuntu [downloadBigFile] windows-10 msvc-2015 windows-7sp1 diff --git a/tests/auto/network/socket/qtcpserver/BLACKLIST b/tests/auto/network/socket/qtcpserver/BLACKLIST index ad0edf0af1..e268468bdb 100644 --- a/tests/auto/network/socket/qtcpserver/BLACKLIST +++ b/tests/auto/network/socket/qtcpserver/BLACKLIST @@ -1,24 +1,16 @@ -[listenWhileListening] -windows-10 msvc-2015 [listenWhileListening:WithSocks5Proxy] linux windows [ipv6Server] -windows-10 msvc-2015 windows-7sp1 windows-10 msvc-2017 [ipv6Server:WithoutProxy] windows osx -[addressReusable] -windows-10 msvc-2015 [eagainBlockingAccept] -windows-10 msvc-2015 -windows-7sp1 -windows-10 msvc-2017 -[proxyFactory] windows-7sp1 +windows-10 [serverAddress] -windows-10 msvc-2017 -windows-10 msvc-2015 windows-7sp1 +windows-10 + diff --git a/tests/auto/network/socket/qtcpsocket/BLACKLIST b/tests/auto/network/socket/qtcpsocket/BLACKLIST index 8c2f8d2638..07532710b3 100644 --- a/tests/auto/network/socket/qtcpsocket/BLACKLIST +++ b/tests/auto/network/socket/qtcpsocket/BLACKLIST @@ -5,9 +5,6 @@ windows-7sp1 windows [bind:[::]:randomport] windows -[timeoutConnect] -windows-10 msvc-2015 -# QTBUG-66247 [timeoutConnect:ip] windows # QTBUG-66247 diff --git a/tests/auto/network/socket/qudpsocket/BLACKLIST b/tests/auto/network/socket/qudpsocket/BLACKLIST index 9b5aa8a3fc..bc6068d695 100644 --- a/tests/auto/network/socket/qudpsocket/BLACKLIST +++ b/tests/auto/network/socket/qudpsocket/BLACKLIST @@ -2,15 +2,9 @@ windows-10 msvc-2017 windows-10 msvc-2015 windows-7sp1 -[multicastLeaveAfterClose] -osx-10.12 -osx-10.11 [readyReadForEmptyDatagram] opensuse-leap -ubuntu-16.04 [echo] opensuse-42.3 -[ipv6Loop] -osx-10.12 [readyReadForEmptyDatagram] linux diff --git a/tests/auto/network/ssl/qsslkey/BLACKLIST b/tests/auto/network/ssl/qsslkey/BLACKLIST index e9723001f5..19fb15cd1f 100644 --- a/tests/auto/network/ssl/qsslkey/BLACKLIST +++ b/tests/auto/network/ssl/qsslkey/BLACKLIST @@ -1,16 +1,9 @@ [constructor] -rhel-6.6 -rhel-7.4 -rhel-7.6 +rhel [length] -rhel-6.6 -rhel-7.4 -rhel-7.6 +rhel [toEncryptedPemOrDer] -rhel-6.6 -rhel-7.4 -rhel-7.6 +rhel [toPemOrDer] -rhel-6.6 -rhel-7.4 -rhel-7.6 +rhel + diff --git a/tests/auto/network/ssl/qsslsocket/BLACKLIST b/tests/auto/network/ssl/qsslsocket/BLACKLIST index 36143691c9..7b4a29f463 100644 --- a/tests/auto/network/ssl/qsslsocket/BLACKLIST +++ b/tests/auto/network/ssl/qsslsocket/BLACKLIST @@ -1,11 +1,7 @@ -[abortOnSslErrors] -windows-10 msvc-2015 [deprecatedProtocols] windows [spontaneousWrite] windows-7sp1 -[sslErrors] -windows-7sp1 [connectToHostEncrypted] osx-10.13 [setSslConfiguration] diff --git a/tests/auto/other/networkselftest/BLACKLIST b/tests/auto/other/networkselftest/BLACKLIST index 948081eb78..55ebad985d 100644 --- a/tests/auto/other/networkselftest/BLACKLIST +++ b/tests/auto/other/networkselftest/BLACKLIST @@ -1,6 +1,5 @@ # QTBUG-27571 [ftpProxyServer] -windows-10 msvc-2017 -windows-10 msvc-2015 windows-7sp1 +windows-10 diff --git a/tests/auto/other/qfocusevent/BLACKLIST b/tests/auto/other/qfocusevent/BLACKLIST deleted file mode 100644 index 5af8be91a0..0000000000 --- a/tests/auto/other/qfocusevent/BLACKLIST +++ /dev/null @@ -1,3 +0,0 @@ -[checkReason_ActiveWindow] -winrt - diff --git a/tests/auto/other/qnetworkaccessmanager_and_qprogressdialog/BLACKLIST b/tests/auto/other/qnetworkaccessmanager_and_qprogressdialog/BLACKLIST index 65a939cdcb..6173488c00 100644 --- a/tests/auto/other/qnetworkaccessmanager_and_qprogressdialog/BLACKLIST +++ b/tests/auto/other/qnetworkaccessmanager_and_qprogressdialog/BLACKLIST @@ -1,5 +1,4 @@ [downloadCheck] -windows-10 msvc-2015 -windows-10 msvc-2017 +windows-10 [downloadCheck:with-zeroCopy] windows diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/BLACKLIST b/tests/auto/widgets/dialogs/qfilesystemmodel/BLACKLIST index f2f0f8d26e..aae2cacc3b 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/BLACKLIST +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/BLACKLIST @@ -7,13 +7,10 @@ b2qt [specialFiles] b2qt [dirsBeforeFiles] -ubuntu-16.04 -rhel-7.6 -windows-10 msvc-2017 -ubuntu-18.04 -b2qt winrt -windows-10 msvc-2015 - +b2qt +ubuntu +windows-10 +rhel [drives] winrt diff --git a/tests/auto/widgets/dialogs/qmessagebox/BLACKLIST b/tests/auto/widgets/dialogs/qmessagebox/BLACKLIST index e633e7c0a3..8d8a7c2105 100644 --- a/tests/auto/widgets/dialogs/qmessagebox/BLACKLIST +++ b/tests/auto/widgets/dialogs/qmessagebox/BLACKLIST @@ -1,6 +1,4 @@ [defaultButton] -ubuntu-16.04 -rhel-7.6 opensuse-leap -ubuntu-18.04 -rhel-7.4 +rhel-7.6 +ubuntu diff --git a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp index da75e64d1e..243cb6483e 100644 --- a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp +++ b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp @@ -417,7 +417,7 @@ void tst_QWizard::setPixmap() QVERIFY(wizard.pixmap(QWizard::BannerPixmap).isNull()); QVERIFY(wizard.pixmap(QWizard::LogoPixmap).isNull()); QVERIFY(wizard.pixmap(QWizard::WatermarkPixmap).isNull()); - if (QSysInfo::macVersion() <= Q_MV_OSX(10, 13)) + if (QOperatingSystemVersion::current() <= QOperatingSystemVersion::MacOSHighSierra) QVERIFY(!wizard.pixmap(QWizard::BackgroundPixmap).isNull()); else QVERIFY(wizard.pixmap(QWizard::BackgroundPixmap).isNull()); @@ -425,7 +425,7 @@ void tst_QWizard::setPixmap() QVERIFY(page->pixmap(QWizard::BannerPixmap).isNull()); QVERIFY(page->pixmap(QWizard::LogoPixmap).isNull()); QVERIFY(page->pixmap(QWizard::WatermarkPixmap).isNull()); - if (QSysInfo::macVersion() <= Q_MV_OSX(10, 13)) + if (QOperatingSystemVersion::current() <= QOperatingSystemVersion::MacOSHighSierra) QVERIFY(!wizard.pixmap(QWizard::BackgroundPixmap).isNull()); else QVERIFY(page->pixmap(QWizard::BackgroundPixmap).isNull()); diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 7b914512ab..72ea2ae31a 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -272,6 +272,9 @@ class tst_QGraphicsItem : public QObject { Q_OBJECT +public: + static void initMain(); + private slots: void construction(); void constructionWithParent(); @@ -474,6 +477,14 @@ private: QTouchDevice *m_touchDevice = nullptr; }; +void tst_QGraphicsItem::initMain() +{ +#ifdef Q_OS_WIN + // Ensure minimum size constraints of framed windows on High DPI screens + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); +#endif +} + void tst_QGraphicsItem::construction() { for (int i = 0; i < 7; ++i) { diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST index a3c9e2e421..c3797c9d57 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST @@ -1,7 +1,5 @@ [isActive] opensuse-42.3 ci -[removeFullyTransparentItem] -osx-10.12 [tabFocus_sceneWithNestedFocusWidgets] opensuse-42.3 diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index 46f1d5df5c..950f3ef670 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.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. @@ -26,11 +26,24 @@ ** ****************************************************************************/ +#include <QtWidgets/QApplication> +#include <QtWidgets/QDial> +#include <QtWidgets/QLabel> +#include <QtWidgets/QLineEdit> +#include <QtWidgets/QGraphicsView> +#include <QtWidgets/QGraphicsScene> +#include <QtWidgets/QGraphicsPixmapItem> +#include <QtWidgets/QStyle> +#include <QtWidgets/QStyleFactory> +#include <QtWidgets/QVBoxLayout> + +#include <QtGui/QScreen> #include <QtTest/QtTest> -#include <QtGui> -#include <QtWidgets> +#include <QtCore/QDebug> +#include <QtCore/QLoggingCategory> + #include <private/qgraphicsscene_p.h> #include <private/qgraphicssceneindex_p.h> #include <math.h> @@ -39,7 +52,7 @@ #include <private/qinputmethod_p.h> #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) -#include <windows.h> +#include <QtCore/qt_windows.h> #define Q_CHECK_PAINTEVENTS \ if (::SwitchDesktop(::GetThreadDesktop(::GetCurrentThreadId())) == 0) \ QSKIP("The Graphics View doesn't get the paint events"); @@ -51,6 +64,7 @@ Q_DECLARE_METATYPE(Qt::FocusReason) Q_DECLARE_METATYPE(QPainterPath) Q_DECLARE_METATYPE(Qt::AspectRatioMode) Q_DECLARE_METATYPE(Qt::ItemSelectionMode) +Q_DECLARE_METATYPE(QGraphicsItem::GraphicsItemFlags) static const int randomX[] = {276, 40, 250, 864, -56, 426, 855, 825, 184, 955, -798, -804, 773, 282, 489, 686, 780, -220, 50, 749, -856, -205, 81, 492, -819, 518, @@ -95,14 +109,16 @@ static const int randomY[] = {603, 70, -318, 843, 450, -637, 199, -527, 407, 964 -588, 864, 234, 225, -303, 493, 246, 153, 338, -378, 377, -819, 140, 136, 467, -849, -326, -533, 166, 252, -994, -699, 904, -566, 621, -752}; +Q_LOGGING_CATEGORY(lcTests, "qt.widgets.tests") + class HoverItem : public QGraphicsRectItem { public: HoverItem() - : QGraphicsRectItem(QRectF(-10, -10, 20, 20)), isHovered(false) + : QGraphicsRectItem(QRectF(-10, -10, 20, 20)) { setAcceptHoverEvents(true); } - bool isHovered; + bool isHovered = false; protected: void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) @@ -128,13 +144,13 @@ class EventSpy : public QGraphicsWidget Q_OBJECT public: EventSpy(QObject *watched, QEvent::Type type) - : _count(0), spied(type) + : spied(type) { watched->installEventFilter(this); } EventSpy(QGraphicsScene *scene, QGraphicsItem *watched, QEvent::Type type) - : _count(0), spied(type) + : spied(type) { scene->addItem(this); watched->installSceneEventFilter(this); @@ -143,7 +159,7 @@ public: int count() const { return _count; } protected: - bool eventFilter(QObject *watched, QEvent *event) + bool eventFilter(QObject *watched, QEvent *event) override { Q_UNUSED(watched); if (event->type() == spied) @@ -151,7 +167,7 @@ protected: return false; } - bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) + bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override { Q_UNUSED(watched); if (event->type() == spied) @@ -159,13 +175,17 @@ protected: return false; } - int _count; - QEvent::Type spied; + int _count = 0; + const QEvent::Type spied; }; class tst_QGraphicsScene : public QObject { Q_OBJECT +public: + tst_QGraphicsScene(); + static void initMain() { QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); } + public slots: void cleanup(); @@ -268,13 +288,26 @@ private slots: void taskQTBUG_15977_renderWithDeviceCoordinateCache(); void taskQTBUG_16401_focusItem(); void taskQTBUG_42915_focusNextPrevChild(); + +private: + QRect m_availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); + QSize m_testSize; }; +tst_QGraphicsScene::tst_QGraphicsScene() +{ + const int testSize = qMax(200, m_availableGeometry.width() / 10); + m_testSize.setWidth(testSize); + m_testSize.setHeight(testSize); +} + void tst_QGraphicsScene::cleanup() { // ensure not even skipped tests with custom input context leave it dangling - QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); - inputMethodPrivate->testContext = 0; + QInputMethodPrivate *inputMethodPrivate = + QInputMethodPrivate::get(QGuiApplication::inputMethod()); + inputMethodPrivate->testContext = nullptr; + QTRY_VERIFY(QApplication::topLevelWidgets().isEmpty()); } void tst_QGraphicsScene::construction() @@ -287,7 +320,7 @@ void tst_QGraphicsScene::construction() QVERIFY(scene.items(QPolygonF()).isEmpty()); QVERIFY(scene.items(QPainterPath()).isEmpty()); QTest::ignoreMessage(QtWarningMsg, "QGraphicsScene::collidingItems: cannot find collisions for null item"); - QVERIFY(scene.collidingItems(0).isEmpty()); + QVERIFY(scene.collidingItems(nullptr).isEmpty()); QVERIFY(scene.items(QPointF()).isEmpty()); QVERIFY(scene.selectedItems().isEmpty()); QVERIFY(!scene.focusItem()); @@ -301,7 +334,7 @@ static inline const QGraphicsItem *itemAt(const QGraphicsScene &scene, qreal x, void tst_QGraphicsScene::sceneRect() { QGraphicsScene scene; - QSignalSpy sceneRectChanged(&scene, SIGNAL(sceneRectChanged(QRectF))); + QSignalSpy sceneRectChanged(&scene, &QGraphicsScene::sceneRectChanged); QCOMPARE(scene.sceneRect(), QRectF()); QCOMPARE(sceneRectChanged.count(), 0); @@ -435,9 +468,9 @@ void tst_QGraphicsScene::items() scene.removeItem(items.at(5)); delete items.at(5); - QVERIFY(!scene.items().contains(0)); + QVERIFY(!scene.items().contains(nullptr)); delete items.at(7); - QVERIFY(!scene.items().contains(0)); + QVERIFY(!scene.items().contains(nullptr)); } { QGraphicsScene scene; @@ -516,7 +549,7 @@ void tst_QGraphicsScene::itemsBoundingRect() QGraphicsScene scene; - foreach (QRectF rect, rects) { + for (const auto &rect : qAsConst(rects)) { QPainterPath path; path.addRect(rect); QGraphicsPathItem *item = scene.addPath(path); @@ -581,7 +614,7 @@ void tst_QGraphicsScene::items_QPointF() int n = 0; QList<QGraphicsItem *> addedItems; - foreach(QRectF rect, items) { + for (const auto &rect : qAsConst(items)) { QPainterPath path; path.addRect(0, 0, rect.width(), rect.height()); @@ -593,7 +626,8 @@ void tst_QGraphicsScene::items_QPointF() } QList<int> itemIndexes; - foreach (QGraphicsItem *item, scene.items(point)) + const auto &actualItemsAtPoint = scene.items(point); + for (QGraphicsItem *item : actualItemsAtPoint) itemIndexes << addedItems.indexOf(item); QCOMPARE(itemIndexes, itemsAtPoint); @@ -912,12 +946,11 @@ void tst_QGraphicsScene::items_QPainterPath_2() class CustomView : public QGraphicsView { public: - CustomView() : repaints(0) - { } + using QGraphicsView::QGraphicsView; - int repaints; + int repaints = 0; protected: - void paintEvent(QPaintEvent *event) + void paintEvent(QPaintEvent *event) override { ++repaints; QGraphicsView::paintEvent(event); @@ -927,7 +960,7 @@ protected: void tst_QGraphicsScene::selectionChanged() { QGraphicsScene scene(0, 0, 1000, 1000); - QSignalSpy spy(&scene, SIGNAL(selectionChanged())); + QSignalSpy spy(&scene, &QGraphicsScene::selectionChanged); QCOMPARE(spy.count(), 0); QPainterPath path; @@ -997,7 +1030,7 @@ void tst_QGraphicsScene::selectionChanged() void tst_QGraphicsScene::selectionChanged2() { QGraphicsScene scene; - QSignalSpy spy(&scene, SIGNAL(selectionChanged())); + QSignalSpy spy(&scene, &QGraphicsScene::selectionChanged); QGraphicsItem *item1 = scene.addRect(0, 0, 100, 100); QGraphicsItem *item2 = scene.addRect(100, 100, 100, 100); @@ -1009,13 +1042,13 @@ void tst_QGraphicsScene::selectionChanged2() QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress); event.setScenePos(QPointF(50, 50)); event.setButton(Qt::LeftButton); - qApp->sendEvent(&scene, &event); + QCoreApplication::sendEvent(&scene, &event); } { QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMouseRelease); event.setScenePos(QPointF(50, 50)); event.setButton(Qt::LeftButton); - qApp->sendEvent(&scene, &event); + QCoreApplication::sendEvent(&scene, &event); } QVERIFY(item1->isSelected()); QVERIFY(!item2->isSelected()); @@ -1024,13 +1057,13 @@ void tst_QGraphicsScene::selectionChanged2() QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress); event.setScenePos(QPointF(150, 150)); event.setButton(Qt::LeftButton); - qApp->sendEvent(&scene, &event); + QCoreApplication::sendEvent(&scene, &event); } { QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMouseRelease); event.setScenePos(QPointF(150, 150)); event.setButton(Qt::LeftButton); - qApp->sendEvent(&scene, &event); + QCoreApplication::sendEvent(&scene, &event); } QVERIFY(!item1->isSelected()); QVERIFY(item2->isSelected()); @@ -1040,7 +1073,7 @@ void tst_QGraphicsScene::selectionChanged2() event.setScenePos(QPointF(50, 50)); event.setButton(Qt::LeftButton); event.setModifiers(Qt::ControlModifier); - qApp->sendEvent(&scene, &event); + QCoreApplication::sendEvent(&scene, &event); } QVERIFY(!item1->isSelected()); QVERIFY(item2->isSelected()); @@ -1049,7 +1082,7 @@ void tst_QGraphicsScene::selectionChanged2() QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMouseRelease); event.setScenePos(QPointF(50, 50)); event.setButton(Qt::LeftButton); - qApp->sendEvent(&scene, &event); + QCoreApplication::sendEvent(&scene, &event); } QVERIFY(item1->isSelected()); QVERIFY(!item2->isSelected()); @@ -1065,10 +1098,12 @@ void tst_QGraphicsScene::addItem() QGraphicsScene scene; CustomView view; + view.setWindowTitle(QTest::currentTestFunction()); view.setScene(&scene); + view.resize(m_testSize); view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); - qApp->processEvents(); + QCoreApplication::processEvents(); view.repaints = 0; scene.addItem(path); @@ -1115,14 +1150,14 @@ void tst_QGraphicsScene::addEllipse() QCOMPARE(ellipse->pen(), QPen(Qt::red)); QCOMPARE(ellipse->brush(), QBrush(Qt::blue)); QCOMPARE(ellipse->rect(), QRectF(-10, -10, 20, 20)); - QCOMPARE(itemAt(scene, 0, 0), (QGraphicsItem *)ellipse); + QCOMPARE(itemAt(scene, 0, 0), ellipse); QVERIFY(scene.items(QPointF(-10, -10)).isEmpty()); - QCOMPARE(itemAt(scene, -9.9, 0), (QGraphicsItem *)ellipse); + QCOMPARE(itemAt(scene, -9.9, 0), ellipse); QVERIFY(scene.items(QPointF(-10, 10)).isEmpty()); - QCOMPARE(itemAt(scene, 0, -9.9), (QGraphicsItem *)ellipse); - QCOMPARE(itemAt(scene, 0, 9.9), (QGraphicsItem *)ellipse); + QCOMPARE(itemAt(scene, 0, -9.9), ellipse); + QCOMPARE(itemAt(scene, 0, 9.9), ellipse); QVERIFY(scene.items(QPointF(10, -10)).isEmpty()); - QCOMPARE(itemAt(scene, 9.9, 0), (QGraphicsItem *)ellipse); + QCOMPARE(itemAt(scene, 9.9, 0), ellipse); QVERIFY(scene.items(QPointF(10, 10)).isEmpty()); } @@ -1136,15 +1171,15 @@ void tst_QGraphicsScene::addLine() QCOMPARE(line->pos(), QPointF()); QCOMPARE(line->pen(), pen); QCOMPARE(line->line(), QLineF(-10, -10, 20, 20)); - QCOMPARE(itemAt(scene, 0, 0), (QGraphicsItem *)line); - QCOMPARE(itemAt(scene, -10, -10), (QGraphicsItem *)line); + QCOMPARE(itemAt(scene, 0, 0), line); + QCOMPARE(itemAt(scene, -10, -10), line); QVERIFY(scene.items(QPointF(-9.9, 0)).isEmpty()); QVERIFY(scene.items(QPointF(-10, 10)).isEmpty()); QVERIFY(scene.items(QPointF(0, -9.9)).isEmpty()); QVERIFY(scene.items(QPointF(0, 9.9)).isEmpty()); QVERIFY(scene.items(QPointF(10, -10)).isEmpty()); QVERIFY(scene.items(QPointF(9.9, 0)).isEmpty()); - QCOMPARE(itemAt(scene, 10, 10), (QGraphicsItem *)line); + QCOMPARE(itemAt(scene, 10, 10), line); } void tst_QGraphicsScene::addPath() @@ -1162,16 +1197,16 @@ void tst_QGraphicsScene::addPath() path->setPen(QPen(Qt::red, 0)); - QCOMPARE(itemAt(scene, 0, 0), (QGraphicsItem *)path); - QCOMPARE(itemAt(scene, -9.9, 0), (QGraphicsItem *)path); - QCOMPARE(itemAt(scene, 9.9, 0), (QGraphicsItem *)path); - QCOMPARE(itemAt(scene, 0, -9.9), (QGraphicsItem *)path); - QCOMPARE(itemAt(scene, 0, 9.9), (QGraphicsItem *)path); - QCOMPARE(itemAt(scene, 0, 30), (QGraphicsItem *)path); - QCOMPARE(itemAt(scene, -9.9, 30), (QGraphicsItem *)path); - QCOMPARE(itemAt(scene, 9.9, 30), (QGraphicsItem *)path); - QCOMPARE(itemAt(scene, 0, 20.1), (QGraphicsItem *)path); - QCOMPARE(itemAt(scene, 0, 39.9), (QGraphicsItem *)path); + QCOMPARE(itemAt(scene, 0, 0), path); + QCOMPARE(itemAt(scene, -9.9, 0), path); + QCOMPARE(itemAt(scene, 9.9, 0), path); + QCOMPARE(itemAt(scene, 0, -9.9), path); + QCOMPARE(itemAt(scene, 0, 9.9), path); + QCOMPARE(itemAt(scene, 0, 30), path); + QCOMPARE(itemAt(scene, -9.9, 30), path); + QCOMPARE(itemAt(scene, 9.9, 30), path); + QCOMPARE(itemAt(scene, 0, 20.1), path); + QCOMPARE(itemAt(scene, 0, 39.9), path); QVERIFY(scene.items(QPointF(-10, -10)).isEmpty()); QVERIFY(scene.items(QPointF(10, -10)).isEmpty()); QVERIFY(scene.items(QPointF(-10, 10)).isEmpty()); @@ -1193,10 +1228,10 @@ void tst_QGraphicsScene::addPixmap() QCOMPARE(pixmap->pos(), QPointF()); QCOMPARE(pixmap->pixmap(), pix); - QCOMPARE(itemAt(scene, 0, 0), (QGraphicsItem *)pixmap); - QCOMPARE(itemAt(scene, pix.width() - 1, 0), (QGraphicsItem *)pixmap); - QCOMPARE(itemAt(scene, 0, pix.height() - 1), (QGraphicsItem *)pixmap); - QCOMPARE(itemAt(scene, pix.width() - 1, pix.height() - 1), (QGraphicsItem *)pixmap); + QCOMPARE(itemAt(scene, 0, 0), pixmap); + QCOMPARE(itemAt(scene, pix.width() - 1, 0), pixmap); + QCOMPARE(itemAt(scene, 0, pix.height() - 1), pixmap); + QCOMPARE(itemAt(scene, pix.width() - 1, pix.height() - 1), pixmap); QVERIFY(scene.items(QPointF(-1, -1)).isEmpty()); QVERIFY(scene.items(QPointF(pix.width() - 1, -1)).isEmpty()); @@ -1218,14 +1253,14 @@ void tst_QGraphicsScene::addRect() rect->setPen(QPen(Qt::red, 0)); - QCOMPARE(itemAt(scene, 0, 0), (QGraphicsItem *)rect); - QCOMPARE(itemAt(scene, -10, -10), (QGraphicsItem *)rect); - QCOMPARE(itemAt(scene, -9.9, 0), (QGraphicsItem *)rect); + QCOMPARE(itemAt(scene, 0, 0),rect); + QCOMPARE(itemAt(scene, -10, -10), rect); + QCOMPARE(itemAt(scene, -9.9, 0), rect); QVERIFY(scene.items(QPointF(-10, 10)).isEmpty()); - QCOMPARE(itemAt(scene, 0, -9.9), (QGraphicsItem *)rect); - QCOMPARE(itemAt(scene, 0, 9.9), (QGraphicsItem *)rect); + QCOMPARE(itemAt(scene, 0, -9.9), rect); + QCOMPARE(itemAt(scene, 0, 9.9), rect); QVERIFY(scene.items(QPointF(10, -10)).isEmpty()); - QCOMPARE(itemAt(scene, 9.9, 0), (QGraphicsItem *)rect); + QCOMPARE(itemAt(scene, 9.9, 0), rect); QVERIFY(scene.items(QPointF(10, 10)).isEmpty()); } @@ -1271,6 +1306,7 @@ void tst_QGraphicsScene::removeItem() scene.setSceneRect(-50, -50, 100, 100); QGraphicsView view(&scene); + view.setWindowTitle(QTest::currentTestFunction()); view.setFixedSize(150, 150); view.show(); QApplication::setActiveWindow(&view); @@ -1342,7 +1378,7 @@ void tst_QGraphicsScene::focusItem() class FocusItem : public QGraphicsTextItem { protected: - void focusOutEvent(QFocusEvent *) + void focusOutEvent(QFocusEvent *) override { QVERIFY(!scene()->focusItem()); } @@ -1359,14 +1395,14 @@ void tst_QGraphicsScene::focusItemLostFocus() scene.addItem(item); item->setFocus(); - QCOMPARE(scene.focusItem(), (QGraphicsItem *)item); + QCOMPARE(scene.focusItem(), item); item->clearFocus(); } class ClearTestItem : public QGraphicsRectItem { public: - ClearTestItem(QGraphicsItem *parent = 0) : QGraphicsRectItem(parent) {} + using QGraphicsRectItem::QGraphicsRectItem; ~ClearTestItem() { qDeleteAll(items); } QList<QGraphicsItem *> items; }; @@ -1389,7 +1425,7 @@ void tst_QGraphicsScene::clear() scene.setItemIndexMethod(QGraphicsScene::NoIndex); scene.addItem(firstItem); scene.addItem(secondItem); - QCOMPARE(scene.items().at(0), (QGraphicsItem*)firstItem); + QCOMPARE(scene.items().at(0), firstItem); QCOMPARE(scene.items().at(1), secondItem); ClearTestItem *thirdItem = new ClearTestItem(firstItem); @@ -1441,7 +1477,7 @@ void tst_QGraphicsScene::setFocusItem() QVERIFY(item->hasFocus()); QVERIFY(!item2->hasFocus()); - scene.setFocusItem(0); + scene.setFocusItem(nullptr); QVERIFY(!item->hasFocus()); QVERIFY(!item2->hasFocus()); @@ -1562,26 +1598,26 @@ void tst_QGraphicsScene::hoverEvents_siblings() Q_CHECK_PAINTEVENTS QGraphicsScene scene; - QGraphicsItem *lastItem = 0; + QGraphicsItem *lastItem = nullptr; QList<HoverItem *> items; for (int i = 0; i < 15; ++i) { - QGraphicsItem *item = new HoverItem; + auto item = new HoverItem; scene.addItem(item); - items << (HoverItem *)item; - if (lastItem) { + items << item; + if (lastItem) item->setPos(lastItem->pos() + QPointF(sin(i / 3.0) * 17, cos(i / 3.0) * 17)); - } item->setZValue(i); lastItem = item; } QGraphicsView view(&scene); + view.setWindowTitle(QTest::currentTestFunction()); view.setRenderHint(QPainter::Antialiasing, true); view.setMinimumSize(400, 300); view.rotate(10); view.scale(1.7, 1.7); view.show(); - qApp->setActiveWindow(&view); + QApplication::setActiveWindow(&view); view.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&view)); @@ -1604,8 +1640,8 @@ void tst_QGraphicsScene::hoverEvents_siblings() mouseEvent.setScenePos(items.at(i)->mapToScene(0, 0)); QApplication::sendEvent(&scene, &mouseEvent); - qApp->processEvents(); // this posts updates from the scene to the view - qApp->processEvents(); // which trigger a repaint here + QCoreApplication::processEvents(); // this posts updates from the scene to the view + QCoreApplication::processEvents(); // which trigger a repaint here QTRY_VERIFY(items.at(i)->isHovered); if (j && i > 0) @@ -1621,8 +1657,8 @@ void tst_QGraphicsScene::hoverEvents_siblings() mouseEvent.setScenePos(QPointF(-1000, -1000)); QApplication::sendEvent(&scene, &mouseEvent); - qApp->processEvents(); // this posts updates from the scene to the view - qApp->processEvents(); // which trigger a repaint here + QCoreApplication::processEvents(); // this posts updates from the scene to the view + QCoreApplication::processEvents(); // which trigger a repaint here } } @@ -1631,12 +1667,12 @@ void tst_QGraphicsScene::hoverEvents_parentChild() Q_CHECK_PAINTEVENTS QGraphicsScene scene; - QGraphicsItem *lastItem = 0; + QGraphicsItem *lastItem = nullptr; QList<HoverItem *> items; for (int i = 0; i < 15; ++i) { - QGraphicsItem *item = new HoverItem; + auto item = new HoverItem; scene.addItem(item); - items << (HoverItem *)item; + items << item; if (lastItem) { item->setParentItem(lastItem); item->setPos(sin(i / 3.0) * 17, cos(i / 3.0) * 17); @@ -1645,12 +1681,13 @@ void tst_QGraphicsScene::hoverEvents_parentChild() } QGraphicsView view(&scene); + view.setWindowTitle(QTest::currentTestFunction()); view.setRenderHint(QPainter::Antialiasing, true); view.setMinimumSize(400, 300); view.rotate(10); view.scale(1.7, 1.7); view.show(); - qApp->setActiveWindow(&view); + QApplication::setActiveWindow(&view); QVERIFY(QTest::qWaitForWindowActive(&view)); QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseMove); @@ -1669,8 +1706,8 @@ void tst_QGraphicsScene::hoverEvents_parentChild() mouseEvent.setScenePos(items.at(i)->mapToScene(0, 0)); QApplication::sendEvent(&scene, &mouseEvent); - qApp->processEvents(); // this posts updates from the scene to the view - qApp->processEvents(); // which trigger a repaint here + QCoreApplication::processEvents(); // this posts updates from the scene to the view + QCoreApplication::processEvents(); // which trigger a repaint here QTRY_VERIFY(items.at(i)->isHovered); if (i < 14) @@ -1683,8 +1720,8 @@ void tst_QGraphicsScene::hoverEvents_parentChild() mouseEvent.setScenePos(QPointF(-1000, -1000)); QApplication::sendEvent(&scene, &mouseEvent); - qApp->processEvents(); // this posts updates from the scene to the view - qApp->processEvents(); // which trigger a repaint here + QCoreApplication::processEvents(); // this posts updates from the scene to the view + QCoreApplication::processEvents(); // which trigger a repaint here } } @@ -1712,23 +1749,23 @@ void tst_QGraphicsScene::createItemGroup() // All items in children1 are children of parent1 QGraphicsItem *parent1 = scene.addRect(QRectF(-10, -10, 20, 20)); - foreach (QGraphicsItem *item, children1) + for (QGraphicsItem *item : qAsConst(children1)) item->setParentItem(parent1); QGraphicsItemGroup *group = scene.createItemGroup(children1); QCOMPARE(group->parentItem(), parent1); - QCOMPARE(children1.first()->parentItem(), (QGraphicsItem *)group); + QCOMPARE(children1.first()->parentItem(), group); scene.destroyItemGroup(group); QCOMPARE(children1.first()->parentItem(), parent1); group = scene.createItemGroup(children1); QCOMPARE(group->parentItem(), parent1); - QCOMPARE(children1.first()->parentItem(), (QGraphicsItem *)group); + QCOMPARE(children1.first()->parentItem(), group); scene.destroyItemGroup(group); QCOMPARE(children1.first()->parentItem(), parent1); // All items in children2 are children of parent2 QGraphicsItem *parent2 = scene.addRect(QRectF(-10, -10, 20, 20)); - foreach (QGraphicsItem *item, children2) + for (QGraphicsItem *item : qAsConst(children2)) item->setParentItem(parent2); // Now make parent2 a child of parent1, so all children2 are also children @@ -1738,21 +1775,21 @@ void tst_QGraphicsScene::createItemGroup() // The children2 group should still have parent2 as their common ancestor. group = scene.createItemGroup(children2); QCOMPARE(group->parentItem(), parent2); - QCOMPARE(children2.first()->parentItem(), (QGraphicsItem *)group); + QCOMPARE(children2.first()->parentItem(), group); scene.destroyItemGroup(group); QCOMPARE(children2.first()->parentItem(), parent2); // But the set of both children2 and children1 share only parent1. group = scene.createItemGroup(children2 + children1); QCOMPARE(group->parentItem(), parent1); - QCOMPARE(children1.first()->parentItem(), (QGraphicsItem *)group); - QCOMPARE(children2.first()->parentItem(), (QGraphicsItem *)group); + QCOMPARE(children1.first()->parentItem(), group); + QCOMPARE(children2.first()->parentItem(), group); scene.destroyItemGroup(group); QCOMPARE(children1.first()->parentItem(), parent1); QCOMPARE(children2.first()->parentItem(), parent1); // Fixup the parent-child chain - foreach (QGraphicsItem *item, children2) + for (QGraphicsItem *item : qAsConst(children2)) item->setParentItem(parent2); // These share no common parent @@ -1762,7 +1799,7 @@ void tst_QGraphicsScene::createItemGroup() // Make children3 children of parent3 QGraphicsItem *parent3 = scene.addRect(QRectF(-10, -10, 20, 20)); - foreach (QGraphicsItem *item, children3) + for (QGraphicsItem *item : qAsConst(children3)) item->setParentItem(parent3); // These should have parent3 as a parent @@ -1794,15 +1831,14 @@ void tst_QGraphicsScene::createItemGroup() class EventTester : public QGraphicsEllipseItem { public: - EventTester() - : QGraphicsEllipseItem(QRectF(-10, -10, 20, 20)), ignoreMouse(false) + EventTester() : QGraphicsEllipseItem(QRectF(-10, -10, 20, 20)) { } - bool ignoreMouse; - QList<QEvent::Type> eventTypes; + bool ignoreMouse = false; + QVector<QEvent::Type> eventTypes; protected: - bool sceneEvent(QEvent *event) + bool sceneEvent(QEvent *event) override { eventTypes << QEvent::Type(event->type()); switch (event->type()) { @@ -1813,6 +1849,7 @@ protected: event->ignore(); return true; } + break; default: break; } @@ -1867,7 +1904,7 @@ void tst_QGraphicsScene::mouseEventPropagation() QCOMPARE(c->eventTypes.size(), 0); QCOMPARE(b->eventTypes.size(), 0); QCOMPARE(a->eventTypes.size(), 0); - QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)d); + QCOMPARE(scene.mouseGrabberItem(), d); // Send a move QApplication::sendEvent(&scene, &moveEvent); @@ -1876,7 +1913,7 @@ void tst_QGraphicsScene::mouseEventPropagation() QCOMPARE(c->eventTypes.size(), 0); QCOMPARE(b->eventTypes.size(), 0); QCOMPARE(a->eventTypes.size(), 0); - QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)d); + QCOMPARE(scene.mouseGrabberItem(), d); // Send a release QApplication::sendEvent(&scene, &releaseEvent); @@ -1898,7 +1935,7 @@ void tst_QGraphicsScene::mouseEventPropagation() QCOMPARE(c->eventTypes.at(1), QEvent::GraphicsSceneMousePress); QCOMPARE(b->eventTypes.size(), 0); QCOMPARE(a->eventTypes.size(), 0); - QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)c); + QCOMPARE(scene.mouseGrabberItem(), c); // Send another press, with a button that isn't actually accepted QApplication::sendEvent(&scene, &pressEvent); @@ -1908,7 +1945,7 @@ void tst_QGraphicsScene::mouseEventPropagation() QCOMPARE(c->eventTypes.at(2), QEvent::GraphicsSceneMousePress); QCOMPARE(b->eventTypes.size(), 0); QCOMPARE(a->eventTypes.size(), 0); - QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)c); + QCOMPARE(scene.mouseGrabberItem(), c); // Send a move QApplication::sendEvent(&scene, &moveEvent); @@ -1917,7 +1954,7 @@ void tst_QGraphicsScene::mouseEventPropagation() QCOMPARE(c->eventTypes.at(3), QEvent::GraphicsSceneMouseMove); QCOMPARE(b->eventTypes.size(), 0); QCOMPARE(a->eventTypes.size(), 0); - QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)c); + QCOMPARE(scene.mouseGrabberItem(), c); // Send a release QApplication::sendEvent(&scene, &releaseEvent); @@ -1950,7 +1987,7 @@ void tst_QGraphicsScene::mouseEventPropagation() QCOMPARE(c->eventTypes.at(7), QEvent::GraphicsSceneMousePress); QCOMPARE(b->eventTypes.size(), 0); QCOMPARE(a->eventTypes.size(), 0); - QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)c); + QCOMPARE(scene.mouseGrabberItem(), c); // Clicking outside the items removes the mouse grabber } @@ -1999,7 +2036,7 @@ void tst_QGraphicsScene::mouseEventPropagation_ignore() QCOMPARE(d->eventTypes.at(0), QEvent::GrabMouse); QCOMPARE(d->eventTypes.at(1), QEvent::GraphicsSceneMousePress); QCOMPARE(d->eventTypes.at(2), QEvent::UngrabMouse); - QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)a); + QCOMPARE(scene.mouseGrabberItem(), a); a->ignoreMouse = true; @@ -2115,7 +2152,7 @@ public: QVector<QPointF> mouseMovePoints; protected: - void mouseMoveEvent(QGraphicsSceneMouseEvent *event) + void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override { mouseMovePoints << event->scenePos(); } @@ -2140,22 +2177,17 @@ void tst_QGraphicsScene::mouseEventPropagation_mouseMove() class DndTester : public QGraphicsEllipseItem { public: - DndTester(const QRectF &rect) - : QGraphicsEllipseItem(rect), lastEvent(0), - ignoresDragEnter(false), ignoresDragMove(false) - - { - } + using QGraphicsEllipseItem::QGraphicsEllipseItem; ~DndTester() { delete lastEvent; } - QGraphicsSceneDragDropEvent *lastEvent; + QGraphicsSceneDragDropEvent *lastEvent = nullptr; QList<QEvent::Type> eventList; - bool ignoresDragEnter; - bool ignoresDragMove; + bool ignoresDragEnter = false; + bool ignoresDragMove = false; protected: void dragEnterEvent(QGraphicsSceneDragDropEvent *event) @@ -2218,21 +2250,21 @@ void tst_QGraphicsScene::dragAndDrop_simple() QMimeData mimeData; // Initial drag enter for the scene - QDragEnterEvent dragEnter(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragEnterEvent dragEnter(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragEnter); QVERIFY(dragEnter.isAccepted()); QCOMPARE(dragEnter.dropAction(), Qt::CopyAction); { // Move outside the item - QDragMoveEvent dragMove(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(!dragMove.isAccepted()); QCOMPARE(dragMove.dropAction(), Qt::CopyAction); } { // Move inside the item without setAcceptDrops - QDragMoveEvent dragMove(view.mapFromScene(item->scenePos()), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(view.mapFromScene(item->scenePos()), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(!dragMove.isAccepted()); QCOMPARE(dragMove.dropAction(), Qt::CopyAction); @@ -2241,7 +2273,7 @@ void tst_QGraphicsScene::dragAndDrop_simple() item->setAcceptDrops(true); { // Move inside the item with setAcceptDrops - QDragMoveEvent dragMove(view.mapFromScene(item->scenePos()), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(view.mapFromScene(item->scenePos()), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(dragMove.isAccepted()); QCOMPARE(dragMove.dropAction(), Qt::IgnoreAction); @@ -2255,7 +2287,7 @@ void tst_QGraphicsScene::dragAndDrop_simple() } { // Another move inside the item - QDragMoveEvent dragMove(view.mapFromScene(item->mapToScene(5, 5)), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(view.mapFromScene(item->mapToScene(5, 5)), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(dragMove.isAccepted()); QCOMPARE(dragMove.dropAction(), Qt::IgnoreAction); @@ -2268,7 +2300,7 @@ void tst_QGraphicsScene::dragAndDrop_simple() } { // Move outside the item - QDragMoveEvent dragMove(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(!dragMove.isAccepted()); QCOMPARE(dragMove.dropAction(), Qt::CopyAction); @@ -2281,7 +2313,7 @@ void tst_QGraphicsScene::dragAndDrop_simple() } { // Move inside the item again - QDragMoveEvent dragMove(view.mapFromScene(item->scenePos()), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(view.mapFromScene(item->scenePos()), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(dragMove.isAccepted()); QCOMPARE(dragMove.dropAction(), Qt::IgnoreAction); @@ -2295,7 +2327,7 @@ void tst_QGraphicsScene::dragAndDrop_simple() } { // Drop inside the item - QDropEvent drop(view.mapFromScene(item->scenePos()), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDropEvent drop(view.mapFromScene(item->scenePos()), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &drop); QVERIFY(drop.isAccepted()); QCOMPARE(drop.dropAction(), Qt::CopyAction); @@ -2322,13 +2354,13 @@ void tst_QGraphicsScene::dragAndDrop_disabledOrInvisible() QMimeData mimeData; // Initial drag enter for the scene - QDragEnterEvent dragEnter(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragEnterEvent dragEnter(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragEnter); QVERIFY(dragEnter.isAccepted()); QCOMPARE(dragEnter.dropAction(), Qt::CopyAction); { // Move inside the item - QDragMoveEvent dragMove(view.mapFromScene(item->scenePos()), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(view.mapFromScene(item->scenePos()), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(dragMove.isAccepted()); QCOMPARE(dragMove.dropAction(), Qt::IgnoreAction); @@ -2338,7 +2370,7 @@ void tst_QGraphicsScene::dragAndDrop_disabledOrInvisible() } { // Move outside the item - QDragMoveEvent dragMove(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(!dragMove.isAccepted()); QCOMPARE(dragMove.dropAction(), Qt::CopyAction); @@ -2353,7 +2385,7 @@ void tst_QGraphicsScene::dragAndDrop_disabledOrInvisible() { // Move inside the item - QDragMoveEvent dragMove(view.mapFromScene(item->scenePos()), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(view.mapFromScene(item->scenePos()), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(!dragMove.isAccepted()); QCOMPARE(dragMove.dropAction(), Qt::CopyAction); @@ -2369,7 +2401,7 @@ void tst_QGraphicsScene::dragAndDrop_disabledOrInvisible() { // Move inside the item - QDragMoveEvent dragMove(view.mapFromScene(item->scenePos()), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(view.mapFromScene(item->scenePos()), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(!dragMove.isAccepted()); QCOMPARE(dragMove.dropAction(), Qt::CopyAction); @@ -2378,7 +2410,7 @@ void tst_QGraphicsScene::dragAndDrop_disabledOrInvisible() } // Dummy drop event to keep the Mac from crashing. - QDropEvent dropEvent(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDropEvent dropEvent(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dropEvent); } @@ -2405,14 +2437,14 @@ void tst_QGraphicsScene::dragAndDrop_propagate() QMimeData mimeData; // Initial drag enter for the scene - QDragEnterEvent dragEnter(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragEnterEvent dragEnter(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragEnter); QVERIFY(dragEnter.isAccepted()); QCOMPARE(dragEnter.dropAction(), Qt::CopyAction); { // Move outside the items - QDragMoveEvent dragMove(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(!dragMove.isAccepted()); QCOMPARE(dragMove.dropAction(), Qt::CopyAction); @@ -2421,7 +2453,7 @@ void tst_QGraphicsScene::dragAndDrop_propagate() } { // Move inside item1 - QDragMoveEvent dragMove(view.mapFromScene(-5, -5), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(view.mapFromScene(-5, -5), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(dragMove.isAccepted()); QCOMPARE(dragMove.dropAction(), Qt::IgnoreAction); @@ -2432,7 +2464,7 @@ void tst_QGraphicsScene::dragAndDrop_propagate() { // Move into the intersection item1-item2 - QDragMoveEvent dragMove(view.mapFromScene(5, 5), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(view.mapFromScene(5, 5), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(!dragMove.isAccepted()); // move does not propagate, (ignoresDragMove = true) QCOMPARE(item1->eventList.size(), 3); @@ -2443,7 +2475,7 @@ void tst_QGraphicsScene::dragAndDrop_propagate() } { // Move into the item2 - QDragMoveEvent dragMove(view.mapFromScene(15, 15), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(view.mapFromScene(15, 15), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(!dragMove.isAccepted()); QCOMPARE(dragMove.dropAction(), Qt::CopyAction); @@ -2453,7 +2485,7 @@ void tst_QGraphicsScene::dragAndDrop_propagate() } { // Move inside item1 - QDragMoveEvent dragMove(view.mapFromScene(-5, -5), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(view.mapFromScene(-5, -5), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(dragMove.isAccepted()); QCOMPARE(dragMove.dropAction(), Qt::IgnoreAction); @@ -2467,7 +2499,7 @@ void tst_QGraphicsScene::dragAndDrop_propagate() { item2->ignoresDragEnter = true; // Move into the intersection item1-item2 - QDragMoveEvent dragMove(view.mapFromScene(5, 5), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(view.mapFromScene(5, 5), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(dragMove.isAccepted()); // dragEnter propagates down to item1, which then accepts the move event. QCOMPARE(dragMove.dropAction(), Qt::IgnoreAction); @@ -2480,7 +2512,7 @@ void tst_QGraphicsScene::dragAndDrop_propagate() { item2->ignoresDragEnter = false; // Drop on the intersection item1-item2 - QDropEvent drop(view.mapFromScene(5, 5), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDropEvent drop(view.mapFromScene(5, 5), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &drop); QVERIFY(drop.isAccepted()); QCOMPARE(drop.dropAction(), Qt::CopyAction); @@ -2491,7 +2523,7 @@ void tst_QGraphicsScene::dragAndDrop_propagate() } // Dummy drop event to keep the Mac from crashing. - QDropEvent dropEvent(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDropEvent dropEvent(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dropEvent); } #endif @@ -2580,6 +2612,8 @@ void tst_QGraphicsScene::render() pix.fill(Qt::blue); QGraphicsView view; + view.setWindowTitle(QTest::currentTestFunction()); + view.resize(m_testSize); QGraphicsScene scene(&view); scene.addEllipse(QRectF(-10, -10, 20, 20), QPen(Qt::black, 0), QBrush(Qt::white)); scene.addEllipse(QRectF(-2, -7, 4, 4), QPen(Qt::black, 0), QBrush(Qt::yellow))->setZValue(1); @@ -2642,6 +2676,7 @@ void tst_QGraphicsScene::render() gridLayout->addWidget(newLabel, 2, 0); QWidget widget; + widget.setWindowTitle(QTest::currentTestFunction()); widget.setLayout(gridLayout); widget.show(); @@ -2660,33 +2695,32 @@ void tst_QGraphicsScene::renderItemsWithNegativeWidthOrHeight() #if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED) || defined(Q_OS_WINRT) QSKIP("Test only works on platforms with resizable windows"); #endif - - QGraphicsScene scene(0, 0, 150, 150); + QGraphicsScene scene(0, 0, m_testSize.width(), m_testSize.height()); // Add item with negative width. - QGraphicsRectItem *item1 = new QGraphicsRectItem(0, 0, -150, 50); + QGraphicsRectItem *item1 = new QGraphicsRectItem(0, 0, -m_testSize.width(), 50); item1->setBrush(Qt::red); - item1->setPos(150, 50); + item1->setPos(m_testSize.width(), 50); scene.addItem(item1); // Add item with negative height. - QGraphicsRectItem *item2 = new QGraphicsRectItem(0, 0, 50, -150); + QGraphicsRectItem *item2 = new QGraphicsRectItem(0, 0, 50, -m_testSize.height()); item2->setBrush(Qt::blue); - item2->setPos(50, 150); + item2->setPos(50, m_testSize.height()); scene.addItem(item2); QGraphicsView view(&scene); + view.setWindowTitle(QTest::currentTestFunction()); view.setFrameStyle(QFrame::NoFrame); - view.resize(150, 150); view.show(); - QCOMPARE(view.viewport()->size(), QSize(150, 150)); + QTRY_COMPARE(view.viewport()->size(), m_testSize); QImage expected(view.viewport()->size(), QImage::Format_RGB32); view.viewport()->render(&expected); // Make sure the scene background is the same as the viewport background. scene.setBackgroundBrush(view.viewport()->palette().brush(view.viewport()->backgroundRole())); - QImage actual(150, 150, QImage::Format_RGB32); + QImage actual(m_testSize, QImage::Format_RGB32); QPainter painter(&actual); scene.render(&painter); painter.end(); @@ -2710,6 +2744,8 @@ void tst_QGraphicsScene::contextMenuEvent() QVERIFY(scene.hasFocus()); QGraphicsView view(&scene); + view.setWindowTitle(QTest::currentTestFunction()); + view.resize(m_testSize); view.show(); view.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&view)); @@ -2726,11 +2762,11 @@ void tst_QGraphicsScene::contextMenuEvent() class ContextMenuItem : public QGraphicsRectItem { public: - ContextMenuItem() : QGraphicsRectItem(0, 0, 100, 100) + ContextMenuItem(const QSize &s) : QGraphicsRectItem(0, 0, s.width(), s.height()) { setBrush(Qt::red); } protected: - void contextMenuEvent(QGraphicsSceneContextMenuEvent *) + void contextMenuEvent(QGraphicsSceneContextMenuEvent *) override { /* just accept */ } }; @@ -2740,26 +2776,30 @@ void tst_QGraphicsScene::contextMenuEvent_ItemIgnoresTransformations() QSKIP("Test fails on some Android devices (QTBUG-44430)"); #endif - QGraphicsScene scene(0, 0, 200, 200); - ContextMenuItem *item = new ContextMenuItem; + QGraphicsScene scene(0, 0, m_testSize.width(), m_testSize.height()); + const QSize itemSize = m_testSize / 2; + ContextMenuItem *item = new ContextMenuItem(itemSize); item->setFlag(QGraphicsItem::ItemIgnoresTransformations); scene.addItem(item); QWidget topLevel; + topLevel.setWindowTitle(QTest::currentTestFunction()); + topLevel.resize(m_testSize); QGraphicsView view(&scene, &topLevel); - view.resize(200, 200); topLevel.show(); QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); + + { - QPoint pos(50, 50); + QPoint pos(itemSize.width() / 2, itemSize.height() / 2); QContextMenuEvent event(QContextMenuEvent::Keyboard, pos, view.viewport()->mapToGlobal(pos)); event.ignore(); QApplication::sendEvent(view.viewport(), &event); QVERIFY(event.isAccepted()); } { - QPoint pos(150, 150); + QPoint pos(itemSize.width() * 3 / 2, itemSize.height() * 3 / 2); QContextMenuEvent event(QContextMenuEvent::Keyboard, pos, view.viewport()->mapToGlobal(pos)); event.ignore(); QApplication::sendEvent(view.viewport(), &event); @@ -2767,14 +2807,14 @@ void tst_QGraphicsScene::contextMenuEvent_ItemIgnoresTransformations() } view.scale(1.5, 1.5); { - QPoint pos(25, 25); + QPoint pos(itemSize.width() / 4, itemSize.height() / 4); QContextMenuEvent event(QContextMenuEvent::Keyboard, pos, view.viewport()->mapToGlobal(pos)); event.ignore(); QApplication::sendEvent(view.viewport(), &event); QVERIFY(event.isAccepted()); } { - QPoint pos(55, 55); + QPoint pos(itemSize.width() / 2 + 5, itemSize.height() / 2 + 5); QContextMenuEvent event(QContextMenuEvent::Keyboard, pos, view.viewport()->mapToGlobal(pos)); event.ignore(); QApplication::sendEvent(view.viewport(), &event); @@ -2790,14 +2830,14 @@ void tst_QGraphicsScene::update() QGraphicsRectItem *rect = new QGraphicsRectItem(0, 0, 100, 100); rect->setPen(QPen(Qt::black, 0)); scene.addItem(rect); - qApp->processEvents(); + QCoreApplication::processEvents(); rect->setPos(-100, -100); // This function forces indexing itemAt(scene, 0, 0); qRegisterMetaType<QList<QRectF> >("QList<QRectF>"); - QSignalSpy spy(&scene, SIGNAL(changed(QList<QRectF>))); + QSignalSpy spy(&scene, &QGraphicsScene::changed); // We update the scene. scene.update(); @@ -2806,12 +2846,13 @@ void tst_QGraphicsScene::update() itemAt(scene, 0, 0); // This will process the pending update - QApplication::instance()->processEvents(); + QCoreApplication::processEvents(); // Check that the update region is correct QCOMPARE(spy.count(), 1); QRectF region; - foreach (QRectF rectF, qvariant_cast<QList<QRectF> >(spy.at(0).at(0))) + const auto &rects = qvariant_cast<QList<QRectF> >(spy.at(0).at(0)); + for (const auto &rectF : rects) region |= rectF; QCOMPARE(region, QRectF(-100, -100, 200, 200)); } @@ -2821,9 +2862,11 @@ void tst_QGraphicsScene::update2() QGraphicsScene scene; scene.setSceneRect(-200, -200, 200, 200); CustomView view; + view.setWindowTitle(QTest::currentTestFunction()); + view.resize(m_testSize); view.setScene(&scene); view.show(); - qApp->setActiveWindow(&view); + QApplication::setActiveWindow(&view); QVERIFY(QTest::qWaitForWindowActive(&view)); QTRY_VERIFY(view.repaints >= 1); view.repaints = 0; @@ -2831,13 +2874,13 @@ void tst_QGraphicsScene::update2() // Make sure QGraphicsScene::update only requires one event-loop iteration // before the view is updated. scene.update(); - qApp->processEvents(); + QCoreApplication::processEvents(); QTRY_COMPARE(view.repaints, 1); view.repaints = 0; // The same for partial scene updates. scene.update(QRectF(-100, -100, 100, 100)); - qApp->processEvents(); + QCoreApplication::processEvents(); QCOMPARE(view.repaints, 1); } @@ -2853,7 +2896,7 @@ void tst_QGraphicsScene::views() QCOMPARE(scene.views().size(), 2); QVERIFY(scene.views().contains(&view1)); - view.setScene(0); + view.setScene(nullptr); QCOMPARE(scene.views().size(), 1); QCOMPARE(scene.views().at(0), &view1); @@ -2871,12 +2914,12 @@ void tst_QGraphicsScene::views() class CustomScene : public QGraphicsScene { public: - CustomScene() : gotTimerEvent(false) + CustomScene() { startTimer(10); } - bool gotTimerEvent; + bool gotTimerEvent = false; protected: - void timerEvent(QTimerEvent *) + void timerEvent(QTimerEvent *) override { gotTimerEvent = true; } @@ -2893,7 +2936,7 @@ void tst_QGraphicsScene::testEvent() class DisabledItemTester : public QGraphicsRectItem { public: - DisabledItemTester(const QRectF &rect, QGraphicsItem *parent = 0) + DisabledItemTester(const QRectF &rect, QGraphicsItem *parent = nullptr) : QGraphicsRectItem(rect, parent) { } @@ -2901,13 +2944,13 @@ public: QList<QEvent::Type> receivedSceneEventFilters; protected: - bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) + bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override { receivedSceneEventFilters << event->type(); return QGraphicsRectItem::sceneEventFilter(watched, event); } - bool sceneEvent(QEvent *event) + bool sceneEvent(QEvent *event) override { receivedSceneEvents << event->type(); return QGraphicsRectItem::sceneEvent(event); @@ -2965,11 +3008,9 @@ void tst_QGraphicsScene::eventsToDisabledItems() class ExposedPixmapItem : public QGraphicsPixmapItem { public: - ExposedPixmapItem(QGraphicsItem *item = 0) - : QGraphicsPixmapItem(item) - { } + using QGraphicsPixmapItem::QGraphicsPixmapItem; - void paint(QPainter *, const QStyleOptionGraphicsItem *option, QWidget *) + void paint(QPainter *, const QStyleOptionGraphicsItem *option, QWidget *) override { exposed = option->exposedRect; } @@ -3013,8 +3054,9 @@ void tst_QGraphicsScene::tabFocus_emptyScene() QWidget widget; widget.setLayout(layout); + widget.setWindowTitle(QTest::currentTestFunction()); widget.show(); - qApp->setActiveWindow(&widget); + QApplication::setActiveWindow(&widget); widget.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&widget)); @@ -3060,9 +3102,10 @@ void tst_QGraphicsScene::tabFocus_sceneWithFocusableItems() layout->addWidget(dial2); QWidget widget; + widget.setWindowTitle(QTest::currentTestFunction()); widget.setLayout(layout); widget.show(); - qApp->setActiveWindow(&widget); + QApplication::setActiveWindow(&widget); widget.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&widget)); @@ -3112,18 +3155,18 @@ void tst_QGraphicsScene::tabFocus_sceneWithFocusableItems() QVERIFY(!view->viewport()->hasFocus()); QVERIFY(!scene.hasFocus()); QVERIFY(!item->hasFocus()); - QCOMPARE(scene.focusItem(), static_cast<QGraphicsItem *>(item)); + QCOMPARE(scene.focusItem(), item); // Check that the correct item regains focus. widget.show(); - qApp->setActiveWindow(&widget); + QApplication::setActiveWindow(&widget); widget.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&widget)); QVERIFY(view->hasFocus()); QTRY_VERIFY(scene.isActive()); QVERIFY(view->viewport()->hasFocus()); QVERIFY(scene.hasFocus()); - QCOMPARE(scene.focusItem(), static_cast<QGraphicsItem *>(item)); + QCOMPARE(scene.focusItem(), item); QVERIFY(item->hasFocus()); } @@ -3131,14 +3174,13 @@ class FocusWidget : public QGraphicsWidget { Q_OBJECT public: - FocusWidget(QGraphicsItem *parent = 0) - : QGraphicsWidget(parent), tabs(0), backTabs(0) + FocusWidget(QGraphicsItem *parent = nullptr) : QGraphicsWidget(parent) { setFocusPolicy(Qt::StrongFocus); resize(100, 100); } - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) override { if (option->state & QStyle::State_HasFocus) { painter->fillRect(rect(), Qt::blue); @@ -3152,11 +3194,11 @@ public: } } - int tabs; - int backTabs; + int tabs = 0; + int backTabs = 0; protected: - bool sceneEvent(QEvent *event) + bool sceneEvent(QEvent *event) override { if (event->type() == QEvent::KeyPress) { QKeyEvent *k = static_cast<QKeyEvent *>(event); @@ -3168,9 +3210,9 @@ protected: return QGraphicsWidget::sceneEvent(event); } - void focusInEvent(QFocusEvent *) + void focusInEvent(QFocusEvent *) override { update(); } - void focusOutEvent(QFocusEvent *) + void focusOutEvent(QFocusEvent *) override { update(); } }; @@ -3195,9 +3237,10 @@ void tst_QGraphicsScene::tabFocus_sceneWithFocusWidgets() layout->addWidget(dial2); QWidget widget; + widget.setWindowTitle(QTest::currentTestFunction()); widget.setLayout(layout); widget.show(); - qApp->setActiveWindow(&widget); + QApplication::setActiveWindow(&widget); widget.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&widget)); @@ -3236,7 +3279,7 @@ void tst_QGraphicsScene::tabFocus_sceneWithFocusWidgets() widget.hide(); QTest::qWait(15); widget.show(); - qApp->setActiveWindow(&widget); + QApplication::setActiveWindow(&widget); widget.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&widget)); QTRY_VERIFY(widget1->hasFocus()); @@ -3279,9 +3322,10 @@ void tst_QGraphicsScene::tabFocus_sceneWithNestedFocusWidgets() layout->addWidget(dial2); QWidget widget; + widget.setWindowTitle(QTest::currentTestFunction()); widget.setLayout(layout); widget.show(); - qApp->setActiveWindow(&widget); + QApplication::setActiveWindow(&widget); widget.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&widget)); @@ -3366,7 +3410,7 @@ void tst_QGraphicsScene::tabFocus_sceneWithNestedFocusWidgets() widget.hide(); QTest::qWait(12); widget.show(); - qApp->setActiveWindow(&widget); + QApplication::setActiveWindow(&widget); widget.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&widget)); QTRY_VERIFY(widget1->hasFocus()); @@ -3390,11 +3434,11 @@ void tst_QGraphicsScene::style() QCOMPARE(sceneSpy.count(), 1); QCOMPARE(proxySpy.count(), 1); QCOMPARE(editSpy.count(), 1); - QCOMPARE(scene.style(), (QStyle *)windowsStyle); - QCOMPARE(proxy->style(), (QStyle *)windowsStyle); - QCOMPARE(edit->style(), (QStyle *)windowsStyle); + QCOMPARE(scene.style(), windowsStyle.data()); + QCOMPARE(proxy->style(), windowsStyle.data()); + QCOMPARE(edit->style(), windowsStyle.data()); - scene.setStyle(0); + scene.setStyle(nullptr); QCOMPARE(sceneSpy.count(), 2); QCOMPARE(proxySpy.count(), 2); QCOMPARE(editSpy.count(), 2); @@ -3411,11 +3455,12 @@ void tst_QGraphicsScene::task139710_bspTreeCrash() for (int i = 0; i < 2; ++i) { // trigger delayed item indexing - qApp->processEvents(); + QCoreApplication::processEvents(); scene.setSceneRect(0, 0, 10000, 10000); // delete all items in the scene - pointers are now likely to be recycled - foreach (QGraphicsItem *item, scene.items()) { + const auto &items = scene.items(); + for (QGraphicsItem *item : items) { scene.removeItem(item); delete item; } @@ -3427,7 +3472,7 @@ void tst_QGraphicsScene::task139710_bspTreeCrash() } // trigger delayed item indexing for the first 1000 items - qApp->processEvents(); + QCoreApplication::processEvents(); // add 1000 more items - the BSP tree is now resized for (int i = 0; i < 1000; ++i) { @@ -3437,7 +3482,8 @@ void tst_QGraphicsScene::task139710_bspTreeCrash() // get items from the BSP tree and use them. there was junk in the tree // the second time this happened. - foreach (QGraphicsItem *item, scene.items(QRectF(0, 0, 1000, 1000))) + const auto &itemsWithin = scene.items(QRectF(0, 0, 1000, 1000)); + for (QGraphicsItem *item : itemsWithin) item->moveBy(0, 0); } } @@ -3446,7 +3492,7 @@ void tst_QGraphicsScene::task139782_containsItemBoundingRect() { // The item in question has a scene bounding rect of (10, 10, 50, 50) QGraphicsScene scene(0.0, 0.0, 200.0, 200.0); - QGraphicsRectItem *item = new QGraphicsRectItem(0.0, 0.0, 50.0, 50.0, 0); + QGraphicsRectItem *item = new QGraphicsRectItem(0.0, 0.0, 50.0, 50.0, nullptr); scene.addItem(item); item->setPos(10.0, 10.0); @@ -3476,7 +3522,8 @@ void tst_QGraphicsScene::task160653_selectionChanged() QGraphicsScene scene(0, 0, 100, 100); scene.addItem(new QGraphicsRectItem(0, 0, 20, 20)); scene.addItem(new QGraphicsRectItem(30, 30, 20, 20)); - foreach (QGraphicsItem *item, scene.items()) { + const auto &items = scene.items(); + for (QGraphicsItem *item : items) { item->setFlags( item->flags() | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable); item->setSelected(true); @@ -3484,12 +3531,14 @@ void tst_QGraphicsScene::task160653_selectionChanged() QVERIFY(scene.items().size() > 1); QCOMPARE(scene.items().size(), scene.selectedItems().size()); - QSignalSpy spy(&scene, SIGNAL(selectionChanged())); + QSignalSpy spy(&scene, &QGraphicsScene::selectionChanged); QGraphicsView view(&scene); + view.setWindowTitle(QTest::currentTestFunction()); + view.resize(m_testSize); view.show(); QVERIFY(QTest::qWaitForWindowActive(&view)); QTest::mouseClick( - view.viewport(), Qt::LeftButton, 0, view.mapFromScene(scene.items().first()->scenePos())); + view.viewport(), Qt::LeftButton, {}, view.mapFromScene(scene.items().first()->scenePos())); QCOMPARE(spy.count(), 1); } @@ -3574,17 +3623,21 @@ void tst_QGraphicsScene::sorting() scene.addItem(t_1); - foreach (QGraphicsItem *item, scene.items()) + const auto &items = scene.items(); + for (QGraphicsItem *item : items) item->setFlag(QGraphicsItem::ItemIsSelectable); // QGraphicsView view(&scene); // view.setDragMode(QGraphicsView::RubberBandDrag); // view.show(); - qDebug() << "items: {"; - foreach (QGraphicsItem *item, scene.items(QRectF(32, 31, 4, 55))) - qDebug() << "\t" << item->data(0).toString(); - qDebug() << "}"; + if (lcTests().isDebugEnabled()) { + qCDebug(lcTests) << "items: {"; + const auto &itemsWithin = scene.items(QRectF(32, 31, 4, 55)); + for (QGraphicsItem *item : itemsWithin) + qCDebug(lcTests).nospace() << '\t' << item->data(0).toString(); + qCDebug(lcTests) << '}'; + } QCOMPARE(scene.items(QRectF(32, 31, 4, 55)), QList<QGraphicsItem *>() @@ -3664,11 +3717,11 @@ void tst_QGraphicsScene::changedSignal() QFETCH(bool, withView); QGraphicsScene scene; ChangedListener cl; - connect(&scene, SIGNAL(changed(QList<QRectF>)), &cl, SLOT(changed(QList<QRectF>))); + connect(&scene, &QGraphicsScene::changed, &cl, &ChangedListener::changed); - QGraphicsView *view = 0; + QScopedPointer<QGraphicsView> view; if (withView) - view = new QGraphicsView(&scene); + view.reset(new QGraphicsView(&scene)); QGraphicsRectItem *rect = new QGraphicsRectItem(0, 0, 10, 10); rect->setPen(QPen(Qt::black, 0)); @@ -3682,16 +3735,13 @@ void tst_QGraphicsScene::changedSignal() rect->setPos(20, 0); QCOMPARE(cl.changes.size(), 1); - qApp->processEvents(); + QCoreApplication::processEvents(); QCOMPARE(cl.changes.size(), 2); QCOMPARE(cl.changes.at(1).size(), 2); QCOMPARE(cl.changes.at(1).first(), QRectF(0, 0, 10, 10)); QCOMPARE(cl.changes.at(1).last(), QRectF(20, 0, 10, 10)); QCOMPARE(scene.sceneRect(), QRectF(0, 0, 30, 10)); - - if (withView) - delete view; } void tst_QGraphicsScene::stickyFocus_data() @@ -3718,7 +3768,7 @@ void tst_QGraphicsScene::stickyFocus() QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress); event.setScenePos(QPointF(-10, -10)); // outside item event.setButton(Qt::LeftButton); - qApp->sendEvent(&scene, &event); + QCoreApplication::sendEvent(&scene, &event); QCOMPARE(text->hasFocus(), sticky); } @@ -3736,43 +3786,51 @@ void tst_QGraphicsScene::sendEvent() void tst_QGraphicsScene::inputMethod_data() { - QTest::addColumn<int>("flags"); + QTest::addColumn<QGraphicsItem::GraphicsItemFlags>("flags"); QTest::addColumn<bool>("callFocusItem"); - QTest::newRow("0") << 0 << false; - QTest::newRow("1") << (int)QGraphicsItem::ItemAcceptsInputMethod << false; - QTest::newRow("2") << (int)QGraphicsItem::ItemIsFocusable << false; + QTest::newRow("0") << QGraphicsItem::GraphicsItemFlags() << false; + QTest::newRow("1") << QGraphicsItem::GraphicsItemFlags(QGraphicsItem::ItemAcceptsInputMethod) << false; + QTest::newRow("2") << QGraphicsItem::GraphicsItemFlags(QGraphicsItem::ItemIsFocusable) << false; QTest::newRow("3") << - (int)(QGraphicsItem::ItemAcceptsInputMethod|QGraphicsItem::ItemIsFocusable) << true; + (QGraphicsItem::ItemAcceptsInputMethod|QGraphicsItem::ItemIsFocusable) << true; } class InputMethodTester : public QGraphicsRectItem { - void inputMethodEvent(QInputMethodEvent *) { ++eventCalls; } - QVariant inputMethodQuery(Qt::InputMethodQuery) const { ++queryCalls; return QVariant(); } + void inputMethodEvent(QInputMethodEvent *) override { ++eventCalls; } + QVariant inputMethodQuery(Qt::InputMethodQuery) const override + { + ++queryCalls; + return QVariant(); + } + public: - int eventCalls; - mutable int queryCalls; + int eventCalls = 0; + mutable int queryCalls = 0; }; void tst_QGraphicsScene::inputMethod() { PlatformInputContext inputContext; - QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); + QInputMethodPrivate *inputMethodPrivate = + QInputMethodPrivate::get(QGuiApplication::inputMethod()); inputMethodPrivate->testContext = &inputContext; - QFETCH(int, flags); + QFETCH(QGraphicsItem::GraphicsItemFlags, flags); QFETCH(bool, callFocusItem); InputMethodTester *item = new InputMethodTester; - item->setFlags((QGraphicsItem::GraphicsItemFlags)flags); + item->setFlags(flags); QGraphicsScene scene; QGraphicsView view(&scene); + view.resize(m_testSize); view.show(); + view.setWindowTitle(QTest::currentTestFunction()); QApplication::setActiveWindow(&view); view.setFocus(); QVERIFY(QTest::qWaitForWindowActive(&view)); - QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view)); + QCOMPARE(QApplication::activeWindow(), &view); inputContext.m_resetCallCount = 0; inputContext.m_commitCallCount = 0; @@ -3784,25 +3842,25 @@ void tst_QGraphicsScene::inputMethod() QCOMPARE(inputContext.m_resetCallCount, 0); item->eventCalls = 0; - qApp->sendEvent(&scene, &event); + QCoreApplication::sendEvent(&scene, &event); QCOMPARE(item->eventCalls, callFocusItem ? 1 : 0); item->queryCalls = 0; - scene.inputMethodQuery((Qt::InputMethodQuery)0); + scene.inputMethodQuery(Qt::InputMethodQuery(0)); QCOMPARE(item->queryCalls, callFocusItem ? 1 : 0); - scene.setFocusItem(0); + scene.setFocusItem(nullptr); // the input context is reset twice, once because an item has lost focus and again because // the Qt::WA_InputMethodEnabled flag is cleared because no item has focus. QCOMPARE(inputContext.m_resetCallCount + inputContext.m_commitCallCount, callFocusItem ? 2 : 0); QCOMPARE(item->queryCalls, callFocusItem ? 1 : 0); // verify that value is unaffected item->eventCalls = 0; - qApp->sendEvent(&scene, &event); + QCoreApplication::sendEvent(&scene, &event); QCOMPARE(item->eventCalls, 0); item->queryCalls = 0; - scene.inputMethodQuery((Qt::InputMethodQuery)0); + scene.inputMethodQuery(Qt::InputMethodQuery(0)); QCOMPARE(item->queryCalls, 0); } @@ -3826,18 +3884,18 @@ void tst_QGraphicsScene::dispatchHoverOnPress() me.setButtons(Qt::LeftButton); QGraphicsSceneMouseEvent me2(QEvent::GraphicsSceneMouseRelease); me2.setButton(Qt::LeftButton); - qApp->sendEvent(&scene, &me); - qApp->sendEvent(&scene, &me2); - QCOMPARE(tester1->eventTypes, QList<QEvent::Type>() + QCoreApplication::sendEvent(&scene, &me); + QCoreApplication::sendEvent(&scene, &me2); + QCOMPARE(tester1->eventTypes, QVector<QEvent::Type>() << QEvent::GraphicsSceneHoverEnter << QEvent::GraphicsSceneHoverMove << QEvent::GrabMouse << QEvent::GraphicsSceneMousePress << QEvent::UngrabMouse); tester1->eventTypes.clear(); - qApp->sendEvent(&scene, &me); - qApp->sendEvent(&scene, &me2); - QCOMPARE(tester1->eventTypes, QList<QEvent::Type>() + QCoreApplication::sendEvent(&scene, &me); + QCoreApplication::sendEvent(&scene, &me2); + QCOMPARE(tester1->eventTypes, QVector<QEvent::Type>() << QEvent::GraphicsSceneHoverMove << QEvent::GrabMouse << QEvent::GraphicsSceneMousePress @@ -3852,21 +3910,21 @@ void tst_QGraphicsScene::dispatchHoverOnPress() me2.setScenePos(QPointF(30, 30)); me2.setButton(Qt::LeftButton); tester1->eventTypes.clear(); - qApp->sendEvent(&scene, &me); - qApp->sendEvent(&scene, &me2); - qDebug() << tester1->eventTypes; - QCOMPARE(tester1->eventTypes, QList<QEvent::Type>() + QCoreApplication::sendEvent(&scene, &me); + QCoreApplication::sendEvent(&scene, &me2); + qCDebug(lcTests) << tester1->eventTypes; + QCOMPARE(tester1->eventTypes, QVector<QEvent::Type>() << QEvent::GraphicsSceneHoverLeave); - QCOMPARE(tester2->eventTypes, QList<QEvent::Type>() + QCOMPARE(tester2->eventTypes, QVector<QEvent::Type>() << QEvent::GraphicsSceneHoverEnter << QEvent::GraphicsSceneHoverMove << QEvent::GrabMouse << QEvent::GraphicsSceneMousePress << QEvent::UngrabMouse); tester2->eventTypes.clear(); - qApp->sendEvent(&scene, &me); - qApp->sendEvent(&scene, &me2); - QCOMPARE(tester2->eventTypes, QList<QEvent::Type>() + QCoreApplication::sendEvent(&scene, &me); + QCoreApplication::sendEvent(&scene, &me2); + QCOMPARE(tester2->eventTypes, QVector<QEvent::Type>() << QEvent::GraphicsSceneHoverMove << QEvent::GrabMouse << QEvent::GraphicsSceneMousePress @@ -3915,7 +3973,7 @@ void tst_QGraphicsScene::initialFocus() if (activeScene) { QEvent windowActivate(QEvent::WindowActivate); - qApp->sendEvent(&scene, &windowActivate); + QCoreApplication::sendEvent(&scene, &windowActivate); scene.setFocus(); } @@ -3923,7 +3981,7 @@ void tst_QGraphicsScene::initialFocus() if (!activeScene) { QEvent windowActivate(QEvent::WindowActivate); - qApp->sendEvent(&scene, &windowActivate); + QCoreApplication::sendEvent(&scene, &windowActivate); scene.setFocus(); } @@ -3933,14 +3991,13 @@ void tst_QGraphicsScene::initialFocus() class PolishItem : public QGraphicsTextItem { public: - PolishItem(QGraphicsItem *parent = 0) - : QGraphicsTextItem(parent), polished(false), deleteChildrenInPolish(true), addChildrenInPolish(false) { } + using QGraphicsTextItem::QGraphicsTextItem; - bool polished; - bool deleteChildrenInPolish; - bool addChildrenInPolish; + bool polished = false; + bool deleteChildrenInPolish = true; + bool addChildrenInPolish = false; protected: - QVariant itemChange(GraphicsItemChange change, const QVariant& value) + QVariant itemChange(GraphicsItemChange change, const QVariant& value) override { if (change == ItemVisibleChange) { polished = true; @@ -3979,19 +4036,19 @@ void tst_QGraphicsScene::polishItems2() // Wait for the polish event to be delivered. QVERIFY(!item->polished); - QApplication::sendPostedEvents(&scene, QEvent::MetaCall); + QCoreApplication::sendPostedEvents(&scene, QEvent::MetaCall); QVERIFY(item->polished); // We deleted the children we added above, but we also // added 10 new children. These should be polished in the next // event loop iteration. - QList<QGraphicsItem *> children = item->childItems(); + const QList<QGraphicsItem *> children = item->childItems(); QCOMPARE(children.count(), 10); - foreach (QGraphicsItem *child, children) + for (QGraphicsItem *child : children) QVERIFY(!static_cast<PolishItem *>(child)->polished); - QApplication::sendPostedEvents(&scene, QEvent::MetaCall); - foreach (QGraphicsItem *child, children) + QCoreApplication::sendPostedEvents(&scene, QEvent::MetaCall); + for (QGraphicsItem *child : children) QVERIFY(static_cast<PolishItem *>(child)->polished); } @@ -4008,6 +4065,8 @@ void tst_QGraphicsScene::isActive() { QWidget toplevel1; + toplevel1.setWindowTitle(QTest::currentTestFunction()); + toplevel1.resize(m_testSize); QHBoxLayout *layout = new QHBoxLayout; toplevel1.setLayout(layout); QGraphicsView *view1 = new QGraphicsView(&scene1); @@ -4073,8 +4132,9 @@ void tst_QGraphicsScene::isActive() { - const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); QWidget toplevel2; + toplevel2.setWindowTitle(QTest::currentTestFunction()); + toplevel2.resize(m_testSize); QHBoxLayout *layout = new QHBoxLayout; toplevel2.setLayout(layout); QGraphicsView *view1 = new QGraphicsView(&scene1); @@ -4087,7 +4147,7 @@ void tst_QGraphicsScene::isActive() QVERIFY(!scene1.hasFocus()); QVERIFY(!scene2.hasFocus()); - toplevel2.move(availableGeometry.topLeft() + QPoint(50, 50)); + toplevel2.move(m_availableGeometry.topLeft() + QPoint(50, 50)); toplevel2.show(); QApplication::setActiveWindow(&toplevel2); QVERIFY(QTest::qWaitForWindowActive(&toplevel2)); @@ -4136,12 +4196,13 @@ void tst_QGraphicsScene::isActive() QVERIFY(!scene2.hasFocus()); QGraphicsView topLevelView; - topLevelView.move(availableGeometry.topLeft() + QPoint(500, 50)); + topLevelView.move(toplevel2.geometry().topRight() + QPoint(100, 50)); + topLevelView.resize(m_testSize); topLevelView.show(); QApplication::setActiveWindow(&topLevelView); topLevelView.setFocus(); QVERIFY(QTest::qWaitForWindowActive(&topLevelView)); - QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&topLevelView)); + QCOMPARE(QApplication::activeWindow(), &topLevelView); QVERIFY(!scene1.isActive()); QVERIFY(!scene2.isActive()); @@ -4182,6 +4243,7 @@ void tst_QGraphicsScene::isActive() { QWidget toplevel3; + toplevel3.resize(m_testSize); QHBoxLayout *layout = new QHBoxLayout; toplevel3.setLayout(layout); QGraphicsView *view1 = new QGraphicsView(&scene1); @@ -4211,7 +4273,7 @@ void tst_QGraphicsScene::isActive() QVERIFY(scene1.hasFocus()); QVERIFY(!scene2.hasFocus()); - view1->setParent(0); + view1->setParent(nullptr); QVERIFY(!scene1.isActive()); QVERIFY(scene2.isActive()); QVERIFY(!scene1.hasFocus()); @@ -4243,7 +4305,7 @@ void tst_QGraphicsScene::siblingIndexAlwaysValid() scene.addItem(parent2); //Then we make the child a top level - child->setParentItem(0); + child->setParentItem(nullptr); //This is trigerred by a repaint... QGraphicsScenePrivate::get(&scene)->index->estimateTopLevelItems(QRectF(), Qt::AscendingOrder); @@ -4259,6 +4321,8 @@ void tst_QGraphicsScene::siblingIndexAlwaysValid() scene2.setItemIndexMethod(QGraphicsScene::NoIndex); QGraphicsView view2(&scene2); + view2.setWindowTitle(QTest::currentTestFunction()); + view2.resize(m_testSize); // first add the blue rect QGraphicsRectItem* const item1 = new QGraphicsRectItem(QRect( 10, 10, 10, 10 )); @@ -4302,9 +4366,11 @@ void tst_QGraphicsScene::removeFullyTransparentItem() child->setParentItem(parent); CustomView view; + view.setWindowTitle(QTest::currentTestFunction()); + view.resize(m_testSize); view.setScene(&scene); view.show(); - qApp->setActiveWindow(&view); + QApplication::setActiveWindow(&view); QVERIFY(QTest::qWaitForWindowActive(&view)); QCoreApplication::processEvents(); // Process all queued paint events @@ -4353,33 +4419,35 @@ void tst_QGraphicsScene::taskQTBUG_5904_crashWithDeviceCoordinateCache() void tst_QGraphicsScene::taskQT657_paintIntoCacheWithTransparentParts() { // Test using DeviceCoordinateCache and opaque item - QWidget *w = new QWidget(); + QScopedPointer<QWidget> w(new QWidget); w->setPalette(QColor(0, 0, 255)); w->setGeometry(0, 0, 50, 50); QGraphicsScene *scene = new QGraphicsScene(); - CustomView *view = new CustomView; - view->setScene(scene); + CustomView view; + view.resize(m_testSize); + view.setWindowTitle(QTest::currentTestFunction()); + view.setScene(scene); - QGraphicsProxyWidget *proxy = scene->addWidget(w); + QGraphicsProxyWidget *proxy = scene->addWidget(w.data()); proxy->setCacheMode(QGraphicsItem::DeviceCoordinateCache); proxy->setTransform(QTransform().rotate(15), true); - view->show(); - QVERIFY(QTest::qWaitForWindowExposed(view)); - view->repaints = 0; + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + view.repaints = 0; proxy->update(10, 10, 10, 10); - QTRY_VERIFY(view->repaints > 0); + QTRY_VERIFY(view.repaints > 0); QPixmap pix; QGraphicsItemPrivate* itemp = QGraphicsItemPrivate::get(proxy); - QTRY_VERIFY(QPixmapCache::find(itemp->extraItemCache()->deviceData.value(view->viewport()).key, &pix)); + QTRY_VERIFY(QPixmapCache::find(itemp->extraItemCache()->deviceData.value(view.viewport()).key, &pix)); QTransform t = proxy->sceneTransform(); // Map from scene coordinates to pixmap coordinates. // X origin in the pixmap is the most-left point // of the item's boundingRect in the scene. - qreal adjust = t.mapRect(proxy->boundingRect().toRect()).left(); + const int adjust = t.mapRect(proxy->boundingRect().toRect()).left(); QRect rect = t.mapRect(QRect(10, 10, 10, 10)).adjusted(-adjust, 0, -adjust + 1, 1); QPixmap subpix = pix.copy(rect); @@ -4388,8 +4456,6 @@ void tst_QGraphicsScene::taskQT657_paintIntoCacheWithTransparentParts() for(int j = 0; j < im.height(); j++) QCOMPARE(qAlpha(im.pixel(i, j)), 255); } - - delete w; } void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts() @@ -4403,28 +4469,30 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts() rectItem->setParentItem(backItem); QGraphicsScene *scene = new QGraphicsScene(); - CustomView *view = new CustomView; - view->setScene(scene); + CustomView view; + view.resize(m_testSize); + view.setWindowTitle(QTest::currentTestFunction()); + view.setScene(scene); scene->addItem(backItem); rectItem->setCacheMode(QGraphicsItem::DeviceCoordinateCache); backItem->setTransform(QTransform().rotate(15), true); - view->show(); - QVERIFY(QTest::qWaitForWindowExposed(view)); - view->repaints = 0; + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + view.repaints = 0; rectItem->update(10, 10, 10, 10); - QTRY_VERIFY(view->repaints > 0); + QTRY_VERIFY(view.repaints > 0); QPixmap pix; QGraphicsItemPrivate* itemp = QGraphicsItemPrivate::get(rectItem); - QTRY_VERIFY(QPixmapCache::find(itemp->extraItemCache()->deviceData.value(view->viewport()).key, &pix)); + QTRY_VERIFY(QPixmapCache::find(itemp->extraItemCache()->deviceData.value(view.viewport()).key, &pix)); QTransform t = rectItem->sceneTransform(); // Map from scene coordinates to pixmap coordinates. // X origin in the pixmap is the most-left point // of the item's boundingRect in the scene. - qreal adjust = t.mapRect(rectItem->boundingRect().toRect()).left(); + const int adjust = t.mapRect(rectItem->boundingRect().toRect()).left(); QRect rect = t.mapRect(QRect(10, 10, 10, 10)).adjusted(-adjust, 0, -adjust + 1, 1); QPixmap subpix = pix.copy(rect); @@ -4434,8 +4502,6 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts() QCOMPARE(qAlpha(im.pixel(i, j)), 125); } } - - delete view; } // Test using ItemCoordinateCache and opaque item @@ -4444,18 +4510,20 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts() rectItem->setBrush(QColor(0, 0, 255)); QGraphicsScene *scene = new QGraphicsScene(); - CustomView *view = new CustomView; - view->setScene(scene); + CustomView view; + view.setWindowTitle(QTest::currentTestFunction()); + view.resize(m_testSize); + view.setScene(scene); scene->addItem(rectItem); rectItem->setCacheMode(QGraphicsItem::ItemCoordinateCache); rectItem->setTransform(QTransform().rotate(15), true); - view->show(); - QVERIFY(QTest::qWaitForWindowExposed(view)); - view->repaints = 0; + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + view.repaints = 0; rectItem->update(10, 10, 10, 10); - QTRY_VERIFY(view->repaints > 0); + QTRY_VERIFY(view.repaints > 0); QPixmap pix; QGraphicsItemPrivate* itemp = QGraphicsItemPrivate::get(rectItem); @@ -4465,7 +4533,7 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts() // Map from scene coordinates to pixmap coordinates. // X origin in the pixmap is the most-left point // of the item's boundingRect in the scene. - qreal adjust = t.mapRect(rectItem->boundingRect().toRect()).left(); + const int adjust = t.mapRect(rectItem->boundingRect().toRect()).left(); QRect rect = t.mapRect(QRect(10, 10, 10, 10)).adjusted(-adjust, 0, -adjust + 1, 1); QPixmap subpix = pix.copy(rect); @@ -4474,8 +4542,6 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts() for(int j = 0; j < im.height(); j++) QCOMPARE(qAlpha(im.pixel(i, j)), 255); } - - delete view; } // Test using ItemCoordinateCache and semi-transparent item @@ -4484,18 +4550,20 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts() rectItem->setBrush(QColor(0, 0, 255, 125)); QGraphicsScene *scene = new QGraphicsScene(); - CustomView *view = new CustomView; - view->setScene(scene); + CustomView view; + view.setWindowTitle(QTest::currentTestFunction()); + view.resize(m_testSize); + view.setScene(scene); scene->addItem(rectItem); rectItem->setCacheMode(QGraphicsItem::ItemCoordinateCache); rectItem->setTransform(QTransform().rotate(15), true); - view->show(); - QVERIFY(QTest::qWaitForWindowExposed(view)); - view->repaints = 0; + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + view.repaints = 0; rectItem->update(10, 10, 10, 10); - QTRY_VERIFY(view->repaints > 0); + QTRY_VERIFY(view.repaints > 0); QPixmap pix; QGraphicsItemPrivate* itemp = QGraphicsItemPrivate::get(rectItem); @@ -4505,7 +4573,7 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts() // Map from scene coordinates to pixmap coordinates. // X origin in the pixmap is the most-left point // of the item's boundingRect in the scene. - qreal adjust = t.mapRect(rectItem->boundingRect().toRect()).left(); + const int adjust = int(t.mapRect(rectItem->boundingRect().toRect()).left()); QRect rect = t.mapRect(QRect(10, 10, 10, 10)).adjusted(-adjust, 0, -adjust + 1, 1); QPixmap subpix = pix.copy(rect); @@ -4514,8 +4582,6 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts() for(int j = 0; j < im.height(); j++) QCOMPARE(qAlpha(im.pixel(i, j)), 125); } - - delete view; } } @@ -4546,7 +4612,7 @@ void tst_QGraphicsScene::zeroScale() QGraphicsView view(&scene); ChangedListener cl; - connect(&scene, SIGNAL(changed(QList<QRectF>)), &cl, SLOT(changed(QList<QRectF>))); + connect(&scene, &QGraphicsScene::changed, &cl, &ChangedListener::changed); QGraphicsRectItem *rect1 = new QGraphicsRectItem(0, 0, 0.0000001, 0.00000001); scene.addItem(rect1); @@ -4569,13 +4635,13 @@ void tst_QGraphicsScene::focusItemChangedSignal() qRegisterMetaType<Qt::FocusReason>("Qt::FocusReason"); QGraphicsScene scene; - QSignalSpy spy(&scene, SIGNAL(focusItemChanged(QGraphicsItem *, QGraphicsItem *, Qt::FocusReason))); + QSignalSpy spy(&scene, &QGraphicsScene::focusItemChanged); QVERIFY(spy.isValid()); QCOMPARE(spy.count(), 0); scene.setFocus(); QCOMPARE(spy.count(), 0); QEvent activateEvent(QEvent::WindowActivate); - qApp->sendEvent(&scene, &activateEvent); + QCoreApplication::sendEvent(&scene, &activateEvent); QCOMPARE(spy.count(), 0); QGraphicsRectItem *topLevelItem1 = new QGraphicsRectItem; @@ -4592,7 +4658,7 @@ void tst_QGraphicsScene::focusItemChangedSignal() QCOMPARE(spy.count(), 1); QList<QVariant> arguments = spy.takeFirst(); QCOMPARE(arguments.size(), 3); - QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), (QGraphicsItem *)topLevelItem2); + QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), topLevelItem2); QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(1)), nullptr); QCOMPARE(qvariant_cast<Qt::FocusReason>(arguments.at(2)), Qt::OtherFocusReason); QVERIFY(topLevelItem2->hasFocus()); @@ -4602,14 +4668,14 @@ void tst_QGraphicsScene::focusItemChangedSignal() arguments = spy.takeFirst(); QCOMPARE(arguments.size(), 3); QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), nullptr); - QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(1)), (QGraphicsItem *)topLevelItem2); + QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(1)), topLevelItem2); QCOMPARE(qvariant_cast<Qt::FocusReason>(arguments.at(2)), Qt::OtherFocusReason); scene.setFocus(Qt::MenuBarFocusReason); QCOMPARE(spy.count(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.size(), 3); - QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), (QGraphicsItem *)topLevelItem2); + QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), topLevelItem2); QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(1)), nullptr); QCOMPARE(qvariant_cast<Qt::FocusReason>(arguments.at(2)), Qt::MenuBarFocusReason); @@ -4617,15 +4683,15 @@ void tst_QGraphicsScene::focusItemChangedSignal() topLevelItem1->setFocus(Qt::TabFocusReason); arguments = spy.takeFirst(); QCOMPARE(arguments.size(), 3); - QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), (QGraphicsItem *)topLevelItem1); - QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(1)), (QGraphicsItem *)topLevelItem2); + QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), topLevelItem1); + QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(1)), topLevelItem2); QCOMPARE(qvariant_cast<Qt::FocusReason>(arguments.at(2)), Qt::TabFocusReason); topLevelItem2->setFocus(Qt::TabFocusReason); arguments = spy.takeFirst(); QCOMPARE(arguments.size(), 3); - QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), (QGraphicsItem *)topLevelItem2); - QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(1)), (QGraphicsItem *)topLevelItem1); + QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), topLevelItem2); + QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(1)), topLevelItem1); QCOMPARE(qvariant_cast<Qt::FocusReason>(arguments.at(2)), Qt::TabFocusReason); } @@ -4633,10 +4699,10 @@ void tst_QGraphicsScene::focusItemChangedSignal() // when the scene activation changes) breaks quite a few tests so leave this fix // for some future release. See QTBUG-28346. QEvent deactivateEvent(QEvent::WindowDeactivate); - qApp->sendEvent(&scene, &deactivateEvent); + QCoreApplication::sendEvent(&scene, &deactivateEvent); QEXPECT_FAIL("", "QTBUG-28346", Continue); QCOMPARE(spy.count(), 1); - qApp->sendEvent(&scene, &activateEvent); + QCoreApplication::sendEvent(&scene, &activateEvent); QEXPECT_FAIL("", "QTBUG-28346", Continue); QCOMPARE(spy.count(), 1); @@ -4647,8 +4713,8 @@ void tst_QGraphicsScene::focusItemChangedSignal() QCOMPARE(spy.count(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.size(), 3); - QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), (QGraphicsItem *)panel1); - QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(1)), (QGraphicsItem *)topLevelItem2); + QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), panel1); + QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(1)), topLevelItem2); QCOMPARE(qvariant_cast<Qt::FocusReason>(arguments.at(2)), Qt::ActiveWindowFocusReason); QGraphicsRectItem *panel2 = new QGraphicsRectItem; @@ -4661,16 +4727,16 @@ void tst_QGraphicsScene::focusItemChangedSignal() QCOMPARE(spy.count(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.size(), 3); - QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), (QGraphicsItem *)panel2); - QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(1)), (QGraphicsItem *)panel1); + QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), panel2); + QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(1)), panel1); QCOMPARE(qvariant_cast<Qt::FocusReason>(arguments.at(2)), Qt::ActiveWindowFocusReason); scene.setActivePanel(panel1); QCOMPARE(spy.count(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.size(), 3); - QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), (QGraphicsItem *)panel1); - QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(1)), (QGraphicsItem *)panel2); + QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), panel1); + QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(1)), panel2); QCOMPARE(qvariant_cast<Qt::FocusReason>(arguments.at(2)), Qt::ActiveWindowFocusReason); } @@ -4679,14 +4745,15 @@ void tst_QGraphicsScene::focusItemChangedSignal() class ItemCountsPaintCalls : public QGraphicsRectItem { public: - ItemCountsPaintCalls(const QRectF & rect, QGraphicsItem *parent = 0) - : QGraphicsRectItem(rect, parent), repaints(0) {} - void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 ) + using QGraphicsRectItem::QGraphicsRectItem; + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, + QWidget *widget = nullptr) override { QGraphicsRectItem::paint(painter, option, widget); ++repaints; } - int repaints; + int repaints = 0; }; void tst_QGraphicsScene::minimumRenderSize() @@ -4700,10 +4767,12 @@ void tst_QGraphicsScene::minimumRenderSize() scene.addItem(bigParent); CustomView view; + view.setWindowTitle(QTest::currentTestFunction()); + view.resize(m_testSize); view.setScene(&scene); view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); - qApp->processEvents(); + QCoreApplication::processEvents(); // Initially, everything should be repainted the same number of times int viewRepaints = 0; @@ -4716,7 +4785,7 @@ void tst_QGraphicsScene::minimumRenderSize() // Setting a minimum render size should cause a repaint scene.setMinimumRenderSize(0.5); - qApp->processEvents(); + QCoreApplication::processEvents(); QTRY_VERIFY(view.repaints > viewRepaints); viewRepaints = view.repaints; @@ -4727,7 +4796,7 @@ void tst_QGraphicsScene::minimumRenderSize() // Scaling should cause a repaint of big items only. view.scale(0.1, 0.1); - qApp->processEvents(); + QCoreApplication::processEvents(); QTRY_VERIFY(view.repaints > viewRepaints); viewRepaints = view.repaints; @@ -4738,7 +4807,7 @@ void tst_QGraphicsScene::minimumRenderSize() // Scaling further should cause even fewer items to be repainted view.scale(0.1, 0.1); // Stacks with previous scale - qApp->processEvents(); + QCoreApplication::processEvents(); QTRY_VERIFY(view.repaints > viewRepaints); viewRepaints = view.repaints; @@ -4752,6 +4821,8 @@ void tst_QGraphicsScene::focusOnTouch() { QGraphicsScene scene; QGraphicsView view(&scene); + view.setWindowTitle(QTest::currentTestFunction()); + view.resize(m_testSize); scene.setSceneRect(0, 0, 100, 100); QGraphicsRectItem *rect = scene.addRect(0, 0, 100, 100); rect->setFlag(QGraphicsItem::ItemIsFocusable, true); @@ -4809,6 +4880,7 @@ void tst_QGraphicsScene::taskQTBUG_16401_focusItem() { QGraphicsScene scene; QGraphicsView view(&scene); + view.resize(m_testSize); QGraphicsRectItem *rect = scene.addRect(0, 0, 100, 100); rect->setFlag(QGraphicsItem::ItemIsFocusable); @@ -4839,6 +4911,8 @@ void tst_QGraphicsScene::taskQTBUG_42915_focusNextPrevChild() { QGraphicsScene scene; QGraphicsView view(&scene); + view.setWindowTitle(QTest::currentTestFunction()); + view.resize(m_testSize); scene.setSceneRect(1, 1, 198, 198); view.setFocus(); diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST index 22fce8620b..9b76ea02ff 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST +++ b/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST @@ -1,24 +1,16 @@ [task255529_transformationAnchorMouseAndViewportMargins] opensuse-leap -rhel-7.4 -ubuntu-16.04 -opensuse-42.3 [cursor] opensuse-leap -ubuntu-16.04 -opensuse-42.3 [cursor2] ubuntu-16.04 [sendEvent] ubuntu-16.04 opensuse-42.3 [resizeAnchor] -ubuntu-16.04 -rhel-7.6 opensuse-leap -ubuntu-18.04 -rhel-7.4 -opensuse-42.3 +rhel-7.6 +ubuntu [update2] opensuse-42.3 [itemsInRect_cosmeticAdjust] diff --git a/tests/auto/widgets/itemviews/qheaderview/BLACKLIST b/tests/auto/widgets/itemviews/qheaderview/BLACKLIST index 297a6fe7b7..4eceaae0d3 100644 --- a/tests/auto/widgets/itemviews/qheaderview/BLACKLIST +++ b/tests/auto/widgets/itemviews/qheaderview/BLACKLIST @@ -1,3 +1,2 @@ [stretchAndRestoreLastSection] opensuse-leap -opensuse-42.3 diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index f247889d55..df02815eb2 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -106,6 +106,7 @@ class tst_QHeaderView : public QObject public: tst_QHeaderView(); + static void initMain(); private slots: void initTestCase(); @@ -265,6 +266,14 @@ protected: QElapsedTimer timer; }; +void tst_QHeaderView::initMain() +{ +#ifdef Q_OS_WIN + // Ensure minimum size constraints of framed windows on High DPI screens + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); +#endif +} + class QtTestModel: public QAbstractTableModel { diff --git a/tests/auto/widgets/kernel/qapplication/BLACKLIST b/tests/auto/widgets/kernel/qapplication/BLACKLIST index ac65a97c40..c68c7d6b14 100644 --- a/tests/auto/widgets/kernel/qapplication/BLACKLIST +++ b/tests/auto/widgets/kernel/qapplication/BLACKLIST @@ -1,4 +1,3 @@ [touchEventPropagation] -opensuse-leap # QTBUG-66745 -opensuse-42.3 +opensuse-leap diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST index 02e97e4b4e..26f9ce1b85 100644 --- a/tests/auto/widgets/kernel/qwidget/BLACKLIST +++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST @@ -14,12 +14,9 @@ rhel-7.4 ubuntu-16.04 rhel-7.6 [focusProxyAndInputMethods] -ubuntu-16.04 rhel-7.6 opensuse-leap -ubuntu-18.04 -rhel-7.4 -opensuse-42.3 +ubuntu [raise] opensuse-leap # QTBUG-68175 @@ -45,12 +42,9 @@ opensuse-leap [moveInResizeEvent] ubuntu-16.04 [multipleToplevelFocusCheck] -ubuntu-16.04 rhel-7.6 opensuse-leap -ubuntu-18.04 -rhel-7.4 -opensuse-42.3 +ubuntu [windowState] # QTBUG-75270 winrt diff --git a/tests/auto/widgets/styles/qstyle/images/mac/button.png b/tests/auto/widgets/styles/qstyle/images/mac/button.png Binary files differdeleted file mode 100644 index 7b11325e87..0000000000 --- a/tests/auto/widgets/styles/qstyle/images/mac/button.png +++ /dev/null diff --git a/tests/auto/widgets/styles/qstyle/images/mac/combobox.png b/tests/auto/widgets/styles/qstyle/images/mac/combobox.png Binary files differdeleted file mode 100644 index ded0b11f29..0000000000 --- a/tests/auto/widgets/styles/qstyle/images/mac/combobox.png +++ /dev/null diff --git a/tests/auto/widgets/styles/qstyle/images/mac/lineedit.png b/tests/auto/widgets/styles/qstyle/images/mac/lineedit.png Binary files differdeleted file mode 100644 index 8d2861b65b..0000000000 --- a/tests/auto/widgets/styles/qstyle/images/mac/lineedit.png +++ /dev/null diff --git a/tests/auto/widgets/styles/qstyle/images/mac/mdi.png b/tests/auto/widgets/styles/qstyle/images/mac/mdi.png Binary files differdeleted file mode 100644 index 8c09ae4338..0000000000 --- a/tests/auto/widgets/styles/qstyle/images/mac/mdi.png +++ /dev/null diff --git a/tests/auto/widgets/styles/qstyle/images/mac/menu.png b/tests/auto/widgets/styles/qstyle/images/mac/menu.png Binary files differdeleted file mode 100644 index 5dd9111d69..0000000000 --- a/tests/auto/widgets/styles/qstyle/images/mac/menu.png +++ /dev/null diff --git a/tests/auto/widgets/styles/qstyle/images/mac/radiobutton.png b/tests/auto/widgets/styles/qstyle/images/mac/radiobutton.png Binary files differdeleted file mode 100644 index 8828e220a2..0000000000 --- a/tests/auto/widgets/styles/qstyle/images/mac/radiobutton.png +++ /dev/null diff --git a/tests/auto/widgets/styles/qstyle/images/mac/slider.png b/tests/auto/widgets/styles/qstyle/images/mac/slider.png Binary files differdeleted file mode 100644 index fc65035631..0000000000 --- a/tests/auto/widgets/styles/qstyle/images/mac/slider.png +++ /dev/null diff --git a/tests/auto/widgets/styles/qstyle/images/mac/spinbox.png b/tests/auto/widgets/styles/qstyle/images/mac/spinbox.png Binary files differdeleted file mode 100644 index ee88441ecb..0000000000 --- a/tests/auto/widgets/styles/qstyle/images/mac/spinbox.png +++ /dev/null diff --git a/tests/auto/widgets/styles/qstyle/images/vista/button.png b/tests/auto/widgets/styles/qstyle/images/vista/button.png Binary files differdeleted file mode 100644 index a6c45276ca..0000000000 --- a/tests/auto/widgets/styles/qstyle/images/vista/button.png +++ /dev/null diff --git a/tests/auto/widgets/styles/qstyle/images/vista/combobox.png b/tests/auto/widgets/styles/qstyle/images/vista/combobox.png Binary files differdeleted file mode 100644 index 9b82f64d32..0000000000 --- a/tests/auto/widgets/styles/qstyle/images/vista/combobox.png +++ /dev/null diff --git a/tests/auto/widgets/styles/qstyle/images/vista/lineedit.png b/tests/auto/widgets/styles/qstyle/images/vista/lineedit.png Binary files differdeleted file mode 100644 index b2c6ac1ae4..0000000000 --- a/tests/auto/widgets/styles/qstyle/images/vista/lineedit.png +++ /dev/null diff --git a/tests/auto/widgets/styles/qstyle/images/vista/menu.png b/tests/auto/widgets/styles/qstyle/images/vista/menu.png Binary files differdeleted file mode 100644 index b114099cc3..0000000000 --- a/tests/auto/widgets/styles/qstyle/images/vista/menu.png +++ /dev/null diff --git a/tests/auto/widgets/styles/qstyle/images/vista/radiobutton.png b/tests/auto/widgets/styles/qstyle/images/vista/radiobutton.png Binary files differdeleted file mode 100644 index c8aa7864df..0000000000 --- a/tests/auto/widgets/styles/qstyle/images/vista/radiobutton.png +++ /dev/null diff --git a/tests/auto/widgets/styles/qstyle/images/vista/slider.png b/tests/auto/widgets/styles/qstyle/images/vista/slider.png Binary files differdeleted file mode 100644 index 7c156ded9d..0000000000 --- a/tests/auto/widgets/styles/qstyle/images/vista/slider.png +++ /dev/null diff --git a/tests/auto/widgets/styles/qstyle/images/vista/spinbox.png b/tests/auto/widgets/styles/qstyle/images/vista/spinbox.png Binary files differdeleted file mode 100644 index b8d0823ab2..0000000000 --- a/tests/auto/widgets/styles/qstyle/images/vista/spinbox.png +++ /dev/null diff --git a/tests/auto/widgets/styles/qstyle/qstyle.pro b/tests/auto/widgets/styles/qstyle/qstyle.pro index 9ad0940245..4dc0525c49 100644 --- a/tests/auto/widgets/styles/qstyle/qstyle.pro +++ b/tests/auto/widgets/styles/qstyle/qstyle.pro @@ -2,8 +2,3 @@ CONFIG += testcase TARGET = tst_qstyle QT += widgets testlib testlib-private SOURCES += tst_qstyle.cpp - -android:!android-embedded { - RESOURCES += \ - testdata.qrc -} diff --git a/tests/auto/widgets/styles/qstyle/testdata.qrc b/tests/auto/widgets/styles/qstyle/testdata.qrc deleted file mode 100644 index 29bb46726e..0000000000 --- a/tests/auto/widgets/styles/qstyle/testdata.qrc +++ /dev/null @@ -1,19 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>images/mac/button.png</file> - <file>images/mac/combobox.png</file> - <file>images/mac/lineedit.png</file> - <file>images/mac/mdi.png</file> - <file>images/mac/menu.png</file> - <file>images/mac/radiobutton.png</file> - <file>images/mac/slider.png</file> - <file>images/mac/spinbox.png</file> - <file>images/vista/button.png</file> - <file>images/vista/combobox.png</file> - <file>images/vista/lineedit.png</file> - <file>images/vista/menu.png</file> - <file>images/vista/radiobutton.png</file> - <file>images/vista/slider.png</file> - <file>images/vista/spinbox.png</file> - </qresource> -</RCC> diff --git a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp index 68e672e16d..ae084310b1 100644 --- a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp +++ b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp @@ -73,7 +73,6 @@ public: private: bool testAllFunctions(QStyle *); bool testScrollBarSubControls(); - void testPainting(QStyle *style, const QString &platform); private slots: void drawItemPixmap(); void init(); @@ -333,141 +332,15 @@ void tst_QStyle::testWindowsStyle() delete wstyle; } -void writeImage(const QString &fileName, QImage image) -{ - QImageWriter imageWriter(fileName); - imageWriter.setFormat("png"); - qDebug() << "result " << imageWriter.write(image); -} - -QImage readImage(const QString &fileName) -{ - QImageReader reader(fileName); - return reader.read(); -} - - #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)); - - if (QOperatingSystemVersion::current().majorVersion() - == QOperatingSystemVersion::WindowsVista.majorVersion() - && QOperatingSystemVersion::current().minorVersion() - == QOperatingSystemVersion::WindowsVista.minorVersion()) - testPainting(vistastyle, "vista"); delete vistastyle; } #endif -void comparePixmap(const QString &filename, const QPixmap &pixmap) -{ - QImage oldFile = readImage(filename); - QPixmap oldPixmap = QPixmap::fromImage(oldFile); - if (!oldFile.isNull()) - QCOMPARE(pixmap, oldPixmap); - else - writeImage(filename, pixmap.toImage()); -} - -void tst_QStyle::testPainting(QStyle *style, const QString &platform) -{ -qDebug("TEST PAINTING"); - //Test Menu - QString fileName = "images/" + platform + "/menu.png"; - QMenu menu; - menu.setStyle(style); - menu.show(); - menu.addAction(new QAction("Test 1", &menu)); - menu.addAction(new QAction("Test 2", &menu)); - QPixmap pixmap = menu.grab(); - comparePixmap(fileName, pixmap); - - //Push button - fileName = "images/" + platform + "/button.png"; - QPushButton button("OK"); - button.setStyle(style); - button.show(); - pixmap = button.grab(); - button.hide(); - comparePixmap(fileName, pixmap); - - //Push button - fileName = "images/" + platform + "/radiobutton.png"; - QRadioButton radiobutton("Check"); - radiobutton.setStyle(style); - radiobutton.show(); - pixmap = radiobutton.grab(); - radiobutton.hide(); - comparePixmap(fileName, pixmap); - - //Combo box - fileName = "images/" + platform + "/combobox.png"; - QComboBox combobox; - combobox.setStyle(style); - combobox.addItem("Test 1"); - combobox.addItem("Test 2"); - combobox.show(); - pixmap = combobox.grab(); - combobox.hide(); - comparePixmap(fileName, pixmap); - - //Spin box - fileName = "images/" + platform + "/spinbox.png"; - QDoubleSpinBox spinbox; - spinbox.setLocale(QLocale(QLocale::English, QLocale::UnitedStates)); - spinbox.setStyle(style); - spinbox.show(); - pixmap = spinbox.grab(); - spinbox.hide(); - comparePixmap(fileName, pixmap); - QLocale::setDefault(QLocale::system()); - - //Slider - fileName = "images/" + platform + "/slider.png"; - QSlider slider; - slider.setStyle(style); - slider.show(); - pixmap = slider.grab(); - slider.hide(); - comparePixmap(fileName, pixmap); - - //Line edit - fileName = "images/" + platform + "/lineedit.png"; - QLineEdit lineedit("Test text"); - lineedit.setStyle(style); - lineedit.show(); - pixmap = lineedit.grab(); - lineedit.hide(); - comparePixmap(fileName, pixmap); - - //MDI - fileName = "images/" + platform + "/mdi.png"; - QMdiArea mdiArea; - mdiArea.addSubWindow(new QWidget(&mdiArea)); - mdiArea.resize(200, 200); - mdiArea.setStyle(style); - mdiArea.show(); - pixmap = mdiArea.grab(); - mdiArea.hide(); - comparePixmap(fileName, pixmap); - - // QToolButton - fileName = "images/" + platform + "/toolbutton.png"; - QToolButton tb; - tb.setToolButtonStyle(Qt::ToolButtonTextUnderIcon); - tb.setText("AaQqPpXx"); - tb.setIcon(style->standardPixmap(QStyle::SP_DirHomeIcon)); - tb.setStyle(style); - tb.show(); - pixmap = tb.grab(); - tb.hide(); - comparePixmap(fileName, pixmap); - -} - #ifdef Q_OS_MAC void tst_QStyle::testMacStyle() { diff --git a/tests/auto/widgets/widgets/qframe/tst_qframe.cpp b/tests/auto/widgets/widgets/qframe/tst_qframe.cpp index 432f4474c5..05f9cd2e4a 100644 --- a/tests/auto/widgets/widgets/qframe/tst_qframe.cpp +++ b/tests/auto/widgets/widgets/qframe/tst_qframe.cpp @@ -37,6 +37,10 @@ class tst_QFrame : public QObject { Q_OBJECT + +public: + static void initMain() { QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); } + private slots: void testDefaults(); void testInitStyleOption_data(); diff --git a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp index 21c9f41646..76f8ebc804 100644 --- a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp +++ b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp @@ -49,6 +49,9 @@ class tst_QOpenGLWidget : public QObject { Q_OBJECT +public: + static void initMain() { QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); } + private slots: void initTestCase(); void create(); |