From 5229d1a799377370062e7b3aa88b961bd188fe74 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Tue, 29 Jun 2010 13:37:22 +1000 Subject: Avoid duplicate code for testing initial sizes --- .../qdeclarativeviewer/tst_qdeclarativeviewer.cpp | 36 +++++++++------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp index 576f721..9660430 100644 --- a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp +++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp @@ -82,6 +82,18 @@ tst_QDeclarativeViewer::tst_QDeclarativeViewer() { } +#define TEST_INITIAL_SIZES(viewer) { \ + QDeclarativeItem* rootItem = qobject_cast(viewer->view()->rootObject()); \ + QVERIFY(rootItem); \ +\ + QCOMPARE(rootItem->width(), 200.0); \ + QCOMPARE(rootItem->height(), 300.0); \ + QTRY_COMPARE(viewer->view()->size(), QSize(200, 300)); \ + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); \ + QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer))); \ + QCOMPARE(viewer->size(), viewer->sizeHint()); \ +} + void tst_QDeclarativeViewer::orientation() { QDeclarativeViewer *viewer = new QDeclarativeViewer(); @@ -97,12 +109,7 @@ void tst_QDeclarativeViewer::orientation() QTest::qWaitForWindowShown(viewer); QTRY_COMPARE(QApplication::activeWindow(), static_cast(viewer)); - QCOMPARE(rootItem->width(), 200.0); - QCOMPARE(rootItem->height(), 300.0); - QTRY_COMPARE(viewer->view()->size(), QSize(200, 300)); - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); - QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer))); - QCOMPARE(viewer->size(), viewer->sizeHint()); + TEST_INITIAL_SIZES(viewer); viewer->rotateOrientation(); qApp->processEvents(); @@ -143,13 +150,7 @@ void tst_QDeclarativeViewer::loading() QTest::qWaitForWindowShown(viewer); QTRY_COMPARE(QApplication::activeWindow(), static_cast(viewer)); - // initial size - QTRY_COMPARE(rootItem->width(), 200.0); - QTRY_COMPARE(rootItem->height(), 300.0); - QCOMPARE(viewer->view()->size(), QSize(200, 300)); - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); - QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height())); - QCOMPARE(viewer->size(), viewer->sizeHint()); + TEST_INITIAL_SIZES(viewer); viewer->resize(QSize(400, 500)); qApp->processEvents(); @@ -251,14 +252,7 @@ void tst_QDeclarativeViewer::resizing() QTest::qWaitForWindowShown(viewer); QTRY_COMPARE(QApplication::activeWindow(), static_cast(viewer)); - // initial size - QCOMPARE(rootItem->width(), 200.0); - QCOMPARE(rootItem->height(), 300.0); - QCOMPARE(viewer->view()->size(), QSize(200, 300)); - QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); - QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer))); - QCOMPARE(viewer->size(), viewer->sizeHint()); + TEST_INITIAL_SIZES(viewer); viewer->setSizeToView(false); -- cgit v0.12