diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2018-01-26 13:16:18 +0200 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2018-01-26 13:28:52 +0000 |
commit | 295cddb287121e58f35a4c119cfba090d0adfb05 (patch) | |
tree | 5da7356b985be66e7855abadc33334b78abe0718 /tests | |
parent | ebdce14531d9ee42accd326172d494ee8cd7ed13 (diff) |
Implement autotest for data input
Task-number: QT3DS-854
Change-Id: I7f2d4b8df555da2667eba6e6930ff026a5d009e6
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Antti Määttä <antti.maatta@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'tests')
6 files changed, 138 insertions, 19 deletions
diff --git a/tests/auto/studio3d/q3dssurfaceviewer/tst_q3dssurfaceviewer.cpp b/tests/auto/studio3d/q3dssurfaceviewer/tst_q3dssurfaceviewer.cpp index 40cbe210..b35169ad 100644 --- a/tests/auto/studio3d/q3dssurfaceviewer/tst_q3dssurfaceviewer.cpp +++ b/tests/auto/studio3d/q3dssurfaceviewer/tst_q3dssurfaceviewer.cpp @@ -32,6 +32,7 @@ #include <QtStudio3D/q3dspresentation.h> #include <QtStudio3D/q3dssceneelement.h> #include <QtStudio3D/q3dselement.h> +#include <QtStudio3D/q3dsdatainput.h> #include <QtGui/qwindow.h> #include <QtGui/qopenglcontext.h> #include <QtGui/qoffscreensurface.h> @@ -1481,16 +1482,51 @@ void tst_Q3DSSurfaceViewer::testDataInput_data() void tst_Q3DSSurfaceViewer::testDataInput() { -// QFETCH(bool, isWindow); + QFETCH(bool, isWindow); + + if (isWindow) + createWindowAndViewer(m_viewer, DATAINPUT); + else + createOffscreenAndViewer(m_viewer, DATAINPUT); -// if (isWindow) -// createWindowAndViewer(m_viewer, DATAINPUT); -// else -// createOffscreenAndViewer(m_viewer, DATAINPUT); + m_viewer->settings()->setScaleMode(Q3DSViewerSettings::ScaleModeFill); + + QPoint point1(m_viewer->size().width() / 4, m_viewer->size().height() / 4); - // TODO: This is a placeholder for data input test. To be finished when proper support - // for changing animation time via data inputs is supported and the display bugs fixed. - // See: https://bugreports.qt.io/browse/QT3DS-854 + const QString animationName = QStringLiteral("animationInput"); + const QString slideName = QStringLiteral("slideInput"); + + checkPixel(m_viewer, Qt::red, point1); + m_viewer->presentation()->setDataInputValue(animationName, 90); + checkPixel(m_viewer, Qt::blue, point1); + m_viewer->presentation()->setDataInputValue(animationName, 10); + checkPixel(m_viewer, Qt::red, point1); + + Q3DSDataInput *animationInput = new Q3DSDataInput(); + animationInput->setName(animationName); + + m_viewer->presentation()->registerDataInput(animationInput); + QVERIFY(m_viewer->presentation()->registeredDataInput(animationInput->name())); + + Q3DSDataInput *slideInput = new Q3DSDataInput(m_viewer->presentation(), slideName); + QVERIFY(m_viewer->presentation()->registeredDataInput(slideInput->name())); + + animationInput->setValue(90); + checkPixel(m_viewer, Qt::blue, point1); + animationInput->setValue(10); + checkPixel(m_viewer, Qt::red, point1); + + slideInput->setValue(QStringLiteral("Slide2")); + checkPixel(m_viewer, Qt::green, point1); + slideInput->setValue(QStringLiteral("Slide1")); + checkPixel(m_viewer, Qt::red, point1); + + m_viewer->presentation()->unregisterDataInput(animationInput); + m_viewer->presentation()->unregisterDataInput(slideInput); + QVERIFY(!m_viewer->presentation()->registeredDataInput(animationInput->name())); + QVERIFY(!m_viewer->presentation()->registeredDataInput(slideInput->name())); + delete animationInput; + delete slideInput; } diff --git a/tests/auto/studio3d/shared/presentation/datainput.uia b/tests/auto/studio3d/shared/presentation/datainput.uia new file mode 100644 index 00000000..fbfa55b6 --- /dev/null +++ b/tests/auto/studio3d/shared/presentation/datainput.uia @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<application> + <assets initial="datainput"> + <dataInput name="animationInput" type="Ranged Number" min="0" max="100"/> + <dataInput name="slideInput" type="String" /> + <presentation id="datainput" src="datainput.uip"/> + <presentation id="subpres" src="datainput_sub.uip"/> + </assets> + <statemachine ref="#logic"> + <visual-states> + <state ref="Initial"> + <enter> + <goto-slide element="main:Scene" rel="next"/> + </enter> + </state> + </visual-states> + </statemachine> +</application> diff --git a/tests/auto/studio3d/shared/presentation/datainput.uip b/tests/auto/studio3d/shared/presentation/datainput.uip index e2464527..09110f23 100644 --- a/tests/auto/studio3d/shared/presentation/datainput.uip +++ b/tests/auto/studio3d/shared/presentation/datainput.uip @@ -1,29 +1,61 @@ <?xml version="1.0" encoding="UTF-8" ?> <UIP version="3" > <Project > - <ProjectSettings author="" company="" presentationWidth="800" presentationHeight="480" maintainAspect="False" > + <ProjectSettings author="" company="" presentationWidth="800" presentationHeight="600" maintainAspect="False" > <CustomColors count="16" >#ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff</CustomColors> </ProjectSettings> <Graph > - <Scene id="Scene" > + <Scene id="Scene" backgroundcolor="0 1 0" controlledproperty="animationInput @timeline slideInput @slide" > <Layer id="Layer" > <Camera id="Camera" /> <Light id="Light" /> - <Text id="Text" /> - <Text id="Text2" /> + <Component id="Component" > + <Text id="Text" /> + </Component> + <Model id="Rectangle" > + <Material id="Default" name="Default" > + <Image id="Default_diffusemap" /> + </Material> + </Model> + <Text id="Text_001" /> + <Model id="Rectangle2" > + <Material id="Default_001" name="Default" /> + </Model> </Layer> - <DataInput id="MyDataInput" name="MyDataInput" controlledelemprop="Scene.Layer.Text textstring " /> </Scene> </Graph> <Logic > <State name="Master Slide" component="#Scene" > - <Add ref="#Layer" /> + <Add ref="#Layer" background="Transparent" sourcepath="" /> <Add ref="#Camera" /> <Add ref="#Light" /> - <State id="Scene-Slide1" name="Slide1" playmode="Looping" > - <Add ref="#Text" name="Text" font="TitilliumWeb-Regular" position="-0.000391006 46.1884 0" scale="1.0 1.0 1.0" size="48" textstring="Datainput value goes here" /> - <Add ref="#Text2" name="Text2" font="TitilliumWeb-Regular" position="2.88678 207.846 0" scale="1 1 1" size="48" textstring="Text via DataInput:" /> - <Add ref="#MyDataInput" name="MyDataInput" /> + <Add ref="#Rectangle" name="Rectangle" sourcepath="#Rectangle" > + <AnimationTrack property="position.x" type="EaseInOut" >0 -327.165 100 100 10 351.542 100 100</AnimationTrack> + <AnimationTrack property="position.y" type="EaseInOut" >0 -6.41502 100 100 10 -17.962 100 100</AnimationTrack> + <AnimationTrack property="position.z" type="EaseInOut" >0 0 100 100 10 0 100 100</AnimationTrack> + </Add> + <Add ref="#Default" diffusemap="#Default_diffusemap" /> + <Add ref="#Default_diffusemap" sourcepath="maps/QT-symbol.png" subpresentation="subpres" /> + <State id="Scene-Slide1" name="Slide1" initialplaystate="Pause" > + <Add ref="#Component" name="Component" controlledproperty="animationInput @timeline" /> + <Add ref="#Rectangle2" name="Rectangle2" position="0 0 100" scale="9999 9999 99999" sourcepath="#Rectangle" /> + <Add ref="#Default_001" > + <AnimationTrack property="diffuse.x" type="EaseInOut" >0 1 100 100 4.487 1 100 100 5.5 0 100 100 10 0 100 100</AnimationTrack> + <AnimationTrack property="diffuse.y" type="EaseInOut" >0 0 100 100 4.487 0 100 100 5.5 0 100 100 10 0 100 100</AnimationTrack> + <AnimationTrack property="diffuse.z" type="EaseInOut" >0 0 100 100 4.487 0 100 100 5.5 1 100 100 10 1 100 100</AnimationTrack> + </Add> + </State> + <State id="Scene-Slide2" name="Slide2" initialplaystate="Play" playmode="Stop at end" playthroughto="Previous" > + <Add ref="#Text_001" name="Text" font="TitilliumWeb-Regular" position="-442.635 -193.733 0" textstring="Second slide" /> + </State> + </State> + <State name="Master Slide" component="#Component" > + <State id="Component-Slide1" name="Slide1" initialplaystate="Pause" > + <Add ref="#Text" name="Text" controlledproperty="animationInput textstring" font="TitilliumWeb-Regular" position="-5.132 137.281 0" > + <AnimationTrack property="rotation.x" type="EaseInOut" >0 0 100 100 10 0 100 100</AnimationTrack> + <AnimationTrack property="rotation.y" type="EaseInOut" >0 0 100 100 10 0 100 100</AnimationTrack> + <AnimationTrack property="rotation.z" type="EaseInOut" >0 0 100 100 10 -360 100 100</AnimationTrack> + </Add> </State> </State> </Logic> diff --git a/tests/auto/studio3d/shared/presentation/datainput_sub.uip b/tests/auto/studio3d/shared/presentation/datainput_sub.uip new file mode 100644 index 00000000..8909cbd3 --- /dev/null +++ b/tests/auto/studio3d/shared/presentation/datainput_sub.uip @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<UIP version="3" > + <Project > + <ProjectSettings author="" company="" presentationWidth="400" presentationHeight="200" maintainAspect="False" > + <CustomColors count="16" >#ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff</CustomColors> + </ProjectSettings> + <Graph > + <Scene id="Scene" controlledproperty="animationInput @timeline" > + <Layer id="Layer" > + <Camera id="Camera" /> + <Light id="Light" /> + <Text id="Text" controlledproperty="slideInput textstring" /> + </Layer> + </Scene> + </Graph> + <Logic > + <State name="Master Slide" component="#Scene" > + <Add ref="#Layer" /> + <Add ref="#Camera" /> + <Add ref="#Light" /> + <State id="Scene-Slide1" name="Slide1" initialplaystate="Pause" > + <Add ref="#Text" name="Text" font="TitilliumWeb-Regular" opacity="99" size="96" > + <AnimationTrack property="rotation.x" type="EaseInOut" >0 0 100 100 10 0 100 100</AnimationTrack> + <AnimationTrack property="rotation.y" type="EaseInOut" >0 0 100 100 10 0 100 100</AnimationTrack> + <AnimationTrack property="rotation.z" type="EaseInOut" >0 0 100 100 10 -360 100 100</AnimationTrack> + </Add> + </State> + </State> + </Logic> + </Project> +</UIP> diff --git a/tests/auto/studio3d/shared/shared_presentations.h b/tests/auto/studio3d/shared/shared_presentations.h index b1d23e0e..6d382738 100644 --- a/tests/auto/studio3d/shared/shared_presentations.h +++ b/tests/auto/studio3d/shared/shared_presentations.h @@ -36,4 +36,4 @@ const QUrl ANIMATION = QUrl(QStringLiteral("qrc:/animation.uip")); const QUrl SETTINGS = QUrl(QStringLiteral("qrc:/settings.uip")); const QUrl MULTISLIDE = QUrl(QStringLiteral("qrc:/multislide.uip")); const QUrl MOUSE = QUrl(QStringLiteral("qrc:/mouse.uip")); -const QUrl DATAINPUT = QUrl(QStringLiteral("qrc:/datinput.uip")); +const QUrl DATAINPUT = QUrl(QStringLiteral("qrc:/datainput.uia")); diff --git a/tests/auto/studio3d/shared/shared_presentations.qrc b/tests/auto/studio3d/shared/shared_presentations.qrc index 00877c26..d4bb668f 100644 --- a/tests/auto/studio3d/shared/shared_presentations.qrc +++ b/tests/auto/studio3d/shared/shared_presentations.qrc @@ -9,5 +9,7 @@ <file alias="multislide.uip">presentation/multislide.uip</file> <file alias="mouse.uip">presentation/mouse.uip</file> <file alias="datainput.uip">presentation/datainput.uip</file> + <file alias="datainput.uia">presentation/datainput.uia</file> + <file alias="datainput_sub.uip">presentation/datainput_sub.uip</file> </qresource> </RCC> |