4e050f3ae26ef7f977847e7a4640c2d2ff0e6e70
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-ScrollView.cpp
1 /*
2  * Copyright (c) 2020 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 #include <dali-toolkit-test-suite-utils.h>
21 #include <dali-toolkit/dali-toolkit.h>
22 #include <dali/integration-api/events/touch-event-integ.h>
23 #include <dali/integration-api/events/wheel-event-integ.h>
24
25 using namespace Dali;
26 using namespace Toolkit;
27
28 void scroll_view_startup(void)
29 {
30   test_return_value = TET_UNDEF;
31 }
32
33 void scroll_view_cleanup(void)
34 {
35   test_return_value = TET_PASS;
36 }
37
38 namespace
39 {
40 static bool gObjectCreatedCallBackCalled;
41
42 static void TestCallback(BaseHandle handle)
43 {
44   gObjectCreatedCallBackCalled = true;
45 }
46
47 struct CallbackFunctor
48 {
49   CallbackFunctor(bool* callbackFlag)
50   : mCallbackFlag( callbackFlag )
51   {
52   }
53
54   void operator()()
55   {
56     *mCallbackFlag = true;
57   }
58   bool* mCallbackFlag;
59 };
60
61 const int RENDER_FRAME_INTERVAL = 16;                           ///< Duration of each frame in ms. (at approx 60FPS)
62
63 const int RENDER_DELAY_SCROLL = 1000;                           ///< duration to wait for any scroll to complete.
64
65 // For Clamp Signal testing...
66 const float CLAMP_EXCESS_WIDTH = 200.0f;                        ///< Amount of width that can be panned outside scrollview
67 const float CLAMP_EXCESS_HEIGHT = 200.0f;                       ///< Amount of height that can be panned outside scrollview
68 const Vector2 CLAMP_START_SCROLL_POSITION(30.0f, 100.0f);       ///< Scroll start position for the Clamping tests.
69 const Vector2 CLAMP_TOUCH_START( 100.0f, 100.0f );              ///< Start point to touch from for the Clamping tests.
70 const Vector2 CLAMP_TOUCH_MOVEMENT( 5.0f, -5.0f );              ///< Amount to move touch for each frame for the Clamping tests.
71 const int CLAMP_GESTURE_FRAMES = 100;                           ///< Number of Frames to synthesize a gesture for the Clamping tests.
72 const Vector3 TEST_ACTOR_POSITION(100.0f, 100.0f, 0.0f);        ///< A Test actor position offset (arbitrary value)
73 const Vector3 TEST_CONSTRAINT_OFFSET(1.0f, 2.0f, 0.0f);         ///< A Test constraint offset (arbitrary value to test effects)
74
75 const float DEFAULT_SNAP_OVERSHOOT_DURATION(0.5f);                  ///< Default overshoot snapping animation time.
76 const float DEFAULT_MAX_OVERSHOOT(100.0f);                          ///< Default maximum allowed overshoot in pixels
77
78 const int MAX_FRAMES_TO_TEST_OVERSHOOT = 600;                       ///< 10 seconds (at 60 frames per second).
79 const Vector2 OVERSHOOT_START_SCROLL_POSITION(100.0f, 100.0f);       ///< Scroll start position for the Overshoot tests.
80 const float SCROLL_ANIMATION_DURATION(0.33f);                       ///< Duration of scroll animation in Overshoot tests (i.e. 100 pixels of overshoot in the speed of 500 pixels per 100 frames, 100/(500/(100/60)) = 0.33)
81 const Vector2 SNAP_POSITION_WITH_DECELERATED_VELOCITY(74.0f, 74.0f); ///< the snap position for Overshoot tests with the decelerated velocity (i.e. Decelerated from 500 pixels per 100 frames).
82 const float TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION = 0.05f;           ///< a Test duration
83 const float TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION = 1.5f;            ///< another Test duration
84 const float TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION = TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * 0.5f; // Same as above, but different alpha function.
85 const float TIME_TOLERANCE = 0.05f;                                 ///< Allow testing tolerance between a 10th of second (+/- 3 frames)
86
87
88 /*
89  * Simulate time passed by.
90  *
91  * @note this will always process at least 1 frame (1/60 sec)
92  *
93  * @param application Test application instance
94  * @param duration Time to pass in milliseconds.
95  * @return The actual time passed in milliseconds
96  */
97 int Wait(ToolkitTestApplication& application, int duration = 0)
98 {
99   int time = 0;
100
101   for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
102   {
103     application.SendNotification();
104     application.Render(RENDER_FRAME_INTERVAL);
105     time += RENDER_FRAME_INTERVAL;
106   }
107
108   return time;
109 }
110
111 // Callback probes.
112
113 static bool gOnScrollStartCalled;                       ///< Whether the OnScrollStart signal was invoked.
114 static bool gOnScrollUpdateCalled;                      ///< Whether the OnScrollUpdate signal was invoked.
115 static bool gOnScrollCompleteCalled;                    ///< Whether the OnScrollComplete signal was invoked.
116 static bool gOnSnapStartCalled;                         ///< Whether the OnSnapStart signal was invoked.
117 static bool gOnWheelEventCalled;                        ///< Whether the WheelEventSignal signal was invoked.
118 static SnapType gLastSnapType;                          ///< Snaping information from SnapEvent.
119 static Vector3 gConstraintResult;                       ///< Result from constraint.
120
121 /**
122  * Invoked when scrolling starts.
123  *
124  * @param[in] position The current scroll position.
125  */
126 static void OnScrollStart( const Vector2& position )
127 {
128   gOnScrollStartCalled = true;
129 }
130
131 /**
132  * Invoked when scrolling updates (via dragging)
133  *
134  * @param[in] position The current scroll position.
135  */
136 static void OnScrollUpdate( const Vector2& position )
137 {
138   gOnScrollUpdateCalled = true;
139 }
140
141 /**
142  * Invoked when scrolling finishes
143  *
144  * @param[in] position The current scroll position.
145  */
146 static void OnScrollComplete( const Vector2& position )
147 {
148   gOnScrollCompleteCalled = true;
149 }
150
151 /**
152  * Invoked when a snap or flick started.
153  *
154  * @param[in] event The type of snap and the target position/scale/rotation.
155  */
156 static void OnSnapStart( const ScrollView::SnapEvent& event )
157 {
158   gOnSnapStartCalled = true;
159   gLastSnapType = event.type;
160 }
161
162 /**
163  * Invoked after a wheel-event is received
164  *
165  * @param[in] actor The owing actor
166  * @param[in] event The wheel event
167  * @return True if the event should be consumed
168  */
169 static bool OnWheelEvent( Actor actor, const Dali::WheelEvent& wheelEvent )
170 {
171   gOnWheelEventCalled = true;
172   return false;
173 }
174
175 /**
176  * TestSumConstraint
177  *
178  * Summation of current value, property, and offset.
179  *
180  * current' = current + mOffset + property;
181  */
182 struct TestSumConstraint
183 {
184   /**
185    * @param[in] offset The offset to be added to current.
186    */
187   TestSumConstraint(const Vector3& offset)
188   :mOffset(offset)
189   {
190   }
191
192   /**
193    * @param[in] current The current base value
194    * @param[in] inputs Contains the property to be added to current.
195    * @return The new current Vector.
196    */
197   void operator()( Vector3& current, const PropertyInputContainer& inputs )
198   {
199     gConstraintResult = current + Vector3(inputs[0]->GetVector2()) + mOffset;
200     current = gConstraintResult;
201   }
202
203   Vector3 mOffset;
204
205 };
206
207 /**
208  * @param[in] application The application instance
209  * @param[in] scrollView The scrollView instance
210  * @return The time taken for the overshoot to reach origin (zero)
211  */
212 static float TestOvershootSnapDuration(ToolkitTestApplication &application, ScrollView scrollView)
213 {
214   int timeToReachOrigin = -1;
215   for(int i = 0;i<MAX_FRAMES_TO_TEST_OVERSHOOT;i++)
216   {
217     float overshootXValue = scrollView.GetCurrentProperty<float>( ScrollView::Property::OVERSHOOT_X );
218     float overshootYValue = scrollView.GetCurrentProperty<float>( ScrollView::Property::OVERSHOOT_Y );
219     if(overshootXValue == 0.0f && overshootYValue == 0.0f)
220     {
221       break;
222     }
223
224     timeToReachOrigin += Wait(application);
225   }
226
227   return static_cast<float>(timeToReachOrigin) * 0.001f; // return in seconds not ms.
228 }
229
230 /**
231  * y = 2x alpha function, which is clamped between 0.0f - 1.0f
232  *
233  * Animations should appear to finish (reach 100% point)
234  * at just half the time of a regular Linear AlphaFunction.
235  *
236  * @param[in] progress value (ranges from 0.0f - 1.0f)
237  * @return interpolation value (ranges from 0.0f - 1.0f)
238  */
239 float TestAlphaFunction(float progress)
240 {
241   return std::min( progress * 2.0f, 1.0f );
242 }
243
244 /**
245  * Generate a complete pan gesture
246  * Note: To initiate the gesture it will go from start, diagonally SE on the screen, then continue in the direction for frames touches
247  */
248 static Vector2 PerformGestureSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, uint32_t& time, bool finish = true)
249 {
250   gOnScrollStartCalled = false;
251   gOnScrollUpdateCalled = false;
252   gOnScrollCompleteCalled = false;
253   gOnSnapStartCalled = false;
254
255   Vector2 pos( start );
256
257   // This is created to ensure a pan is started
258   Vector2 pos_start_jump( start + Vector2(11.0f, 11.0f) );
259   TestStartPan( application, start, pos_start_jump, time );
260   pos = pos_start_jump;
261
262   Wait(application);
263
264   for(int i = 0;i<frames;i++)
265   {
266     pos += direction; // Move in this direction
267     TestMovePan(application, pos, time );
268     time += Wait(application);
269   }
270
271   if(finish)
272   {
273     pos += direction; // Move in this direction.
274     TestEndPan(application, pos, time );
275     time += Wait(application, RENDER_DELAY_SCROLL);
276   }
277
278   return pos;
279 }
280
281
282 } // unnamed namespace
283
284
285 int UtcDaliToolkitScrollViewConstructorP(void)
286 {
287   ToolkitTestApplication application;
288
289   ScrollView scrollView;
290   DALI_TEST_CHECK( !scrollView );
291   END_TEST;
292 }
293
294 int UtcDaliToolkitScrollViewCopyConstructorP(void)
295 {
296   ToolkitTestApplication application;
297
298   ScrollView scrollView = ScrollView::New();
299   scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) );
300
301   ScrollView copy( scrollView );
302   DALI_TEST_CHECK( copy );
303   DALI_TEST_CHECK( copy.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) == scrollView.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) );
304   END_TEST;
305 }
306
307 int UtcDaliScrollViewMoveConstructor(void)
308 {
309   ToolkitTestApplication application;
310
311   ScrollView scrollView = ScrollView::New();
312   DALI_TEST_EQUALS( 1, scrollView.GetBaseObject().ReferenceCount(), TEST_LOCATION );
313   scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) );
314   DALI_TEST_EQUALS( scrollView.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ), Vector2(10.0f, 10.0f), TEST_LOCATION );
315
316   ScrollView moved = std::move( scrollView );
317   DALI_TEST_CHECK( moved );
318   DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
319   DALI_TEST_EQUALS( moved.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ), Vector2(10.0f, 10.0f), TEST_LOCATION );
320   DALI_TEST_CHECK( !scrollView );
321
322   END_TEST;
323 }
324
325 int UtcDaliToolkitScrollViewAssignmentOperatorP(void)
326 {
327   ToolkitTestApplication application;
328
329   ScrollView scrollView = ScrollView::New();
330   scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) );
331
332   ScrollView copy;
333   copy = scrollView;
334   DALI_TEST_CHECK( copy );
335   DALI_TEST_CHECK( copy.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) == scrollView.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) );
336   END_TEST;
337 }
338
339 int UtcDaliScrollViewMoveAssignment(void)
340 {
341   ToolkitTestApplication application;
342
343   ScrollView scrollView = ScrollView::New();
344   DALI_TEST_EQUALS( 1, scrollView.GetBaseObject().ReferenceCount(), TEST_LOCATION );
345   scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) );
346   DALI_TEST_EQUALS( scrollView.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ), Vector2(10.0f, 10.0f), TEST_LOCATION );
347
348   ScrollView moved;
349   moved = std::move( scrollView );
350   DALI_TEST_CHECK( moved );
351   DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
352   DALI_TEST_EQUALS( moved.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ), Vector2(10.0f, 10.0f), TEST_LOCATION );
353   DALI_TEST_CHECK( !scrollView );
354
355   END_TEST;
356 }
357
358 int UtcDaliScrollViewDestructorP(void)
359 {
360   ToolkitTestApplication application;
361
362   ScrollView* scrollView = new ScrollView();
363   delete scrollView;
364
365   DALI_TEST_CHECK( true );
366   END_TEST;
367 }
368
369 int UtcDaliToolkitScrollViewNewP1(void)
370 {
371   ToolkitTestApplication application;
372   tet_infoline(" UtcDaliToolkitScrollViewNewP1");
373
374   ScrollView scrollView;
375
376   DALI_TEST_CHECK( !scrollView );
377
378   scrollView = ScrollView::New();
379
380   DALI_TEST_CHECK( scrollView );
381
382   ScrollView scrollView2(scrollView);
383
384   DALI_TEST_CHECK( scrollView2 == scrollView );
385
386   //Additional check to ensure object is created by checking if it's registered
387   ObjectRegistry registry = application.GetCore().GetObjectRegistry();
388   DALI_TEST_CHECK( registry );
389
390   gObjectCreatedCallBackCalled = false;
391   registry.ObjectCreatedSignal().Connect( &TestCallback );
392   {
393     ScrollView scrollView = ScrollView::New();
394   }
395   DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
396   END_TEST;
397 }
398
399 int UtcDaliToolkitScrollViewNewP2(void)
400 {
401   ToolkitTestApplication application;
402   tet_infoline(" UtcDaliToolkitScrollViewNewP2 - create thru type registry");
403
404   ScrollView scrollView;
405   DALI_TEST_CHECK( !scrollView );
406
407   TypeRegistry typeRegistry = TypeRegistry::Get();
408   TypeInfo scrollViewType = typeRegistry.GetTypeInfo("ScrollView");
409   BaseHandle handle = scrollViewType.CreateInstance();
410   DALI_TEST_CHECK( handle );
411
412   scrollView = ScrollView::DownCast(handle);
413   DALI_TEST_CHECK( scrollView );
414
415   END_TEST;
416 }
417
418 int UtcDaliToolkitScrollViewDownCastP(void)
419 {
420   ToolkitTestApplication application;
421   tet_infoline(" UtcDaliToolkitScrollViewDownCastP");
422
423   ScrollView scrollView = ScrollView::New();
424   BaseHandle handle(scrollView);
425
426   ScrollView newScrollView = ScrollView::DownCast( handle );
427   DALI_TEST_CHECK( scrollView );
428   DALI_TEST_CHECK( newScrollView == scrollView );
429   END_TEST;
430 }
431
432 int UtcDaliToolkitScrollViewScrollToPositionP(void)
433 {
434   ToolkitTestApplication application;
435   tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionP");
436
437   // Create the ScrollView actor
438   ScrollView scrollView = ScrollView::New();
439   application.GetScene().Add( scrollView );
440
441   const Vector2 target = Vector2(100.0f, 200.0f);
442   const Vector2 target2 = Vector2(300.0f, 100.0f);
443
444   scrollView.ScrollTo( target, 0.0f );
445   Wait(application);
446   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
447   scrollView.ScrollTo( target2 );
448   Wait(application, RENDER_DELAY_SCROLL);
449   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
450
451   END_TEST;
452 }
453
454 int UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP(void)
455 {
456   ToolkitTestApplication application;
457   tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP");
458
459   ScrollView scrollView = ScrollView::New();
460   application.GetScene().Add( scrollView );
461   RulerPtr rulerX = new FixedRuler( 100.0f );
462   rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
463   RulerPtr rulerY = new FixedRuler( 100.0f );
464   rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
465
466   scrollView.SetRulerX( rulerX );
467   scrollView.SetRulerY( rulerY );
468
469   scrollView.SetWrapMode(true);
470
471   Property::Value wrapMode = scrollView.GetProperty( Toolkit::ScrollView::Property::WRAP_ENABLED );
472   DALI_TEST_EQUALS( wrapMode.Get<bool>(), true, TEST_LOCATION );
473
474   const Vector2 target = Vector2(50.0f, 50.0f);
475   const Vector2 target2 = Vector2(150.0f, 150.0f);
476
477   scrollView.ScrollTo( target, 0.0f );
478   Wait(application, RENDER_DELAY_SCROLL);
479   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
480
481   scrollView.ScrollTo( target2, 0.25f, Dali::Toolkit::DirectionBiasLeft, Dali::Toolkit::DirectionBiasLeft );
482   Wait(application, RENDER_DELAY_SCROLL);
483   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
484
485   scrollView.ScrollTo( target, 0.0f );
486   Wait(application, RENDER_DELAY_SCROLL);
487   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
488
489   scrollView.ScrollTo( target2, 0.25f, Dali::Toolkit::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
490   Wait(application, RENDER_DELAY_SCROLL);
491   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
492
493   END_TEST;
494 }
495
496 int UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionP(void)
497 {
498   ToolkitTestApplication application;
499   tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionP");
500
501   // Create the ScrollView actor
502   ScrollView scrollView = ScrollView::New();
503   application.GetScene().Add( scrollView );
504
505   const Vector2 target = Vector2(100.0f, 200.0f);
506   const Vector2 target2 = Vector2(300.0f, 100.0f);
507
508   scrollView.ScrollTo( target, 0.5f, TestAlphaFunction );
509   Wait(application, 250);
510   // Check that the scroll animation should finish within just half of the specified duration with the above alpha function
511   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
512
513   scrollView.ScrollTo( target2, 0.5f, AlphaFunction::LINEAR );
514   Wait(application, 250);
515   // Check that the scroll animation has not finished within half of the specified duration with the linear alpha function
516   DALI_TEST_CHECK( scrollView.GetCurrentScrollPosition() != target2 );
517
518   // Wait till the end of the specified duration
519   Wait(application, 250);
520   // Check that the scroll animation has finished
521   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
522
523   END_TEST;
524 }
525
526 int UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionAndDirectionBiasP(void)
527 {
528   ToolkitTestApplication application;
529   tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionAndDirectionBiasP");
530
531   ScrollView scrollView = ScrollView::New();
532   application.GetScene().Add( scrollView );
533   RulerPtr rulerX = new FixedRuler( 100.0f );
534   rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
535   RulerPtr rulerY = new FixedRuler( 100.0f );
536   rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
537
538   scrollView.SetRulerX( rulerX );
539   scrollView.SetRulerY( rulerY );
540
541   scrollView.SetWrapMode(true);
542
543   const Vector2 target = Vector2(50.0f, 50.0f);
544   const Vector2 target2 = Vector2(150.0f, 150.0f);
545
546   scrollView.ScrollTo( target, 0.0f );
547   Wait(application, RENDER_DELAY_SCROLL);
548   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
549
550   scrollView.ScrollTo( target2, 0.25f, AlphaFunction::LINEAR, Dali::Toolkit::DirectionBiasLeft, Dali::Toolkit::DirectionBiasLeft );
551   Wait(application, RENDER_DELAY_SCROLL);
552   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
553
554   scrollView.ScrollTo( target, 0.0f );
555   Wait(application, RENDER_DELAY_SCROLL);
556   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
557
558   scrollView.ScrollTo( target2, 0.25f, AlphaFunction::LINEAR, Dali::Toolkit::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
559   Wait(application, RENDER_DELAY_SCROLL);
560   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
561
562   scrollView.ScrollTo( target, 0.0f );
563   Wait(application, RENDER_DELAY_SCROLL);
564   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
565
566   scrollView.ScrollTo( target2, 0.25f, TestAlphaFunction, Dali::Toolkit::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
567   Wait(application, 125);
568   // Check that the scroll animation should finish within just half of the specified duration with the above alpha function
569   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
570
571   END_TEST;
572 }
573
574 int UtcDaliToolkitScrollViewScrollToPageP(void)
575 {
576   ToolkitTestApplication application;
577   tet_infoline(" UtcDaliToolkitScrollViewScrollToPageP");
578
579   ScrollView scrollView = ScrollView::New();
580   application.GetScene().Add( scrollView );
581   RulerPtr rulerX = new FixedRuler( 100.0f );
582   rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
583   RulerPtr rulerY = new FixedRuler( 100.0f );
584   rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
585
586   scrollView.SetRulerX( rulerX );
587   scrollView.SetRulerY( rulerY );
588
589   scrollView.ScrollTo( 1, 0.0f );
590   Wait(application);
591   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION );
592
593   scrollView.ScrollTo( 5, 0.0f );
594   Wait(application);
595   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(500.0f, 0.0f), TEST_LOCATION );
596
597   scrollView.ScrollTo( 10, 0.0f );
598   Wait(application);
599   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 100.0f), TEST_LOCATION );
600
601   scrollView.ScrollTo( 15, 0.0f );
602   Wait(application);
603   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(700.0f, 100.0f), TEST_LOCATION );
604   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION );
605
606   scrollView.ScrollTo( 3 );
607   Wait(application, RENDER_DELAY_SCROLL);
608   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(300.0f, 0.0f), TEST_LOCATION );
609   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION );
610
611   scrollView.ScrollTo( 9 );
612   Wait(application, RENDER_DELAY_SCROLL);
613   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 100.0f), TEST_LOCATION );
614   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION );
615
616   // Apply DefaultRulers instead and see what happens.
617   rulerX = new DefaultRuler();
618   rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
619   rulerY = new DefaultRuler();
620   rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
621
622   scrollView.SetRulerX( rulerX );
623   scrollView.SetRulerY( rulerY );
624
625   // This time should always scroll to origin (0.0f, 0.0f)
626   scrollView.ScrollTo( 1, 0.0f );
627   Wait(application);
628   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
629   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
630
631   END_TEST;
632 }
633
634
635 int UtcDaliToolkitScrollModeP1(void)
636 {
637   ToolkitTestApplication application;
638   tet_infoline( " UtcDaliToolkitScrollView ScrollMode property" );
639
640   // Set up a scrollView.
641   ScrollView scrollView = ScrollView::New();
642
643   // Do not rely on stage size for UTC tests.
644   Vector2 viewPageSize( 720.0f, 1280.0f );
645   scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
646   scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
647   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
648   scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
649   scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
650
651   // Position rulers.
652   Property::Map rulerMap;
653   rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, true );
654   rulerMap.Add( ScrollMode::X_AXIS_SNAP_TO_INTERVAL, viewPageSize.width );
655   rulerMap.Add( ScrollMode::X_AXIS_SCROLL_BOUNDARY, viewPageSize.width*3 );
656   rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, false );
657   scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
658
659   scrollView.SetWrapMode( false );
660   scrollView.SetScrollSensitive( true );
661
662   application.GetScene().Add( scrollView );
663
664   // Set up a gesture to perform.
665   Vector2 startPos( 50.0f, 0.0f );
666   Vector2 direction( -5.0f, 0.0f );
667   int frames = 200;
668   uint32_t time = 0;
669
670   // Force starting position.
671   scrollView.ScrollTo( startPos, 0.0f );
672   time += Wait( application );
673
674   // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
675   Vector2 currentPos( PerformGestureSwipe( application, startPos, direction, frames - 1, time, false ) );
676
677   // Confirm the final X coord has not moved more than one page from the start X position.
678   DALI_TEST_GREATER( ( startPos.x + viewPageSize.width ), scrollView.GetCurrentScrollPosition().x, TEST_LOCATION );
679
680   // Finish the gesture and wait for the snap.
681   currentPos += direction;
682   TestEndPan( application, currentPos, time );
683   // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
684   time += Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
685
686   // Confirm the final X coord has snapped to exactly one page ahead of the start page.
687   DALI_TEST_EQUALS( viewPageSize.width, scrollView.GetCurrentScrollPosition().x, Math::MACHINE_EPSILON_0, TEST_LOCATION );
688
689   END_TEST;
690 }
691
692 int UtcDaliToolkitScrollModeP2(void)
693 {
694   ToolkitTestApplication application;
695   tet_infoline( " UtcDaliToolkitScrollView ScrollMode property" );
696
697   // Set up a scrollView.
698   ScrollView scrollView = ScrollView::New();
699
700   // Do not rely on stage size for UTC tests.
701   Vector2 viewPageSize( 720.0f, 1280.0f );
702   scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
703   scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
704   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
705   scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
706   scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
707
708   // Position rulers.
709   Property::Map rulerMap;
710   rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, false );
711   rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, true );
712   rulerMap.Add( ScrollMode::Y_AXIS_SNAP_TO_INTERVAL, viewPageSize.height );
713   rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_BOUNDARY, viewPageSize.height*3 );
714   scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
715
716   scrollView.SetWrapMode( false );
717   scrollView.SetScrollSensitive( true );
718
719   application.GetScene().Add( scrollView );
720
721   // Set up a gesture to perform.
722   Vector2 startPos( 0.0f, 50.0f );
723   Vector2 direction( 0.0f, -6.0f );
724   int frames = 200;
725   uint32_t time = 0;
726
727   // Force starting position.
728   scrollView.ScrollTo( startPos, 0.0f );
729   time += Wait( application );
730
731   // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
732   Vector2 currentPos( PerformGestureSwipe( application, startPos, direction, frames - 1, time, false ) );
733
734   // Confirm the final X coord has not moved more than one page from the start X position.
735   DALI_TEST_GREATER( ( startPos.y + viewPageSize.height ), scrollView.GetCurrentScrollPosition().y, TEST_LOCATION );
736
737   // Finish the gesture and wait for the snap.
738   currentPos += direction;
739   time += Wait( application );
740   TestEndPan( application, currentPos, time );
741   // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
742   Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
743
744   // Confirm the final Y coord has snapped to exactly one page ahead of the start page.
745   DALI_TEST_EQUALS( viewPageSize.height, scrollView.GetCurrentScrollPosition().y, Math::MACHINE_EPSILON_0, TEST_LOCATION );
746
747   END_TEST;
748 }
749
750 int UtcDaliToolkitScrollModeP3(void)
751 {
752   ToolkitTestApplication application;
753   tet_infoline( " UtcDaliToolkitScrollView ScrollMode property" );
754
755   // Set up a scrollView.
756   ScrollView scrollView = ScrollView::New();
757
758   // Do not rely on stage size for UTC tests.
759   Vector2 viewPageSize( 720.0f, 1280.0f );
760   scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
761   scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
762   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
763   scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
764   scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
765
766   // Position rulers.
767   Property::Map rulerMap;
768   rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, false );
769   rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, true );
770   rulerMap.Add( ScrollMode::Y_AXIS_SNAP_TO_INTERVAL, viewPageSize.height );
771   rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_BOUNDARY, viewPageSize.height*3 );
772   scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
773
774   scrollView.SetWrapMode( false );
775   scrollView.SetScrollSensitive( true );
776
777   application.GetScene().Add( scrollView );
778
779   // Set up a gesture to perform.
780   Vector2 startPos( 0.0f, 50.0f );
781   Vector2 direction( 0.0f, -6.0f );
782   int frames = 200;
783   uint32_t time  = 0;
784
785   // Force starting position.
786   scrollView.ScrollTo( startPos, 0.0f );
787   time += Wait( application );
788
789   // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
790   Vector2 currentPos( PerformGestureSwipe( application, startPos, direction, frames - 1, time, false ) );
791
792   // Confirm the final X coord has not moved more than one page from the start X position.
793   DALI_TEST_GREATER( ( startPos.y + viewPageSize.height ), scrollView.GetCurrentScrollPosition().y, TEST_LOCATION );
794
795   // Finish the gesture and wait for the snap.
796   currentPos += direction;
797   TestEndPan( application, currentPos, time );
798   // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
799   Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
800
801   // Confirm the final Y coord has snapped to exactly one page ahead of the start page.
802   DALI_TEST_EQUALS( viewPageSize.height, scrollView.GetCurrentScrollPosition().y, Math::MACHINE_EPSILON_0, TEST_LOCATION );
803
804   END_TEST;
805 }
806
807 int UtcDaliToolkitScrollModeP4(void)
808 {
809   ToolkitTestApplication application;
810   tet_infoline( " UtcDaliToolkitScrollView ScrollMode property, DefaultRulers" );
811
812   // Set up a scrollView.
813   ScrollView scrollView = ScrollView::New();
814
815   // Do not rely on stage size for UTC tests.
816   Vector2 viewPageSize( 720.0f, 1280.0f );
817   scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
818   scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
819   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
820   scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
821   scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
822
823   // Position rulers - expect Default rulers to be used which don't snap
824   Property::Map rulerMap;
825   rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, true );
826   rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, true );
827   scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
828
829   scrollView.SetWrapMode( false );
830   scrollView.SetScrollSensitive( true );
831
832   application.GetScene().Add( scrollView );
833
834   Vector2 START_POSITION = Vector2(10.0f, 10.0f);
835
836   uint32_t time = 0;
837   scrollView.ScrollTo(START_POSITION, 0.0f);
838   time += Wait(application);
839
840   // Try a vertical swipe.
841   // PerformGestureSwipe not used as a different initial direction was required
842   Vector2 pos( START_POSITION + Vector2(0.0f, 15.0f) );
843   Vector2 dir( 0.0f, 1.0f );
844
845   TestStartPan( application, START_POSITION, pos, time );
846
847   Wait(application);
848
849   for( int i = 0; i<45; i++ )
850   {
851     pos += dir;
852     TestMovePan( application, pos, time );
853     time += Wait( application );
854   }
855
856   pos += dir;
857
858   TestEndPan( application, pos, time );
859   Wait( application, RENDER_DELAY_SCROLL );
860
861   // Take into account resampling done when prediction is off.
862   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
863
864   END_TEST;
865 }
866
867 int UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP(void)
868 {
869   ToolkitTestApplication application;
870   tet_infoline(" UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP");
871
872   ScrollView scrollView = ScrollView::New();
873   application.GetScene().Add( scrollView );
874   RulerPtr rulerX = new FixedRuler( 100.0f );
875   rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
876   RulerPtr rulerY = new FixedRuler( 100.0f );
877   rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
878
879   scrollView.SetRulerX( rulerX );
880   scrollView.SetRulerY( rulerY );
881
882   scrollView.SetWrapMode(true);
883
884   scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DirectionBiasLeft );
885
886   Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame
887   // Check that the scroll position remains the same
888   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
889
890   Wait(application, RENDER_DELAY_SCROLL); // Wait for one second
891   // Check that it stays at the same page (i.e. the same scroll position)
892   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
893   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
894
895   scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DirectionBiasRight );
896
897   Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame
898   // Check that it scrolls towards the right
899   DALI_TEST_CHECK( scrollView.GetCurrentScrollPosition().x > 0.0f );
900
901   Wait(application, RENDER_DELAY_SCROLL); // Wait for one second
902   // Check that it scrolls back to the same page (i.e. the same scroll position)
903   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
904   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
905
906   END_TEST;
907 }
908
909 int UtcDaliToolkitScrollViewScrollToActorP(void)
910 {
911   ToolkitTestApplication application;
912   tet_infoline(" UtcDaliToolkitScrollViewScrollToActorP");
913
914   ScrollView scrollView = ScrollView::New();
915   application.GetScene().Add( scrollView );
916
917   Actor actorA = Actor::New();
918   const Vector3 positionA = Vector3(100.0f, 400.0f, 0.0f);
919   actorA.SetProperty( Actor::Property::POSITION, positionA );
920   scrollView.Add(actorA);
921
922   Actor actorB = Actor::New();
923   const Vector3 positionB = Vector3(500.0f, 200.0f, 0.0f);
924   actorB.SetProperty( Actor::Property::POSITION, positionB );
925   scrollView.Add(actorB);
926
927   Wait(application);
928
929   scrollView.ScrollTo(actorA, 0.0f);
930   Wait(application);
931   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION );
932
933   Wait(application);
934   scrollView.ScrollTo(actorB, 0.0f);
935   Wait(application);
936   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION );
937
938   scrollView.ScrollTo(actorA);
939   Wait(application, RENDER_DELAY_SCROLL);
940   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION );
941
942   scrollView.ScrollTo(actorB);
943   Wait(application, RENDER_DELAY_SCROLL);
944   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION );
945   END_TEST;
946 }
947
948 int UtcDaliToolkitScrollViewScrollToSnapPointP(void)
949 {
950   ToolkitTestApplication application;
951   tet_infoline(" UtcDaliToolkitScrollViewScrollToSnapPointP");
952
953   ScrollView scrollView = ScrollView::New();
954   application.GetScene().Add( scrollView );
955   RulerPtr rulerX = new FixedRuler( 100.0f );
956   rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
957   RulerPtr rulerY = new FixedRuler( 100.0f );
958   rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
959
960   scrollView.SetRulerX( rulerX );
961   scrollView.SetRulerY( rulerY );
962
963   scrollView.ScrollTo( Vector2(120.0f, 190.0f), 0.0f );
964   Wait(application);
965   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(120.0f, 190.0f), TEST_LOCATION );
966
967   scrollView.ScrollToSnapPoint();
968
969   Wait(application, RENDER_DELAY_SCROLL);
970   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 200.0f), TEST_LOCATION );
971   END_TEST;
972 }
973
974 int UtcDaliToolkitScrollViewSetScrollUpdateDistanceP(void)
975 {
976   ToolkitTestApplication application;
977   tet_infoline(" UtcDaliToolkitScrollViewSetScrollUpdateDistanceP");
978
979   ScrollView scrollView = ScrollView::New();
980
981   scrollView.SetScrollUpdateDistance(0);
982   DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 0, TEST_LOCATION);
983   scrollView.SetScrollUpdateDistance(10);
984   DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 10, TEST_LOCATION);
985   scrollView.SetScrollUpdateDistance(1000);
986   DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 1000, TEST_LOCATION);
987   END_TEST;
988 }
989
990 int UtcDaliToolkitScrollViewSetWrapModeP(void)
991 {
992   ToolkitTestApplication application;
993   tet_infoline(" UtcDaliToolkitScrollViewSetWrapModeP");
994
995   ScrollView scrollView = ScrollView::New();
996   application.GetScene().Add( scrollView );
997
998   Actor actor = Actor::New();
999   scrollView.Add( actor );
1000
1001   // Position rulers. 4x4 grid.
1002   RulerPtr rulerX = new FixedRuler(50.0f);
1003   RulerPtr rulerY = new FixedRuler(50.0f);
1004   rulerX->SetDomain( RulerDomain(0.0f, 200.0f, false) );
1005   rulerY->SetDomain( RulerDomain(0.0f, 200.0f, false) );
1006   scrollView.SetRulerX(rulerX);
1007   scrollView.SetRulerY(rulerY);
1008
1009   scrollView.SetWrapMode(false);
1010   scrollView.ScrollTo(Vector2(225.0f, 125.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
1011   Wait(application);
1012   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 17, TEST_LOCATION );
1013
1014   scrollView.SetWrapMode(true);
1015   scrollView.ScrollTo(Vector2(230.0f, 130.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
1016   Wait(application);
1017   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 13, TEST_LOCATION );
1018   END_TEST;
1019 }
1020
1021 int UtcDaliToolkitScrollViewActorAutoSnap(void)
1022 {
1023   ToolkitTestApplication application;
1024   tet_infoline(" UtcDaliToolkitScrollViewActorAutoSnap");
1025
1026   ScrollView scrollView = ScrollView::New();
1027   application.GetScene().Add( scrollView );
1028
1029   // Position rulers.
1030   RulerPtr rulerX = new DefaultRuler();
1031   RulerPtr rulerY = new DefaultRuler();
1032   rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1033   rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1034   scrollView.SetRulerX(rulerX);
1035   scrollView.SetRulerY(rulerY);
1036
1037   const Vector3 aPosition = Vector3(200.0f, 50.0f, 0.0f);
1038   Actor a = Actor::New();
1039   scrollView.Add(a);
1040   a.SetProperty( Actor::Property::POSITION, aPosition );
1041
1042   const Vector3 bPosition = Vector3(600.0f, 600.0f, 0.0f);
1043   Actor b = Actor::New();
1044   scrollView.Add(b);
1045   b.SetProperty( Actor::Property::POSITION, bPosition );
1046
1047   // Goto a random position, and execute snap (should not move)
1048   Vector2 targetScroll = Vector2(500.0f, 500.0f);
1049   scrollView.ScrollTo(targetScroll, 0.0f);
1050   Wait(application);
1051   scrollView.ScrollToSnapPoint();
1052   Wait(application, RENDER_DELAY_SCROLL);
1053   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), targetScroll, TEST_LOCATION );
1054
1055   // Enable ActorAutoSnap, and now try snapping.
1056   scrollView.SetActorAutoSnap(true);
1057   scrollView.ScrollToSnapPoint();
1058   Wait(application, RENDER_DELAY_SCROLL);
1059   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), bPosition.GetVectorXY(), TEST_LOCATION );
1060
1061   scrollView.ScrollTo(Vector2(0.0f, 0.0f), 0.0f);
1062   Wait(application);
1063   scrollView.ScrollToSnapPoint();
1064   Wait(application, RENDER_DELAY_SCROLL);
1065   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), aPosition.GetVectorXY(), TEST_LOCATION );
1066   END_TEST;
1067 }
1068
1069 int UtcDaliToolkitScrollViewSignalsStartComplete(void)
1070 {
1071   ToolkitTestApplication application;
1072   tet_infoline(" UtcDaliToolkitScrollViewSignalsStartComplete");
1073
1074   gOnScrollStartCalled = false;
1075   gOnScrollCompleteCalled = false;
1076
1077   ScrollView scrollView = ScrollView::New();
1078   application.GetScene().Add( scrollView );
1079
1080   // Position rulers.
1081   RulerPtr rulerX = new DefaultRuler();
1082   RulerPtr rulerY = new DefaultRuler();
1083   rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1084   rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1085   scrollView.SetRulerX(rulerX);
1086   scrollView.SetRulerY(rulerY);
1087   scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1088   scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1089   scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1090   scrollView.ScrollTo( Vector2(100.0f, 100.0f) );
1091   Wait(application, RENDER_DELAY_SCROLL);
1092
1093   DALI_TEST_CHECK(gOnScrollStartCalled);
1094   DALI_TEST_CHECK(gOnScrollCompleteCalled);
1095   END_TEST;
1096 }
1097
1098 int UtcDaliToolkitScrollViewSignalsUpdate01(void)
1099 {
1100   ToolkitTestApplication application;
1101   tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate");
1102
1103   gOnScrollStartCalled = false;
1104   gOnScrollUpdateCalled = false;
1105   gOnScrollCompleteCalled = false;
1106
1107   ScrollView scrollView = ScrollView::New();
1108   application.GetScene().Add( scrollView );
1109   Vector2 stageSize = application.GetScene().GetSize();
1110   scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1111   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1112   scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1113
1114   // Position rulers.
1115   RulerPtr rulerX = new DefaultRuler();
1116   RulerPtr rulerY = new DefaultRuler();
1117   rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1118   rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1119   scrollView.SetRulerX(rulerX);
1120   scrollView.SetRulerY(rulerY);
1121   scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1122   scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1123   scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1124
1125   Actor image = Actor::New();
1126   image.SetProperty( Actor::Property::SIZE, stageSize);
1127   image.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1128   image.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1129   scrollView.Add(image);
1130
1131   Wait(application);
1132
1133   // Do a pan starting from 100,100 and moving down diagonally.
1134   Vector2 pos(100.0f, 100.0f);
1135   uint32_t time = 100;
1136   TestStartPan( application, pos, pos, time );
1137   pos.x += 5.0f;
1138   pos.y += 5.0f;
1139   Wait(application, 100);
1140
1141   for(int i = 0;i<20;i++)
1142   {
1143     time += RENDER_FRAME_INTERVAL;
1144     TestMovePan( application, pos, time);
1145     pos.x += 5.0f;
1146     pos.y += 5.0f;
1147     Wait(application);
1148   }
1149
1150   time += RENDER_FRAME_INTERVAL;
1151   TestEndPan(application, pos, time );
1152   Wait(application, RENDER_DELAY_SCROLL);
1153
1154   DALI_TEST_CHECK(gOnScrollStartCalled);
1155   DALI_TEST_CHECK(gOnScrollUpdateCalled);
1156   DALI_TEST_CHECK(gOnScrollCompleteCalled);
1157   END_TEST;
1158 }
1159
1160 int UtcDaliToolkitScrollViewSignalsUpdate02(void)
1161 {
1162   ToolkitTestApplication application;
1163   tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate");
1164
1165   gOnScrollStartCalled = false;
1166   gOnScrollUpdateCalled = false;
1167   gOnScrollCompleteCalled = false;
1168
1169   ScrollView scrollView = ScrollView::New();
1170   application.GetScene().Add( scrollView );
1171   Vector2 stageSize = application.GetScene().GetSize();
1172   scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1173   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1174   scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1175
1176   // Position rulers.
1177   RulerPtr rulerX = new DefaultRuler();
1178   RulerPtr rulerY = new DefaultRuler();
1179   rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1180   rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1181   scrollView.SetRulerX(rulerX);
1182   scrollView.SetRulerY(rulerY);
1183   Dali::ConnectionTracker tracker;
1184   bool scrollStarted=false;
1185   bool scrollUpdated=false;
1186   bool scrollCompleted=false;
1187   DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollStarted", CallbackFunctor(&scrollStarted) ));
1188   DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollUpdated", CallbackFunctor(&scrollUpdated) ));
1189   DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollCompleted", CallbackFunctor(&scrollCompleted) ));
1190
1191   Actor image = Actor::New();
1192   image.SetProperty( Actor::Property::SIZE, stageSize);
1193   image.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1194   image.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1195   scrollView.Add(image);
1196
1197   Wait(application);
1198
1199   // Do a pan starting from 100,100 and moving down diagonally.
1200   Vector2 pos(100.0f, 100.0f);
1201   uint32_t time = 100;
1202   TestStartPan( application, pos, pos, time );
1203   pos.x += 5.0f;
1204   pos.y += 5.0f;
1205   Wait(application, 100);
1206
1207   for(int i = 0;i<20;i++)
1208   {
1209     time += RENDER_FRAME_INTERVAL;
1210     TestMovePan( application, pos, time);
1211     pos.x += 5.0f;
1212     pos.y += 5.0f;
1213     Wait(application);
1214   }
1215
1216   time += RENDER_FRAME_INTERVAL;
1217   TestEndPan(application, pos, time );
1218   Wait(application, RENDER_DELAY_SCROLL);
1219
1220   DALI_TEST_CHECK(scrollStarted);
1221   DALI_TEST_CHECK(scrollUpdated);
1222   DALI_TEST_CHECK(scrollCompleted);
1223
1224   application.GetScene().Remove( scrollView );
1225
1226   END_TEST;
1227 }
1228
1229 int UtcDaliToolkitScrollViewScrollSensitive(void)
1230 {
1231   ToolkitTestApplication application;
1232   tet_infoline(" UtcDaliToolkitScrollViewScrollSensitive");
1233
1234   // Set up a scrollView...
1235   ScrollView scrollView = ScrollView::New();
1236   scrollView.SetOvershootEnabled(true);
1237   application.GetScene().Add( scrollView );
1238   Vector2 stageSize = application.GetScene().GetSize();
1239   scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1240   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1241   scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1242
1243   // Position rulers.
1244   RulerPtr rulerX = new DefaultRuler();
1245   RulerPtr rulerY = new DefaultRuler();
1246   rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1247   rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1248   scrollView.SetRulerX(rulerX);
1249   scrollView.SetRulerY(rulerY);
1250   scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1251   scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1252   scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1253   scrollView.SnapStartedSignal().Connect( &OnSnapStart );
1254
1255   scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1256   uint32_t time = 0;
1257   time +=Wait(application);
1258
1259   // First try insensitive swipe.
1260   scrollView.SetScrollSensitive(false);
1261   PerformGestureSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, time, true);
1262
1263   DALI_TEST_CHECK( !gOnScrollStartCalled );
1264   DALI_TEST_CHECK( !gOnScrollCompleteCalled );
1265   DALI_TEST_CHECK( !gOnSnapStartCalled );
1266
1267   // Second try sensitive swipe.
1268   scrollView.SetScrollSensitive(true);
1269   PerformGestureSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, time, true);
1270
1271   DALI_TEST_CHECK( gOnScrollStartCalled );
1272   DALI_TEST_CHECK( gOnScrollCompleteCalled );
1273   DALI_TEST_CHECK( gOnSnapStartCalled );
1274   END_TEST;
1275 }
1276
1277 int UtcDaliToolkitScrollViewAxisAutoLock(void)
1278 {
1279   ToolkitTestApplication application;
1280   tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLock");
1281
1282   // Set up a scrollView...
1283   ScrollView scrollView = ScrollView::New();
1284   application.GetScene().Add( scrollView );
1285   Vector2 stageSize = application.GetScene().GetSize();
1286   scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1287   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1288   scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1289
1290   // Position rulers.
1291   RulerPtr rulerX = new DefaultRuler();
1292   RulerPtr rulerY = new DefaultRuler();
1293   rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1294   rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1295   scrollView.SetRulerX(rulerX);
1296   scrollView.SetRulerY(rulerY);
1297   scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1298   scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1299   scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1300
1301   // Normal
1302   scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
1303   uint32_t time = 0;
1304   time += Wait(application);
1305
1306   Vector2 startPosition = scrollView.GetCurrentScrollPosition();
1307   Vector2 dir(5.0f, 1.0f);
1308
1309   // PerformGestureSwipe not used as a different initial direction was required
1310
1311   Vector2 pos( CLAMP_TOUCH_START + Vector2(15.0f, 3.0f) );
1312
1313   TestStartPan( application, CLAMP_TOUCH_START, pos, time );
1314
1315   time += Wait(application);
1316
1317   for( int i = 0; i<47; i++ )
1318   {
1319     pos += dir;
1320     TestMovePan( application, pos, time );
1321     time += Wait( application );
1322   }
1323
1324   pos += dir;
1325
1326   TestEndPan( application, pos, time );
1327
1328   const Vector2 positionAfterNormal = scrollView.GetCurrentScrollPosition();
1329
1330   // Autolock
1331   scrollView.SetAxisAutoLock(true);
1332   DALI_TEST_CHECK(scrollView.GetAxisAutoLock());
1333
1334   scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
1335   time += Wait(application);
1336
1337   Vector2 pos2( CLAMP_TOUCH_START + Vector2(15.0f, 3.0f) );
1338
1339   TestStartPan( application, CLAMP_TOUCH_START, pos2, time );
1340
1341   time += Wait(application);
1342
1343   for( int i = 0; i<47; i++ )
1344   {
1345     pos2 += dir;
1346     TestMovePan( application, pos2, time );
1347     time += Wait( application );
1348   }
1349
1350   pos2 += dir;
1351
1352   TestEndPan( application, pos2, time );
1353
1354   const Vector2 positionAfterAutoLock = scrollView.GetCurrentScrollPosition();
1355
1356   // compare how much the Y position has deviated for normal and autolock.
1357   const float devianceNormal = fabsf(startPosition.y - positionAfterNormal.y);
1358   const float devianceAutoLock = fabsf(startPosition.y - positionAfterAutoLock.y);
1359
1360   // in auto-lock it should be a mostly horizontal pan (thus deviance should be much lower)
1361   DALI_TEST_CHECK(devianceAutoLock < devianceNormal);
1362
1363   scrollView.SetAxisAutoLock(false);
1364   DALI_TEST_CHECK(!scrollView.GetAxisAutoLock());
1365   END_TEST;
1366 }
1367
1368 int UtcDaliToolkitScrollViewAxisAutoLockGradient(void)
1369 {
1370   ToolkitTestApplication application;
1371   tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLockGradient");
1372
1373   // Set up a scrollView...
1374   ScrollView scrollView = ScrollView::New();
1375   scrollView.SetAxisAutoLockGradient(0.5f);
1376   DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 0.5f, TEST_LOCATION);
1377   scrollView.SetAxisAutoLockGradient(1.0f);
1378   DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 1.0f, TEST_LOCATION);
1379   END_TEST;
1380 }
1381
1382 int UtcDaliToolkitScrollViewConstraints(void)
1383 {
1384   ToolkitTestApplication application;
1385   tet_infoline(" UtcDaliToolkitScrollViewConstraints");
1386
1387   // Set up a scrollView...
1388   ScrollView scrollView = ScrollView::New();
1389   application.GetScene().Add( scrollView );
1390   Vector2 stageSize = application.GetScene().GetSize();
1391   scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1392   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1393   scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1394
1395   // Position rulers.
1396   RulerPtr rulerX = new DefaultRuler();
1397   RulerPtr rulerY = new DefaultRuler();
1398   rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1399   rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1400   scrollView.SetRulerX(rulerX);
1401   scrollView.SetRulerY(rulerY);
1402
1403   // Add an Actor to ScrollView,
1404   // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1405   gConstraintResult = Vector3::ZERO;
1406   Actor a = Actor::New();
1407   scrollView.Add(a);
1408   a.SetProperty( Actor::Property::POSITION, TEST_ACTOR_POSITION);
1409   Wait(application);
1410
1411   Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1412   constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
1413   constraint.SetRemoveAction(Constraint::Discard);
1414   scrollView.ApplyConstraintToChildren(constraint);
1415   Wait(application);
1416
1417   DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1418
1419   gConstraintResult = Vector3::ZERO;
1420   scrollView.RemoveConstraintsFromChildren();
1421   Wait(application);
1422
1423   DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
1424   END_TEST;
1425 }
1426
1427 int UtcDaliToolkitScrollViewBind(void)
1428 {
1429   ToolkitTestApplication application;
1430   tet_infoline(" UtcDaliToolkitScrollViewBind");
1431
1432   // Set up a scrollView...
1433   ScrollView scrollView = ScrollView::New();
1434   application.GetScene().Add( scrollView );
1435   Vector2 stageSize = application.GetScene().GetSize();
1436   scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1437   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1438   scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1439
1440   // Position rulers.
1441   RulerPtr rulerX = new DefaultRuler();
1442   RulerPtr rulerY = new DefaultRuler();
1443   rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1444   rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1445   scrollView.SetRulerX(rulerX);
1446   scrollView.SetRulerY(rulerY);
1447
1448   // Add an Actor to ScrollView,
1449   // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1450
1451   gConstraintResult = Vector3::ZERO;
1452   Actor a = Actor::New();
1453   scrollView.Add(a);
1454   a.SetProperty( Actor::Property::POSITION, TEST_ACTOR_POSITION);
1455   Wait(application);
1456
1457   // apply this constraint to scrollview
1458   Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1459   constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
1460   constraint.SetRemoveAction(Constraint::Discard);
1461   scrollView.ApplyConstraintToChildren(constraint);
1462
1463   Wait(application);
1464   // Defaulty Bound.
1465   DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1466
1467   // UnBind
1468   gConstraintResult = Vector3::ZERO;
1469   scrollView.UnbindActor( a );
1470   Wait(application);
1471   DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
1472
1473   // Bind
1474   gConstraintResult = Vector3::ZERO;
1475   scrollView.BindActor( a );
1476   Wait(application);
1477   DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1478   END_TEST;
1479 }
1480
1481 int UtcDaliToolkitScrollViewOvershoot(void)
1482 {
1483   ToolkitTestApplication application;
1484   tet_infoline(" UtcDaliToolkitScrollViewOvershoot");
1485
1486   // Set up a scrollView...
1487   ScrollView scrollView = ScrollView::New();
1488   scrollView.SetOvershootEnabled(true);
1489
1490   uint32_t time = 0;
1491   Vector2 overshootSize = Vector2(100.0f,100.0f);
1492   scrollView.SetProperty( Scrollable::Property::OVERSHOOT_SIZE, overshootSize );
1493   DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_SIZE).Get<Vector2>(), overshootSize, TEST_LOCATION );
1494
1495   application.GetScene().Add( scrollView );
1496   Vector2 stageSize = application.GetScene().GetSize();
1497   scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1498   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1499   scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1500
1501   // Position rulers.
1502   RulerPtr rulerX = new DefaultRuler();
1503   RulerPtr rulerY = new DefaultRuler();
1504   rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1505   rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1506   scrollView.SetRulerX(rulerX);
1507   scrollView.SetRulerY(rulerY);
1508   scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1509   scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1510   scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1511
1512   scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1513   time += Wait(application);
1514
1515   // 1. Scroll page in NW (-500,-500 pixels), then inspect overshoot. (don't release touch)
1516   Vector2 currentPos = Vector2(100.0f, 100.0f);
1517   currentPos = PerformGestureSwipe(application, currentPos, Vector2(5.0f, 5.0f), 100, time, false);
1518   float overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1519   float overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1520   Vector2 positionValue = scrollView.GetCurrentProperty< Vector2 >( ScrollView::Property::SCROLL_POSITION );
1521   DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1522   DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1523   DALI_TEST_EQUALS(positionValue, Vector2::ZERO, TEST_LOCATION);
1524
1525   float timeToReachOrigin;
1526
1527   // Now release touch. Overshoot should snap back to zero.
1528   TestEndPan(application, currentPos, time);
1529
1530   timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1531
1532   float minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1533   float maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1534
1535   DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1536                    (timeToReachOrigin < maxTimeToReachOrigin) );
1537
1538   // 2. Repeat Scroll, but this time change overshoot snap duration to shorter time
1539   scrollView.SetSnapOvershootDuration(TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION);
1540
1541   currentPos = PerformGestureSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, time, false);
1542   // Now release touch. Overshoot should snap back to zero.
1543   TestEndPan(application, currentPos, time);
1544   timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1545
1546   minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1547   maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1548
1549   DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1550                    (timeToReachOrigin < maxTimeToReachOrigin) );
1551
1552   // 3. Repeat Scroll, but this time change overshoot snap duration to longer time.
1553   scrollView.SetSnapOvershootDuration(TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION);
1554
1555   currentPos = PerformGestureSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, time, false);
1556   // Now release touch. Overshoot should snap back to zero.
1557   TestEndPan(application, currentPos, time);
1558   timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1559
1560   minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1561   maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1562
1563   DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1564                    (timeToReachOrigin < maxTimeToReachOrigin) );
1565
1566   // 4. Repeat Scroll, but this time change overshoot function.
1567   scrollView.SetSnapOvershootDuration(TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION);
1568   scrollView.SetSnapOvershootAlphaFunction(TestAlphaFunction);
1569
1570   currentPos = PerformGestureSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, time, false);
1571   // Now release touch. Overshoot should snap back to zero.
1572   TestEndPan(application, currentPos, time);
1573   timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1574
1575   minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1576   maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1577
1578   DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1579                    (timeToReachOrigin < maxTimeToReachOrigin) );
1580   END_TEST;
1581 }
1582
1583 int UtcDaliToolkitScrollViewSnapAlphaFunction(void)
1584 {
1585   ToolkitTestApplication application;
1586   tet_infoline(" UtcDaliToolkitScrollViewSnapAlphaFunction");
1587
1588   // Set up a scrollView...
1589   ScrollView scrollView = ScrollView::New();
1590   scrollView.SetScrollSnapAlphaFunction( AlphaFunction::EASE_IN );
1591   DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_IN );
1592   scrollView.SetScrollSnapAlphaFunction( AlphaFunction::EASE_OUT );
1593   DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_OUT );
1594
1595   scrollView.SetScrollFlickAlphaFunction( AlphaFunction::BOUNCE );
1596   DALI_TEST_CHECK( scrollView.GetScrollFlickAlphaFunction().GetBuiltinFunction() == AlphaFunction::BOUNCE );
1597
1598   END_TEST;
1599 }
1600
1601 int UtcDaliToolkitScrollViewSnapDuration(void)
1602 {
1603   ToolkitTestApplication application;
1604   tet_infoline(" UtcDaliToolkitScrollViewSnapDuration");
1605
1606   // Set up a scrollView...
1607   ScrollView scrollView = ScrollView::New();
1608   scrollView.SetScrollSnapDuration( 1.0f );
1609   DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 1.0f, TEST_LOCATION );
1610   scrollView.SetScrollSnapDuration( 0.5f );
1611   DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 0.5f, TEST_LOCATION );
1612
1613   scrollView.SetScrollFlickDuration( 2.0f );
1614   DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 2.0f, TEST_LOCATION );
1615   scrollView.SetScrollFlickDuration( 1.5f );
1616   DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 1.5f, TEST_LOCATION );
1617   END_TEST;
1618 }
1619
1620 int UtcDaliToolkitScrollViewSnapStartedSignalP(void)
1621 {
1622   ToolkitTestApplication application;
1623   tet_infoline(" UtcDaliToolkitScrollViewSnapStartedSignalP");
1624
1625   // Set up a scrollView...
1626   ScrollView scrollView = ScrollView::New();
1627   application.GetScene().Add( scrollView );
1628   Vector2 stageSize = application.GetScene().GetSize();
1629   scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1630   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1631   scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1632
1633   // Position rulers.
1634   RulerPtr rulerX = new DefaultRuler();
1635   RulerPtr rulerY = new DefaultRuler();
1636   rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1637   rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1638   scrollView.SetRulerX(rulerX);
1639   scrollView.SetRulerY(rulerY);
1640   scrollView.SnapStartedSignal().Connect( &OnSnapStart );
1641
1642   scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1643   uint32_t time = 0;
1644   time += Wait(application);
1645
1646   // First try a snap.
1647   PerformGestureSwipe(application, CLAMP_TOUCH_START, Vector2(0.5f, 0.0f), 60, time, true);
1648
1649   DALI_TEST_CHECK( gOnSnapStartCalled );
1650   DALI_TEST_CHECK( gLastSnapType == Toolkit::Snap );
1651
1652   // Second try a swipe.
1653   PerformGestureSwipe(application, CLAMP_TOUCH_START, Vector2(20.0f, 0.0f), 60, time, true);
1654
1655   DALI_TEST_CHECK( gOnSnapStartCalled );
1656   DALI_TEST_CHECK( gLastSnapType == Toolkit::Flick );
1657   END_TEST;
1658 }
1659
1660 int UtcDaliToolkitScrollViewGetCurrentPageP(void)
1661 {
1662   ToolkitTestApplication application;
1663   tet_infoline(" UtcDaliToolkitScrollViewGetCurrentPageP");
1664
1665   ScrollView scrollView = ScrollView::New();
1666   application.GetScene().Add( scrollView );
1667   RulerPtr rulerX = new FixedRuler( 100.0f );
1668   rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1669   RulerPtr rulerY = new FixedRuler( 100.0f );
1670   rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1671
1672   scrollView.SetRulerX( rulerX );
1673   scrollView.SetRulerY( rulerY );
1674
1675   scrollView.ScrollTo( 15 );
1676   Wait(application, RENDER_DELAY_SCROLL);
1677   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION );
1678
1679   scrollView.ScrollTo( 3 );
1680   Wait(application, RENDER_DELAY_SCROLL);
1681   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION );
1682
1683   scrollView.ScrollTo( 9 );
1684   Wait(application, RENDER_DELAY_SCROLL);
1685   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION );
1686
1687   END_TEST;
1688 }
1689
1690 int UtcDaliToolkitScrollViewSetMaxOvershootP(void)
1691 {
1692   ToolkitTestApplication application;
1693   tet_infoline(" UtcDaliToolkitScrollViewSetMaxOvershootP");
1694
1695   // Set up a scrollView...
1696   ScrollView scrollView = ScrollView::New();
1697   application.GetScene().Add( scrollView );
1698   Vector2 stageSize = application.GetScene().GetSize();
1699   scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1700   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1701   scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1702
1703   // Position rulers.
1704   RulerPtr rulerX = new DefaultRuler();
1705   RulerPtr rulerY = new DefaultRuler();
1706   rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1707   rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1708   scrollView.SetRulerX(rulerX);
1709   scrollView.SetRulerY(rulerY);
1710
1711   // Set the max overshoot to be 50 pixels in both X axis and Y axis
1712   scrollView.SetMaxOvershoot(50.0f, 50.0f);
1713
1714   scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1715   uint32_t time = 0;
1716   time += Wait(application);
1717
1718   // Scroll page in NW (-20,-20 pixels), then check that overshoot should be 0. (don't release touch)
1719   Vector2 currentPos = PerformGestureSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 10, time, false);
1720   float overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1721   float overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1722   DALI_TEST_EQUALS(overshootXValue, 0.0f, TEST_LOCATION);
1723   DALI_TEST_EQUALS(overshootYValue, 0.0f, TEST_LOCATION);
1724
1725   time += Wait(application);
1726   // Scroll page further in NW (-105,-105 pixels), then check that overshoot should be around 0.5. (don't release touch)
1727   for(int i = 0; i<106; i++)
1728   {
1729     TestMovePan(application, currentPos, time );
1730     currentPos += Vector2(1.0f, 1.0f);
1731     time += Wait(application);
1732   }
1733
1734   overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1735   overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1736   // The overshoot value is a 0.0f - 1.0f ranged value of the amount overshot related to the maximum overshoot.
1737   // EG. If we move 105, max overshoot is 50, then we overshot 50 / 105.
1738   float correctOvershootValue = 0.508f;   // This was measured and then set as the limit
1739   DALI_TEST_EQUALS( overshootXValue, correctOvershootValue, 0.001f, TEST_LOCATION );
1740   DALI_TEST_EQUALS( overshootYValue, correctOvershootValue, 0.001f, TEST_LOCATION );
1741
1742   // Scroll page further in NW (-25,-25 pixels), then check that overshoot should be now 1.0. (don't release touch)
1743   for(int i = 0;i<25;i++)
1744   {
1745     TestMovePan(application, currentPos, time );
1746     currentPos += Vector2(1.0f, 1.0f); // Move in this direction
1747     time += Wait(application);
1748   }
1749
1750   overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1751   overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1752   DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1753   DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1754
1755   // Change the max overshoot to be 250 pixels in both X axis and Y axis
1756   scrollView.SetMaxOvershoot(250.0f, 250.0f);
1757   time += Wait(application);
1758
1759   // Check that overshoot should be now around 0.8.
1760   overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1761   overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1762   DALI_TEST_CHECK(overshootXValue > 0.79f && overshootXValue < 0.81f);
1763   DALI_TEST_CHECK(overshootYValue > 0.79f && overshootYValue < 0.81f);
1764
1765   // Scroll page further in NW (-50,-50 pixels), then check that overshoot should be now 1.0. (don't release touch)
1766   for(int i = 0;i<50;i++)
1767   {
1768     TestMovePan(application, currentPos, time );
1769     currentPos += Vector2(1.0f, 1.0f); // Move in this direction
1770     time += Wait(application);
1771   }
1772
1773   overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1774   overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1775   DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1776   DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1777
1778   END_TEST;
1779 }
1780
1781 int UtcDaliToolkitScrollViewSetScrollingDirectionP(void)
1782 {
1783   ToolkitTestApplication application;
1784   tet_infoline(" UtcDaliToolkitScrollViewSetScrollingDirectionP");
1785
1786   // Set up a scrollView...
1787   ScrollView scrollView = ScrollView::New();
1788   application.GetScene().Add( scrollView );
1789   Vector2 stageSize = application.GetScene().GetSize();
1790   scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1791   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1792   scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1793
1794   Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1795
1796   scrollView.ScrollTo(START_POSITION, 0.0f);
1797   uint32_t time = 0;
1798   time += Wait(application);
1799
1800   // Try a vertical swipe.
1801   // PerformGestureSwipe not used as a different initial direction was required
1802
1803   Vector2 pos( START_POSITION + Vector2(0.0f, 15.0f) );
1804   TestStartPan( application, START_POSITION, pos, time );
1805   time += Wait(application);
1806   for( int i = 0; i<45; i++ )
1807   {
1808     pos += Vector2(0.0f, 1.0f);
1809     TestMovePan( application, pos, time );
1810     time += Wait( application );
1811   }
1812   pos += Vector2(0.0f, 1.0f);
1813   TestEndPan( application, pos, time );
1814   time += Wait( application );
1815
1816   // Take into account resampling done when prediction is off.
1817   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1818
1819   scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1820
1821   scrollView.ScrollTo(START_POSITION, 0.0f);
1822   time += Wait(application);
1823
1824   // Try a vertical swipe.
1825   // PerformGestureSwipe not used as a different initial direction was required
1826   pos = ( START_POSITION + Vector2(0.0f, 15.0f) );
1827   TestStartPan( application, START_POSITION, pos, time );
1828   time += Wait(application);
1829   for( int i = 0; i<45; i++ )
1830   {
1831     pos += Vector2(0.0f, 1.0f);
1832     TestMovePan( application, pos, time );
1833     time += Wait( application );
1834   }
1835   pos += Vector2(0.0f, 1.0f);
1836   TestEndPan( application, pos, time );
1837   time += Wait( application );
1838
1839   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1840
1841   scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1842
1843   scrollView.ScrollTo(START_POSITION, 0.0f);
1844
1845   time += Wait(application);
1846
1847   // Try a vertical swipe.
1848   // PerformGestureSwipe not used as a different initial direction was required
1849   pos = ( START_POSITION + Vector2(0.0f, 15.0f) );
1850   TestStartPan( application, START_POSITION, pos, time );
1851   time += Wait(application);
1852   for( int i = 0; i<45; i++ )
1853   {
1854     pos += Vector2(0.0f, 1.0f);
1855     TestMovePan( application, pos, time );
1856     time += Wait( application );
1857   }
1858   pos += Vector2(0.0f, 1.0f);
1859   TestEndPan( application, pos, time );
1860   time += Wait( application );
1861
1862   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1863
1864   END_TEST;
1865 }
1866
1867 int UtcDaliToolkitScrollViewRemoveScrollingDirectionP(void)
1868 {
1869   ToolkitTestApplication application;
1870   tet_infoline(" UtcDaliToolkitScrollViewRemoveScrollingDirectionP");
1871
1872   // Set up a scrollView...
1873   ScrollView scrollView = ScrollView::New();
1874   application.GetScene().Add( scrollView );
1875   Vector2 stageSize = application.GetScene().GetSize();
1876   scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1877   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1878   scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1879
1880   Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1881   uint32_t time = 0;
1882
1883   scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1884
1885   scrollView.ScrollTo(START_POSITION, 0.0f);
1886
1887   time += Wait(application);
1888
1889   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION );
1890
1891   // Try a vertical swipe.
1892   // PerformGestureSwipe not used as a different initial direction was required
1893   Vector2 pos( START_POSITION + Vector2(0.0f, 15.0f) );
1894   TestStartPan( application, START_POSITION, pos, time );
1895   time += Wait(application);
1896   for( int i = 0; i<45; i++ )
1897   {
1898     pos += Vector2(0.0f, 1.0f);
1899     TestMovePan( application, pos, time );
1900     time += Wait( application );
1901   }
1902   pos += Vector2(0.0f, 1.0f);
1903   TestEndPan( application, pos, time );
1904   time += Wait( application );
1905
1906   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1907
1908   scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1909   // When the horizontal direction is removed, there are no directions set and therefore all will work
1910   scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_HORIZONTAL);
1911
1912   time += Wait(application);
1913   // Try a vertical swipe.
1914   Vector2 pos2( pos + Vector2(0.0f, 15.0f) );
1915   TestStartPan( application, pos, pos2, time );
1916   time += Wait(application);
1917   for( int i = 0; i<45; i++ )
1918   {
1919     pos2 += Vector2(0.0f, 1.0f);
1920     TestMovePan( application, pos2, time );
1921     time += Wait( application );
1922   }
1923   pos2 += Vector2(0.0f, 1.0f);
1924   TestEndPan( application, pos2, time );
1925
1926   // The previous scroll should not have had any effect
1927   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1928
1929   END_TEST;
1930 }
1931
1932 int UtcDaliToolkitScrollViewSetRulerXP(void)
1933 {
1934   ToolkitTestApplication application;
1935   tet_infoline(" UtcDaliToolkitScrollViewSetRulerXP");
1936
1937   ScrollView scrollView = ScrollView::New();
1938   application.GetScene().Add( scrollView );
1939   RulerPtr rulerX = new FixedRuler( 100.0f );
1940   rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1941
1942   scrollView.SetRulerX( rulerX );
1943
1944   scrollView.ScrollTo( 1, 0.0f );
1945   Wait(application);
1946   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION );
1947
1948   RulerPtr newRulerX = new FixedRuler( 200.0f );
1949   newRulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1950
1951   scrollView.SetRulerX( newRulerX );
1952
1953   scrollView.ScrollTo( 1, 0.0f );
1954   Wait(application);
1955   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 0.0f), TEST_LOCATION );
1956
1957   END_TEST;
1958 }
1959
1960 int UtcDaliToolkitScrollViewSetRulerYP(void)
1961 {
1962   ToolkitTestApplication application;
1963   tet_infoline(" UtcDaliToolkitScrollViewSetRulerYP");
1964
1965   ScrollView scrollView = ScrollView::New();
1966   application.GetScene().Add( scrollView );
1967
1968   RulerPtr rulerY = new FixedRuler( 200.0f );
1969   rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1970
1971   scrollView.SetRulerY( rulerY );
1972
1973   scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f );
1974   Wait(application);
1975   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 350.0f), TEST_LOCATION );
1976
1977   RulerPtr newRulerY = new FixedRuler( 100.0f );
1978   newRulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
1979   scrollView.SetRulerY( newRulerY );
1980
1981   scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f );
1982   Wait(application);
1983   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 200.0f), TEST_LOCATION );
1984
1985   END_TEST;
1986 }
1987
1988 int UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP(void)
1989 {
1990   ToolkitTestApplication application;
1991   tet_infoline(" UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP");
1992
1993   ScrollView scrollView = ScrollView::New();
1994   scrollView.SetMinimumSpeedForFlick(25.0f);
1995   DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 25.0f, TEST_LOCATION );
1996   scrollView.SetMinimumSpeedForFlick(60.0f);
1997   DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 60.0f, TEST_LOCATION );
1998   END_TEST;
1999 }
2000
2001 int UtcDaliToolkitScrollViewSetMinimumDistanceForFlickP(void)
2002 {
2003   ToolkitTestApplication application;
2004   tet_infoline(" UtcDaliToolkitScrollViewSetMinimumDistanceForFlick");
2005
2006   ScrollView scrollView = ScrollView::New();
2007
2008   scrollView.SetMinimumDistanceForFlick(Vector2(30.0f, 15.0f));
2009   DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(30.0f, 15.0f), TEST_LOCATION );
2010   scrollView.SetMinimumDistanceForFlick(Vector2(60.0f, 30.0f));
2011   DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(60.0f, 30.0f), TEST_LOCATION);
2012   END_TEST;
2013 }
2014
2015 int UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP(void)
2016 {
2017   ToolkitTestApplication application;
2018   tet_infoline(" UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP");
2019
2020   ScrollView scrollView = ScrollView::New();
2021   // Disable Refresh signal (TET environment cannot use adaptor's Timer)
2022   scrollView.SetWheelScrollDistanceStep(Vector2(30.0f, 15.0f));
2023   DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(30.0f, 15.0f), TEST_LOCATION );
2024   scrollView.SetWheelScrollDistanceStep(Vector2(60.0f, 30.0f));
2025   DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(60.0f, 30.0f), TEST_LOCATION);
2026   END_TEST;
2027 }
2028
2029 int UtcDaliToolkitScrollViewApplyEffectP(void)
2030 {
2031   ToolkitTestApplication application;
2032   tet_infoline(" UtcDaliToolkitScrollViewApplyEffectP");
2033
2034   // Create a ScrollView
2035   ScrollView scrollView = ScrollView::New();
2036
2037   // Create two scroll view effects
2038   Dali::Path path = Dali::Path::New();
2039   ScrollViewEffect effect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 0.0f, 0.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(100.0f, 100.0f, 0.0f), 2);
2040   ScrollViewEffect newEffect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 1.0f, 1.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(200.0f, 150.0f, 0.0f), 5);
2041
2042   // Apply both effects
2043   scrollView.ApplyEffect(effect);
2044   scrollView.ApplyEffect(newEffect);
2045
2046   DALI_TEST_CHECK( true );
2047
2048   END_TEST;
2049 }
2050
2051 int UtcDaliToolkitScrollViewApplyEffectN(void)
2052 {
2053   ToolkitTestApplication application;
2054   tet_infoline(" UtcDaliToolkitScrollViewApplyEffectN");
2055
2056   // Create a ScrollView
2057   ScrollView scrollView = ScrollView::New();
2058
2059   // Create two scroll view effects
2060   Dali::Path path = Dali::Path::New();
2061   ScrollViewEffect effect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 0.0f, 0.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(100.0f, 100.0f, 0.0f), 2);
2062   ScrollViewEffect newEffect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 1.0f, 1.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(200.0f, 150.0f, 0.0f), 5);
2063
2064   // Apply both effects
2065   scrollView.ApplyEffect(effect);
2066   scrollView.ApplyEffect(newEffect);
2067
2068   // Attempt to apply the same effect again
2069   try
2070   {
2071     scrollView.ApplyEffect(newEffect);
2072     tet_result( TET_FAIL );
2073   }
2074   catch ( DaliException& e )
2075   {
2076     DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
2077   }
2078
2079   END_TEST;
2080 }
2081
2082 int UtcDaliToolkitScrollViewRemoveEffectP(void)
2083 {
2084   ToolkitTestApplication application;
2085   tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectP");
2086
2087   // Create a ScrollView
2088   ScrollView scrollView = ScrollView::New();
2089
2090   // Create two scroll view effects
2091   Dali::Path path = Dali::Path::New();
2092   ScrollViewEffect effect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 0.0f, 0.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(100.0f, 100.0f, 0.0f), 2);
2093   ScrollViewEffect newEffect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 1.0f, 1.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(200.0f, 150.0f, 0.0f), 5);
2094
2095   // Apply both effects
2096   scrollView.ApplyEffect(effect);
2097   scrollView.ApplyEffect(newEffect);
2098
2099   // Remove both effects
2100   scrollView.RemoveEffect(effect);
2101   scrollView.RemoveEffect(newEffect);
2102
2103   DALI_TEST_CHECK( true );
2104
2105   END_TEST;
2106 }
2107
2108 int UtcDaliToolkitScrollViewRemoveEffectN(void)
2109 {
2110   ToolkitTestApplication application;
2111   tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectN");
2112
2113   // Create a ScrollView
2114   ScrollView scrollView = ScrollView::New();
2115
2116   // Create two scroll view effects
2117   Dali::Path path = Dali::Path::New();
2118   ScrollViewEffect effect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 0.0f, 0.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(100.0f, 100.0f, 0.0f), 2);
2119   ScrollViewEffect newEffect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 1.0f, 1.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(200.0f, 150.0f, 0.0f), 5);
2120
2121   // Apply the first effect
2122   scrollView.ApplyEffect(effect);
2123
2124   // Attempt to remove the second effect which has not been applied to scroll view
2125   try
2126   {
2127     scrollView.RemoveEffect(newEffect);
2128     tet_result( TET_FAIL );
2129   }
2130   catch ( DaliException& e )
2131   {
2132     DALI_TEST_ASSERT( e, "effectExistedInScrollView", TEST_LOCATION );
2133   }
2134
2135   END_TEST;
2136 }
2137
2138 int UtcDaliToolkitScrollViewRemoveAllEffectsP(void)
2139 {
2140   ToolkitTestApplication application;
2141   tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsP");
2142
2143   // Create a ScrollView
2144   ScrollView scrollView = ScrollView::New();
2145
2146   // Create two scroll view effects
2147   Dali::Path path = Dali::Path::New();
2148   ScrollViewEffect effect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 0.0f, 0.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(100.0f, 100.0f, 0.0f), 2);
2149   ScrollViewEffect newEffect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 1.0f, 1.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(200.0f, 150.0f, 0.0f), 5);
2150
2151   // Apply both effects
2152   scrollView.ApplyEffect(effect);
2153   scrollView.ApplyEffect(newEffect);
2154
2155   // Attempt to apply the same first effect again
2156   try
2157   {
2158     scrollView.ApplyEffect(effect);
2159     tet_result( TET_FAIL );
2160   }
2161   catch ( DaliException& e )
2162   {
2163     DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
2164   }
2165
2166   // Remove both effects
2167   scrollView.RemoveAllEffects();
2168
2169   // Apply both effects again
2170   scrollView.ApplyEffect(effect);
2171   scrollView.ApplyEffect(newEffect);
2172
2173   DALI_TEST_CHECK( true );
2174
2175   END_TEST;
2176 }
2177
2178 int UtcDaliToolkitScrollViewRemoveAllEffectsN(void)
2179 {
2180   ToolkitTestApplication application;
2181   tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsN");
2182
2183   // Create a ScrollView
2184   ScrollView scrollView = ScrollView::New();
2185
2186   // Remove effects when there is no effect applied previously
2187   scrollView.RemoveAllEffects();
2188
2189   DALI_TEST_CHECK( true );
2190
2191   END_TEST;
2192 }
2193
2194 int UtcDaliToolkitScrollViewSetOvershootEnabledP(void)
2195 {
2196   ToolkitTestApplication application;
2197   tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEnabledP");
2198
2199   ScrollView scrollView = ScrollView::New();
2200
2201   scrollView.SetOvershootEnabled(true);
2202   DALI_TEST_CHECK(scrollView.IsOvershootEnabled());
2203
2204   scrollView.SetOvershootEnabled(false);
2205   DALI_TEST_CHECK(!scrollView.IsOvershootEnabled());
2206
2207   END_TEST;
2208 }
2209
2210 int UtcDaliToolkitScrollViewSetOvershootEffectColorP(void)
2211 {
2212   ToolkitTestApplication application;
2213   tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEffectColorP");
2214
2215   ScrollView scrollView = ScrollView::New();
2216
2217   scrollView.SetOvershootEffectColor(Dali::Color::RED);
2218   DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::RED, TEST_LOCATION);
2219
2220   scrollView.SetOvershootEffectColor(Dali::Color::YELLOW);
2221   DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::YELLOW, TEST_LOCATION);
2222
2223   END_TEST;
2224 }
2225
2226 int UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP(void)
2227 {
2228   ToolkitTestApplication application;
2229   tet_infoline(" UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP");
2230
2231   ScrollView scrollView = ScrollView::New();
2232
2233   scrollView.SetOvershootAnimationSpeed(55.0f);
2234   DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 55.0f, TEST_LOCATION);
2235
2236   scrollView.SetOvershootAnimationSpeed(120.0f);
2237   DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 120.0f, TEST_LOCATION);
2238
2239   END_TEST;
2240 }
2241
2242 int UtcDaliToolkitScrollViewGetSet(void)
2243 {
2244   ToolkitTestApplication application;
2245   tet_infoline(" UtcDaliToolkitScrollViewGetSet");
2246   ScrollView scrollView = ScrollView::New();
2247   scrollView.SetMaxFlickSpeed(0.5f);
2248   DALI_TEST_EQUALS(scrollView.GetMaxFlickSpeed(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
2249   scrollView.SetFrictionCoefficient(0.6f);
2250   DALI_TEST_EQUALS(scrollView.GetFrictionCoefficient(), 0.6f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
2251   scrollView.SetFlickSpeedCoefficient(0.7f);
2252   DALI_TEST_EQUALS(scrollView.GetFlickSpeedCoefficient(), 0.7f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
2253   END_TEST;
2254 }
2255
2256 int UtcDaliToolkitScrollViewRulerDomainConstructorP(void)
2257 {
2258   ToolkitTestApplication application;
2259
2260   RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2261   DALI_TEST_EQUALS( domainX.min, 0.0f, TEST_LOCATION);
2262   DALI_TEST_EQUALS( domainX.max, 200.0f, TEST_LOCATION);
2263   DALI_TEST_EQUALS( domainX.enabled, true, TEST_LOCATION);
2264
2265   RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
2266   DALI_TEST_EQUALS( domainY.min, 100.0f, TEST_LOCATION);
2267   DALI_TEST_EQUALS( domainY.max, 500.0f, TEST_LOCATION);
2268   DALI_TEST_EQUALS( domainY.enabled, false, TEST_LOCATION);
2269
2270   END_TEST;
2271 }
2272
2273 int UtcDaliToolkitScrollViewRulerDomainGetSizeP(void)
2274 {
2275   ToolkitTestApplication application;
2276
2277   RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2278   DALI_TEST_EQUALS( domainX.GetSize(), 200.0f, TEST_LOCATION);
2279
2280   RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
2281   DALI_TEST_EQUALS( domainY.GetSize(), 400.0f, TEST_LOCATION);
2282
2283   END_TEST;
2284 }
2285
2286 int UtcDaliToolkitScrollViewRulerDomainClampP(void)
2287 {
2288   ToolkitTestApplication application;
2289
2290   RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2291
2292   float value = domainX.Clamp(50.0f, 100.0f, 1.0f);
2293   DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
2294
2295   value = domainX.Clamp(300.0f, 20.0f, 1.0f);
2296   DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
2297
2298   value = domainX.Clamp(300.0f, 20.0f, 0.5f);
2299   DALI_TEST_EQUALS( value, 80.0f, TEST_LOCATION);
2300
2301   value = domainX.Clamp(250.0f, 200.0f, 2.0f);
2302   DALI_TEST_EQUALS( value, 200.0f, TEST_LOCATION);
2303
2304   END_TEST;
2305 }
2306
2307 int UtcDaliToolkitScrollViewRulerDomainClampWithStateP(void)
2308 {
2309   ToolkitTestApplication application;
2310
2311   RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2312
2313   ClampState clamped;
2314   float value = domainX.Clamp(50.0f, 100.0f, 1.0f, clamped);
2315   DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
2316   DALI_TEST_EQUALS( clamped, Dali::Toolkit::NotClamped, TEST_LOCATION);
2317
2318   value = domainX.Clamp(-100.0f, 200.0f, 1.0f, clamped);
2319   DALI_TEST_EQUALS( value, 0.0f, TEST_LOCATION);
2320   DALI_TEST_EQUALS( clamped, Dali::Toolkit::ClampedToMin, TEST_LOCATION);
2321
2322   value = domainX.Clamp(300.0f, 20.0f, 1.0f, clamped);
2323   DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
2324   DALI_TEST_EQUALS( clamped, Dali::Toolkit::ClampedToMax, TEST_LOCATION);
2325
2326   END_TEST;
2327 }
2328
2329 int UtcDaliToolkitScrollViewDefaultRulerConstructorP(void)
2330 {
2331   ToolkitTestApplication application;
2332   tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerConstructorP");
2333
2334   RulerPtr defaultRuler = new DefaultRuler();
2335   DALI_TEST_CHECK( defaultRuler );
2336
2337   END_TEST;
2338 }
2339
2340 int UtcDaliToolkitScrollViewDefaultRulerDestructorP(void)
2341 {
2342   ToolkitTestApplication application;
2343   tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerDestructorP");
2344
2345   RulerPtr defaultRuler = new DefaultRuler();
2346
2347   DALI_TEST_CHECK( true );
2348   END_TEST;
2349 }
2350
2351 int UtcDaliToolkitScrollViewFixedRulerConstructorP(void)
2352 {
2353   ToolkitTestApplication application;
2354   tet_infoline(" UtcDaliToolkitScrollViewFixedRulerConstructorP");
2355
2356   RulerPtr fixedRuler = new FixedRuler( 100.0f );
2357   DALI_TEST_CHECK( fixedRuler );
2358
2359   fixedRuler = new FixedRuler( 0.0f );
2360   DALI_TEST_CHECK( fixedRuler );
2361
2362   END_TEST;
2363 }
2364
2365 int UtcDaliToolkitScrollViewFixedRulerDestructorP(void)
2366 {
2367   ToolkitTestApplication application;
2368   tet_infoline(" UtcDaliToolkitScrollViewFixedRulerDestructorP");
2369
2370   RulerPtr fixedRuler = new FixedRuler( 100.0f );
2371
2372   DALI_TEST_CHECK( true );
2373   END_TEST;
2374 }
2375
2376 int UtcDaliToolkitScrollViewRulerGetTypeP(void)
2377 {
2378   ToolkitTestApplication application;
2379   tet_infoline(" UtcDaliToolkitScrollViewRulerGetTypeP");
2380
2381   RulerPtr defaultRuler = new DefaultRuler();
2382   DALI_TEST_CHECK( defaultRuler );
2383   DALI_TEST_EQUALS( defaultRuler->GetType(), Dali::Toolkit::Ruler::Free, TEST_LOCATION);
2384
2385   RulerPtr fixedRuler = new FixedRuler( 100.0f );
2386   DALI_TEST_CHECK( fixedRuler );
2387   DALI_TEST_EQUALS( fixedRuler->GetType(), Dali::Toolkit::Ruler::Fixed, TEST_LOCATION);
2388
2389   END_TEST;
2390 }
2391
2392 int UtcDaliToolkitScrollViewRulerGetExtensionP(void)
2393 {
2394   ToolkitTestApplication application;
2395   tet_infoline(" UtcDaliToolkitScrollViewRulerGetExtensionP");
2396
2397   RulerPtr defaultRuler = new DefaultRuler();
2398   DALI_TEST_CHECK( defaultRuler );
2399   DALI_TEST_CHECK( !defaultRuler->GetExtension() );
2400
2401   RulerPtr fixedRuler = new FixedRuler( 100.0f );
2402   DALI_TEST_CHECK( fixedRuler );
2403   DALI_TEST_CHECK( !fixedRuler->GetExtension() );
2404
2405   END_TEST;
2406 }
2407
2408 int UtcDaliToolkitScrollViewRulerEnableDisable(void)
2409 {
2410   ToolkitTestApplication application;
2411   tet_infoline(" UtcDaliToolkitScrollViewRulerEnableDisable");
2412
2413   RulerPtr ruler = new DefaultRuler();
2414
2415   DALI_TEST_CHECK( ruler->IsEnabled() );
2416   ruler->Disable();
2417   DALI_TEST_CHECK( !ruler->IsEnabled() );
2418   ruler->Enable();
2419   DALI_TEST_CHECK( ruler->IsEnabled() );
2420   END_TEST;
2421 }
2422
2423 int UtcDaliToolkitScrollViewRulerDomainEnableDisable(void)
2424 {
2425   ToolkitTestApplication application;
2426   tet_infoline(" UtcDaliToolkitScrollViewRulerDomainEnableDisable");
2427
2428   RulerPtr ruler = new DefaultRuler();
2429   DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
2430
2431   ruler->SetDomain( RulerDomain(0.0f, 100.0f, true) );
2432   DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 100.0f, TEST_LOCATION );
2433   DALI_TEST_EQUALS( ruler->Clamp(-200.0f), 0.0f, TEST_LOCATION );
2434   DALI_TEST_EQUALS( ruler->Clamp(200.0f), 100.0f, TEST_LOCATION );
2435
2436   ruler->DisableDomain();
2437   DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
2438   DALI_TEST_EQUALS( ruler->Clamp(-200.0f), -200.0f, TEST_LOCATION );
2439   DALI_TEST_EQUALS( ruler->Clamp(200.0f), 200.0f, TEST_LOCATION );
2440   END_TEST;
2441 }
2442
2443 int UtcDaliToolkitScrollViewRulerSnapAndClamp(void)
2444 {
2445   ToolkitTestApplication application;
2446   tet_infoline(" UtcDaliToolkitScrollViewRulerSnapAndClamp");
2447
2448   RulerPtr ruler = new FixedRuler( 50.0f );
2449   ruler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2450
2451   // default testing. (snap and clamp)
2452   DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f), 50.0f, TEST_LOCATION);
2453   DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f), 50.0f, TEST_LOCATION);
2454   DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f), 0.0f, TEST_LOCATION);
2455   DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f), 0.0f, TEST_LOCATION);
2456   DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f), 400.0f, TEST_LOCATION);
2457   DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f), 400.0f, TEST_LOCATION);
2458
2459   // bias testing.
2460   DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
2461   DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.5f), 50.0f, TEST_LOCATION); // No Flick
2462   DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
2463
2464   DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
2465   DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.5f), 0.0f, TEST_LOCATION); // No Flick
2466   DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
2467
2468   // length testing.
2469   DALI_TEST_EQUALS( ruler->SnapAndClamp(-10.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (over left boundary)
2470   DALI_TEST_EQUALS( ruler->SnapAndClamp(-5.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (slightly ovr left boundary)
2471   DALI_TEST_EQUALS( ruler->SnapAndClamp(300.0f, 0.5f, 10.0f), 300.0f, TEST_LOCATION); // 10 units long (not over a boundary)
2472   DALI_TEST_EQUALS( ruler->SnapAndClamp(395.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (slightly over right boundary)
2473   DALI_TEST_EQUALS( ruler->SnapAndClamp(500.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (over right boundary)
2474
2475   // scale testing.
2476   DALI_TEST_EQUALS( ruler->SnapAndClamp(-100.0f, 0.5f, 0.0f, 2.0f), 0.0f, TEST_LOCATION);
2477   DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 2.0f), 50.0f, TEST_LOCATION);
2478   DALI_TEST_EQUALS( ruler->SnapAndClamp(700.0f, 0.5f, 0.0f, 2.0f), 700.0f, TEST_LOCATION);
2479   DALI_TEST_EQUALS( ruler->SnapAndClamp(850.0f, 0.5f, 0.0f, 2.0f), 800.0f, TEST_LOCATION);
2480
2481   // clamp state testing.
2482   ClampState clamped;
2483   DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
2484   DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2485   DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
2486   DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2487   DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
2488   DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2489   DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
2490   DALI_TEST_EQUALS( clamped, ClampedToMin, TEST_LOCATION );
2491   DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
2492   DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2493   DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
2494   DALI_TEST_EQUALS( clamped, ClampedToMax, TEST_LOCATION );
2495   END_TEST;
2496 }
2497
2498 int UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP(void)
2499 {
2500   ToolkitTestApplication application;
2501   tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP");
2502
2503   RulerPtr rulerNormal = new FixedRuler( 25.0f );
2504   rulerNormal->SetDomain( RulerDomain(10.0f, 90.0f, true) );
2505
2506   unsigned int volume;
2507   float position;
2508
2509   position = rulerNormal->GetPositionFromPage(1, volume, true);
2510   DALI_TEST_EQUALS( position, 35.0f, TEST_LOCATION );
2511   DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
2512
2513   position = rulerNormal->GetPositionFromPage(2, volume, true);
2514   DALI_TEST_EQUALS( position, 60.0f, TEST_LOCATION );
2515   DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
2516
2517   // Disable the ruler
2518   rulerNormal->Disable();
2519
2520   position = rulerNormal->GetPositionFromPage(1, volume, true);
2521   DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
2522   DALI_TEST_EQUALS( volume, 1u, TEST_LOCATION );
2523
2524   position = rulerNormal->GetPositionFromPage(2, volume, true);
2525   DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
2526   DALI_TEST_EQUALS( volume, 2u, TEST_LOCATION );
2527
2528   END_TEST;
2529 }
2530
2531 int UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP(void)
2532 {
2533   ToolkitTestApplication application;
2534   tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP");
2535
2536   RulerPtr defaultRuler = new DefaultRuler();
2537   DALI_TEST_CHECK( defaultRuler );
2538   DALI_TEST_EQUALS( defaultRuler->GetTotalPages(), 1u, TEST_LOCATION);
2539
2540   END_TEST;
2541 }
2542
2543 int UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP(void)
2544 {
2545   ToolkitTestApplication application;
2546   tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP");
2547
2548   RulerPtr defaultRuler = new DefaultRuler();
2549   DALI_TEST_CHECK( defaultRuler );
2550   DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(100.0f, true), 0u, TEST_LOCATION);
2551   DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(-300.0f, false), 0u, TEST_LOCATION);
2552
2553   END_TEST;
2554 }
2555
2556 int UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP(void)
2557 {
2558   ToolkitTestApplication application;
2559   tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP");
2560
2561   RulerPtr defaultRuler = new DefaultRuler();
2562   DALI_TEST_CHECK( defaultRuler );
2563
2564   unsigned int volume;
2565   DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(0, volume, true), 0.0f, TEST_LOCATION);
2566   DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
2567
2568   DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(3, volume, false), 0.0f, TEST_LOCATION);
2569   DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
2570
2571   END_TEST;
2572 }
2573
2574 int UtcDaliToolkitScrollViewDefaultRulerSnapP(void)
2575 {
2576   ToolkitTestApplication application;
2577   tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerSnapP");
2578
2579   RulerPtr defaultRuler = new DefaultRuler();
2580   DALI_TEST_CHECK( defaultRuler );
2581
2582   DALI_TEST_EQUALS( defaultRuler->Snap(50.0f, 0.5f), 50.0f, TEST_LOCATION);
2583   DALI_TEST_EQUALS( defaultRuler->Snap(-120.0f, 1.0f), -120.0f, TEST_LOCATION);
2584
2585   END_TEST;
2586 }
2587
2588 int UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP(void)
2589 {
2590   ToolkitTestApplication application;
2591   tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP");
2592
2593   RulerPtr fixedRuler = new FixedRuler( 100.0f );
2594   fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2595
2596   fixedRuler->Enable();
2597   DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 4u, TEST_LOCATION);
2598
2599   fixedRuler->Disable();
2600   DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 1u, TEST_LOCATION);
2601
2602   END_TEST;
2603 }
2604
2605 int UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP(void)
2606 {
2607   ToolkitTestApplication application;
2608   tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP");
2609
2610   RulerPtr fixedRuler = new FixedRuler( 100.0f );
2611   fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2612
2613   fixedRuler->Enable();
2614   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 3u, TEST_LOCATION);
2615   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2616   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 1u, TEST_LOCATION);
2617   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2618
2619   fixedRuler->Disable();
2620   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2621   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
2622   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2623   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2624
2625   // Set domain size to be smaller than the ruler space
2626   fixedRuler->SetDomain( RulerDomain(0.0f, 50.0f, true) );
2627
2628   fixedRuler->Enable();
2629   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2630   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2631   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2632   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2633
2634   fixedRuler->Disable();
2635   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2636   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
2637   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2638   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2639
2640   END_TEST;
2641 }
2642
2643 int UtcDaliToolkitScrollViewFixedRulerSnapP(void)
2644 {
2645   ToolkitTestApplication application;
2646   tet_infoline(" UtcDaliToolkitScrollViewFixedRulerSnapP");
2647
2648   RulerPtr fixedRuler = new FixedRuler( 100.0f );
2649   fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2650
2651   DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.0f), -100.0f, TEST_LOCATION);
2652   DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.0f), -100.0f, TEST_LOCATION);
2653   DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.0f), -200.0f, TEST_LOCATION);
2654   DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.0f), -500.0f, TEST_LOCATION);
2655   DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.0f), 0.0f, TEST_LOCATION);
2656   DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.0f), 0.0f, TEST_LOCATION);
2657   DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.0f), 0.0f, TEST_LOCATION);
2658   DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.0f), 100.0f, TEST_LOCATION);
2659   DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.0f), 100.0f, TEST_LOCATION);
2660   DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.0f), 200.0f, TEST_LOCATION);
2661   DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.0f), 600.0f, TEST_LOCATION);
2662
2663   DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.5f), 0.0f, TEST_LOCATION);
2664   DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.5f), -100.0f, TEST_LOCATION);
2665   DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.5f), -100.0f, TEST_LOCATION);
2666   DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.5f), -500.0f, TEST_LOCATION);
2667   DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.5f), 0.0f, TEST_LOCATION);
2668   DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.5f), 100.0f, TEST_LOCATION);
2669   DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.5f), 100.0f, TEST_LOCATION);
2670   DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.5f), 100.0f, TEST_LOCATION);
2671   DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.5f), 100.0f, TEST_LOCATION);
2672   DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.5f), 300.0f, TEST_LOCATION);
2673   DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.5f), 600.0f, TEST_LOCATION);
2674
2675   DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 1.0f), 0.0f, TEST_LOCATION);
2676   DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 1.0f), 0.0f, TEST_LOCATION);
2677   DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 1.0f), -100.0f, TEST_LOCATION);
2678   DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 1.0f), -400.0f, TEST_LOCATION);
2679   DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 1.0f), 100.0f, TEST_LOCATION);
2680   DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 1.0f), 100.0f, TEST_LOCATION);
2681   DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 1.0f), 100.0f, TEST_LOCATION);
2682   DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 1.0f), 200.0f, TEST_LOCATION);
2683   DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 1.0f), 200.0f, TEST_LOCATION);
2684   DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 1.0f), 300.0f, TEST_LOCATION);
2685   DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 1.0f), 700.0f, TEST_LOCATION);
2686
2687   END_TEST;
2688 }
2689
2690 int UtcDaliToolkitScrollViewConstraintsMove(void)
2691 {
2692   ToolkitTestApplication application;
2693   tet_infoline(" UtcDaliToolkitScrollViewConstraintsMove");
2694
2695   // Set up a scrollView...
2696   ScrollView scrollView = ScrollView::New();
2697   application.GetScene().Add( scrollView );
2698   Vector2 stageSize = application.GetScene().GetSize();
2699   scrollView.SetProperty( Actor::Property::SIZE, stageSize);
2700   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
2701   scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2702
2703   // Position rulers.
2704   RulerPtr rulerX = new DefaultRuler();
2705   RulerPtr rulerY = new DefaultRuler();
2706   rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
2707   rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
2708   scrollView.SetRulerX(rulerX);
2709   scrollView.SetRulerY(rulerY);
2710
2711   // Add an Actor to ScrollView,
2712   Actor a = Actor::New();
2713   scrollView.Add(a);
2714   a.SetProperty( Actor::Property::POSITION, TEST_ACTOR_POSITION);
2715   Wait(application);
2716
2717   const Vector2 target = Vector2(100.0f, 100.0f);
2718   const Vector2 target2 = Vector2(200.0f, 200.0f);
2719
2720   Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, MoveActorConstraint );
2721   constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
2722   constraint.SetRemoveAction(Constraint::Discard);
2723   scrollView.ApplyConstraintToChildren(constraint);
2724
2725   scrollView.ScrollTo( target, 0.0f );
2726   Wait(application);
2727   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
2728   scrollView.ScrollTo( target2 );
2729   Wait(application, RENDER_DELAY_SCROLL);
2730   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
2731
2732   END_TEST;
2733 }
2734
2735 int UtcDaliToolkitScrollViewConstraintsWrap(void)
2736 {
2737   ToolkitTestApplication application;
2738   tet_infoline(" UtcDaliToolkitScrollViewConstraintsWrap");
2739
2740   // Set up a scrollView...
2741   ScrollView scrollView = ScrollView::New();
2742   application.GetScene().Add( scrollView );
2743   Vector2 stageSize = application.GetScene().GetSize();
2744   scrollView.SetProperty( Actor::Property::SIZE, stageSize);
2745   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
2746   scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2747
2748   // Position rulers.
2749   RulerPtr rulerX = new DefaultRuler();
2750   RulerPtr rulerY = new DefaultRuler();
2751   rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
2752   rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
2753   scrollView.SetRulerX(rulerX);
2754   scrollView.SetRulerY(rulerY);
2755
2756   // Add an Actor to ScrollView,
2757   Actor a = Actor::New();
2758   scrollView.Add(a);
2759   a.SetProperty( Actor::Property::POSITION, TEST_ACTOR_POSITION);
2760   Wait(application);
2761
2762   const Vector2 target = Vector2(100.0f, 100.0f);
2763   const Vector2 target2 = Vector2(200.0f, 200.0f);
2764
2765   Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, WrapActorConstraint );
2766   constraint.AddSource( LocalSource( Actor::Property::SCALE ) );
2767   constraint.AddSource( LocalSource( Actor::Property::ANCHOR_POINT ) );
2768   constraint.AddSource( LocalSource( Actor::Property::SIZE ) );
2769   constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
2770   constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
2771   constraint.AddSource( Source( scrollView, Toolkit::ScrollView::Property::WRAP ) );
2772   constraint.SetRemoveAction(Constraint::Discard);
2773   scrollView.ApplyConstraintToChildren(constraint);
2774
2775   scrollView.ScrollTo( target, 0.0f );
2776   Wait(application);
2777   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
2778   scrollView.ScrollTo( target2 );
2779   Wait(application, RENDER_DELAY_SCROLL);
2780   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
2781
2782   scrollView.Remove(a);
2783   Wait(application);
2784
2785   END_TEST;
2786 }
2787
2788 // Non-API test (so no P or N variant).
2789 int UtcDaliToolkitScrollViewGesturePageLimit(void)
2790 {
2791   ToolkitTestApplication application;
2792   tet_infoline( " UtcDaliToolkitScrollViewGesturePageLimit" );
2793
2794   // Set up a scrollView.
2795   ScrollView scrollView = ScrollView::New();
2796
2797   // Do not rely on stage size for UTC tests.
2798   Vector2 viewPageSize( 720.0f, 1280.0f );
2799   scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
2800   scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
2801   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
2802   scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
2803   scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
2804
2805   // Position rulers.
2806   // We set the X ruler to fixed to give us pages to snap to.
2807   Dali::Toolkit::FixedRuler* rulerX = new Dali::Toolkit::FixedRuler( viewPageSize.width );
2808   // Note: The 3x page width is arbitary, but we need enough to show that we are
2809   // capping page movement by the page limiter, and not the domain.
2810   rulerX->SetDomain( Dali::Toolkit::RulerDomain( 0.0f, viewPageSize.width * 3.0f, false ) );
2811   Dali::Toolkit::RulerPtr rulerY = new Dali::Toolkit::DefaultRuler();
2812   rulerY->Disable();
2813   scrollView.SetRulerX( rulerX );
2814   scrollView.SetRulerY( rulerY );
2815
2816   scrollView.SetWrapMode( false );
2817   scrollView.SetScrollSensitive( true );
2818
2819   application.GetScene().Add( scrollView );
2820
2821   // Set up a gesture to perform.
2822   Vector2 startPos( 50.0f, 0.0f );
2823   Vector2 direction( -5.0f, 0.0f );
2824   int frames = 200;
2825
2826   // Force starting position.
2827   scrollView.ScrollTo( startPos, 0.0f );
2828   uint32_t time = 0;
2829   time += Wait( application );
2830
2831   // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
2832   Vector2 currentPos( PerformGestureSwipe( application, startPos, direction, frames - 1, time, false ) );
2833
2834   // Confirm the final X coord has not moved more than one page from the start X position.
2835   DALI_TEST_GREATER( ( startPos.x + viewPageSize.width ), scrollView.GetCurrentScrollPosition().x, TEST_LOCATION );
2836
2837   // Finish the gesture and wait for the snap.
2838   currentPos += direction;
2839   TestEndPan(application, currentPos, time);
2840   // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
2841   time += Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
2842
2843   // Confirm the final X coord has snapped to exactly one page ahead of the start page.
2844   DALI_TEST_EQUALS( viewPageSize.width, scrollView.GetCurrentScrollPosition().x, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2845
2846   END_TEST;
2847 }
2848
2849 int UtcDaliScrollViewSetGetProperty(void)
2850 {
2851   ToolkitTestApplication application;
2852
2853   // Create the ScrollView actor
2854   ScrollView scrollView = ScrollView::New();
2855   DALI_TEST_CHECK(scrollView);
2856
2857   // Event side properties
2858
2859   // Test "wrapEnabled" property
2860   DALI_TEST_CHECK( scrollView.GetPropertyIndex("wrapEnabled") == ScrollView::Property::WRAP_ENABLED );
2861   scrollView.SetProperty( ScrollView::Property::WRAP_ENABLED, true );
2862   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WRAP_ENABLED).Get<bool>(), true, TEST_LOCATION );
2863
2864   // Test "panningEnabled" property
2865   DALI_TEST_CHECK( scrollView.GetPropertyIndex("panningEnabled") == ScrollView::Property::PANNING_ENABLED );
2866   scrollView.SetProperty( ScrollView::Property::PANNING_ENABLED, false );
2867   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::PANNING_ENABLED).Get<bool>(), false, TEST_LOCATION );
2868
2869   // Test "axisAutoLockEnabled" property
2870   DALI_TEST_CHECK( scrollView.GetPropertyIndex("axisAutoLockEnabled") == ScrollView::Property::AXIS_AUTO_LOCK_ENABLED );
2871   scrollView.SetProperty( ScrollView::Property::AXIS_AUTO_LOCK_ENABLED, false );
2872   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::AXIS_AUTO_LOCK_ENABLED).Get<bool>(), false, TEST_LOCATION );
2873
2874   // Test "wheelScrollDistanceStep" property
2875   DALI_TEST_CHECK( scrollView.GetPropertyIndex("wheelScrollDistanceStep") == ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP );
2876   scrollView.SetProperty( ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP, Vector2(100.0f, 50.0f) );
2877   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP).Get<Vector2>(), Vector2(100.0f, 50.0f), TEST_LOCATION );
2878
2879   // Test "overshootEnabled" property
2880   DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootEnabled") == Scrollable::Property::OVERSHOOT_ENABLED  );
2881   DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), scrollView.IsOvershootEnabled(), TEST_LOCATION );
2882   scrollView.SetProperty( Scrollable::Property::OVERSHOOT_ENABLED, false );
2883   DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), false, TEST_LOCATION );
2884
2885   // Animatable properties
2886
2887   // Test "scrollPosition" property
2888   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPosition") == ScrollView::Property::SCROLL_POSITION );
2889   scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(320.0f, 550.0f) );
2890   Wait(application);
2891   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION).Get<Vector2>(), Vector2(320.0f, 550.0f), TEST_LOCATION );
2892
2893   // Test "scrollPrePosition", "scrollPrePositionX" and "scrollPrePositionY" properties
2894   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePosition") == ScrollView::Property::SCROLL_PRE_POSITION );
2895   scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION, Vector2(300.0f, 500.0f) );
2896   Wait(application);
2897   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION).Get<Vector2>(), Vector2(300.0f, 500.0f), TEST_LOCATION );
2898
2899   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionX") == ScrollView::Property::SCROLL_PRE_POSITION_X );
2900   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionY") == ScrollView::Property::SCROLL_PRE_POSITION_Y );
2901   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_X).Get<float>(), 300.0f, TEST_LOCATION );
2902   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_Y).Get<float>(), 500.0f, TEST_LOCATION );
2903   scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_X, 400.0f );
2904   scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_Y, 600.0f );
2905   Wait(application);
2906   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_X).Get<float>(), 400.0f, TEST_LOCATION );
2907   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_Y).Get<float>(), 600.0f, TEST_LOCATION );
2908   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION).Get<Vector2>(), Vector2(400.0f, 600.0f), TEST_LOCATION );
2909
2910   // Test "scrollPrePositionMax", "scrollPrePositionMaxX" and "scrollPrePositionMaxY" properties
2911   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMax") == ScrollView::Property::SCROLL_PRE_POSITION_MAX );
2912   scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX, Vector2(100.0f, 200.0f) );
2913   Wait(application);
2914   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX).Get<Vector2>(), Vector2(100.0f, 200.0f), TEST_LOCATION );
2915
2916   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMaxX") == ScrollView::Property::SCROLL_PRE_POSITION_MAX_X );
2917   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMaxY") == ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y );
2918   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_X).Get<float>(), 100.0f, TEST_LOCATION );
2919   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y).Get<float>(), 200.0f, TEST_LOCATION );
2920   scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX_X, 300.0f );
2921   scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y, 400.0f );
2922   Wait(application);
2923   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_X).Get<float>(), 300.0f, TEST_LOCATION );
2924   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y).Get<float>(), 400.0f, TEST_LOCATION );
2925   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX).Get<Vector2>(), Vector2(300.0f, 400.0f), TEST_LOCATION );
2926
2927   // Test "overshootX" property
2928   DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootX") == ScrollView::Property::OVERSHOOT_X );
2929   scrollView.SetProperty( ScrollView::Property::OVERSHOOT_X, 0.8f );
2930   Wait(application);
2931   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::OVERSHOOT_X).Get<float>(), 0.8f, TEST_LOCATION );
2932
2933   // Test "overshootY" property
2934   DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootY") == ScrollView::Property::OVERSHOOT_Y );
2935   scrollView.SetProperty( ScrollView::Property::OVERSHOOT_Y, 0.8f );
2936   Wait(application);
2937   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y).Get<float>(), 0.8f, TEST_LOCATION );
2938
2939   // Test "scrollFinal", "scrollFinalX" and "scrollFinalY" properties
2940   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinal") == ScrollView::Property::SCROLL_FINAL );
2941   scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL, Vector2(200.0f, 300.0f) );
2942   Wait(application);
2943   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL).Get<Vector2>(), Vector2(200.0f, 300.0f), TEST_LOCATION );
2944
2945   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinalX") == ScrollView::Property::SCROLL_FINAL_X );
2946   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinalY") == ScrollView::Property::SCROLL_FINAL_Y );
2947   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_X).Get<float>(), 200.0f, TEST_LOCATION );
2948   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_Y).Get<float>(), 300.0f, TEST_LOCATION );
2949   scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL_X, 500.0f );
2950   scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL_Y, 600.0f );
2951   Wait(application);
2952   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_X).Get<float>(), 500.0f, TEST_LOCATION );
2953   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_Y).Get<float>(), 600.0f, TEST_LOCATION );
2954   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL).Get<Vector2>(), Vector2(500.0f, 600.0f), TEST_LOCATION );
2955
2956   // Test "wrap" property
2957   DALI_TEST_CHECK( scrollView.GetPropertyIndex("wrap") == ScrollView::Property::WRAP );
2958   scrollView.SetProperty( ScrollView::Property::WRAP, false );
2959   Wait(application);
2960   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WRAP).Get<bool>(), false, TEST_LOCATION );
2961
2962   // Test "panning" property
2963   DALI_TEST_CHECK( scrollView.GetPropertyIndex("panning") == ScrollView::Property::PANNING );
2964   scrollView.SetProperty( ScrollView::Property::PANNING, true );
2965   Wait(application);
2966   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::PANNING).Get<bool>(), true, TEST_LOCATION );
2967
2968   // Test "scrolling" property
2969   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrolling") == ScrollView::Property::SCROLLING );
2970   scrollView.SetProperty( ScrollView::Property::SCROLLING, false );
2971   Wait(application);
2972   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLLING).Get<bool>(), false, TEST_LOCATION );
2973
2974   // Test "scrollDomainSize", "scrollDomainSizeX" and "scrollDomainSizeY" properties
2975   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSize") == ScrollView::Property::SCROLL_DOMAIN_SIZE );
2976   scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE, Vector2(1200.0f, 1300.0f) );
2977   Wait(application);
2978   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE).Get<Vector2>(), Vector2(1200.0f, 1300.0f), TEST_LOCATION );
2979
2980   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSizeX") == ScrollView::Property::SCROLL_DOMAIN_SIZE_X );
2981   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSizeY") == ScrollView::Property::SCROLL_DOMAIN_SIZE_Y );
2982   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_X).Get<float>(), 1200.0f, TEST_LOCATION );
2983   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_Y).Get<float>(), 1300.0f, TEST_LOCATION );
2984   scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE_X, 1500.0f );
2985   scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE_Y, 1600.0f );
2986   Wait(application);
2987   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_X).Get<float>(), 1500.0f, TEST_LOCATION );
2988   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_Y).Get<float>(), 1600.0f, TEST_LOCATION );
2989   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE).Get<Vector2>(), Vector2(1500.0f, 1600.0f), TEST_LOCATION );
2990
2991   // Test "scrollDomainOffset" property
2992   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainOffset") == ScrollView::Property::SCROLL_DOMAIN_OFFSET );
2993   scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_OFFSET, Vector2(500.0f, 200.0f) );
2994   Wait(application);
2995   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_OFFSET).Get<Vector2>(), Vector2(500.0f, 200.0f), TEST_LOCATION );
2996
2997   // Test "scrollPositionDelta" property
2998   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPositionDelta") == ScrollView::Property::SCROLL_POSITION_DELTA );
2999   scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION_DELTA, Vector2(10.0f, 30.0f) );
3000   Wait(application);
3001   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION_DELTA).Get<Vector2>(), Vector2(10.0f, 30.0f), TEST_LOCATION );
3002
3003   // Test "startPagePosition" property
3004   DALI_TEST_CHECK( scrollView.GetPropertyIndex("startPagePosition") == ScrollView::Property::START_PAGE_POSITION );
3005   scrollView.SetProperty( ScrollView::Property::START_PAGE_POSITION, Vector3(50.0f, 100.0f, 20.0f) );
3006   Wait(application);
3007   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::START_PAGE_POSITION).Get<Vector3>(), Vector3(50.0f, 100.0f, 20.0f), TEST_LOCATION );
3008
3009   END_TEST;
3010 }
3011
3012 int UtcDaliToolkitScrollViewWheelEvent(void)
3013 {
3014   ToolkitTestApplication application;
3015
3016   // Set up a scrollView.
3017   ScrollView scrollView = ScrollView::New();
3018
3019   // Do not rely on stage size for UTC tests.
3020   Vector2 viewPageSize( 720.0f, 1280.0f );
3021   scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3022   scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
3023   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
3024   scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
3025   scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
3026
3027   // Position rulers.
3028   // We set the X ruler to fixed to give us pages to snap to.
3029   Dali::Toolkit::FixedRuler* rulerX = new Dali::Toolkit::FixedRuler( viewPageSize.width );
3030   // Note: The 3x page width is arbitary, but we need enough to show that we are
3031   // capping page movement by the page limiter, and not the domain.
3032   rulerX->SetDomain( Dali::Toolkit::RulerDomain( 0.0f, viewPageSize.width * 3.0f, false ) );
3033   Dali::Toolkit::RulerPtr rulerY = new Dali::Toolkit::DefaultRuler();
3034   rulerY->Disable();
3035   scrollView.SetRulerX( rulerX );
3036   scrollView.SetRulerY( rulerY );
3037
3038   scrollView.SetWrapMode( false );
3039
3040   application.GetScene().Add( scrollView );
3041
3042   //Connect to wheel event signal
3043   scrollView.WheelEventSignal().Connect( &OnWheelEvent );
3044
3045   DALI_TEST_CHECK( !gOnWheelEventCalled );
3046
3047   // Render and notify
3048   application.Render();
3049   application.SendNotification();
3050   application.Render();
3051   application.SendNotification();
3052
3053   // Perform a wheel event
3054   Dali::Integration::WheelEvent wheelEvent( Dali::Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, Vector2( 10.0f, 10.0f ), 1, 1000u );
3055   application.ProcessEvent( wheelEvent );
3056   DALI_TEST_CHECK( gOnWheelEventCalled );
3057
3058   // Set X ruler to free
3059   Dali::Toolkit::DefaultRuler* defaultRuler = new Dali::Toolkit::DefaultRuler();
3060   scrollView.SetRulerX( defaultRuler );
3061
3062   // Perform a wheel event
3063   gOnWheelEventCalled = false;
3064   application.ProcessEvent( wheelEvent );
3065   DALI_TEST_CHECK( gOnWheelEventCalled );
3066
3067   // Enable Y ruler
3068   rulerY->Enable();
3069
3070   // Perform a wheel event
3071   gOnWheelEventCalled = false;
3072   application.ProcessEvent( wheelEvent );
3073   DALI_TEST_CHECK( gOnWheelEventCalled );
3074
3075   // Wait until it finishes scrolling
3076   Wait(application, RENDER_DELAY_SCROLL);
3077
3078   // Set Y ruler to fixed
3079   Dali::Toolkit::FixedRuler* fixedRulerY = new Dali::Toolkit::FixedRuler( viewPageSize.height );
3080   scrollView.SetRulerY( fixedRulerY );
3081
3082   // Perform a wheel event
3083   gOnWheelEventCalled = false;
3084   application.ProcessEvent( wheelEvent );
3085   DALI_TEST_CHECK( gOnWheelEventCalled );
3086
3087   END_TEST;
3088 }