2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
22 #include <dali/public-api/dali-core.h>
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali/integration-api/events/touch-event-integ.h>
25 #include <dali/integration-api/events/pan-gesture-event.h>
27 #include <dali-toolkit-test-suite-utils.h>
30 using namespace Toolkit;
32 static void Startup();
33 static void Cleanup();
37 static bool gObjectCreatedCallBackCalled;
39 static void TestCallback(BaseHandle handle)
41 gObjectCreatedCallBackCalled = true;
46 void (*tet_startup)() = Startup;
47 void (*tet_cleanup)() = Cleanup;
50 static void UtcDaliScrollViewCustomEffectSetup();
51 static void UtcDaliScrollViewCubeEffectSetup();
52 static void UtcDaliScrollViewPageCubeEffectSetup();
53 static void UtcDaliScrollViewSpiralEffectSetup();
54 static void UtcDaliScrollViewPageCarouselEffectSetup();
55 static void UtcDaliScrollViewCarouselEffectSetup();
56 static void UtcDaliScrollViewDepthEffectSetup();
57 static void UtcDaliScrollViewSlideEffectSetup();
58 static void UtcDaliScrollViewTwistEffectSetup();
60 static void UtcDaliScrollViewCubeEffectTest();
61 static void UtcDaliScrollViewPageCubeEffectTest();
62 static void UtcDaliScrollViewSpiralEffectTest();
63 static void UtcDaliScrollViewPageCarouselEffectTest();
64 static void UtcDaliScrollViewCarouselEffectTest();
65 static void UtcDaliScrollViewDepthEffectTest();
66 static void UtcDaliScrollViewSlideEffectTest();
67 static void UtcDaliScrollViewTwistEffectTest();
68 static void UtcDaliScrollViewCustomEffectTest();
71 POSITIVE_TC_IDX = 0x01,
75 // Add test functionality for all APIs in the class (Positive and Negative)
77 struct tet_testlist tet_testlist[] = {
78 { UtcDaliScrollViewCustomEffectSetup, POSITIVE_TC_IDX },
79 { UtcDaliScrollViewCubeEffectSetup, POSITIVE_TC_IDX },
80 { UtcDaliScrollViewPageCubeEffectSetup, POSITIVE_TC_IDX },
81 { UtcDaliScrollViewSpiralEffectSetup, POSITIVE_TC_IDX },
82 { UtcDaliScrollViewPageCarouselEffectSetup, POSITIVE_TC_IDX },
83 { UtcDaliScrollViewCarouselEffectSetup, POSITIVE_TC_IDX },
84 { UtcDaliScrollViewDepthEffectSetup, POSITIVE_TC_IDX },
85 { UtcDaliScrollViewSlideEffectSetup, POSITIVE_TC_IDX },
86 { UtcDaliScrollViewTwistEffectSetup, POSITIVE_TC_IDX },
87 { UtcDaliScrollViewCubeEffectTest, POSITIVE_TC_IDX },
88 { UtcDaliScrollViewPageCubeEffectTest, POSITIVE_TC_IDX },
89 { UtcDaliScrollViewSpiralEffectTest, POSITIVE_TC_IDX },
90 { UtcDaliScrollViewPageCarouselEffectTest, POSITIVE_TC_IDX },
91 { UtcDaliScrollViewCarouselEffectTest, POSITIVE_TC_IDX },
92 { UtcDaliScrollViewDepthEffectTest, POSITIVE_TC_IDX },
93 { UtcDaliScrollViewSlideEffectTest, POSITIVE_TC_IDX },
94 { UtcDaliScrollViewTwistEffectTest, POSITIVE_TC_IDX },
95 { UtcDaliScrollViewCustomEffectTest, POSITIVE_TC_IDX },
100 namespace // unnamed namespace
103 const int MILLISECONDS_PER_SECOND = 1000;
104 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
105 const int RENDER_ANIMATION_TEST_DURATION_MS = 1000; ///< 1000ms to test animation
106 const int RENDER_DELAY_SCROLL = 1000; ///< duration to wait for any scroll to complete.
109 * Simulate time passed by.
111 * @note this will always process at least 1 frame (1/60 sec)
113 * @param application Test application instance
114 * @param duration Time to pass in milliseconds.
115 * @return The actual time passed in milliseconds
117 int Wait(ToolkitTestApplication& application, int duration = 0)
121 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
123 application.SendNotification();
124 application.Render(RENDER_FRAME_INTERVAL);
125 time += RENDER_FRAME_INTERVAL;
132 * Creates a Ruler that snaps to a specified grid size.
133 * If that grid size is 0.0 then this ruler does not
136 * @param[in] gridSize (optional) The grid size for the ruler,
137 * (Default = 0.0 i.e. no snapping)
138 * @return The ruler is returned.
140 RulerPtr CreateRuler(float gridSize = 0.0f)
142 if(gridSize <= Math::MACHINE_EPSILON_0)
144 return new DefaultRuler();
146 return new FixedRuler(gridSize);
151 static bool gOnScrollStartCalled; ///< Whether the OnScrollStart signal was invoked.
152 static bool gOnScrollUpdateCalled; ///< Whether the OnScrollUpdate signal was invoked.
153 static bool gOnScrollCompleteCalled; ///< Whether the OnScrollComplete signal was invoked.
154 static bool gOnScrollClampedCalled; ///< Whether the OnScrollClamped signal was invoked.
155 static bool gOnSnapStartCalled; ///< Whether the OnSnapStart signal was invoked.
156 static ClampState3 gLastClampPosition; ///< Clamping information from OnScrollClampedEvent.
157 static SnapType gLastSnapType; ///< Snaping information from SnapEvent.
158 static Vector3 gConstraintResult; ///< Result from constraint.
160 static ActorContainer gPages; ///< Keeps track of all the pages for applying effects.
162 static void ResetScrollCallbackResults()
164 gOnScrollStartCalled = false;
165 gOnScrollUpdateCalled = false;
166 gOnScrollCompleteCalled = false;
170 * Invoked when scrolling starts.
172 * @param[in] position The current scroll position.
174 static void OnScrollStart( const Vector3& position )
176 gOnScrollStartCalled = true;
180 * Invoked when scrolling updates (via dragging)
182 * @param[in] position The current scroll position.
184 static void OnScrollUpdate( const Vector3& position )
186 gOnScrollUpdateCalled = true;
190 * Invoked when scrolling finishes
192 * @param[in] position The current scroll position.
194 static void OnScrollComplete( const Vector3& position )
196 gOnScrollCompleteCalled = true;
200 * Invoked when scrolling clamped.
202 * @param[in] event The position/scale/rotation axes that were clamped.
204 static void OnScrollClamped( const ScrollView::ClampEvent& event )
206 gOnScrollClampedCalled = true;
207 gLastClampPosition = event.position;
211 * Invoked when a snap or flick started.
213 * @param[in] event The type of snap and the target position/scale/rotation.
215 static void OnSnapStart( const ScrollView::SnapEvent& event )
217 gOnSnapStartCalled = true;
218 gLastSnapType = event.type;
221 ScrollView SetupTestScrollView(int rows, int columns, Vector2 size)
223 ScrollView scrollView = ScrollView::New();
224 scrollView.SetSize(size);
225 scrollView.SetAnchorPoint(AnchorPoint::CENTER);
226 scrollView.SetParentOrigin(ParentOrigin::CENTER);
227 scrollView.ApplyConstraint( Constraint::New<Dali::Vector3>( Dali::Actor::SIZE, Dali::ParentSource( Dali::Actor::SIZE ), Dali::EqualToConstraint() ) );
228 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
229 scrollView.SetWrapMode(false);
230 scrollView.SetRefreshInterval(0);
231 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
232 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
233 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
234 Stage::GetCurrent().Add( scrollView );
235 RulerPtr rulerX = CreateRuler(size.width);
236 RulerPtr rulerY = CreateRuler(size.height);
239 rulerX->SetDomain(RulerDomain(0.0f, size.width * columns));
247 rulerY->SetDomain(RulerDomain(0.0f, size.width * rows));
254 scrollView.SetRulerX( rulerX );
255 scrollView.SetRulerY( rulerY );
256 Stage::GetCurrent().Add( scrollView );
258 Actor container = Actor::New();
259 container.SetParentOrigin(ParentOrigin::CENTER);
260 container.SetAnchorPoint(AnchorPoint::CENTER);
261 container.SetSize( size );
262 scrollView.Add( container );
263 container.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
266 for(int row = 0;row<rows;row++)
268 for(int column = 0;column<columns;column++)
270 Actor page = Actor::New();
271 page.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
272 page.SetParentOrigin( ParentOrigin::CENTER );
273 page.SetAnchorPoint( AnchorPoint::CENTER );
274 page.SetPosition( column * size.x, row * size.y );
277 gPages.push_back(page);
281 ResetScrollCallbackResults();
288 ResetScrollCallbackResults();
291 Actor AddActorToPage(Actor page, float x, float y, float cols, float rows)
293 Stage stage = Stage::GetCurrent();
294 Vector2 stageSize = stage.GetSize();
296 const float margin = 10.0f;
297 const Vector2 actorSize((stageSize.x / cols) - margin, (stageSize.y / rows) - margin);
299 Actor actor = Actor::New();
300 actor.SetParentOrigin( ParentOrigin::CENTER );
301 actor.SetAnchorPoint( AnchorPoint::CENTER );
303 Vector3 position( margin * 0.5f + (actorSize.x + margin) * x - stageSize.width * 0.5f,
304 margin * 0.5f + (actorSize.y + margin) * y - stageSize.height * 0.5f,
306 Vector3 positionEnd( margin * 0.5f + (actorSize.x + margin) * (x + cols) - stageSize.width * 0.5f - margin,
307 margin * 0.5f + (actorSize.y + margin) * (y + rows) - stageSize.height * 0.5f - margin,
309 Vector3 size(positionEnd - position);
310 actor.SetPosition( position + size * 0.5f);
311 actor.SetSize( positionEnd - position );
316 } // unnamed namespace
318 // Called only once before first test is run.
319 static void Startup()
323 // Called only once after last test is run
324 static void Cleanup()
328 static void UtcDaliScrollViewCustomEffectSetup()
330 tet_infoline(" UtcDaliScrollViewCustomEffectSetup");
332 ScrollViewCustomEffect effect;
334 DALI_TEST_CHECK( !effect );
336 BaseHandle handle = ScrollViewCustomEffect::New();
338 DALI_TEST_CHECK( handle );
340 effect = ScrollViewCustomEffect::DownCast(handle);
342 DALI_TEST_CHECK( effect );
346 static void UtcDaliScrollViewCubeEffectSetup()
348 tet_infoline(" UtcDaliScrollViewCubeEffectSetup");
350 ScrollViewCubeEffect effect;
352 DALI_TEST_CHECK( !effect );
354 BaseHandle handle = ScrollViewCubeEffect::New();
356 DALI_TEST_CHECK( handle );
358 effect = ScrollViewCubeEffect::DownCast(handle);
360 DALI_TEST_CHECK( effect );
363 static void UtcDaliScrollViewPageCubeEffectSetup()
365 tet_infoline(" UtcDaliScrollViewPageCubeEffectSetup");
367 ScrollViewPageCubeEffect effect;
369 DALI_TEST_CHECK( !effect );
371 BaseHandle handle = ScrollViewPageCubeEffect::New();
373 DALI_TEST_CHECK( handle );
375 effect = ScrollViewPageCubeEffect::DownCast(handle);
377 DALI_TEST_CHECK( effect );
380 static void UtcDaliScrollViewSpiralEffectSetup()
382 tet_infoline(" UtcDaliScrollViewSpiralEffectSetup");
384 ScrollViewPageSpiralEffect effect;
386 DALI_TEST_CHECK( !effect );
388 BaseHandle handle = ScrollViewPageSpiralEffect::New();
390 DALI_TEST_CHECK( handle );
392 effect = ScrollViewPageSpiralEffect::DownCast(handle);
394 DALI_TEST_CHECK( effect );
397 static void UtcDaliScrollViewPageCarouselEffectSetup()
399 tet_infoline(" UtcDaliScrollViewCarouselEffectSetup");
401 ScrollViewPageCarouselEffect effect;
403 DALI_TEST_CHECK( !effect );
405 BaseHandle handle = ScrollViewPageCarouselEffect::New();
407 DALI_TEST_CHECK( handle );
409 effect = ScrollViewPageCarouselEffect::DownCast(handle);
411 DALI_TEST_CHECK( effect );
414 static void UtcDaliScrollViewCarouselEffectSetup()
416 tet_infoline(" UtcDaliScrollViewCarouselEffectSetup");
418 ScrollViewCarouselEffect effect;
420 DALI_TEST_CHECK( !effect );
422 BaseHandle handle = ScrollViewCarouselEffect::New();
424 DALI_TEST_CHECK( handle );
426 effect = ScrollViewCarouselEffect::DownCast(handle);
428 DALI_TEST_CHECK( effect );
431 static void UtcDaliScrollViewDepthEffectSetup()
433 tet_infoline(" UtcDaliScrollViewDepthEffectSetup");
435 ScrollViewDepthEffect effect;
437 DALI_TEST_CHECK( !effect );
439 BaseHandle handle = ScrollViewDepthEffect::New();
441 DALI_TEST_CHECK( handle );
443 effect = ScrollViewDepthEffect::DownCast(handle);
445 DALI_TEST_CHECK( effect );
448 static void UtcDaliScrollViewSlideEffectSetup()
450 tet_infoline(" UtcDaliScrollViewSlideEffectSetup");
452 ScrollViewSlideEffect effect;
454 DALI_TEST_CHECK( !effect );
456 BaseHandle handle = ScrollViewSlideEffect::New();
458 DALI_TEST_CHECK( handle );
460 effect = ScrollViewSlideEffect::DownCast(handle);
462 DALI_TEST_CHECK( effect );
465 static void UtcDaliScrollViewTwistEffectSetup()
467 tet_infoline(" UtcDaliScrollViewTwistEffectSetup");
469 ScrollViewTwistEffect effect;
471 DALI_TEST_CHECK( !effect );
473 BaseHandle handle = ScrollViewTwistEffect::New();
475 DALI_TEST_CHECK( handle );
477 effect = ScrollViewTwistEffect::DownCast(handle);
479 DALI_TEST_CHECK( effect );
482 static void UtcDaliScrollViewCubeEffectTest()
484 ToolkitTestApplication application;
485 tet_infoline(" UtcDaliScrollViewCubeEffectTest");
487 Vector2 size = Stage::GetCurrent().GetSize();
489 ScrollView scrollView = SetupTestScrollView(1, 3, size);
490 Actor page = gPages[1];
491 Wait(application, 500);
493 ScrollViewCubeEffect effect = ScrollViewCubeEffect::New();
494 scrollView.ApplyEffect(effect);
496 Actor actor = AddActorToPage(page, 0.5f, 0.5f, 3, 3);
498 Vector3 actorPrePosition = actor.GetCurrentPosition();
500 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);
502 Actor actor2 = AddActorToPage(page, 0.5f, 0.5f, 3, 3);
503 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);
505 scrollView.ScrollTo(1);
506 while(!gOnScrollCompleteCalled)
510 // test that the first page has reached centre of screen
511 Vector3 actorPostPosition = actor.GetCurrentPosition();
512 // just check the actor has moved
513 DALI_TEST_CHECK((actorPostPosition - actorPrePosition).Length() > Math::MACHINE_EPSILON_1);
517 static void UtcDaliScrollViewPageCubeEffectTest()
519 ToolkitTestApplication application;
520 tet_infoline(" UtcDaliScrollViewPageCubeEffectTest");
522 Vector2 size = Stage::GetCurrent().GetSize();
524 ScrollView scrollView = SetupTestScrollView(1, 3, size);
525 Actor testPage = gPages[1];
526 Wait(application, 500);
528 ScrollViewPageCubeEffect effect = ScrollViewPageCubeEffect::New();
529 scrollView.ApplyEffect(effect);
531 for(ActorIter pageIter = gPages.begin(); pageIter != gPages.end(); ++pageIter)
533 Actor page = *pageIter;
534 page.RemoveConstraints();
535 page.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
536 effect.ApplyToPage(page, Vector2(Math::PI_2, 0.0f));
540 scrollView.ScrollTo(1);
541 while(!gOnScrollCompleteCalled)
545 // test that the first page has reached centre of screen
546 Vector3 pagePos = testPage.GetCurrentPosition();
547 DALI_TEST_EQUALS(pagePos, Vector3::ZERO, Math::MACHINE_EPSILON_0, TEST_LOCATION);
551 static void UtcDaliScrollViewSpiralEffectTest()
553 ToolkitTestApplication application;
554 tet_infoline(" UtcDaliScrollViewSpiralEffectTest");
556 Vector2 size = Stage::GetCurrent().GetSize();
558 ScrollView scrollView = SetupTestScrollView(1, 3, size);
559 Actor testPage = gPages[1];
560 Wait(application, 500);
562 ScrollViewPageSpiralEffect effect = ScrollViewPageSpiralEffect::New();
563 scrollView.ApplyEffect(effect);
565 for(ActorIter pageIter = gPages.begin(); pageIter != gPages.end(); ++pageIter)
567 Actor page = *pageIter;
568 page.RemoveConstraints();
569 page.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
570 effect.ApplyToPage(page, Vector2(Math::PI_2, 0.0f));
574 scrollView.ScrollTo(1);
575 while(!gOnScrollCompleteCalled)
579 // test that the first page has reached centre of screen
580 Vector3 pagePos = testPage.GetCurrentPosition();
581 DALI_TEST_EQUALS(pagePos, Vector3::ZERO, Math::MACHINE_EPSILON_0, TEST_LOCATION);
585 static void UtcDaliScrollViewPageCarouselEffectTest()
587 ToolkitTestApplication application;
588 tet_infoline(" UtcDaliScrollViewPageCarouselEffectTest");
590 Vector2 size = Stage::GetCurrent().GetSize();
592 ScrollView scrollView = SetupTestScrollView(1, 3, size);
593 Actor testPage = gPages[1];
594 Wait(application, 500);
596 ScrollViewPageCarouselEffect effect = ScrollViewPageCarouselEffect::New();
597 scrollView.ApplyEffect(effect);
599 for(ActorIter pageIter = gPages.begin(); pageIter != gPages.end(); ++pageIter)
601 Actor page = *pageIter;
602 page.RemoveConstraints();
603 page.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
604 effect.ApplyToPage(page);
608 scrollView.ScrollTo(1, 0.5f, DirectionBiasNone);
609 while(!gOnScrollCompleteCalled)
613 // test that the first page has reached centre of screen
614 Vector3 pagePos = testPage.GetCurrentPosition();
615 DALI_TEST_EQUALS(pagePos, Vector3::ZERO, Math::MACHINE_EPSILON_0, TEST_LOCATION);
619 static void UtcDaliScrollViewCarouselEffectTest()
621 ToolkitTestApplication application;
622 tet_infoline(" UtcDaliScrollViewCarouselEffectTest");
624 Vector2 size = Stage::GetCurrent().GetSize();
626 ScrollView scrollView = SetupTestScrollView(1, 3, size);
627 Actor testPage = gPages[1];
628 Wait(application, 500);
630 ScrollViewCarouselEffect effect = ScrollViewCarouselEffect::New();
631 scrollView.ApplyEffect(effect);
633 Actor actor = AddActorToPage(testPage, 0.5f, 0.5f, 3, 3);
635 Vector3 actorPrePosition = actor.GetCurrentPosition();
637 effect.ApplyToActor( actor, Vector2(1.2f, 1.2f) );
639 scrollView.ScrollTo(Vector3(size.x, 0.0f, 0.0f), 0.5f, DirectionBiasNone, DirectionBiasNone);
640 while(!gOnScrollCompleteCalled)
644 // test that the first page has reached centre of screen
645 Vector3 actorPostPosition = actor.GetCurrentPosition();
646 // just check the actor has moved
647 DALI_TEST_CHECK((actorPostPosition - actorPrePosition).Length() > Math::MACHINE_EPSILON_1);
651 static void UtcDaliScrollViewDepthEffectTest()
653 ToolkitTestApplication application;
654 tet_infoline(" UtcDaliScrollViewDepthEffectTest");
656 Vector2 size = Stage::GetCurrent().GetSize();
658 ScrollView scrollView = SetupTestScrollView(1, 3, size);
659 Actor testPage = gPages[1];
660 Wait(application, 500);
662 ScrollViewDepthEffect effect = ScrollViewDepthEffect::New();
663 scrollView.ApplyEffect(effect);
665 Actor actor = AddActorToPage(testPage, 0.5f, 0.5f, 3, 3);
667 Vector3 actorPrePosition = actor.GetCurrentPosition();
669 const Vector2 positionExtent(0.5f, 2.5f);
670 const Vector2 offsetExtent(1.0f, 1.0f);
671 const float positionScale(1.5f);
672 const float scaleExtent(0.5f);
674 effect.ApplyToActor( actor, positionExtent, offsetExtent, positionScale, scaleExtent );
676 scrollView.ScrollTo(1);
677 while(!gOnScrollCompleteCalled)
681 // test that the first page has reached centre of screen
682 Vector3 actorPostPosition = actor.GetCurrentPosition();
683 // just check the actor has moved
684 DALI_TEST_CHECK((actorPostPosition - actorPrePosition).Length() > Math::MACHINE_EPSILON_1);
688 static void UtcDaliScrollViewSlideEffectTest()
690 ToolkitTestApplication application;
691 tet_infoline(" UtcDaliScrollViewSlideEffectTest");
693 Vector2 size = Stage::GetCurrent().GetSize();
694 Vector3 pageSize(size.x, size.y, 0.0f);
696 ScrollView scrollView = SetupTestScrollView(1, 3, size);
697 Actor testPage = gPages[1];
698 Wait(application, 500);
700 ScrollViewSlideEffect effect = ScrollViewSlideEffect::New();
701 effect.SetDelayReferenceOffset(pageSize * 0.25);
702 DALI_TEST_EQUALS(effect.GetDelayReferenceOffset(), pageSize * 0.25, Math::MACHINE_EPSILON_0, TEST_LOCATION);
703 effect.SetMaxDelayDuration(0.5f);
704 DALI_TEST_EQUALS(effect.GetMaxDelayDuration(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
705 effect.SetSlideDirection(false);
706 DALI_TEST_CHECK(!effect.GetSlideDirection());
708 scrollView.ApplyEffect(effect);
710 Actor actor = AddActorToPage(testPage, 0.5f, 0.5f, 3, 3);
712 Vector3 actorPrePosition = actor.GetCurrentPosition();
714 effect.ApplyToActor(actor, 0.0f, 0.5f);
716 scrollView.ScrollTo(1);
717 while(!gOnScrollCompleteCalled)
721 // test that the first page has reached centre of screen
722 Vector3 actorPostPosition = actor.GetCurrentPosition();
723 // just check the actor has moved
724 DALI_TEST_CHECK((actorPostPosition - actorPrePosition).Length() > Math::MACHINE_EPSILON_1);
728 static void UtcDaliScrollViewTwistEffectTest()
730 ToolkitTestApplication application;
731 tet_infoline(" UtcDaliScrollViewTwistEffectTest");
733 Vector2 size = Stage::GetCurrent().GetSize();
735 ScrollView scrollView = SetupTestScrollView(1, 3, size);
736 Actor testPage = gPages[1];
737 Wait(application, 500);
739 ScrollViewTwistEffect effect = ScrollViewTwistEffect::New();
740 float shrinkDist = 0.2f;
741 effect.SetMinimumDistanceForShrink(shrinkDist);
742 DALI_TEST_CHECK((shrinkDist - effect.GetMinimumDistanceForShrink()) < Math::MACHINE_EPSILON_0);
743 effect.EnableEffect(true);
744 scrollView.ApplyEffect(effect);
746 Actor actor = AddActorToPage(testPage, 0.5f, 0.5f, 3, 3);
748 Vector3 actorPrePosition = actor.GetCurrentPosition();
750 effect.ApplyToActor( actor,
752 Vector2(Math::PI_2, Math::PI_2),
755 scrollView.ScrollTo(1);
756 while(!gOnScrollCompleteCalled)
760 // test that the first page has reached centre of screen
761 Vector3 actorPostPosition = actor.GetCurrentPosition();
762 // just check the actor has moved
763 DALI_TEST_CHECK((actorPostPosition - actorPrePosition).Length() > Math::MACHINE_EPSILON_1);
767 static void UtcDaliScrollViewCustomEffectTest()
769 ToolkitTestApplication application;
770 tet_infoline(" UtcDaliScrollViewCustomEffectTest");
772 Vector2 size = Stage::GetCurrent().GetSize();
773 Vector3 pageSize(size.x, size.y, 0.0f);
775 ScrollView scrollView = SetupTestScrollView(1, 3, size);
776 Actor testPage = gPages[1];
777 Wait(application, 500);
778 Vector3 pageStartPos, pagePos;
779 pageStartPos = pagePos = testPage.GetCurrentPosition();
780 //scrollView.RemoveConstraintsFromChildren();
782 ScrollViewCustomEffect effect = ScrollViewCustomEffect::DownCast(scrollView.ApplyEffect(ScrollView::PageEffectCarousel));
784 for(ActorIter pageIter = gPages.begin(); pageIter != gPages.end(); ++pageIter)
786 Actor page = *pageIter;
787 page.RemoveConstraints();
788 page.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
789 effect.ApplyToPage(page, pageSize);
792 pagePos = testPage.GetCurrentPosition();
793 DALI_TEST_EQUALS(pagePos, pageStartPos, Math::MACHINE_EPSILON_0, TEST_LOCATION);
795 scrollView.ScrollTo(1);
796 while(!gOnScrollCompleteCalled)
800 ResetScrollCallbackResults();
801 // test that the first page has reached centre of screen
802 pagePos = testPage.GetCurrentPosition();
803 DALI_TEST_EQUALS(pagePos, Vector3::ZERO, Math::MACHINE_EPSILON_0, TEST_LOCATION);
805 // scroll back to page 0
806 scrollView.ScrollTo(0);
807 while(!gOnScrollCompleteCalled)
811 ResetScrollCallbackResults();
812 pagePos = testPage.GetCurrentPosition();
813 DALI_TEST_EQUALS(pagePos, pageStartPos, Math::MACHINE_EPSILON_0, TEST_LOCATION);
815 scrollView.RemoveEffect(effect);
817 effect = ScrollViewCustomEffect::New();
818 effect.SetPageTranslation(Vector3(20.0f, 20.0f, 5.0f));
819 effect.SetPageTranslation(Vector3(20.0f, 20.0f, 5.0f), Vector3(20.0f, 20.0f, -5.0f));
820 effect.SetPageTranslationIn(Vector3(20.0f, 20.0f, 5.0f));
821 effect.SetPageTranslationOut(Vector3(20.0f, 20.0f, -5.0f));
822 effect.SetPageTranslation(Vector3(20.0f, 0.0f, 0.0f));
823 effect.SetSwingAngle(Math::PI, Vector3::YAXIS);
824 effect.SetPageSpacing(Vector2(20.0f, 20.0f));
825 scrollView.ApplyEffect(effect);
827 for(ActorIter pageIter = gPages.begin(); pageIter != gPages.end(); ++pageIter)
829 Actor page = *pageIter;
830 page.RemoveConstraints();
831 page.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
832 effect.ApplyToPage(page, pageSize);
835 pagePos = testPage.GetCurrentPosition();
836 DALI_TEST_EQUALS(pagePos, pageStartPos, Math::MACHINE_EPSILON_0, TEST_LOCATION);
838 scrollView.ScrollTo(1);
839 while(!gOnScrollCompleteCalled)
843 ResetScrollCallbackResults();
844 // test that the first page has reached centre of screen
845 pagePos = testPage.GetCurrentPosition();
846 DALI_TEST_EQUALS(pagePos, Vector3::ZERO, Math::MACHINE_EPSILON_0, TEST_LOCATION);
848 // scroll back to page 0
849 scrollView.ScrollTo(0);
850 while(!gOnScrollCompleteCalled)
854 ResetScrollCallbackResults();
855 pagePos = testPage.GetCurrentPosition();
856 DALI_TEST_EQUALS(pagePos, pageStartPos, Math::MACHINE_EPSILON_0, TEST_LOCATION);
858 scrollView.RemoveEffect(effect);
859 effect = ScrollViewCustomEffect::New();
860 effect.SetSwingAngle(Math::PI, Vector3::YAXIS);
861 effect.SetSwingAnchor(AnchorPoint::CENTER_LEFT);
862 effect.SetPageTranslation(Vector3(size.x, size.y, 0));
863 effect.SetOpacityThreshold(0.66f);
864 scrollView.ApplyEffect(effect);
866 for(ActorIter pageIter = gPages.begin(); pageIter != gPages.end(); ++pageIter)
868 Actor page = *pageIter;
869 page.RemoveConstraints();
870 page.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
871 effect.ApplyToPage(page, pageSize);
875 scrollView.ScrollTo(1);
876 while(!gOnScrollCompleteCalled)
880 ResetScrollCallbackResults();
881 // test that the first page has reached centre of screen
882 pagePos = testPage.GetCurrentPosition();
883 DALI_TEST_EQUALS(pagePos, Vector3::ZERO, Math::MACHINE_EPSILON_0, TEST_LOCATION);
885 // scroll back to page 0
886 scrollView.ScrollTo(0);
887 while(!gOnScrollCompleteCalled)
891 ResetScrollCallbackResults();
892 pagePos = testPage.GetCurrentPosition();
893 DALI_TEST_EQUALS(pagePos, pageStartPos, Math::MACHINE_EPSILON_0, TEST_LOCATION);
894 scrollView.RemoveEffect(effect);
897 effect.SetPageTranslateAlphaFunction(AlphaFunctions::Linear);
898 effect.SetPageTranslateAlphaFunction(AlphaFunctions::Linear, AlphaFunctions::Linear);
899 effect.SetPageTranslateAlphaFunctionIn(AlphaFunctions::Linear);
900 effect.SetPageTranslateAlphaFunctionOut(AlphaFunctions::Linear);
901 effect.SetGlobalPageRotation(Math::PI, Vector3::YAXIS);
902 effect.SetAngledOriginPageRotation(Vector3(Math::PI, Math::PI, 0.0f));
903 effect.SetGlobalPageRotation(Math::PI, Vector3::YAXIS, Math::PI, Vector3::YAXIS);
904 effect.SetGlobalPageRotationIn(Math::PI, Vector3::YAXIS);
905 effect.SetGlobalPageRotationOut(Math::PI, Vector3::YAXIS);
906 effect.SetGlobalPageRotationOrigin(Vector3::ZERO);
907 effect.SetGlobalPageRotationOrigin(Vector3::ZERO, Vector3::ZERO);
908 effect.SetGlobalPageRotationOriginIn(Vector3::ZERO);
909 effect.SetGlobalPageRotationOriginOut(Vector3::ZERO);
910 effect.SetSwingAngle(Math::PI, Vector3::YAXIS);
911 effect.SetSwingAngle(Math::PI, Vector3::YAXIS, Math::PI, Vector3::YAXIS);
912 effect.SetSwingAngleIn(Math::PI, Vector3::YAXIS);
913 effect.SetSwingAngleOut(Math::PI, Vector3::YAXIS);
914 effect.SetSwingAngleAlphaFunction(AlphaFunctions::Linear);
915 effect.SetSwingAngleAlphaFunction(AlphaFunctions::Linear, AlphaFunctions::Linear);
916 effect.SetSwingAngleAlphaFunctionIn(AlphaFunctions::Linear);
917 effect.SetSwingAngleAlphaFunctionOut(AlphaFunctions::Linear);
918 effect.SetSwingAnchor(AnchorPoint::CENTER, AnchorPoint::CENTER_LEFT);
919 effect.SetSwingAnchorIn(AnchorPoint::CENTER);
920 effect.SetSwingAnchorOut(AnchorPoint::CENTER);
921 effect.SetSwingAnchorAlphaFunction(AlphaFunctions::Linear);
922 effect.SetSwingAnchorAlphaFunction(AlphaFunctions::Linear, AlphaFunctions::Linear);
923 effect.SetSwingAnchorAlphaFunctionIn(AlphaFunctions::Linear);
924 effect.SetSwingAnchorAlphaFunctionOut(AlphaFunctions::Linear);
925 effect.SetOpacityThreshold(0.5f);
926 effect.SetOpacityThreshold(0.5f, 0.5f);
927 effect.SetOpacityThresholdIn(0.5f);
928 effect.SetOpacityThresholdOut(0.5f);
929 effect.SetOpacityAlphaFunction(AlphaFunctions::Linear);
930 effect.SetOpacityAlphaFunction(AlphaFunctions::Linear, AlphaFunctions::Linear);
931 effect.SetOpacityAlphaFunctionIn(AlphaFunctions::Linear);
932 effect.SetOpacityAlphaFunctionOut(AlphaFunctions::Linear);