Using New Constraints
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-ScrollView.cpp
index 867abd8..39af3d3 100644 (file)
@@ -207,25 +207,13 @@ struct TestSumConstraint
 
   /**
    * @param[in] current The current base value
-   * @param[in] property The property to be added to current.
+   * @param[in] inputs Contains the property to be added to current.
    * @return The new current Vector.
    */
-  Vector3 operator()(const Vector3& current)
+  void operator()( Vector3& current, const PropertyInputContainer& inputs )
   {
-    gConstraintResult = current + mOffset;
-    return gConstraintResult;
-  }
-
-  /**
-   * @param[in] current The current base value
-   * @param[in] property The property to be added to current.
-   * @return The new current Vector.
-   */
-  Vector3 operator()(const Vector3&    current,
-                    const PropertyInput& property)
-  {
-    gConstraintResult = current + property.GetVector3() + mOffset;
-    return gConstraintResult;
+    gConstraintResult = current + inputs[0]->GetVector3() + mOffset;
+    current = gConstraintResult;
   }
 
   Vector3 mOffset;
@@ -239,14 +227,11 @@ struct TestSumConstraint
  */
 static float TestOvershootSnapDuration(ToolkitTestApplication &application, ScrollView scrollView)
 {
-  Property::Index overshootPropertyX = scrollView.GetPropertyIndex(ScrollView::SCROLL_OVERSHOOT_X_PROPERTY_NAME);
-  Property::Index overshootPropertyY = scrollView.GetPropertyIndex(ScrollView::SCROLL_OVERSHOOT_Y_PROPERTY_NAME);
-
   int timeToReachOrigin = -1;
   for(int i = 0;i<MAX_FRAMES_TO_TEST_OVERSHOOT;i++)
   {
-    float overshootXValue = scrollView.GetProperty<float>(overshootPropertyX);
-    float overshootYValue = scrollView.GetProperty<float>(overshootPropertyY);
+    float overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
+    float overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
     if(overshootXValue == 0.0f && overshootYValue == 0.0f)
     {
       break;
@@ -722,57 +707,6 @@ int UtcDaliScrollViewScrollSensitive(void)
   END_TEST;
 }
 
-int UtcDaliScrollViewTouchesRequired(void)
-{
-  ToolkitTestApplication application;
-  tet_infoline(" UtcDaliScrollViewTouchesRequired");
-
-  // Set up a scrollView...
-  ScrollView scrollView = ScrollView::New();
-  Stage::GetCurrent().Add( scrollView );
-  Vector2 stageSize = Stage::GetCurrent().GetSize();
-  scrollView.SetSize(stageSize);
-  scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
-  scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-
-  // Position rulers.
-  RulerPtr rulerX = new DefaultRuler();
-  RulerPtr rulerY = new DefaultRuler();
-  rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
-  rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
-  scrollView.SetRulerX(rulerX);
-  scrollView.SetRulerY(rulerY);
-  scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
-  scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
-  scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
-  scrollView.SnapStartedSignal().Connect( &OnSnapStart );
-
-  scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
-  Wait(application);
-
-  // First try touches required being a minimum and maximum of 2.
-  scrollView.SetTouchesRequiredForPanning(2, 2, true);
-  PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, true);
-
-  DALI_TEST_CHECK( !gOnScrollStartCalled );
-  DALI_TEST_CHECK( !gOnScrollUpdateCalled );
-  DALI_TEST_CHECK( !gOnScrollCompleteCalled );
-  DALI_TEST_CHECK( !gOnSnapStartCalled );
-
-  scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
-  Wait(application);
-
-  // Second try touches required being a minimum and maximum of 1.
-  scrollView.SetTouchesRequiredForPanning(1, 1, true);
-  PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT * 0.1f, CLAMP_GESTURE_FRAMES * 0.1f, true);
-
-  DALI_TEST_CHECK( gOnScrollStartCalled );
-  DALI_TEST_CHECK( gOnScrollUpdateCalled );
-  DALI_TEST_CHECK( gOnScrollCompleteCalled );
-  DALI_TEST_CHECK( gOnSnapStartCalled );
-  END_TEST;
-}
-
 int UtcDaliScrollViewAxisAutoLock(void)
 {
   ToolkitTestApplication application;
@@ -868,10 +802,8 @@ int UtcDaliScrollViewConstraints(void)
   a.SetPosition( TEST_ACTOR_POSITION );
   Wait(application);
 
-  Property::Index scrollPositionProperty = scrollView.GetPropertyIndex(ScrollView::SCROLL_POSITION_PROPERTY_NAME);
-  Constraint constraint = Constraint::New<Vector3>( Actor::POSITION,
-                                                       Source(scrollView, scrollPositionProperty),
-                                                       TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
+  Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
+  constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
   constraint.SetRemoveAction(Constraint::Discard);
   scrollView.ApplyConstraintToChildren(constraint);
   Wait(application);
@@ -916,12 +848,9 @@ int UtcDaliScrollViewBind(void)
   a.SetPosition( TEST_ACTOR_POSITION );
   Wait(application);
 
-  Property::Index scrollPositionProperty = scrollView.GetPropertyIndex(ScrollView::SCROLL_POSITION_PROPERTY_NAME);
   // apply this constraint to scrollview
-  Constraint constraint = Constraint::New<Vector3>( Actor::POSITION,
-                                                       Source(scrollView, scrollPositionProperty),
-                                                       TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
-
+  Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
+  constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
   constraint.SetRemoveAction(Constraint::Discard);
   scrollView.ApplyConstraintToChildren(constraint);
 
@@ -1085,12 +1014,9 @@ int UtcDaliScrollViewOvershoot(void)
   // 1. Scroll page in NW (-500,-500 pixels), then inspect overshoot. (don't release touch)
   Vector2 currentPos = Vector2(100.0f, 100.0f);
   currentPos = PerformGestureDiagonalSwipe(application, currentPos, Vector2(5.0f, 5.0f), 100, false);
-  Property::Index overshootXProperty = scrollView.GetPropertyIndex(ScrollView::SCROLL_OVERSHOOT_X_PROPERTY_NAME);
-  Property::Index overshootYProperty = scrollView.GetPropertyIndex(ScrollView::SCROLL_OVERSHOOT_Y_PROPERTY_NAME);
-  Property::Index scrollPositionProperty = scrollView.GetPropertyIndex(ScrollView::SCROLL_POSITION_PROPERTY_NAME);
-  float overshootXValue = scrollView.GetProperty<float>(overshootXProperty);
-  float overshootYValue = scrollView.GetProperty<float>(overshootYProperty);
-  Vector3 positionValue = scrollView.GetProperty<Vector3>(scrollPositionProperty);
+  float overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
+  float overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
+  Vector3 positionValue = scrollView.GetProperty<Vector3>(ScrollView::Property::SCROLL_POSITION);
   DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
   DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
   DALI_TEST_EQUALS(positionValue, Vector3::ZERO, TEST_LOCATION);