fdd75ecfe001ac58c771c816cd5291818b603546
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-ScrollViewEffect.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <iostream>
19 #include <stdlib.h>
20
21 // Need to override adaptor classes for toolkit test harness, so include
22 // test harness headers before dali headers.
23 #include <dali-toolkit-test-suite-utils.h>
24
25 #include <dali.h>
26 #include <dali-toolkit/dali-toolkit.h>
27 #include <dali/integration-api/events/touch-event-integ.h>
28 #include <dali/integration-api/events/pan-gesture-event.h>
29
30 using namespace Dali;
31 using namespace Toolkit;
32
33 void utc_dali_toolkit_scroll_view_effect_startup(void)
34 {
35   test_return_value = TET_UNDEF;
36 }
37
38 void utc_dali_toolkit_scroll_view_effect_cleanup(void)
39 {
40   test_return_value = TET_PASS;
41 }
42
43 namespace
44 {
45 static bool gObjectCreatedCallBackCalled;
46
47 static void TestCallback(BaseHandle handle)
48 {
49   gObjectCreatedCallBackCalled = true;
50 }
51
52 const int MILLISECONDS_PER_SECOND = 1000;
53 const int RENDER_FRAME_INTERVAL = 16;                           ///< Duration of each frame in ms. (at approx 60FPS)
54 const int RENDER_ANIMATION_TEST_DURATION_MS = 1000;             ///< 1000ms to test animation
55 const int RENDER_DELAY_SCROLL = 1000;                           ///< duration to wait for any scroll to complete.
56
57 /*
58  * Simulate time passed by.
59  *
60  * @note this will always process at least 1 frame (1/60 sec)
61  *
62  * @param application Test application instance
63  * @param duration Time to pass in milliseconds.
64  * @return The actual time passed in milliseconds
65  */
66 int Wait(ToolkitTestApplication& application, int duration = 0)
67 {
68   int time = 0;
69
70   for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
71   {
72     application.SendNotification();
73     application.Render(RENDER_FRAME_INTERVAL);
74     time += RENDER_FRAME_INTERVAL;
75   }
76
77   return time;
78 }
79
80 /**
81  * Creates a Ruler that snaps to a specified grid size.
82  * If that grid size is 0.0 then this ruler does not
83  * snap.
84  *
85  * @param[in] gridSize (optional) The grid size for the ruler,
86  * (Default = 0.0 i.e. no snapping)
87  * @return The ruler is returned.
88  */
89 RulerPtr CreateRuler(float gridSize = 0.0f)
90 {
91   if(gridSize <= Math::MACHINE_EPSILON_0)
92   {
93       return new DefaultRuler();
94   }
95   return new FixedRuler(gridSize);
96 }
97
98 // Callback probes.
99
100 static bool gOnScrollStartCalled;                       ///< Whether the OnScrollStart signal was invoked.
101 static bool gOnScrollUpdateCalled;                      ///< Whether the OnScrollUpdate signal was invoked.
102 static bool gOnScrollCompleteCalled;                    ///< Whether the OnScrollComplete signal was invoked.
103 static bool gOnScrollClampedCalled;                     ///< Whether the OnScrollClamped signal was invoked.
104 static bool gOnSnapStartCalled;                         ///< Whether the OnSnapStart signal was invoked.
105 static ClampState3 gLastClampPosition;                  ///< Clamping information from OnScrollClampedEvent.
106 static SnapType gLastSnapType;                          ///< Snaping information from SnapEvent.
107 static Vector3 gConstraintResult;                       ///< Result from constraint.
108
109 static ActorContainer gPages;                                ///< Keeps track of all the pages for applying effects.
110
111 static void ResetScrollCallbackResults()
112 {
113   gOnScrollStartCalled = false;
114   gOnScrollUpdateCalled = false;
115   gOnScrollCompleteCalled = false;
116 }
117
118 /**
119  * Invoked when scrolling starts.
120  *
121  * @param[in] position The current scroll position.
122  */
123 static void OnScrollStart( const Vector3& position )
124 {
125   gOnScrollStartCalled = true;
126 }
127
128 /**
129  * Invoked when scrolling updates (via dragging)
130  *
131  * @param[in] position The current scroll position.
132  */
133 static void OnScrollUpdate( const Vector3& position )
134 {
135   gOnScrollUpdateCalled = true;
136 }
137
138 /**
139  * Invoked when scrolling finishes
140  *
141  * @param[in] position The current scroll position.
142  */
143 static void OnScrollComplete( const Vector3& position )
144 {
145   gOnScrollCompleteCalled = true;
146 }
147
148 /**
149  * Invoked when scrolling clamped.
150  *
151  * @param[in] event The position/scale/rotation axes that were clamped.
152  */
153 static void OnScrollClamped( const ScrollView::ClampEvent& event )
154 {
155   gOnScrollClampedCalled = true;
156   gLastClampPosition = event.position;
157 }
158
159 /**
160  * Invoked when a snap or flick started.
161  *
162  * @param[in] event The type of snap and the target position/scale/rotation.
163  */
164 static void OnSnapStart( const ScrollView::SnapEvent& event )
165 {
166   gOnSnapStartCalled = true;
167   gLastSnapType = event.type;
168 }
169
170 ScrollView SetupTestScrollView(int rows, int columns, Vector2 size)
171 {
172   ScrollView scrollView = ScrollView::New();
173   scrollView.SetSize(size);
174   scrollView.SetAnchorPoint(AnchorPoint::CENTER);
175   scrollView.SetParentOrigin(ParentOrigin::CENTER);
176   scrollView.ApplyConstraint( Constraint::New<Dali::Vector3>( Dali::Actor::SIZE, Dali::ParentSource( Dali::Actor::SIZE ), Dali::EqualToConstraint() ) );
177   // Disable Refresh signal (TET environment cannot use adaptor's Timer)
178   scrollView.SetWrapMode(false);
179   scrollView.SetRefreshInterval(0);
180   scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
181   scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
182   scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
183   Stage::GetCurrent().Add( scrollView );
184   RulerPtr rulerX = CreateRuler(size.width);
185   RulerPtr rulerY = CreateRuler(size.height);
186   if(columns > 1)
187   {
188     rulerX->SetDomain(RulerDomain(0.0f, size.width * columns));
189   }
190   else
191   {
192     rulerX->Disable();
193   }
194   if(rows > 1)
195   {
196     rulerY->SetDomain(RulerDomain(0.0f, size.width * rows));
197   }
198   else
199   {
200     rulerY->Disable();
201   }
202
203   scrollView.SetRulerX( rulerX );
204   scrollView.SetRulerY( rulerY );
205   Stage::GetCurrent().Add( scrollView );
206
207   Actor container = Actor::New();
208   container.SetParentOrigin(ParentOrigin::CENTER);
209   container.SetAnchorPoint(AnchorPoint::CENTER);
210   container.SetSize( size );
211   scrollView.Add( container );
212   container.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
213
214   gPages.clear();
215   for(int row = 0;row<rows;row++)
216   {
217     for(int column = 0;column<columns;column++)
218     {
219       Actor page = Actor::New();
220       page.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
221       page.SetParentOrigin( ParentOrigin::CENTER );
222       page.SetAnchorPoint( AnchorPoint::CENTER );
223       page.SetPosition( column * size.x, row * size.y );
224       container.Add(page);
225
226       gPages.push_back(page);
227     }
228   }
229
230   ResetScrollCallbackResults();
231   return scrollView;
232 }
233
234 void CleanupTest()
235 {
236   gPages.clear();
237   ResetScrollCallbackResults();
238 }
239
240 Actor AddActorToPage(Actor page, float x, float y, float cols, float rows)
241 {
242   Stage stage = Stage::GetCurrent();
243   Vector2 stageSize = stage.GetSize();
244
245   const float margin = 10.0f;
246   const Vector2 actorSize((stageSize.x / cols) - margin, (stageSize.y / rows) - margin);
247
248   Actor actor = Actor::New();
249   actor.SetParentOrigin( ParentOrigin::CENTER );
250   actor.SetAnchorPoint( AnchorPoint::CENTER );
251
252   Vector3 position( margin * 0.5f + (actorSize.x + margin) * x - stageSize.width * 0.5f,
253                     margin * 0.5f + (actorSize.y + margin) * y - stageSize.height * 0.5f,
254                     0.0f);
255   Vector3 positionEnd( margin * 0.5f + (actorSize.x + margin) * (x + cols) - stageSize.width * 0.5f - margin,
256                        margin * 0.5f + (actorSize.y + margin) * (y + rows) - stageSize.height * 0.5f - margin,
257                        0.0f);
258   Vector3 size(positionEnd - position);
259   actor.SetPosition( position + size * 0.5f);
260   actor.SetSize( positionEnd - position );
261   page.Add(actor);
262   return actor;
263 }
264
265 } // unnamed namespace
266
267
268 int UtcDaliScrollViewCustomEffectSetup(void)
269 {
270   tet_infoline(" UtcDaliScrollViewCustomEffectSetup");
271
272   ScrollViewCustomEffect effect;
273
274   DALI_TEST_CHECK( !effect );
275
276   BaseHandle handle = ScrollViewCustomEffect::New();
277
278   DALI_TEST_CHECK( handle );
279
280   effect = ScrollViewCustomEffect::DownCast(handle);
281
282   DALI_TEST_CHECK( effect );
283
284   END_TEST;
285 }
286
287 int UtcDaliScrollViewCubeEffectSetup(void)
288 {
289   tet_infoline(" UtcDaliScrollViewCubeEffectSetup");
290
291   ScrollViewCubeEffect effect;
292
293   DALI_TEST_CHECK( !effect );
294
295   BaseHandle handle = ScrollViewCubeEffect::New();
296
297   DALI_TEST_CHECK( handle );
298
299   effect = ScrollViewCubeEffect::DownCast(handle);
300
301   DALI_TEST_CHECK( effect );
302   END_TEST;
303 }
304
305 int UtcDaliScrollViewSpiralEffectSetup(void)
306 {
307   tet_infoline(" UtcDaliScrollViewSpiralEffectSetup");
308
309   ScrollViewPageSpiralEffect effect;
310
311   DALI_TEST_CHECK( !effect );
312
313   BaseHandle handle = ScrollViewPageSpiralEffect::New();
314
315   DALI_TEST_CHECK( handle );
316
317   effect = ScrollViewPageSpiralEffect::DownCast(handle);
318
319   DALI_TEST_CHECK( effect );
320   END_TEST;
321 }
322
323
324
325
326 int UtcDaliScrollViewSlideEffectSetup(void)
327 {
328   tet_infoline(" UtcDaliScrollViewSlideEffectSetup");
329
330   ScrollViewSlideEffect effect;
331
332   DALI_TEST_CHECK( !effect );
333
334   BaseHandle handle = ScrollViewSlideEffect::New();
335
336   DALI_TEST_CHECK( handle );
337
338   effect = ScrollViewSlideEffect::DownCast(handle);
339
340   DALI_TEST_CHECK( effect );
341   END_TEST;
342 }
343
344 int UtcDaliScrollViewTwistEffectSetup(void)
345 {
346   tet_infoline(" UtcDaliScrollViewTwistEffectSetup");
347
348   ScrollViewTwistEffect effect;
349
350   DALI_TEST_CHECK( !effect );
351
352   BaseHandle handle = ScrollViewTwistEffect::New();
353
354   DALI_TEST_CHECK( handle );
355
356   effect = ScrollViewTwistEffect::DownCast(handle);
357
358   DALI_TEST_CHECK( effect );
359   END_TEST;
360 }
361
362 int UtcDaliScrollViewCubeEffectTest(void)
363 {
364   ToolkitTestApplication application;
365   tet_infoline(" UtcDaliScrollViewCubeEffectTest");
366
367   Vector2 size = Stage::GetCurrent().GetSize();
368
369   ScrollView scrollView = SetupTestScrollView(1, 3, size);
370   Actor page = gPages[1];
371   Wait(application, 500);
372
373   ScrollViewCubeEffect effect = ScrollViewCubeEffect::New();
374   scrollView.ApplyEffect(effect);
375
376   Actor actor = AddActorToPage(page, 0.5f, 0.5f, 3, 3);
377   Wait(application);
378   Vector3 actorPrePosition = actor.GetCurrentPosition();
379
380   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);
381
382   Actor actor2 = AddActorToPage(page, 0.5f, 0.5f, 3, 3);
383   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);
384
385   scrollView.ScrollTo(1);
386   while(!gOnScrollCompleteCalled)
387   {
388     Wait(application);
389   }
390   // test that the first page has reached centre of screen
391   Vector3 actorPostPosition = actor.GetCurrentPosition();
392   // just check the actor has moved
393   DALI_TEST_CHECK((actorPostPosition - actorPrePosition).Length() > Math::MACHINE_EPSILON_1);
394   CleanupTest();
395   END_TEST;
396 }
397
398
399 int UtcDaliScrollViewSpiralEffectTest(void)
400 {
401   ToolkitTestApplication application;
402   tet_infoline(" UtcDaliScrollViewSpiralEffectTest");
403
404   Vector2 size = Stage::GetCurrent().GetSize();
405
406   ScrollView scrollView = SetupTestScrollView(1, 3, size);
407   Actor testPage = gPages[1];
408   Wait(application, 500);
409
410   ScrollViewPageSpiralEffect effect = ScrollViewPageSpiralEffect::New();
411   scrollView.ApplyEffect(effect);
412
413   for(ActorIter pageIter = gPages.begin(); pageIter != gPages.end(); ++pageIter)
414   {
415     Actor page = *pageIter;
416     page.RemoveConstraints();
417     page.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
418     effect.ApplyToPage(page, Vector2(Math::PI_2, 0.0f));
419   }
420   Wait(application);
421
422   scrollView.ScrollTo(1);
423   while(!gOnScrollCompleteCalled)
424   {
425     Wait(application);
426   }
427   // test that the first page has reached centre of screen
428   Vector3 pagePos = testPage.GetCurrentPosition();
429   DALI_TEST_EQUALS(pagePos, Vector3::ZERO, Math::MACHINE_EPSILON_0, TEST_LOCATION);
430   CleanupTest();
431   END_TEST;
432 }
433
434
435
436 int UtcDaliScrollViewSlideEffectTest(void)
437 {
438   ToolkitTestApplication application;
439   tet_infoline(" UtcDaliScrollViewSlideEffectTest");
440
441   Vector2 size = Stage::GetCurrent().GetSize();
442   Vector3 pageSize(size.x, size.y, 0.0f);
443
444   ScrollView scrollView = SetupTestScrollView(1, 3, size);
445   Actor testPage = gPages[1];
446   Wait(application, 500);
447
448   ScrollViewSlideEffect effect = ScrollViewSlideEffect::New();
449   effect.SetDelayReferenceOffset(pageSize * 0.25);
450   DALI_TEST_EQUALS(effect.GetDelayReferenceOffset(), pageSize * 0.25, Math::MACHINE_EPSILON_0, TEST_LOCATION);
451   effect.SetMaxDelayDuration(0.5f);
452   DALI_TEST_EQUALS(effect.GetMaxDelayDuration(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
453   effect.SetSlideDirection(false);
454   DALI_TEST_CHECK(!effect.GetSlideDirection());
455
456   scrollView.ApplyEffect(effect);
457
458   Actor actor = AddActorToPage(testPage, 0.5f, 0.5f, 3, 3);
459   Wait(application);
460   Vector3 actorPrePosition = actor.GetCurrentPosition();
461
462   effect.ApplyToActor(actor, 0.0f, 0.5f);
463
464   scrollView.ScrollTo(1);
465   while(!gOnScrollCompleteCalled)
466   {
467     Wait(application);
468   }
469   // test that the first page has reached centre of screen
470   Vector3 actorPostPosition = actor.GetCurrentPosition();
471   // just check the actor has moved
472   DALI_TEST_CHECK((actorPostPosition - actorPrePosition).Length() > Math::MACHINE_EPSILON_1);
473   CleanupTest();
474   END_TEST;
475 }
476
477 int UtcDaliScrollViewTwistEffectTest(void)
478 {
479   ToolkitTestApplication application;
480   tet_infoline(" UtcDaliScrollViewTwistEffectTest");
481
482   Vector2 size = Stage::GetCurrent().GetSize();
483
484   ScrollView scrollView = SetupTestScrollView(1, 3, size);
485   Actor testPage = gPages[1];
486   Wait(application, 500);
487
488   ScrollViewTwistEffect effect = ScrollViewTwistEffect::New();
489   float shrinkDist = 0.2f;
490   effect.SetMinimumDistanceForShrink(shrinkDist);
491   DALI_TEST_CHECK((shrinkDist - effect.GetMinimumDistanceForShrink()) < Math::MACHINE_EPSILON_0);
492   effect.EnableEffect(true);
493   scrollView.ApplyEffect(effect);
494
495   Actor actor = AddActorToPage(testPage, 0.5f, 0.5f, 3, 3);
496   Wait(application);
497   Vector3 actorPrePosition = actor.GetCurrentPosition();
498
499   effect.ApplyToActor( actor,
500       true,
501       Vector2(Math::PI_2, Math::PI_2),
502       0.0f);
503
504   scrollView.ScrollTo(1);
505   while(!gOnScrollCompleteCalled)
506   {
507     Wait(application);
508   }
509   // test that the first page has reached centre of screen
510   Vector3 actorPostPosition = actor.GetCurrentPosition();
511   // just check the actor has moved
512   DALI_TEST_CHECK((actorPostPosition - actorPrePosition).Length() > Math::MACHINE_EPSILON_1);
513   CleanupTest();
514   END_TEST;
515 }
516
517 int UtcDaliScrollViewCustomEffectTest(void)
518 {
519   ToolkitTestApplication application;
520   tet_infoline(" UtcDaliScrollViewCustomEffectTest");
521
522   Vector2 size = Stage::GetCurrent().GetSize();
523   Vector3 pageSize(size.x, size.y, 0.0f);
524
525   ScrollView scrollView = SetupTestScrollView(1, 3, size);
526   Actor testPage = gPages[1];
527   Wait(application, 500);
528   Vector3 pageStartPos, pagePos;
529   pageStartPos = pagePos = testPage.GetCurrentPosition();
530   //scrollView.RemoveConstraintsFromChildren();
531
532   ScrollViewCustomEffect effect = ScrollViewCustomEffect::DownCast(scrollView.ApplyEffect(ScrollView::PageEffectCarousel));
533
534   for(ActorIter pageIter = gPages.begin(); pageIter != gPages.end(); ++pageIter)
535   {
536     Actor page = *pageIter;
537     page.RemoveConstraints();
538     page.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
539     effect.ApplyToPage(page, pageSize);
540   }
541   Wait(application);
542   pagePos = testPage.GetCurrentPosition();
543   DALI_TEST_EQUALS(pagePos, pageStartPos, Math::MACHINE_EPSILON_0, TEST_LOCATION);
544
545   scrollView.ScrollTo(1);
546   while(!gOnScrollCompleteCalled)
547   {
548     Wait(application);
549   }
550   ResetScrollCallbackResults();
551   // test that the first page has reached centre of screen
552   pagePos = testPage.GetCurrentPosition();
553   DALI_TEST_EQUALS(pagePos, Vector3::ZERO, Math::MACHINE_EPSILON_0, TEST_LOCATION);
554
555   // scroll back to page 0
556   scrollView.ScrollTo(0);
557   while(!gOnScrollCompleteCalled)
558   {
559     Wait(application);
560   }
561   ResetScrollCallbackResults();
562   pagePos = testPage.GetCurrentPosition();
563   DALI_TEST_EQUALS(pagePos, pageStartPos, Math::MACHINE_EPSILON_0, TEST_LOCATION);
564
565   scrollView.RemoveEffect(effect);
566
567   effect = ScrollViewCustomEffect::New();
568   effect.SetPageTranslation(Vector3(20.0f, 20.0f, 5.0f));
569   effect.SetPageTranslation(Vector3(20.0f, 20.0f, 5.0f), Vector3(20.0f, 20.0f, -5.0f));
570   effect.SetPageTranslationIn(Vector3(20.0f, 20.0f, 5.0f));
571   effect.SetPageTranslationOut(Vector3(20.0f, 20.0f, -5.0f));
572   effect.SetPageTranslation(Vector3(20.0f, 0.0f, 0.0f));
573   effect.SetSwingAngle(Math::PI, Vector3::YAXIS);
574   effect.SetPageSpacing(Vector2(20.0f, 20.0f));
575   scrollView.ApplyEffect(effect);
576
577   for(ActorIter pageIter = gPages.begin(); pageIter != gPages.end(); ++pageIter)
578   {
579     Actor page = *pageIter;
580     page.RemoveConstraints();
581     page.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
582     effect.ApplyToPage(page, pageSize);
583   }
584   Wait(application);
585   pagePos = testPage.GetCurrentPosition();
586   DALI_TEST_EQUALS(pagePos, pageStartPos, Math::MACHINE_EPSILON_0, TEST_LOCATION);
587
588   scrollView.ScrollTo(1);
589   while(!gOnScrollCompleteCalled)
590   {
591     Wait(application);
592   }
593   ResetScrollCallbackResults();
594   // test that the first page has reached centre of screen
595   pagePos = testPage.GetCurrentPosition();
596   DALI_TEST_EQUALS(pagePos, Vector3::ZERO, Math::MACHINE_EPSILON_0, TEST_LOCATION);
597
598   // scroll back to page 0
599   scrollView.ScrollTo(0);
600   while(!gOnScrollCompleteCalled)
601   {
602     Wait(application);
603   }
604   ResetScrollCallbackResults();
605   pagePos = testPage.GetCurrentPosition();
606   DALI_TEST_EQUALS(pagePos, pageStartPos, Math::MACHINE_EPSILON_0, TEST_LOCATION);
607
608   scrollView.RemoveEffect(effect);
609   effect = ScrollViewCustomEffect::New();
610   effect.SetSwingAngle(Math::PI, Vector3::YAXIS);
611   effect.SetSwingAnchor(AnchorPoint::CENTER_LEFT);
612   effect.SetPageTranslation(Vector3(size.x, size.y, 0));
613   effect.SetOpacityThreshold(0.66f);
614   scrollView.ApplyEffect(effect);
615
616   for(ActorIter pageIter = gPages.begin(); pageIter != gPages.end(); ++pageIter)
617   {
618     Actor page = *pageIter;
619     page.RemoveConstraints();
620     page.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
621     effect.ApplyToPage(page, pageSize);
622   }
623   Wait(application);
624
625   scrollView.ScrollTo(1);
626   while(!gOnScrollCompleteCalled)
627   {
628     Wait(application);
629   }
630   ResetScrollCallbackResults();
631   // test that the first page has reached centre of screen
632   pagePos = testPage.GetCurrentPosition();
633   DALI_TEST_EQUALS(pagePos, Vector3::ZERO, Math::MACHINE_EPSILON_0, TEST_LOCATION);
634
635   // scroll back to page 0
636   scrollView.ScrollTo(0);
637   while(!gOnScrollCompleteCalled)
638   {
639     Wait(application);
640   }
641   ResetScrollCallbackResults();
642   pagePos = testPage.GetCurrentPosition();
643   DALI_TEST_EQUALS(pagePos, pageStartPos, Math::MACHINE_EPSILON_0, TEST_LOCATION);
644   scrollView.RemoveEffect(effect);
645
646
647   effect.SetPageTranslateAlphaFunction(AlphaFunctions::Linear);
648   effect.SetPageTranslateAlphaFunction(AlphaFunctions::Linear, AlphaFunctions::Linear);
649   effect.SetPageTranslateAlphaFunctionIn(AlphaFunctions::Linear);
650   effect.SetPageTranslateAlphaFunctionOut(AlphaFunctions::Linear);
651   effect.SetGlobalPageRotation(Math::PI, Vector3::YAXIS);
652   effect.SetAngledOriginPageRotation(Vector3(Math::PI, Math::PI, 0.0f));
653   effect.SetGlobalPageRotation(Math::PI, Vector3::YAXIS, Math::PI, Vector3::YAXIS);
654   effect.SetGlobalPageRotationIn(Math::PI, Vector3::YAXIS);
655   effect.SetGlobalPageRotationOut(Math::PI, Vector3::YAXIS);
656   effect.SetGlobalPageRotationOrigin(Vector3::ZERO);
657   effect.SetGlobalPageRotationOrigin(Vector3::ZERO, Vector3::ZERO);
658   effect.SetGlobalPageRotationOriginIn(Vector3::ZERO);
659   effect.SetGlobalPageRotationOriginOut(Vector3::ZERO);
660   effect.SetSwingAngle(Math::PI, Vector3::YAXIS);
661   effect.SetSwingAngle(Math::PI, Vector3::YAXIS, Math::PI, Vector3::YAXIS);
662   effect.SetSwingAngleIn(Math::PI, Vector3::YAXIS);
663   effect.SetSwingAngleOut(Math::PI, Vector3::YAXIS);
664   effect.SetSwingAngleAlphaFunction(AlphaFunctions::Linear);
665   effect.SetSwingAngleAlphaFunction(AlphaFunctions::Linear, AlphaFunctions::Linear);
666   effect.SetSwingAngleAlphaFunctionIn(AlphaFunctions::Linear);
667   effect.SetSwingAngleAlphaFunctionOut(AlphaFunctions::Linear);
668   effect.SetSwingAnchor(AnchorPoint::CENTER, AnchorPoint::CENTER_LEFT);
669   effect.SetSwingAnchorIn(AnchorPoint::CENTER);
670   effect.SetSwingAnchorOut(AnchorPoint::CENTER);
671   effect.SetSwingAnchorAlphaFunction(AlphaFunctions::Linear);
672   effect.SetSwingAnchorAlphaFunction(AlphaFunctions::Linear, AlphaFunctions::Linear);
673   effect.SetSwingAnchorAlphaFunctionIn(AlphaFunctions::Linear);
674   effect.SetSwingAnchorAlphaFunctionOut(AlphaFunctions::Linear);
675   effect.SetOpacityThreshold(0.5f);
676   effect.SetOpacityThreshold(0.5f, 0.5f);
677   effect.SetOpacityThresholdIn(0.5f);
678   effect.SetOpacityThresholdOut(0.5f);
679   effect.SetOpacityAlphaFunction(AlphaFunctions::Linear);
680   effect.SetOpacityAlphaFunction(AlphaFunctions::Linear, AlphaFunctions::Linear);
681   effect.SetOpacityAlphaFunctionIn(AlphaFunctions::Linear);
682   effect.SetOpacityAlphaFunctionOut(AlphaFunctions::Linear);
683   CleanupTest();
684   END_TEST;
685 }