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