Basic pan-gesture resampling for when prediction is off
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-ScrollView.cpp
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <iostream>
19 #include <stdlib.h>
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <dali-toolkit/dali-toolkit.h>
22 #include <dali/integration-api/events/touch-event-integ.h>
23 #include <dali/integration-api/events/pan-gesture-event.h>
24
25 using namespace Dali;
26 using namespace Toolkit;
27
28 void scroll_view_startup(void)
29 {
30   test_return_value = TET_UNDEF;
31 }
32
33 void scroll_view_cleanup(void)
34 {
35   test_return_value = TET_PASS;
36 }
37
38 namespace
39 {
40 static bool gObjectCreatedCallBackCalled;
41
42 static void TestCallback(BaseHandle handle)
43 {
44   gObjectCreatedCallBackCalled = true;
45 }
46
47
48 const int MILLISECONDS_PER_SECOND = 1000;
49 const int RENDER_FRAME_INTERVAL = 16;                           ///< Duration of each frame in ms. (at approx 60FPS)
50 const int RENDER_ANIMATION_TEST_DURATION_MS = 1000;             ///< 1000ms to test animation
51 const int RENDER_DELAY_SCROLL = 1000;                           ///< duration to wait for any scroll to complete.
52
53 // For Clamp Signal testing...
54 const float CLAMP_EXCESS_WIDTH = 200.0f;                        ///< Amount of width that can be panned outside scrollview
55 const float CLAMP_EXCESS_HEIGHT = 200.0f;                       ///< Amount of height that can be panned outside scrollview
56 const int CLAMP_STEP_0_CHECK_NOTCLAMPED = 0;                    ///< FSM: "First check that scrollview isn't clamped"
57 const int CLAMP_STEP_1_CHECK_CLAMPED_WEST = 1;                  ///< FSM: "Next check that scrollview clamps against left side"
58 const int CLAMP_STEP_2_CHECK_CLAMPED_SOUTH_WEST = 2;            ///< FSM: "Then check that scrollview clamps against bottom-left side"
59 const int CLAMP_STEP_3_SUCCESS = 3;                             ///< FSM: "Finished (Success)"
60 const Vector2 CLAMP_START_SCROLL_POSITION(30.0f, 100.0f);       ///< Scroll start position for the Clamping tests.
61 const Vector2 CLAMP_TOUCH_START( 100.0f, 100.0f );              ///< Start point to touch from for the Clamping tests.
62 const Vector2 CLAMP_TOUCH_MOVEMENT( 5.0f, -5.0f );              ///< Amount to move touch for each frame for the Clamping tests.
63 const int CLAMP_GESTURE_FRAMES = 100;                           ///< Number of Frames to synthesize a gesture for the Clamping tests.
64 const Vector3 TEST_ACTOR_POSITION(100.0f, 100.0f, 0.0f);        ///< A Test actor position offset (arbitrary value)
65 const Vector3 TEST_CONSTRAINT_OFFSET(1.0f, 2.0f, 0.0f);         ///< A Test constraint offset (arbitrary value to test effects)
66 const float TEST_RATIO_TOLERANCE = 0.05;                        ///< +/-5% tolerance for ratio comparisons.
67
68 const float DEFAULT_SNAP_OVERSHOOT_DURATION(0.5f);                  ///< Default overshoot snapping animation time.
69 const float DEFAULT_MAX_OVERSHOOT(100.0f);                          ///< Default maximum allowed overshoot in pixels
70
71 const int MAX_FRAMES_TO_TEST_OVERSHOOT = 600;                       ///< 10 seconds (at 60 frames per second).
72 const Vector2 OVERSHOOT_START_SCROLL_POSITION(100.0f, 100.0f);       ///< Scroll start position for the Overshoot tests.
73 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)
74 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).
75 const float TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION = 0.05f;           ///< a Test duration
76 const float TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION = 1.5f;            ///< another Test duration
77 const float TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION = TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * 0.5f; // Same as above, but different alpha function.
78 const float TIME_TOLERANCE = 0.05f;                                 ///< Allow testing tolerance between a 10th of second (+/- 3 frames)
79
80
81 // Generate a PanGestureEvent to send to Core
82 Integration::PanGestureEvent GeneratePan(
83     Gesture::State state,
84     const Vector2& previousPosition,
85     const Vector2& currentPosition,
86     unsigned long timeDelta,
87     unsigned int numberOfTouches = 1)
88 {
89   Integration::PanGestureEvent pan(state);
90
91   pan.previousPosition = previousPosition;
92   pan.currentPosition = currentPosition;
93   pan.timeDelta = timeDelta;
94   pan.numberOfTouches = numberOfTouches;
95
96   return pan;
97 }
98
99 /**
100  * Helper to generate PanGestureEvent
101  *
102  * @param[in] application Application instance
103  * @param[in] state The Gesture State
104  * @param[in] pos The current position of touch.
105  */
106 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
107 {
108   static Vector2 last;
109
110   if( (state == Gesture::Started) ||
111       (state == Gesture::Possible) )
112   {
113     last.x = pos.x;
114     last.y = pos.y;
115   }
116
117   application.ProcessEvent(GeneratePan(state, last, pos, RENDER_FRAME_INTERVAL));
118
119   last.x = pos.x;
120   last.y = pos.y;
121 }
122
123 /*
124  * Simulate time passed by.
125  *
126  * @note this will always process at least 1 frame (1/60 sec)
127  *
128  * @param application Test application instance
129  * @param duration Time to pass in milliseconds.
130  * @return The actual time passed in milliseconds
131  */
132 int Wait(ToolkitTestApplication& application, int duration = 0)
133 {
134   int time = 0;
135
136   for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
137   {
138     application.SendNotification();
139     application.Render(RENDER_FRAME_INTERVAL);
140     time += RENDER_FRAME_INTERVAL;
141   }
142
143   return time;
144 }
145
146 // Callback probes.
147
148 static bool gOnScrollStartCalled;                       ///< Whether the OnScrollStart signal was invoked.
149 static bool gOnScrollUpdateCalled;                      ///< Whether the OnScrollUpdate signal was invoked.
150 static bool gOnScrollCompleteCalled;                    ///< Whether the OnScrollComplete signal was invoked.
151 static bool gOnSnapStartCalled;                         ///< Whether the OnSnapStart signal was invoked.
152 static SnapType gLastSnapType;                          ///< Snaping information from SnapEvent.
153 static Vector3 gConstraintResult;                       ///< Result from constraint.
154
155 /**
156  * Invoked when scrolling starts.
157  *
158  * @param[in] position The current scroll position.
159  */
160 static void OnScrollStart( const Vector2& position )
161 {
162   gOnScrollStartCalled = true;
163 }
164
165 /**
166  * Invoked when scrolling updates (via dragging)
167  *
168  * @param[in] position The current scroll position.
169  */
170 static void OnScrollUpdate( const Vector2& position )
171 {
172   gOnScrollUpdateCalled = true;
173 }
174
175 /**
176  * Invoked when scrolling finishes
177  *
178  * @param[in] position The current scroll position.
179  */
180 static void OnScrollComplete( const Vector2& position )
181 {
182   gOnScrollCompleteCalled = true;
183 }
184
185 /**
186  * Invoked when a snap or flick started.
187  *
188  * @param[in] event The type of snap and the target position/scale/rotation.
189  */
190 static void OnSnapStart( const ScrollView::SnapEvent& event )
191 {
192   gOnSnapStartCalled = true;
193   gLastSnapType = event.type;
194 }
195
196 /**
197  * TestSumConstraint
198  *
199  * Summation of current value, property, and offset.
200  *
201  * current' = current + mOffset + property;
202  */
203 struct TestSumConstraint
204 {
205   /**
206    * @param[in] offset The offset to be added to current.
207    */
208   TestSumConstraint(const Vector3& offset)
209   :mOffset(offset)
210   {
211   }
212
213   /**
214    * @param[in] current The current base value
215    * @param[in] inputs Contains the property to be added to current.
216    * @return The new current Vector.
217    */
218   void operator()( Vector3& current, const PropertyInputContainer& inputs )
219   {
220     gConstraintResult = current + Vector3(inputs[0]->GetVector2()) + mOffset;
221     current = gConstraintResult;
222   }
223
224   Vector3 mOffset;
225
226 };
227
228 /**
229  * @param[in] application The application instance
230  * @param[in] scrollView The scrollView instance
231  * @return The time taken for the overshoot to reach origin (zero)
232  */
233 static float TestOvershootSnapDuration(ToolkitTestApplication &application, ScrollView scrollView)
234 {
235   int timeToReachOrigin = -1;
236   for(int i = 0;i<MAX_FRAMES_TO_TEST_OVERSHOOT;i++)
237   {
238     float overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
239     float overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
240     if(overshootXValue == 0.0f && overshootYValue == 0.0f)
241     {
242       break;
243     }
244
245     timeToReachOrigin += Wait(application);
246   }
247
248   return static_cast<float>(timeToReachOrigin) * 0.001f; // return in seconds not ms.
249 }
250
251 /**
252  * y = 2x alpha function, which is clamped between 0.0f - 1.0f
253  *
254  * Animations should appear to finish (reach 100% point)
255  * at just half the time of a regular Linear AlphaFunction.
256  *
257  * @param[in] progress value (ranges from 0.0f - 1.0f)
258  * @return interpolation value (ranges from 0.0f - 1.0f)
259  */
260 float TestAlphaFunction(float progress)
261 {
262   return std::min( progress * 2.0f, 1.0f );
263 }
264
265 } // unnamed namespace
266
267
268 int UtcDaliToolkitScrollViewConstructorP(void)
269 {
270   ToolkitTestApplication application;
271
272   ScrollView scrollView;
273   DALI_TEST_CHECK( !scrollView );
274   END_TEST;
275 }
276
277 int UtcDaliToolkitScrollViewCopyConstructorP(void)
278 {
279   ToolkitTestApplication application;
280
281   ScrollView scrollView = ScrollView::New();
282   scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) );
283
284   ScrollView copy( scrollView );
285   DALI_TEST_CHECK( copy );
286   DALI_TEST_CHECK( copy.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) == scrollView.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) );
287   END_TEST;
288 }
289
290 int UtcDaliToolkitScrollViewAssignmentOperatorP(void)
291 {
292   ToolkitTestApplication application;
293
294   ScrollView scrollView = ScrollView::New();
295   scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) );
296
297   ScrollView copy = scrollView;
298   DALI_TEST_CHECK( copy );
299   DALI_TEST_CHECK( copy.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) == scrollView.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) );
300   END_TEST;
301 }
302
303 int UtcDaliScrollViewDestructorP(void)
304 {
305   ToolkitTestApplication application;
306
307   ScrollView* scrollView = new ScrollView();
308   delete scrollView;
309
310   DALI_TEST_CHECK( true );
311   END_TEST;
312 }
313
314 int UtcDaliToolkitScrollViewNewP(void)
315 {
316   ToolkitTestApplication application;
317   tet_infoline(" UtcDaliToolkitScrollViewNewP");
318
319   ScrollView scrollView;
320
321   DALI_TEST_CHECK( !scrollView );
322
323   scrollView = ScrollView::New();
324
325   DALI_TEST_CHECK( scrollView );
326
327   ScrollView scrollView2(scrollView);
328
329   DALI_TEST_CHECK( scrollView2 == scrollView );
330
331   //Additional check to ensure object is created by checking if it's registered
332   ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
333   DALI_TEST_CHECK( registry );
334
335   gObjectCreatedCallBackCalled = false;
336   registry.ObjectCreatedSignal().Connect( &TestCallback );
337   {
338     ScrollView scrollView = ScrollView::New();
339   }
340   DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
341   END_TEST;
342 }
343
344 int UtcDaliToolkitScrollViewDownCastP(void)
345 {
346   ToolkitTestApplication application;
347   tet_infoline(" UtcDaliToolkitScrollViewDownCastP");
348
349   ScrollView scrollView = ScrollView::New();
350   BaseHandle handle(scrollView);
351
352   ScrollView newScrollView = ScrollView::DownCast( handle );
353   DALI_TEST_CHECK( scrollView );
354   DALI_TEST_CHECK( newScrollView == scrollView );
355   END_TEST;
356 }
357
358 int UtcDaliToolkitScrollViewScrollToPositionP(void)
359 {
360   ToolkitTestApplication application;
361   tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionP");
362
363   // Create the ScrollView actor
364   ScrollView scrollView = ScrollView::New();
365   Stage::GetCurrent().Add( scrollView );
366
367   const Vector2 target = Vector2(100.0f, 200.0f);
368   const Vector2 target2 = Vector2(300.0f, 100.0f);
369
370   scrollView.ScrollTo( target, 0.0f );
371   Wait(application);
372   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
373   scrollView.ScrollTo( target2 );
374   Wait(application, RENDER_DELAY_SCROLL);
375   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
376
377   END_TEST;
378 }
379
380 int UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP(void)
381 {
382   ToolkitTestApplication application;
383   tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP");
384
385   ScrollView scrollView = ScrollView::New();
386   Stage::GetCurrent().Add( scrollView );
387   RulerPtr rulerX = new FixedRuler( 100.0f );
388   rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
389   RulerPtr rulerY = new FixedRuler( 100.0f );
390   rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
391
392   scrollView.SetRulerX( rulerX );
393   scrollView.SetRulerY( rulerY );
394
395   scrollView.SetWrapMode(true);
396
397   const Vector2 target = Vector2(50.0f, 50.0f);
398   const Vector2 target2 = Vector2(150.0f, 150.0f);
399
400   scrollView.ScrollTo( target, 0.0f );
401   Wait(application, RENDER_DELAY_SCROLL);
402   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
403
404   scrollView.ScrollTo( target2, 0.25f, Dali::Toolkit::DirectionBiasLeft, Dali::Toolkit::DirectionBiasLeft );
405   Wait(application, RENDER_DELAY_SCROLL);
406   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2::ZERO, TEST_LOCATION );
407
408   scrollView.ScrollTo( target, 0.0f );
409   Wait(application, RENDER_DELAY_SCROLL);
410   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
411
412   scrollView.ScrollTo( target2, 0.25f, Dali::Toolkit::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
413   Wait(application, RENDER_DELAY_SCROLL);
414   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
415
416   END_TEST;
417 }
418
419 int UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionP(void)
420 {
421   ToolkitTestApplication application;
422   tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionP");
423
424   // Create the ScrollView actor
425   ScrollView scrollView = ScrollView::New();
426   Stage::GetCurrent().Add( scrollView );
427
428   const Vector2 target = Vector2(100.0f, 200.0f);
429   const Vector2 target2 = Vector2(300.0f, 100.0f);
430
431   scrollView.ScrollTo( target, 0.5f, TestAlphaFunction );
432   Wait(application, 250);
433   // Check that the scroll animation should finish within just half of the specified duration with the above alpha function
434   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
435
436   scrollView.ScrollTo( target2, 0.5f, AlphaFunction::LINEAR );
437   Wait(application, 250);
438   // Check that the scroll animation has not finished within half of the specified duration with the linear alpha function
439   DALI_TEST_CHECK( scrollView.GetCurrentScrollPosition() != target2 );
440
441   // Wait till the end of the specified duration
442   Wait(application, 250);
443   // Check that the scroll animation has finished
444   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
445
446   END_TEST;
447 }
448
449 int UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionAndDirectionBiasP(void)
450 {
451   ToolkitTestApplication application;
452   tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionAndDirectionBiasP");
453
454   ScrollView scrollView = ScrollView::New();
455   Stage::GetCurrent().Add( scrollView );
456   RulerPtr rulerX = new FixedRuler( 100.0f );
457   rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
458   RulerPtr rulerY = new FixedRuler( 100.0f );
459   rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
460
461   scrollView.SetRulerX( rulerX );
462   scrollView.SetRulerY( rulerY );
463
464   scrollView.SetWrapMode(true);
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, AlphaFunction::LINEAR, Dali::Toolkit::DirectionBiasLeft, Dali::Toolkit::DirectionBiasLeft );
474   Wait(application, RENDER_DELAY_SCROLL);
475   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2::ZERO, 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, AlphaFunction::LINEAR, Dali::Toolkit::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
482   Wait(application, RENDER_DELAY_SCROLL);
483   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
484
485   scrollView.ScrollTo( target, 0.0f );
486   Wait(application, RENDER_DELAY_SCROLL);
487   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
488
489   scrollView.ScrollTo( target2, 0.25f, TestAlphaFunction, Dali::Toolkit::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
490   Wait(application, 125);
491   // Check that the scroll animation should finish within just half of the specified duration with the above alpha function
492   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
493
494   END_TEST;
495 }
496
497 int UtcDaliToolkitScrollViewScrollToPageP(void)
498 {
499   ToolkitTestApplication application;
500   tet_infoline(" UtcDaliToolkitScrollViewScrollToPageP");
501
502   ScrollView scrollView = ScrollView::New();
503   Stage::GetCurrent().Add( scrollView );
504   RulerPtr rulerX = new FixedRuler( 100.0f );
505   rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
506   RulerPtr rulerY = new FixedRuler( 100.0f );
507   rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
508
509   scrollView.SetRulerX( rulerX );
510   scrollView.SetRulerY( rulerY );
511
512   scrollView.ScrollTo( 1, 0.0f );
513   Wait(application);
514   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION );
515
516   scrollView.ScrollTo( 5, 0.0f );
517   Wait(application);
518   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(500.0f, 0.0f), TEST_LOCATION );
519
520   scrollView.ScrollTo( 10, 0.0f );
521   Wait(application);
522   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 100.0f), TEST_LOCATION );
523
524   scrollView.ScrollTo( 15, 0.0f );
525   Wait(application);
526   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(700.0f, 100.0f), TEST_LOCATION );
527   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION );
528
529   scrollView.ScrollTo( 3 );
530   Wait(application, RENDER_DELAY_SCROLL);
531   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(300.0f, 0.0f), TEST_LOCATION );
532   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION );
533
534   scrollView.ScrollTo( 9 );
535   Wait(application, RENDER_DELAY_SCROLL);
536   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 100.0f), TEST_LOCATION );
537   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION );
538
539   // Apply DefaultRulers instead and see what happens.
540   rulerX = new DefaultRuler();
541   rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
542   rulerY = new DefaultRuler();
543   rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
544
545   scrollView.SetRulerX( rulerX );
546   scrollView.SetRulerY( rulerY );
547
548   // This time should always scroll to origin (0.0f, 0.0f)
549   scrollView.ScrollTo( 1, 0.0f );
550   Wait(application);
551   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
552   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
553
554   END_TEST;
555 }
556
557 int UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP(void)
558 {
559   ToolkitTestApplication application;
560   tet_infoline(" UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP");
561
562   ScrollView scrollView = ScrollView::New();
563   Stage::GetCurrent().Add( scrollView );
564   RulerPtr rulerX = new FixedRuler( 100.0f );
565   rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
566   RulerPtr rulerY = new FixedRuler( 100.0f );
567   rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
568
569   scrollView.SetRulerX( rulerX );
570   scrollView.SetRulerY( rulerY );
571
572   scrollView.SetWrapMode(true);
573
574   scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DirectionBiasLeft );
575
576   Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame
577   // Check that the scroll position remains the same
578   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
579
580   Wait(application, RENDER_DELAY_SCROLL); // Wait for one second
581   // Check that it stays at the same page (i.e. the same scroll position)
582   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
583   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
584
585   scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DirectionBiasRight );
586
587   Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame
588   // Check that it scrolls towards the right
589   DALI_TEST_CHECK( scrollView.GetCurrentScrollPosition().x > 0.0f );
590
591   Wait(application, RENDER_DELAY_SCROLL); // Wait for one second
592   // Check that it scrolls back to the same page (i.e. the same scroll position)
593   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
594   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
595
596   END_TEST;
597 }
598
599 int UtcDaliToolkitScrollViewScrollToActorP(void)
600 {
601   ToolkitTestApplication application;
602   tet_infoline(" UtcDaliToolkitScrollViewScrollToActorP");
603
604   ScrollView scrollView = ScrollView::New();
605   Stage::GetCurrent().Add( scrollView );
606
607   Actor actorA = Actor::New();
608   const Vector3 positionA = Vector3(100.0f, 400.0f, 0.0f);
609   actorA.SetPosition(positionA);
610   scrollView.Add(actorA);
611
612   Actor actorB = Actor::New();
613   const Vector3 positionB = Vector3(500.0f, 200.0f, 0.0f);
614   actorB.SetPosition(positionB);
615   scrollView.Add(actorB);
616
617   Wait(application);
618
619   scrollView.ScrollTo(actorA, 0.0f);
620   Wait(application);
621   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION );
622
623   Wait(application);
624   scrollView.ScrollTo(actorB, 0.0f);
625   Wait(application);
626   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION );
627
628   scrollView.ScrollTo(actorA);
629   Wait(application, RENDER_DELAY_SCROLL);
630   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION );
631
632   scrollView.ScrollTo(actorB);
633   Wait(application, RENDER_DELAY_SCROLL);
634   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION );
635   END_TEST;
636 }
637
638 int UtcDaliToolkitScrollViewScrollToSnapPointP(void)
639 {
640   ToolkitTestApplication application;
641   tet_infoline(" UtcDaliToolkitScrollViewScrollToSnapPointP");
642
643   ScrollView scrollView = ScrollView::New();
644   Stage::GetCurrent().Add( scrollView );
645   RulerPtr rulerX = new FixedRuler( 100.0f );
646   rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
647   RulerPtr rulerY = new FixedRuler( 100.0f );
648   rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
649
650   scrollView.SetRulerX( rulerX );
651   scrollView.SetRulerY( rulerY );
652
653   scrollView.ScrollTo( Vector2(120.0f, 190.0f), 0.0f );
654   Wait(application);
655   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(120.0f, 190.0f), TEST_LOCATION );
656
657   scrollView.ScrollToSnapPoint();
658
659   Wait(application, RENDER_DELAY_SCROLL);
660   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 200.0f), TEST_LOCATION );
661   END_TEST;
662 }
663
664 int UtcDaliToolkitScrollViewSetScrollUpdateDistanceP(void)
665 {
666   ToolkitTestApplication application;
667   tet_infoline(" UtcDaliToolkitScrollViewSetScrollUpdateDistanceP");
668
669   ScrollView scrollView = ScrollView::New();
670
671   scrollView.SetScrollUpdateDistance(0);
672   DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 0, TEST_LOCATION);
673   scrollView.SetScrollUpdateDistance(10);
674   DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 10, TEST_LOCATION);
675   scrollView.SetScrollUpdateDistance(1000);
676   DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 1000, TEST_LOCATION);
677   END_TEST;
678 }
679
680 int UtcDaliToolkitScrollViewSetWrapModeP(void)
681 {
682   ToolkitTestApplication application;
683   tet_infoline(" UtcDaliToolkitScrollViewSetWrapModeP");
684
685   ScrollView scrollView = ScrollView::New();
686   Stage::GetCurrent().Add( scrollView );
687
688   Actor actor = Actor::New();
689   scrollView.Add( actor );
690
691   // Position rulers. 4x4 grid.
692   RulerPtr rulerX = new FixedRuler(50.0f);
693   RulerPtr rulerY = new FixedRuler(50.0f);
694   rulerX->SetDomain( RulerDomain(0.0f, 200.0f, false) );
695   rulerY->SetDomain( RulerDomain(0.0f, 200.0f, false) );
696   scrollView.SetRulerX(rulerX);
697   scrollView.SetRulerY(rulerY);
698
699   scrollView.SetWrapMode(false);
700   scrollView.ScrollTo(Vector2(225.0f, 125.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
701   Wait(application);
702   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 17, TEST_LOCATION );
703
704   scrollView.SetWrapMode(true);
705   scrollView.ScrollTo(Vector2(230.0f, 130.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
706   Wait(application);
707   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 13, TEST_LOCATION );
708   END_TEST;
709 }
710
711 int UtcDaliToolkitScrollViewActorAutoSnap(void)
712 {
713   ToolkitTestApplication application;
714   tet_infoline(" UtcDaliToolkitScrollViewActorAutoSnap");
715
716   ScrollView scrollView = ScrollView::New();
717   Stage::GetCurrent().Add( scrollView );
718
719   // Position rulers.
720   RulerPtr rulerX = new DefaultRuler();
721   RulerPtr rulerY = new DefaultRuler();
722   rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
723   rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
724   scrollView.SetRulerX(rulerX);
725   scrollView.SetRulerY(rulerY);
726
727   const Vector3 aPosition = Vector3(200.0f, 50.0f, 0.0f);
728   Actor a = Actor::New();
729   scrollView.Add(a);
730   a.SetPosition(aPosition);
731
732   const Vector3 bPosition = Vector3(600.0f, 600.0f, 0.0f);
733   Actor b = Actor::New();
734   scrollView.Add(b);
735   b.SetPosition(bPosition);
736
737   // Goto a random position, and execute snap (should not move)
738   Vector2 targetScroll = Vector2(500.0f, 500.0f);
739   scrollView.ScrollTo(targetScroll, 0.0f);
740   Wait(application);
741   scrollView.ScrollToSnapPoint();
742   Wait(application, RENDER_DELAY_SCROLL);
743   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), targetScroll, TEST_LOCATION );
744
745   // Enable ActorAutoSnap, and now try snapping.
746   scrollView.SetActorAutoSnap(true);
747   scrollView.ScrollToSnapPoint();
748   Wait(application, RENDER_DELAY_SCROLL);
749   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), bPosition.GetVectorXY(), TEST_LOCATION );
750
751   scrollView.ScrollTo(Vector2(0.0f, 0.0f), 0.0f);
752   Wait(application);
753   scrollView.ScrollToSnapPoint();
754   Wait(application, RENDER_DELAY_SCROLL);
755   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), aPosition.GetVectorXY(), TEST_LOCATION );
756   END_TEST;
757 }
758
759 int UtcDaliToolkitScrollViewSignalsStartComplete(void)
760 {
761   ToolkitTestApplication application;
762   tet_infoline(" UtcDaliToolkitScrollViewSignalsStartComplete");
763
764   gOnScrollStartCalled = false;
765   gOnScrollCompleteCalled = false;
766
767   ScrollView scrollView = ScrollView::New();
768   Stage::GetCurrent().Add( scrollView );
769
770   // Position rulers.
771   RulerPtr rulerX = new DefaultRuler();
772   RulerPtr rulerY = new DefaultRuler();
773   rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
774   rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
775   scrollView.SetRulerX(rulerX);
776   scrollView.SetRulerY(rulerY);
777   scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
778   scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
779   scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
780   scrollView.ScrollTo( Vector2(100.0f, 100.0f) );
781   Wait(application, RENDER_DELAY_SCROLL);
782
783   DALI_TEST_CHECK(gOnScrollStartCalled);
784   DALI_TEST_CHECK(gOnScrollCompleteCalled);
785   END_TEST;
786 }
787
788 int UtcDaliToolkitScrollViewSignalsUpdate(void)
789 {
790   ToolkitTestApplication application;
791   tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate");
792
793   gOnScrollStartCalled = false;
794   gOnScrollUpdateCalled = false;
795   gOnScrollCompleteCalled = false;
796
797   ScrollView scrollView = ScrollView::New();
798   Stage::GetCurrent().Add( scrollView );
799   Vector2 stageSize = Stage::GetCurrent().GetSize();
800   scrollView.SetSize(stageSize);
801   scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
802   scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
803
804   // Position rulers.
805   RulerPtr rulerX = new DefaultRuler();
806   RulerPtr rulerY = new DefaultRuler();
807   rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
808   rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
809   scrollView.SetRulerX(rulerX);
810   scrollView.SetRulerY(rulerY);
811   scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
812   scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
813   scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
814
815   ImageActor image = CreateSolidColorActor( Color::RED );
816   image.SetSize(stageSize);
817   image.SetParentOrigin(ParentOrigin::TOP_LEFT);
818   image.SetAnchorPoint(AnchorPoint::TOP_LEFT);
819   scrollView.Add(image);
820
821   Wait(application);
822
823   // Do a pan starting from 100,100 and moving down diagonally.
824   Vector2 pos(100.0f, 100.0f);
825   SendPan(application, Gesture::Possible, pos);
826   SendPan(application, Gesture::Started, pos);
827   pos.x += 5.0f;
828   pos.y += 5.0f;
829   Wait(application, 100);
830
831   for(int i = 0;i<20;i++)
832   {
833     SendPan(application, Gesture::Continuing, pos);
834     pos.x += 5.0f;
835     pos.y += 5.0f;
836     Wait(application);
837   }
838
839   SendPan(application, Gesture::Finished, pos);
840   Wait(application, RENDER_DELAY_SCROLL);
841
842   DALI_TEST_CHECK(gOnScrollStartCalled);
843   DALI_TEST_CHECK(gOnScrollUpdateCalled);
844   DALI_TEST_CHECK(gOnScrollCompleteCalled);
845   END_TEST;
846 }
847
848 static Vector2 PerformGestureDiagonalSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, bool finish = true)
849 {
850   gOnScrollStartCalled = false;
851   gOnScrollUpdateCalled = false;
852   gOnScrollCompleteCalled = false;
853   gOnSnapStartCalled = false;
854
855   // Now do a pan starting from (start) and heading (direction)
856   Vector2 pos(start);
857   SendPan(application, Gesture::Possible, pos);
858   SendPan(application, Gesture::Started, pos);
859   Wait(application);
860
861   for(int i = 0;i<frames;i++)
862   {
863     pos += direction; // Move in this direction
864     SendPan(application, Gesture::Continuing, pos);
865     Wait(application);
866   }
867
868   if(finish)
869   {
870     pos += direction; // Move in this direction.
871     SendPan(application, Gesture::Finished, pos);
872     Wait(application, RENDER_DELAY_SCROLL);
873   }
874
875   return pos;
876 }
877
878 int UtcDaliToolkitScrollViewScrollSensitive(void)
879 {
880   ToolkitTestApplication application;
881   tet_infoline(" UtcDaliToolkitScrollViewScrollSensitive");
882
883   // Set up a scrollView...
884   ScrollView scrollView = ScrollView::New();
885   Stage::GetCurrent().Add( scrollView );
886   Vector2 stageSize = Stage::GetCurrent().GetSize();
887   scrollView.SetSize(stageSize);
888   scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
889   scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
890
891   // Position rulers.
892   RulerPtr rulerX = new DefaultRuler();
893   RulerPtr rulerY = new DefaultRuler();
894   rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
895   rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
896   scrollView.SetRulerX(rulerX);
897   scrollView.SetRulerY(rulerY);
898   scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
899   scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
900   scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
901   scrollView.SnapStartedSignal().Connect( &OnSnapStart );
902
903   scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
904   Wait(application);
905
906   // First try insensitive swipe.
907   scrollView.SetScrollSensitive(false);
908   PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, true);
909
910   DALI_TEST_CHECK( !gOnScrollStartCalled );
911   DALI_TEST_CHECK( !gOnScrollCompleteCalled );
912   DALI_TEST_CHECK( !gOnSnapStartCalled );
913
914   // Second try sensitive swipe.
915   scrollView.SetScrollSensitive(true);
916   PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, true);
917
918   DALI_TEST_CHECK( gOnScrollStartCalled );
919   DALI_TEST_CHECK( gOnScrollCompleteCalled );
920   DALI_TEST_CHECK( gOnSnapStartCalled );
921   END_TEST;
922 }
923
924 int UtcDaliToolkitScrollViewAxisAutoLock(void)
925 {
926   ToolkitTestApplication application;
927   tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLock");
928
929   // Set up a scrollView...
930   ScrollView scrollView = ScrollView::New();
931   Stage::GetCurrent().Add( scrollView );
932   Vector2 stageSize = Stage::GetCurrent().GetSize();
933   scrollView.SetSize(stageSize);
934   scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
935   scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
936
937   // Position rulers.
938   RulerPtr rulerX = new DefaultRuler();
939   RulerPtr rulerY = new DefaultRuler();
940   rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
941   rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
942   scrollView.SetRulerX(rulerX);
943   scrollView.SetRulerY(rulerY);
944   scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
945   scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
946   scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
947
948   // Normal
949   scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
950   Wait(application);
951   Vector2 startPosition = scrollView.GetCurrentScrollPosition();
952   PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(5.0f, 1.0f), 50, true); // mostly horizontal
953   const Vector2 positionAfterNormal = scrollView.GetCurrentScrollPosition();
954
955   // Autolock
956   scrollView.SetAxisAutoLock(true);
957   DALI_TEST_CHECK(scrollView.GetAxisAutoLock());
958
959   scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
960   Wait(application);
961   PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(5.0f, 1.0f), 50, true); // mostly horizontal
962   const Vector2 positionAfterAutoLock = scrollView.GetCurrentScrollPosition();
963
964   // compare how much the Y position has deviated for normal and autolock.
965   const float devianceNormal = fabsf(startPosition.y - positionAfterNormal.y);
966   const float devianceAutoLock = fabsf(startPosition.y - positionAfterAutoLock.y);
967
968   // in auto-lock it should be a mostly horizontal pan (thus deviance should be much lower)
969   DALI_TEST_CHECK(devianceAutoLock < devianceNormal);
970
971   scrollView.SetAxisAutoLock(false);
972   DALI_TEST_CHECK(!scrollView.GetAxisAutoLock());
973   END_TEST;
974 }
975
976 int UtcDaliToolkitScrollViewAxisAutoLockGradient(void)
977 {
978   ToolkitTestApplication application;
979   tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLockGradient");
980
981   // Set up a scrollView...
982   ScrollView scrollView = ScrollView::New();
983   scrollView.SetAxisAutoLockGradient(0.5f);
984   DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 0.5f, TEST_LOCATION);
985   scrollView.SetAxisAutoLockGradient(1.0f);
986   DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 1.0f, TEST_LOCATION);
987   END_TEST;
988 }
989
990 int UtcDaliToolkitScrollViewConstraints(void)
991 {
992   ToolkitTestApplication application;
993   tet_infoline(" UtcDaliToolkitScrollViewConstraints");
994
995   // Set up a scrollView...
996   ScrollView scrollView = ScrollView::New();
997   Stage::GetCurrent().Add( scrollView );
998   Vector2 stageSize = Stage::GetCurrent().GetSize();
999   scrollView.SetSize(stageSize);
1000   scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1001   scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1002
1003   // Position rulers.
1004   RulerPtr rulerX = new DefaultRuler();
1005   RulerPtr rulerY = new DefaultRuler();
1006   rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1007   rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1008   scrollView.SetRulerX(rulerX);
1009   scrollView.SetRulerY(rulerY);
1010
1011   // Add an Actor to ScrollView,
1012   // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1013   gConstraintResult = Vector3::ZERO;
1014   Actor a = Actor::New();
1015   scrollView.Add(a);
1016   a.SetPosition( TEST_ACTOR_POSITION );
1017   Wait(application);
1018
1019   Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1020   constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
1021   constraint.SetRemoveAction(Constraint::Discard);
1022   scrollView.ApplyConstraintToChildren(constraint);
1023   Wait(application);
1024
1025   DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1026
1027   gConstraintResult = Vector3::ZERO;
1028   scrollView.RemoveConstraintsFromChildren();
1029   Wait(application);
1030
1031   DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
1032   END_TEST;
1033 }
1034
1035 int UtcDaliToolkitScrollViewBind(void)
1036 {
1037   ToolkitTestApplication application;
1038   tet_infoline(" UtcDaliToolkitScrollViewBind");
1039
1040   // Set up a scrollView...
1041   ScrollView scrollView = ScrollView::New();
1042   Stage::GetCurrent().Add( scrollView );
1043   Vector2 stageSize = Stage::GetCurrent().GetSize();
1044   scrollView.SetSize(stageSize);
1045   scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1046   scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1047
1048   // Position rulers.
1049   RulerPtr rulerX = new DefaultRuler();
1050   RulerPtr rulerY = new DefaultRuler();
1051   rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1052   rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1053   scrollView.SetRulerX(rulerX);
1054   scrollView.SetRulerY(rulerY);
1055
1056   // Add an Actor to ScrollView,
1057   // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1058
1059   gConstraintResult = Vector3::ZERO;
1060   Actor a = Actor::New();
1061   scrollView.Add(a);
1062   a.SetPosition( TEST_ACTOR_POSITION );
1063   Wait(application);
1064
1065   // apply this constraint to scrollview
1066   Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1067   constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
1068   constraint.SetRemoveAction(Constraint::Discard);
1069   scrollView.ApplyConstraintToChildren(constraint);
1070
1071   Wait(application);
1072   // Defaulty Bound.
1073   DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1074
1075   // UnBind
1076   gConstraintResult = Vector3::ZERO;
1077   scrollView.UnbindActor( a );
1078   Wait(application);
1079   DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
1080
1081   // Bind
1082   gConstraintResult = Vector3::ZERO;
1083   scrollView.BindActor( a );
1084   Wait(application);
1085   DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1086   END_TEST;
1087 }
1088
1089 int UtcDaliToolkitScrollViewOvershoot(void)
1090 {
1091   ToolkitTestApplication application;
1092   tet_infoline(" UtcDaliToolkitScrollViewOvershoot");
1093
1094   // Set up a scrollView...
1095   ScrollView scrollView = ScrollView::New();
1096   Stage::GetCurrent().Add( scrollView );
1097   Vector2 stageSize = Stage::GetCurrent().GetSize();
1098   scrollView.SetSize(stageSize);
1099   scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1100   scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1101
1102   // Position rulers.
1103   RulerPtr rulerX = new DefaultRuler();
1104   RulerPtr rulerY = new DefaultRuler();
1105   rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1106   rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1107   scrollView.SetRulerX(rulerX);
1108   scrollView.SetRulerY(rulerY);
1109   scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1110   scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1111   scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1112
1113   scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1114   Wait(application);
1115
1116   // 1. Scroll page in NW (-500,-500 pixels), then inspect overshoot. (don't release touch)
1117   Vector2 currentPos = Vector2(100.0f, 100.0f);
1118   currentPos = PerformGestureDiagonalSwipe(application, currentPos, Vector2(5.0f, 5.0f), 100, false);
1119   float overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1120   float overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1121   Vector2 positionValue = scrollView.GetProperty<Vector2>(ScrollView::Property::SCROLL_POSITION);
1122   DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1123   DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1124   DALI_TEST_EQUALS(positionValue, Vector2::ZERO, TEST_LOCATION);
1125
1126   float timeToReachOrigin;
1127
1128   // Now release touch. Overshoot should snap back to zero.
1129   SendPan(application, Gesture::Finished, currentPos);
1130   timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1131
1132   float minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1133   float maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1134
1135   DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1136                    (timeToReachOrigin < maxTimeToReachOrigin) );
1137
1138   // 2. Repeat Scroll, but this time change overshoot snap duration to shorter time
1139   scrollView.SetSnapOvershootDuration(TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION);
1140
1141   currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1142   // Now release touch. Overshoot should snap back to zero.
1143   SendPan(application, Gesture::Finished, currentPos);
1144   timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1145
1146   minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1147   maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1148
1149   DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1150                    (timeToReachOrigin < maxTimeToReachOrigin) );
1151
1152   // 3. Repeat Scroll, but this time change overshoot snap duration to longer time.
1153   scrollView.SetSnapOvershootDuration(TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION);
1154
1155   currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1156   // Now release touch. Overshoot should snap back to zero.
1157   SendPan(application, Gesture::Finished, currentPos);
1158   timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1159
1160   minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1161   maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1162
1163   DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1164                    (timeToReachOrigin < maxTimeToReachOrigin) );
1165
1166   // 4. Repeat Scroll, but this time change overshoot function.
1167   scrollView.SetSnapOvershootDuration(TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION);
1168   scrollView.SetSnapOvershootAlphaFunction(TestAlphaFunction);
1169
1170   currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1171   // Now release touch. Overshoot should snap back to zero.
1172   SendPan(application, Gesture::Finished, currentPos);
1173   timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1174
1175   minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1176   maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1177
1178   DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1179                    (timeToReachOrigin < maxTimeToReachOrigin) );
1180   END_TEST;
1181 }
1182
1183 int UtcDaliToolkitScrollViewSnapAlphaFunction(void)
1184 {
1185   ToolkitTestApplication application;
1186   tet_infoline(" UtcDaliToolkitScrollViewSnapAlphaFunction");
1187
1188   // Set up a scrollView...
1189   ScrollView scrollView = ScrollView::New();
1190   scrollView.SetScrollSnapAlphaFunction( AlphaFunction::EASE_IN );
1191   DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_IN );
1192   scrollView.SetScrollSnapAlphaFunction( AlphaFunction::EASE_OUT );
1193   DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_OUT );
1194
1195   scrollView.SetScrollFlickAlphaFunction( AlphaFunction::BOUNCE );
1196   DALI_TEST_CHECK( scrollView.GetScrollFlickAlphaFunction().GetBuiltinFunction() == AlphaFunction::BOUNCE );
1197
1198   END_TEST;
1199 }
1200
1201 int UtcDaliToolkitScrollViewSnapDuration(void)
1202 {
1203   ToolkitTestApplication application;
1204   tet_infoline(" UtcDaliToolkitScrollViewSnapDuration");
1205
1206   // Set up a scrollView...
1207   ScrollView scrollView = ScrollView::New();
1208   scrollView.SetScrollSnapDuration( 1.0f );
1209   DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 1.0f, TEST_LOCATION );
1210   scrollView.SetScrollSnapDuration( 0.5f );
1211   DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 0.5f, TEST_LOCATION );
1212
1213   scrollView.SetScrollFlickDuration( 2.0f );
1214   DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 2.0f, TEST_LOCATION );
1215   scrollView.SetScrollFlickDuration( 1.5f );
1216   DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 1.5f, TEST_LOCATION );
1217   END_TEST;
1218 }
1219
1220 int UtcDaliToolkitScrollViewSnapStartedSignalP(void)
1221 {
1222   ToolkitTestApplication application;
1223   tet_infoline(" UtcDaliToolkitScrollViewSnapStartedSignalP");
1224
1225   // Set up a scrollView...
1226   ScrollView scrollView = ScrollView::New();
1227   Stage::GetCurrent().Add( scrollView );
1228   Vector2 stageSize = Stage::GetCurrent().GetSize();
1229   scrollView.SetSize(stageSize);
1230   scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1231   scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1232
1233   // Position rulers.
1234   RulerPtr rulerX = new DefaultRuler();
1235   RulerPtr rulerY = new DefaultRuler();
1236   rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1237   rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1238   scrollView.SetRulerX(rulerX);
1239   scrollView.SetRulerY(rulerY);
1240   scrollView.SnapStartedSignal().Connect( &OnSnapStart );
1241
1242   scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1243   Wait(application);
1244
1245   // First try a snap.
1246   PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(0.5f, 0.0f), 60, true);
1247
1248   DALI_TEST_CHECK( gOnSnapStartCalled );
1249   DALI_TEST_CHECK( gLastSnapType == Toolkit::Snap );
1250
1251   // Second try a swipe.
1252   PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(20.0f, 0.0f), 60, true);
1253
1254   DALI_TEST_CHECK( gOnSnapStartCalled );
1255   DALI_TEST_CHECK( gLastSnapType == Toolkit::Flick );
1256   END_TEST;
1257 }
1258
1259 int UtcDaliToolkitScrollViewGetCurrentPageP(void)
1260 {
1261   ToolkitTestApplication application;
1262   tet_infoline(" UtcDaliToolkitScrollViewGetCurrentPageP");
1263
1264   ScrollView scrollView = ScrollView::New();
1265   Stage::GetCurrent().Add( scrollView );
1266   RulerPtr rulerX = new FixedRuler( 100.0f );
1267   rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1268   RulerPtr rulerY = new FixedRuler( 100.0f );
1269   rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1270
1271   scrollView.SetRulerX( rulerX );
1272   scrollView.SetRulerY( rulerY );
1273
1274   scrollView.ScrollTo( 15 );
1275   Wait(application, RENDER_DELAY_SCROLL);
1276   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION );
1277
1278   scrollView.ScrollTo( 3 );
1279   Wait(application, RENDER_DELAY_SCROLL);
1280   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION );
1281
1282   scrollView.ScrollTo( 9 );
1283   Wait(application, RENDER_DELAY_SCROLL);
1284   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION );
1285
1286   END_TEST;
1287 }
1288
1289 int UtcDaliToolkitScrollViewSetMaxOvershootP(void)
1290 {
1291   ToolkitTestApplication application;
1292   tet_infoline(" UtcDaliToolkitScrollViewSetMaxOvershootP");
1293
1294   // Set up a scrollView...
1295   ScrollView scrollView = ScrollView::New();
1296   Stage::GetCurrent().Add( scrollView );
1297   Vector2 stageSize = Stage::GetCurrent().GetSize();
1298   scrollView.SetSize(stageSize);
1299   scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1300   scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1301
1302   // Position rulers.
1303   RulerPtr rulerX = new DefaultRuler();
1304   RulerPtr rulerY = new DefaultRuler();
1305   rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1306   rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1307   scrollView.SetRulerX(rulerX);
1308   scrollView.SetRulerY(rulerY);
1309
1310   // Set the max overshoot to be 50 pixels in both X axis and Y axis
1311   scrollView.SetMaxOvershoot(50.0f, 50.0f);
1312
1313   scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1314   Wait(application);
1315
1316   // Scroll page in NW (-20,-20 pixels), then check that overshoot should be 0. (don't release touch)
1317   Vector2 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 20, false);
1318   float overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1319   float overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1320   DALI_TEST_EQUALS(overshootXValue, 0.0f, TEST_LOCATION);
1321   DALI_TEST_EQUALS(overshootYValue, 0.0f, TEST_LOCATION);
1322
1323   // Scroll page further in NW (-105,-105 pixels), then check that overshoot should be around 0.5. (don't release touch)
1324   currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 105, false);
1325   overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1326   overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1327   // The overshoot value is a 0.0f - 1.0f ranged value of the amount overshot related to the maximum overshoot.
1328   // EG. If we move 105, max overshoot is 50, then we overshot 50 / 105.
1329   float correctOvershootValue = 50.0f / 105.f;
1330   DALI_TEST_EQUALS( overshootXValue, correctOvershootValue, 0.001f, TEST_LOCATION );
1331   DALI_TEST_EQUALS( overshootYValue, correctOvershootValue, 0.001f, TEST_LOCATION );
1332
1333   // Scroll page further in NW (-30,-30 pixels), then check that overshoot should be now 1.0. (don't release touch)
1334   currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 30, false);
1335   overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1336   overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1337   DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1338   DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1339
1340   // Change the max overshoot to be 100 pixels in both X axis and Y axis
1341   scrollView.SetMaxOvershoot(100.0f, 100.0f);
1342   Wait(application);
1343
1344   // Check that overshoot should be now around 0.8.
1345   overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1346   overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1347   DALI_TEST_CHECK(overshootXValue > 0.79f && overshootXValue < 0.81f);
1348   DALI_TEST_CHECK(overshootYValue > 0.79f && overshootYValue < 0.81f);
1349
1350   // Scroll page further in NW (-30,-30 pixels), then check that overshoot should be now 1.0. (don't release touch)
1351   currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 30, false);
1352   overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1353   overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1354   DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1355   DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1356
1357   END_TEST;
1358 }
1359
1360 int UtcDaliToolkitScrollViewSetScrollingDirectionP(void)
1361 {
1362   ToolkitTestApplication application;
1363   tet_infoline(" UtcDaliToolkitScrollViewSetScrollingDirectionP");
1364
1365   // Set up a scrollView...
1366   ScrollView scrollView = ScrollView::New();
1367   Stage::GetCurrent().Add( scrollView );
1368   Vector2 stageSize = Stage::GetCurrent().GetSize();
1369   scrollView.SetSize(stageSize);
1370   scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1371   scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1372
1373   Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1374
1375   scrollView.ScrollTo(START_POSITION, 0.0f);
1376   Wait(application);
1377   // Try a vertical swipe.
1378   PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1379   // Take into account resampling done when prediction is off.
1380   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1381
1382   scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1383
1384   scrollView.ScrollTo(START_POSITION, 0.0f);
1385   Wait(application);
1386   // Try a vertical swipe.
1387   PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1388   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION );
1389
1390   scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1391
1392   scrollView.ScrollTo(Vector2(10.0f, 10.0f), 0.0f);
1393   Wait(application);
1394   // Try a vertical swipe.
1395   PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1396   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1397
1398   END_TEST;
1399 }
1400
1401 int UtcDaliToolkitScrollViewRemoveScrollingDirectionP(void)
1402 {
1403   ToolkitTestApplication application;
1404   tet_infoline(" UtcDaliToolkitScrollViewRemoveScrollingDirectionP");
1405
1406   // Set up a scrollView...
1407   ScrollView scrollView = ScrollView::New();
1408   Stage::GetCurrent().Add( scrollView );
1409   Vector2 stageSize = Stage::GetCurrent().GetSize();
1410   scrollView.SetSize(stageSize);
1411   scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1412   scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1413
1414   Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1415
1416   scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1417
1418   scrollView.ScrollTo(START_POSITION, 0.0f);
1419   Wait(application);
1420   // Try a vertical swipe.
1421   PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1422   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION );
1423
1424   scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1425
1426   scrollView.ScrollTo(Vector2(10.0f, 10.0f), 0.0f);
1427   Wait(application);
1428   // Try a vertical swipe.
1429   PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1430   // Take into account resampling done when prediction is off.
1431   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1432
1433   END_TEST;
1434 }
1435
1436 int UtcDaliToolkitScrollViewSetRulerXP(void)
1437 {
1438   ToolkitTestApplication application;
1439   tet_infoline(" UtcDaliToolkitScrollViewSetRulerXP");
1440
1441   ScrollView scrollView = ScrollView::New();
1442   Stage::GetCurrent().Add( scrollView );
1443   RulerPtr rulerX = new FixedRuler( 100.0f );
1444   rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1445
1446   scrollView.SetRulerX( rulerX );
1447
1448   scrollView.ScrollTo( 1, 0.0f );
1449   Wait(application);
1450   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION );
1451
1452   RulerPtr newRulerX = new FixedRuler( 200.0f );
1453   newRulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1454
1455   scrollView.SetRulerX( newRulerX );
1456
1457   scrollView.ScrollTo( 1, 0.0f );
1458   Wait(application);
1459   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 0.0f), TEST_LOCATION );
1460
1461   END_TEST;
1462 }
1463
1464 int UtcDaliToolkitScrollViewSetRulerYP(void)
1465 {
1466   ToolkitTestApplication application;
1467   tet_infoline(" UtcDaliToolkitScrollViewSetRulerYP");
1468
1469   ScrollView scrollView = ScrollView::New();
1470   Stage::GetCurrent().Add( scrollView );
1471
1472   RulerPtr rulerY = new FixedRuler( 200.0f );
1473   rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1474
1475   scrollView.SetRulerY( rulerY );
1476
1477   scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f );
1478   Wait(application);
1479   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 350.0f), TEST_LOCATION );
1480
1481   RulerPtr newRulerY = new FixedRuler( 100.0f );
1482   newRulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
1483   scrollView.SetRulerY( newRulerY );
1484
1485   scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f );
1486   Wait(application);
1487   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 200.0f), TEST_LOCATION );
1488
1489   END_TEST;
1490 }
1491
1492 int UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP(void)
1493 {
1494   ToolkitTestApplication application;
1495   tet_infoline(" UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP");
1496
1497   ScrollView scrollView = ScrollView::New();
1498   scrollView.SetMinimumSpeedForFlick(25.0f);
1499   DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 25.0f, TEST_LOCATION );
1500   scrollView.SetMinimumSpeedForFlick(60.0f);
1501   DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 60.0f, TEST_LOCATION );
1502   END_TEST;
1503 }
1504
1505 int UtcDaliToolkitScrollViewSetMinimumDistanceForFlickP(void)
1506 {
1507   ToolkitTestApplication application;
1508   tet_infoline(" UtcDaliToolkitScrollViewSetMinimumDistanceForFlick");
1509
1510   ScrollView scrollView = ScrollView::New();
1511
1512   scrollView.SetMinimumDistanceForFlick(Vector2(30.0f, 15.0f));
1513   DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(30.0f, 15.0f), TEST_LOCATION );
1514   scrollView.SetMinimumDistanceForFlick(Vector2(60.0f, 30.0f));
1515   DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(60.0f, 30.0f), TEST_LOCATION);
1516   END_TEST;
1517 }
1518
1519 int UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP(void)
1520 {
1521   ToolkitTestApplication application;
1522   tet_infoline(" UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP");
1523
1524   ScrollView scrollView = ScrollView::New();
1525   // Disable Refresh signal (TET environment cannot use adaptor's Timer)
1526   scrollView.SetWheelScrollDistanceStep(Vector2(30.0f, 15.0f));
1527   DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(30.0f, 15.0f), TEST_LOCATION );
1528   scrollView.SetWheelScrollDistanceStep(Vector2(60.0f, 30.0f));
1529   DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(60.0f, 30.0f), TEST_LOCATION);
1530   END_TEST;
1531 }
1532
1533 int UtcDaliToolkitScrollViewApplyEffectP(void)
1534 {
1535   ToolkitTestApplication application;
1536   tet_infoline(" UtcDaliToolkitScrollViewApplyEffectP");
1537
1538   // Create a ScrollView
1539   ScrollView scrollView = ScrollView::New();
1540
1541   // Create two scroll view effects
1542   Dali::Path path = Dali::Path::New();
1543   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);
1544   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);
1545
1546   // Apply both effects
1547   scrollView.ApplyEffect(effect);
1548   scrollView.ApplyEffect(newEffect);
1549
1550   DALI_TEST_CHECK( true );
1551
1552   END_TEST;
1553 }
1554
1555 int UtcDaliToolkitScrollViewApplyEffectN(void)
1556 {
1557   ToolkitTestApplication application;
1558   tet_infoline(" UtcDaliToolkitScrollViewApplyEffectN");
1559
1560   // Create a ScrollView
1561   ScrollView scrollView = ScrollView::New();
1562
1563   // Create two scroll view effects
1564   Dali::Path path = Dali::Path::New();
1565   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);
1566   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);
1567
1568   // Apply both effects
1569   scrollView.ApplyEffect(effect);
1570   scrollView.ApplyEffect(newEffect);
1571
1572   // Attempt to apply the same effect again
1573   try
1574   {
1575     scrollView.ApplyEffect(newEffect);
1576     tet_result( TET_FAIL );
1577   }
1578   catch ( DaliException& e )
1579   {
1580     DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
1581   }
1582
1583   END_TEST;
1584 }
1585
1586 int UtcDaliToolkitScrollViewRemoveEffectP(void)
1587 {
1588   ToolkitTestApplication application;
1589   tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectP");
1590
1591   // Create a ScrollView
1592   ScrollView scrollView = ScrollView::New();
1593
1594   // Create two scroll view effects
1595   Dali::Path path = Dali::Path::New();
1596   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);
1597   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);
1598
1599   // Apply both effects
1600   scrollView.ApplyEffect(effect);
1601   scrollView.ApplyEffect(newEffect);
1602
1603   // Remove both effects
1604   scrollView.RemoveEffect(effect);
1605   scrollView.RemoveEffect(newEffect);
1606
1607   DALI_TEST_CHECK( true );
1608
1609   END_TEST;
1610 }
1611
1612 int UtcDaliToolkitScrollViewRemoveEffectN(void)
1613 {
1614   ToolkitTestApplication application;
1615   tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectN");
1616
1617   // Create a ScrollView
1618   ScrollView scrollView = ScrollView::New();
1619
1620   // Create two scroll view effects
1621   Dali::Path path = Dali::Path::New();
1622   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);
1623   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);
1624
1625   // Apply the first effect
1626   scrollView.ApplyEffect(effect);
1627
1628   // Attempt to remove the second effect which has not been applied to scroll view
1629   try
1630   {
1631     scrollView.RemoveEffect(newEffect);
1632     tet_result( TET_FAIL );
1633   }
1634   catch ( DaliException& e )
1635   {
1636     DALI_TEST_ASSERT( e, "effectExistedInScrollView", TEST_LOCATION );
1637   }
1638
1639   END_TEST;
1640 }
1641
1642 int UtcDaliToolkitScrollViewRemoveAllEffectsP(void)
1643 {
1644   ToolkitTestApplication application;
1645   tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsP");
1646
1647   // Create a ScrollView
1648   ScrollView scrollView = ScrollView::New();
1649
1650   // Create two scroll view effects
1651   Dali::Path path = Dali::Path::New();
1652   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);
1653   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);
1654
1655   // Apply both effects
1656   scrollView.ApplyEffect(effect);
1657   scrollView.ApplyEffect(newEffect);
1658
1659   // Attempt to apply the same first effect again
1660   try
1661   {
1662     scrollView.ApplyEffect(effect);
1663     tet_result( TET_FAIL );
1664   }
1665   catch ( DaliException& e )
1666   {
1667     DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
1668   }
1669
1670   // Remove both effects
1671   scrollView.RemoveAllEffects();
1672
1673   // Apply both effects again
1674   scrollView.ApplyEffect(effect);
1675   scrollView.ApplyEffect(newEffect);
1676
1677   DALI_TEST_CHECK( true );
1678
1679   END_TEST;
1680 }
1681
1682 int UtcDaliToolkitScrollViewRemoveAllEffectsN(void)
1683 {
1684   ToolkitTestApplication application;
1685   tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsN");
1686
1687   // Create a ScrollView
1688   ScrollView scrollView = ScrollView::New();
1689
1690   // Remove effects when there is no effect applied previously
1691   scrollView.RemoveAllEffects();
1692
1693   DALI_TEST_CHECK( true );
1694
1695   END_TEST;
1696 }
1697
1698 int UtcDaliToolkitScrollViewSetOvershootEnabledP(void)
1699 {
1700   ToolkitTestApplication application;
1701   tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEnabledP");
1702
1703   ScrollView scrollView = ScrollView::New();
1704
1705   scrollView.SetOvershootEnabled(true);
1706   DALI_TEST_CHECK(scrollView.IsOvershootEnabled());
1707
1708   scrollView.SetOvershootEnabled(false);
1709   DALI_TEST_CHECK(!scrollView.IsOvershootEnabled());
1710
1711   END_TEST;
1712 }
1713
1714 int UtcDaliToolkitScrollViewSetOvershootEffectColorP(void)
1715 {
1716   ToolkitTestApplication application;
1717   tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEffectColorP");
1718
1719   ScrollView scrollView = ScrollView::New();
1720
1721   scrollView.SetOvershootEffectColor(Dali::Color::RED);
1722   DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::RED, TEST_LOCATION);
1723
1724   scrollView.SetOvershootEffectColor(Dali::Color::YELLOW);
1725   DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::YELLOW, TEST_LOCATION);
1726
1727   END_TEST;
1728 }
1729
1730 int UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP(void)
1731 {
1732   ToolkitTestApplication application;
1733   tet_infoline(" UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP");
1734
1735   ScrollView scrollView = ScrollView::New();
1736
1737   scrollView.SetOvershootAnimationSpeed(55.0f);
1738   DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 55.0f, TEST_LOCATION);
1739
1740   scrollView.SetOvershootAnimationSpeed(120.0f);
1741   DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 120.0f, TEST_LOCATION);
1742
1743   END_TEST;
1744 }
1745
1746 int UtcDaliToolkitScrollViewGetSet(void)
1747 {
1748   ToolkitTestApplication application;
1749   tet_infoline(" UtcDaliToolkitScrollViewGetSet");
1750   ScrollView scrollView = ScrollView::New();
1751   scrollView.SetMaxFlickSpeed(0.5f);
1752   DALI_TEST_EQUALS(scrollView.GetMaxFlickSpeed(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1753   scrollView.SetFrictionCoefficient(0.6f);
1754   DALI_TEST_EQUALS(scrollView.GetFrictionCoefficient(), 0.6f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1755   scrollView.SetFlickSpeedCoefficient(0.7f);
1756   DALI_TEST_EQUALS(scrollView.GetFlickSpeedCoefficient(), 0.7f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1757   END_TEST;
1758 }
1759
1760 int UtcDaliToolkitScrollViewRulerDomainConstructorP(void)
1761 {
1762   ToolkitTestApplication application;
1763
1764   RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
1765   DALI_TEST_EQUALS( domainX.min, 0.0f, TEST_LOCATION);
1766   DALI_TEST_EQUALS( domainX.max, 200.0f, TEST_LOCATION);
1767   DALI_TEST_EQUALS( domainX.enabled, true, TEST_LOCATION);
1768
1769   RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
1770   DALI_TEST_EQUALS( domainY.min, 100.0f, TEST_LOCATION);
1771   DALI_TEST_EQUALS( domainY.max, 500.0f, TEST_LOCATION);
1772   DALI_TEST_EQUALS( domainY.enabled, false, TEST_LOCATION);
1773
1774   END_TEST;
1775 }
1776
1777 int UtcDaliToolkitScrollViewRulerDomainGetSizeP(void)
1778 {
1779   ToolkitTestApplication application;
1780
1781   RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
1782   DALI_TEST_EQUALS( domainX.GetSize(), 200.0f, TEST_LOCATION);
1783
1784   RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
1785   DALI_TEST_EQUALS( domainY.GetSize(), 400.0f, TEST_LOCATION);
1786
1787   END_TEST;
1788 }
1789
1790 int UtcDaliToolkitScrollViewRulerDomainClampP(void)
1791 {
1792   ToolkitTestApplication application;
1793
1794   RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
1795
1796   float value = domainX.Clamp(50.0f, 100.0f, 1.0f);
1797   DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
1798
1799   value = domainX.Clamp(300.0f, 20.0f, 1.0f);
1800   DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
1801
1802   value = domainX.Clamp(300.0f, 20.0f, 0.5f);
1803   DALI_TEST_EQUALS( value, 80.0f, TEST_LOCATION);
1804
1805   value = domainX.Clamp(250.0f, 200.0f, 2.0f);
1806   DALI_TEST_EQUALS( value, 200.0f, TEST_LOCATION);
1807
1808   END_TEST;
1809 }
1810
1811 int UtcDaliToolkitScrollViewRulerDomainClampWithStateP(void)
1812 {
1813   ToolkitTestApplication application;
1814
1815   RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
1816
1817   ClampState clamped;
1818   float value = domainX.Clamp(50.0f, 100.0f, 1.0f, clamped);
1819   DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
1820   DALI_TEST_EQUALS( clamped, Dali::Toolkit::NotClamped, TEST_LOCATION);
1821
1822   value = domainX.Clamp(-100.0f, 200.0f, 1.0f, clamped);
1823   DALI_TEST_EQUALS( value, 0.0f, TEST_LOCATION);
1824   DALI_TEST_EQUALS( clamped, Dali::Toolkit::ClampedToMin, TEST_LOCATION);
1825
1826   value = domainX.Clamp(300.0f, 20.0f, 1.0f, clamped);
1827   DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
1828   DALI_TEST_EQUALS( clamped, Dali::Toolkit::ClampedToMax, TEST_LOCATION);
1829
1830   END_TEST;
1831 }
1832
1833 int UtcDaliToolkitScrollViewDefaultRulerConstructorP(void)
1834 {
1835   ToolkitTestApplication application;
1836   tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerConstructorP");
1837
1838   RulerPtr defaultRuler = new DefaultRuler();
1839   DALI_TEST_CHECK( defaultRuler );
1840
1841   END_TEST;
1842 }
1843
1844 int UtcDaliToolkitScrollViewDefaultRulerDestructorP(void)
1845 {
1846   ToolkitTestApplication application;
1847   tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerDestructorP");
1848
1849   RulerPtr defaultRuler = new DefaultRuler();
1850
1851   DALI_TEST_CHECK( true );
1852   END_TEST;
1853 }
1854
1855 int UtcDaliToolkitScrollViewFixedRulerConstructorP(void)
1856 {
1857   ToolkitTestApplication application;
1858   tet_infoline(" UtcDaliToolkitScrollViewFixedRulerConstructorP");
1859
1860   RulerPtr fixedRuler = new FixedRuler( 100.0f );
1861   DALI_TEST_CHECK( fixedRuler );
1862
1863   fixedRuler = new FixedRuler( 0.0f );
1864   DALI_TEST_CHECK( fixedRuler );
1865
1866   END_TEST;
1867 }
1868
1869 int UtcDaliToolkitScrollViewFixedRulerDestructorP(void)
1870 {
1871   ToolkitTestApplication application;
1872   tet_infoline(" UtcDaliToolkitScrollViewFixedRulerDestructorP");
1873
1874   RulerPtr fixedRuler = new FixedRuler( 100.0f );
1875
1876   DALI_TEST_CHECK( true );
1877   END_TEST;
1878 }
1879
1880 int UtcDaliToolkitScrollViewRulerGetTypeP(void)
1881 {
1882   ToolkitTestApplication application;
1883   tet_infoline(" UtcDaliToolkitScrollViewRulerGetTypeP");
1884
1885   RulerPtr defaultRuler = new DefaultRuler();
1886   DALI_TEST_CHECK( defaultRuler );
1887   DALI_TEST_EQUALS( defaultRuler->GetType(), Dali::Toolkit::Ruler::Free, TEST_LOCATION);
1888
1889   RulerPtr fixedRuler = new FixedRuler( 100.0f );
1890   DALI_TEST_CHECK( fixedRuler );
1891   DALI_TEST_EQUALS( fixedRuler->GetType(), Dali::Toolkit::Ruler::Fixed, TEST_LOCATION);
1892
1893   END_TEST;
1894 }
1895
1896 int UtcDaliToolkitScrollViewRulerGetExtensionP(void)
1897 {
1898   ToolkitTestApplication application;
1899   tet_infoline(" UtcDaliToolkitScrollViewRulerGetExtensionP");
1900
1901   RulerPtr defaultRuler = new DefaultRuler();
1902   DALI_TEST_CHECK( defaultRuler );
1903   DALI_TEST_CHECK( !defaultRuler->GetExtension() );
1904
1905   RulerPtr fixedRuler = new FixedRuler( 100.0f );
1906   DALI_TEST_CHECK( fixedRuler );
1907   DALI_TEST_CHECK( !fixedRuler->GetExtension() );
1908
1909   END_TEST;
1910 }
1911
1912 int UtcDaliToolkitScrollViewRulerEnableDisable(void)
1913 {
1914   ToolkitTestApplication application;
1915   tet_infoline(" UtcDaliToolkitScrollViewRulerEnableDisable");
1916
1917   RulerPtr ruler = new DefaultRuler();
1918
1919   DALI_TEST_CHECK( ruler->IsEnabled() );
1920   ruler->Disable();
1921   DALI_TEST_CHECK( !ruler->IsEnabled() );
1922   ruler->Enable();
1923   DALI_TEST_CHECK( ruler->IsEnabled() );
1924   END_TEST;
1925 }
1926
1927 int UtcDaliToolkitScrollViewRulerDomainEnableDisable(void)
1928 {
1929   ToolkitTestApplication application;
1930   tet_infoline(" UtcDaliToolkitScrollViewRulerDomainEnableDisable");
1931
1932   RulerPtr ruler = new DefaultRuler();
1933   DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
1934
1935   ruler->SetDomain( RulerDomain(0.0f, 100.0f, true) );
1936   DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 100.0f, TEST_LOCATION );
1937   DALI_TEST_EQUALS( ruler->Clamp(-200.0f), 0.0f, TEST_LOCATION );
1938   DALI_TEST_EQUALS( ruler->Clamp(200.0f), 100.0f, TEST_LOCATION );
1939
1940   ruler->DisableDomain();
1941   DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
1942   DALI_TEST_EQUALS( ruler->Clamp(-200.0f), -200.0f, TEST_LOCATION );
1943   DALI_TEST_EQUALS( ruler->Clamp(200.0f), 200.0f, TEST_LOCATION );
1944   END_TEST;
1945 }
1946
1947 int UtcDaliToolkitScrollViewRulerSnapAndClamp(void)
1948 {
1949   ToolkitTestApplication application;
1950   tet_infoline(" UtcDaliToolkitScrollViewRulerSnapAndClamp");
1951
1952   RulerPtr ruler = new FixedRuler( 50.0f );
1953   ruler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1954
1955   // default testing. (snap and clamp)
1956   DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f), 50.0f, TEST_LOCATION);
1957   DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f), 50.0f, TEST_LOCATION);
1958   DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f), 0.0f, TEST_LOCATION);
1959   DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f), 0.0f, TEST_LOCATION);
1960   DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f), 400.0f, TEST_LOCATION);
1961   DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f), 400.0f, TEST_LOCATION);
1962
1963   // bias testing.
1964   DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
1965   DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.5f), 50.0f, TEST_LOCATION); // No Flick
1966   DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
1967
1968   DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
1969   DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.5f), 0.0f, TEST_LOCATION); // No Flick
1970   DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
1971
1972   // length testing.
1973   DALI_TEST_EQUALS( ruler->SnapAndClamp(-10.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (over left boundary)
1974   DALI_TEST_EQUALS( ruler->SnapAndClamp(-5.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (slightly ovr left boundary)
1975   DALI_TEST_EQUALS( ruler->SnapAndClamp(300.0f, 0.5f, 10.0f), 300.0f, TEST_LOCATION); // 10 units long (not over a boundary)
1976   DALI_TEST_EQUALS( ruler->SnapAndClamp(395.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (slightly over right boundary)
1977   DALI_TEST_EQUALS( ruler->SnapAndClamp(500.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (over right boundary)
1978
1979   // scale testing.
1980   DALI_TEST_EQUALS( ruler->SnapAndClamp(-100.0f, 0.5f, 0.0f, 2.0f), 0.0f, TEST_LOCATION);
1981   DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 2.0f), 50.0f, TEST_LOCATION);
1982   DALI_TEST_EQUALS( ruler->SnapAndClamp(700.0f, 0.5f, 0.0f, 2.0f), 700.0f, TEST_LOCATION);
1983   DALI_TEST_EQUALS( ruler->SnapAndClamp(850.0f, 0.5f, 0.0f, 2.0f), 800.0f, TEST_LOCATION);
1984
1985   // clamp state testing.
1986   ClampState clamped;
1987   DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
1988   DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
1989   DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
1990   DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
1991   DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
1992   DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
1993   DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
1994   DALI_TEST_EQUALS( clamped, ClampedToMin, TEST_LOCATION );
1995   DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
1996   DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
1997   DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
1998   DALI_TEST_EQUALS( clamped, ClampedToMax, TEST_LOCATION );
1999   END_TEST;
2000 }
2001
2002 int UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP(void)
2003 {
2004   ToolkitTestApplication application;
2005   tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP");
2006
2007   RulerPtr rulerNormal = new FixedRuler( 25.0f );
2008   rulerNormal->SetDomain( RulerDomain(10.0f, 90.0f, true) );
2009
2010   unsigned int volume;
2011   float position;
2012
2013   position = rulerNormal->GetPositionFromPage(1, volume, true);
2014   DALI_TEST_EQUALS( position, 35.0f, TEST_LOCATION );
2015   DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
2016
2017   position = rulerNormal->GetPositionFromPage(2, volume, true);
2018   DALI_TEST_EQUALS( position, 60.0f, TEST_LOCATION );
2019   DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
2020
2021   // Disable the ruler
2022   rulerNormal->Disable();
2023
2024   position = rulerNormal->GetPositionFromPage(1, volume, true);
2025   DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
2026   DALI_TEST_EQUALS( volume, 1u, TEST_LOCATION );
2027
2028   position = rulerNormal->GetPositionFromPage(2, volume, true);
2029   DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
2030   DALI_TEST_EQUALS( volume, 2u, TEST_LOCATION );
2031
2032   END_TEST;
2033 }
2034
2035 int UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP(void)
2036 {
2037   ToolkitTestApplication application;
2038   tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP");
2039
2040   RulerPtr defaultRuler = new DefaultRuler();
2041   DALI_TEST_CHECK( defaultRuler );
2042   DALI_TEST_EQUALS( defaultRuler->GetTotalPages(), 1u, TEST_LOCATION);
2043
2044   END_TEST;
2045 }
2046
2047 int UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP(void)
2048 {
2049   ToolkitTestApplication application;
2050   tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP");
2051
2052   RulerPtr defaultRuler = new DefaultRuler();
2053   DALI_TEST_CHECK( defaultRuler );
2054   DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(100.0f, true), 0u, TEST_LOCATION);
2055   DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(-300.0f, false), 0u, TEST_LOCATION);
2056
2057   END_TEST;
2058 }
2059
2060 int UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP(void)
2061 {
2062   ToolkitTestApplication application;
2063   tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP");
2064
2065   RulerPtr defaultRuler = new DefaultRuler();
2066   DALI_TEST_CHECK( defaultRuler );
2067
2068   unsigned int volume;
2069   DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(0, volume, true), 0.0f, TEST_LOCATION);
2070   DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
2071
2072   DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(3, volume, false), 0.0f, TEST_LOCATION);
2073   DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
2074
2075   END_TEST;
2076 }
2077
2078 int UtcDaliToolkitScrollViewDefaultRulerSnapP(void)
2079 {
2080   ToolkitTestApplication application;
2081   tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerSnapP");
2082
2083   RulerPtr defaultRuler = new DefaultRuler();
2084   DALI_TEST_CHECK( defaultRuler );
2085
2086   DALI_TEST_EQUALS( defaultRuler->Snap(50.0f, 0.5f), 50.0f, TEST_LOCATION);
2087   DALI_TEST_EQUALS( defaultRuler->Snap(-120.0f, 1.0f), -120.0f, TEST_LOCATION);
2088
2089   END_TEST;
2090 }
2091
2092 int UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP(void)
2093 {
2094   ToolkitTestApplication application;
2095   tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP");
2096
2097   RulerPtr fixedRuler = new FixedRuler( 100.0f );
2098   fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2099
2100   fixedRuler->Enable();
2101   DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 4u, TEST_LOCATION);
2102
2103   fixedRuler->Disable();
2104   DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 1u, TEST_LOCATION);
2105
2106   END_TEST;
2107 }
2108
2109 int UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP(void)
2110 {
2111   ToolkitTestApplication application;
2112   tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP");
2113
2114   RulerPtr fixedRuler = new FixedRuler( 100.0f );
2115   fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2116
2117   fixedRuler->Enable();
2118   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 3u, TEST_LOCATION);
2119   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2120   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 1u, TEST_LOCATION);
2121   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2122
2123   fixedRuler->Disable();
2124   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2125   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
2126   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2127   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2128
2129   // Set domain size to be smaller than the ruler space
2130   fixedRuler->SetDomain( RulerDomain(0.0f, 50.0f, true) );
2131
2132   fixedRuler->Enable();
2133   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2134   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2135   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2136   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2137
2138   fixedRuler->Disable();
2139   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2140   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
2141   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2142   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2143
2144   END_TEST;
2145 }
2146
2147 int UtcDaliToolkitScrollViewFixedRulerSnapP(void)
2148 {
2149   ToolkitTestApplication application;
2150   tet_infoline(" UtcDaliToolkitScrollViewFixedRulerSnapP");
2151
2152   RulerPtr fixedRuler = new FixedRuler( 100.0f );
2153   fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2154
2155   DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.0f), -100.0f, TEST_LOCATION);
2156   DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.0f), -100.0f, TEST_LOCATION);
2157   DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.0f), -200.0f, TEST_LOCATION);
2158   DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.0f), -500.0f, TEST_LOCATION);
2159   DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.0f), 0.0f, TEST_LOCATION);
2160   DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.0f), 0.0f, TEST_LOCATION);
2161   DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.0f), 0.0f, TEST_LOCATION);
2162   DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.0f), 100.0f, TEST_LOCATION);
2163   DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.0f), 100.0f, TEST_LOCATION);
2164   DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.0f), 200.0f, TEST_LOCATION);
2165   DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.0f), 600.0f, TEST_LOCATION);
2166
2167   DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.5f), 0.0f, TEST_LOCATION);
2168   DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.5f), -100.0f, TEST_LOCATION);
2169   DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.5f), -100.0f, TEST_LOCATION);
2170   DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.5f), -500.0f, TEST_LOCATION);
2171   DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.5f), 0.0f, TEST_LOCATION);
2172   DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.5f), 100.0f, TEST_LOCATION);
2173   DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.5f), 100.0f, TEST_LOCATION);
2174   DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.5f), 100.0f, TEST_LOCATION);
2175   DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.5f), 100.0f, TEST_LOCATION);
2176   DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.5f), 300.0f, TEST_LOCATION);
2177   DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.5f), 600.0f, TEST_LOCATION);
2178
2179   DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 1.0f), 0.0f, TEST_LOCATION);
2180   DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 1.0f), 0.0f, TEST_LOCATION);
2181   DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 1.0f), -100.0f, TEST_LOCATION);
2182   DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 1.0f), -400.0f, TEST_LOCATION);
2183   DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 1.0f), 100.0f, TEST_LOCATION);
2184   DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 1.0f), 100.0f, TEST_LOCATION);
2185   DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 1.0f), 100.0f, TEST_LOCATION);
2186   DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 1.0f), 200.0f, TEST_LOCATION);
2187   DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 1.0f), 200.0f, TEST_LOCATION);
2188   DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 1.0f), 300.0f, TEST_LOCATION);
2189   DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 1.0f), 700.0f, TEST_LOCATION);
2190
2191   END_TEST;
2192 }
2193
2194 int UtcDaliToolkitScrollViewConstraintsMove(void)
2195 {
2196   ToolkitTestApplication application;
2197   tet_infoline(" UtcDaliToolkitScrollViewConstraintsMove");
2198
2199   // Set up a scrollView...
2200   ScrollView scrollView = ScrollView::New();
2201   Stage::GetCurrent().Add( scrollView );
2202   Vector2 stageSize = Stage::GetCurrent().GetSize();
2203   scrollView.SetSize(stageSize);
2204   scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
2205   scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2206
2207   // Position rulers.
2208   RulerPtr rulerX = new DefaultRuler();
2209   RulerPtr rulerY = new DefaultRuler();
2210   rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
2211   rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
2212   scrollView.SetRulerX(rulerX);
2213   scrollView.SetRulerY(rulerY);
2214
2215   // Add an Actor to ScrollView,
2216   Actor a = Actor::New();
2217   scrollView.Add(a);
2218   a.SetPosition( TEST_ACTOR_POSITION );
2219   Wait(application);
2220
2221   const Vector2 target = Vector2(100.0f, 100.0f);
2222   const Vector2 target2 = Vector2(200.0f, 200.0f);
2223
2224   Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, MoveActorConstraint );
2225   constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
2226   constraint.SetRemoveAction(Constraint::Discard);
2227   scrollView.ApplyConstraintToChildren(constraint);
2228
2229   scrollView.ScrollTo( target, 0.0f );
2230   Wait(application);
2231   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
2232   scrollView.ScrollTo( target2 );
2233   Wait(application, RENDER_DELAY_SCROLL);
2234   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
2235
2236   END_TEST;
2237 }
2238
2239 int UtcDaliToolkitScrollViewConstraintsWrap(void)
2240 {
2241   ToolkitTestApplication application;
2242   tet_infoline(" UtcDaliToolkitScrollViewConstraintsWrap");
2243
2244   // Set up a scrollView...
2245   ScrollView scrollView = ScrollView::New();
2246   Stage::GetCurrent().Add( scrollView );
2247   Vector2 stageSize = Stage::GetCurrent().GetSize();
2248   scrollView.SetSize(stageSize);
2249   scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
2250   scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2251
2252   // Position rulers.
2253   RulerPtr rulerX = new DefaultRuler();
2254   RulerPtr rulerY = new DefaultRuler();
2255   rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
2256   rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
2257   scrollView.SetRulerX(rulerX);
2258   scrollView.SetRulerY(rulerY);
2259
2260   // Add an Actor to ScrollView,
2261   Actor a = Actor::New();
2262   scrollView.Add(a);
2263   a.SetPosition( TEST_ACTOR_POSITION );
2264   Wait(application);
2265
2266   const Vector2 target = Vector2(100.0f, 100.0f);
2267   const Vector2 target2 = Vector2(200.0f, 200.0f);
2268
2269   Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, WrapActorConstraint );
2270   constraint.AddSource( LocalSource( Actor::Property::SCALE ) );
2271   constraint.AddSource( LocalSource( Actor::Property::ANCHOR_POINT ) );
2272   constraint.AddSource( LocalSource( Actor::Property::SIZE ) );
2273   constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
2274   constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
2275   constraint.AddSource( Source( scrollView, Toolkit::ScrollView::Property::WRAP ) );
2276   constraint.SetRemoveAction(Constraint::Discard);
2277   scrollView.ApplyConstraintToChildren(constraint);
2278
2279   scrollView.ScrollTo( target, 0.0f );
2280   Wait(application);
2281   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
2282   scrollView.ScrollTo( target2 );
2283   Wait(application, RENDER_DELAY_SCROLL);
2284   DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
2285
2286   END_TEST;
2287 }