summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaj Grönholm <kaj.gronholm@qt.io>2019-04-11 16:07:25 +0300
committerKaj Grönholm <kaj.gronholm@qt.io>2019-04-15 05:38:37 +0000
commit46000b6fb0fca6594827875695c564cf5d7d070c (patch)
tree1b12c5fbecf2e90a6167f79a1c60a22adc714576
parent87be74ca13eac287f887ce71c7d15af3b6b4bfd7 (diff)
Fix and extend viewer autotests
Fix viewer autotest to use opengl runtime import and extend tests to cover more Studio3D, Presentation and ViewerSettings API. Task-number: QT3DS-3213 Change-Id: I65ca87b6fdb90b9d90411011e5a1f665c1151e04 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r--tests/auto/viewer/tst_qt3dsviewer.cpp88
-rw-r--r--tests/auto/viewer/tst_qt3dsviewer.h18
-rw-r--r--tests/auto/viewer/tst_qt3dsviewer.qml4
-rw-r--r--tests/auto/viewer/viewer.pro2
4 files changed, 95 insertions, 17 deletions
diff --git a/tests/auto/viewer/tst_qt3dsviewer.cpp b/tests/auto/viewer/tst_qt3dsviewer.cpp
index f1d09407..c6692c3d 100644
--- a/tests/auto/viewer/tst_qt3dsviewer.cpp
+++ b/tests/auto/viewer/tst_qt3dsviewer.cpp
@@ -28,7 +28,6 @@
****************************************************************************/
#include "tst_qt3dsviewer.h"
-#include <QtQuick/QQuickView>
#include <QtQuick/QQuickItem>
#include <QtGui/QSurfaceFormat>
@@ -50,6 +49,12 @@ void messageOutput(QtMsgType type, const QMessageLogContext &context,
void tst_qt3dsviewer::initTestCase()
{
qInstallMessageHandler(messageOutput);
+ m_viewer.setTitle(QStringLiteral("tst_qt3dsviewer"));
+}
+
+void tst_qt3dsviewer::cleanupTestCase()
+{
+ QCOMPARE(m_studio3DItem->property("error").toString(), QString());
}
void tst_qt3dsviewer::init()
@@ -67,26 +72,81 @@ void tst_qt3dsviewer::init()
format.setProfile(QSurfaceFormat::CoreProfile);
QSurfaceFormat::setDefaultFormat(format);
#endif
+
+ m_viewer.setSource(QUrl("qrc:/tst_qt3dsviewer.qml"));
+ m_studio3DItem = m_viewer.rootObject();
+ QVERIFY(m_studio3DItem);
+ m_presentation = static_cast<Q3DSPresentation *>(m_studio3DItem->children().at(0));
+ QVERIFY(m_presentation);
+ m_settings = static_cast<Q3DSViewerSettings *>(m_studio3DItem->children().at(1));
+ QVERIFY(m_settings);
+}
+
+void tst_qt3dsviewer::cleanup()
+{
+ m_viewer.hide();
}
-void tst_qt3dsviewer::testQml()
+void tst_qt3dsviewer::testEmpty()
+{
+ m_presentation->setProperty("source", QUrl());
+ m_viewer.show();
+ QTest::qWait(1000);
+ QCOMPARE(m_studio3DItem->property("running").toBool(), false);
+}
+
+void tst_qt3dsviewer::testLoading()
+{
+ QCOMPARE(m_studio3DItem->property("running").toBool(), false);
+ m_viewer.show();
+ QTest::qWait(1000);
+ QCOMPARE(m_studio3DItem->property("running").toBool(), true);
+}
+
+
+void tst_qt3dsviewer::testSlides()
{
- QQuickView viewer;
- viewer.setSource(QUrl("qrc:/tst_qt3dsviewer.qml"));
- viewer.setTitle(QStringLiteral("tst_qt3dsviewer"));
- viewer.show();
-
- QObject *item = viewer.rootObject();
- QObject *presentation = viewer.rootObject()->children().at(0);
- QSignalSpy spyFrames(item, SIGNAL(frameUpdate()));
- QSignalSpy spyEntered(presentation,
+ QSignalSpy spyEntered(m_presentation,
SIGNAL(slideEntered(const QString &, unsigned int, const QString &)));
- QSignalSpy spyExited(presentation,
+ QSignalSpy spyExited(m_presentation,
SIGNAL(slideExited(const QString &, unsigned int, const QString &)));
- QVERIFY(spyExited.wait(11000));
- QVERIFY(spyFrames.count() > 590); // Should be 60 with fudge for startup
+ QCOMPARE(spyEntered.count(), 0);
+ QCOMPARE(spyExited.count(), 0);
+
+ m_viewer.show();
+ QTest::qWait(1000);
+
+ QCOMPARE(spyEntered.count(), 1);
+ QCOMPARE(spyExited.count(), 0);
+
+ QVERIFY(spyExited.wait(12000));
QCOMPARE(spyEntered.count(), 2);
QCOMPARE(spyExited.count(), 1);
}
+void tst_qt3dsviewer::testFrameUpdates()
+{
+ QSignalSpy spyFrames(m_studio3DItem, SIGNAL(frameUpdate()));
+ QSignalSpy spyExited(m_presentation,
+ SIGNAL(slideExited(const QString &, unsigned int, const QString &)));
+ m_viewer.show();
+ QVERIFY(spyExited.wait(12000));
+ QVERIFY(spyFrames.count() > 590); // Should be 60 with fudge for startup
+}
+
+void tst_qt3dsviewer::testSettings()
+{
+ m_viewer.show();
+ m_settings->setMatteColor(QColor("#0000ff"));
+ QVERIFY(m_settings->matteColor() == QColor("#0000ff"));
+
+ // Save and change matte color
+ m_settings->save("", "tst_qt3dsviewer", "tst_qt3dsviewer");
+ m_settings->setMatteColor(QColor("#00ff00"));
+ QVERIFY(m_settings->matteColor() == QColor("#00ff00"));
+ // Load and previous matte color should be back
+ m_settings->load("", "tst_qt3dsviewer", "tst_qt3dsviewer");
+ QVERIFY(m_settings->matteColor() == QColor("#0000ff"));
+}
+
QTEST_MAIN(tst_qt3dsviewer)
diff --git a/tests/auto/viewer/tst_qt3dsviewer.h b/tests/auto/viewer/tst_qt3dsviewer.h
index d1b4b863..1fe60bb5 100644
--- a/tests/auto/viewer/tst_qt3dsviewer.h
+++ b/tests/auto/viewer/tst_qt3dsviewer.h
@@ -32,6 +32,9 @@
#include <QtTest/QtTest>
#include <QtTest/QSignalSpy>
+#include <QtQuick/QQuickView>
+#include <QtStudio3D/q3dspresentation.h>
+#include <QtStudio3D/q3dsviewersettings.h>
class tst_qt3dsviewer : public QObject
{
@@ -43,9 +46,22 @@ public:
private Q_SLOTS:
void initTestCase();
+ void cleanupTestCase();
void init();
+ void cleanup();
+
+ void testEmpty();
+ void testLoading();
+ void testSlides();
+ void testFrameUpdates();
+ void testSettings();
+
+private:
+ QQuickView m_viewer;
+ QObject *m_studio3DItem = nullptr;
+ Q3DSPresentation *m_presentation = nullptr;
+ Q3DSViewerSettings *m_settings = nullptr;
- void testQml();
};
#endif // TST_QT3DSVIEWER
diff --git a/tests/auto/viewer/tst_qt3dsviewer.qml b/tests/auto/viewer/tst_qt3dsviewer.qml
index 804cc370..794928f6 100644
--- a/tests/auto/viewer/tst_qt3dsviewer.qml
+++ b/tests/auto/viewer/tst_qt3dsviewer.qml
@@ -48,7 +48,7 @@
**
****************************************************************************/
-import QtStudio3D 1.0
+import QtStudio3D.OpenGL 2.4
Studio3D {
id: studio3D
@@ -57,4 +57,6 @@ Studio3D {
Presentation {
source: "qrc:/simple_cube_animation/simple_cube_animation.uia"
}
+ ViewerSettings {
+ }
}
diff --git a/tests/auto/viewer/viewer.pro b/tests/auto/viewer/viewer.pro
index cc377eef..ad832e02 100644
--- a/tests/auto/viewer/viewer.pro
+++ b/tests/auto/viewer/viewer.pro
@@ -3,7 +3,7 @@ CONFIG += testcase
include($$PWD/../../../src/Runtime/commoninclude.pri)
TARGET = tst_qt3dsviewer
-QT += testlib gui quick
+QT += testlib gui quick studio3d
RESOURCES += viewer.qrc
HEADERS += \