bool mCalled{ false };
};
-} // anon namespace
-
class FrameCallbackOneActor : public FrameCallbackBasic
{
public:
bool mBakeScaleCallSuccess{ false };
};
+} // anon namespace
+
///////////////////////////////////////////////////////////////////////////////
int UtcDaliFrameCallbackCheckInstallationAndRemoval(void)
DALI_TEST_EQUALS( actor.GetCurrentProperty( Actor::Property::COLOR ).Get< Vector4 >(), Color::WHITE, TEST_LOCATION );
DALI_TEST_EQUALS( actor.GetCurrentProperty( Actor::Property::SCALE ).Get< Vector3 >(), Vector3::ONE, TEST_LOCATION );
+ // Render for a couple more frames to ensure the values are reset properly (some values are double-buffered)
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( actor.GetCurrentProperty( Actor::Property::POSITION ).Get< Vector3 >(), Vector3::ZERO, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >(), Vector3( actorSize ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentProperty( Actor::Property::COLOR ).Get< Vector4 >(), Color::WHITE, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentProperty( Actor::Property::SCALE ).Get< Vector3 >(), Vector3::ONE, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( actor.GetCurrentProperty( Actor::Property::POSITION ).Get< Vector3 >(), Vector3::ZERO, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentProperty( Actor::Property::SIZE ).Get< Vector3 >(), Vector3( actorSize ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentProperty( Actor::Property::COLOR ).Get< Vector4 >(), Color::WHITE, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentProperty( Actor::Property::SCALE ).Get< Vector3 >(), Vector3::ONE, TEST_LOCATION );
+
END_TEST;
}
END_TEST;
}
+
+int UtcDaliFrameCallbackMultipleCallbacks(void)
+{
+ // Test to ensure multiple frame-callbacks work as expected
+
+ TestApplication application;
+ Stage stage = Stage::GetCurrent();
+
+ Actor actor = Actor::New();
+ stage.Add( actor );
+
+ FrameCallbackBasic frameCallback1;
+ FrameCallbackBasic frameCallback2;
+ DevelStage::AddFrameCallback( stage, frameCallback1, stage.GetRootLayer() );
+ DevelStage::AddFrameCallback( stage, frameCallback2, stage.GetRootLayer() );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( frameCallback1.mCalled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( frameCallback2.mCalled, true, TEST_LOCATION );
+ frameCallback1.Reset();
+ frameCallback2.Reset();
+
+ // Remove the second frame-callback, only the first should be called
+
+ DevelStage::RemoveFrameCallback( stage, frameCallback2 );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( frameCallback1.mCalled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( frameCallback2.mCalled, false, TEST_LOCATION );
+ frameCallback1.Reset();
+ frameCallback2.Reset();
+
+ // Re-add the second frame-callback and remove the first, only the second should be called
+
+ DevelStage::AddFrameCallback( stage, frameCallback2, stage.GetRootLayer() );
+ DevelStage::RemoveFrameCallback( stage, frameCallback1 );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( frameCallback1.mCalled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( frameCallback2.mCalled, true, TEST_LOCATION );
+ frameCallback1.Reset();
+ frameCallback2.Reset();
+
+ // Attempt removal of the first frame-callback again, should be a no-op and yield the exact same results as the last run
+ DevelStage::RemoveFrameCallback( stage, frameCallback1 );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( frameCallback1.mCalled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( frameCallback2.mCalled, true, TEST_LOCATION );
+ frameCallback1.Reset();
+ frameCallback2.Reset();
+
+ // Remove the second frame-callback as well, neither should be called
+ DevelStage::RemoveFrameCallback( stage, frameCallback2 );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( frameCallback1.mCalled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( frameCallback2.mCalled, false, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliFrameCallbackActorDestroyed(void)
+{
+ // Test to ensure that the frame-callback behaves gracefully if the connected root-actor is destroyed
+
+ TestApplication application;
+ Stage stage = Stage::GetCurrent();
+
+ Actor actor = Actor::New();
+ stage.Add( actor );
+
+ FrameCallbackBasic frameCallback1;
+ FrameCallbackBasic frameCallback2;
+ DevelStage::AddFrameCallback( stage, frameCallback1, actor );
+ DevelStage::AddFrameCallback( stage, frameCallback2, actor );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( frameCallback1.mCalled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( frameCallback2.mCalled, true, TEST_LOCATION );
+ frameCallback1.Reset();
+ frameCallback2.Reset();
+
+ // Remove the second frame-callback, only the first should be called
+
+ DevelStage::RemoveFrameCallback( stage, frameCallback2 );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( frameCallback1.mCalled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( frameCallback2.mCalled, false, TEST_LOCATION );
+ frameCallback1.Reset();
+ frameCallback2.Reset();
+
+ // Remove and destroy the actor, the first one should not be called either
+ stage.Remove( actor );
+ actor.Reset();
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( frameCallback1.mCalled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( frameCallback2.mCalled, false, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliFrameCallbackDestroyedBeforeRemoving(void)
+{
+ // Ensure there's no segmentation fault if the callback is deleted without being removed
+
+ TestApplication application;
+ Stage stage = Stage::GetCurrent();
+
+ Actor actor = Actor::New();
+ stage.Add( actor );
+
+ {
+ FrameCallbackBasic frameCallback;
+ DevelStage::AddFrameCallback( stage, frameCallback, actor );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( frameCallback.mCalled, true, TEST_LOCATION );
+ frameCallback.Reset();
+ }
+
+ // frameCallback has now been destroyed but not removed
+
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_CHECK( true ); // If it runs to here then there's no segmentation fault
+
+ END_TEST;
+}
+
+int UtcDaliFrameCallbackDoubleAddition(void)
+{
+ // Ensure we don't connect the same frame-callback twice
+
+ TestApplication application;
+ Stage stage = Stage::GetCurrent();
+ Actor rootActor = stage.GetRootLayer();
+
+ FrameCallbackBasic frameCallback;
+ DevelStage::AddFrameCallback( stage, frameCallback, rootActor );
+
+ try
+ {
+ DevelStage::AddFrameCallback( stage, frameCallback, rootActor );
+ }
+ catch( ... )
+ {
+ DALI_TEST_CHECK( true );
+ }
+
+ END_TEST;
+}