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