From 9022f42a4fb0965df480b440edf6bbce0286081f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Samuel=20R=C3=B8dal?= Date: Tue, 1 Nov 2011 08:12:07 +0100 Subject: [PATCH] Get rid of "#if 0" and skipped tests in QPainter autotest. qt_format_text_clip() and qt_format_text_boundingrect() have been skipped ever since they were originally added to git, so I see no point in keeping them. The #if 0 in setEqualClipRegionAndPath() was ifdefed out from when that specific test case was added (maybe it was failing to begin with?), but it passes now, so we should enable it. Change-Id: I6551e3b5612a4d4b00a969511af6abc85db43892 Reviewed-by: Jason McDonald --- tests/auto/gui/painting/qpainter/tst_qpainter.cpp | 271 ---------------------- 1 file changed, 271 deletions(-) diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index d33ee59..d41e0e4 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -94,8 +94,6 @@ public slots: void cleanup(); private slots: void getSetCheck(); - void qt_format_text_clip(); - void qt_format_text_boundingRect(); #ifndef Q_WS_MAC void drawPixmap_comp_data(); void drawPixmap_comp(); @@ -373,273 +371,6 @@ void tst_QPainter::cleanup() { } -/* tests the clipping operations in qt_format_text, making sure - the clip rectangle after the call is the same as before -*/ -void tst_QPainter::qt_format_text_clip() -{ - QSKIP("Needs fixing..."); - - QWidget *w = new QWidget( 0 ); - - int modes[] = { Qt::AlignVCenter|Qt::TextSingleLine, - Qt::AlignVCenter|Qt::TextSingleLine|Qt::TextDontClip, - Qt::AlignVCenter|Qt::TextWordWrap, - Qt::AlignVCenter|Qt::TextWordWrap|Qt::TextDontClip, - 0 - }; - - int *m = modes; - while( *m ) { - { - QPainter p( w ); - QRegion clipreg = p.clipRegion(); - bool hasClipping = p.hasClipping(); - qreal tx = p.matrix().dx(); - qreal ty = p.matrix().dy(); - - p.drawText( 10, 10, 100, 100, *m, - "fooo" ); - - QVERIFY( clipreg == p.clipRegion() ); - QVERIFY( hasClipping == p.hasClipping() ); - QCOMPARE( tx, p.matrix().dx() ); - QCOMPARE( ty, p.matrix().dy() ); - - p.setClipRect( QRect( 5, 5, 50, 50 ) ); - clipreg = p.clipRegion(); - hasClipping = p.hasClipping(); - - p.drawText( 10, 10, 100, 100, *m, - "fooo" ); - - QVERIFY( clipreg == p.clipRegion() ); - QVERIFY( hasClipping == p.hasClipping() ); - QCOMPARE( tx, p.matrix().dx() ); - QCOMPARE( ty, p.matrix().dy() ); - } - { - QPainter p( w ); - p.setMatrix( QMatrix( 2, 1, 3, 4, 5, 6 ) ); - QRegion clipreg = p.clipRegion(); - bool hasClipping = p.hasClipping(); - qreal tx = p.matrix().dx(); - qreal ty = p.matrix().dy(); - - p.drawText( 10, 10, 100, 100, *m, - "fooo" ); - - QVERIFY( clipreg == p.clipRegion() ); - QVERIFY( hasClipping == p.hasClipping() ); - QCOMPARE( tx, p.matrix().dx() ); - QCOMPARE( ty, p.matrix().dy() ); - - p.setClipRect( QRect( 5, 5, 50, 50 ) ); - clipreg = p.clipRegion(); - hasClipping = p.hasClipping(); - - p.drawText( 10, 10, 100, 100, *m, - "fooo" ); - - QVERIFY( clipreg == p.clipRegion() ); - QVERIFY( hasClipping == p.hasClipping() ); - QCOMPARE( tx, p.matrix().dx() ); - QCOMPARE( ty, p.matrix().dy() ); - } - { - QPainter p( w ); - QRegion clipreg = p.clipRegion(); - bool hasClipping = p.hasClipping(); - qreal tx = p.matrix().dx(); - qreal ty = p.matrix().dy(); - - p.drawText( 10, 10, 100, 100, *m, - "fooo" ); - - QVERIFY( clipreg == p.clipRegion() ); - QVERIFY( hasClipping == p.hasClipping() ); - QCOMPARE( tx, p.matrix().dx() ); - QCOMPARE( ty, p.matrix().dy() ); - - p.setClipRect( QRect( 5, 5, 50, 50 )); - clipreg = p.clipRegion(); - hasClipping = p.hasClipping(); - - p.drawText( 10, 10, 100, 100, *m, - "fooo" ); - - QVERIFY( clipreg == p.clipRegion() ); - QVERIFY( hasClipping == p.hasClipping() ); - QCOMPARE( tx, p.matrix().dx() ); - QCOMPARE( ty, p.matrix().dy() ); - } - { - QPainter p( w ); - p.setMatrix( QMatrix( 2, 1, 3, 4, 5, 6 ) ); - QRegion clipreg = p.clipRegion(); - bool hasClipping = p.hasClipping(); - qreal tx = p.matrix().dx(); - qreal ty = p.matrix().dy(); - - p.drawText( 10, 10, 100, 100, *m, - "fooo" ); - - QVERIFY( clipreg == p.clipRegion() ); - QVERIFY( hasClipping == p.hasClipping() ); - QCOMPARE( tx, p.matrix().dx() ); - QCOMPARE( ty, p.matrix().dy() ); - - p.setClipRect(QRect( 5, 5, 50, 50 )); - clipreg = p.clipRegion(); - hasClipping = p.hasClipping(); - - p.drawText( 10, 10, 100, 100, *m, - "fooo" ); - - QVERIFY( clipreg == p.clipRegion() ); - QVERIFY( hasClipping == p.hasClipping() ); - QCOMPARE( tx, p.matrix().dx() ); - QCOMPARE( ty, p.matrix().dy() ); - } - ++m; - } - delete w; -} - -/* tests the bounding rect calculations in qt_format_text, making sure - the bounding rect has a reasonable value. -*/ -void tst_QPainter::qt_format_text_boundingRect() -{ - QSKIP("Needs fixing..."); - - { - const char * strings[] = { - "a\n\nb", - "abc", - "a\n \nb", - "this is a longer string", - "\327\222\327\223\327\233\327\223\327\222\327\233\327\222\327\223\327\233", - "aa\327\222\327\233aa", - "\327\222\327\223\327\233\327\223\327\222\327\233\327\222\327\223\327\233", - "\327\222\327\233aa", - "linebreakatend\n", - "some text longer than 30 chars with a line break at the end\n", - "some text\nwith line breaks\nin the middle\nand at the end\n", - "foo\n\n\nfoo", - 0 - }; - - int modes[] = { Qt::AlignVCenter|Qt::TextSingleLine, - Qt::AlignVCenter|Qt::TextSingleLine|Qt::TextDontClip, - Qt::AlignVCenter|Qt::TextWordWrap, - Qt::AlignVCenter|Qt::TextWordWrap|Qt::TextDontClip, - Qt::AlignLeft, - Qt::AlignCenter, - Qt::AlignRight, - 0 - }; - - QFont f; - for(int i = 5; i < 15; ++i) { - f.setPointSize(i); - QFontMetrics fm(f); - const char **str = strings; - while( *str ) { - int *m = modes; - while( *m ) { - QRect br = fm.boundingRect( 0, 0, 2000, 100, *m, QString::fromUtf8( *str ) ); - QVERIFY( br.width() < 800 ); - - QRect br2 = fm.boundingRect( br.x(), br.y(), br.width(), br.height(), *m, QString::fromUtf8( *str ) ); - QCOMPARE( br, br2 ); -#if 0 - { - QPrinter printer; - printer.setOutputToFile(TRUE); - printer.setOutputFileName("tmp.prn"); - QPainter p(&printer); - QRect pbr = p.fontMetrics().boundingRect( 0, 0, 2000, 100, *m, QString::fromUtf8( *str ) ); - QCOMPARE(pbr, br); - } -#endif -#if !defined(QT_NO_PRINTER) && !defined(Q_OS_WINCE) - { - QPrinter printer(QPrinter::HighResolution); - if (printer.printerName().isEmpty()) - QSKIP("No printers installed, skipping bounding rect test"); - - printer.setOutputFileName("tmp.prn"); - QPainter p(&printer); - QRect pbr = p.fontMetrics().boundingRect( 0, 0, 12000, 600, *m, QString::fromUtf8( *str ) ); - QVERIFY(pbr.width() > 2*br.width()); - QVERIFY(pbr.height() > 2*br.height()); - } -#endif - ++m; - } - ++str; - } - } - } - - { - const char * strings[] = { - "a", - "a\nb", - "a\n\nb", - "abc", -// "a\n \nb", - "this is a longer string", -// "\327\222\327\223\327\233\327\223\327\222\327\233\327\222\327\223\327\233", -// "aa\327\222\327\233aa", -// "\327\222\327\223\327\233\327\223\327\222\327\233\327\222\327\223\327\233", -// "\327\222\327\233aa", -// "linebreakatend\n", -// "some text longer than 30 chars with a line break at the end\n", -// "some text\nwith line breaks\nin the middle\nand at the end\n", - "foo\n\n\nfoo", - "a\n\n\n\n\nb", - "a\n\n\n\n\n\nb", -// "\347\231\273\351\214\262\346\203\205\345\240\261\343\201\214\350\246\213\343\201\244\343\201\213\343\202\211\343\201\252\343\201\204\343\201\213\347\204\241\345\212\271\343\201\252\343\201\237\343\202\201\343\200\201\nPhotoshop Album \343\202\222\350\265\267\345\213\225\343\201\247\343\201\215\343\201\276\343\201\233\343\202\223\343\200\202\345\206\215\343\202\244\343\203\263\343\202\271\343\203\210\343\203\274\343\203\253\343\201\227\343\201\246\343\201\217\343\201\240\343\201\225\343\201\204\343\200\202" -// "\347\231\273\351\214\262\346\203\205\345\240\261\343\201\214\350\246\213\343\201\244\343\201\213\343\202\211\343\201\252\343\201\204\343\201\213\347\204\241\345\212\271\343\201\252\343\201\237\343\202\201\343\200\201\n\343\202\222\350\265\267\345\213\225\343\201\247\343\201\215\343\201\276\343\201\233\343\202\223\343\200\202\345\206\215\343\202\244\343\203\263\343\202\271\343\203\210\343\203\274\343\203\253\343\201\227\343\201\246\343\201\217\343\201\240\343\201\225\343\201\204\343\200\202", - 0 - }; - - int modes[] = { Qt::AlignVCenter, - Qt::AlignLeft, - Qt::AlignCenter, - Qt::AlignRight, - 0 - }; - - - QFont f; - for(int i = 5; i < 15; ++i) { - f.setPointSize(i); - QFontMetrics fm(f); - const char **str = strings; - while( *str ) { - int *m = modes; - while( *m ) { - QString s = QString::fromUtf8(*str); - QRect br = fm.boundingRect(0, 0, 1000, 1000, *m, s ); - int lines = - s.count("\n"); - int expectedHeight = fm.height()+lines*fm.lineSpacing(); - QCOMPARE(br.height(), expectedHeight); - ++m; - } - ++str; - } - QRect br = fm.boundingRect(0, 0, 100, 0, Qt::TextWordWrap, - "A paragraph with gggggggggggggggggggggggggggggggggggg in the middle."); - QVERIFY(br.height() >= fm.height()+2*fm.lineSpacing()); - } - } -} - - static const char* const maskSource_data[] = { "16 13 6 1", ". c None", @@ -1944,7 +1675,6 @@ void tst_QPainter::setEqualClipRegionAndPath() QCOMPARE(img1, img2); -#if 0 // rotated img1.fill(0x12345678); img2.fill(0x12345678); @@ -1963,7 +1693,6 @@ void tst_QPainter::setEqualClipRegionAndPath() } QCOMPARE(img1, img2); -#endif img1.fill(0x12345678); img2.fill(0x12345678); -- 2.7.4