From e7d476031474786a2e11ff6d3f9af0d5244f19d8 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 5 Jul 2016 09:41:15 +0200 Subject: Testlib: Format QRegion in QCOMPARE Output regions as a compact list of rectangles: QRegion(2 rectangles, 50x200+100+200, 200x50+10+10) Change-Id: I62e42bd30897a1d31b28e0cbd6afe7fa8ecf2664 Reviewed-by: Edward Welbourne --- .../auto/testlib/selftests/cmptest/tst_cmptest.cpp | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp') diff --git a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp index c3229b495e..3586b7f420 100644 --- a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp +++ b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp @@ -141,6 +141,8 @@ private slots: void compareQPixmaps_data(); void compareQImages(); void compareQImages_data(); + void compareQRegion_data(); + void compareQRegion(); #endif void verify(); void verify2(); @@ -409,6 +411,29 @@ void tst_Cmptest::compareQImages() QCOMPARE(opA, opB); } + +void tst_Cmptest::compareQRegion_data() +{ + QTest::addColumn("rA"); + QTest::addColumn("rB"); + const QRect rect1(QPoint(10, 10), QSize(200, 50)); + const QRegion region1(rect1); + QRegion listRegion2; + const QVector list2 = QVector() << QRect(QPoint(100, 200), QSize(50, 200)) << rect1; + listRegion2.setRects(list2.constData(), list2.size()); + QTest::newRow("equal-empty") << QRegion() << QRegion(); + QTest::newRow("1-empty") << region1 << QRegion(); + QTest::newRow("equal") << region1 << region1; + QTest::newRow("different lists") << region1 << listRegion2; +} + +void tst_Cmptest::compareQRegion() +{ + QFETCH(QRegion, rA); + QFETCH(QRegion, rB); + + QCOMPARE(rA, rB); +} #endif // QT_GUI_LIB static int opaqueFunc() -- cgit v1.2.3