Add KEYBOARD_FOCUSABLE_CHILDREN property.
[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::DIRECTION_BIAS_LEFT, Dali::Toolkit::DIRECTION_BIAS_LEFT );
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::DIRECTION_BIAS_RIGHT, Dali::Toolkit::DIRECTION_BIAS_RIGHT );
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::DIRECTION_BIAS_LEFT, Dali::Toolkit::DIRECTION_BIAS_LEFT );
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::DIRECTION_BIAS_RIGHT, Dali::Toolkit::DIRECTION_BIAS_RIGHT );
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::DIRECTION_BIAS_RIGHT, Dali::Toolkit::DIRECTION_BIAS_RIGHT );
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   // Change scroll mode during pan, should not crash
690   PerformGestureSwipe( application, startPos, direction, frames - 1, time, false );
691   try
692   {
693     scrollView.SetScrollSensitive(false);
694     DALI_TEST_CHECK(true);
695   }
696   catch(...)
697   {
698     DALI_TEST_CHECK(false);
699   }
700
701   END_TEST;
702 }
703
704 int UtcDaliToolkitScrollModeP2(void)
705 {
706   ToolkitTestApplication application;
707   tet_infoline( " UtcDaliToolkitScrollView ScrollMode property" );
708
709   // Set up a scrollView.
710   ScrollView scrollView = ScrollView::New();
711
712   // Do not rely on stage size for UTC tests.
713   Vector2 viewPageSize( 720.0f, 1280.0f );
714   scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
715   scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
716   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
717   scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
718   scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
719
720   // Position rulers.
721   Property::Map rulerMap;
722   rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, false );
723   rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, true );
724   rulerMap.Add( ScrollMode::Y_AXIS_SNAP_TO_INTERVAL, viewPageSize.height );
725   rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_BOUNDARY, viewPageSize.height*3 );
726   scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
727
728   scrollView.SetWrapMode( false );
729   scrollView.SetScrollSensitive( true );
730
731   application.GetScene().Add( scrollView );
732
733   // Set up a gesture to perform.
734   Vector2 startPos( 0.0f, 50.0f );
735   Vector2 direction( 0.0f, -6.0f );
736   int frames = 200;
737   uint32_t time = 0;
738
739   // Force starting position.
740   scrollView.ScrollTo( startPos, 0.0f );
741   time += Wait( application );
742
743   // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
744   Vector2 currentPos( PerformGestureSwipe( application, startPos, direction, frames - 1, time, false ) );
745
746   // Confirm the final X coord has not moved more than one page from the start X position.
747   DALI_TEST_GREATER( ( startPos.y + viewPageSize.height ), scrollView.GetCurrentScrollPosition().y, TEST_LOCATION );
748
749   // Finish the gesture and wait for the snap.
750   currentPos += direction;
751   time += Wait( application );
752   TestEndPan( application, currentPos, time );
753   // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
754   Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
755
756   // Confirm the final Y coord has snapped to exactly one page ahead of the start page.
757   DALI_TEST_EQUALS( viewPageSize.height, scrollView.GetCurrentScrollPosition().y, Math::MACHINE_EPSILON_0, TEST_LOCATION );
758
759   END_TEST;
760 }
761
762 int UtcDaliToolkitScrollModeP3(void)
763 {
764   ToolkitTestApplication application;
765   tet_infoline( " UtcDaliToolkitScrollView ScrollMode property" );
766
767   // Set up a scrollView.
768   ScrollView scrollView = ScrollView::New();
769
770   // Do not rely on stage size for UTC tests.
771   Vector2 viewPageSize( 720.0f, 1280.0f );
772   scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
773   scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
774   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
775   scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
776   scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
777
778   // Position rulers.
779   Property::Map rulerMap;
780   rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, false );
781   rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, true );
782   rulerMap.Add( ScrollMode::Y_AXIS_SNAP_TO_INTERVAL, viewPageSize.height );
783   rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_BOUNDARY, viewPageSize.height*3 );
784   scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
785
786   scrollView.SetWrapMode( false );
787   scrollView.SetScrollSensitive( true );
788
789   application.GetScene().Add( scrollView );
790
791   // Set up a gesture to perform.
792   Vector2 startPos( 0.0f, 50.0f );
793   Vector2 direction( 0.0f, -6.0f );
794   int frames = 200;
795   uint32_t time  = 0;
796
797   // Force starting position.
798   scrollView.ScrollTo( startPos, 0.0f );
799   time += Wait( application );
800
801   // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
802   Vector2 currentPos( PerformGestureSwipe( application, startPos, direction, frames - 1, time, false ) );
803
804   // Confirm the final X coord has not moved more than one page from the start X position.
805   DALI_TEST_GREATER( ( startPos.y + viewPageSize.height ), scrollView.GetCurrentScrollPosition().y, TEST_LOCATION );
806
807   // Finish the gesture and wait for the snap.
808   currentPos += direction;
809   TestEndPan( application, currentPos, time );
810   // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
811   Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
812
813   // Confirm the final Y coord has snapped to exactly one page ahead of the start page.
814   DALI_TEST_EQUALS( viewPageSize.height, scrollView.GetCurrentScrollPosition().y, Math::MACHINE_EPSILON_0, TEST_LOCATION );
815
816   END_TEST;
817 }
818
819 int UtcDaliToolkitScrollModeP4(void)
820 {
821   ToolkitTestApplication application;
822   tet_infoline( " UtcDaliToolkitScrollView ScrollMode property, DefaultRulers" );
823
824   // Set up a scrollView.
825   ScrollView scrollView = ScrollView::New();
826
827   // Do not rely on stage size for UTC tests.
828   Vector2 viewPageSize( 720.0f, 1280.0f );
829   scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
830   scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
831   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
832   scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
833   scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
834
835   // Position rulers - expect Default rulers to be used which don't snap
836   Property::Map rulerMap;
837   rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, true );
838   rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, true );
839   scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
840
841   scrollView.SetWrapMode( false );
842   scrollView.SetScrollSensitive( true );
843
844   application.GetScene().Add( scrollView );
845
846   Vector2 START_POSITION = Vector2(10.0f, 10.0f);
847
848   uint32_t time = 0;
849   scrollView.ScrollTo(START_POSITION, 0.0f);
850   time += Wait(application);
851
852   // Try a vertical swipe.
853   // PerformGestureSwipe not used as a different initial direction was required
854   Vector2 pos( START_POSITION + Vector2(0.0f, 15.0f) );
855   Vector2 dir( 0.0f, 1.0f );
856
857   TestStartPan( application, START_POSITION, pos, time );
858
859   Wait(application);
860
861   for( int i = 0; i<45; i++ )
862   {
863     pos += dir;
864     TestMovePan( application, pos, time );
865     time += Wait( application );
866   }
867
868   pos += dir;
869
870   TestEndPan( application, pos, time );
871   Wait( application, RENDER_DELAY_SCROLL );
872
873   // Take into account resampling done when prediction is off.
874   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
875
876   END_TEST;
877 }
878
879 int UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP(void)
880 {
881   ToolkitTestApplication application;
882   tet_infoline(" UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP");
883
884   ScrollView scrollView = ScrollView::New();
885   application.GetScene().Add( scrollView );
886   RulerPtr rulerX = new FixedRuler( 100.0f );
887   rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
888   RulerPtr rulerY = new FixedRuler( 100.0f );
889   rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
890
891   scrollView.SetRulerX( rulerX );
892   scrollView.SetRulerY( rulerY );
893
894   scrollView.SetWrapMode(true);
895
896   scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DIRECTION_BIAS_LEFT );
897
898   Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame
899   // Check that the scroll position remains the same
900   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
901
902   Wait(application, RENDER_DELAY_SCROLL); // Wait for one second
903   // Check that it stays at the same page (i.e. the same scroll position)
904   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
905   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
906
907   scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DIRECTION_BIAS_RIGHT );
908
909   Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame
910   // Check that it scrolls towards the right
911   DALI_TEST_CHECK( scrollView.GetCurrentScrollPosition().x > 0.0f );
912
913   Wait(application, RENDER_DELAY_SCROLL); // Wait for one second
914   // Check that it scrolls back to the same page (i.e. the same scroll position)
915   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
916   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
917
918   END_TEST;
919 }
920
921 int UtcDaliToolkitScrollViewScrollToActorP(void)
922 {
923   ToolkitTestApplication application;
924   tet_infoline(" UtcDaliToolkitScrollViewScrollToActorP");
925
926   ScrollView scrollView = ScrollView::New();
927   application.GetScene().Add( scrollView );
928
929   Actor actorA = Actor::New();
930   const Vector3 positionA = Vector3(100.0f, 400.0f, 0.0f);
931   actorA.SetProperty( Actor::Property::POSITION, positionA );
932   scrollView.Add(actorA);
933
934   Actor actorB = Actor::New();
935   const Vector3 positionB = Vector3(500.0f, 200.0f, 0.0f);
936   actorB.SetProperty( Actor::Property::POSITION, positionB );
937   scrollView.Add(actorB);
938
939   Wait(application);
940
941   scrollView.ScrollTo(actorA, 0.0f);
942   Wait(application);
943   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION );
944
945   Wait(application);
946   scrollView.ScrollTo(actorB, 0.0f);
947   Wait(application);
948   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION );
949
950   scrollView.ScrollTo(actorA);
951   Wait(application, RENDER_DELAY_SCROLL);
952   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION );
953
954   scrollView.ScrollTo(actorB);
955   Wait(application, RENDER_DELAY_SCROLL);
956   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION );
957   END_TEST;
958 }
959
960 int UtcDaliToolkitScrollViewScrollToSnapPointP(void)
961 {
962   ToolkitTestApplication application;
963   tet_infoline(" UtcDaliToolkitScrollViewScrollToSnapPointP");
964
965   ScrollView scrollView = ScrollView::New();
966   application.GetScene().Add( scrollView );
967   RulerPtr rulerX = new FixedRuler( 100.0f );
968   rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
969   RulerPtr rulerY = new FixedRuler( 100.0f );
970   rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
971
972   scrollView.SetRulerX( rulerX );
973   scrollView.SetRulerY( rulerY );
974
975   scrollView.ScrollTo( Vector2(120.0f, 190.0f), 0.0f );
976   Wait(application);
977   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(120.0f, 190.0f), TEST_LOCATION );
978
979   scrollView.ScrollToSnapPoint();
980
981   Wait(application, RENDER_DELAY_SCROLL);
982   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 200.0f), TEST_LOCATION );
983   END_TEST;
984 }
985
986 int UtcDaliToolkitScrollViewSetScrollUpdateDistanceP(void)
987 {
988   ToolkitTestApplication application;
989   tet_infoline(" UtcDaliToolkitScrollViewSetScrollUpdateDistanceP");
990
991   ScrollView scrollView = ScrollView::New();
992
993   scrollView.SetScrollUpdateDistance(0);
994   DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 0, TEST_LOCATION);
995   scrollView.SetScrollUpdateDistance(10);
996   DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 10, TEST_LOCATION);
997   scrollView.SetScrollUpdateDistance(1000);
998   DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 1000, TEST_LOCATION);
999   END_TEST;
1000 }
1001
1002 int UtcDaliToolkitScrollViewSetWrapModeP(void)
1003 {
1004   ToolkitTestApplication application;
1005   tet_infoline(" UtcDaliToolkitScrollViewSetWrapModeP");
1006
1007   ScrollView scrollView = ScrollView::New();
1008   application.GetScene().Add( scrollView );
1009
1010   Actor actor = Actor::New();
1011   scrollView.Add( actor );
1012
1013   // Position rulers. 4x4 grid.
1014   RulerPtr rulerX = new FixedRuler(50.0f);
1015   RulerPtr rulerY = new FixedRuler(50.0f);
1016   rulerX->SetDomain( RulerDomain(0.0f, 200.0f, false) );
1017   rulerY->SetDomain( RulerDomain(0.0f, 200.0f, false) );
1018   scrollView.SetRulerX(rulerX);
1019   scrollView.SetRulerY(rulerY);
1020
1021   scrollView.SetWrapMode(false);
1022   scrollView.ScrollTo(Vector2(225.0f, 125.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
1023   Wait(application);
1024   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 17, TEST_LOCATION );
1025
1026   scrollView.SetWrapMode(true);
1027   scrollView.ScrollTo(Vector2(230.0f, 130.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
1028   Wait(application);
1029   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 13, TEST_LOCATION );
1030   END_TEST;
1031 }
1032
1033 int UtcDaliToolkitScrollViewActorAutoSnap(void)
1034 {
1035   ToolkitTestApplication application;
1036   tet_infoline(" UtcDaliToolkitScrollViewActorAutoSnap");
1037
1038   ScrollView scrollView = ScrollView::New();
1039   application.GetScene().Add( scrollView );
1040
1041   // Position rulers.
1042   RulerPtr rulerX = new DefaultRuler();
1043   RulerPtr rulerY = new DefaultRuler();
1044   rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1045   rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1046   scrollView.SetRulerX(rulerX);
1047   scrollView.SetRulerY(rulerY);
1048
1049   const Vector3 aPosition = Vector3(200.0f, 50.0f, 0.0f);
1050   Actor a = Actor::New();
1051   scrollView.Add(a);
1052   a.SetProperty( Actor::Property::POSITION, aPosition );
1053
1054   const Vector3 bPosition = Vector3(600.0f, 600.0f, 0.0f);
1055   Actor b = Actor::New();
1056   scrollView.Add(b);
1057   b.SetProperty( Actor::Property::POSITION, bPosition );
1058
1059   // Goto a random position, and execute snap (should not move)
1060   Vector2 targetScroll = Vector2(500.0f, 500.0f);
1061   scrollView.ScrollTo(targetScroll, 0.0f);
1062   Wait(application);
1063   scrollView.ScrollToSnapPoint();
1064   Wait(application, RENDER_DELAY_SCROLL);
1065   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), targetScroll, TEST_LOCATION );
1066
1067   // Enable ActorAutoSnap, and now try snapping.
1068   scrollView.SetActorAutoSnap(true);
1069   scrollView.ScrollToSnapPoint();
1070   Wait(application, RENDER_DELAY_SCROLL);
1071   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), bPosition.GetVectorXY(), TEST_LOCATION );
1072
1073   scrollView.ScrollTo(Vector2(0.0f, 0.0f), 0.0f);
1074   Wait(application);
1075   scrollView.ScrollToSnapPoint();
1076   Wait(application, RENDER_DELAY_SCROLL);
1077   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), aPosition.GetVectorXY(), TEST_LOCATION );
1078   END_TEST;
1079 }
1080
1081 int UtcDaliToolkitScrollViewSignalsStartComplete(void)
1082 {
1083   ToolkitTestApplication application;
1084   tet_infoline(" UtcDaliToolkitScrollViewSignalsStartComplete");
1085
1086   gOnScrollStartCalled = false;
1087   gOnScrollCompleteCalled = false;
1088
1089   ScrollView scrollView = ScrollView::New();
1090   application.GetScene().Add( scrollView );
1091
1092   // Position rulers.
1093   RulerPtr rulerX = new DefaultRuler();
1094   RulerPtr rulerY = new DefaultRuler();
1095   rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1096   rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1097   scrollView.SetRulerX(rulerX);
1098   scrollView.SetRulerY(rulerY);
1099   scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1100   scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1101   scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1102   scrollView.ScrollTo( Vector2(100.0f, 100.0f) );
1103   Wait(application, RENDER_DELAY_SCROLL);
1104
1105   DALI_TEST_CHECK(gOnScrollStartCalled);
1106   DALI_TEST_CHECK(gOnScrollCompleteCalled);
1107   END_TEST;
1108 }
1109
1110 int UtcDaliToolkitScrollViewSignalsUpdate01(void)
1111 {
1112   ToolkitTestApplication application;
1113   tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate");
1114
1115   gOnScrollStartCalled = false;
1116   gOnScrollUpdateCalled = false;
1117   gOnScrollCompleteCalled = false;
1118
1119   ScrollView scrollView = ScrollView::New();
1120   application.GetScene().Add( scrollView );
1121   Vector2 stageSize = application.GetScene().GetSize();
1122   scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1123   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1124   scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1125
1126   // Position rulers.
1127   RulerPtr rulerX = new DefaultRuler();
1128   RulerPtr rulerY = new DefaultRuler();
1129   rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1130   rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1131   scrollView.SetRulerX(rulerX);
1132   scrollView.SetRulerY(rulerY);
1133   scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1134   scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1135   scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1136
1137   Actor image = Actor::New();
1138   image.SetProperty( Actor::Property::SIZE, stageSize);
1139   image.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1140   image.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1141   scrollView.Add(image);
1142
1143   Wait(application);
1144
1145   // Do a pan starting from 100,100 and moving down diagonally.
1146   Vector2 pos(100.0f, 100.0f);
1147   uint32_t time = 100;
1148   TestStartPan( application, pos, pos, time );
1149   pos.x += 5.0f;
1150   pos.y += 5.0f;
1151   Wait(application, 100);
1152
1153   for(int i = 0;i<20;i++)
1154   {
1155     time += RENDER_FRAME_INTERVAL;
1156     TestMovePan( application, pos, time);
1157     pos.x += 5.0f;
1158     pos.y += 5.0f;
1159     Wait(application);
1160   }
1161
1162   time += RENDER_FRAME_INTERVAL;
1163   TestEndPan(application, pos, time );
1164   Wait(application, RENDER_DELAY_SCROLL);
1165
1166   DALI_TEST_CHECK(gOnScrollStartCalled);
1167   DALI_TEST_CHECK(gOnScrollUpdateCalled);
1168   DALI_TEST_CHECK(gOnScrollCompleteCalled);
1169   END_TEST;
1170 }
1171
1172 int UtcDaliToolkitScrollViewSignalsUpdate02(void)
1173 {
1174   ToolkitTestApplication application;
1175   tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate");
1176
1177   gOnScrollStartCalled = false;
1178   gOnScrollUpdateCalled = false;
1179   gOnScrollCompleteCalled = false;
1180
1181   ScrollView scrollView = ScrollView::New();
1182   application.GetScene().Add( scrollView );
1183   Vector2 stageSize = application.GetScene().GetSize();
1184   scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1185   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1186   scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1187
1188   // Position rulers.
1189   RulerPtr rulerX = new DefaultRuler();
1190   RulerPtr rulerY = new DefaultRuler();
1191   rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1192   rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1193   scrollView.SetRulerX(rulerX);
1194   scrollView.SetRulerY(rulerY);
1195   Dali::ConnectionTracker tracker;
1196   bool scrollStarted=false;
1197   bool scrollUpdated=false;
1198   bool scrollCompleted=false;
1199   DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollStarted", CallbackFunctor(&scrollStarted) ));
1200   DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollUpdated", CallbackFunctor(&scrollUpdated) ));
1201   DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollCompleted", CallbackFunctor(&scrollCompleted) ));
1202
1203   Actor image = Actor::New();
1204   image.SetProperty( Actor::Property::SIZE, stageSize);
1205   image.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1206   image.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1207   scrollView.Add(image);
1208
1209   Wait(application);
1210
1211   // Do a pan starting from 100,100 and moving down diagonally.
1212   Vector2 pos(100.0f, 100.0f);
1213   uint32_t time = 100;
1214   TestStartPan( application, pos, pos, time );
1215   pos.x += 5.0f;
1216   pos.y += 5.0f;
1217   Wait(application, 100);
1218
1219   for(int i = 0;i<20;i++)
1220   {
1221     time += RENDER_FRAME_INTERVAL;
1222     TestMovePan( application, pos, time);
1223     pos.x += 5.0f;
1224     pos.y += 5.0f;
1225     Wait(application);
1226   }
1227
1228   time += RENDER_FRAME_INTERVAL;
1229   TestEndPan(application, pos, time );
1230   Wait(application, RENDER_DELAY_SCROLL);
1231
1232   DALI_TEST_CHECK(scrollStarted);
1233   DALI_TEST_CHECK(scrollUpdated);
1234   DALI_TEST_CHECK(scrollCompleted);
1235
1236   application.GetScene().Remove( scrollView );
1237
1238   END_TEST;
1239 }
1240
1241 int UtcDaliToolkitScrollViewScrollSensitive(void)
1242 {
1243   ToolkitTestApplication application;
1244   tet_infoline(" UtcDaliToolkitScrollViewScrollSensitive");
1245
1246   // Set up a scrollView...
1247   ScrollView scrollView = ScrollView::New();
1248   scrollView.SetOvershootEnabled(true);
1249   application.GetScene().Add( scrollView );
1250   Vector2 stageSize = application.GetScene().GetSize();
1251   scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1252   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1253   scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1254
1255   // Position rulers.
1256   RulerPtr rulerX = new DefaultRuler();
1257   RulerPtr rulerY = new DefaultRuler();
1258   rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1259   rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1260   scrollView.SetRulerX(rulerX);
1261   scrollView.SetRulerY(rulerY);
1262   scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1263   scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1264   scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1265   scrollView.SnapStartedSignal().Connect( &OnSnapStart );
1266
1267   scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1268   uint32_t time = 0;
1269   time +=Wait(application);
1270
1271   // First try insensitive swipe.
1272   scrollView.SetScrollSensitive(false);
1273   PerformGestureSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, time, true);
1274
1275   DALI_TEST_CHECK( !gOnScrollStartCalled );
1276   DALI_TEST_CHECK( !gOnScrollCompleteCalled );
1277   DALI_TEST_CHECK( !gOnSnapStartCalled );
1278
1279   // Second try sensitive swipe.
1280   scrollView.SetScrollSensitive(true);
1281   PerformGestureSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, time, true);
1282
1283   DALI_TEST_CHECK( gOnScrollStartCalled );
1284   DALI_TEST_CHECK( gOnScrollCompleteCalled );
1285   DALI_TEST_CHECK( gOnSnapStartCalled );
1286   END_TEST;
1287 }
1288
1289 int UtcDaliToolkitScrollViewAxisAutoLock(void)
1290 {
1291   ToolkitTestApplication application;
1292   tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLock");
1293
1294   // Set up a scrollView...
1295   ScrollView scrollView = ScrollView::New();
1296   application.GetScene().Add( scrollView );
1297   Vector2 stageSize = application.GetScene().GetSize();
1298   scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1299   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1300   scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1301
1302   // Position rulers.
1303   RulerPtr rulerX = new DefaultRuler();
1304   RulerPtr rulerY = new DefaultRuler();
1305   rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1306   rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1307   scrollView.SetRulerX(rulerX);
1308   scrollView.SetRulerY(rulerY);
1309   scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1310   scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1311   scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1312
1313   // Normal
1314   scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
1315   uint32_t time = 0;
1316   time += Wait(application);
1317
1318   Vector2 startPosition = scrollView.GetCurrentScrollPosition();
1319   Vector2 dir(5.0f, 1.0f);
1320
1321   // PerformGestureSwipe not used as a different initial direction was required
1322
1323   Vector2 pos( CLAMP_TOUCH_START + Vector2(15.0f, 3.0f) );
1324
1325   TestStartPan( application, CLAMP_TOUCH_START, pos, time );
1326
1327   time += Wait(application);
1328
1329   for( int i = 0; i<47; i++ )
1330   {
1331     pos += dir;
1332     TestMovePan( application, pos, time );
1333     time += Wait( application );
1334   }
1335
1336   pos += dir;
1337
1338   TestEndPan( application, pos, time );
1339
1340   const Vector2 positionAfterNormal = scrollView.GetCurrentScrollPosition();
1341
1342   // Autolock
1343   scrollView.SetAxisAutoLock(true);
1344   DALI_TEST_CHECK(scrollView.GetAxisAutoLock());
1345
1346   scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
1347   time += Wait(application);
1348
1349   Vector2 pos2( CLAMP_TOUCH_START + Vector2(15.0f, 3.0f) );
1350
1351   TestStartPan( application, CLAMP_TOUCH_START, pos2, time );
1352
1353   time += Wait(application);
1354
1355   for( int i = 0; i<47; i++ )
1356   {
1357     pos2 += dir;
1358     TestMovePan( application, pos2, time );
1359     time += Wait( application );
1360   }
1361
1362   pos2 += dir;
1363
1364   TestEndPan( application, pos2, time );
1365
1366   const Vector2 positionAfterAutoLock = scrollView.GetCurrentScrollPosition();
1367
1368   // compare how much the Y position has deviated for normal and autolock.
1369   const float devianceNormal = fabsf(startPosition.y - positionAfterNormal.y);
1370   const float devianceAutoLock = fabsf(startPosition.y - positionAfterAutoLock.y);
1371
1372   // in auto-lock it should be a mostly horizontal pan (thus deviance should be much lower)
1373   DALI_TEST_CHECK(devianceAutoLock < devianceNormal);
1374
1375   scrollView.SetAxisAutoLock(false);
1376   DALI_TEST_CHECK(!scrollView.GetAxisAutoLock());
1377   END_TEST;
1378 }
1379
1380 int UtcDaliToolkitScrollViewAxisAutoLockGradient(void)
1381 {
1382   ToolkitTestApplication application;
1383   tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLockGradient");
1384
1385   // Set up a scrollView...
1386   ScrollView scrollView = ScrollView::New();
1387   scrollView.SetAxisAutoLockGradient(0.5f);
1388   DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 0.5f, TEST_LOCATION);
1389   scrollView.SetAxisAutoLockGradient(1.0f);
1390   DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 1.0f, TEST_LOCATION);
1391   END_TEST;
1392 }
1393
1394 int UtcDaliToolkitScrollViewConstraints(void)
1395 {
1396   ToolkitTestApplication application;
1397   tet_infoline(" UtcDaliToolkitScrollViewConstraints");
1398
1399   // Set up a scrollView...
1400   ScrollView scrollView = ScrollView::New();
1401   application.GetScene().Add( scrollView );
1402   Vector2 stageSize = application.GetScene().GetSize();
1403   scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1404   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1405   scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1406
1407   // Position rulers.
1408   RulerPtr rulerX = new DefaultRuler();
1409   RulerPtr rulerY = new DefaultRuler();
1410   rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1411   rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1412   scrollView.SetRulerX(rulerX);
1413   scrollView.SetRulerY(rulerY);
1414
1415   // Add an Actor to ScrollView,
1416   // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1417   gConstraintResult = Vector3::ZERO;
1418   Actor a = Actor::New();
1419   scrollView.Add(a);
1420   a.SetProperty( Actor::Property::POSITION, TEST_ACTOR_POSITION);
1421   Wait(application);
1422
1423   Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1424   constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
1425   constraint.SetRemoveAction(Constraint::DISCARD);
1426   scrollView.ApplyConstraintToChildren(constraint);
1427   Wait(application);
1428
1429   DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1430
1431   gConstraintResult = Vector3::ZERO;
1432   scrollView.RemoveConstraintsFromChildren();
1433   Wait(application);
1434
1435   DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
1436   END_TEST;
1437 }
1438
1439 int UtcDaliToolkitScrollViewBind(void)
1440 {
1441   ToolkitTestApplication application;
1442   tet_infoline(" UtcDaliToolkitScrollViewBind");
1443
1444   // Set up a scrollView...
1445   ScrollView scrollView = ScrollView::New();
1446   application.GetScene().Add( scrollView );
1447   Vector2 stageSize = application.GetScene().GetSize();
1448   scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1449   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1450   scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1451
1452   // Position rulers.
1453   RulerPtr rulerX = new DefaultRuler();
1454   RulerPtr rulerY = new DefaultRuler();
1455   rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1456   rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1457   scrollView.SetRulerX(rulerX);
1458   scrollView.SetRulerY(rulerY);
1459
1460   // Add an Actor to ScrollView,
1461   // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1462
1463   gConstraintResult = Vector3::ZERO;
1464   Actor a = Actor::New();
1465   scrollView.Add(a);
1466   a.SetProperty( Actor::Property::POSITION, TEST_ACTOR_POSITION);
1467   Wait(application);
1468
1469   // apply this constraint to scrollview
1470   Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1471   constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
1472   constraint.SetRemoveAction(Constraint::DISCARD);
1473   scrollView.ApplyConstraintToChildren(constraint);
1474
1475   Wait(application);
1476   // Defaulty Bound.
1477   DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1478
1479   // UnBind
1480   gConstraintResult = Vector3::ZERO;
1481   scrollView.UnbindActor( a );
1482   Wait(application);
1483   DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
1484
1485   // Bind
1486   gConstraintResult = Vector3::ZERO;
1487   scrollView.BindActor( a );
1488   Wait(application);
1489   DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1490   END_TEST;
1491 }
1492
1493 int UtcDaliToolkitScrollViewOvershoot(void)
1494 {
1495   ToolkitTestApplication application;
1496   tet_infoline(" UtcDaliToolkitScrollViewOvershoot");
1497
1498   // Set up a scrollView...
1499   ScrollView scrollView = ScrollView::New();
1500   scrollView.SetOvershootEnabled(true);
1501
1502   uint32_t time = 0;
1503   Vector2 overshootSize = Vector2(100.0f,100.0f);
1504   scrollView.SetProperty( Scrollable::Property::OVERSHOOT_SIZE, overshootSize );
1505   DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_SIZE).Get<Vector2>(), overshootSize, TEST_LOCATION );
1506
1507   application.GetScene().Add( scrollView );
1508   Vector2 stageSize = application.GetScene().GetSize();
1509   scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1510   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1511   scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1512
1513   // Position rulers.
1514   RulerPtr rulerX = new DefaultRuler();
1515   RulerPtr rulerY = new DefaultRuler();
1516   rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1517   rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1518   scrollView.SetRulerX(rulerX);
1519   scrollView.SetRulerY(rulerY);
1520   scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1521   scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1522   scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1523
1524   scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1525   time += Wait(application);
1526
1527   // 1. Scroll page in NW (-500,-500 pixels), then inspect overshoot. (don't release touch)
1528   Vector2 currentPos = Vector2(100.0f, 100.0f);
1529   currentPos = PerformGestureSwipe(application, currentPos, Vector2(5.0f, 5.0f), 100, time, false);
1530   float overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1531   float overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1532   Vector2 positionValue = scrollView.GetCurrentProperty< Vector2 >( ScrollView::Property::SCROLL_POSITION );
1533   DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1534   DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1535   DALI_TEST_EQUALS(positionValue, Vector2::ZERO, TEST_LOCATION);
1536
1537   float timeToReachOrigin;
1538
1539   // Now release touch. Overshoot should snap back to zero.
1540   TestEndPan(application, currentPos, time);
1541
1542   timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1543
1544   float minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1545   float maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1546
1547   DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1548                    (timeToReachOrigin < maxTimeToReachOrigin) );
1549
1550   // 2. Repeat Scroll, but this time change overshoot snap duration to shorter time
1551   scrollView.SetSnapOvershootDuration(TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION);
1552
1553   currentPos = PerformGestureSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, time, false);
1554   // Now release touch. Overshoot should snap back to zero.
1555   TestEndPan(application, currentPos, time);
1556   timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1557
1558   minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1559   maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1560
1561   DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1562                    (timeToReachOrigin < maxTimeToReachOrigin) );
1563
1564   // 3. Repeat Scroll, but this time change overshoot snap duration to longer time.
1565   scrollView.SetSnapOvershootDuration(TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION);
1566
1567   currentPos = PerformGestureSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, time, false);
1568   // Now release touch. Overshoot should snap back to zero.
1569   TestEndPan(application, currentPos, time);
1570   timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1571
1572   minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1573   maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1574
1575   DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1576                    (timeToReachOrigin < maxTimeToReachOrigin) );
1577
1578   // 4. Repeat Scroll, but this time change overshoot function.
1579   scrollView.SetSnapOvershootDuration(TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION);
1580   scrollView.SetSnapOvershootAlphaFunction(TestAlphaFunction);
1581
1582   currentPos = PerformGestureSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, time, false);
1583   // Now release touch. Overshoot should snap back to zero.
1584   TestEndPan(application, currentPos, time);
1585   timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1586
1587   minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1588   maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1589
1590   DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1591                    (timeToReachOrigin < maxTimeToReachOrigin) );
1592   END_TEST;
1593 }
1594
1595 int UtcDaliToolkitScrollViewSnapAlphaFunction(void)
1596 {
1597   ToolkitTestApplication application;
1598   tet_infoline(" UtcDaliToolkitScrollViewSnapAlphaFunction");
1599
1600   // Set up a scrollView...
1601   ScrollView scrollView = ScrollView::New();
1602   scrollView.SetScrollSnapAlphaFunction( AlphaFunction::EASE_IN );
1603   DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_IN );
1604   scrollView.SetScrollSnapAlphaFunction( AlphaFunction::EASE_OUT );
1605   DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_OUT );
1606
1607   scrollView.SetScrollFlickAlphaFunction( AlphaFunction::BOUNCE );
1608   DALI_TEST_CHECK( scrollView.GetScrollFlickAlphaFunction().GetBuiltinFunction() == AlphaFunction::BOUNCE );
1609
1610   END_TEST;
1611 }
1612
1613 int UtcDaliToolkitScrollViewSnapDuration(void)
1614 {
1615   ToolkitTestApplication application;
1616   tet_infoline(" UtcDaliToolkitScrollViewSnapDuration");
1617
1618   // Set up a scrollView...
1619   ScrollView scrollView = ScrollView::New();
1620   scrollView.SetScrollSnapDuration( 1.0f );
1621   DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 1.0f, TEST_LOCATION );
1622   scrollView.SetScrollSnapDuration( 0.5f );
1623   DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 0.5f, TEST_LOCATION );
1624
1625   scrollView.SetScrollFlickDuration( 2.0f );
1626   DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 2.0f, TEST_LOCATION );
1627   scrollView.SetScrollFlickDuration( 1.5f );
1628   DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 1.5f, TEST_LOCATION );
1629   END_TEST;
1630 }
1631
1632 int UtcDaliToolkitScrollViewSnapStartedSignalP(void)
1633 {
1634   ToolkitTestApplication application;
1635   tet_infoline(" UtcDaliToolkitScrollViewSnapStartedSignalP");
1636
1637   // Set up a scrollView...
1638   ScrollView scrollView = ScrollView::New();
1639   application.GetScene().Add( scrollView );
1640   Vector2 stageSize = application.GetScene().GetSize();
1641   scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1642   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1643   scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1644
1645   // Position rulers.
1646   RulerPtr rulerX = new DefaultRuler();
1647   RulerPtr rulerY = new DefaultRuler();
1648   rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1649   rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1650   scrollView.SetRulerX(rulerX);
1651   scrollView.SetRulerY(rulerY);
1652   scrollView.SnapStartedSignal().Connect( &OnSnapStart );
1653
1654   scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1655   uint32_t time = 0;
1656   time += Wait(application);
1657
1658   // First try a snap.
1659   PerformGestureSwipe(application, CLAMP_TOUCH_START, Vector2(0.5f, 0.0f), 60, time, true);
1660
1661   DALI_TEST_CHECK( gOnSnapStartCalled );
1662   DALI_TEST_CHECK( gLastSnapType == Toolkit::SNAP );
1663
1664   // Second try a swipe.
1665   PerformGestureSwipe(application, CLAMP_TOUCH_START, Vector2(20.0f, 0.0f), 60, time, true);
1666
1667   DALI_TEST_CHECK( gOnSnapStartCalled );
1668   DALI_TEST_CHECK( gLastSnapType == Toolkit::FLICK );
1669   END_TEST;
1670 }
1671
1672 int UtcDaliToolkitScrollViewGetCurrentPageP(void)
1673 {
1674   ToolkitTestApplication application;
1675   tet_infoline(" UtcDaliToolkitScrollViewGetCurrentPageP");
1676
1677   ScrollView scrollView = ScrollView::New();
1678   application.GetScene().Add( scrollView );
1679   RulerPtr rulerX = new FixedRuler( 100.0f );
1680   rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1681   RulerPtr rulerY = new FixedRuler( 100.0f );
1682   rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1683
1684   scrollView.SetRulerX( rulerX );
1685   scrollView.SetRulerY( rulerY );
1686
1687   scrollView.ScrollTo( 15 );
1688   Wait(application, RENDER_DELAY_SCROLL);
1689   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION );
1690
1691   scrollView.ScrollTo( 3 );
1692   Wait(application, RENDER_DELAY_SCROLL);
1693   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION );
1694
1695   scrollView.ScrollTo( 9 );
1696   Wait(application, RENDER_DELAY_SCROLL);
1697   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION );
1698
1699   END_TEST;
1700 }
1701
1702 int UtcDaliToolkitScrollViewSetMaxOvershootP(void)
1703 {
1704   ToolkitTestApplication application;
1705   tet_infoline(" UtcDaliToolkitScrollViewSetMaxOvershootP");
1706
1707   // Set up a scrollView...
1708   ScrollView scrollView = ScrollView::New();
1709   application.GetScene().Add( scrollView );
1710   Vector2 stageSize = application.GetScene().GetSize();
1711   scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1712   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1713   scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1714
1715   // Position rulers.
1716   RulerPtr rulerX = new DefaultRuler();
1717   RulerPtr rulerY = new DefaultRuler();
1718   rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1719   rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1720   scrollView.SetRulerX(rulerX);
1721   scrollView.SetRulerY(rulerY);
1722
1723   // Set the max overshoot to be 50 pixels in both X axis and Y axis
1724   scrollView.SetMaxOvershoot(50.0f, 50.0f);
1725
1726   scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1727   uint32_t time = 0;
1728   time += Wait(application);
1729
1730   // Scroll page in NW (-20,-20 pixels), then check that overshoot should be 0. (don't release touch)
1731   Vector2 currentPos = PerformGestureSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 10, time, false);
1732   float overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1733   float overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1734   DALI_TEST_EQUALS(overshootXValue, 0.0f, TEST_LOCATION);
1735   DALI_TEST_EQUALS(overshootYValue, 0.0f, TEST_LOCATION);
1736
1737   time += Wait(application);
1738   // Scroll page further in NW (-105,-105 pixels), then check that overshoot should be around 0.5. (don't release touch)
1739   for(int i = 0; i<106; i++)
1740   {
1741     TestMovePan(application, currentPos, time );
1742     currentPos += Vector2(1.0f, 1.0f);
1743     time += Wait(application);
1744   }
1745
1746   overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1747   overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1748   // The overshoot value is a 0.0f - 1.0f ranged value of the amount overshot related to the maximum overshoot.
1749   // EG. If we move 105, max overshoot is 50, then we overshot 50 / 105.
1750   float correctOvershootValue = 0.508f;   // This was measured and then set as the limit
1751   DALI_TEST_EQUALS( overshootXValue, correctOvershootValue, 0.001f, TEST_LOCATION );
1752   DALI_TEST_EQUALS( overshootYValue, correctOvershootValue, 0.001f, TEST_LOCATION );
1753
1754   // Scroll page further in NW (-25,-25 pixels), then check that overshoot should be now 1.0. (don't release touch)
1755   for(int i = 0;i<25;i++)
1756   {
1757     TestMovePan(application, currentPos, time );
1758     currentPos += Vector2(1.0f, 1.0f); // Move in this direction
1759     time += Wait(application);
1760   }
1761
1762   overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1763   overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1764   DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1765   DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1766
1767   // Change the max overshoot to be 250 pixels in both X axis and Y axis
1768   scrollView.SetMaxOvershoot(250.0f, 250.0f);
1769   time += Wait(application);
1770
1771   // Check that overshoot should be now around 0.8.
1772   overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1773   overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1774   DALI_TEST_CHECK(overshootXValue > 0.79f && overshootXValue < 0.81f);
1775   DALI_TEST_CHECK(overshootYValue > 0.79f && overshootYValue < 0.81f);
1776
1777   // Scroll page further in NW (-50,-50 pixels), then check that overshoot should be now 1.0. (don't release touch)
1778   for(int i = 0;i<50;i++)
1779   {
1780     TestMovePan(application, currentPos, time );
1781     currentPos += Vector2(1.0f, 1.0f); // Move in this direction
1782     time += Wait(application);
1783   }
1784
1785   overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1786   overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1787   DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1788   DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1789
1790   END_TEST;
1791 }
1792
1793 int UtcDaliToolkitScrollViewSetScrollingDirectionP(void)
1794 {
1795   ToolkitTestApplication application;
1796   tet_infoline(" UtcDaliToolkitScrollViewSetScrollingDirectionP");
1797
1798   // Set up a scrollView...
1799   ScrollView scrollView = ScrollView::New();
1800   application.GetScene().Add( scrollView );
1801   Vector2 stageSize = application.GetScene().GetSize();
1802   scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1803   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1804   scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1805
1806   Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1807
1808   scrollView.ScrollTo(START_POSITION, 0.0f);
1809   uint32_t time = 0;
1810   time += Wait(application);
1811
1812   // Try a vertical swipe.
1813   // PerformGestureSwipe not used as a different initial direction was required
1814
1815   Vector2 pos( START_POSITION + Vector2(0.0f, 15.0f) );
1816   TestStartPan( application, START_POSITION, pos, time );
1817   time += Wait(application);
1818   for( int i = 0; i<45; i++ )
1819   {
1820     pos += Vector2(0.0f, 1.0f);
1821     TestMovePan( application, pos, time );
1822     time += Wait( application );
1823   }
1824   pos += Vector2(0.0f, 1.0f);
1825   TestEndPan( application, pos, time );
1826   time += Wait( application );
1827
1828   // Take into account resampling done when prediction is off.
1829   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1830
1831   scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1832
1833   scrollView.ScrollTo(START_POSITION, 0.0f);
1834   time += Wait(application);
1835
1836   // Try a vertical swipe.
1837   // PerformGestureSwipe not used as a different initial direction was required
1838   pos = ( START_POSITION + Vector2(0.0f, 15.0f) );
1839   TestStartPan( application, START_POSITION, pos, time );
1840   time += Wait(application);
1841   for( int i = 0; i<45; i++ )
1842   {
1843     pos += Vector2(0.0f, 1.0f);
1844     TestMovePan( application, pos, time );
1845     time += Wait( application );
1846   }
1847   pos += Vector2(0.0f, 1.0f);
1848   TestEndPan( application, pos, time );
1849   time += Wait( application );
1850
1851   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1852
1853   scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1854
1855   scrollView.ScrollTo(START_POSITION, 0.0f);
1856
1857   time += Wait(application);
1858
1859   // Try a vertical swipe.
1860   // PerformGestureSwipe not used as a different initial direction was required
1861   pos = ( START_POSITION + Vector2(0.0f, 15.0f) );
1862   TestStartPan( application, START_POSITION, pos, time );
1863   time += Wait(application);
1864   for( int i = 0; i<45; i++ )
1865   {
1866     pos += Vector2(0.0f, 1.0f);
1867     TestMovePan( application, pos, time );
1868     time += Wait( application );
1869   }
1870   pos += Vector2(0.0f, 1.0f);
1871   TestEndPan( application, pos, time );
1872   time += Wait( application );
1873
1874   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1875
1876   END_TEST;
1877 }
1878
1879 int UtcDaliToolkitScrollViewRemoveScrollingDirectionP(void)
1880 {
1881   ToolkitTestApplication application;
1882   tet_infoline(" UtcDaliToolkitScrollViewRemoveScrollingDirectionP");
1883
1884   // Set up a scrollView...
1885   ScrollView scrollView = ScrollView::New();
1886   application.GetScene().Add( scrollView );
1887   Vector2 stageSize = application.GetScene().GetSize();
1888   scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1889   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1890   scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1891
1892   Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1893   uint32_t time = 0;
1894
1895   scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1896
1897   scrollView.ScrollTo(START_POSITION, 0.0f);
1898
1899   time += Wait(application);
1900
1901   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION );
1902
1903   // Try a vertical swipe.
1904   // PerformGestureSwipe not used as a different initial direction was required
1905   Vector2 pos( START_POSITION + Vector2(0.0f, 15.0f) );
1906   TestStartPan( application, START_POSITION, pos, time );
1907   time += Wait(application);
1908   for( int i = 0; i<45; i++ )
1909   {
1910     pos += Vector2(0.0f, 1.0f);
1911     TestMovePan( application, pos, time );
1912     time += Wait( application );
1913   }
1914   pos += Vector2(0.0f, 1.0f);
1915   TestEndPan( application, pos, time );
1916   time += Wait( application );
1917
1918   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1919
1920   scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1921   // When the horizontal direction is removed, there are no directions set and therefore all will work
1922   scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_HORIZONTAL);
1923
1924   time += Wait(application);
1925   // Try a vertical swipe.
1926   Vector2 pos2( pos + Vector2(0.0f, 15.0f) );
1927   TestStartPan( application, pos, pos2, time );
1928   time += Wait(application);
1929   for( int i = 0; i<45; i++ )
1930   {
1931     pos2 += Vector2(0.0f, 1.0f);
1932     TestMovePan( application, pos2, time );
1933     time += Wait( application );
1934   }
1935   pos2 += Vector2(0.0f, 1.0f);
1936   TestEndPan( application, pos2, time );
1937
1938   // The previous scroll should not have had any effect
1939   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1940
1941   END_TEST;
1942 }
1943
1944 int UtcDaliToolkitScrollViewSetRulerXP(void)
1945 {
1946   ToolkitTestApplication application;
1947   tet_infoline(" UtcDaliToolkitScrollViewSetRulerXP");
1948
1949   ScrollView scrollView = ScrollView::New();
1950   application.GetScene().Add( scrollView );
1951   RulerPtr rulerX = new FixedRuler( 100.0f );
1952   rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1953
1954   scrollView.SetRulerX( rulerX );
1955
1956   scrollView.ScrollTo( 1, 0.0f );
1957   Wait(application);
1958   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION );
1959
1960   RulerPtr newRulerX = new FixedRuler( 200.0f );
1961   newRulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1962
1963   scrollView.SetRulerX( newRulerX );
1964
1965   scrollView.ScrollTo( 1, 0.0f );
1966   Wait(application);
1967   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 0.0f), TEST_LOCATION );
1968
1969   END_TEST;
1970 }
1971
1972 int UtcDaliToolkitScrollViewSetRulerYP(void)
1973 {
1974   ToolkitTestApplication application;
1975   tet_infoline(" UtcDaliToolkitScrollViewSetRulerYP");
1976
1977   ScrollView scrollView = ScrollView::New();
1978   application.GetScene().Add( scrollView );
1979
1980   RulerPtr rulerY = new FixedRuler( 200.0f );
1981   rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1982
1983   scrollView.SetRulerY( rulerY );
1984
1985   scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f );
1986   Wait(application);
1987   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 350.0f), TEST_LOCATION );
1988
1989   RulerPtr newRulerY = new FixedRuler( 100.0f );
1990   newRulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
1991   scrollView.SetRulerY( newRulerY );
1992
1993   scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f );
1994   Wait(application);
1995   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 200.0f), TEST_LOCATION );
1996
1997   END_TEST;
1998 }
1999
2000 int UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP(void)
2001 {
2002   ToolkitTestApplication application;
2003   tet_infoline(" UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP");
2004
2005   ScrollView scrollView = ScrollView::New();
2006   scrollView.SetMinimumSpeedForFlick(25.0f);
2007   DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 25.0f, TEST_LOCATION );
2008   scrollView.SetMinimumSpeedForFlick(60.0f);
2009   DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 60.0f, TEST_LOCATION );
2010   END_TEST;
2011 }
2012
2013 int UtcDaliToolkitScrollViewSetMinimumDistanceForFlickP(void)
2014 {
2015   ToolkitTestApplication application;
2016   tet_infoline(" UtcDaliToolkitScrollViewSetMinimumDistanceForFlick");
2017
2018   ScrollView scrollView = ScrollView::New();
2019
2020   scrollView.SetMinimumDistanceForFlick(Vector2(30.0f, 15.0f));
2021   DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(30.0f, 15.0f), TEST_LOCATION );
2022   scrollView.SetMinimumDistanceForFlick(Vector2(60.0f, 30.0f));
2023   DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(60.0f, 30.0f), TEST_LOCATION);
2024   END_TEST;
2025 }
2026
2027 int UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP(void)
2028 {
2029   ToolkitTestApplication application;
2030   tet_infoline(" UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP");
2031
2032   ScrollView scrollView = ScrollView::New();
2033   // Disable Refresh signal (TET environment cannot use adaptor's Timer)
2034   scrollView.SetWheelScrollDistanceStep(Vector2(30.0f, 15.0f));
2035   DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(30.0f, 15.0f), TEST_LOCATION );
2036   scrollView.SetWheelScrollDistanceStep(Vector2(60.0f, 30.0f));
2037   DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(60.0f, 30.0f), TEST_LOCATION);
2038   END_TEST;
2039 }
2040
2041 int UtcDaliToolkitScrollViewApplyEffectP(void)
2042 {
2043   ToolkitTestApplication application;
2044   tet_infoline(" UtcDaliToolkitScrollViewApplyEffectP");
2045
2046   // Create a ScrollView
2047   ScrollView scrollView = ScrollView::New();
2048
2049   // Create two scroll view effects
2050   Dali::Path path = Dali::Path::New();
2051   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);
2052   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);
2053
2054   // Apply both effects
2055   scrollView.ApplyEffect(effect);
2056   scrollView.ApplyEffect(newEffect);
2057
2058   DALI_TEST_CHECK( true );
2059
2060   END_TEST;
2061 }
2062
2063 int UtcDaliToolkitScrollViewApplyEffectN(void)
2064 {
2065   ToolkitTestApplication application;
2066   tet_infoline(" UtcDaliToolkitScrollViewApplyEffectN");
2067
2068   // Create a ScrollView
2069   ScrollView scrollView = ScrollView::New();
2070
2071   // Create two scroll view effects
2072   Dali::Path path = Dali::Path::New();
2073   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);
2074   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);
2075
2076   // Apply both effects
2077   scrollView.ApplyEffect(effect);
2078   scrollView.ApplyEffect(newEffect);
2079
2080   // Attempt to apply the same effect again
2081   try
2082   {
2083     scrollView.ApplyEffect(newEffect);
2084     tet_result( TET_FAIL );
2085   }
2086   catch ( DaliException& e )
2087   {
2088     DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
2089   }
2090
2091   END_TEST;
2092 }
2093
2094 int UtcDaliToolkitScrollViewRemoveEffectP(void)
2095 {
2096   ToolkitTestApplication application;
2097   tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectP");
2098
2099   // Create a ScrollView
2100   ScrollView scrollView = ScrollView::New();
2101
2102   // Create two scroll view effects
2103   Dali::Path path = Dali::Path::New();
2104   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);
2105   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);
2106
2107   // Apply both effects
2108   scrollView.ApplyEffect(effect);
2109   scrollView.ApplyEffect(newEffect);
2110
2111   // Remove both effects
2112   scrollView.RemoveEffect(effect);
2113   scrollView.RemoveEffect(newEffect);
2114
2115   DALI_TEST_CHECK( true );
2116
2117   END_TEST;
2118 }
2119
2120 int UtcDaliToolkitScrollViewRemoveEffectN(void)
2121 {
2122   ToolkitTestApplication application;
2123   tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectN");
2124
2125   // Create a ScrollView
2126   ScrollView scrollView = ScrollView::New();
2127
2128   // Create two scroll view effects
2129   Dali::Path path = Dali::Path::New();
2130   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);
2131   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);
2132
2133   // Apply the first effect
2134   scrollView.ApplyEffect(effect);
2135
2136   // Attempt to remove the second effect which has not been applied to scroll view
2137   try
2138   {
2139     scrollView.RemoveEffect(newEffect);
2140     tet_result( TET_FAIL );
2141   }
2142   catch ( DaliException& e )
2143   {
2144     DALI_TEST_ASSERT( e, "effectExistedInScrollView", TEST_LOCATION );
2145   }
2146
2147   END_TEST;
2148 }
2149
2150 int UtcDaliToolkitScrollViewRemoveAllEffectsP(void)
2151 {
2152   ToolkitTestApplication application;
2153   tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsP");
2154
2155   // Create a ScrollView
2156   ScrollView scrollView = ScrollView::New();
2157
2158   // Create two scroll view effects
2159   Dali::Path path = Dali::Path::New();
2160   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);
2161   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);
2162
2163   // Apply both effects
2164   scrollView.ApplyEffect(effect);
2165   scrollView.ApplyEffect(newEffect);
2166
2167   // Attempt to apply the same first effect again
2168   try
2169   {
2170     scrollView.ApplyEffect(effect);
2171     tet_result( TET_FAIL );
2172   }
2173   catch ( DaliException& e )
2174   {
2175     DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
2176   }
2177
2178   // Remove both effects
2179   scrollView.RemoveAllEffects();
2180
2181   // Apply both effects again
2182   scrollView.ApplyEffect(effect);
2183   scrollView.ApplyEffect(newEffect);
2184
2185   DALI_TEST_CHECK( true );
2186
2187   END_TEST;
2188 }
2189
2190 int UtcDaliToolkitScrollViewRemoveAllEffectsN(void)
2191 {
2192   ToolkitTestApplication application;
2193   tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsN");
2194
2195   // Create a ScrollView
2196   ScrollView scrollView = ScrollView::New();
2197
2198   // Remove effects when there is no effect applied previously
2199   scrollView.RemoveAllEffects();
2200
2201   DALI_TEST_CHECK( true );
2202
2203   END_TEST;
2204 }
2205
2206 int UtcDaliToolkitScrollViewSetOvershootEnabledP(void)
2207 {
2208   ToolkitTestApplication application;
2209   tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEnabledP");
2210
2211   ScrollView scrollView = ScrollView::New();
2212
2213   scrollView.SetOvershootEnabled(true);
2214   DALI_TEST_CHECK(scrollView.IsOvershootEnabled());
2215
2216   scrollView.SetOvershootEnabled(false);
2217   DALI_TEST_CHECK(!scrollView.IsOvershootEnabled());
2218
2219   END_TEST;
2220 }
2221
2222 int UtcDaliToolkitScrollViewSetOvershootEffectColorP(void)
2223 {
2224   ToolkitTestApplication application;
2225   tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEffectColorP");
2226
2227   ScrollView scrollView = ScrollView::New();
2228
2229   scrollView.SetOvershootEffectColor(Dali::Color::RED);
2230   DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::RED, TEST_LOCATION);
2231
2232   scrollView.SetOvershootEffectColor(Dali::Color::YELLOW);
2233   DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::YELLOW, TEST_LOCATION);
2234
2235   END_TEST;
2236 }
2237
2238 int UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP(void)
2239 {
2240   ToolkitTestApplication application;
2241   tet_infoline(" UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP");
2242
2243   ScrollView scrollView = ScrollView::New();
2244
2245   scrollView.SetOvershootAnimationSpeed(55.0f);
2246   DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 55.0f, TEST_LOCATION);
2247
2248   scrollView.SetOvershootAnimationSpeed(120.0f);
2249   DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 120.0f, TEST_LOCATION);
2250
2251   END_TEST;
2252 }
2253
2254 int UtcDaliToolkitScrollViewGetSet(void)
2255 {
2256   ToolkitTestApplication application;
2257   tet_infoline(" UtcDaliToolkitScrollViewGetSet");
2258   ScrollView scrollView = ScrollView::New();
2259   scrollView.SetMaxFlickSpeed(0.5f);
2260   DALI_TEST_EQUALS(scrollView.GetMaxFlickSpeed(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
2261   scrollView.SetFrictionCoefficient(0.6f);
2262   DALI_TEST_EQUALS(scrollView.GetFrictionCoefficient(), 0.6f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
2263   scrollView.SetFlickSpeedCoefficient(0.7f);
2264   DALI_TEST_EQUALS(scrollView.GetFlickSpeedCoefficient(), 0.7f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
2265   END_TEST;
2266 }
2267
2268 int UtcDaliToolkitScrollViewRulerDomainConstructorP(void)
2269 {
2270   ToolkitTestApplication application;
2271
2272   RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2273   DALI_TEST_EQUALS( domainX.min, 0.0f, TEST_LOCATION);
2274   DALI_TEST_EQUALS( domainX.max, 200.0f, TEST_LOCATION);
2275   DALI_TEST_EQUALS( domainX.enabled, true, TEST_LOCATION);
2276
2277   RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
2278   DALI_TEST_EQUALS( domainY.min, 100.0f, TEST_LOCATION);
2279   DALI_TEST_EQUALS( domainY.max, 500.0f, TEST_LOCATION);
2280   DALI_TEST_EQUALS( domainY.enabled, false, TEST_LOCATION);
2281
2282   END_TEST;
2283 }
2284
2285 int UtcDaliToolkitScrollViewRulerDomainGetSizeP(void)
2286 {
2287   ToolkitTestApplication application;
2288
2289   RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2290   DALI_TEST_EQUALS( domainX.GetSize(), 200.0f, TEST_LOCATION);
2291
2292   RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
2293   DALI_TEST_EQUALS( domainY.GetSize(), 400.0f, TEST_LOCATION);
2294
2295   END_TEST;
2296 }
2297
2298 int UtcDaliToolkitScrollViewRulerDomainClampP(void)
2299 {
2300   ToolkitTestApplication application;
2301
2302   RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2303
2304   float value = domainX.Clamp(50.0f, 100.0f, 1.0f);
2305   DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
2306
2307   value = domainX.Clamp(300.0f, 20.0f, 1.0f);
2308   DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
2309
2310   value = domainX.Clamp(300.0f, 20.0f, 0.5f);
2311   DALI_TEST_EQUALS( value, 80.0f, TEST_LOCATION);
2312
2313   value = domainX.Clamp(250.0f, 200.0f, 2.0f);
2314   DALI_TEST_EQUALS( value, 200.0f, TEST_LOCATION);
2315
2316   END_TEST;
2317 }
2318
2319 int UtcDaliToolkitScrollViewRulerDomainClampWithStateP(void)
2320 {
2321   ToolkitTestApplication application;
2322
2323   RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2324
2325   ClampState clamped;
2326   float value = domainX.Clamp(50.0f, 100.0f, 1.0f, clamped);
2327   DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
2328   DALI_TEST_EQUALS( clamped, Dali::Toolkit::NOT_CLAMPED, TEST_LOCATION);
2329
2330   value = domainX.Clamp(-100.0f, 200.0f, 1.0f, clamped);
2331   DALI_TEST_EQUALS( value, 0.0f, TEST_LOCATION);
2332   DALI_TEST_EQUALS( clamped, Dali::Toolkit::CLAMPED_TO_MIN, TEST_LOCATION);
2333
2334   value = domainX.Clamp(300.0f, 20.0f, 1.0f, clamped);
2335   DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
2336   DALI_TEST_EQUALS( clamped, Dali::Toolkit::CLAMPED_TO_MAX, TEST_LOCATION);
2337
2338   END_TEST;
2339 }
2340
2341 int UtcDaliToolkitScrollViewDefaultRulerConstructorP(void)
2342 {
2343   ToolkitTestApplication application;
2344   tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerConstructorP");
2345
2346   RulerPtr defaultRuler = new DefaultRuler();
2347   DALI_TEST_CHECK( defaultRuler );
2348
2349   END_TEST;
2350 }
2351
2352 int UtcDaliToolkitScrollViewDefaultRulerDestructorP(void)
2353 {
2354   ToolkitTestApplication application;
2355   tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerDestructorP");
2356
2357   RulerPtr defaultRuler = new DefaultRuler();
2358
2359   DALI_TEST_CHECK( true );
2360   END_TEST;
2361 }
2362
2363 int UtcDaliToolkitScrollViewFixedRulerConstructorP(void)
2364 {
2365   ToolkitTestApplication application;
2366   tet_infoline(" UtcDaliToolkitScrollViewFixedRulerConstructorP");
2367
2368   RulerPtr fixedRuler = new FixedRuler( 100.0f );
2369   DALI_TEST_CHECK( fixedRuler );
2370
2371   fixedRuler = new FixedRuler( 0.0f );
2372   DALI_TEST_CHECK( fixedRuler );
2373
2374   END_TEST;
2375 }
2376
2377 int UtcDaliToolkitScrollViewFixedRulerDestructorP(void)
2378 {
2379   ToolkitTestApplication application;
2380   tet_infoline(" UtcDaliToolkitScrollViewFixedRulerDestructorP");
2381
2382   RulerPtr fixedRuler = new FixedRuler( 100.0f );
2383
2384   DALI_TEST_CHECK( true );
2385   END_TEST;
2386 }
2387
2388 int UtcDaliToolkitScrollViewRulerGetTypeP(void)
2389 {
2390   ToolkitTestApplication application;
2391   tet_infoline(" UtcDaliToolkitScrollViewRulerGetTypeP");
2392
2393   RulerPtr defaultRuler = new DefaultRuler();
2394   DALI_TEST_CHECK( defaultRuler );
2395   DALI_TEST_EQUALS( defaultRuler->GetType(), Dali::Toolkit::Ruler::FREE, TEST_LOCATION);
2396
2397   RulerPtr fixedRuler = new FixedRuler( 100.0f );
2398   DALI_TEST_CHECK( fixedRuler );
2399   DALI_TEST_EQUALS( fixedRuler->GetType(), Dali::Toolkit::Ruler::FIXED, TEST_LOCATION);
2400
2401   END_TEST;
2402 }
2403
2404 int UtcDaliToolkitScrollViewRulerGetExtensionP(void)
2405 {
2406   ToolkitTestApplication application;
2407   tet_infoline(" UtcDaliToolkitScrollViewRulerGetExtensionP");
2408
2409   RulerPtr defaultRuler = new DefaultRuler();
2410   DALI_TEST_CHECK( defaultRuler );
2411   DALI_TEST_CHECK( !defaultRuler->GetExtension() );
2412
2413   RulerPtr fixedRuler = new FixedRuler( 100.0f );
2414   DALI_TEST_CHECK( fixedRuler );
2415   DALI_TEST_CHECK( !fixedRuler->GetExtension() );
2416
2417   END_TEST;
2418 }
2419
2420 int UtcDaliToolkitScrollViewRulerEnableDisable(void)
2421 {
2422   ToolkitTestApplication application;
2423   tet_infoline(" UtcDaliToolkitScrollViewRulerEnableDisable");
2424
2425   RulerPtr ruler = new DefaultRuler();
2426
2427   DALI_TEST_CHECK( ruler->IsEnabled() );
2428   ruler->Disable();
2429   DALI_TEST_CHECK( !ruler->IsEnabled() );
2430   ruler->Enable();
2431   DALI_TEST_CHECK( ruler->IsEnabled() );
2432   END_TEST;
2433 }
2434
2435 int UtcDaliToolkitScrollViewRulerDomainEnableDisable(void)
2436 {
2437   ToolkitTestApplication application;
2438   tet_infoline(" UtcDaliToolkitScrollViewRulerDomainEnableDisable");
2439
2440   RulerPtr ruler = new DefaultRuler();
2441   DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
2442
2443   ruler->SetDomain( RulerDomain(0.0f, 100.0f, true) );
2444   DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 100.0f, TEST_LOCATION );
2445   DALI_TEST_EQUALS( ruler->Clamp(-200.0f), 0.0f, TEST_LOCATION );
2446   DALI_TEST_EQUALS( ruler->Clamp(200.0f), 100.0f, TEST_LOCATION );
2447
2448   ruler->DisableDomain();
2449   DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
2450   DALI_TEST_EQUALS( ruler->Clamp(-200.0f), -200.0f, TEST_LOCATION );
2451   DALI_TEST_EQUALS( ruler->Clamp(200.0f), 200.0f, TEST_LOCATION );
2452   END_TEST;
2453 }
2454
2455 int UtcDaliToolkitScrollViewRulerSnapAndClamp(void)
2456 {
2457   ToolkitTestApplication application;
2458   tet_infoline(" UtcDaliToolkitScrollViewRulerSnapAndClamp");
2459
2460   RulerPtr ruler = new FixedRuler( 50.0f );
2461   ruler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2462
2463   // default testing. (snap and clamp)
2464   DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f), 50.0f, TEST_LOCATION);
2465   DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f), 50.0f, TEST_LOCATION);
2466   DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f), 0.0f, TEST_LOCATION);
2467   DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f), 0.0f, TEST_LOCATION);
2468   DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f), 400.0f, TEST_LOCATION);
2469   DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f), 400.0f, TEST_LOCATION);
2470
2471   // bias testing.
2472   DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
2473   DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.5f), 50.0f, TEST_LOCATION); // No Flick
2474   DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
2475
2476   DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
2477   DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.5f), 0.0f, TEST_LOCATION); // No Flick
2478   DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
2479
2480   // length testing.
2481   DALI_TEST_EQUALS( ruler->SnapAndClamp(-10.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (over left boundary)
2482   DALI_TEST_EQUALS( ruler->SnapAndClamp(-5.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (slightly ovr left boundary)
2483   DALI_TEST_EQUALS( ruler->SnapAndClamp(300.0f, 0.5f, 10.0f), 300.0f, TEST_LOCATION); // 10 units long (not over a boundary)
2484   DALI_TEST_EQUALS( ruler->SnapAndClamp(395.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (slightly over right boundary)
2485   DALI_TEST_EQUALS( ruler->SnapAndClamp(500.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (over right boundary)
2486
2487   // scale testing.
2488   DALI_TEST_EQUALS( ruler->SnapAndClamp(-100.0f, 0.5f, 0.0f, 2.0f), 0.0f, TEST_LOCATION);
2489   DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 2.0f), 50.0f, TEST_LOCATION);
2490   DALI_TEST_EQUALS( ruler->SnapAndClamp(700.0f, 0.5f, 0.0f, 2.0f), 700.0f, TEST_LOCATION);
2491   DALI_TEST_EQUALS( ruler->SnapAndClamp(850.0f, 0.5f, 0.0f, 2.0f), 800.0f, TEST_LOCATION);
2492
2493   // clamp state testing.
2494   ClampState clamped;
2495   DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
2496   DALI_TEST_EQUALS( clamped, NOT_CLAMPED, TEST_LOCATION );
2497   DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
2498   DALI_TEST_EQUALS( clamped, NOT_CLAMPED, TEST_LOCATION );
2499   DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
2500   DALI_TEST_EQUALS( clamped, NOT_CLAMPED, TEST_LOCATION );
2501   DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
2502   DALI_TEST_EQUALS( clamped, CLAMPED_TO_MIN, TEST_LOCATION );
2503   DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
2504   DALI_TEST_EQUALS( clamped, NOT_CLAMPED, TEST_LOCATION );
2505   DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
2506   DALI_TEST_EQUALS( clamped, CLAMPED_TO_MAX, TEST_LOCATION );
2507   END_TEST;
2508 }
2509
2510 int UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP(void)
2511 {
2512   ToolkitTestApplication application;
2513   tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP");
2514
2515   RulerPtr rulerNormal = new FixedRuler( 25.0f );
2516   rulerNormal->SetDomain( RulerDomain(10.0f, 90.0f, true) );
2517
2518   unsigned int volume;
2519   float position;
2520
2521   position = rulerNormal->GetPositionFromPage(1, volume, true);
2522   DALI_TEST_EQUALS( position, 35.0f, TEST_LOCATION );
2523   DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
2524
2525   position = rulerNormal->GetPositionFromPage(2, volume, true);
2526   DALI_TEST_EQUALS( position, 60.0f, TEST_LOCATION );
2527   DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
2528
2529   // Disable the ruler
2530   rulerNormal->Disable();
2531
2532   position = rulerNormal->GetPositionFromPage(1, volume, true);
2533   DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
2534   DALI_TEST_EQUALS( volume, 1u, TEST_LOCATION );
2535
2536   position = rulerNormal->GetPositionFromPage(2, volume, true);
2537   DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
2538   DALI_TEST_EQUALS( volume, 2u, TEST_LOCATION );
2539
2540   END_TEST;
2541 }
2542
2543 int UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP(void)
2544 {
2545   ToolkitTestApplication application;
2546   tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP");
2547
2548   RulerPtr defaultRuler = new DefaultRuler();
2549   DALI_TEST_CHECK( defaultRuler );
2550   DALI_TEST_EQUALS( defaultRuler->GetTotalPages(), 1u, TEST_LOCATION);
2551
2552   END_TEST;
2553 }
2554
2555 int UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP(void)
2556 {
2557   ToolkitTestApplication application;
2558   tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP");
2559
2560   RulerPtr defaultRuler = new DefaultRuler();
2561   DALI_TEST_CHECK( defaultRuler );
2562   DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(100.0f, true), 0u, TEST_LOCATION);
2563   DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(-300.0f, false), 0u, TEST_LOCATION);
2564
2565   END_TEST;
2566 }
2567
2568 int UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP(void)
2569 {
2570   ToolkitTestApplication application;
2571   tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP");
2572
2573   RulerPtr defaultRuler = new DefaultRuler();
2574   DALI_TEST_CHECK( defaultRuler );
2575
2576   unsigned int volume;
2577   DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(0, volume, true), 0.0f, TEST_LOCATION);
2578   DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
2579
2580   DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(3, volume, false), 0.0f, TEST_LOCATION);
2581   DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
2582
2583   END_TEST;
2584 }
2585
2586 int UtcDaliToolkitScrollViewDefaultRulerSnapP(void)
2587 {
2588   ToolkitTestApplication application;
2589   tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerSnapP");
2590
2591   RulerPtr defaultRuler = new DefaultRuler();
2592   DALI_TEST_CHECK( defaultRuler );
2593
2594   DALI_TEST_EQUALS( defaultRuler->Snap(50.0f, 0.5f), 50.0f, TEST_LOCATION);
2595   DALI_TEST_EQUALS( defaultRuler->Snap(-120.0f, 1.0f), -120.0f, TEST_LOCATION);
2596
2597   END_TEST;
2598 }
2599
2600 int UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP(void)
2601 {
2602   ToolkitTestApplication application;
2603   tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP");
2604
2605   RulerPtr fixedRuler = new FixedRuler( 100.0f );
2606   fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2607
2608   fixedRuler->Enable();
2609   DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 4u, TEST_LOCATION);
2610
2611   fixedRuler->Disable();
2612   DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 1u, TEST_LOCATION);
2613
2614   END_TEST;
2615 }
2616
2617 int UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP(void)
2618 {
2619   ToolkitTestApplication application;
2620   tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP");
2621
2622   RulerPtr fixedRuler = new FixedRuler( 100.0f );
2623   fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2624
2625   fixedRuler->Enable();
2626   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 3u, TEST_LOCATION);
2627   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2628   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 1u, TEST_LOCATION);
2629   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2630
2631   fixedRuler->Disable();
2632   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2633   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
2634   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2635   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2636
2637   // Set domain size to be smaller than the ruler space
2638   fixedRuler->SetDomain( RulerDomain(0.0f, 50.0f, true) );
2639
2640   fixedRuler->Enable();
2641   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2642   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2643   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2644   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2645
2646   fixedRuler->Disable();
2647   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2648   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
2649   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2650   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2651
2652   END_TEST;
2653 }
2654
2655 int UtcDaliToolkitScrollViewFixedRulerSnapP(void)
2656 {
2657   ToolkitTestApplication application;
2658   tet_infoline(" UtcDaliToolkitScrollViewFixedRulerSnapP");
2659
2660   RulerPtr fixedRuler = new FixedRuler( 100.0f );
2661   fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2662
2663   DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.0f), -100.0f, TEST_LOCATION);
2664   DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.0f), -100.0f, TEST_LOCATION);
2665   DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.0f), -200.0f, TEST_LOCATION);
2666   DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.0f), -500.0f, TEST_LOCATION);
2667   DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.0f), 0.0f, TEST_LOCATION);
2668   DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.0f), 0.0f, TEST_LOCATION);
2669   DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.0f), 0.0f, TEST_LOCATION);
2670   DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.0f), 100.0f, TEST_LOCATION);
2671   DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.0f), 100.0f, TEST_LOCATION);
2672   DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.0f), 200.0f, TEST_LOCATION);
2673   DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.0f), 600.0f, TEST_LOCATION);
2674
2675   DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.5f), 0.0f, TEST_LOCATION);
2676   DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.5f), -100.0f, TEST_LOCATION);
2677   DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.5f), -100.0f, TEST_LOCATION);
2678   DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.5f), -500.0f, TEST_LOCATION);
2679   DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.5f), 0.0f, TEST_LOCATION);
2680   DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.5f), 100.0f, TEST_LOCATION);
2681   DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.5f), 100.0f, TEST_LOCATION);
2682   DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.5f), 100.0f, TEST_LOCATION);
2683   DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.5f), 100.0f, TEST_LOCATION);
2684   DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.5f), 300.0f, TEST_LOCATION);
2685   DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.5f), 600.0f, TEST_LOCATION);
2686
2687   DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 1.0f), 0.0f, TEST_LOCATION);
2688   DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 1.0f), 0.0f, TEST_LOCATION);
2689   DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 1.0f), -100.0f, TEST_LOCATION);
2690   DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 1.0f), -400.0f, TEST_LOCATION);
2691   DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 1.0f), 100.0f, TEST_LOCATION);
2692   DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 1.0f), 100.0f, TEST_LOCATION);
2693   DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 1.0f), 100.0f, TEST_LOCATION);
2694   DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 1.0f), 200.0f, TEST_LOCATION);
2695   DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 1.0f), 200.0f, TEST_LOCATION);
2696   DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 1.0f), 300.0f, TEST_LOCATION);
2697   DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 1.0f), 700.0f, TEST_LOCATION);
2698
2699   END_TEST;
2700 }
2701
2702 int UtcDaliToolkitScrollViewConstraintsMove(void)
2703 {
2704   ToolkitTestApplication application;
2705   tet_infoline(" UtcDaliToolkitScrollViewConstraintsMove");
2706
2707   // Set up a scrollView...
2708   ScrollView scrollView = ScrollView::New();
2709   application.GetScene().Add( scrollView );
2710   Vector2 stageSize = application.GetScene().GetSize();
2711   scrollView.SetProperty( Actor::Property::SIZE, stageSize);
2712   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
2713   scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2714
2715   // Position rulers.
2716   RulerPtr rulerX = new DefaultRuler();
2717   RulerPtr rulerY = new DefaultRuler();
2718   rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
2719   rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
2720   scrollView.SetRulerX(rulerX);
2721   scrollView.SetRulerY(rulerY);
2722
2723   // Add an Actor to ScrollView,
2724   Actor a = Actor::New();
2725   scrollView.Add(a);
2726   a.SetProperty( Actor::Property::POSITION, TEST_ACTOR_POSITION);
2727   Wait(application);
2728
2729   const Vector2 target = Vector2(100.0f, 100.0f);
2730   const Vector2 target2 = Vector2(200.0f, 200.0f);
2731
2732   Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, MoveActorConstraint );
2733   constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
2734   constraint.SetRemoveAction(Constraint::DISCARD);
2735   scrollView.ApplyConstraintToChildren(constraint);
2736
2737   scrollView.ScrollTo( target, 0.0f );
2738   Wait(application);
2739   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
2740   scrollView.ScrollTo( target2 );
2741   Wait(application, RENDER_DELAY_SCROLL);
2742   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
2743
2744   END_TEST;
2745 }
2746
2747 int UtcDaliToolkitScrollViewConstraintsWrap(void)
2748 {
2749   ToolkitTestApplication application;
2750   tet_infoline(" UtcDaliToolkitScrollViewConstraintsWrap");
2751
2752   // Set up a scrollView...
2753   ScrollView scrollView = ScrollView::New();
2754   application.GetScene().Add( scrollView );
2755   Vector2 stageSize = application.GetScene().GetSize();
2756   scrollView.SetProperty( Actor::Property::SIZE, stageSize);
2757   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
2758   scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2759
2760   // Position rulers.
2761   RulerPtr rulerX = new DefaultRuler();
2762   RulerPtr rulerY = new DefaultRuler();
2763   rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
2764   rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
2765   scrollView.SetRulerX(rulerX);
2766   scrollView.SetRulerY(rulerY);
2767
2768   // Add an Actor to ScrollView,
2769   Actor a = Actor::New();
2770   scrollView.Add(a);
2771   a.SetProperty( Actor::Property::POSITION, TEST_ACTOR_POSITION);
2772   Wait(application);
2773
2774   const Vector2 target = Vector2(100.0f, 100.0f);
2775   const Vector2 target2 = Vector2(200.0f, 200.0f);
2776
2777   Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, WrapActorConstraint );
2778   constraint.AddSource( LocalSource( Actor::Property::SCALE ) );
2779   constraint.AddSource( LocalSource( Actor::Property::ANCHOR_POINT ) );
2780   constraint.AddSource( LocalSource( Actor::Property::SIZE ) );
2781   constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
2782   constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
2783   constraint.AddSource( Source( scrollView, Toolkit::ScrollView::Property::WRAP ) );
2784   constraint.SetRemoveAction(Constraint::DISCARD);
2785   scrollView.ApplyConstraintToChildren(constraint);
2786
2787   scrollView.ScrollTo( target, 0.0f );
2788   Wait(application);
2789   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
2790   scrollView.ScrollTo( target2 );
2791   Wait(application, RENDER_DELAY_SCROLL);
2792   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
2793
2794   scrollView.Remove(a);
2795   Wait(application);
2796
2797   END_TEST;
2798 }
2799
2800 // Non-API test (so no P or N variant).
2801 int UtcDaliToolkitScrollViewGesturePageLimit(void)
2802 {
2803   ToolkitTestApplication application;
2804   tet_infoline( " UtcDaliToolkitScrollViewGesturePageLimit" );
2805
2806   // Set up a scrollView.
2807   ScrollView scrollView = ScrollView::New();
2808
2809   // Do not rely on stage size for UTC tests.
2810   Vector2 viewPageSize( 720.0f, 1280.0f );
2811   scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
2812   scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
2813   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
2814   scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
2815   scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
2816
2817   // Position rulers.
2818   // We set the X ruler to fixed to give us pages to snap to.
2819   Dali::Toolkit::FixedRuler* rulerX = new Dali::Toolkit::FixedRuler( viewPageSize.width );
2820   // Note: The 3x page width is arbitary, but we need enough to show that we are
2821   // capping page movement by the page limiter, and not the domain.
2822   rulerX->SetDomain( Dali::Toolkit::RulerDomain( 0.0f, viewPageSize.width * 3.0f, false ) );
2823   Dali::Toolkit::RulerPtr rulerY = new Dali::Toolkit::DefaultRuler();
2824   rulerY->Disable();
2825   scrollView.SetRulerX( rulerX );
2826   scrollView.SetRulerY( rulerY );
2827
2828   scrollView.SetWrapMode( false );
2829   scrollView.SetScrollSensitive( true );
2830
2831   application.GetScene().Add( scrollView );
2832
2833   // Set up a gesture to perform.
2834   Vector2 startPos( 50.0f, 0.0f );
2835   Vector2 direction( -5.0f, 0.0f );
2836   int frames = 200;
2837
2838   // Force starting position.
2839   scrollView.ScrollTo( startPos, 0.0f );
2840   uint32_t time = 0;
2841   time += Wait( application );
2842
2843   // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
2844   Vector2 currentPos( PerformGestureSwipe( application, startPos, direction, frames - 1, time, false ) );
2845
2846   // Confirm the final X coord has not moved more than one page from the start X position.
2847   DALI_TEST_GREATER( ( startPos.x + viewPageSize.width ), scrollView.GetCurrentScrollPosition().x, TEST_LOCATION );
2848
2849   // Finish the gesture and wait for the snap.
2850   currentPos += direction;
2851   TestEndPan(application, currentPos, time);
2852   // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
2853   time += Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
2854
2855   // Confirm the final X coord has snapped to exactly one page ahead of the start page.
2856   DALI_TEST_EQUALS( viewPageSize.width, scrollView.GetCurrentScrollPosition().x, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2857
2858   END_TEST;
2859 }
2860
2861 int UtcDaliScrollViewSetGetProperty(void)
2862 {
2863   ToolkitTestApplication application;
2864
2865   // Create the ScrollView actor
2866   ScrollView scrollView = ScrollView::New();
2867   DALI_TEST_CHECK(scrollView);
2868
2869   // Event side properties
2870
2871   // Test "wrapEnabled" property
2872   DALI_TEST_CHECK( scrollView.GetPropertyIndex("wrapEnabled") == ScrollView::Property::WRAP_ENABLED );
2873   scrollView.SetProperty( ScrollView::Property::WRAP_ENABLED, true );
2874   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WRAP_ENABLED).Get<bool>(), true, TEST_LOCATION );
2875
2876   // Test "panningEnabled" property
2877   DALI_TEST_CHECK( scrollView.GetPropertyIndex("panningEnabled") == ScrollView::Property::PANNING_ENABLED );
2878   scrollView.SetProperty( ScrollView::Property::PANNING_ENABLED, false );
2879   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::PANNING_ENABLED).Get<bool>(), false, TEST_LOCATION );
2880
2881   // Test "axisAutoLockEnabled" property
2882   DALI_TEST_CHECK( scrollView.GetPropertyIndex("axisAutoLockEnabled") == ScrollView::Property::AXIS_AUTO_LOCK_ENABLED );
2883   scrollView.SetProperty( ScrollView::Property::AXIS_AUTO_LOCK_ENABLED, false );
2884   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::AXIS_AUTO_LOCK_ENABLED).Get<bool>(), false, TEST_LOCATION );
2885
2886   // Test "wheelScrollDistanceStep" property
2887   DALI_TEST_CHECK( scrollView.GetPropertyIndex("wheelScrollDistanceStep") == ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP );
2888   scrollView.SetProperty( ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP, Vector2(100.0f, 50.0f) );
2889   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP).Get<Vector2>(), Vector2(100.0f, 50.0f), TEST_LOCATION );
2890
2891   // Test "overshootEnabled" property
2892   DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootEnabled") == Scrollable::Property::OVERSHOOT_ENABLED  );
2893   DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), scrollView.IsOvershootEnabled(), TEST_LOCATION );
2894   scrollView.SetProperty( Scrollable::Property::OVERSHOOT_ENABLED, false );
2895   DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), false, TEST_LOCATION );
2896
2897   // Animatable properties
2898
2899   // Test "scrollPosition" property
2900   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPosition") == ScrollView::Property::SCROLL_POSITION );
2901   scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(320.0f, 550.0f) );
2902   Wait(application);
2903   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION).Get<Vector2>(), Vector2(320.0f, 550.0f), TEST_LOCATION );
2904
2905   // Test "scrollPrePosition", "scrollPrePositionX" and "scrollPrePositionY" properties
2906   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePosition") == ScrollView::Property::SCROLL_PRE_POSITION );
2907   scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION, Vector2(300.0f, 500.0f) );
2908   Wait(application);
2909   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION).Get<Vector2>(), Vector2(300.0f, 500.0f), TEST_LOCATION );
2910
2911   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionX") == ScrollView::Property::SCROLL_PRE_POSITION_X );
2912   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionY") == ScrollView::Property::SCROLL_PRE_POSITION_Y );
2913   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_X).Get<float>(), 300.0f, TEST_LOCATION );
2914   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_Y).Get<float>(), 500.0f, TEST_LOCATION );
2915   scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_X, 400.0f );
2916   scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_Y, 600.0f );
2917   Wait(application);
2918   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_X).Get<float>(), 400.0f, TEST_LOCATION );
2919   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_Y).Get<float>(), 600.0f, TEST_LOCATION );
2920   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION).Get<Vector2>(), Vector2(400.0f, 600.0f), TEST_LOCATION );
2921
2922   // Test "scrollPrePositionMax", "scrollPrePositionMaxX" and "scrollPrePositionMaxY" properties
2923   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMax") == ScrollView::Property::SCROLL_PRE_POSITION_MAX );
2924   scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX, Vector2(100.0f, 200.0f) );
2925   Wait(application);
2926   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX).Get<Vector2>(), Vector2(100.0f, 200.0f), TEST_LOCATION );
2927
2928   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMaxX") == ScrollView::Property::SCROLL_PRE_POSITION_MAX_X );
2929   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMaxY") == ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y );
2930   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_X).Get<float>(), 100.0f, TEST_LOCATION );
2931   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y).Get<float>(), 200.0f, TEST_LOCATION );
2932   scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX_X, 300.0f );
2933   scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y, 400.0f );
2934   Wait(application);
2935   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_X).Get<float>(), 300.0f, TEST_LOCATION );
2936   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y).Get<float>(), 400.0f, TEST_LOCATION );
2937   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX).Get<Vector2>(), Vector2(300.0f, 400.0f), TEST_LOCATION );
2938
2939   // Test "overshootX" property
2940   DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootX") == ScrollView::Property::OVERSHOOT_X );
2941   scrollView.SetProperty( ScrollView::Property::OVERSHOOT_X, 0.8f );
2942   Wait(application);
2943   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::OVERSHOOT_X).Get<float>(), 0.8f, TEST_LOCATION );
2944
2945   // Test "overshootY" property
2946   DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootY") == ScrollView::Property::OVERSHOOT_Y );
2947   scrollView.SetProperty( ScrollView::Property::OVERSHOOT_Y, 0.8f );
2948   Wait(application);
2949   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y).Get<float>(), 0.8f, TEST_LOCATION );
2950
2951   // Test "scrollFinal", "scrollFinalX" and "scrollFinalY" properties
2952   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinal") == ScrollView::Property::SCROLL_FINAL );
2953   scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL, Vector2(200.0f, 300.0f) );
2954   Wait(application);
2955   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL).Get<Vector2>(), Vector2(200.0f, 300.0f), TEST_LOCATION );
2956
2957   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinalX") == ScrollView::Property::SCROLL_FINAL_X );
2958   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinalY") == ScrollView::Property::SCROLL_FINAL_Y );
2959   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_X).Get<float>(), 200.0f, TEST_LOCATION );
2960   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_Y).Get<float>(), 300.0f, TEST_LOCATION );
2961   scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL_X, 500.0f );
2962   scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL_Y, 600.0f );
2963   Wait(application);
2964   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_X).Get<float>(), 500.0f, TEST_LOCATION );
2965   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_Y).Get<float>(), 600.0f, TEST_LOCATION );
2966   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL).Get<Vector2>(), Vector2(500.0f, 600.0f), TEST_LOCATION );
2967
2968   // Test "wrap" property
2969   DALI_TEST_CHECK( scrollView.GetPropertyIndex("wrap") == ScrollView::Property::WRAP );
2970   scrollView.SetProperty( ScrollView::Property::WRAP, false );
2971   Wait(application);
2972   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WRAP).Get<bool>(), false, TEST_LOCATION );
2973
2974   // Test "panning" property
2975   DALI_TEST_CHECK( scrollView.GetPropertyIndex("panning") == ScrollView::Property::PANNING );
2976   scrollView.SetProperty( ScrollView::Property::PANNING, true );
2977   Wait(application);
2978   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::PANNING).Get<bool>(), true, TEST_LOCATION );
2979
2980   // Test "scrolling" property
2981   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrolling") == ScrollView::Property::SCROLLING );
2982   scrollView.SetProperty( ScrollView::Property::SCROLLING, false );
2983   Wait(application);
2984   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLLING).Get<bool>(), false, TEST_LOCATION );
2985
2986   // Test "scrollDomainSize", "scrollDomainSizeX" and "scrollDomainSizeY" properties
2987   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSize") == ScrollView::Property::SCROLL_DOMAIN_SIZE );
2988   scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE, Vector2(1200.0f, 1300.0f) );
2989   Wait(application);
2990   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE).Get<Vector2>(), Vector2(1200.0f, 1300.0f), TEST_LOCATION );
2991
2992   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSizeX") == ScrollView::Property::SCROLL_DOMAIN_SIZE_X );
2993   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSizeY") == ScrollView::Property::SCROLL_DOMAIN_SIZE_Y );
2994   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_X).Get<float>(), 1200.0f, TEST_LOCATION );
2995   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_Y).Get<float>(), 1300.0f, TEST_LOCATION );
2996   scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE_X, 1500.0f );
2997   scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE_Y, 1600.0f );
2998   Wait(application);
2999   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_X).Get<float>(), 1500.0f, TEST_LOCATION );
3000   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_Y).Get<float>(), 1600.0f, TEST_LOCATION );
3001   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE).Get<Vector2>(), Vector2(1500.0f, 1600.0f), TEST_LOCATION );
3002
3003   // Test "scrollDomainOffset" property
3004   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainOffset") == ScrollView::Property::SCROLL_DOMAIN_OFFSET );
3005   scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_OFFSET, Vector2(500.0f, 200.0f) );
3006   Wait(application);
3007   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_OFFSET).Get<Vector2>(), Vector2(500.0f, 200.0f), TEST_LOCATION );
3008
3009   // Test "scrollPositionDelta" property
3010   DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPositionDelta") == ScrollView::Property::SCROLL_POSITION_DELTA );
3011   scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION_DELTA, Vector2(10.0f, 30.0f) );
3012   Wait(application);
3013   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION_DELTA).Get<Vector2>(), Vector2(10.0f, 30.0f), TEST_LOCATION );
3014
3015   // Test "startPagePosition" property
3016   DALI_TEST_CHECK( scrollView.GetPropertyIndex("startPagePosition") == ScrollView::Property::START_PAGE_POSITION );
3017   scrollView.SetProperty( ScrollView::Property::START_PAGE_POSITION, Vector3(50.0f, 100.0f, 20.0f) );
3018   Wait(application);
3019   DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::START_PAGE_POSITION).Get<Vector3>(), Vector3(50.0f, 100.0f, 20.0f), TEST_LOCATION );
3020
3021   END_TEST;
3022 }
3023
3024 int UtcDaliToolkitScrollViewWheelEvent(void)
3025 {
3026   ToolkitTestApplication application;
3027
3028   // Set up a scrollView.
3029   ScrollView scrollView = ScrollView::New();
3030
3031   // Do not rely on stage size for UTC tests.
3032   Vector2 viewPageSize( 720.0f, 1280.0f );
3033   scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3034   scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
3035   scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
3036   scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
3037   scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
3038
3039   // Position rulers.
3040   // We set the X ruler to fixed to give us pages to snap to.
3041   Dali::Toolkit::FixedRuler* rulerX = new Dali::Toolkit::FixedRuler( viewPageSize.width );
3042   // Note: The 3x page width is arbitary, but we need enough to show that we are
3043   // capping page movement by the page limiter, and not the domain.
3044   rulerX->SetDomain( Dali::Toolkit::RulerDomain( 0.0f, viewPageSize.width * 3.0f, false ) );
3045   Dali::Toolkit::RulerPtr rulerY = new Dali::Toolkit::DefaultRuler();
3046   rulerY->Disable();
3047   scrollView.SetRulerX( rulerX );
3048   scrollView.SetRulerY( rulerY );
3049
3050   scrollView.SetWrapMode( false );
3051
3052   application.GetScene().Add( scrollView );
3053
3054   //Connect to wheel event signal
3055   scrollView.WheelEventSignal().Connect( &OnWheelEvent );
3056
3057   DALI_TEST_CHECK( !gOnWheelEventCalled );
3058
3059   // Render and notify
3060   application.Render();
3061   application.SendNotification();
3062   application.Render();
3063   application.SendNotification();
3064
3065   // Perform a wheel event
3066   Dali::Integration::WheelEvent wheelEvent( Dali::Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, Vector2( 10.0f, 10.0f ), 1, 1000u );
3067   application.ProcessEvent( wheelEvent );
3068   DALI_TEST_CHECK( gOnWheelEventCalled );
3069
3070   // Set X ruler to free
3071   Dali::Toolkit::DefaultRuler* defaultRuler = new Dali::Toolkit::DefaultRuler();
3072   scrollView.SetRulerX( defaultRuler );
3073
3074   // Perform a wheel event
3075   gOnWheelEventCalled = false;
3076   application.ProcessEvent( wheelEvent );
3077   DALI_TEST_CHECK( gOnWheelEventCalled );
3078
3079   // Enable Y ruler
3080   rulerY->Enable();
3081
3082   // Perform a wheel event
3083   gOnWheelEventCalled = false;
3084   application.ProcessEvent( wheelEvent );
3085   DALI_TEST_CHECK( gOnWheelEventCalled );
3086
3087   // Wait until it finishes scrolling
3088   Wait(application, RENDER_DELAY_SCROLL);
3089
3090   // Set Y ruler to fixed
3091   Dali::Toolkit::FixedRuler* fixedRulerY = new Dali::Toolkit::FixedRuler( viewPageSize.height );
3092   scrollView.SetRulerY( fixedRulerY );
3093
3094   // Perform a wheel event
3095   gOnWheelEventCalled = false;
3096   application.ProcessEvent( wheelEvent );
3097   DALI_TEST_CHECK( gOnWheelEventCalled );
3098
3099   END_TEST;
3100 }