diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2012-01-13 10:31:11 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-24 15:38:48 +0100 |
commit | b39df8bf92a530783144dbcf5cae939742ff2d23 (patch) | |
tree | 0560985d33f59a48693acadbdfbb59b328131499 /tests/auto/gui/kernel/qscreen | |
parent | b0a0403daf81e82ea732aa91ec92cf94553a7935 (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/auto/gui/kernel/qscreen')
-rw-r--r-- | tests/auto/gui/kernel/qscreen/tst_qscreen.cpp | 21 |
1 files changed, 16 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> |