summaryrefslogtreecommitdiffstats
path: root/tests/auto/studio3d/q3dssurfaceviewer/tst_q3dssurfaceviewer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/studio3d/q3dssurfaceviewer/tst_q3dssurfaceviewer.cpp')
-rw-r--r--tests/auto/studio3d/q3dssurfaceviewer/tst_q3dssurfaceviewer.cpp128
1 files changed, 126 insertions, 2 deletions
diff --git a/tests/auto/studio3d/q3dssurfaceviewer/tst_q3dssurfaceviewer.cpp b/tests/auto/studio3d/q3dssurfaceviewer/tst_q3dssurfaceviewer.cpp
index ccda520..4f9588c 100644
--- a/tests/auto/studio3d/q3dssurfaceviewer/tst_q3dssurfaceviewer.cpp
+++ b/tests/auto/studio3d/q3dssurfaceviewer/tst_q3dssurfaceviewer.cpp
@@ -61,6 +61,8 @@ private slots:
void testBasics();
void testSourceChange_data();
void testSourceChange();
+ void testActivateActions_data();
+ void testActivateActions();
void testSizeChange_data();
void testSizeChange();
void testUpdateInterval_data();
@@ -85,6 +87,8 @@ private slots:
void testMouseInput();
void testDataInput_data();
void testDataInput();
+ void testTextureQuery();
+ void testTextureQuery_data();
private:
QWindow *createWindow(const QSize &size);
@@ -366,6 +370,43 @@ void tst_Q3DSSurfaceViewer::testSourceChange()
checkPixel(m_viewer, Qt::red);
}
+void tst_Q3DSSurfaceViewer::testActivateActions_data()
+{
+ testBasics_data();
+}
+
+void tst_Q3DSSurfaceViewer::testActivateActions()
+{
+ QFETCH(bool, isWindow);
+
+ if (isWindow)
+ createWindowAndViewer(m_viewer, ACTIVATEACTIONS);
+ else
+ createOffscreenAndViewer(m_viewer, ACTIVATEACTIONS);
+
+ QSignalSpy spy(m_viewer->presentation(), &Q3DSPresentation::customSignalEmitted);
+
+ QVERIFY(spy.isValid());
+
+ // Wait a bit to prevent grabbing the first image too soon
+ QTest::qWait(100);
+
+ // This presentations sends custom signals at 1000ms and at 3000ms.
+ // At same times it also changes scene color using activate actions.
+ QCOMPARE(spy.count(), 0);
+ QImage image1 = m_viewer->grab();
+
+ QTest::qWait(2000);
+ QCOMPARE(spy.count(), 1);
+ QImage image2 = m_viewer->grab();
+ QVERIFY(image1 != image2);
+
+ QTest::qWait(2000);
+ QCOMPARE(spy.count(), 2);
+ QImage image3 = m_viewer->grab();
+ QVERIFY(image1 == image3);
+}
+
void tst_Q3DSSurfaceViewer::testSizeChange_data()
{
testBasics_data();
@@ -1249,7 +1290,7 @@ void tst_Q3DSSurfaceViewer::testSceneElement()
QCOMPARE(spy1.count(), 6);
QCOMPARE(spy2.count(), 6);
- scene->setCurrentSlideIndex(0);
+ scene->setCurrentSlideIndex(1);
checkPixel(m_viewer, Qt::red);
QCOMPARE(spy1.count(), 7);
@@ -1305,7 +1346,7 @@ void tst_Q3DSSurfaceViewer::testSceneElement()
QCOMPARE(spy2.count(), 11);
// Back to first slide for further tests
- scene->setCurrentSlideIndex(0);
+ scene->setCurrentSlideIndex(1);
checkPixel(m_viewer, Qt::red);
QCOMPARE(spy1.count(), 12);
@@ -1507,6 +1548,89 @@ void tst_Q3DSSurfaceViewer::testDataInput()
delete slideInput;
}
+void tst_Q3DSSurfaceViewer::testTextureQuery_data()
+{
+ testBasics_data();
+}
+
+void tst_Q3DSSurfaceViewer::testTextureQuery()
+{
+ QFETCH(bool, isWindow);
+
+ if (isWindow)
+ createWindowAndViewer(m_viewer, DATAINPUT);
+ else
+ createOffscreenAndViewer(m_viewer, DATAINPUT);
+
+ m_viewer->settings()->setScaleMode(Q3DSViewerSettings::ScaleModeFill);
+
+ QGuiApplication::processEvents();
+ // Test texture info getters, first for layer then for individual material.
+ // Texture id's are likely to change if test ordering changes.
+ QSize texsize;
+ GLenum format;
+
+ uint textureid = m_viewer->presentation()->textureId("Scene.Layer", texsize, format);
+ if (isWindow)
+ QCOMPARE(textureid, 6);
+ else
+ QCOMPARE(textureid, 7);
+
+ QCOMPARE(texsize, QSize(300,200));
+ QCOMPARE(format, GL_RGBA8);
+
+ textureid = m_viewer->presentation()->textureId("Scene.Layer.Rectangle.Default.diffusemap",
+ texsize, format);
+ if (isWindow)
+ QCOMPARE(textureid, 1);
+ else
+ QCOMPARE(textureid, 2);
+ QCOMPARE(texsize, QSize(400,200));
+ QCOMPARE(format, GL_RGBA8);
+
+ m_viewer->presentation()->setAttribute("Scene.Layer.Rectangle.Default.diffusemap",
+ "subpresentation", "");
+ m_viewer->presentation()->setAttribute("Scene.Layer.Rectangle.Default.diffusemap", "sourcepath",
+ "maps/OpenfootageNET_garage-512.hdr");
+
+ QGuiApplication::processEvents();
+
+ // Changed to HDR texture, studio-internally RGB8E but texture query should map to GL RGBA8
+ textureid = m_viewer->presentation()->textureId("Scene.Layer.Rectangle.Default.diffusemap",
+ texsize, format);
+ if (isWindow)
+ QCOMPARE(textureid, 8);
+ else
+ QCOMPARE(textureid, 9);
+
+ QCOMPARE(texsize, QSize(512,256));
+ QCOMPARE(format, GL_RGBA8);
+
+ // Reset textureid and format
+ textureid = m_viewer->presentation()->textureId("Scene.Layer", texsize, format);
+ if (isWindow)
+ QCOMPARE(textureid, 6);
+ else
+ QCOMPARE(textureid, 7);
+
+ // Test setting sourcepath without the file extension.
+ // Loading should succeed finding the .hdr file.
+ m_viewer->presentation()->setAttribute("Scene.Layer.Rectangle.Default.diffusemap", "sourcepath",
+ "maps/OpenfootageNET_garage-512");
+
+ QGuiApplication::processEvents();
+
+ // Changed to HDR texture, studio-internally RGB8E but texture query should map to GL RGBA8
+ textureid = m_viewer->presentation()->textureId("Scene.Layer.Rectangle.Default.diffusemap",
+ texsize, format);
+ if (isWindow)
+ QCOMPARE(textureid, 8);
+ else
+ QCOMPARE(textureid, 9);
+
+ QCOMPARE(texsize, QSize(512,256));
+ QCOMPARE(format, GL_RGBA8);
+}
QTEST_MAIN(tst_Q3DSSurfaceViewer)