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