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