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