summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
authorJoona Petrell <joona.t.petrell@nokia.com>2010-05-05 04:57:53 (GMT)
committerJoona Petrell <joona.t.petrell@nokia.com>2010-05-07 00:59:27 (GMT)
commit7c945e152c9abd0478bed5a4d251012944d93b44 (patch)
tree4edc61eaf52e44485db237ead602f0871726c2d5 /tests/auto/declarative
parent35e6100977e496a242c41f6f0fc66889e7cd49fc (diff)
downloadQt-7c945e152c9abd0478bed5a4d251012944d93b44.zip
Qt-7c945e152c9abd0478bed5a4d251012944d93b44.tar.gz
Qt-7c945e152c9abd0478bed5a4d251012944d93b44.tar.bz2
Resize qmlruntime window to new dimensions when orientation changes
Task-number: Reviewed-by: Warwick Allison
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/declarative.pro1
-rw-r--r--tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp4
-rw-r--r--tests/auto/declarative/qdeclarativeviewer/data/orientation.qml10
-rw-r--r--tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro11
-rw-r--r--tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp108
5 files changed, 132 insertions, 2 deletions
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro
index b8e33cf..05c4c26 100644
--- a/tests/auto/declarative/declarative.pro
+++ b/tests/auto/declarative/declarative.pro
@@ -64,6 +64,7 @@ SUBDIRS += \
qdeclarativestyledtext \ # Cover
qdeclarativesqldatabase \ # Cover
qdeclarativevisualdatamodel \ # Cover
+ qdeclarativeviewer \ # Cover
qmlvisual # Cover
contains(QT_CONFIG, webkit) {
diff --git a/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp b/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp
index 1ed51c1..dd2f46e 100644
--- a/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp
+++ b/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp
@@ -147,7 +147,7 @@ void tst_QDeclarativeView::resizemodedeclarativeitem()
declarativeItem->setHeight(80);
QCOMPARE(canvas->width(), 80);
QCOMPARE(canvas->height(), 100);
- QCOMPARE(canvas->size(), canvas->sizeHint());
+ QCOMPARE(QSize(declarativeItem->width(), declarativeItem->height()), canvas->sizeHint());
QCOMPARE(sceneResizedSpy2.count(), 2);
// size update from view
@@ -230,7 +230,7 @@ void tst_QDeclarativeView::resizemodegraphicswidget()
canvas->setResizeMode(QDeclarativeView::SizeRootObjectToView);
graphicsWidget->resize(QSizeF(60,80));
QCOMPARE(canvas->size(), QSize(80,100));
- QCOMPARE(canvas->size(), canvas->sizeHint());
+ QCOMPARE(QSize(graphicsWidget->size().width(), graphicsWidget->size().height()), canvas->sizeHint());
QCOMPARE(sceneResizedSpy2.count(), 2);
// size update from view
diff --git a/tests/auto/declarative/qdeclarativeviewer/data/orientation.qml b/tests/auto/declarative/qdeclarativeviewer/data/orientation.qml
new file mode 100644
index 0000000..687fac6
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeviewer/data/orientation.qml
@@ -0,0 +1,10 @@
+import Qt 4.7
+Rectangle {
+ color: "black"
+ width: (runtime.orientation == Orientation.Landscape) ? 300 : 200
+ height: (runtime.orientation == Orientation.Landscape) ? 200 : 300
+ Text {
+ text: runtime.orientation == Orientation.Landscape ? "Landscape" : "Portrait"
+ color: "white"
+ }
+} \ No newline at end of file
diff --git a/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro b/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro
new file mode 100644
index 0000000..dc10f5b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro
@@ -0,0 +1,11 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+include(../../../../tools/qml/qml.pri)
+
+SOURCES += tst_qdeclarativeviewer.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
diff --git a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
new file mode 100644
index 0000000..9429dc9
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativeview.h>
+#include <QtDeclarative/qdeclarativeitem.h>
+#include "qmlruntime.h"
+
+class tst_QDeclarativeViewer : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_QDeclarativeViewer();
+
+private slots:
+ void orientation();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+tst_QDeclarativeViewer::tst_QDeclarativeViewer()
+{
+}
+
+void tst_QDeclarativeViewer::orientation()
+{
+ QWidget window;
+ QDeclarativeViewer *viewer = new QDeclarativeViewer(&window);
+ 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();
+
+ QCOMPARE(rootItem->width(), 200.0);
+ QCOMPARE(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());
+
+ viewer->toggleOrientation();
+ qApp->processEvents();
+
+ QCOMPARE(rootItem->width(), 300.0);
+ QCOMPARE(rootItem->height(), 200.0);
+ QCOMPARE(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(), viewer->sizeHint());
+
+ viewer->toggleOrientation();
+ qApp->processEvents();
+
+ QCOMPARE(rootItem->width(), 200.0);
+ QCOMPARE(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());
+}
+
+QTEST_MAIN(tst_QDeclarativeViewer)
+
+#include "tst_qdeclarativeviewer.moc"