summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativeviewer
diff options
context:
space:
mode:
authorJoona Petrell <joona.t.petrell@nokia.com>2010-07-28 08:45:23 (GMT)
committerJoona Petrell <joona.t.petrell@nokia.com>2010-08-03 01:45:34 (GMT)
commite62f266a7642e675e9d235a1f54a6b5746500d48 (patch)
tree7ed719f4539ecb0a634dad714105c70819683810 /tests/auto/declarative/qdeclarativeviewer
parent1fc6cab93ba2d067fadcd0979640c32aa1d5ae4a (diff)
downloadQt-e62f266a7642e675e9d235a1f54a6b5746500d48.zip
Qt-e62f266a7642e675e9d235a1f54a6b5746500d48.tar.gz
Qt-e62f266a7642e675e9d235a1f54a6b5746500d48.tar.bz2
Make it possible to manually set the orientation of QML Viewer on Symbian
Task-number: QTBUG-12142 Reviewed-by: Warwick Allison This patch brings ability to switch QML Viewer's orientation between auto-orientation (=follow sensor), portrait and landscape orientations (lock orientation) on Symbian. It provides same orientation options as Qt Creator 2.1's Qt QML Standalone Application creation wizard. Also, menu item rotateOrientation now works on Symbian, but it's hidden when orientation mode is set to auto-orientation. Property runtime.orientation has been switched back to supporting four-way orientation on Symbian, previously it only updated values between portrait and landscape. If your application only supports landscape or portrait modes, just don't react to the inverted orientations. Added orientation example screenorientation under examples/declarative. The patch includes a fix for calculator example, which rotated to wrong direction when switching from portrait to landscape. Also, improved qdeclarativeviewer unit tests. Changes have been tested to work on Windows, Linux and Symbian^3.
Diffstat (limited to 'tests/auto/declarative/qdeclarativeviewer')
-rw-r--r--tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp36
1 files changed, 33 insertions, 3 deletions
diff --git a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
index de8d222..1c1c04b 100644
--- a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
+++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
@@ -43,9 +43,11 @@
#include <QtDeclarative/qdeclarativeengine.h>
#include <QtDeclarative/qdeclarativeview.h>
#include <QtDeclarative/qdeclarativeitem.h>
+#include <QtDeclarative/qdeclarativecontext.h>
#include <QtGui/qmenubar.h>
#include "../../../shared/util.h"
#include "qmlruntime.h"
+#include "deviceorientation.h"
#include "../../../shared/util.h"
#ifdef Q_OS_SYMBIAN
@@ -67,7 +69,7 @@ public:
tst_QDeclarativeViewer();
private slots:
- void orientation();
+ void runtimeContextProperty();
void loading();
void fileBrowser();
void resizing();
@@ -94,7 +96,7 @@ tst_QDeclarativeViewer::tst_QDeclarativeViewer()
QCOMPARE(viewer->size(), viewer->sizeHint()); \
}
-void tst_QDeclarativeViewer::orientation()
+void tst_QDeclarativeViewer::runtimeContextProperty()
{
QDeclarativeViewer *viewer = new QDeclarativeViewer();
QVERIFY(viewer);
@@ -103,17 +105,30 @@ void tst_QDeclarativeViewer::orientation()
QVERIFY(viewer->menuBar());
QDeclarativeItem* rootItem = qobject_cast<QDeclarativeItem*>(viewer->view()->rootObject());
QVERIFY(rootItem);
+ QObject *runtimeObject = qvariant_cast<QObject*>(viewer->view()->engine()->rootContext()->contextProperty("runtime"));
+ QVERIFY(runtimeObject);
+
+ // test isActiveWindow property
+ QVERIFY(!runtimeObject->property("isActiveWindow").toBool());
+
viewer->show();
-
QApplication::setActiveWindow(viewer);
QTest::qWaitForWindowShown(viewer);
QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(viewer));
+ QVERIFY(runtimeObject->property("isActiveWindow").toBool());
+
TEST_INITIAL_SIZES(viewer);
+ // test orientation property
+ QCOMPARE(runtimeObject->property("orientation").toInt(), int(DeviceOrientation::Portrait));
+
viewer->rotateOrientation();
qApp->processEvents();
+ QCOMPARE(runtimeObject->property("orientation").toInt(), int(DeviceOrientation::Landscape));
+ QCOMPARE(rootItem->width(), 300.0);
+
QCOMPARE(rootItem->width(), 300.0);
QCOMPARE(rootItem->height(), 200.0);
QTRY_COMPARE(viewer->view()->size(), QSize(300, 200));
@@ -124,6 +139,8 @@ void tst_QDeclarativeViewer::orientation()
viewer->rotateOrientation();
qApp->processEvents();
+ QCOMPARE(runtimeObject->property("orientation").toInt(), int(DeviceOrientation::PortraitInverted));
+
QCOMPARE(rootItem->width(), 200.0);
QCOMPARE(rootItem->height(), 300.0);
QTRY_COMPARE(viewer->view()->size(), QSize(200, 300));
@@ -131,6 +148,19 @@ void tst_QDeclarativeViewer::orientation()
QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer)));
QCOMPARE(viewer->size(), viewer->sizeHint());
+ viewer->rotateOrientation();
+ qApp->processEvents();
+
+ QCOMPARE(runtimeObject->property("orientation").toInt(), int(DeviceOrientation::LandscapeInverted));
+
+ viewer->rotateOrientation();
+ qApp->processEvents();
+
+ QCOMPARE(runtimeObject->property("orientation").toInt(), int(DeviceOrientation::Portrait));
+
+ viewer->hide();
+ QVERIFY(!runtimeObject->property("isActiveWindow").toBool());
+
delete viewer;
}