X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-ScrollViewEffect.cpp;h=d7edf064720fc8e04e052725e152ec5c33340187;hp=5cda4972adb04bf22aac8481e733b598f1ddff65;hb=refs%2Fchanges%2F34%2F39034%2F20;hpb=b8d4bac83c801b93dc7b3298148864a4215e139f diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ScrollViewEffect.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ScrollViewEffect.cpp index 5cda497..d7edf06 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ScrollViewEffect.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ScrollViewEffect.cpp @@ -96,7 +96,8 @@ static bool gOnScrollUpdateCalled; ///< Whether the OnScrol static bool gOnScrollCompleteCalled; ///< Whether the OnScrollComplete signal was invoked. static Vector3 gConstraintResult; ///< Result from constraint. -static ActorContainer gPages; ///< Keeps track of all the pages for applying effects. +static std::vector< Actor > gPages; ///< Keeps track of all the pages for applying effects. +typedef std::vector< Actor >::iterator ActorIter; static void ResetScrollCallbackResults() { @@ -110,7 +111,7 @@ static void ResetScrollCallbackResults() * * @param[in] position The current scroll position. */ -static void OnScrollStart( const Vector3& position ) +static void OnScrollStart( const Vector2& position ) { gOnScrollStartCalled = true; } @@ -120,7 +121,7 @@ static void OnScrollStart( const Vector3& position ) * * @param[in] position The current scroll position. */ -static void OnScrollUpdate( const Vector3& position ) +static void OnScrollUpdate( const Vector2& position ) { gOnScrollUpdateCalled = true; } @@ -130,18 +131,24 @@ static void OnScrollUpdate( const Vector3& position ) * * @param[in] position The current scroll position. */ -static void OnScrollComplete( const Vector3& position ) +static void OnScrollComplete( const Vector2& position ) { gOnScrollCompleteCalled = true; } ScrollView SetupTestScrollView(int rows, int columns, Vector2 size) { + Constraint constraint; + ScrollView scrollView = ScrollView::New(); scrollView.SetSize(size); scrollView.SetAnchorPoint(AnchorPoint::CENTER); scrollView.SetParentOrigin(ParentOrigin::CENTER); - scrollView.ApplyConstraint( Constraint::New( Dali::Actor::Property::SIZE, Dali::ParentSource( Dali::Actor::Property::SIZE ), Dali::EqualToConstraint() ) ); + + constraint = Constraint::New( scrollView, Dali::Actor::Property::SIZE, Dali::EqualToConstraint() ); + constraint.AddSource( Dali::ParentSource( Dali::Actor::Property::SIZE ) ); + constraint.Apply(); + scrollView.SetWrapMode(false); scrollView.ScrollStartedSignal().Connect( &OnScrollStart ); scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate ); @@ -175,7 +182,10 @@ ScrollView SetupTestScrollView(int rows, int columns, Vector2 size) container.SetAnchorPoint(AnchorPoint::CENTER); container.SetSize( size ); scrollView.Add( container ); - container.ApplyConstraint( Constraint::New( Actor::Property::SIZE, ParentSource( Actor::Property::SIZE ), EqualToConstraint() ) ); + + constraint = Constraint::New( container, Actor::Property::SIZE, EqualToConstraint() ); + constraint.AddSource( Dali::ParentSource( Dali::Actor::Property::SIZE ) ); + constraint.Apply(); gPages.clear(); for(int row = 0;row( Actor::Property::SIZE, ParentSource( Actor::Property::SIZE ), EqualToConstraint() ) ); + + constraint = Constraint::New( page, Actor::Property::SIZE, EqualToConstraint() ); + constraint.AddSource( Dali::ParentSource( Dali::Actor::Property::SIZE ) ); + constraint.Apply(); page.SetParentOrigin( ParentOrigin::CENTER ); page.SetAnchorPoint( AnchorPoint::CENTER ); page.SetPosition( column * size.x, row * size.y ); @@ -249,24 +262,6 @@ int UtcDaliScrollViewCubeEffectSetup(void) END_TEST; } -int UtcDaliScrollViewSpiralEffectSetup(void) -{ - tet_infoline(" UtcDaliScrollViewSpiralEffectSetup"); - - ScrollViewPageSpiralEffect effect; - - DALI_TEST_CHECK( !effect ); - - BaseHandle handle = ScrollViewPageSpiralEffect::New(); - - DALI_TEST_CHECK( handle ); - - effect = ScrollViewPageSpiralEffect::DownCast(handle); - - DALI_TEST_CHECK( effect ); - END_TEST; -} - int UtcDaliScrollViewCubeEffectTest(void) { ToolkitTestApplication application; @@ -303,79 +298,6 @@ int UtcDaliScrollViewCubeEffectTest(void) END_TEST; } - -int UtcDaliScrollViewSpiralEffectTest(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewSpiralEffectTest"); - - Vector2 size = Stage::GetCurrent().GetSize(); - - ScrollView scrollView = SetupTestScrollView(1, 3, size); - Actor testPage = gPages[1]; - Wait(application, 500); - - ScrollViewPageSpiralEffect effect = ScrollViewPageSpiralEffect::New(); - scrollView.ApplyEffect(effect); - - for(ActorIter pageIter = gPages.begin(); pageIter != gPages.end(); ++pageIter) - { - Actor page = *pageIter; - page.RemoveConstraints(); - page.ApplyConstraint( Constraint::New( Actor::Property::SIZE, ParentSource( Actor::Property::SIZE ), EqualToConstraint() ) ); - effect.ApplyToPage(page, Vector2(Math::PI_2, 0.0f)); - } - Wait(application); - - scrollView.ScrollTo(1); - while(!gOnScrollCompleteCalled) - { - Wait(application); - } - // test that the first page has reached centre of screen - Vector3 pagePos = testPage.GetCurrentPosition(); - DALI_TEST_EQUALS(pagePos, Vector3::ZERO, Math::MACHINE_EPSILON_0, TEST_LOCATION); - CleanupTest(); - END_TEST; -} - -int UtcDaliScrollViewPageCubeEffectSetup(void) -{ - tet_infoline(" UtcDaliScrollViewPageCubeEffectSetup"); - - ScrollViewPageCubeEffect effect; - - DALI_TEST_CHECK( !effect ); - - BaseHandle handle = ScrollViewPageCubeEffect::New(); - - DALI_TEST_CHECK( handle ); - - effect = ScrollViewPageCubeEffect::DownCast(handle); - - DALI_TEST_CHECK( effect ); - END_TEST; -} - - -int UtcDaliScrollViewPageCarouselEffectSetup(void) -{ - tet_infoline(" UtcDaliScrollViewCarouselEffectSetup"); - - ScrollViewPageCarouselEffect effect; - - DALI_TEST_CHECK( !effect ); - - BaseHandle handle = ScrollViewPageCarouselEffect::New(); - - DALI_TEST_CHECK( handle ); - - effect = ScrollViewPageCarouselEffect::DownCast(handle); - - DALI_TEST_CHECK( effect ); - END_TEST; -} - int UtcDaliScrollViewCarouselEffectSetup(void) { tet_infoline(" UtcDaliScrollViewCarouselEffectSetup"); @@ -394,29 +316,10 @@ int UtcDaliScrollViewCarouselEffectSetup(void) END_TEST; } -int UtcDaliScrollViewDepthEffectSetup(void) -{ - tet_infoline(" UtcDaliScrollViewDepthEffectSetup"); - - ScrollViewDepthEffect effect; - - DALI_TEST_CHECK( !effect ); - - BaseHandle handle = ScrollViewDepthEffect::New(); - - DALI_TEST_CHECK( handle ); - - effect = ScrollViewDepthEffect::DownCast(handle); - - DALI_TEST_CHECK( effect ); - END_TEST; -} - - -int UtcDaliScrollViewPageCubeEffectTest(void) +int UtcDaliScrollViewCarouselEffectTest(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewPageCubeEffectTest"); + tet_infoline(" UtcDaliScrollViewCarouselEffectTest"); Vector2 size = Stage::GetCurrent().GetSize(); @@ -424,69 +327,50 @@ int UtcDaliScrollViewPageCubeEffectTest(void) Actor testPage = gPages[1]; Wait(application, 500); - ScrollViewPageCubeEffect effect = ScrollViewPageCubeEffect::New(); + ScrollViewCarouselEffect effect = ScrollViewCarouselEffect::New(); scrollView.ApplyEffect(effect); - for(ActorIter pageIter = gPages.begin(); pageIter != gPages.end(); ++pageIter) - { - Actor page = *pageIter; - page.RemoveConstraints(); - page.ApplyConstraint( Constraint::New( Actor::Property::SIZE, ParentSource( Actor::Property::SIZE ), EqualToConstraint() ) ); - effect.ApplyToPage(page, Vector2(Math::PI_2, 0.0f)); - } + Actor actor = AddActorToPage(testPage, 0.5f, 0.5f, 3, 3); Wait(application); + Vector3 actorPrePosition = actor.GetCurrentPosition(); - scrollView.ScrollTo(1); + effect.ApplyToActor( actor, Vector2(1.2f, 1.2f) ); + + scrollView.ScrollTo(Vector2(size.x, 0.0f), 0.5f, DirectionBiasNone, DirectionBiasNone); while(!gOnScrollCompleteCalled) { Wait(application); } // test that the first page has reached centre of screen - Vector3 pagePos = testPage.GetCurrentPosition(); - DALI_TEST_EQUALS(pagePos, Vector3::ZERO, Math::MACHINE_EPSILON_0, TEST_LOCATION); + Vector3 actorPostPosition = actor.GetCurrentPosition(); + // just check the actor has moved + DALI_TEST_CHECK((actorPostPosition - actorPrePosition).Length() > Math::MACHINE_EPSILON_1); CleanupTest(); END_TEST; } -int UtcDaliScrollViewPageCarouselEffectTest(void) +int UtcDaliScrollViewDepthEffectSetup(void) { - ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewPageCarouselEffectTest"); + tet_infoline(" UtcDaliScrollViewDepthEffectSetup"); - Vector2 size = Stage::GetCurrent().GetSize(); + ScrollViewDepthEffect effect; - ScrollView scrollView = SetupTestScrollView(1, 3, size); - Actor testPage = gPages[1]; - Wait(application, 500); + DALI_TEST_CHECK( !effect ); - ScrollViewPageCarouselEffect effect = ScrollViewPageCarouselEffect::New(); - scrollView.ApplyEffect(effect); + BaseHandle handle = ScrollViewDepthEffect::New(); - for(ActorIter pageIter = gPages.begin(); pageIter != gPages.end(); ++pageIter) - { - Actor page = *pageIter; - page.RemoveConstraints(); - page.ApplyConstraint( Constraint::New( Actor::Property::SIZE, ParentSource( Actor::Property::SIZE ), EqualToConstraint() ) ); - effect.ApplyToPage(page); - } - Wait(application); + DALI_TEST_CHECK( handle ); - scrollView.ScrollTo(1, 0.5f, DirectionBiasNone); - while(!gOnScrollCompleteCalled) - { - Wait(application); - } - // test that the first page has reached centre of screen - Vector3 pagePos = testPage.GetCurrentPosition(); - DALI_TEST_EQUALS(pagePos, Vector3::ZERO, Math::MACHINE_EPSILON_0, TEST_LOCATION); - CleanupTest(); + effect = ScrollViewDepthEffect::DownCast(handle); + + DALI_TEST_CHECK( effect ); END_TEST; } -int UtcDaliScrollViewCarouselEffectTest(void) +int UtcDaliScrollViewDepthEffectTest(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewCarouselEffectTest"); + tet_infoline(" UtcDaliScrollViewDepthEffectTest"); Vector2 size = Stage::GetCurrent().GetSize(); @@ -494,16 +378,21 @@ int UtcDaliScrollViewCarouselEffectTest(void) Actor testPage = gPages[1]; Wait(application, 500); - ScrollViewCarouselEffect effect = ScrollViewCarouselEffect::New(); + ScrollViewDepthEffect effect = ScrollViewDepthEffect::New(); scrollView.ApplyEffect(effect); Actor actor = AddActorToPage(testPage, 0.5f, 0.5f, 3, 3); Wait(application); Vector3 actorPrePosition = actor.GetCurrentPosition(); - effect.ApplyToActor( actor, Vector2(1.2f, 1.2f) ); + const Vector2 positionExtent(0.5f, 2.5f); + const Vector2 offsetExtent(1.0f, 1.0f); + const float positionScale(1.5f); + const float scaleExtent(0.5f); + + effect.ApplyToActor( actor, positionExtent, offsetExtent, positionScale, scaleExtent ); - scrollView.ScrollTo(Vector3(size.x, 0.0f, 0.0f), 0.5f, DirectionBiasNone, DirectionBiasNone); + scrollView.ScrollTo(1); while(!gOnScrollCompleteCalled) { Wait(application); @@ -516,40 +405,85 @@ int UtcDaliScrollViewCarouselEffectTest(void) END_TEST; } -int UtcDaliScrollViewDepthEffectTest(void) + +int UtcDaliScrollViewPagePathEffectSetup(void) +{ + tet_infoline(" UtcDaliScrollViewPagePathEffectSetup"); + + ScrollViewPagePathEffect effect; + + DALI_TEST_CHECK( !effect ); + + BaseHandle handle = ScrollViewPagePathEffect::New(Dali::Path::New(), Vector3::ZERO,Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3::ZERO,0); + + DALI_TEST_CHECK( handle ); + + effect = ScrollViewPagePathEffect::DownCast(handle); + + DALI_TEST_CHECK( effect ); + END_TEST; +} + +int UtcDaliScrollViewPagePathEffectTest(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewDepthEffectTest"); + tet_infoline(" UtcDaliScrollViewPagePathEffectTest"); Vector2 size = Stage::GetCurrent().GetSize(); ScrollView scrollView = SetupTestScrollView(1, 3, size); - Actor testPage = gPages[1]; + Actor testPage = gPages[2]; Wait(application, 500); - ScrollViewDepthEffect effect = ScrollViewDepthEffect::New(); + //Create path + float xHalfSize( size.x * 0.5f); + + Dali::Path path = Dali::Path::New(); + Dali::Property::Array points; + points.resize(3); + points[0] = Vector3( xHalfSize, 0.0f, -xHalfSize); + points[1] = Vector3( 0.0f, 0.0f, 0.0f ); + points[2] = Vector3( -xHalfSize, 0.0f, -xHalfSize); + path.SetProperty( Path::Property::POINTS, points ); + + Dali::Property::Array controlPoints; + controlPoints.resize(4); + controlPoints[0] = Vector3( xHalfSize, 0.0f, 0.0f ); + controlPoints[1] = Vector3( xHalfSize, 0.0f, 0.0f ); + controlPoints[2] = Vector3(-xHalfSize, 0.0f, 0.0f ); + controlPoints[3] = Vector3(-xHalfSize, 0.0f, 0.0f ); + path.SetProperty( Path::Property::CONTROL_POINTS, controlPoints ); + + ScrollViewPagePathEffect effect = ScrollViewPagePathEffect::New(path, + Vector3::ZERO, + Toolkit::ScrollView::Property::SCROLL_FINAL_X, + Vector3(size.x,size.y,0.0f), + 3); scrollView.ApplyEffect(effect); - Actor actor = AddActorToPage(testPage, 0.5f, 0.5f, 3, 3); + unsigned int pageCounter(0); + for(ActorIter pageIter = gPages.begin(); pageIter != gPages.end(); ++pageIter) + { + Actor page = *pageIter; + page.RemoveConstraints(); + Constraint constraint = Constraint::New( page, Actor::Property::SIZE, EqualToConstraint() ); + constraint.AddSource( ParentSource( Actor::Property::SIZE ) ); + constraint.Apply(); + effect.ApplyToPage(page, pageCounter++); + } Wait(application); - Vector3 actorPrePosition = actor.GetCurrentPosition(); - - const Vector2 positionExtent(0.5f, 2.5f); - const Vector2 offsetExtent(1.0f, 1.0f); - const float positionScale(1.5f); - const float scaleExtent(0.5f); - - effect.ApplyToActor( actor, positionExtent, offsetExtent, positionScale, scaleExtent ); scrollView.ScrollTo(1); while(!gOnScrollCompleteCalled) { Wait(application); } - // test that the first page has reached centre of screen - Vector3 actorPostPosition = actor.GetCurrentPosition(); - // just check the actor has moved - DALI_TEST_CHECK((actorPostPosition - actorPrePosition).Length() > Math::MACHINE_EPSILON_1); + + // test that the test page has reached centre of screen + Vector3 pagePos = testPage.GetCurrentPosition(); + DALI_TEST_EQUALS(pagePos, Vector3::ZERO, Math::MACHINE_EPSILON_0, TEST_LOCATION); + CleanupTest(); END_TEST; } +