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