| 1 |
/* |
| 2 |
* Copyright 2013 Canonical Ltd. |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU Lesser General Public License as published by |
| 6 |
* the Free Software Foundation; version 3. |
| 7 |
* |
| 8 |
* This program is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
* GNU Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public License |
| 14 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
* |
| 16 |
* Author: Christian Dywan <[email protected]> |
| 17 |
*/ |
| 18 |
|
| 19 |
#include <QtCore/QCoreApplication> |
| 20 |
#include <QtGui/QMatrix4x4> |
| 21 |
#include <QtGui/QQuaternion> |
| 22 |
#include <QtGui/QVector3D> |
| 23 |
#include <QtGui/QVector4D> |
| 24 |
#include <QtQml/QQmlEngine> |
| 25 |
#include <QtQml/QQmlProperty> |
| 26 |
#include <QtQuick/QQuickItem> |
| 27 |
#include <QtQuick/QQuickView> |
| 28 |
#include <QtTest/QtTest> |
| 29 |
#include <QtTest/QSignalSpy> |
| 30 |
|
| 31 |
#include "uctestcase.h" |
| 32 |
|
| 33 |
class tst_OrientationTest : public QObject |
| 34 |
{ |
| 35 |
Q_OBJECT |
| 36 |
public: |
| 37 |
tst_OrientationTest() {} |
| 38 |
|
| 39 |
private Q_SLOTS: |
| 40 |
|
| 41 |
void test_defaults() |
| 42 |
{ |
| 43 |
QScopedPointer<LomiriTestCase> testCase(new LomiriTestCase("Defaults.qml")); |
| 44 |
QQuickItem *helper = testCase->findItem<QQuickItem*>("helper"); |
| 45 |
QCOMPARE(helper->property("automaticOrientation").toBool(), true); |
| 46 |
// No warnings expected |
| 47 |
QCOMPARE(testCase->warnings(), 0); |
| 48 |
} |
| 49 |
|
| 50 |
void test_manualAngle() |
| 51 |
{ |
| 52 |
QScopedPointer<LomiriTestCase> testCase(new LomiriTestCase("ManualAngle.qml")); |
| 53 |
QQuickItem *helper = testCase->findItem<QQuickItem*>("helper"); |
| 54 |
// No warning about "window" being undefined must appear |
| 55 |
QSKIP("FIXME: We have no valid effectiveness tests for OrientationHelper. See bug #1626063."); |
| 56 |
QCOMPARE(testCase->warnings(), 0); |
| 57 |
QCOMPARE(helper->property("orientationAngle").toInt(), 90); |
| 58 |
// Verify expected values |
| 59 |
QQuickItem *checkpoint = testCase->findItem<QQuickItem*>("checkpoint"); |
| 60 |
// window.contentOrientation |
| 61 |
QCOMPARE(checkpoint->property("contentOrientation").toInt(), helper->property("orientationAngle").toInt()); |
| 62 |
} |
| 63 |
}; |
| 64 |
|
| 65 |
QTEST_MAIN(tst_OrientationTest) |
| 66 |
|
| 67 |
#include "tst_orientation.moc" |
| 68 |
|
| 69 |
|
| 70 |
|