diff options
author | Joerg Bornemann <joerg.bornemann@nokia.com> | 2010-01-22 12:55:31 (GMT) |
---|---|---|
committer | Prasanth Ullattil <prasanth.ullattil@nokia.com> | 2010-01-27 15:30:24 (GMT) |
commit | 98e2e1d674669bdfb773ddc8b8281eeb935a14e1 (patch) | |
tree | cd4a37c12e28e1bcf64cfe4b06b3d1c5d61cef68 | |
parent | 0f59e2a256266e9981a56945103ffd2a850f0d95 (diff) | |
download | Qt-98e2e1d674669bdfb773ddc8b8281eeb935a14e1.zip Qt-98e2e1d674669bdfb773ddc8b8281eeb935a14e1.tar.gz Qt-98e2e1d674669bdfb773ddc8b8281eeb935a14e1.tar.bz2 |
revert parts of 10392eef4fd4f9
We can't call QCOMPARE from within a nested function, because the
return statement will just exit that function.
VERIFY_COLOR can't be turned into a function this way.
-rw-r--r-- | tests/auto/qwidget/tst_qwidget.cpp | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index ee4e726..ea90ae3 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -5439,26 +5439,24 @@ public: QRegion r; }; -template<typename R, typename C> -void verifyColor(R const& region, C const& color) -{ - const QRegion r = QRegion(region); - for (int i = 0; i < r.rects().size(); ++i) { - const QRect rect = r.rects().at(i); - for (int t = 0; t < 5; t++) { - const QPixmap pixmap = QPixmap::grabWindow(QDesktopWidget().winId(), - rect.left(), rect.top(), - rect.width(), rect.height()); - QCOMPARE(pixmap.size(), rect.size()); - QPixmap expectedPixmap(pixmap); /* ensure equal formats */ - expectedPixmap.fill(color); - if (pixmap.toImage().pixel(0,0) != QColor(color).rgb() && t < 4 ) - { QTest::qWait(200); continue; } - QCOMPARE(pixmap.toImage().pixel(0,0), QColor(color).rgb()); - QCOMPARE(pixmap, expectedPixmap); - break; - } - } +#define VERIFY_COLOR(region, color) { \ + const QRegion r = QRegion(region); \ + for (int i = 0; i < r.rects().size(); ++i) { \ + const QRect rect = r.rects().at(i); \ + for (int t = 0; t < 5; t++) { \ + const QPixmap pixmap = QPixmap::grabWindow(QDesktopWidget().winId(), \ + rect.left(), rect.top(), \ + rect.width(), rect.height()); \ + QCOMPARE(pixmap.size(), rect.size()); \ + QPixmap expectedPixmap(pixmap); /* ensure equal formats */ \ + expectedPixmap.fill(color); \ + if (pixmap.toImage().pixel(0,0) != QColor(color).rgb() && t < 4 ) \ + { QTest::qWait(200); continue; } \ + QCOMPARE(pixmap.toImage().pixel(0,0), QColor(color).rgb()); \ + QCOMPARE(pixmap, expectedPixmap); \ + break; \ + } \ + } \ } void tst_QWidget::moveChild_data() @@ -5499,9 +5497,9 @@ void tst_QWidget::moveChild() #endif QTRY_COMPARE(parent.r, QRegion(parent.rect()) - child.geometry()); QTRY_COMPARE(child.r, QRegion(child.rect())); - verifyColor(child.geometry().translated(tlwOffset), + VERIFY_COLOR(child.geometry().translated(tlwOffset), child.color); - verifyColor(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), + VERIFY_COLOR(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), parent.color); parent.reset(); child.reset(); @@ -5520,9 +5518,9 @@ void tst_QWidget::moveChild() // should be scrolled in backingstore QCOMPARE(child.r, QRegion()); #endif - verifyColor(child.geometry().translated(tlwOffset), + VERIFY_COLOR(child.geometry().translated(tlwOffset), child.color); - verifyColor(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), + VERIFY_COLOR(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), parent.color); } @@ -5553,8 +5551,8 @@ void tst_QWidget::showAndMoveChild() child.move(desktopDimensions.width()/2, desktopDimensions.height()/2); qApp->processEvents(); - verifyColor(child.geometry().translated(tlwOffset), Qt::blue); - verifyColor(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), Qt::red); + VERIFY_COLOR(child.geometry().translated(tlwOffset), Qt::blue); + VERIFY_COLOR(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), Qt::red); } void tst_QWidget::subtractOpaqueSiblings() |