- // Repeat with a delay
- float delay = 0.5f;
- animation = Animation::New(durationSeconds);
- animation.ScaleBy(actor, relativeScale, AlphaFunctions::Linear, delay, durationSeconds - delay);
- animation.FinishedSignal().Connect(&application, finishCheck);
- animation.Play();
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliAnimationScaleTo(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
- Stage::GetCurrent().Add(actor);
- DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
-
- // Build the animation
- float durationSeconds(1.0f);
- Animation animation = Animation::New(durationSeconds);
- Vector3 targetScale(2.0f, 2.0f, 2.0f);
- animation.ScaleTo(actor, targetScale.x, targetScale.y, targetScale.z);
-
- Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f);
-
- // Start the animation
- animation.Play();
-
- bool signalReceived(false);
- AnimationFinishCheck finishCheck(signalReceived);
- animation.FinishedSignal().Connect(&application, finishCheck);
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
-
- // Reset everything
- finishCheck.Reset();
- actor.SetScale(Vector3::ONE);
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
-
- // Repeat with a different (ease-in) alpha function
- animation = Animation::New(durationSeconds);
- animation.ScaleTo(actor, targetScale, AlphaFunctions::EaseIn);
- animation.FinishedSignal().Connect(&application, finishCheck);
- animation.Play();
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
-
- // The scale should have grown less, than with a linear alpha function
- Vector3 current(actor.GetCurrentScale());
- DALI_TEST_CHECK( current.x > 1.0f );
- DALI_TEST_CHECK( current.y > 1.0f );
- DALI_TEST_CHECK( current.z > 1.0f );
- DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
- DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
- DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
-
- // Reset everything
- finishCheck.Reset();
- actor.SetScale(Vector3::ONE);
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
-
- // Repeat with a delay
- float delay = 0.5f;
- animation = Animation::New(durationSeconds);
- animation.ScaleTo(actor, targetScale, AlphaFunctions::Linear, delay, durationSeconds - delay);
- animation.FinishedSignal().Connect(&application, finishCheck);
- animation.Play();
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliAnimationShow(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
- actor.SetVisible(false);
- application.SendNotification();
- application.Render(0);
- DALI_TEST_CHECK( !actor.IsVisible() );
- Stage::GetCurrent().Add(actor);
-
- // Start the animation
- float durationSeconds(10.0f);
- Animation animation = Animation::New(durationSeconds);
- animation.Show(actor, durationSeconds*0.5f);
- animation.Play();
-
- bool signalReceived(false);
- AnimationFinishCheck finishCheck(signalReceived);
- animation.FinishedSignal().Connect(&application, finishCheck);
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_CHECK( !actor.IsVisible() );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be shown now*/);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_CHECK( actor.IsVisible() );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_CHECK( actor.IsVisible() );
- END_TEST;
-}
-
-int UtcDaliAnimationHide(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
- DALI_TEST_CHECK( actor.IsVisible() );
- Stage::GetCurrent().Add(actor);
-
- // Start the animation
- float durationSeconds(10.0f);
- Animation animation = Animation::New(durationSeconds);
- animation.Hide(actor, durationSeconds*0.5f);
- animation.Play();
-
- bool signalReceived(false);
- AnimationFinishCheck finishCheck(signalReceived);
- animation.FinishedSignal().Connect(&application, finishCheck);
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*490.0f));
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_CHECK( actor.IsVisible() );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*10.0f)/*Should be hidden now*/);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_CHECK( !actor.IsVisible() );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_CHECK( !actor.IsVisible() );
- END_TEST;
-}
-
-int UtcDaliAnimationShowHideAtEnd(void)
-{
- // Test that show/hide delay can be the same as animation duration
- // i.e. to show/hide at the end of the animation
-
- TestApplication application;
-
- Actor actor = Actor::New();
- DALI_TEST_CHECK( actor.IsVisible() );
- Stage::GetCurrent().Add(actor);
-
- // Start Hide animation
- float durationSeconds(10.0f);
- Animation animation = Animation::New(durationSeconds);
- animation.Hide(actor, durationSeconds/*Hide at end*/);
- animation.Play();
-
- bool signalReceived(false);
- AnimationFinishCheck finishCheck(signalReceived);
- animation.FinishedSignal().Connect(&application, finishCheck);
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_CHECK( !actor.IsVisible() );
-
- // Start Show animation
- animation = Animation::New(durationSeconds);
- animation.Show(actor, durationSeconds/*Show at end*/);
- animation.FinishedSignal().Connect(&application, finishCheck);
- animation.Play();
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_CHECK( actor.IsVisible() );
- END_TEST;
-}
-
-int UtcDaliAnimationOpacityBy(void)
-{
- TestApplication application;
- Actor actor = Actor::New();
- float startingOpacity(0.5f);
- actor.SetOpacity(startingOpacity);
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
- Stage::GetCurrent().Add(actor);
-
- // Build the animation
- float durationSeconds(1.0f);
- Animation animation = Animation::New(durationSeconds);
- float relativeOpacity(-0.5f); // target of zero
- animation.OpacityBy(actor, relativeOpacity);
-
- float seventyFivePercentProgress((1.0f - 0.75f) * startingOpacity);
-
- // Start the animation
- animation.Play();
-
- bool signalReceived(false);
- AnimationFinishCheck finishCheck(signalReceived);
- animation.FinishedSignal().Connect(&application, finishCheck);
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentOpacity(), seventyFivePercentProgress, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION );
-
- // Reset everything
- finishCheck.Reset();
- actor.SetOpacity(startingOpacity);
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
-
- // Repeat with a different (ease-in) alpha function
- animation = Animation::New(durationSeconds);
- animation.OpacityBy(actor, relativeOpacity, AlphaFunctions::EaseIn);
- animation.FinishedSignal().Connect(&application, finishCheck);
- animation.Play();
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*750.0f)/* 75% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
-
- // The opacity should reduce less, than with a linear alpha function
- float current(actor.GetCurrentOpacity());
- DALI_TEST_CHECK( current < 1.0f );
- DALI_TEST_CHECK( current > seventyFivePercentProgress );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION );
-
- // Reset everything
- finishCheck.Reset();
- actor.SetOpacity(startingOpacity);
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
-
- // Repeat with a delay
- float delay = 0.5f;
- animation = Animation::New(durationSeconds);
- animation.OpacityBy(actor, relativeOpacity, AlphaFunctions::Linear, delay, durationSeconds - delay);
- animation.FinishedSignal().Connect(&application, finishCheck);
- animation.Play();
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentOpacity(), seventyFivePercentProgress, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliAnimationOpacityTo(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
- Stage::GetCurrent().Add(actor);
- DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
-
- // Build the animation
- float durationSeconds(1.0f);
- Animation animation = Animation::New(durationSeconds);
- float targetOpacity(0.0f);
- animation.OpacityTo(actor, targetOpacity);
-
- float ninetyNinePercentProgress(0.01f);
-
- // Start the animation
- animation.Play();
-
- bool signalReceived(false);
- AnimationFinishCheck finishCheck(signalReceived);
- animation.FinishedSignal().Connect(&application, finishCheck);
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentOpacity(), ninetyNinePercentProgress, 0.001f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
-
- // Reset everything
- finishCheck.Reset();
- actor.SetOpacity(1.0f);
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
-
- // Repeat with a different (ease-in) alpha function
- animation = Animation::New(durationSeconds);
- animation.OpacityTo(actor, targetOpacity, AlphaFunctions::EaseIn);
- animation.FinishedSignal().Connect(&application, finishCheck);
- animation.Play();
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
-
- // The opacity should reduce less, than with a linear alpha function
- float current(actor.GetCurrentOpacity());
- DALI_TEST_CHECK( current < 1.0f );
- DALI_TEST_CHECK( current > ninetyNinePercentProgress );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
-
- // Reset everything
- finishCheck.Reset();
- actor.SetOpacity(1.0f);
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
-
- // Repeat with a delay
- float delay = 0.5f;
- animation = Animation::New(durationSeconds);
- animation.OpacityTo(actor, targetOpacity, AlphaFunctions::Linear, delay, durationSeconds - delay);
- animation.FinishedSignal().Connect(&application, finishCheck);
- animation.Play();
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliAnimationColorBy(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
- actor.SetColor(Color::BLACK);
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::BLACK, TEST_LOCATION );
- Stage::GetCurrent().Add(actor);
-
- // Build the animation
- float durationSeconds(1.0f);
- Animation animation = Animation::New(durationSeconds);
- Vector4 targetColor(Color::GREEN);
- Vector4 relativeColor(Color::GREEN); // Note the alpha is automatically clamped <= 1.0f in world color
- animation.ColorBy(actor, relativeColor);
-
- Vector4 tenPercentProgress(Vector4(0.0f, 0.1f, 0.0f, 1.0f));
- Vector4 twentyPercentProgress(Vector4(0.0f, 0.2f, 0.0f, 1.0f));
-
- // Start the animation
- animation.Play();
-
- bool signalReceived(false);
- AnimationFinishCheck finishCheck(signalReceived);
- animation.FinishedSignal().Connect(&application, finishCheck);
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), tenPercentProgress, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
-
- // Reset everything
- finishCheck.Reset();
- actor.SetColor(Color::BLACK);
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), Color::BLACK, TEST_LOCATION );
-
- // Repeat with a different (ease-in) alpha function
- animation = Animation::New(durationSeconds);
- animation.ColorBy(actor, relativeColor, AlphaFunctions::EaseIn);
- animation.FinishedSignal().Connect(&application, finishCheck);
- animation.Play();
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
-
- // The color should have changed less, than with a linear alpha function
- Vector4 current(actor.GetCurrentWorldColor());
- DALI_TEST_CHECK( current.x == 0.0f ); // doesn't change
- DALI_TEST_CHECK( current.y > 0.0f );
- DALI_TEST_CHECK( current.y < tenPercentProgress.y );
- DALI_TEST_CHECK( current.z == 0.0f ); // doesn't change
- DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
-
- // Reset everything
- finishCheck.Reset();
- actor.SetColor(Color::BLACK);
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), Color::BLACK, TEST_LOCATION );
-
- // Repeat with a shorter animator duration
- float animatorDuration = 0.5f;
- animation = Animation::New(durationSeconds);
- animation.ColorBy(actor, relativeColor, AlphaFunctions::Linear, 0, animatorDuration);
- animation.FinishedSignal().Connect(&application, finishCheck);
- animation.Play();
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), twentyPercentProgress, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliAnimationColorTo(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
- Stage::GetCurrent().Add(actor);
- DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
-
- // Build the animation
- float durationSeconds(1.0f);
- Animation animation = Animation::New(durationSeconds);
- Vector4 targetColor(Color::RED);
- animation.ColorTo(actor, targetColor);
-
- Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f));
- Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f));
-
- // Start the animation
- animation.Play();
-
- bool signalReceived(false);
- AnimationFinishCheck finishCheck(signalReceived);
- animation.FinishedSignal().Connect(&application, finishCheck);
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
-
- // Reset everything
- finishCheck.Reset();
- actor.SetColor(Color::WHITE);
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
-
- // Repeat with a different (ease-in) alpha function
- animation = Animation::New(durationSeconds);
- animation.ColorTo(actor, targetColor, AlphaFunctions::EaseIn);
- animation.FinishedSignal().Connect(&application, finishCheck);
- animation.Play();
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
-
- // The color should have changed less, than with a linear alpha function
- Vector4 current(actor.GetCurrentColor());
- DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change
- DALI_TEST_CHECK( current.y < 1.0f );
- DALI_TEST_CHECK( current.y > tenPercentProgress.y );
- DALI_TEST_CHECK( current.z < 1.0f );
- DALI_TEST_CHECK( current.z > tenPercentProgress.z );
- DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
-
- // Reset everything
- finishCheck.Reset();
- actor.SetColor(Color::WHITE);
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
-
- // Repeat with a shorter animator duration
- float animatorDuration = 0.5f;
- animation = Animation::New(durationSeconds);
- animation.ColorTo(actor, targetColor, AlphaFunctions::Linear, 0, animatorDuration);
- animation.FinishedSignal().Connect(&application, finishCheck);
- animation.Play();
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliAnimationResize(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
- Stage::GetCurrent().Add(actor);
- DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
-
- // Build the animation
- float durationSeconds(1.0f);
- Animation animation = Animation::New(durationSeconds);
- Vector3 targetSize(100.0f, 100.0f, 100.0f);
- animation.Resize(actor, targetSize);
-
- Vector3 ninetyNinePercentProgress(targetSize * 0.99f);
-
- // Start the animation
- animation.Play();
-
- bool signalReceived(false);
- AnimationFinishCheck finishCheck(signalReceived);
- animation.FinishedSignal().Connect(&application, finishCheck);
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
-
- // Reset everything
- finishCheck.Reset();
- actor.SetSize(Vector3::ZERO);
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
-
- // Repeat with a different (ease-in) alpha function
- animation = Animation::New(durationSeconds);
- animation.Resize(actor, targetSize, AlphaFunctions::EaseIn);
- animation.FinishedSignal().Connect(&application, finishCheck);
- animation.Play();
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*990.0f)/* 99% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
-
- // The size should have travelled less, than with a linear alpha function
- Vector3 current(actor.GetCurrentSize());
- DALI_TEST_CHECK( current.x > 0.0f );
- DALI_TEST_CHECK( current.y > 0.0f );
- DALI_TEST_CHECK( current.z > 0.0f );
- DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x );
- DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y );
- DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
-
- // Reset everything
- finishCheck.Reset();
- actor.SetSize(Vector3::ZERO);
- application.SendNotification();
- application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
-
- // Repeat with a delay
- float delay = 0.5f;
- animation = Animation::New(durationSeconds);
- animation.Resize(actor, targetSize, AlphaFunctions::Linear, delay, durationSeconds - delay);
- animation.FinishedSignal().Connect(&application, finishCheck);
- animation.Play();
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliAnimationAnimateBool(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
- DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
- Stage::GetCurrent().Add(actor);
-
- // Build the animation
- float durationSeconds(10.0f);
- Animation animation = Animation::New(durationSeconds);
- animation.Animate<bool>( Property(actor, Actor::VISIBLE), ReturnFalseAfterProgressOne, TimePeriod(durationSeconds*0.25f/*delay*/, durationSeconds*0.1f) );
-
- // Start the animation
- animation.Play();
-
- bool signalReceived(false);
- AnimationFinishCheck finishCheck(signalReceived);
- animation.FinishedSignal().Connect(&application, finishCheck);
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
-
- // Should still be visible
- DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
-
- // Now animate functor should have hidden the actor
- DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliAnimationAnimateFloat(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
- Stage::GetCurrent().Add(actor);
-
- // Register a float property
- float startValue(10.0f);
- Property::Index index = actor.RegisterProperty( "test-property", startValue );
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), startValue, TEST_LOCATION );
-
- // Build the animation
- float durationSeconds(10.0f);
- Animation animation = Animation::New(durationSeconds);
- float targetPosition(0.0f);
- AnimateFloatTestFunctor func( 100, targetPosition );
- animation.Animate<float>( Property(actor, index), func );
-
- // Start the animation
- animation.Play();
-
- bool signalReceived(false);
- AnimationFinishCheck finishCheck(signalReceived);
- animation.FinishedSignal().Connect(&application, finishCheck);
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), 75.0f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), 50.0f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
-
- // We didn't expect the animation to finish yet
- application.SendNotification();
- finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), 25.0f, TEST_LOCATION );
-
- application.SendNotification();
- application.Render(static_cast<unsigned int>(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/);
-
- // We did expect the animation to finish
- application.SendNotification();
- finishCheck.CheckSignalReceived();
- DALI_TEST_EQUALS( actor.GetProperty<float>(index), targetPosition, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliAnimationAnimateInteger(void)
-{
- TestApplication application;