Add UTCs for public-api
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-ScrollView.cpp
index c438865..d5baabb 100644 (file)
@@ -685,6 +685,9 @@ int UtcDaliToolkitScrollViewSetWrapModeP(void)
   ScrollView scrollView = ScrollView::New();
   Stage::GetCurrent().Add( scrollView );
 
+  Actor actor = Actor::New();
+  scrollView.Add( actor );
+
   // Position rulers. 4x4 grid.
   RulerPtr rulerX = new FixedRuler(50.0f);
   RulerPtr rulerY = new FixedRuler(50.0f);
@@ -697,7 +700,10 @@ int UtcDaliToolkitScrollViewSetWrapModeP(void)
   scrollView.ScrollTo(Vector2(225.0f, 125.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
   Wait(application);
   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 17, TEST_LOCATION );
+
   scrollView.SetWrapMode(true);
+  scrollView.ScrollTo(Vector2(230.0f, 130.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
+  Wait(application);
   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 13, TEST_LOCATION );
   END_TEST;
 }
@@ -1505,17 +1511,17 @@ int UtcDaliToolkitScrollViewSetMinimumDistanceForFlickP(void)
   END_TEST;
 }
 
-int UtcDaliToolkitScrollViewSetMouseWheelScrollDistanceStepP(void)
+int UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP(void)
 {
   ToolkitTestApplication application;
-  tet_infoline(" UtcDaliToolkitScrollViewSetMouseWheelScrollDistanceStepP");
+  tet_infoline(" UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP");
 
   ScrollView scrollView = ScrollView::New();
   // Disable Refresh signal (TET environment cannot use adaptor's Timer)
-  scrollView.SetMouseWheelScrollDistanceStep(Vector2(30.0f, 15.0f));
-  DALI_TEST_EQUALS( scrollView.GetMouseWheelScrollDistanceStep(), Vector2(30.0f, 15.0f), TEST_LOCATION );
-  scrollView.SetMouseWheelScrollDistanceStep(Vector2(60.0f, 30.0f));
-  DALI_TEST_EQUALS( scrollView.GetMouseWheelScrollDistanceStep(), Vector2(60.0f, 30.0f), TEST_LOCATION);
+  scrollView.SetWheelScrollDistanceStep(Vector2(30.0f, 15.0f));
+  DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(30.0f, 15.0f), TEST_LOCATION );
+  scrollView.SetWheelScrollDistanceStep(Vector2(60.0f, 30.0f));
+  DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(60.0f, 30.0f), TEST_LOCATION);
   END_TEST;
 }
 
@@ -1684,6 +1690,54 @@ int UtcDaliToolkitScrollViewRemoveAllEffectsN(void)
   END_TEST;
 }
 
+int UtcDaliToolkitScrollViewSetOvershootEnabledP(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEnabledP");
+
+  ScrollView scrollView = ScrollView::New();
+
+  scrollView.SetOvershootEnabled(true);
+  DALI_TEST_CHECK(scrollView.IsOvershootEnabled());
+
+  scrollView.SetOvershootEnabled(false);
+  DALI_TEST_CHECK(!scrollView.IsOvershootEnabled());
+
+  END_TEST;
+}
+
+int UtcDaliToolkitScrollViewSetOvershootEffectColorP(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEffectColorP");
+
+  ScrollView scrollView = ScrollView::New();
+
+  scrollView.SetOvershootEffectColor(Dali::Color::RED);
+  DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::RED, TEST_LOCATION);
+
+  scrollView.SetOvershootEffectColor(Dali::Color::YELLOW);
+  DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::YELLOW, TEST_LOCATION);
+
+  END_TEST;
+}
+
+int UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP");
+
+  ScrollView scrollView = ScrollView::New();
+
+  scrollView.SetOvershootAnimationSpeed(55.0f);
+  DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 55.0f, TEST_LOCATION);
+
+  scrollView.SetOvershootAnimationSpeed(120.0f);
+  DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 120.0f, TEST_LOCATION);
+
+  END_TEST;
+}
+
 int UtcDaliToolkitScrollViewGetSet(void)
 {
   ToolkitTestApplication application;
@@ -1801,6 +1855,9 @@ int UtcDaliToolkitScrollViewFixedRulerConstructorP(void)
   RulerPtr fixedRuler = new FixedRuler( 100.0f );
   DALI_TEST_CHECK( fixedRuler );
 
+  fixedRuler = new FixedRuler( 0.0f );
+  DALI_TEST_CHECK( fixedRuler );
+
   END_TEST;
 }
 
