2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 #include <dali/public-api/dali-core.h>
24 #include <dali-toolkit/dali-toolkit.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/integration-api/events/pan-gesture-event.h>
28 #include <dali-toolkit-test-suite-utils.h>
31 using namespace Toolkit;
33 static void Startup();
34 static void Cleanup();
38 static bool gObjectCreatedCallBackCalled;
40 static void TestCallback(BaseHandle handle)
42 gObjectCreatedCallBackCalled = true;
47 void (*tet_startup)() = Startup;
48 void (*tet_cleanup)() = Cleanup;
51 static void UtcDaliScrollViewCustomEffectSetup();
52 static void UtcDaliScrollViewCubeEffectSetup();
53 static void UtcDaliScrollViewPageCubeEffectSetup();
54 static void UtcDaliScrollViewSpiralEffectSetup();
55 static void UtcDaliScrollViewPageCarouselEffectSetup();
56 static void UtcDaliScrollViewCarouselEffectSetup();
57 static void UtcDaliScrollViewDepthEffectSetup();
58 static void UtcDaliScrollViewSlideEffectSetup();
59 static void UtcDaliScrollViewTwistEffectSetup();
61 static void UtcDaliScrollViewCubeEffectTest();
62 static void UtcDaliScrollViewPageCubeEffectTest();
63 static void UtcDaliScrollViewSpiralEffectTest();
64 static void UtcDaliScrollViewPageCarouselEffectTest();
65 static void UtcDaliScrollViewCarouselEffectTest();
66 static void UtcDaliScrollViewDepthEffectTest();
67 static void UtcDaliScrollViewSlideEffectTest();
68 static void UtcDaliScrollViewTwistEffectTest();
69 static void UtcDaliScrollViewCustomEffectTest();
72 POSITIVE_TC_IDX = 0x01,
76 // Add test functionality for all APIs in the class (Positive and Negative)
78 struct tet_testlist tet_testlist[] = {
79 { UtcDaliScrollViewCustomEffectSetup, POSITIVE_TC_IDX },
80 { UtcDaliScrollViewCubeEffectSetup, POSITIVE_TC_IDX },
81 { UtcDaliScrollViewPageCubeEffectSetup, POSITIVE_TC_IDX },
82 { UtcDaliScrollViewSpiralEffectSetup, POSITIVE_TC_IDX },
83 { UtcDaliScrollViewPageCarouselEffectSetup, POSITIVE_TC_IDX },
84 { UtcDaliScrollViewCarouselEffectSetup, POSITIVE_TC_IDX },
85 { UtcDaliScrollViewDepthEffectSetup, POSITIVE_TC_IDX },
86 { UtcDaliScrollViewSlideEffectSetup, POSITIVE_TC_IDX },
87 { UtcDaliScrollViewTwistEffectSetup, POSITIVE_TC_IDX },
88 { UtcDaliScrollViewCubeEffectTest, POSITIVE_TC_IDX },
89 { UtcDaliScrollViewPageCubeEffectTest, POSITIVE_TC_IDX },
90 { UtcDaliScrollViewSpiralEffectTest, POSITIVE_TC_IDX },
91 { UtcDaliScrollViewPageCarouselEffectTest, POSITIVE_TC_IDX },
92 { UtcDaliScrollViewCarouselEffectTest, POSITIVE_TC_IDX },
93 { UtcDaliScrollViewDepthEffectTest, POSITIVE_TC_IDX },
94 { UtcDaliScrollViewSlideEffectTest, POSITIVE_TC_IDX },
95 { UtcDaliScrollViewTwistEffectTest, POSITIVE_TC_IDX },
96 { UtcDaliScrollViewCustomEffectTest, POSITIVE_TC_IDX },
101 namespace // unnamed namespace
104 const int MILLISECONDS_PER_SECOND = 1000;
105 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
106 const int RENDER_ANIMATION_TEST_DURATION_MS = 1000; ///< 1000ms to test animation
107 const int RENDER_DELAY_SCROLL = 1000; ///< duration to wait for any scroll to complete.
110 * Simulate time passed by.
112 * @note this will always process at least 1 frame (1/60 sec)
114 * @param application Test application instance
115 * @param duration Time to pass in milliseconds.
116 * @return The actual time passed in milliseconds
118 int Wait(ToolkitTestApplication& application, int duration = 0)
122 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
124 application.SendNotification();
125 application.Render(RENDER_FRAME_INTERVAL);
126 time += RENDER_FRAME_INTERVAL;
133 * Creates a Ruler that snaps to a specified grid size.
134 * If that grid size is 0.0 then this ruler does not
137 * @param[in] gridSize (optional) The grid size for the ruler,
138 * (Default = 0.0 i.e. no snapping)
139 * @return The ruler is returned.
141 RulerPtr CreateRuler(float gridSize = 0.0f)
143 if(gridSize <= Math::MACHINE_EPSILON_0)
145 return new DefaultRuler();
147 return new FixedRuler(gridSize);
152 static bool gOnScrollStartCalled; ///< Whether the OnScrollStart signal was invoked.
153 static bool gOnScrollUpdateCalled; ///< Whether the OnScrollUpdate signal was invoked.
154 static bool gOnScrollCompleteCalled; ///< Whether the OnScrollComplete signal was invoked.
155 static bool gOnScrollClampedCalled; ///< Whether the OnScrollClamped signal was invoked.
156 static bool gOnSnapStartCalled; ///< Whether the OnSnapStart signal was invoked.
157 static ClampState3 gLastClampPosition; ///< Clamping information from OnScrollClampedEvent.
158 static SnapType gLastSnapType; ///< Snaping information from SnapEvent.
159 static Vector3 gConstraintResult; ///< Result from constraint.
161 static ActorContainer gPages; ///< Keeps track of all the pages for applying effects.
163 static void ResetScrollCallbackResults()
165 gOnScrollStartCalled = false;
166 gOnScrollUpdateCalled = false;
167 gOnScrollCompleteCalled = false;
171 * Invoked when scrolling starts.
173 * @param[in] position The current scroll position.
175 static void OnScrollStart( const Vector3& position )
177 gOnScrollStartCalled = true;
181 * Invoked when scrolling updates (via dragging)
183 * @param[in] position The current scroll position.
185 static void OnScrollUpdate( const Vector3& position )
187 gOnScrollUpdateCalled = true;
191 * Invoked when scrolling finishes
193 * @param[in] position The current scroll position.
195 static void OnScrollComplete( const Vector3& position )
197 gOnScrollCompleteCalled = true;
201 * Invoked when scrolling clamped.
203 * @param[in] event The position/scale/rotation axes that were clamped.
205 static void OnScrollClamped( const ScrollView::ClampEvent& event )
207 gOnScrollClampedCalled = true;
208 gLastClampPosition = event.position;
212 * Invoked when a snap or flick started.
214 * @param[in] event The type of snap and the target position/scale/rotation.
216 static void OnSnapStart( const ScrollView::SnapEvent& event )
218 gOnSnapStartCalled = true;
219 gLastSnapType = event.type;
222 ScrollView SetupTestScrollView(int rows, int columns, Vector2 size)
224 ScrollView scrollView = ScrollView::New();
225 scrollView.SetSize(size);
226 scrollView.SetAnchorPoint(AnchorPoint::CENTER);
227 scrollView.SetParentOrigin(ParentOrigin::CENTER);
228 scrollView.ApplyConstraint( Constraint::New<Dali::Vector3>( Dali::Actor::SIZE, Dali::ParentSource( Dali::Actor::SIZE ), Dali::EqualToConstraint() ) );
229 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
230 scrollView.SetWrapMode(false);
231 scrollView.SetRefreshInterval(0);
232 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
233 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
234 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
235 Stage::GetCurrent().Add( scrollView );
236 RulerPtr rulerX = CreateRuler(size.width);
237 RulerPtr rulerY = CreateRuler(size.height);
240 rulerX->SetDomain(RulerDomain(0.0f, size.width * columns));
248 rulerY->SetDomain(RulerDomain(0.0f, size.width * rows));
255 scrollView.SetRulerX( rulerX );
256 scrollView.SetRulerY( rulerY );
257 Stage::GetCurrent().Add( scrollView );
259 Actor container = Actor::New();
260 container.SetParentOrigin(ParentOrigin::CENTER);
261 container.SetAnchorPoint(AnchorPoint::CENTER);
262 container.SetSize( size );
263 scrollView.Add( container );
264 container.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
267 for(int row = 0;row<rows;row++)
269 for(int column = 0;column<columns;column++)
271 Actor page = Actor::New();
272 page.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
273 page.SetParentOrigin( ParentOrigin::CENTER );
274 page.SetAnchorPoint( AnchorPoint::CENTER );
275 page.SetPosition( column * size.x, row * size.y );
278 gPages.push_back(page);
282 ResetScrollCallbackResults();
289 ResetScrollCallbackResults();
292 Actor AddActorToPage(Actor page, float x, float y, float cols, float rows)
294 Stage stage = Stage::GetCurrent();
295 Vector2 stageSize = stage.GetSize();
297 const float margin = 10.0f;
298 const Vector2 actorSize((stageSize.x / cols) - margin, (stageSize.y / rows) - margin);
300 Actor actor = Actor::New();
301 actor.SetParentOrigin( ParentOrigin::CENTER );
302 actor.SetAnchorPoint( AnchorPoint::CENTER );
304 Vector3 position( margin * 0.5f + (actorSize.x + margin) * x - stageSize.width * 0.5f,
305 margin * 0.5f + (actorSize.y + margin) * y - stageSize.height * 0.5f,
307 Vector3 positionEnd( margin * 0.5f + (actorSize.x + margin) * (x + cols) - stageSize.width * 0.5f - margin,
308 margin * 0.5f + (actorSize.y + margin) * (y + rows) - stageSize.height * 0.5f - margin,
310 Vector3 size(positionEnd - position);
311 actor.SetPosition( position + size * 0.5f);
312 actor.SetSize( positionEnd - position );
317 } // unnamed namespace
319 // Called only once before first test is run.
320 static void Startup()
324 // Called only once after last test is run
325 static void Cleanup()
329 static void UtcDaliScrollViewCustomEffectSetup()
331 tet_infoline(" UtcDaliScrollViewCustomEffectSetup");
333 ScrollViewCustomEffect effect;
335 DALI_TEST_CHECK( !effect );
337 BaseHandle handle = ScrollViewCustomEffect::New();
339 DALI_TEST_CHECK( handle );
341 effect = ScrollViewCustomEffect::DownCast(handle);
343 DALI_TEST_CHECK( effect );
347 static void UtcDaliScrollViewCubeEffectSetup()
349 tet_infoline(" UtcDaliScrollViewCubeEffectSetup");
351 ScrollViewCubeEffect effect;
353 DALI_TEST_CHECK( !effect );
355 BaseHandle handle = ScrollViewCubeEffect::New();
357 DALI_TEST_CHECK( handle );
359 effect = ScrollViewCubeEffect::DownCast(handle);
361 DALI_TEST_CHECK( effect );
364 static void UtcDaliScrollViewPageCubeEffectSetup()
366 tet_infoline(" UtcDaliScrollViewPageCubeEffectSetup");
368 ScrollViewPageCubeEffect effect;
370 DALI_TEST_CHECK( !effect );
372 BaseHandle handle = ScrollViewPageCubeEffect::New();
374 DALI_TEST_CHECK( handle );
376 effect = ScrollViewPageCubeEffect::DownCast(handle);
378 DALI_TEST_CHECK( effect );
381 static void UtcDaliScrollViewSpiralEffectSetup()
383 tet_infoline(" UtcDaliScrollViewSpiralEffectSetup");
385 ScrollViewPageSpiralEffect effect;
387 DALI_TEST_CHECK( !effect );
389 BaseHandle handle = ScrollViewPageSpiralEffect::New();
391 DALI_TEST_CHECK( handle );
393 effect = ScrollViewPageSpiralEffect::DownCast(handle);
395 DALI_TEST_CHECK( effect );
398 static void UtcDaliScrollViewPageCarouselEffectSetup()
400 tet_infoline(" UtcDaliScrollViewCarouselEffectSetup");
402 ScrollViewPageCarouselEffect effect;
404 DALI_TEST_CHECK( !effect );
406 BaseHandle handle = ScrollViewPageCarouselEffect::New();
408 DALI_TEST_CHECK( handle );
410 effect = ScrollViewPageCarouselEffect::DownCast(handle);
412 DALI_TEST_CHECK( effect );
415 static void UtcDaliScrollViewCarouselEffectSetup()
417 tet_infoline(" UtcDaliScrollViewCarouselEffectSetup");
419 ScrollViewCarouselEffect effect;
421 DALI_TEST_CHECK( !effect );
423 BaseHandle handle = ScrollViewCarouselEffect::New();
425 DALI_TEST_CHECK( handle );
427 effect = ScrollViewCarouselEffect::DownCast(handle);
429 DALI_TEST_CHECK( effect );
432 static void UtcDaliScrollViewDepthEffectSetup()
434 tet_infoline(" UtcDaliScrollViewDepthEffectSetup");
436 ScrollViewDepthEffect effect;
438 DALI_TEST_CHECK( !effect );
440 BaseHandle handle = ScrollViewDepthEffect::New();
442 DALI_TEST_CHECK( handle );
444 effect = ScrollViewDepthEffect::DownCast(handle);
446 DALI_TEST_CHECK( effect );
449 static void UtcDaliScrollViewSlideEffectSetup()
451 tet_infoline(" UtcDaliScrollViewSlideEffectSetup");
453 ScrollViewSlideEffect effect;
455 DALI_TEST_CHECK( !effect );
457 BaseHandle handle = ScrollViewSlideEffect::New();
459 DALI_TEST_CHECK( handle );
461 effect = ScrollViewSlideEffect::DownCast(handle);
463 DALI_TEST_CHECK( effect );
466 static void UtcDaliScrollViewTwistEffectSetup()
468 tet_infoline(" UtcDaliScrollViewTwistEffectSetup");
470 ScrollViewTwistEffect effect;
472 DALI_TEST_CHECK( !effect );
474 BaseHandle handle = ScrollViewTwistEffect::New();
476 DALI_TEST_CHECK( handle );
478 effect = ScrollViewTwistEffect::DownCast(handle);
480 DALI_TEST_CHECK( effect );
483 static void UtcDaliScrollViewCubeEffectTest()
485 ToolkitTestApplication application;
486 tet_infoline(" UtcDaliScrollViewCubeEffectTest");
488 Vector2 size = Stage::GetCurrent().GetSize();
490 ScrollView scrollView = SetupTestScrollView(1, 3, size);
491 Actor page = gPages[1];
492 Wait(application, 500);
494 ScrollViewCubeEffect effect = ScrollViewCubeEffect::New();
495 scrollView.ApplyEffect(effect);
497 Actor actor = AddActorToPage(page, 0.5f, 0.5f, 3, 3);
499 Vector3 actorPrePosition = actor.GetCurrentPosition();
501 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);
503 Actor actor2 = AddActorToPage(page, 0.5f, 0.5f, 3, 3);
504 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);
506 scrollView.ScrollTo(1);
507 while(!gOnScrollCompleteCalled)
511 // test that the first page has reached centre of screen
512 Vector3 actorPostPosition = actor.GetCurrentPosition();
513 // just check the actor has moved
514 DALI_TEST_CHECK((actorPostPosition - actorPrePosition).Length() > Math::MACHINE_EPSILON_1);
518 static void UtcDaliScrollViewPageCubeEffectTest()
520 ToolkitTestApplication application;
521 tet_infoline(" UtcDaliScrollViewPageCubeEffectTest");
523 Vector2 size = Stage::GetCurrent().GetSize();
525 ScrollView scrollView = SetupTestScrollView(1, 3, size);
526 Actor testPage = gPages[1];
527 Wait(application, 500);
529 ScrollViewPageCubeEffect effect = ScrollViewPageCubeEffect::New();
530 scrollView.ApplyEffect(effect);
532 for(ActorIter pageIter = gPages.begin(); pageIter != gPages.end(); ++pageIter)
534 Actor page = *pageIter;
535 page.RemoveConstraints();
536 page.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
537 effect.ApplyToPage(page, Vector2(Math::PI_2, 0.0f));
541 scrollView.ScrollTo(1);
542 while(!gOnScrollCompleteCalled)
546 // test that the first page has reached centre of screen
547 Vector3 pagePos = testPage.GetCurrentPosition();
548 DALI_TEST_EQUALS(pagePos, Vector3::ZERO, Math::MACHINE_EPSILON_0, TEST_LOCATION);
552 static void UtcDaliScrollViewSpiralEffectTest()
554 ToolkitTestApplication application;
555 tet_infoline(" UtcDaliScrollViewSpiralEffectTest");
557 Vector2 size = Stage::GetCurrent().GetSize();
559 ScrollView scrollView = SetupTestScrollView(1, 3, size);
560 Actor testPage = gPages[1];
561 Wait(application, 500);
563 ScrollViewPageSpiralEffect effect = ScrollViewPageSpiralEffect::New();
564 scrollView.ApplyEffect(effect);
566 for(ActorIter pageIter = gPages.begin(); pageIter != gPages.end(); ++pageIter)
568 Actor page = *pageIter;
569 page.RemoveConstraints();
570 page.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
571 effect.ApplyToPage(page, Vector2(Math::PI_2, 0.0f));
575 scrollView.ScrollTo(1);
576 while(!gOnScrollCompleteCalled)
580 // test that the first page has reached centre of screen
581 Vector3 pagePos = testPage.GetCurrentPosition();
582 DALI_TEST_EQUALS(pagePos, Vector3::ZERO, Math::MACHINE_EPSILON_0, TEST_LOCATION);
586 static void UtcDaliScrollViewPageCarouselEffectTest()
588 ToolkitTestApplication application;
589 tet_infoline(" UtcDaliScrollViewPageCarouselEffectTest");
591 Vector2 size = Stage::GetCurrent().GetSize();
593 ScrollView scrollView = SetupTestScrollView(1, 3, size);
594 Actor testPage = gPages[1];
595 Wait(application, 500);
597 ScrollViewPageCarouselEffect effect = ScrollViewPageCarouselEffect::New();
598 scrollView.ApplyEffect(effect);
600 for(ActorIter pageIter = gPages.begin(); pageIter != gPages.end(); ++pageIter)
602 Actor page = *pageIter;
603 page.RemoveConstraints();
604 page.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
605 effect.ApplyToPage(page);
609 scrollView.ScrollTo(1, 0.5f, DirectionBiasNone);
610 while(!gOnScrollCompleteCalled)
614 // test that the first page has reached centre of screen
615 Vector3 pagePos = testPage.GetCurrentPosition();
616 DALI_TEST_EQUALS(pagePos, Vector3::ZERO, Math::MACHINE_EPSILON_0, TEST_LOCATION);
620 static void UtcDaliScrollViewCarouselEffectTest()
622 ToolkitTestApplication application;
623 tet_infoline(" UtcDaliScrollViewCarouselEffectTest");
625 Vector2 size = Stage::GetCurrent().GetSize();
627 ScrollView scrollView = SetupTestScrollView(1, 3, size);
628 Actor testPage = gPages[1];
629 Wait(application, 500);
631 ScrollViewCarouselEffect effect = ScrollViewCarouselEffect::New();
632 scrollView.ApplyEffect(effect);
634 Actor actor = AddActorToPage(testPage, 0.5f, 0.5f, 3, 3);
636 Vector3 actorPrePosition = actor.GetCurrentPosition();
638 effect.ApplyToActor( actor, Vector2(1.2f, 1.2f) );
640 scrollView.ScrollTo(Vector3(size.x, 0.0f, 0.0f), 0.5f, DirectionBiasNone, DirectionBiasNone);
641 while(!gOnScrollCompleteCalled)
645 // test that the first page has reached centre of screen
646 Vector3 actorPostPosition = actor.GetCurrentPosition();
647 // just check the actor has moved
648 DALI_TEST_CHECK((actorPostPosition - actorPrePosition).Length() > Math::MACHINE_EPSILON_1);
652 static void UtcDaliScrollViewDepthEffectTest()
654 ToolkitTestApplication application;
655 tet_infoline(" UtcDaliScrollViewDepthEffectTest");
657 Vector2 size = Stage::GetCurrent().GetSize();
659 ScrollView scrollView = SetupTestScrollView(1, 3, size);
660 Actor testPage = gPages[1];
661 Wait(application, 500);
663 ScrollViewDepthEffect effect = ScrollViewDepthEffect::New();
664 scrollView.ApplyEffect(effect);
666 Actor actor = AddActorToPage(testPage, 0.5f, 0.5f, 3, 3);
668 Vector3 actorPrePosition = actor.GetCurrentPosition();
670 const Vector2 positionExtent(0.5f, 2.5f);
671 const Vector2 offsetExtent(1.0f, 1.0f);
672 const float positionScale(1.5f);
673 const float scaleExtent(0.5f);
675 effect.ApplyToActor( actor, positionExtent, offsetExtent, positionScale, scaleExtent );
677 scrollView.ScrollTo(1);
678 while(!gOnScrollCompleteCalled)
682 // test that the first page has reached centre of screen
683 Vector3 actorPostPosition = actor.GetCurrentPosition();
684 // just check the actor has moved
685 DALI_TEST_CHECK((actorPostPosition - actorPrePosition).Length() > Math::MACHINE_EPSILON_1);
689 static void UtcDaliScrollViewSlideEffectTest()
691 ToolkitTestApplication application;
692 tet_infoline(" UtcDaliScrollViewSlideEffectTest");
694 Vector2 size = Stage::GetCurrent().GetSize();
695 Vector3 pageSize(size.x, size.y, 0.0f);
697 ScrollView scrollView = SetupTestScrollView(1, 3, size);
698 Actor testPage = gPages[1];
699 Wait(application, 500);
701 ScrollViewSlideEffect effect = ScrollViewSlideEffect::New();
702 effect.SetDelayReferenceOffset(pageSize * 0.25);
703 DALI_TEST_EQUALS(effect.GetDelayReferenceOffset(), pageSize * 0.25, Math::MACHINE_EPSILON_0, TEST_LOCATION);
704 effect.SetMaxDelayDuration(0.5f);
705 DALI_TEST_EQUALS(effect.GetMaxDelayDuration(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
706 effect.SetSlideDirection(false);
707 DALI_TEST_CHECK(!effect.GetSlideDirection());
709 scrollView.ApplyEffect(effect);
711 Actor actor = AddActorToPage(testPage, 0.5f, 0.5f, 3, 3);
713 Vector3 actorPrePosition = actor.GetCurrentPosition();
715 effect.ApplyToActor(actor, 0.0f, 0.5f);
717 scrollView.ScrollTo(1);
718 while(!gOnScrollCompleteCalled)
722 // test that the first page has reached centre of screen
723 Vector3 actorPostPosition = actor.GetCurrentPosition();
724 // just check the actor has moved
725 DALI_TEST_CHECK((actorPostPosition - actorPrePosition).Length() > Math::MACHINE_EPSILON_1);
729 static void UtcDaliScrollViewTwistEffectTest()
731 ToolkitTestApplication application;
732 tet_infoline(" UtcDaliScrollViewTwistEffectTest");
734 Vector2 size = Stage::GetCurrent().GetSize();
736 ScrollView scrollView = SetupTestScrollView(1, 3, size);
737 Actor testPage = gPages[1];
738 Wait(application, 500);
740 ScrollViewTwistEffect effect = ScrollViewTwistEffect::New();
741 float shrinkDist = 0.2f;
742 effect.SetMinimumDistanceForShrink(shrinkDist);
743 DALI_TEST_CHECK((shrinkDist - effect.GetMinimumDistanceForShrink()) < Math::MACHINE_EPSILON_0);
744 effect.EnableEffect(true);
745 scrollView.ApplyEffect(effect);
747 Actor actor = AddActorToPage(testPage, 0.5f, 0.5f, 3, 3);
749 Vector3 actorPrePosition = actor.GetCurrentPosition();
751 effect.ApplyToActor( actor,
753 Vector2(Math::PI_2, Math::PI_2),
756 scrollView.ScrollTo(1);
757 while(!gOnScrollCompleteCalled)
761 // test that the first page has reached centre of screen
762 Vector3 actorPostPosition = actor.GetCurrentPosition();
763 // just check the actor has moved
764 DALI_TEST_CHECK((actorPostPosition - actorPrePosition).Length() > Math::MACHINE_EPSILON_1);
768 static void UtcDaliScrollViewCustomEffectTest()
770 ToolkitTestApplication application;
771 tet_infoline(" UtcDaliScrollViewCustomEffectTest");
773 Vector2 size = Stage::GetCurrent().GetSize();
774 Vector3 pageSize(size.x, size.y, 0.0f);
776 ScrollView scrollView = SetupTestScrollView(1, 3, size);
777 Actor testPage = gPages[1];
778 Wait(application, 500);
779 Vector3 pageStartPos, pagePos;
780 pageStartPos = pagePos = testPage.GetCurrentPosition();
781 //scrollView.RemoveConstraintsFromChildren();
783 ScrollViewCustomEffect effect = ScrollViewCustomEffect::DownCast(scrollView.ApplyEffect(ScrollView::PageEffectCarousel));
785 for(ActorIter pageIter = gPages.begin(); pageIter != gPages.end(); ++pageIter)
787 Actor page = *pageIter;
788 page.RemoveConstraints();
789 page.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
790 effect.ApplyToPage(page, pageSize);
793 pagePos = testPage.GetCurrentPosition();
794 DALI_TEST_EQUALS(pagePos, pageStartPos, Math::MACHINE_EPSILON_0, TEST_LOCATION);
796 scrollView.ScrollTo(1);
797 while(!gOnScrollCompleteCalled)
801 ResetScrollCallbackResults();
802 // test that the first page has reached centre of screen
803 pagePos = testPage.GetCurrentPosition();
804 DALI_TEST_EQUALS(pagePos, Vector3::ZERO, Math::MACHINE_EPSILON_0, TEST_LOCATION);
806 // scroll back to page 0
807 scrollView.ScrollTo(0);
808 while(!gOnScrollCompleteCalled)
812 ResetScrollCallbackResults();
813 pagePos = testPage.GetCurrentPosition();
814 DALI_TEST_EQUALS(pagePos, pageStartPos, Math::MACHINE_EPSILON_0, TEST_LOCATION);
816 scrollView.RemoveEffect(effect);
818 effect = ScrollViewCustomEffect::New();
819 effect.SetPageTranslation(Vector3(20.0f, 20.0f, 5.0f));
820 effect.SetPageTranslation(Vector3(20.0f, 20.0f, 5.0f), Vector3(20.0f, 20.0f, -5.0f));
821 effect.SetPageTranslationIn(Vector3(20.0f, 20.0f, 5.0f));
822 effect.SetPageTranslationOut(Vector3(20.0f, 20.0f, -5.0f));
823 effect.SetPageTranslation(Vector3(20.0f, 0.0f, 0.0f));
824 effect.SetSwingAngle(Math::PI, Vector3::YAXIS);
825 effect.SetPageSpacing(Vector2(20.0f, 20.0f));
826 scrollView.ApplyEffect(effect);
828 for(ActorIter pageIter = gPages.begin(); pageIter != gPages.end(); ++pageIter)
830 Actor page = *pageIter;
831 page.RemoveConstraints();
832 page.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
833 effect.ApplyToPage(page, pageSize);
836 pagePos = testPage.GetCurrentPosition();
837 DALI_TEST_EQUALS(pagePos, pageStartPos, Math::MACHINE_EPSILON_0, TEST_LOCATION);
839 scrollView.ScrollTo(1);
840 while(!gOnScrollCompleteCalled)
844 ResetScrollCallbackResults();
845 // test that the first page has reached centre of screen
846 pagePos = testPage.GetCurrentPosition();
847 DALI_TEST_EQUALS(pagePos, Vector3::ZERO, Math::MACHINE_EPSILON_0, TEST_LOCATION);
849 // scroll back to page 0
850 scrollView.ScrollTo(0);
851 while(!gOnScrollCompleteCalled)
855 ResetScrollCallbackResults();
856 pagePos = testPage.GetCurrentPosition();
857 DALI_TEST_EQUALS(pagePos, pageStartPos, Math::MACHINE_EPSILON_0, TEST_LOCATION);
859 scrollView.RemoveEffect(effect);
860 effect = ScrollViewCustomEffect::New();
861 effect.SetSwingAngle(Math::PI, Vector3::YAXIS);
862 effect.SetSwingAnchor(AnchorPoint::CENTER_LEFT);
863 effect.SetPageTranslation(Vector3(size.x, size.y, 0));
864 effect.SetOpacityThreshold(0.66f);
865 scrollView.ApplyEffect(effect);
867 for(ActorIter pageIter = gPages.begin(); pageIter != gPages.end(); ++pageIter)
869 Actor page = *pageIter;
870 page.RemoveConstraints();
871 page.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
872 effect.ApplyToPage(page, pageSize);
876 scrollView.ScrollTo(1);
877 while(!gOnScrollCompleteCalled)
881 ResetScrollCallbackResults();
882 // test that the first page has reached centre of screen
883 pagePos = testPage.GetCurrentPosition();
884 DALI_TEST_EQUALS(pagePos, Vector3::ZERO, Math::MACHINE_EPSILON_0, TEST_LOCATION);
886 // scroll back to page 0
887 scrollView.ScrollTo(0);
888 while(!gOnScrollCompleteCalled)
892 ResetScrollCallbackResults();
893 pagePos = testPage.GetCurrentPosition();
894 DALI_TEST_EQUALS(pagePos, pageStartPos, Math::MACHINE_EPSILON_0, TEST_LOCATION);
895 scrollView.RemoveEffect(effect);
898 effect.SetPageTranslateAlphaFunction(AlphaFunctions::Linear);
899 effect.SetPageTranslateAlphaFunction(AlphaFunctions::Linear, AlphaFunctions::Linear);
900 effect.SetPageTranslateAlphaFunctionIn(AlphaFunctions::Linear);
901 effect.SetPageTranslateAlphaFunctionOut(AlphaFunctions::Linear);
902 effect.SetGlobalPageRotation(Math::PI, Vector3::YAXIS);
903 effect.SetAngledOriginPageRotation(Vector3(Math::PI, Math::PI, 0.0f));
904 effect.SetGlobalPageRotation(Math::PI, Vector3::YAXIS, Math::PI, Vector3::YAXIS);
905 effect.SetGlobalPageRotationIn(Math::PI, Vector3::YAXIS);
906 effect.SetGlobalPageRotationOut(Math::PI, Vector3::YAXIS);
907 effect.SetGlobalPageRotationOrigin(Vector3::ZERO);
908 effect.SetGlobalPageRotationOrigin(Vector3::ZERO, Vector3::ZERO);
909 effect.SetGlobalPageRotationOriginIn(Vector3::ZERO);
910 effect.SetGlobalPageRotationOriginOut(Vector3::ZERO);
911 effect.SetSwingAngle(Math::PI, Vector3::YAXIS);
912 effect.SetSwingAngle(Math::PI, Vector3::YAXIS, Math::PI, Vector3::YAXIS);
913 effect.SetSwingAngleIn(Math::PI, Vector3::YAXIS);
914 effect.SetSwingAngleOut(Math::PI, Vector3::YAXIS);
915 effect.SetSwingAngleAlphaFunction(AlphaFunctions::Linear);
916 effect.SetSwingAngleAlphaFunction(AlphaFunctions::Linear, AlphaFunctions::Linear);
917 effect.SetSwingAngleAlphaFunctionIn(AlphaFunctions::Linear);
918 effect.SetSwingAngleAlphaFunctionOut(AlphaFunctions::Linear);
919 effect.SetSwingAnchor(AnchorPoint::CENTER, AnchorPoint::CENTER_LEFT);
920 effect.SetSwingAnchorIn(AnchorPoint::CENTER);
921 effect.SetSwingAnchorOut(AnchorPoint::CENTER);
922 effect.SetSwingAnchorAlphaFunction(AlphaFunctions::Linear);
923 effect.SetSwingAnchorAlphaFunction(AlphaFunctions::Linear, AlphaFunctions::Linear);
924 effect.SetSwingAnchorAlphaFunctionIn(AlphaFunctions::Linear);
925 effect.SetSwingAnchorAlphaFunctionOut(AlphaFunctions::Linear);
926 effect.SetOpacityThreshold(0.5f);
927 effect.SetOpacityThreshold(0.5f, 0.5f);
928 effect.SetOpacityThresholdIn(0.5f);
929 effect.SetOpacityThresholdOut(0.5f);
930 effect.SetOpacityAlphaFunction(AlphaFunctions::Linear);
931 effect.SetOpacityAlphaFunction(AlphaFunctions::Linear, AlphaFunctions::Linear);
932 effect.SetOpacityAlphaFunctionIn(AlphaFunctions::Linear);
933 effect.SetOpacityAlphaFunctionOut(AlphaFunctions::Linear);