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