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