summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativeviewer
diff options
context:
space:
mode:
authorRobert Griebl <robert.griebl@nokia.com>2010-06-28 22:31:37 (GMT)
committerRobert Griebl <robert.griebl@nokia.com>2010-06-28 22:32:26 (GMT)
commit5b0de255d1facfe89efed393447a1c914ffdf414 (patch)
tree0c4a628c2058a1f54eb8ca56d04748d084ea87b0 /tests/auto/declarative/qdeclarativeviewer
parent9149efe500f91c08867d3658ac1064c7f226841e (diff)
downloadQt-5b0de255d1facfe89efed393447a1c914ffdf414.zip
Qt-5b0de255d1facfe89efed393447a1c914ffdf414.tar.gz
Qt-5b0de255d1facfe89efed393447a1c914ffdf414.tar.bz2
Adapt all qmlviewer testcases to the code changes in the actual viewer.
(currently tested on Linux only)
Diffstat (limited to 'tests/auto/declarative/qdeclarativeviewer')
-rw-r--r--tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
index 1ea2a95..576f721 100644
--- a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
+++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
@@ -43,6 +43,7 @@
#include <QtDeclarative/qdeclarativeengine.h>
#include <QtDeclarative/qdeclarativeview.h>
#include <QtDeclarative/qdeclarativeitem.h>
+#include <QtGui/qmenubar.h>
#include "../../../shared/util.h"
#include "qmlruntime.h"
#include "../../../shared/util.h"
@@ -52,6 +53,12 @@
#define SRCDIR "."
#endif
+#if defined(Q_OS_MAC) || defined(Q_WS_MAEMO_5) || defined(Q_WS_S60)
+# define MENUBAR_HEIGHT(mw) 0
+#else
+# define MENUBAR_HEIGHT(mw) (mw->menuBar()->height())
+#endif
+
class tst_QDeclarativeViewer : public QObject
{
@@ -77,45 +84,46 @@ tst_QDeclarativeViewer::tst_QDeclarativeViewer()
void tst_QDeclarativeViewer::orientation()
{
- QWidget window;
- QDeclarativeViewer *viewer = new QDeclarativeViewer(&window);
+ QDeclarativeViewer *viewer = new QDeclarativeViewer();
QVERIFY(viewer);
viewer->open(SRCDIR "/data/orientation.qml");
QVERIFY(viewer->view());
QVERIFY(viewer->menuBar());
QDeclarativeItem* rootItem = qobject_cast<QDeclarativeItem*>(viewer->view()->rootObject());
QVERIFY(rootItem);
- window.show();
+ viewer->show();
- QApplication::setActiveWindow(&window);
- QTest::qWaitForWindowShown(&window);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&window));
+ QApplication::setActiveWindow(viewer);
+ 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+viewer->menuBar()->height()));
+ QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer)));
QCOMPARE(viewer->size(), viewer->sizeHint());
viewer->rotateOrientation();
qApp->processEvents();
+ qApp->processEvents(); // one extra round for the delayed updateSizeHints() call
QCOMPARE(rootItem->width(), 300.0);
QCOMPARE(rootItem->height(), 200.0);
QTRY_COMPARE(viewer->view()->size(), QSize(300, 200));
QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(300, 200));
- QCOMPARE(viewer->size(), QSize(300, 200+viewer->menuBar()->height()));
+ QCOMPARE(viewer->size(), QSize(300, 200 + MENUBAR_HEIGHT(viewer)));
QCOMPARE(viewer->size(), viewer->sizeHint());
viewer->rotateOrientation();
qApp->processEvents();
+ qApp->processEvents(); // one extra round for the delayed updateSizeHints() call
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+viewer->menuBar()->height()));
+ QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer)));
QCOMPARE(viewer->size(), viewer->sizeHint());
}
@@ -249,7 +257,7 @@ void tst_QDeclarativeViewer::resizing()
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+viewer->menuBar()->height()));
+ QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer)));
QCOMPARE(viewer->size(), viewer->sizeHint());
viewer->setSizeToView(false);