summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2012-01-13 10:31:11 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-24 15:38:48 +0100
commitb39df8bf92a530783144dbcf5cae939742ff2d23 (patch)
tree0560985d33f59a48693acadbdfbb59b328131499 /tests
parentb0a0403daf81e82ea732aa91ec92cf94553a7935 (diff)
Made window orientation API more flexible.
Previously we only had QWindow::setOrientation() which was a hint about the orientation the window's contents were rendered in. However, it's necessary to separate between the orientation corresponding to the window buffer layout and orientation of the contents. A game for example might typically want to use a landscape buffer even on a portrait device. Thus, we replace QWindow::orientation() with QWindow::reportContentOrientationChange() and QWindow::requestWindowOrientation(). Change-Id: I1f07362192daf36c45519cb05b43ac352f1945b5 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/kernel/qscreen/tst_qscreen.cpp21
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp18
2 files changed, 34 insertions, 5 deletions
diff --git a/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp b/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp
index d4d6ff1401..5f2be63263 100644
--- a/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp
+++ b/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp
@@ -90,6 +90,11 @@ void tst_QScreen::angleBetween_data()
<< uint(Qt::InvertedLandscapeOrientation)
<< uint(Qt::LandscapeOrientation)
<< 180;
+
+ QTest::newRow("Landscape Primary")
+ << uint(Qt::LandscapeOrientation)
+ << uint(Qt::PrimaryOrientation)
+ << QGuiApplication::primaryScreen()->angleBetween(Qt::LandscapeOrientation, QGuiApplication::primaryScreen()->primaryOrientation());
}
void tst_QScreen::angleBetween()
@@ -101,8 +106,8 @@ void tst_QScreen::angleBetween()
Qt::ScreenOrientation a = Qt::ScreenOrientation(oa);
Qt::ScreenOrientation b = Qt::ScreenOrientation(ob);
- QCOMPARE(QScreen::angleBetween(a, b), expected);
- QCOMPARE(QScreen::angleBetween(b, a), (360 - expected) % 360);
+ QCOMPARE(QGuiApplication::primaryScreen()->angleBetween(a, b), expected);
+ QCOMPARE(QGuiApplication::primaryScreen()->angleBetween(b, a), (360 - expected) % 360);
}
void tst_QScreen::transformBetween_data()
@@ -149,6 +154,12 @@ void tst_QScreen::transformBetween_data()
<< uint(Qt::LandscapeOrientation)
<< rect
<< QTransform(-1, 0, 0, -1, rect.width(), rect.height());
+
+ QTest::newRow("Landscape Primary")
+ << uint(Qt::LandscapeOrientation)
+ << uint(Qt::PrimaryOrientation)
+ << rect
+ << QGuiApplication::primaryScreen()->transformBetween(Qt::LandscapeOrientation, QGuiApplication::primaryScreen()->primaryOrientation(), rect);
}
void tst_QScreen::transformBetween()
@@ -161,7 +172,7 @@ void tst_QScreen::transformBetween()
Qt::ScreenOrientation a = Qt::ScreenOrientation(oa);
Qt::ScreenOrientation b = Qt::ScreenOrientation(ob);
- QCOMPARE(QScreen::transformBetween(a, b, rect), expected);
+ QCOMPARE(QGuiApplication::primaryScreen()->transformBetween(a, b, rect), expected);
}
void tst_QScreen::orientationChange()
@@ -169,10 +180,10 @@ void tst_QScreen::orientationChange()
QScreen *screen = QGuiApplication::primaryScreen();
QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::LandscapeOrientation);
- QTRY_COMPARE(screen->currentOrientation(), Qt::LandscapeOrientation);
+ QTRY_COMPARE(screen->orientation(), Qt::LandscapeOrientation);
QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::PortraitOrientation);
- QTRY_COMPARE(screen->currentOrientation(), Qt::PortraitOrientation);
+ QTRY_COMPARE(screen->orientation(), Qt::PortraitOrientation);
}
#include <tst_qscreen.moc>
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index ac8c8f9b20..d0d2ce1e1d 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -57,6 +57,7 @@ private slots:
void touchToMouseTranslation();
void mouseToTouchTranslation();
void mouseToTouchLoop();
+ void orientation();
void initTestCase()
{
touchDevice = new QTouchDevice;
@@ -481,5 +482,22 @@ void tst_QWindow::mouseToTouchLoop()
qApp->setAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents, false);
}
+void tst_QWindow::orientation()
+{
+ QWindow window;
+ window.setGeometry(80, 80, 40, 40);
+ window.create();
+
+ window.reportContentOrientationChange(Qt::PortraitOrientation);
+ QCOMPARE(window.contentOrientation(), Qt::PortraitOrientation);
+
+ window.reportContentOrientationChange(Qt::PrimaryOrientation);
+ QCOMPARE(window.contentOrientation(), window.screen()->primaryOrientation());
+
+ QVERIFY(!window.requestWindowOrientation(Qt::LandscapeOrientation) || window.windowOrientation() == Qt::LandscapeOrientation);
+ QVERIFY(!window.requestWindowOrientation(Qt::PortraitOrientation) || window.windowOrientation() == Qt::PortraitOrientation);
+ QVERIFY(!window.requestWindowOrientation(Qt::PrimaryOrientation) || window.windowOrientation() == window.screen()->primaryOrientation());
+}
+
#include <tst_qwindow.moc>
QTEST_MAIN(tst_QWindow);