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=fa269404a045aad63f0209ab42d6e510f0ae4b7f;hp=fdd75ecfe001ac58c771c816cd5291818b603546;hb=HEAD;hpb=d5e3ed5f5b1c8fdba3ae97ead8729620f54b3836 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ScrollViewEffect.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ScrollViewEffect.cpp index fdd75ec..147df63 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ScrollViewEffect.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ScrollViewEffect.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,17 +15,16 @@ * */ -#include #include +#include // Need to override adaptor classes for toolkit test harness, so include // test harness headers before dali headers. #include -#include #include +#include #include -#include using namespace Dali; using namespace Toolkit; @@ -42,17 +41,7 @@ void utc_dali_toolkit_scroll_view_effect_cleanup(void) namespace { -static bool gObjectCreatedCallBackCalled; - -static void TestCallback(BaseHandle handle) -{ - gObjectCreatedCallBackCalled = true; -} - -const int MILLISECONDS_PER_SECOND = 1000; -const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS) -const int RENDER_ANIMATION_TEST_DURATION_MS = 1000; ///< 1000ms to test animation -const int RENDER_DELAY_SCROLL = 1000; ///< duration to wait for any scroll to complete. +const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS) /* * Simulate time passed by. @@ -67,7 +56,7 @@ int Wait(ToolkitTestApplication& application, int duration = 0) { int time = 0; - for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++) + for(int i = 0; i <= (duration / RENDER_FRAME_INTERVAL); i++) { application.SendNotification(); application.Render(RENDER_FRAME_INTERVAL); @@ -90,28 +79,25 @@ RulerPtr CreateRuler(float gridSize = 0.0f) { if(gridSize <= Math::MACHINE_EPSILON_0) { - return new DefaultRuler(); + return new DefaultRuler(); } return new FixedRuler(gridSize); } // Callback probes. -static bool gOnScrollStartCalled; ///< Whether the OnScrollStart signal was invoked. -static bool gOnScrollUpdateCalled; ///< Whether the OnScrollUpdate signal was invoked. -static bool gOnScrollCompleteCalled; ///< Whether the OnScrollComplete signal was invoked. -static bool gOnScrollClampedCalled; ///< Whether the OnScrollClamped signal was invoked. -static bool gOnSnapStartCalled; ///< Whether the OnSnapStart signal was invoked. -static ClampState3 gLastClampPosition; ///< Clamping information from OnScrollClampedEvent. -static SnapType gLastSnapType; ///< Snaping information from SnapEvent. -static Vector3 gConstraintResult; ///< Result from constraint. +static bool gOnScrollStartCalled; ///< Whether the OnScrollStart signal was invoked. +static bool gOnScrollUpdateCalled; ///< Whether the OnScrollUpdate signal was invoked. +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 gPages; ///< Keeps track of all the pages for applying effects. +typedef std::vector::iterator ActorIter; static void ResetScrollCallbackResults() { - gOnScrollStartCalled = false; - gOnScrollUpdateCalled = false; + gOnScrollStartCalled = false; + gOnScrollUpdateCalled = false; gOnScrollCompleteCalled = false; } @@ -120,7 +106,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; } @@ -130,7 +116,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; } @@ -140,47 +126,29 @@ 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; } -/** - * Invoked when scrolling clamped. - * - * @param[in] event The position/scale/rotation axes that were clamped. - */ -static void OnScrollClamped( const ScrollView::ClampEvent& event ) -{ - gOnScrollClampedCalled = true; - gLastClampPosition = event.position; -} - -/** - * Invoked when a snap or flick started. - * - * @param[in] event The type of snap and the target position/scale/rotation. - */ -static void OnSnapStart( const ScrollView::SnapEvent& event ) +ScrollView SetupTestScrollView(Integration::Scene scene, int rows, int columns, Vector2 size) { - gOnSnapStartCalled = true; - gLastSnapType = event.type; -} + Constraint constraint; -ScrollView SetupTestScrollView(int rows, int columns, Vector2 size) -{ ScrollView scrollView = ScrollView::New(); - scrollView.SetSize(size); - scrollView.SetAnchorPoint(AnchorPoint::CENTER); - scrollView.SetParentOrigin(ParentOrigin::CENTER); - scrollView.ApplyConstraint( Constraint::New( Dali::Actor::SIZE, Dali::ParentSource( Dali::Actor::SIZE ), Dali::EqualToConstraint() ) ); - // Disable Refresh signal (TET environment cannot use adaptor's Timer) + scrollView.SetProperty(Actor::Property::SIZE, size); + scrollView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + scrollView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + + constraint = Constraint::New(scrollView, Dali::Actor::Property::SIZE, Dali::EqualToConstraint()); + constraint.AddSource(Dali::ParentSource(Dali::Actor::Property::SIZE)); + constraint.Apply(); + scrollView.SetWrapMode(false); - scrollView.SetRefreshInterval(0); - scrollView.ScrollStartedSignal().Connect( &OnScrollStart ); - scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate ); - scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete ); - Stage::GetCurrent().Add( scrollView ); + scrollView.ScrollStartedSignal().Connect(&OnScrollStart); + scrollView.ScrollUpdatedSignal().Connect(&OnScrollUpdate); + scrollView.ScrollCompletedSignal().Connect(&OnScrollComplete); + scene.Add(scrollView); RulerPtr rulerX = CreateRuler(size.width); RulerPtr rulerY = CreateRuler(size.height); if(columns > 1) @@ -200,27 +168,33 @@ ScrollView SetupTestScrollView(int rows, int columns, Vector2 size) rulerY->Disable(); } - scrollView.SetRulerX( rulerX ); - scrollView.SetRulerY( rulerY ); - Stage::GetCurrent().Add( scrollView ); + scrollView.SetRulerX(rulerX); + scrollView.SetRulerY(rulerY); + scene.Add(scrollView); Actor container = Actor::New(); - container.SetParentOrigin(ParentOrigin::CENTER); - container.SetAnchorPoint(AnchorPoint::CENTER); - container.SetSize( size ); - scrollView.Add( container ); - container.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); + container.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + container.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + container.SetProperty(Actor::Property::SIZE, size); + scrollView.Add(container); + + 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::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); - page.SetParentOrigin( ParentOrigin::CENTER ); - page.SetAnchorPoint( AnchorPoint::CENTER ); - page.SetPosition( column * size.x, row * size.y ); + + constraint = Constraint::New(page, Actor::Property::SIZE, EqualToConstraint()); + constraint.AddSource(Dali::ParentSource(Dali::Actor::Property::SIZE)); + constraint.Apply(); + page.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + page.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + page.SetProperty(Actor::Property::POSITION, Vector2(column * size.x, row * size.y)); container.Add(page); gPages.push_back(page); @@ -237,449 +211,86 @@ void CleanupTest() ResetScrollCallbackResults(); } -Actor AddActorToPage(Actor page, float x, float y, float cols, float rows) -{ - Stage stage = Stage::GetCurrent(); - Vector2 stageSize = stage.GetSize(); - - const float margin = 10.0f; - const Vector2 actorSize((stageSize.x / cols) - margin, (stageSize.y / rows) - margin); - - Actor actor = Actor::New(); - actor.SetParentOrigin( ParentOrigin::CENTER ); - actor.SetAnchorPoint( AnchorPoint::CENTER ); - - Vector3 position( margin * 0.5f + (actorSize.x + margin) * x - stageSize.width * 0.5f, - margin * 0.5f + (actorSize.y + margin) * y - stageSize.height * 0.5f, - 0.0f); - Vector3 positionEnd( margin * 0.5f + (actorSize.x + margin) * (x + cols) - stageSize.width * 0.5f - margin, - margin * 0.5f + (actorSize.y + margin) * (y + rows) - stageSize.height * 0.5f - margin, - 0.0f); - Vector3 size(positionEnd - position); - actor.SetPosition( position + size * 0.5f); - actor.SetSize( positionEnd - position ); - page.Add(actor); - return actor; -} - } // unnamed namespace - -int UtcDaliScrollViewCustomEffectSetup(void) -{ - tet_infoline(" UtcDaliScrollViewCustomEffectSetup"); - - ScrollViewCustomEffect effect; - - DALI_TEST_CHECK( !effect ); - - BaseHandle handle = ScrollViewCustomEffect::New(); - - DALI_TEST_CHECK( handle ); - - effect = ScrollViewCustomEffect::DownCast(handle); - - DALI_TEST_CHECK( effect ); - - END_TEST; -} - -int UtcDaliScrollViewCubeEffectSetup(void) -{ - tet_infoline(" UtcDaliScrollViewCubeEffectSetup"); - - ScrollViewCubeEffect effect; - - DALI_TEST_CHECK( !effect ); - - BaseHandle handle = ScrollViewCubeEffect::New(); - - DALI_TEST_CHECK( handle ); - - effect = ScrollViewCubeEffect::DownCast(handle); - - DALI_TEST_CHECK( effect ); - 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 UtcDaliScrollViewSlideEffectSetup(void) -{ - tet_infoline(" UtcDaliScrollViewSlideEffectSetup"); - - ScrollViewSlideEffect effect; - - DALI_TEST_CHECK( !effect ); - - BaseHandle handle = ScrollViewSlideEffect::New(); - - DALI_TEST_CHECK( handle ); - - effect = ScrollViewSlideEffect::DownCast(handle); - - DALI_TEST_CHECK( effect ); - END_TEST; -} - -int UtcDaliScrollViewTwistEffectSetup(void) -{ - tet_infoline(" UtcDaliScrollViewTwistEffectSetup"); - - ScrollViewTwistEffect effect; - - DALI_TEST_CHECK( !effect ); - - BaseHandle handle = ScrollViewTwistEffect::New(); - - DALI_TEST_CHECK( handle ); - - effect = ScrollViewTwistEffect::DownCast(handle); - - DALI_TEST_CHECK( effect ); - END_TEST; -} - -int UtcDaliScrollViewCubeEffectTest(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewCubeEffectTest"); - - Vector2 size = Stage::GetCurrent().GetSize(); - - ScrollView scrollView = SetupTestScrollView(1, 3, size); - Actor page = gPages[1]; - Wait(application, 500); - - ScrollViewCubeEffect effect = ScrollViewCubeEffect::New(); - scrollView.ApplyEffect(effect); - - Actor actor = AddActorToPage(page, 0.5f, 0.5f, 3, 3); - Wait(application); - Vector3 actorPrePosition = actor.GetCurrentPosition(); - - effect.ApplyToActor(actor, page, Vector3(-105.0f, 30.0f, -240.0f), Vector2(Math::PI * 0.5f, Math::PI * 0.5f), Vector2(0.25f, 0.25f) * size); - - Actor actor2 = AddActorToPage(page, 0.5f, 0.5f, 3, 3); - effect.ApplyToActor(actor2, Vector3(-105.0f, 30.0f, -240.0f), Vector2(Math::PI * 0.5f, Math::PI * 0.5f), Vector2(0.25f, 0.25f) * size); - - 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); - CleanupTest(); - 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::SIZE, ParentSource( Actor::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 UtcDaliScrollViewSlideEffectTest(void) +int UtcDaliScrollViewPagePathEffectSetup(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewSlideEffectTest"); + tet_infoline(" UtcDaliScrollViewPagePathEffectSetup"); - Vector2 size = Stage::GetCurrent().GetSize(); - Vector3 pageSize(size.x, size.y, 0.0f); + ScrollViewPagePathEffect effect; - ScrollView scrollView = SetupTestScrollView(1, 3, size); - Actor testPage = gPages[1]; - Wait(application, 500); - - ScrollViewSlideEffect effect = ScrollViewSlideEffect::New(); - effect.SetDelayReferenceOffset(pageSize * 0.25); - DALI_TEST_EQUALS(effect.GetDelayReferenceOffset(), pageSize * 0.25, Math::MACHINE_EPSILON_0, TEST_LOCATION); - effect.SetMaxDelayDuration(0.5f); - DALI_TEST_EQUALS(effect.GetMaxDelayDuration(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION); - effect.SetSlideDirection(false); - DALI_TEST_CHECK(!effect.GetSlideDirection()); - - scrollView.ApplyEffect(effect); - - Actor actor = AddActorToPage(testPage, 0.5f, 0.5f, 3, 3); - Wait(application); - Vector3 actorPrePosition = actor.GetCurrentPosition(); - - effect.ApplyToActor(actor, 0.0f, 0.5f); - - 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); - CleanupTest(); - END_TEST; -} + DALI_TEST_CHECK(!effect); -int UtcDaliScrollViewTwistEffectTest(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewTwistEffectTest"); + BaseHandle handle = ScrollViewPagePathEffect::New(Dali::Path::New(), Vector3::ZERO, Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3::ZERO, 0); - Vector2 size = Stage::GetCurrent().GetSize(); + DALI_TEST_CHECK(handle); - ScrollView scrollView = SetupTestScrollView(1, 3, size); - Actor testPage = gPages[1]; - Wait(application, 500); + effect = ScrollViewPagePathEffect::DownCast(handle); - ScrollViewTwistEffect effect = ScrollViewTwistEffect::New(); - float shrinkDist = 0.2f; - effect.SetMinimumDistanceForShrink(shrinkDist); - DALI_TEST_CHECK((shrinkDist - effect.GetMinimumDistanceForShrink()) < Math::MACHINE_EPSILON_0); - effect.EnableEffect(true); - scrollView.ApplyEffect(effect); - - Actor actor = AddActorToPage(testPage, 0.5f, 0.5f, 3, 3); - Wait(application); - Vector3 actorPrePosition = actor.GetCurrentPosition(); - - effect.ApplyToActor( actor, - true, - Vector2(Math::PI_2, Math::PI_2), - 0.0f); - - 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); - CleanupTest(); + DALI_TEST_CHECK(effect); END_TEST; } -int UtcDaliScrollViewCustomEffectTest(void) +int UtcDaliScrollViewPagePathEffectTest(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliScrollViewCustomEffectTest"); + tet_infoline(" UtcDaliScrollViewPagePathEffectTest"); - Vector2 size = Stage::GetCurrent().GetSize(); - Vector3 pageSize(size.x, size.y, 0.0f); + Vector2 size = application.GetScene().GetSize(); - ScrollView scrollView = SetupTestScrollView(1, 3, size); - Actor testPage = gPages[1]; + ScrollView scrollView = SetupTestScrollView(application.GetScene(), 1, 3, size); + Actor testPage = gPages[2]; Wait(application, 500); - Vector3 pageStartPos, pagePos; - pageStartPos = pagePos = testPage.GetCurrentPosition(); - //scrollView.RemoveConstraintsFromChildren(); - - ScrollViewCustomEffect effect = ScrollViewCustomEffect::DownCast(scrollView.ApplyEffect(ScrollView::PageEffectCarousel)); - - for(ActorIter pageIter = gPages.begin(); pageIter != gPages.end(); ++pageIter) - { - Actor page = *pageIter; - page.RemoveConstraints(); - page.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); - effect.ApplyToPage(page, pageSize); - } - Wait(application); - pagePos = testPage.GetCurrentPosition(); - DALI_TEST_EQUALS(pagePos, pageStartPos, Math::MACHINE_EPSILON_0, TEST_LOCATION); - - scrollView.ScrollTo(1); - while(!gOnScrollCompleteCalled) - { - Wait(application); - } - ResetScrollCallbackResults(); - // test that the first page has reached centre of screen - pagePos = testPage.GetCurrentPosition(); - DALI_TEST_EQUALS(pagePos, Vector3::ZERO, Math::MACHINE_EPSILON_0, TEST_LOCATION); - // scroll back to page 0 - scrollView.ScrollTo(0); - while(!gOnScrollCompleteCalled) - { - Wait(application); - } - ResetScrollCallbackResults(); - pagePos = testPage.GetCurrentPosition(); - DALI_TEST_EQUALS(pagePos, pageStartPos, Math::MACHINE_EPSILON_0, TEST_LOCATION); - - scrollView.RemoveEffect(effect); - - effect = ScrollViewCustomEffect::New(); - effect.SetPageTranslation(Vector3(20.0f, 20.0f, 5.0f)); - effect.SetPageTranslation(Vector3(20.0f, 20.0f, 5.0f), Vector3(20.0f, 20.0f, -5.0f)); - effect.SetPageTranslationIn(Vector3(20.0f, 20.0f, 5.0f)); - effect.SetPageTranslationOut(Vector3(20.0f, 20.0f, -5.0f)); - effect.SetPageTranslation(Vector3(20.0f, 0.0f, 0.0f)); - effect.SetSwingAngle(Math::PI, Vector3::YAXIS); - effect.SetPageSpacing(Vector2(20.0f, 20.0f)); + //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); + unsigned int pageCounter(0); for(ActorIter pageIter = gPages.begin(); pageIter != gPages.end(); ++pageIter) { Actor page = *pageIter; page.RemoveConstraints(); - page.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); - effect.ApplyToPage(page, pageSize); + Constraint constraint = Constraint::New(page, Actor::Property::SIZE, EqualToConstraint()); + constraint.AddSource(ParentSource(Actor::Property::SIZE)); + constraint.Apply(); + effect.ApplyToPage(page, pageCounter++); } Wait(application); - pagePos = testPage.GetCurrentPosition(); - DALI_TEST_EQUALS(pagePos, pageStartPos, Math::MACHINE_EPSILON_0, TEST_LOCATION); scrollView.ScrollTo(1); while(!gOnScrollCompleteCalled) { Wait(application); } - ResetScrollCallbackResults(); - // test that the first page has reached centre of screen - pagePos = testPage.GetCurrentPosition(); - DALI_TEST_EQUALS(pagePos, Vector3::ZERO, Math::MACHINE_EPSILON_0, TEST_LOCATION); - - // scroll back to page 0 - scrollView.ScrollTo(0); - while(!gOnScrollCompleteCalled) - { - Wait(application); - } - ResetScrollCallbackResults(); - pagePos = testPage.GetCurrentPosition(); - DALI_TEST_EQUALS(pagePos, pageStartPos, Math::MACHINE_EPSILON_0, TEST_LOCATION); - - scrollView.RemoveEffect(effect); - effect = ScrollViewCustomEffect::New(); - effect.SetSwingAngle(Math::PI, Vector3::YAXIS); - effect.SetSwingAnchor(AnchorPoint::CENTER_LEFT); - effect.SetPageTranslation(Vector3(size.x, size.y, 0)); - effect.SetOpacityThreshold(0.66f); - scrollView.ApplyEffect(effect); - - for(ActorIter pageIter = gPages.begin(); pageIter != gPages.end(); ++pageIter) - { - Actor page = *pageIter; - page.RemoveConstraints(); - page.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); - effect.ApplyToPage(page, pageSize); - } - Wait(application); - scrollView.ScrollTo(1); - while(!gOnScrollCompleteCalled) - { - Wait(application); - } - ResetScrollCallbackResults(); - // test that the first page has reached centre of screen - pagePos = testPage.GetCurrentPosition(); + // test that the test page has reached centre of screen + Vector3 pagePos = testPage.GetCurrentProperty(Actor::Property::POSITION); DALI_TEST_EQUALS(pagePos, Vector3::ZERO, Math::MACHINE_EPSILON_0, TEST_LOCATION); - // scroll back to page 0 - scrollView.ScrollTo(0); - while(!gOnScrollCompleteCalled) - { - Wait(application); - } - ResetScrollCallbackResults(); - pagePos = testPage.GetCurrentPosition(); - DALI_TEST_EQUALS(pagePos, pageStartPos, Math::MACHINE_EPSILON_0, TEST_LOCATION); - scrollView.RemoveEffect(effect); - - - effect.SetPageTranslateAlphaFunction(AlphaFunctions::Linear); - effect.SetPageTranslateAlphaFunction(AlphaFunctions::Linear, AlphaFunctions::Linear); - effect.SetPageTranslateAlphaFunctionIn(AlphaFunctions::Linear); - effect.SetPageTranslateAlphaFunctionOut(AlphaFunctions::Linear); - effect.SetGlobalPageRotation(Math::PI, Vector3::YAXIS); - effect.SetAngledOriginPageRotation(Vector3(Math::PI, Math::PI, 0.0f)); - effect.SetGlobalPageRotation(Math::PI, Vector3::YAXIS, Math::PI, Vector3::YAXIS); - effect.SetGlobalPageRotationIn(Math::PI, Vector3::YAXIS); - effect.SetGlobalPageRotationOut(Math::PI, Vector3::YAXIS); - effect.SetGlobalPageRotationOrigin(Vector3::ZERO); - effect.SetGlobalPageRotationOrigin(Vector3::ZERO, Vector3::ZERO); - effect.SetGlobalPageRotationOriginIn(Vector3::ZERO); - effect.SetGlobalPageRotationOriginOut(Vector3::ZERO); - effect.SetSwingAngle(Math::PI, Vector3::YAXIS); - effect.SetSwingAngle(Math::PI, Vector3::YAXIS, Math::PI, Vector3::YAXIS); - effect.SetSwingAngleIn(Math::PI, Vector3::YAXIS); - effect.SetSwingAngleOut(Math::PI, Vector3::YAXIS); - effect.SetSwingAngleAlphaFunction(AlphaFunctions::Linear); - effect.SetSwingAngleAlphaFunction(AlphaFunctions::Linear, AlphaFunctions::Linear); - effect.SetSwingAngleAlphaFunctionIn(AlphaFunctions::Linear); - effect.SetSwingAngleAlphaFunctionOut(AlphaFunctions::Linear); - effect.SetSwingAnchor(AnchorPoint::CENTER, AnchorPoint::CENTER_LEFT); - effect.SetSwingAnchorIn(AnchorPoint::CENTER); - effect.SetSwingAnchorOut(AnchorPoint::CENTER); - effect.SetSwingAnchorAlphaFunction(AlphaFunctions::Linear); - effect.SetSwingAnchorAlphaFunction(AlphaFunctions::Linear, AlphaFunctions::Linear); - effect.SetSwingAnchorAlphaFunctionIn(AlphaFunctions::Linear); - effect.SetSwingAnchorAlphaFunctionOut(AlphaFunctions::Linear); - effect.SetOpacityThreshold(0.5f); - effect.SetOpacityThreshold(0.5f, 0.5f); - effect.SetOpacityThresholdIn(0.5f); - effect.SetOpacityThresholdOut(0.5f); - effect.SetOpacityAlphaFunction(AlphaFunctions::Linear); - effect.SetOpacityAlphaFunction(AlphaFunctions::Linear, AlphaFunctions::Linear); - effect.SetOpacityAlphaFunctionIn(AlphaFunctions::Linear); - effect.SetOpacityAlphaFunctionOut(AlphaFunctions::Linear); CleanupTest(); END_TEST; }