@@ -1831,6 +1888,22 @@ int UtcDaliToolkitScrollViewRulerGetTypeP(void)
   END_TEST;
 }
 
+int UtcDaliToolkitScrollViewRulerGetExtensionP(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitScrollViewRulerGetExtensionP");
+
+  RulerPtr defaultRuler = new DefaultRuler();
+  DALI_TEST_CHECK( defaultRuler );
+  DALI_TEST_CHECK( !defaultRuler->GetExtension() );
+
+  RulerPtr fixedRuler = new FixedRuler( 100.0f );
+  DALI_TEST_CHECK( fixedRuler );
+  DALI_TEST_CHECK( !fixedRuler->GetExtension() );
+
+  END_TEST;
+}
+
 int UtcDaliToolkitScrollViewRulerEnableDisable(void)
 {
   ToolkitTestApplication application;
@@ -1939,6 +2012,18 @@ int UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP(void)
   position = rulerNormal->GetPositionFromPage(2, volume, true);
   DALI_TEST_EQUALS( position, 60.0f, TEST_LOCATION );
   DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
+
+  // Disable the ruler
+  rulerNormal->Disable();
+
+  position = rulerNormal->GetPositionFromPage(1, volume, true);
+  DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
+  DALI_TEST_EQUALS( volume, 1u, TEST_LOCATION );
+
+  position = rulerNormal->GetPositionFromPage(2, volume, true);
+  DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
+  DALI_TEST_EQUALS( volume, 2u, TEST_LOCATION );
+
   END_TEST;
 }
 
@@ -2036,6 +2121,21 @@ int UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP(void)
   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
 
+  // Set domain size to be smaller than the ruler space
+  fixedRuler->SetDomain( RulerDomain(0.0f, 50.0f, true) );
+
+  fixedRuler->Enable();
+  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
+  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
+  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
+  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
+
+  fixedRuler->Disable();
+  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
+  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
+  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
+  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
+
   END_TEST;
 }
 
@@ -2086,6 +2186,97 @@ int UtcDaliToolkitScrollViewFixedRulerSnapP(void)
   END_TEST;
 }
 
+int UtcDaliToolkitScrollViewConstraintsMove(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitScrollViewConstraintsMove");
 
+  // 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);
+
+  // Add an Actor to ScrollView,
+  Actor a = Actor::New();
+  scrollView.Add(a);
+  a.SetPosition( TEST_ACTOR_POSITION );
+  Wait(application);
+
+  const Vector2 target = Vector2(100.0f, 100.0f);
+  const Vector2 target2 = Vector2(200.0f, 200.0f);
+
+  Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, MoveActorConstraint );
+  constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
+  constraint.SetRemoveAction(Constraint::Discard);
+  scrollView.ApplyConstraintToChildren(constraint);
+
+  scrollView.ScrollTo( target, 0.0f );
+  Wait(application);
+  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
+  scrollView.ScrollTo( target2 );
+  Wait(application, RENDER_DELAY_SCROLL);
+  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliToolkitScrollViewConstraintsWrap(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitScrollViewConstraintsWrap");
+
+  // 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);
 
+  // Add an Actor to ScrollView,
+  Actor a = Actor::New();
+  scrollView.Add(a);
+  a.SetPosition( TEST_ACTOR_POSITION );
+  Wait(application);
+
+  const Vector2 target = Vector2(100.0f, 100.0f);
+  const Vector2 target2 = Vector2(200.0f, 200.0f);
+
+  Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, WrapActorConstraint );
+  constraint.AddSource( LocalSource( Actor::Property::SCALE ) );
+  constraint.AddSource( LocalSource( Actor::Property::ANCHOR_POINT ) );
+  constraint.AddSource( LocalSource( Actor::Property::SIZE ) );
+  constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
+  constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
+  constraint.AddSource( Source( scrollView, Toolkit::ScrollView::Property::WRAP ) );
+  constraint.SetRemoveAction(Constraint::Discard);
+  scrollView.ApplyConstraintToChildren(constraint);
+
+  scrollView.ScrollTo( target, 0.0f );
+  Wait(application);
+  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
+  scrollView.ScrollTo( target2 );
+  Wait(application, RENDER_DELAY_SCROLL);
+  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
+
+  END_TEST;
+}