tst_QRegion: compile under QT_DISABLE_DEPRECATED_BEFORE=0x051200

The introduction of begin()/end() actually made most tests
that still use rects() duplicates. Keep them, though, for
test coverage (rects() takes a very different code path
from begin()/end()), but, under the assumption that Qt at
some point will default to built with deprecated APIs dis-
abled, make the test compile with disabled deprecated API.

Port some checks that still used rects() to begin()/end().

Change-Id: Ia7da80f0cd6ef69693f54a474924683624a2c3eb
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Marc Mutz 2017-12-07 09:27:41 +01:00
parent b461ac36ed
commit a31f65d8c8

View File

@ -158,15 +158,19 @@ void tst_QRegion::rects()
QRegion region(rect); QRegion region(rect);
QVERIFY(region.isEmpty()); QVERIFY(region.isEmpty());
QCOMPARE(region.begin(), region.end()); QCOMPARE(region.begin(), region.end());
#if QT_DEPRECATED_SINCE(5, 11)
QVERIFY(region.rects().isEmpty()); QVERIFY(region.rects().isEmpty());
#endif
} }
{ {
QRect rect(10, -20, 30, 40); QRect rect(10, -20, 30, 40);
QRegion region(rect); QRegion region(rect);
QCOMPARE(region.end(), region.begin() + 1); QCOMPARE(region.end(), region.begin() + 1);
QCOMPARE(*region.begin(), rect); QCOMPARE(*region.begin(), rect);
#if QT_DEPRECATED_SINCE(5, 11)
QCOMPARE(region.rects().count(), 1); QCOMPARE(region.rects().count(), 1);
QCOMPARE(region.rects()[0], rect); QCOMPARE(region.rects()[0], rect);
#endif
} }
{ {
QRect r(QPoint(10, 10), QPoint(40, 40)); QRect r(QPoint(10, 10), QPoint(40, 40));
@ -193,8 +197,8 @@ void tst_QRegion::swap()
QRegion r1(QRect(0, 0,10,10)); QRegion r1(QRect(0, 0,10,10));
QRegion r2(QRect(10,10,10,10)); QRegion r2(QRect(10,10,10,10));
r1.swap(r2); r1.swap(r2);
QCOMPARE(r1.rects().front(), QRect(10,10,10,10)); QCOMPARE(*r1.begin(), QRect(10,10,10,10));
QCOMPARE(r2.rects().front(), QRect(0, 0,10,10)); QCOMPARE(*r2.begin(), QRect(0, 0,10,10));
} }
void tst_QRegion::setRects() void tst_QRegion::setRects()
@ -202,7 +206,8 @@ void tst_QRegion::setRects()
{ {
QRegion region; QRegion region;
region.setRects(0, 0); region.setRects(0, 0);
QVERIFY(region.rects().isEmpty()); QVERIFY(region.isEmpty());
QCOMPARE(region.begin(), region.end());
} }
{ {
QRegion region; QRegion region;
@ -212,7 +217,9 @@ void tst_QRegion::setRects()
QCOMPARE(region, QRegion()); QCOMPARE(region, QRegion());
QCOMPARE(region.begin(), region.end()); QCOMPARE(region.begin(), region.end());
QVERIFY(!region.boundingRect().isValid()); QVERIFY(!region.boundingRect().isValid());
#if QT_DEPRECATED_SINCE(5, 11)
QVERIFY(region.rects().isEmpty()); QVERIFY(region.rects().isEmpty());
#endif
} }
{ {
QRegion region; QRegion region;
@ -220,15 +227,19 @@ void tst_QRegion::setRects()
region.setRects(&rect, 1); region.setRects(&rect, 1);
QCOMPARE(region.begin(), region.end()); QCOMPARE(region.begin(), region.end());
QVERIFY(!region.boundingRect().isValid()); QVERIFY(!region.boundingRect().isValid());
#if QT_DEPRECATED_SINCE(5, 11)
QVERIFY(region.rects().isEmpty()); QVERIFY(region.rects().isEmpty());
#endif
} }
{ {
QRegion region; QRegion region;
QRect rect(10, -20, 30, 40); QRect rect(10, -20, 30, 40);
region.setRects(&rect, 1); region.setRects(&rect, 1);
QCOMPARE(region.end(), region.begin() + 1); QCOMPARE(region.end(), region.begin() + 1);
#if QT_DEPRECATED_SINCE(5, 11)
QCOMPARE(region.rects().count(), 1); QCOMPARE(region.rects().count(), 1);
QCOMPARE(region.rects()[0], rect); QCOMPARE(region.rects()[0], rect);
#endif
QCOMPARE(*region.begin(), rect); QCOMPARE(*region.begin(), rect);
} }
} }
@ -345,9 +356,11 @@ void tst_QRegion::emptyPolygonRegion()
QTEST(int(std::distance(r.begin(), r.end())), "numRects"); QTEST(int(std::distance(r.begin(), r.end())), "numRects");
QVector<QRect> rects; QVector<QRect> rects;
std::copy(r.begin(), r.end(), std::back_inserter(rects)); std::copy(r.begin(), r.end(), std::back_inserter(rects));
QTEST(r.rects().count(), "numRects"); QTEST(rects.size(), "numRects");
QTEST(r.rects(), "rects"); QTEST(rects, "rects");
#if QT_DEPRECATED_SINCE(5, 11)
QCOMPARE(r.rects(), rects); QCOMPARE(r.rects(), rects);
#endif
} }
@ -890,7 +903,9 @@ void tst_QRegion::isEmpty()
QCOMPARE(region, QRegion()); QCOMPARE(region, QRegion());
QCOMPARE(region.rectCount(), 0); QCOMPARE(region.rectCount(), 0);
QCOMPARE(region.boundingRect(), QRect()); QCOMPARE(region.boundingRect(), QRect());
#if QT_DEPRECATED_SINCE(5, 11)
QVERIFY(region.rects().isEmpty()); QVERIFY(region.rects().isEmpty());
#endif
} }
#if 0 /* Used to be included in Qt4 for Q_WS_X11 */ && defined(QT_BUILD_INTERNAL) #if 0 /* Used to be included in Qt4 for Q_WS_X11 */ && defined(QT_BUILD_INTERNAL)
@ -924,9 +939,11 @@ void tst_QRegion::regionFromPath()
QCOMPARE(rgn.begin()[0], QRect(0, 0, 10, 10)); QCOMPARE(rgn.begin()[0], QRect(0, 0, 10, 10));
QCOMPARE(rgn.begin()[1], QRect(0, 100, 100, 1000)); QCOMPARE(rgn.begin()[1], QRect(0, 100, 100, 1000));
#if QT_DEPRECATED_SINCE(5, 11)
QCOMPARE(rgn.rects().size(), 2); QCOMPARE(rgn.rects().size(), 2);
QCOMPARE(rgn.rects().at(0), QRect(0, 0, 10, 10)); QCOMPARE(rgn.rects().at(0), QRect(0, 0, 10, 10));
QCOMPARE(rgn.rects().at(1), QRect(0, 100, 100, 1000)); QCOMPARE(rgn.rects().at(1), QRect(0, 100, 100, 1000));
#endif
QCOMPARE(rgn.boundingRect(), QRect(0, 0, 100, 1100)); QCOMPARE(rgn.boundingRect(), QRect(0, 0, 100, 1100));
} }
@ -944,11 +961,13 @@ void tst_QRegion::regionFromPath()
QCOMPARE(rgn.begin()[2], QRect(90, 10, 10, 80)); QCOMPARE(rgn.begin()[2], QRect(90, 10, 10, 80));
QCOMPARE(rgn.begin()[3], QRect(0, 90, 100, 10)); QCOMPARE(rgn.begin()[3], QRect(0, 90, 100, 10));
#if QT_DEPRECATED_SINCE(5, 11)
QCOMPARE(rgn.rects().size(), 4); QCOMPARE(rgn.rects().size(), 4);
QCOMPARE(rgn.rects().at(0), QRect(0, 0, 100, 10)); QCOMPARE(rgn.rects().at(0), QRect(0, 0, 100, 10));
QCOMPARE(rgn.rects().at(1), QRect(0, 10, 10, 80)); QCOMPARE(rgn.rects().at(1), QRect(0, 10, 10, 80));
QCOMPARE(rgn.rects().at(2), QRect(90, 10, 10, 80)); QCOMPARE(rgn.rects().at(2), QRect(90, 10, 10, 80));
QCOMPARE(rgn.rects().at(3), QRect(0, 90, 100, 10)); QCOMPARE(rgn.rects().at(3), QRect(0, 90, 100, 10));
#endif
QCOMPARE(rgn.boundingRect(), QRect(0, 0, 100, 100)); QCOMPARE(rgn.boundingRect(), QRect(0, 0, 100, 100));
} }