(Animation) Ensure we do not adjust the current value when stopping an AnimateBy... 24/216624/1
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 29 Oct 2019 16:54:33 +0000 (16:54 +0000)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 29 Oct 2019 16:55:46 +0000 (16:55 +0000)
- The issue was that when issuing a stop, we set the current value but
  we use that as the amount to adjust for an AnimateBy animation rather
  than a target.

Change-Id: I49ab3a5d004dce5b18d747b9e7791df81d4aaddb

automated-tests/src/dali/utc-Dali-Animation.cpp
dali/internal/event/animation/animation-impl.cpp

index 179ac9b..addc288 100644 (file)
@@ -13493,3 +13493,38 @@ int UtcDaliAnimationPlayFromWithLoopCount(void)
 
   END_TEST;
 }
+
+int UtcDaliAnimationCombineToAndByWithStop(void)
+{
+  tet_infoline( "Ensure the Y Position is not modified when animating the X position using AnimateTo and AnimateBy");
+
+  TestApplication application;
+
+  auto actor = Actor::New();
+  actor.SetPosition( 100.0f, 100.0f );
+  Stage::GetCurrent().Add( actor );
+
+  auto animation = Animation::New( 1.0f );
+  const float origY = actor.GetProperty( Actor::Property::POSITION_Y ).Get< float >();
+  animation.AnimateTo( Property( actor, Actor::Property::POSITION ), Vector3( 150.0f, origY, 0.0f ), TimePeriod( 1.0f ) );
+  animation.AnimateBy( Property( actor, Actor::Property::POSITION ), Vector3( -30.0f, 0.0f, 0.0f ), TimePeriod( 1.0f, 1.0f ) );
+  animation.Play();
+
+  application.SendNotification();
+  application.Render( 500 );
+
+  application.SendNotification();
+  application.Render( 500 );
+
+  application.SendNotification();
+  application.Render( 500 );
+
+  // Stop and clear the animation using the current values
+  animation.Stop();
+  animation.Clear();
+
+  // Check the y position, it should be the same as before
+  DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::POSITION_Y).Get< float >(), origY, TEST_LOCATION );
+
+  END_TEST;
+}
index ceab690..e82da5e 100644 (file)
@@ -1114,8 +1114,8 @@ void Animation::NotifyObjects( Animation::Notify notifyValueType )
         object->NotifyPropertyAnimation(
           *this,
           propertyIndex,
-          ( notifyValueType == Notify::USE_TARGET_VALUE ) ? iter->targetValue : object->GetCurrentProperty( propertyIndex ),
-          iter->animatorType );
+          ( notifyValueType == Notify::USE_TARGET_VALUE ) ? iter->targetValue  : object->GetCurrentProperty( propertyIndex ),
+          ( notifyValueType == Notify::USE_TARGET_VALUE ) ? iter->animatorType : Animation::TO ); // If we're setting the current value, then use TO as we want to set, not adjust, the current value
       }
     }
   }