Merge "Removed -std=c++11 from dali-core.pc.in" into devel/master
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-PanGesture.cpp
index 681da1d..b35ec97 100644 (file)
@@ -39,25 +39,30 @@ int UtcDaliPanGestureConstructor(void)
 {
   TestApplication application; // Reset all test adapter return codes
 
-  PanGesture gesture(Gesture::Started);
-  DALI_TEST_EQUALS(Gesture::Started, gesture.state, TEST_LOCATION);
+  PanGesture gesture;
+  DALI_TEST_EQUALS(Gesture::Clear, gesture.state, TEST_LOCATION);
   DALI_TEST_EQUALS(1u, gesture.numberOfTouches, TEST_LOCATION);
   DALI_TEST_EQUALS(Gesture::Pan, gesture.type, TEST_LOCATION);
 
-  PanGesture gesture2(Gesture::Continuing);
-  DALI_TEST_EQUALS(Gesture::Continuing, gesture2.state, TEST_LOCATION);
+  PanGesture gesture2(Gesture::Started);
+  DALI_TEST_EQUALS(Gesture::Started, gesture2.state, TEST_LOCATION);
   DALI_TEST_EQUALS(1u, gesture2.numberOfTouches, TEST_LOCATION);
   DALI_TEST_EQUALS(Gesture::Pan, gesture2.type, TEST_LOCATION);
 
-  PanGesture gesture3(Gesture::Finished);
-  DALI_TEST_EQUALS(Gesture::Finished, gesture3.state, TEST_LOCATION);
+  PanGesture gesture3(Gesture::Continuing);
+  DALI_TEST_EQUALS(Gesture::Continuing, gesture3.state, TEST_LOCATION);
   DALI_TEST_EQUALS(1u, gesture3.numberOfTouches, TEST_LOCATION);
   DALI_TEST_EQUALS(Gesture::Pan, gesture3.type, TEST_LOCATION);
 
+  PanGesture gesture4(Gesture::Finished);
+  DALI_TEST_EQUALS(Gesture::Finished, gesture4.state, TEST_LOCATION);
+  DALI_TEST_EQUALS(1u, gesture4.numberOfTouches, TEST_LOCATION);
+  DALI_TEST_EQUALS(Gesture::Pan, gesture4.type, TEST_LOCATION);
+
   // Test copy constructor
-  gesture3.numberOfTouches = 3u;
+  gesture4.numberOfTouches = 3u;
 
-  PanGesture pan(gesture3);
+  PanGesture pan(gesture4);
   DALI_TEST_EQUALS(Gesture::Finished, pan.state, TEST_LOCATION);
   DALI_TEST_EQUALS(3u, pan.numberOfTouches, TEST_LOCATION);
   DALI_TEST_EQUALS(Gesture::Pan, pan.type, TEST_LOCATION);
@@ -129,3 +134,66 @@ int UtcDaliPanGestureGetScreenDistance(void)
   DALI_TEST_EQUALS(50.0f, gesture.GetScreenDistance(), TEST_LOCATION);
   END_TEST;
 }
+
+int UtcDaliPanGestureDynamicAllocation(void)
+{
+  PanGesture* gesture = new PanGesture( Gesture::Started );
+  DALI_TEST_EQUALS(Gesture::Started, gesture->state, TEST_LOCATION);
+  DALI_TEST_EQUALS(1u, gesture->numberOfTouches, TEST_LOCATION);
+  DALI_TEST_EQUALS(Gesture::Pan, gesture->type, TEST_LOCATION);
+  delete gesture;
+
+  END_TEST;
+}
+
+int UtcDaliPanGestureDetectorRegisterProperty(void)
+{
+  TestApplication application;
+
+  GestureDetector detector = PanGestureDetector::New();
+
+  Property::Index index = detector.RegisterProperty( "sceneProperty", 0 );
+  DALI_TEST_EQUALS( index, (Property::Index)PROPERTY_CUSTOM_START_INDEX, TEST_LOCATION );
+  DALI_TEST_EQUALS( detector.GetProperty< int32_t >( index ), 0, TEST_LOCATION );
+  detector.SetProperty( index, -99 );
+
+  using Dali::Animation;
+  Animation animation = Animation::New( 1.0f );
+  animation.AnimateTo( Property( detector, index ), 99 );
+  DALI_TEST_EQUALS( detector.GetProperty< int32_t >( index ), -99, TEST_LOCATION );
+
+  // create another pan gesture
+  GestureDetector detector2 = PanGestureDetector::New();
+  DALI_TEST_EQUALS( detector2.GetProperty< int32_t >( index ), 0, TEST_LOCATION );
+
+  // Start the animation
+  animation.Play();
+  application.SendNotification();
+  application.Render( 500 /* 50% progress */);
+  DALI_TEST_EQUALS( detector.GetCurrentProperty< int32_t >( index ), 0 /*half way*/, TEST_LOCATION );
+
+  // register another pan gesture value
+  Property::Index index2 = detector2.RegisterProperty( "sceneProperty2", 12 );
+  DALI_TEST_EQUALS( index2, (Property::Index)PROPERTY_CUSTOM_START_INDEX, TEST_LOCATION );
+  DALI_TEST_EQUALS( detector2.GetProperty< int32_t >( index2 ), 12, TEST_LOCATION );
+  DALI_TEST_EQUALS( detector2.GetCurrentProperty< int32_t >( index2 ), 12, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( detector.GetProperty< int32_t >( index ), 99 /*target*/, TEST_LOCATION );
+  DALI_TEST_EQUALS( detector.GetCurrentProperty< int32_t >( index ), 0, TEST_LOCATION );
+
+  Animation animation2 = Animation::New( 1.0f );
+  animation2.AnimateTo( Property( detector2, index2 ), -99 );
+  // Start the animation
+  animation2.Play();
+  application.SendNotification();
+  application.Render( 1000 /* 100% more progress */);
+
+  DALI_TEST_EQUALS( detector2.GetProperty< int32_t >( index2 ), -99, TEST_LOCATION );
+  DALI_TEST_EQUALS( detector2.GetCurrentProperty< int32_t >( index2 ), -99, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( detector.GetProperty< int32_t >( index ), 99, TEST_LOCATION );
+  DALI_TEST_EQUALS( detector.GetCurrentProperty< int32_t >( index ), 99, TEST_LOCATION );
+
+  END_TEST;
+}
+