diff options
author | Kaj Grönholm <kaj.gronholm@qt.io> | 2020-09-16 17:30:39 +0300 |
---|---|---|
committer | Kaj Grönholm <kaj.gronholm@qt.io> | 2020-09-21 07:47:10 +0300 |
commit | 7761f86cec898a0a38ed2e3adddc5ef0fdbdea89 (patch) | |
tree | fc08bf2827a5fa797e380408e60459e7d3fc2cd3 /tests | |
parent | 05eb20d0b7e46101dd79d3f5788681f5a2a9446e (diff) |
Add support for onActivate and onDeactivate Actions
Add new Action types onActivate and onDeactivate. When assigned, these
will get triggered at object timeline start and end times. Using these
it is possible to trigger events at specific times during animation.
Example and autotest case included.
Task-number: QT3DS-4128
Change-Id: Ib973b479a1de47745089d41c5764c2a1747ec95e
Reviewed-by: Antti Määttä <antti.maatta@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'tests')
4 files changed, 93 insertions, 0 deletions
diff --git a/tests/auto/studio3d/q3dssurfaceviewer/tst_q3dssurfaceviewer.cpp b/tests/auto/studio3d/q3dssurfaceviewer/tst_q3dssurfaceviewer.cpp index 7197b49..6133577 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(); @@ -368,6 +370,40 @@ 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()); + + // 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(); diff --git a/tests/auto/studio3d/shared/presentation/activateactions.uip b/tests/auto/studio3d/shared/presentation/activateactions.uip new file mode 100644 index 0000000..52ca81a --- /dev/null +++ b/tests/auto/studio3d/shared/presentation/activateactions.uip @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<UIP version="6" > + <Project > + <ProjectSettings author="" company="" presentationWidth="800" presentationHeight="480" maintainAspect="False" preferKtx="False" flipCompressedTextures="False" > + <CustomColors count="16" >#969696 #780000 #ff0055 #ffffff #0a0a0a #ffffff #a0a8b2 #ffffff #ff643a #ffffff #4694ff #ffffff #ff0800 #ffffff #280000 #ffffff</CustomColors> + </ProjectSettings> + <Graph > + <Scene id="Scene_u31923" backgroundcolor="1 0 0 1" bgcolorenable="False" > + <Layer id="Layer_u40191" variants="" > + <Camera id="Camera_u60961" /> + <Light id="Light_u46987" /> + <Model id="Cube_u48840" variants="" > + <ReferencedMaterial id="Default_u50569" name="Default" /> + </Model> + <Group id="Events1_u28102" variants="" /> + <Group id="Events2_u17296" variants="" /> + </Layer> + <Material id="__Container_u55481" > + <Material id="materials//Default_u19189" /> + </Material> + </Scene> + </Graph> + <Logic > + <State name="Master Slide" component="#Scene_u31923" > + <Add ref="#Layer_u40191" /> + <Add ref="#Camera_u60961" /> + <Add ref="#Light_u46987" /> + <Add ref="#__Container_u55481" name="__Container" /> + <Add ref="#materials//Default_u19189" name="materials//Default" /> + <State id="Scene-Slide1_u54514" name="Slide1" > + <Add ref="#Cube_u48840" name="Cube" rotation="20 360 20" sourcepath="#Cube" /> + <Add ref="#Default_u50569" name="Default" referencedmaterial="#materials//Default_u19189" sourcepath="/Default" /> + <Add ref="#Events1_u28102" name="Events1" endtime="3000" starttime="1000" > + <Action id="Events1-Action_u22921" eyeball="True" triggerObject="#Events1_u28102" event="onActivate" targetObject="#Scene_u31923" handler="Set Property" > + <HandlerArgument name="Property Name" type="String" argtype="Property" value="bgcolorenable" /> + <HandlerArgument name="Property Value" type="Bool" argtype="Dependent" value="True" /> + </Action> + <Action id="Events1-Action_u62890" eyeball="True" triggerObject="#Events1_u28102" event="onDeactivate" targetObject="#Scene_u31923" handler="Set Property" > + <HandlerArgument name="Property Name" type="String" argtype="Property" value="bgcolorenable" /> + <HandlerArgument name="Property Value" type="Bool" argtype="Dependent" /> + </Action> + </Add> + <Add ref="#Events2_u17296" name="Events2" endtime="3000" starttime="1000" > + <Action id="Events2-Action_u55956" eyeball="True" triggerObject="#Events2_u17296" event="onActivate" targetObject="#Events2_u17296" handler="Emit Signal" > + <HandlerArgument name="Signal Name" type="String" argtype="Signal" value="mySignal1" /> + </Action> + <Action id="Events2-Action_u17879" eyeball="True" triggerObject="#Events2_u17296" event="onDeactivate" targetObject="#Events2_u17296" handler="Emit Signal" > + <HandlerArgument name="Signal Name" type="String" argtype="Signal" value="mySignal2" /> + </Action> + </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 6d38273..af9bd87 100644 --- a/tests/auto/studio3d/shared/shared_presentations.h +++ b/tests/auto/studio3d/shared/shared_presentations.h @@ -37,3 +37,4 @@ 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:/datainput.uia")); +const QUrl ACTIVATEACTIONS = QUrl(QStringLiteral("qrc:/activateactions.uip")); diff --git a/tests/auto/studio3d/shared/shared_presentations.qrc b/tests/auto/studio3d/shared/shared_presentations.qrc index 25dd40e..c55f2bc 100644 --- a/tests/auto/studio3d/shared/shared_presentations.qrc +++ b/tests/auto/studio3d/shared/shared_presentations.qrc @@ -12,5 +12,6 @@ <file alias="datainput.uia">presentation/datainput.uia</file> <file alias="datainput_sub.uip">presentation/datainput_sub.uip</file> <file>maps/OpenfootageNET_garage-512.hdr</file> + <file alias="activateactions.uip">presentation/activateactions.uip</file> </qresource> </RCC> |