+
+ // Create two scroll view effects
+ Dali::Path path = Dali::Path::New();
+ ScrollViewEffect effect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 0.0f, 0.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(100.0f, 100.0f, 0.0f), 2);
+ ScrollViewEffect newEffect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 1.0f, 1.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(200.0f, 150.0f, 0.0f), 5);
+
+ // Apply both effects
+ scrollView.ApplyEffect(effect);
+ scrollView.ApplyEffect(newEffect);
+
+ DALI_TEST_CHECK( true );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewApplyEffectN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewApplyEffectN");
+
+ // Create a ScrollView
+ ScrollView scrollView = ScrollView::New();
+
+ // Create two scroll view effects
+ Dali::Path path = Dali::Path::New();
+ ScrollViewEffect effect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 0.0f, 0.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(100.0f, 100.0f, 0.0f), 2);
+ ScrollViewEffect newEffect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 1.0f, 1.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(200.0f, 150.0f, 0.0f), 5);
+
+ // Apply both effects
+ scrollView.ApplyEffect(effect);
+ scrollView.ApplyEffect(newEffect);
+
+ // Attempt to apply the same effect again
+ try
+ {
+ scrollView.ApplyEffect(newEffect);
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewRemoveEffectP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectP");
+
+ // Create a ScrollView
+ ScrollView scrollView = ScrollView::New();
+
+ // Create two scroll view effects
+ Dali::Path path = Dali::Path::New();
+ ScrollViewEffect effect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 0.0f, 0.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(100.0f, 100.0f, 0.0f), 2);
+ ScrollViewEffect newEffect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 1.0f, 1.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(200.0f, 150.0f, 0.0f), 5);
+
+ // Apply both effects
+ scrollView.ApplyEffect(effect);
+ scrollView.ApplyEffect(newEffect);
+
+ // Remove both effects
+ scrollView.RemoveEffect(effect);
+ scrollView.RemoveEffect(newEffect);
+
+ DALI_TEST_CHECK( true );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewRemoveEffectN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectN");
+
+ // Create a ScrollView
+ ScrollView scrollView = ScrollView::New();
+
+ // Create two scroll view effects
+ Dali::Path path = Dali::Path::New();
+ ScrollViewEffect effect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 0.0f, 0.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(100.0f, 100.0f, 0.0f), 2);
+ ScrollViewEffect newEffect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 1.0f, 1.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(200.0f, 150.0f, 0.0f), 5);
+
+ // Apply the first effect
+ scrollView.ApplyEffect(effect);
+
+ // Attempt to remove the second effect which has not been applied to scroll view
+ try
+ {
+ scrollView.RemoveEffect(newEffect);
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "effectExistedInScrollView", TEST_LOCATION );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewRemoveAllEffectsP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsP");
+
+ // Create a ScrollView
+ ScrollView scrollView = ScrollView::New();
+
+ // Create two scroll view effects
+ Dali::Path path = Dali::Path::New();
+ ScrollViewEffect effect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 0.0f, 0.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(100.0f, 100.0f, 0.0f), 2);
+ ScrollViewEffect newEffect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 1.0f, 1.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(200.0f, 150.0f, 0.0f), 5);
+
+ // Apply both effects
+ scrollView.ApplyEffect(effect);
+ scrollView.ApplyEffect(newEffect);
+
+ // Attempt to apply the same first effect again
+ try
+ {
+ scrollView.ApplyEffect(effect);
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
+ }
+
+ // Remove both effects
+ scrollView.RemoveAllEffects();
+
+ // Apply both effects again
+ scrollView.ApplyEffect(effect);
+ scrollView.ApplyEffect(newEffect);
+
+ DALI_TEST_CHECK( true );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewRemoveAllEffectsN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsN");
+
+ // Create a ScrollView
+ ScrollView scrollView = ScrollView::New();
+
+ // Remove effects when there is no effect applied previously
+ scrollView.RemoveAllEffects();
+
+ DALI_TEST_CHECK( true );
+
+ 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;
+ tet_infoline(" UtcDaliToolkitScrollViewGetSet");
+ ScrollView scrollView = ScrollView::New();
+ scrollView.SetMaxFlickSpeed(0.5f);
+ DALI_TEST_EQUALS(scrollView.GetMaxFlickSpeed(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
+ scrollView.SetFrictionCoefficient(0.6f);
+ DALI_TEST_EQUALS(scrollView.GetFrictionCoefficient(), 0.6f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
+ scrollView.SetFlickSpeedCoefficient(0.7f);
+ DALI_TEST_EQUALS(scrollView.GetFlickSpeedCoefficient(), 0.7f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewRulerDomainConstructorP(void)
+{
+ ToolkitTestApplication application;
+
+ RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
+ DALI_TEST_EQUALS( domainX.min, 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( domainX.max, 200.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( domainX.enabled, true, TEST_LOCATION);
+
+ RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
+ DALI_TEST_EQUALS( domainY.min, 100.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( domainY.max, 500.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( domainY.enabled, false, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewRulerDomainGetSizeP(void)
+{
+ ToolkitTestApplication application;
+
+ RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
+ DALI_TEST_EQUALS( domainX.GetSize(), 200.0f, TEST_LOCATION);
+
+ RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
+ DALI_TEST_EQUALS( domainY.GetSize(), 400.0f, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewRulerDomainClampP(void)
+{
+ ToolkitTestApplication application;
+
+ RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
+
+ float value = domainX.Clamp(50.0f, 100.0f, 1.0f);
+ DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
+
+ value = domainX.Clamp(300.0f, 20.0f, 1.0f);
+ DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
+
+ value = domainX.Clamp(300.0f, 20.0f, 0.5f);
+ DALI_TEST_EQUALS( value, 80.0f, TEST_LOCATION);
+
+ value = domainX.Clamp(250.0f, 200.0f, 2.0f);
+ DALI_TEST_EQUALS( value, 200.0f, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewRulerDomainClampWithStateP(void)
+{
+ ToolkitTestApplication application;
+
+ RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
+
+ ClampState clamped;
+ float value = domainX.Clamp(50.0f, 100.0f, 1.0f, clamped);
+ DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( clamped, Dali::Toolkit::NotClamped, TEST_LOCATION);
+
+ value = domainX.Clamp(-100.0f, 200.0f, 1.0f, clamped);
+ DALI_TEST_EQUALS( value, 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( clamped, Dali::Toolkit::ClampedToMin, TEST_LOCATION);
+
+ value = domainX.Clamp(300.0f, 20.0f, 1.0f, clamped);
+ DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( clamped, Dali::Toolkit::ClampedToMax, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewDefaultRulerConstructorP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerConstructorP");
+
+ RulerPtr defaultRuler = new DefaultRuler();
+ DALI_TEST_CHECK( defaultRuler );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewDefaultRulerDestructorP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerDestructorP");
+
+ RulerPtr defaultRuler = new DefaultRuler();
+
+ DALI_TEST_CHECK( true );
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewFixedRulerConstructorP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewFixedRulerConstructorP");
+
+ RulerPtr fixedRuler = new FixedRuler( 100.0f );
+ DALI_TEST_CHECK( fixedRuler );
+
+ fixedRuler = new FixedRuler( 0.0f );
+ DALI_TEST_CHECK( fixedRuler );
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewFixedRulerDestructorP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewFixedRulerDestructorP");
+
+ RulerPtr fixedRuler = new FixedRuler( 100.0f );
+
+ DALI_TEST_CHECK( true );
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewRulerGetTypeP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewRulerGetTypeP");
+
+ RulerPtr defaultRuler = new DefaultRuler();
+ DALI_TEST_CHECK( defaultRuler );
+ DALI_TEST_EQUALS( defaultRuler->GetType(), Dali::Toolkit::Ruler::Free, TEST_LOCATION);
+
+ RulerPtr fixedRuler = new FixedRuler( 100.0f );
+ DALI_TEST_CHECK( fixedRuler );
+ DALI_TEST_EQUALS( fixedRuler->GetType(), Dali::Toolkit::Ruler::Fixed, TEST_LOCATION);
+
+ 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;
+ tet_infoline(" UtcDaliToolkitScrollViewRulerEnableDisable");
+
+ RulerPtr ruler = new DefaultRuler();
+
+ DALI_TEST_CHECK( ruler->IsEnabled() );
+ ruler->Disable();
+ DALI_TEST_CHECK( !ruler->IsEnabled() );
+ ruler->Enable();
+ DALI_TEST_CHECK( ruler->IsEnabled() );
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewRulerDomainEnableDisable(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewRulerDomainEnableDisable");
+
+ RulerPtr ruler = new DefaultRuler();
+ DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
+
+ ruler->SetDomain( RulerDomain(0.0f, 100.0f, true) );
+ DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 100.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( ruler->Clamp(-200.0f), 0.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( ruler->Clamp(200.0f), 100.0f, TEST_LOCATION );
+
+ ruler->DisableDomain();
+ DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( ruler->Clamp(-200.0f), -200.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( ruler->Clamp(200.0f), 200.0f, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewRulerSnapAndClamp(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewRulerSnapAndClamp");
+
+ RulerPtr ruler = new FixedRuler( 50.0f );
+ ruler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
+
+ // default testing. (snap and clamp)
+ DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f), 50.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f), 50.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f), 400.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f), 400.0f, TEST_LOCATION);
+
+ // bias testing.
+ DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
+ DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.5f), 50.0f, TEST_LOCATION); // No Flick
+ DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
+
+ DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
+ DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.5f), 0.0f, TEST_LOCATION); // No Flick
+ DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
+
+ // length testing.
+ DALI_TEST_EQUALS( ruler->SnapAndClamp(-10.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (over left boundary)
+ DALI_TEST_EQUALS( ruler->SnapAndClamp(-5.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (slightly ovr left boundary)
+ DALI_TEST_EQUALS( ruler->SnapAndClamp(300.0f, 0.5f, 10.0f), 300.0f, TEST_LOCATION); // 10 units long (not over a boundary)
+ DALI_TEST_EQUALS( ruler->SnapAndClamp(395.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (slightly over right boundary)
+ DALI_TEST_EQUALS( ruler->SnapAndClamp(500.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (over right boundary)
+
+ // scale testing.
+ DALI_TEST_EQUALS( ruler->SnapAndClamp(-100.0f, 0.5f, 0.0f, 2.0f), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 2.0f), 50.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( ruler->SnapAndClamp(700.0f, 0.5f, 0.0f, 2.0f), 700.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( ruler->SnapAndClamp(850.0f, 0.5f, 0.0f, 2.0f), 800.0f, TEST_LOCATION);
+
+ // clamp state testing.
+ ClampState clamped;
+ DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
+ DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
+ DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
+ DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( clamped, ClampedToMin, TEST_LOCATION );
+ DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
+ DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( clamped, ClampedToMax, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP");
+
+ RulerPtr rulerNormal = new FixedRuler( 25.0f );
+ rulerNormal->SetDomain( RulerDomain(10.0f, 90.0f, true) );
+
+ unsigned int volume;
+ float position;
+
+ position = rulerNormal->GetPositionFromPage(1, volume, true);
+ DALI_TEST_EQUALS( position, 35.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
+
+ 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;
+}
+
+int UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP");
+
+ RulerPtr defaultRuler = new DefaultRuler();
+ DALI_TEST_CHECK( defaultRuler );
+ DALI_TEST_EQUALS( defaultRuler->GetTotalPages(), 1u, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP");
+
+ RulerPtr defaultRuler = new DefaultRuler();
+ DALI_TEST_CHECK( defaultRuler );
+ DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(100.0f, true), 0u, TEST_LOCATION);
+ DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(-300.0f, false), 0u, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP");
+
+ RulerPtr defaultRuler = new DefaultRuler();
+ DALI_TEST_CHECK( defaultRuler );
+
+ unsigned int volume;
+ DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(0, volume, true), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
+
+ DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(3, volume, false), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewDefaultRulerSnapP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerSnapP");
+
+ RulerPtr defaultRuler = new DefaultRuler();
+ DALI_TEST_CHECK( defaultRuler );
+
+ DALI_TEST_EQUALS( defaultRuler->Snap(50.0f, 0.5f), 50.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( defaultRuler->Snap(-120.0f, 1.0f), -120.0f, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP");
+
+ RulerPtr fixedRuler = new FixedRuler( 100.0f );
+ fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
+
+ fixedRuler->Enable();
+ DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 4u, TEST_LOCATION);
+
+ fixedRuler->Disable();
+ DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 1u, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP");
+
+ RulerPtr fixedRuler = new FixedRuler( 100.0f );
+ fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
+
+ fixedRuler->Enable();
+ DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 3u, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 1u, 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);
+
+ // 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;
+}
+
+int UtcDaliToolkitScrollViewFixedRulerSnapP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitScrollViewFixedRulerSnapP");
+
+ RulerPtr fixedRuler = new FixedRuler( 100.0f );
+ fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
+
+ DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.0f), -100.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.0f), -100.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.0f), -200.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.0f), -500.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.0f), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.0f), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.0f), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.0f), 100.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.0f), 100.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.0f), 200.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.0f), 600.0f, TEST_LOCATION);
+
+ DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.5f), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.5f), -100.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.5f), -100.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.5f), -500.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.5f), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.5f), 100.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.5f), 100.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.5f), 100.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.5f), 100.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.5f), 300.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.5f), 600.0f, TEST_LOCATION);
+
+ DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 1.0f), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 1.0f), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 1.0f), -100.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 1.0f), -400.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 1.0f), 100.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 1.0f), 100.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 1.0f), 100.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 1.0f), 200.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 1.0f), 200.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 1.0f), 300.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 1.0f), 700.0f, TEST_LOCATION);
+
+ 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 );
+