summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativeviewer
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-06-29 03:37:22 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-06-29 06:32:36 (GMT)
commit5229d1a799377370062e7b3aa88b961bd188fe74 (patch)
tree5e68ce45d2bdf42c94fbacc84b897a87facb93c0 /tests/auto/declarative/qdeclarativeviewer
parenta9c721865d8da3533692452ca8dd4bf49e66528c (diff)
downloadQt-5229d1a799377370062e7b3aa88b961bd188fe74.zip
Qt-5229d1a799377370062e7b3aa88b961bd188fe74.tar.gz
Qt-5229d1a799377370062e7b3aa88b961bd188fe74.tar.bz2
Avoid duplicate code for testing initial sizes
Diffstat (limited to 'tests/auto/declarative/qdeclarativeviewer')
-rw-r--r--tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp36
1 files 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<QDeclarativeItem*>(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<QWidget *>(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<QWidget *>(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<QWidget *>(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);