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