summaryrefslogtreecommitdiffstats
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
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)
-rw-r--r--tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp28
-rw-r--r--tools/qml/main.cpp2
-rw-r--r--tools/qml/qmlruntime.cpp12
-rw-r--r--tools/qml/qmlruntime.h5
4 files changed, 22 insertions, 25 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);
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp
index de5bca2..a75023b 100644
--- a/tools/qml/main.cpp
+++ b/tools/qml/main.cpp
@@ -346,7 +346,7 @@ int main(int argc, char ** argv)
if (stayOnTop)
wflags |= Qt::WindowStaysOnTopHint;
- QDeclarativeViewer *viewer = QDeclarativeViewer::instance(0, wflags);
+ QDeclarativeViewer *viewer = new QDeclarativeViewer(0, wflags);
viewer->setAttribute(Qt::WA_DeleteOnClose, true);
if (!scriptopts.isEmpty()) {
QStringList options =
diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp
index e0482cf..2cca262 100644
--- a/tools/qml/qmlruntime.cpp
+++ b/tools/qml/qmlruntime.cpp
@@ -534,17 +534,6 @@ QString QDeclarativeViewer::getVideoFileName()
return QFileDialog::getSaveFileName(this, title, "", types.join(";; "));
}
-QDeclarativeViewer *QDeclarativeViewer::inst = 0;
-
-QDeclarativeViewer *QDeclarativeViewer::instance(QWidget *parent, Qt::WindowFlags flags)
-{
- if (!inst) {
- inst = new QDeclarativeViewer(parent, flags);
- inst->setAttribute(Qt::WA_DeleteOnClose);
- }
- return inst;
-}
-
QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
: QMainWindow(parent, flags)
, loggerWindow(new LoggerWidget(this))
@@ -1400,6 +1389,7 @@ void QDeclarativeViewer::updateSizeHints()
canvas->setMinimumSize(newWindowSize);
canvas->resize(newWindowSize);
resize(1, 1); // workaround for QMainWindowLayout NOT shrinking the window if the centralWidget() shrinks
+ canvas->setMinimumSize(QSize(0, 0));
}
} else { // QDeclarativeView::SizeRootObjectToView
canvas->setMinimumSize(QSize(0,0));
diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h
index 92c2969..a3a9fb3 100644
--- a/tools/qml/qmlruntime.h
+++ b/tools/qml/qmlruntime.h
@@ -62,16 +62,15 @@ class QNetworkCookieJar;
class NetworkAccessManagerFactory;
class QTranslator;
class QActionGroup;
+class QMenuBar;
class QDeclarativeViewer
: public QMainWindow
{
Q_OBJECT
- QDeclarativeViewer(QWidget *parent = 0, Qt::WindowFlags flags = 0);
- static QDeclarativeViewer *inst;
public:
- static QDeclarativeViewer *instance(QWidget *parent = 0, Qt::WindowFlags flags = 0);
+ QDeclarativeViewer(QWidget *parent = 0, Qt::WindowFlags flags = 0);
~QDeclarativeViewer();
static void registerTypes();