Dali 3D User Interface Engine
utc-Dali-ScrollView.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #include <iostream>
19 #include <stdlib.h>
24 
25 using namespace Dali;
26 using namespace Toolkit;
27 
29 {
31 }
32 
34 {
36 }
37 
38 namespace
39 {
41 
42 static void TestCallback(BaseHandle handle)
43 {
44  gObjectCreatedCallBackCalled = true;
45 }
46 
47 
48 const int MILLISECONDS_PER_SECOND = 1000;
49 const int RENDER_FRAME_INTERVAL = 16;
51 const int RENDER_DELAY_SCROLL = 1000;
52 
53 // For Clamp Signal testing...
54 const float CLAMP_EXCESS_WIDTH = 200.0f;
55 const float CLAMP_EXCESS_HEIGHT = 200.0f;
59 const int CLAMP_STEP_3_SUCCESS = 3;
60 const Vector2 CLAMP_START_SCROLL_POSITION(30.0f, 100.0f);
61 const Vector2 CLAMP_TOUCH_START( 100.0f, 100.0f );
62 const Vector2 CLAMP_TOUCH_MOVEMENT( 5.0f, -5.0f );
63 const int CLAMP_GESTURE_FRAMES = 100;
64 const Vector3 TEST_ACTOR_POSITION(100.0f, 100.0f, 0.0f);
65 const Vector3 TEST_CONSTRAINT_OFFSET(1.0f, 2.0f, 0.0f);
66 const float TEST_RATIO_TOLERANCE = 0.05;
67 
68 const float DEFAULT_SNAP_OVERSHOOT_DURATION(0.5f);
69 const float DEFAULT_MAX_OVERSHOOT(100.0f);
70 
72 const Vector2 OVERSHOOT_START_SCROLL_POSITION(100.0f, 100.0f);
73 const float SCROLL_ANIMATION_DURATION(0.33f);
77 const float TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION = TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * 0.5f; // Same as above, but different alpha function.
78 const float TIME_TOLERANCE = 0.05f;
79 
80 
81 // Generate a PanGestureEvent to send to Core
82 Integration::PanGestureEvent GeneratePan(
83  Gesture::State state,
84  const Vector2& previousPosition,
85  const Vector2& currentPosition,
86  unsigned long timeDelta,
87  unsigned int numberOfTouches = 1)
88 {
89  Integration::PanGestureEvent pan(state);
90 
91  pan.previousPosition = previousPosition;
92  pan.currentPosition = currentPosition;
93  pan.timeDelta = timeDelta;
94  pan.numberOfTouches = numberOfTouches;
95 
96  return pan;
97 }
98 
106 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
107 {
108  static Vector2 last;
109 
110  if( (state == Gesture::Started) ||
111  (state == Gesture::Possible) )
112  {
113  last.x = pos.x;
114  last.y = pos.y;
115  }
116 
117  application.ProcessEvent(GeneratePan(state, last, pos, RENDER_FRAME_INTERVAL));
118 
119  last.x = pos.x;
120  last.y = pos.y;
121 }
122 
123 /*
124  * Simulate time passed by.
125  *
126  * @note this will always process at least 1 frame (1/60 sec)
127  *
128  * @param application Test application instance
129  * @param duration Time to pass in milliseconds.
130  * @return The actual time passed in milliseconds
131  */
132 int Wait(ToolkitTestApplication& application, int duration = 0)
133 {
134  int time = 0;
135 
136  for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
137  {
138  application.SendNotification();
139  application.Render(RENDER_FRAME_INTERVAL);
140  time += RENDER_FRAME_INTERVAL;
141  }
142 
143  return time;
144 }
145 
146 // Callback probes.
147 
148 static bool gOnScrollStartCalled;
151 static bool gOnSnapStartCalled;
154 
160 static void OnScrollStart( const Vector2& position )
161 {
162  gOnScrollStartCalled = true;
163 }
164 
170 static void OnScrollUpdate( const Vector2& position )
171 {
172  gOnScrollUpdateCalled = true;
173 }
174 
180 static void OnScrollComplete( const Vector2& position )
181 {
182  gOnScrollCompleteCalled = true;
183 }
184 
190 static void OnSnapStart( const ScrollView::SnapEvent& event )
191 {
192  gOnSnapStartCalled = true;
193  gLastSnapType = event.type;
194 }
195 
204 {
209  :mOffset(offset)
210  {
211  }
212 
218  void operator()( Vector3& current, const PropertyInputContainer& inputs )
219  {
220  gConstraintResult = current + Vector3(inputs[0]->GetVector2()) + mOffset;
221  current = gConstraintResult;
222  }
223 
225 
226 };
227 
233 static float TestOvershootSnapDuration(ToolkitTestApplication &application, ScrollView scrollView)
234 {
235  int timeToReachOrigin = -1;
236  for(int i = 0;i<MAX_FRAMES_TO_TEST_OVERSHOOT;i++)
237  {
238  float overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
239  float overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
240  if(overshootXValue == 0.0f && overshootYValue == 0.0f)
241  {
242  break;
243  }
244 
245  timeToReachOrigin += Wait(application);
246  }
247 
248  return static_cast<float>(timeToReachOrigin) * 0.001f; // return in seconds not ms.
249 }
250 
260 float TestAlphaFunction(float progress)
261 {
262  return std::min( progress * 2.0f, 1.0f );
263 }
264 
265 } // unnamed namespace
266 
267 
269 {
270  ToolkitTestApplication application;
271 
272  ScrollView scrollView;
273  DALI_TEST_CHECK( !scrollView );
274  END_TEST;
275 }
276 
278 {
279  ToolkitTestApplication application;
280 
281  ScrollView scrollView = ScrollView::New();
282  scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) );
283 
284  ScrollView copy( scrollView );
285  DALI_TEST_CHECK( copy );
287  END_TEST;
288 }
289 
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 );
300  END_TEST;
301 }
302 
304 {
305  ToolkitTestApplication application;
306 
307  ScrollView* scrollView = new ScrollView();
308  delete scrollView;
309 
310  DALI_TEST_CHECK( true );
311  END_TEST;
312 }
313 
315 {
316  ToolkitTestApplication application;
317  tet_infoline(" UtcDaliToolkitScrollViewNewP");
318 
319  ScrollView scrollView;
320 
321  DALI_TEST_CHECK( !scrollView );
322 
323  scrollView = ScrollView::New();
324 
325  DALI_TEST_CHECK( scrollView );
326 
327  ScrollView scrollView2(scrollView);
328 
329  DALI_TEST_CHECK( scrollView2 == scrollView );
330 
331  //Additional check to ensure object is created by checking if it's registered
333  DALI_TEST_CHECK( registry );
334 
336  registry.ObjectCreatedSignal().Connect( &TestCallback );
337  {
338  ScrollView scrollView = ScrollView::New();
339  }
341  END_TEST;
342 }
343 
345 {
346  ToolkitTestApplication application;
347  tet_infoline(" UtcDaliToolkitScrollViewDownCastP");
348 
349  ScrollView scrollView = ScrollView::New();
350  BaseHandle handle(scrollView);
351 
352  ScrollView newScrollView = ScrollView::DownCast( handle );
353  DALI_TEST_CHECK( scrollView );
354  DALI_TEST_CHECK( newScrollView == scrollView );
355  END_TEST;
356 }
357 
359 {
360  ToolkitTestApplication application;
361  tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionP");
362 
363  // Create the ScrollView actor
364  ScrollView scrollView = ScrollView::New();
365  Stage::GetCurrent().Add( scrollView );
366 
367  const Vector2 target = Vector2(100.0f, 200.0f);
368  const Vector2 target2 = Vector2(300.0f, 100.0f);
369 
370  scrollView.ScrollTo( target, 0.0f );
371  Wait(application);
373  scrollView.ScrollTo( target2 );
374  Wait(application, RENDER_DELAY_SCROLL);
375  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
376 
377  END_TEST;
378 }
379 
381 {
382  ToolkitTestApplication application;
383  tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP");
384 
385  ScrollView scrollView = ScrollView::New();
386  Stage::GetCurrent().Add( scrollView );
387  RulerPtr rulerX = new FixedRuler( 100.0f );
388  rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
389  RulerPtr rulerY = new FixedRuler( 100.0f );
390  rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
391 
392  scrollView.SetRulerX( rulerX );
393  scrollView.SetRulerY( rulerY );
394 
395  scrollView.SetWrapMode(true);
396 
397  const Vector2 target = Vector2(50.0f, 50.0f);
398  const Vector2 target2 = Vector2(150.0f, 150.0f);
399 
400  scrollView.ScrollTo( target, 0.0f );
401  Wait(application, RENDER_DELAY_SCROLL);
403 
405  Wait(application, RENDER_DELAY_SCROLL);
407 
408  scrollView.ScrollTo( target, 0.0f );
409  Wait(application, RENDER_DELAY_SCROLL);
411 
413  Wait(application, RENDER_DELAY_SCROLL);
414  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
415 
416  END_TEST;
417 }
418 
420 {
421  ToolkitTestApplication application;
422  tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionP");
423 
424  // Create the ScrollView actor
425  ScrollView scrollView = ScrollView::New();
426  Stage::GetCurrent().Add( scrollView );
427 
428  const Vector2 target = Vector2(100.0f, 200.0f);
429  const Vector2 target2 = Vector2(300.0f, 100.0f);
430 
431  scrollView.ScrollTo( target, 0.5f, TestAlphaFunction );
432  Wait(application, 250);
433  // Check that the scroll animation should finish within just half of the specified duration with the above alpha function
435 
436  scrollView.ScrollTo( target2, 0.5f, AlphaFunction::LINEAR );
437  Wait(application, 250);
438  // Check that the scroll animation has not finished within half of the specified duration with the linear alpha function
439  DALI_TEST_CHECK( scrollView.GetCurrentScrollPosition() != target2 );
440 
441  // Wait till the end of the specified duration
442  Wait(application, 250);
443  // Check that the scroll animation has finished
444  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
445 
446  END_TEST;
447 }
448 
450 {
451  ToolkitTestApplication application;
452  tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionAndDirectionBiasP");
453 
454  ScrollView scrollView = ScrollView::New();
455  Stage::GetCurrent().Add( scrollView );
456  RulerPtr rulerX = new FixedRuler( 100.0f );
457  rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
458  RulerPtr rulerY = new FixedRuler( 100.0f );
459  rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
460 
461  scrollView.SetRulerX( rulerX );
462  scrollView.SetRulerY( rulerY );
463 
464  scrollView.SetWrapMode(true);
465 
466  const Vector2 target = Vector2(50.0f, 50.0f);
467  const Vector2 target2 = Vector2(150.0f, 150.0f);
468 
469  scrollView.ScrollTo( target, 0.0f );
470  Wait(application, RENDER_DELAY_SCROLL);
472 
474  Wait(application, RENDER_DELAY_SCROLL);
476 
477  scrollView.ScrollTo( target, 0.0f );
478  Wait(application, RENDER_DELAY_SCROLL);
480 
482  Wait(application, RENDER_DELAY_SCROLL);
483  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
484 
485  scrollView.ScrollTo( target, 0.0f );
486  Wait(application, RENDER_DELAY_SCROLL);
488 
490  Wait(application, 125);
491  // Check that the scroll animation should finish within just half of the specified duration with the above alpha function
492  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
493 
494  END_TEST;
495 }
496 
498 {
499  ToolkitTestApplication application;
500  tet_infoline(" UtcDaliToolkitScrollViewScrollToPageP");
501 
502  ScrollView scrollView = ScrollView::New();
503  Stage::GetCurrent().Add( scrollView );
504  RulerPtr rulerX = new FixedRuler( 100.0f );
505  rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
506  RulerPtr rulerY = new FixedRuler( 100.0f );
507  rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
508 
509  scrollView.SetRulerX( rulerX );
510  scrollView.SetRulerY( rulerY );
511 
512  scrollView.ScrollTo( 1, 0.0f );
513  Wait(application);
514  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION );
515 
516  scrollView.ScrollTo( 5, 0.0f );
517  Wait(application);
518  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(500.0f, 0.0f), TEST_LOCATION );
519 
520  scrollView.ScrollTo( 10, 0.0f );
521  Wait(application);
522  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 100.0f), TEST_LOCATION );
523 
524  scrollView.ScrollTo( 15, 0.0f );
525  Wait(application);
526  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(700.0f, 100.0f), TEST_LOCATION );
527  DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION );
528 
529  scrollView.ScrollTo( 3 );
530  Wait(application, RENDER_DELAY_SCROLL);
531  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(300.0f, 0.0f), TEST_LOCATION );
532  DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION );
533 
534  scrollView.ScrollTo( 9 );
535  Wait(application, RENDER_DELAY_SCROLL);
536  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 100.0f), TEST_LOCATION );
537  DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION );
538 
539  // Apply DefaultRulers instead and see what happens.
540  rulerX = new DefaultRuler();
541  rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
542  rulerY = new DefaultRuler();
543  rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
544 
545  scrollView.SetRulerX( rulerX );
546  scrollView.SetRulerY( rulerY );
547 
548  // This time should always scroll to origin (0.0f, 0.0f)
549  scrollView.ScrollTo( 1, 0.0f );
550  Wait(application);
551  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
552  DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
553 
554  END_TEST;
555 }
556 
558 {
559  ToolkitTestApplication application;
560  tet_infoline(" UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP");
561 
562  ScrollView scrollView = ScrollView::New();
563  Stage::GetCurrent().Add( scrollView );
564  RulerPtr rulerX = new FixedRuler( 100.0f );
565  rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
566  RulerPtr rulerY = new FixedRuler( 100.0f );
567  rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
568 
569  scrollView.SetRulerX( rulerX );
570  scrollView.SetRulerY( rulerY );
571 
572  scrollView.SetWrapMode(true);
573 
574  scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DirectionBiasLeft );
575 
576  Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame
577  // Check that the scroll position remains the same
578  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
579 
580  Wait(application, RENDER_DELAY_SCROLL); // Wait for one second
581  // Check that it stays at the same page (i.e. the same scroll position)
582  DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
583  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
584 
585  scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DirectionBiasRight );
586 
587  Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame
588  // Check that it scrolls towards the right
589  DALI_TEST_CHECK( scrollView.GetCurrentScrollPosition().x > 0.0f );
590 
591  Wait(application, RENDER_DELAY_SCROLL); // Wait for one second
592  // Check that it scrolls back to the same page (i.e. the same scroll position)
593  DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
594  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
595 
596  END_TEST;
597 }
598 
600 {
601  ToolkitTestApplication application;
602  tet_infoline(" UtcDaliToolkitScrollViewScrollToActorP");
603 
604  ScrollView scrollView = ScrollView::New();
605  Stage::GetCurrent().Add( scrollView );
606 
607  Actor actorA = Actor::New();
608  const Vector3 positionA = Vector3(100.0f, 400.0f, 0.0f);
609  actorA.SetPosition(positionA);
610  scrollView.Add(actorA);
611 
612  Actor actorB = Actor::New();
613  const Vector3 positionB = Vector3(500.0f, 200.0f, 0.0f);
614  actorB.SetPosition(positionB);
615  scrollView.Add(actorB);
616 
617  Wait(application);
618 
619  scrollView.ScrollTo(actorA, 0.0f);
620  Wait(application);
622 
623  Wait(application);
624  scrollView.ScrollTo(actorB, 0.0f);
625  Wait(application);
627 
628  scrollView.ScrollTo(actorA);
629  Wait(application, RENDER_DELAY_SCROLL);
631 
632  scrollView.ScrollTo(actorB);
633  Wait(application, RENDER_DELAY_SCROLL);
635  END_TEST;
636 }
637 
639 {
640  ToolkitTestApplication application;
641  tet_infoline(" UtcDaliToolkitScrollViewScrollToSnapPointP");
642 
643  ScrollView scrollView = ScrollView::New();
644  Stage::GetCurrent().Add( scrollView );
645  RulerPtr rulerX = new FixedRuler( 100.0f );
646  rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
647  RulerPtr rulerY = new FixedRuler( 100.0f );
648  rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
649 
650  scrollView.SetRulerX( rulerX );
651  scrollView.SetRulerY( rulerY );
652 
653  scrollView.ScrollTo( Vector2(120.0f, 190.0f), 0.0f );
654  Wait(application);
655  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(120.0f, 190.0f), TEST_LOCATION );
656 
657  scrollView.ScrollToSnapPoint();
658 
659  Wait(application, RENDER_DELAY_SCROLL);
660  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 200.0f), TEST_LOCATION );
661  END_TEST;
662 }
663 
665 {
666  ToolkitTestApplication application;
667  tet_infoline(" UtcDaliToolkitScrollViewSetScrollUpdateDistanceP");
668 
669  ScrollView scrollView = ScrollView::New();
670 
671  scrollView.SetScrollUpdateDistance(0);
673  scrollView.SetScrollUpdateDistance(10);
675  scrollView.SetScrollUpdateDistance(1000);
677  END_TEST;
678 }
679 
681 {
682  ToolkitTestApplication application;
683  tet_infoline(" UtcDaliToolkitScrollViewSetWrapModeP");
684 
685  ScrollView scrollView = ScrollView::New();
686  Stage::GetCurrent().Add( scrollView );
687 
688  Actor actor = Actor::New();
689  scrollView.Add( actor );
690 
691  // Position rulers. 4x4 grid.
692  RulerPtr rulerX = new FixedRuler(50.0f);
693  RulerPtr rulerY = new FixedRuler(50.0f);
694  rulerX->SetDomain( RulerDomain(0.0f, 200.0f, false) );
695  rulerY->SetDomain( RulerDomain(0.0f, 200.0f, false) );
696  scrollView.SetRulerX(rulerX);
697  scrollView.SetRulerY(rulerY);
698 
699  scrollView.SetWrapMode(false);
700  scrollView.ScrollTo(Vector2(225.0f, 125.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
701  Wait(application);
702  DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 17, TEST_LOCATION );
703 
704  scrollView.SetWrapMode(true);
705  scrollView.ScrollTo(Vector2(230.0f, 130.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
706  Wait(application);
707  DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 13, TEST_LOCATION );
708  END_TEST;
709 }
710 
712 {
713  ToolkitTestApplication application;
714  tet_infoline(" UtcDaliToolkitScrollViewActorAutoSnap");
715 
716  ScrollView scrollView = ScrollView::New();
717  Stage::GetCurrent().Add( scrollView );
718 
719  // Position rulers.
720  RulerPtr rulerX = new DefaultRuler();
721  RulerPtr rulerY = new DefaultRuler();
722  rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
723  rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
724  scrollView.SetRulerX(rulerX);
725  scrollView.SetRulerY(rulerY);
726 
727  const Vector3 aPosition = Vector3(200.0f, 50.0f, 0.0f);
728  Actor a = Actor::New();
729  scrollView.Add(a);
730  a.SetPosition(aPosition);
731 
732  const Vector3 bPosition = Vector3(600.0f, 600.0f, 0.0f);
733  Actor b = Actor::New();
734  scrollView.Add(b);
735  b.SetPosition(bPosition);
736 
737  // Goto a random position, and execute snap (should not move)
738  Vector2 targetScroll = Vector2(500.0f, 500.0f);
739  scrollView.ScrollTo(targetScroll, 0.0f);
740  Wait(application);
741  scrollView.ScrollToSnapPoint();
742  Wait(application, RENDER_DELAY_SCROLL);
743  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), targetScroll, TEST_LOCATION );
744 
745  // Enable ActorAutoSnap, and now try snapping.
746  scrollView.SetActorAutoSnap(true);
747  scrollView.ScrollToSnapPoint();
748  Wait(application, RENDER_DELAY_SCROLL);
750 
751  scrollView.ScrollTo(Vector2(0.0f, 0.0f), 0.0f);
752  Wait(application);
753  scrollView.ScrollToSnapPoint();
754  Wait(application, RENDER_DELAY_SCROLL);
756  END_TEST;
757 }
758 
760 {
761  ToolkitTestApplication application;
762  tet_infoline(" UtcDaliToolkitScrollViewSignalsStartComplete");
763 
764  gOnScrollStartCalled = false;
765  gOnScrollCompleteCalled = false;
766 
767  ScrollView scrollView = ScrollView::New();
768  Stage::GetCurrent().Add( scrollView );
769 
770  // Position rulers.
771  RulerPtr rulerX = new DefaultRuler();
772  RulerPtr rulerY = new DefaultRuler();
773  rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
774  rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
775  scrollView.SetRulerX(rulerX);
776  scrollView.SetRulerY(rulerY);
777  scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
778  scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
779  scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
780  scrollView.ScrollTo( Vector2(100.0f, 100.0f) );
781  Wait(application, RENDER_DELAY_SCROLL);
782 
785  END_TEST;
786 }
787 
789 {
790  ToolkitTestApplication application;
791  tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate");
792 
793  gOnScrollStartCalled = false;
794  gOnScrollUpdateCalled = false;
795  gOnScrollCompleteCalled = false;
796 
797  ScrollView scrollView = ScrollView::New();
798  Stage::GetCurrent().Add( scrollView );
799  Vector2 stageSize = Stage::GetCurrent().GetSize();
800  scrollView.SetSize(stageSize);
803 
804  // Position rulers.
805  RulerPtr rulerX = new DefaultRuler();
806  RulerPtr rulerY = new DefaultRuler();
807  rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
808  rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
809  scrollView.SetRulerX(rulerX);
810  scrollView.SetRulerY(rulerY);
811  scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
812  scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
813  scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
814 
816  image.SetSize(stageSize);
819  scrollView.Add(image);
820 
821  Wait(application);
822 
823  // Do a pan starting from 100,100 and moving down diagonally.
824  Vector2 pos(100.0f, 100.0f);
825  SendPan(application, Gesture::Possible, pos);
826  SendPan(application, Gesture::Started, pos);
827  pos.x += 5.0f;
828  pos.y += 5.0f;
829  Wait(application, 100);
830 
831  for(int i = 0;i<20;i++)
832  {
833  SendPan(application, Gesture::Continuing, pos);
834  pos.x += 5.0f;
835  pos.y += 5.0f;
836  Wait(application);
837  }
838 
839  SendPan(application, Gesture::Finished, pos);
840  Wait(application, RENDER_DELAY_SCROLL);
841 
845  END_TEST;
846 }
847 
848 static Vector2 PerformGestureDiagonalSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, bool finish = true)
849 {
850  gOnScrollStartCalled = false;
851  gOnScrollUpdateCalled = false;
852  gOnScrollCompleteCalled = false;
853  gOnSnapStartCalled = false;
854 
855  // Now do a pan starting from (start) and heading (direction)
856  Vector2 pos(start);
857  SendPan(application, Gesture::Possible, pos);
858  SendPan(application, Gesture::Started, pos);
859  Wait(application);
860 
861  for(int i = 0;i<frames;i++)
862  {
863  pos += direction; // Move in this direction
864  SendPan(application, Gesture::Continuing, pos);
865  Wait(application);
866  }
867 
868  if(finish)
869  {
870  pos += direction; // Move in this direction.
871  SendPan(application, Gesture::Finished, pos);
872  Wait(application, RENDER_DELAY_SCROLL);
873  }
874 
875  return pos;
876 }
877 
879 {
880  ToolkitTestApplication application;
881  tet_infoline(" UtcDaliToolkitScrollViewScrollSensitive");
882 
883  // Set up a scrollView...
884  ScrollView scrollView = ScrollView::New();
885  scrollView.SetOvershootEnabled(true);
886  Stage::GetCurrent().Add( scrollView );
887  Vector2 stageSize = Stage::GetCurrent().GetSize();
888  scrollView.SetSize(stageSize);
891 
892  // Position rulers.
893  RulerPtr rulerX = new DefaultRuler();
894  RulerPtr rulerY = new DefaultRuler();
895  rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
896  rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
897  scrollView.SetRulerX(rulerX);
898  scrollView.SetRulerY(rulerY);
899  scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
900  scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
901  scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
902  scrollView.SnapStartedSignal().Connect( &OnSnapStart );
903 
904  scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
905  Wait(application);
906 
907  // First try insensitive swipe.
908  scrollView.SetScrollSensitive(false);
910 
914 
915  // Second try sensitive swipe.
916  scrollView.SetScrollSensitive(true);
918 
922  END_TEST;
923 }
924 
926 {
927  ToolkitTestApplication application;
928  tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLock");
929 
930  // Set up a scrollView...
931  ScrollView scrollView = ScrollView::New();
932  Stage::GetCurrent().Add( scrollView );
933  Vector2 stageSize = Stage::GetCurrent().GetSize();
934  scrollView.SetSize(stageSize);
937 
938  // Position rulers.
939  RulerPtr rulerX = new DefaultRuler();
940  RulerPtr rulerY = new DefaultRuler();
941  rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
942  rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
943  scrollView.SetRulerX(rulerX);
944  scrollView.SetRulerY(rulerY);
945  scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
946  scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
947  scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
948 
949  // Normal
950  scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
951  Wait(application);
952  Vector2 startPosition = scrollView.GetCurrentScrollPosition();
953  PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(5.0f, 1.0f), 50, true); // mostly horizontal
954  const Vector2 positionAfterNormal = scrollView.GetCurrentScrollPosition();
955 
956  // Autolock
957  scrollView.SetAxisAutoLock(true);
958  DALI_TEST_CHECK(scrollView.GetAxisAutoLock());
959 
960  scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
961  Wait(application);
962  PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(5.0f, 1.0f), 50, true); // mostly horizontal
963  const Vector2 positionAfterAutoLock = scrollView.GetCurrentScrollPosition();
964 
965  // compare how much the Y position has deviated for normal and autolock.
966  const float devianceNormal = fabsf(startPosition.y - positionAfterNormal.y);
967  const float devianceAutoLock = fabsf(startPosition.y - positionAfterAutoLock.y);
968 
969  // in auto-lock it should be a mostly horizontal pan (thus deviance should be much lower)
970  DALI_TEST_CHECK(devianceAutoLock < devianceNormal);
971 
972  scrollView.SetAxisAutoLock(false);
973  DALI_TEST_CHECK(!scrollView.GetAxisAutoLock());
974  END_TEST;
975 }
976 
978 {
979  ToolkitTestApplication application;
980  tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLockGradient");
981 
982  // Set up a scrollView...
983  ScrollView scrollView = ScrollView::New();
984  scrollView.SetAxisAutoLockGradient(0.5f);
986  scrollView.SetAxisAutoLockGradient(1.0f);
988  END_TEST;
989 }
990 
992 {
993  ToolkitTestApplication application;
994  tet_infoline(" UtcDaliToolkitScrollViewConstraints");
995 
996  // Set up a scrollView...
997  ScrollView scrollView = ScrollView::New();
998  Stage::GetCurrent().Add( scrollView );
999  Vector2 stageSize = Stage::GetCurrent().GetSize();
1000  scrollView.SetSize(stageSize);
1003 
1004  // Position rulers.
1005  RulerPtr rulerX = new DefaultRuler();
1006  RulerPtr rulerY = new DefaultRuler();
1007  rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1008  rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1009  scrollView.SetRulerX(rulerX);
1010  scrollView.SetRulerY(rulerY);
1011 
1012  // Add an Actor to ScrollView,
1013  // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1015  Actor a = Actor::New();
1016  scrollView.Add(a);
1018  Wait(application);
1019 
1020  Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1021  constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
1023  scrollView.ApplyConstraintToChildren(constraint);
1024  Wait(application);
1025 
1027 
1029  scrollView.RemoveConstraintsFromChildren();
1030  Wait(application);
1031 
1033  END_TEST;
1034 }
1035 
1037 {
1038  ToolkitTestApplication application;
1039  tet_infoline(" UtcDaliToolkitScrollViewBind");
1040 
1041  // Set up a scrollView...
1042  ScrollView scrollView = ScrollView::New();
1043  Stage::GetCurrent().Add( scrollView );
1044  Vector2 stageSize = Stage::GetCurrent().GetSize();
1045  scrollView.SetSize(stageSize);
1048 
1049  // Position rulers.
1050  RulerPtr rulerX = new DefaultRuler();
1051  RulerPtr rulerY = new DefaultRuler();
1052  rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1053  rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1054  scrollView.SetRulerX(rulerX);
1055  scrollView.SetRulerY(rulerY);
1056 
1057  // Add an Actor to ScrollView,
1058  // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1059 
1061  Actor a = Actor::New();
1062  scrollView.Add(a);
1064  Wait(application);
1065 
1066  // apply this constraint to scrollview
1067  Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1068  constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
1070  scrollView.ApplyConstraintToChildren(constraint);
1071 
1072  Wait(application);
1073  // Defaulty Bound.
1075 
1076  // UnBind
1078  scrollView.UnbindActor( a );
1079  Wait(application);
1081 
1082  // Bind
1084  scrollView.BindActor( a );
1085  Wait(application);
1087  END_TEST;
1088 }
1089 
1091 {
1092  ToolkitTestApplication application;
1093  tet_infoline(" UtcDaliToolkitScrollViewOvershoot");
1094 
1095  // Set up a scrollView...
1096  ScrollView scrollView = ScrollView::New();
1097  scrollView.SetOvershootEnabled(true);
1098  Stage::GetCurrent().Add( scrollView );
1099  Vector2 stageSize = Stage::GetCurrent().GetSize();
1100  scrollView.SetSize(stageSize);
1103 
1104  // Position rulers.
1105  RulerPtr rulerX = new DefaultRuler();
1106  RulerPtr rulerY = new DefaultRuler();
1107  rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1108  rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1109  scrollView.SetRulerX(rulerX);
1110  scrollView.SetRulerY(rulerY);
1111  scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1112  scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1113  scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1114 
1115  scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1116  Wait(application);
1117 
1118  // 1. Scroll page in NW (-500,-500 pixels), then inspect overshoot. (don't release touch)
1119  Vector2 currentPos = Vector2(100.0f, 100.0f);
1120  currentPos = PerformGestureDiagonalSwipe(application, currentPos, Vector2(5.0f, 5.0f), 100, false);
1121  float overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1122  float overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1124  DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1125  DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1126  DALI_TEST_EQUALS(positionValue, Vector2::ZERO, TEST_LOCATION);
1127 
1128  float timeToReachOrigin;
1129 
1130  // Now release touch. Overshoot should snap back to zero.
1131  SendPan(application, Gesture::Finished, currentPos);
1132  timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1133 
1136 
1137  DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1138  (timeToReachOrigin < maxTimeToReachOrigin) );
1139 
1140  // 2. Repeat Scroll, but this time change overshoot snap duration to shorter time
1142 
1143  currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1144  // Now release touch. Overshoot should snap back to zero.
1145  SendPan(application, Gesture::Finished, currentPos);
1146  timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1147 
1150 
1151  DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1152  (timeToReachOrigin < maxTimeToReachOrigin) );
1153 
1154  // 3. Repeat Scroll, but this time change overshoot snap duration to longer time.
1156 
1157  currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1158  // Now release touch. Overshoot should snap back to zero.
1159  SendPan(application, Gesture::Finished, currentPos);
1160  timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1161 
1164 
1165  DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1166  (timeToReachOrigin < maxTimeToReachOrigin) );
1167 
1168  // 4. Repeat Scroll, but this time change overshoot function.
1171 
1172  currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1173  // Now release touch. Overshoot should snap back to zero.
1174  SendPan(application, Gesture::Finished, currentPos);
1175  timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1176 
1179 
1180  DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1181  (timeToReachOrigin < maxTimeToReachOrigin) );
1182  END_TEST;
1183 }
1184 
1186 {
1187  ToolkitTestApplication application;
1188  tet_infoline(" UtcDaliToolkitScrollViewSnapAlphaFunction");
1189 
1190  // Set up a scrollView...
1191  ScrollView scrollView = ScrollView::New();
1196 
1199 
1200  END_TEST;
1201 }
1202 
1204 {
1205  ToolkitTestApplication application;
1206  tet_infoline(" UtcDaliToolkitScrollViewSnapDuration");
1207 
1208  // Set up a scrollView...
1209  ScrollView scrollView = ScrollView::New();
1210  scrollView.SetScrollSnapDuration( 1.0f );
1211  DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 1.0f, TEST_LOCATION );
1212  scrollView.SetScrollSnapDuration( 0.5f );
1213  DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 0.5f, TEST_LOCATION );
1214 
1215  scrollView.SetScrollFlickDuration( 2.0f );
1216  DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 2.0f, TEST_LOCATION );
1217  scrollView.SetScrollFlickDuration( 1.5f );
1218  DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 1.5f, TEST_LOCATION );
1219  END_TEST;
1220 }
1221 
1223 {
1224  ToolkitTestApplication application;
1225  tet_infoline(" UtcDaliToolkitScrollViewSnapStartedSignalP");
1226 
1227  // Set up a scrollView...
1228  ScrollView scrollView = ScrollView::New();
1229  Stage::GetCurrent().Add( scrollView );
1230  Vector2 stageSize = Stage::GetCurrent().GetSize();
1231  scrollView.SetSize(stageSize);
1234 
1235  // Position rulers.
1236  RulerPtr rulerX = new DefaultRuler();
1237  RulerPtr rulerY = new DefaultRuler();
1238  rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1239  rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1240  scrollView.SetRulerX(rulerX);
1241  scrollView.SetRulerY(rulerY);
1242  scrollView.SnapStartedSignal().Connect( &OnSnapStart );
1243 
1244  scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1245  Wait(application);
1246 
1247  // First try a snap.
1248  PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(0.5f, 0.0f), 60, true);
1249 
1252 
1253  // Second try a swipe.
1254  PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(20.0f, 0.0f), 60, true);
1255 
1258  END_TEST;
1259 }
1260 
1262 {
1263  ToolkitTestApplication application;
1264  tet_infoline(" UtcDaliToolkitScrollViewGetCurrentPageP");
1265 
1266  ScrollView scrollView = ScrollView::New();
1267  Stage::GetCurrent().Add( scrollView );
1268  RulerPtr rulerX = new FixedRuler( 100.0f );
1269  rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1270  RulerPtr rulerY = new FixedRuler( 100.0f );
1271  rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1272 
1273  scrollView.SetRulerX( rulerX );
1274  scrollView.SetRulerY( rulerY );
1275 
1276  scrollView.ScrollTo( 15 );
1277  Wait(application, RENDER_DELAY_SCROLL);
1278  DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION );
1279 
1280  scrollView.ScrollTo( 3 );
1281  Wait(application, RENDER_DELAY_SCROLL);
1282  DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION );
1283 
1284  scrollView.ScrollTo( 9 );
1285  Wait(application, RENDER_DELAY_SCROLL);
1286  DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION );
1287 
1288  END_TEST;
1289 }
1290 
1292 {
1293  ToolkitTestApplication application;
1294  tet_infoline(" UtcDaliToolkitScrollViewSetMaxOvershootP");
1295 
1296  // Set up a scrollView...
1297  ScrollView scrollView = ScrollView::New();
1298  Stage::GetCurrent().Add( scrollView );
1299  Vector2 stageSize = Stage::GetCurrent().GetSize();
1300  scrollView.SetSize(stageSize);
1303 
1304  // Position rulers.
1305  RulerPtr rulerX = new DefaultRuler();
1306  RulerPtr rulerY = new DefaultRuler();
1307  rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1308  rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1309  scrollView.SetRulerX(rulerX);
1310  scrollView.SetRulerY(rulerY);
1311 
1312  // Set the max overshoot to be 50 pixels in both X axis and Y axis
1313  scrollView.SetMaxOvershoot(50.0f, 50.0f);
1314 
1315  scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1316  Wait(application);
1317 
1318  // Scroll page in NW (-20,-20 pixels), then check that overshoot should be 0. (don't release touch)
1319  Vector2 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 20, false);
1320  float overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1321  float overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1322  DALI_TEST_EQUALS(overshootXValue, 0.0f, TEST_LOCATION);
1323  DALI_TEST_EQUALS(overshootYValue, 0.0f, TEST_LOCATION);
1324 
1325  // Scroll page further in NW (-105,-105 pixels), then check that overshoot should be around 0.5. (don't release touch)
1326  currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 105, false);
1327  overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1328  overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1329  // The overshoot value is a 0.0f - 1.0f ranged value of the amount overshot related to the maximum overshoot.
1330  // EG. If we move 105, max overshoot is 50, then we overshot 50 / 105.
1331  float correctOvershootValue = 50.0f / 105.f;
1332  DALI_TEST_EQUALS( overshootXValue, correctOvershootValue, 0.001f, TEST_LOCATION );
1333  DALI_TEST_EQUALS( overshootYValue, correctOvershootValue, 0.001f, TEST_LOCATION );
1334 
1335  // Scroll page further in NW (-30,-30 pixels), then check that overshoot should be now 1.0. (don't release touch)
1336  currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 30, false);
1337  overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1338  overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1339  DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1340  DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1341 
1342  // Change the max overshoot to be 100 pixels in both X axis and Y axis
1343  scrollView.SetMaxOvershoot(100.0f, 100.0f);
1344  Wait(application);
1345 
1346  // Check that overshoot should be now around 0.8.
1347  overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1348  overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1349  DALI_TEST_CHECK(overshootXValue > 0.79f && overshootXValue < 0.81f);
1350  DALI_TEST_CHECK(overshootYValue > 0.79f && overshootYValue < 0.81f);
1351 
1352  // Scroll page further in NW (-30,-30 pixels), then check that overshoot should be now 1.0. (don't release touch)
1353  currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 30, false);
1354  overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1355  overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1356  DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1357  DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1358 
1359  END_TEST;
1360 }
1361 
1363 {
1364  ToolkitTestApplication application;
1365  tet_infoline(" UtcDaliToolkitScrollViewSetScrollingDirectionP");
1366 
1367  // Set up a scrollView...
1368  ScrollView scrollView = ScrollView::New();
1369  Stage::GetCurrent().Add( scrollView );
1370  Vector2 stageSize = Stage::GetCurrent().GetSize();
1371  scrollView.SetSize(stageSize);
1374 
1375  Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1376 
1377  scrollView.ScrollTo(START_POSITION, 0.0f);
1378  Wait(application);
1379  // Try a vertical swipe.
1380  PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1381  // Take into account resampling done when prediction is off.
1382  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1383 
1385 
1386  scrollView.ScrollTo(START_POSITION, 0.0f);
1387  Wait(application);
1388  // Try a vertical swipe.
1389  PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1390  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION );
1391 
1393 
1394  scrollView.ScrollTo(Vector2(10.0f, 10.0f), 0.0f);
1395  Wait(application);
1396  // Try a vertical swipe.
1397  PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1398  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1399 
1400  END_TEST;
1401 }
1402 
1404 {
1405  ToolkitTestApplication application;
1406  tet_infoline(" UtcDaliToolkitScrollViewRemoveScrollingDirectionP");
1407 
1408  // Set up a scrollView...
1409  ScrollView scrollView = ScrollView::New();
1410  Stage::GetCurrent().Add( scrollView );
1411  Vector2 stageSize = Stage::GetCurrent().GetSize();
1412  scrollView.SetSize(stageSize);
1415 
1416  Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1417 
1419 
1420  scrollView.ScrollTo(START_POSITION, 0.0f);
1421  Wait(application);
1422  // Try a vertical swipe.
1423  PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1424  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION );
1425 
1427 
1428  scrollView.ScrollTo(Vector2(10.0f, 10.0f), 0.0f);
1429  Wait(application);
1430  // Try a vertical swipe.
1431  PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1432  // Take into account resampling done when prediction is off.
1433  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1434 
1435  END_TEST;
1436 }
1437 
1439 {
1440  ToolkitTestApplication application;
1441  tet_infoline(" UtcDaliToolkitScrollViewSetRulerXP");
1442 
1443  ScrollView scrollView = ScrollView::New();
1444  Stage::GetCurrent().Add( scrollView );
1445  RulerPtr rulerX = new FixedRuler( 100.0f );
1446  rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1447 
1448  scrollView.SetRulerX( rulerX );
1449 
1450  scrollView.ScrollTo( 1, 0.0f );
1451  Wait(application);
1452  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION );
1453 
1454  RulerPtr newRulerX = new FixedRuler( 200.0f );
1455  newRulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1456 
1457  scrollView.SetRulerX( newRulerX );
1458 
1459  scrollView.ScrollTo( 1, 0.0f );
1460  Wait(application);
1461  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 0.0f), TEST_LOCATION );
1462 
1463  END_TEST;
1464 }
1465 
1467 {
1468  ToolkitTestApplication application;
1469  tet_infoline(" UtcDaliToolkitScrollViewSetRulerYP");
1470 
1471  ScrollView scrollView = ScrollView::New();
1472  Stage::GetCurrent().Add( scrollView );
1473 
1474  RulerPtr rulerY = new FixedRuler( 200.0f );
1475  rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1476 
1477  scrollView.SetRulerY( rulerY );
1478 
1479  scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f );
1480  Wait(application);
1481  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 350.0f), TEST_LOCATION );
1482 
1483  RulerPtr newRulerY = new FixedRuler( 100.0f );
1484  newRulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
1485  scrollView.SetRulerY( newRulerY );
1486 
1487  scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f );
1488  Wait(application);
1489  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 200.0f), TEST_LOCATION );
1490 
1491  END_TEST;
1492 }
1493 
1495 {
1496  ToolkitTestApplication application;
1497  tet_infoline(" UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP");
1498 
1499  ScrollView scrollView = ScrollView::New();
1500  scrollView.SetMinimumSpeedForFlick(25.0f);
1501  DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 25.0f, TEST_LOCATION );
1502  scrollView.SetMinimumSpeedForFlick(60.0f);
1503  DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 60.0f, TEST_LOCATION );
1504  END_TEST;
1505 }
1506 
1508 {
1509  ToolkitTestApplication application;
1510  tet_infoline(" UtcDaliToolkitScrollViewSetMinimumDistanceForFlick");
1511 
1512  ScrollView scrollView = ScrollView::New();
1513 
1514  scrollView.SetMinimumDistanceForFlick(Vector2(30.0f, 15.0f));
1515  DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(30.0f, 15.0f), TEST_LOCATION );
1516  scrollView.SetMinimumDistanceForFlick(Vector2(60.0f, 30.0f));
1517  DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(60.0f, 30.0f), TEST_LOCATION);
1518  END_TEST;
1519 }
1520 
1522 {
1523  ToolkitTestApplication application;
1524  tet_infoline(" UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP");
1525 
1526  ScrollView scrollView = ScrollView::New();
1527  // Disable Refresh signal (TET environment cannot use adaptor's Timer)
1528  scrollView.SetWheelScrollDistanceStep(Vector2(30.0f, 15.0f));
1529  DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(30.0f, 15.0f), TEST_LOCATION );
1530  scrollView.SetWheelScrollDistanceStep(Vector2(60.0f, 30.0f));
1531  DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(60.0f, 30.0f), TEST_LOCATION);
1532  END_TEST;
1533 }
1534 
1536 {
1537  ToolkitTestApplication application;
1538  tet_infoline(" UtcDaliToolkitScrollViewApplyEffectP");
1539 
1540  // Create a ScrollView
1541  ScrollView scrollView = ScrollView::New();
1542 
1543  // Create two scroll view effects
1544  Dali::Path path = Dali::Path::New();
1545  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);
1546  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);
1547 
1548  // Apply both effects
1549  scrollView.ApplyEffect(effect);
1550  scrollView.ApplyEffect(newEffect);
1551 
1552  DALI_TEST_CHECK( true );
1553 
1554  END_TEST;
1555 }
1556 
1558 {
1559  ToolkitTestApplication application;
1560  tet_infoline(" UtcDaliToolkitScrollViewApplyEffectN");
1561 
1562  // Create a ScrollView
1563  ScrollView scrollView = ScrollView::New();
1564 
1565  // Create two scroll view effects
1566  Dali::Path path = Dali::Path::New();
1567  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);
1568  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);
1569 
1570  // Apply both effects
1571  scrollView.ApplyEffect(effect);
1572  scrollView.ApplyEffect(newEffect);
1573 
1574  // Attempt to apply the same effect again
1575  try
1576  {
1577  scrollView.ApplyEffect(newEffect);
1578  tet_result( TET_FAIL );
1579  }
1580  catch ( DaliException& e )
1581  {
1582  DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
1583  }
1584 
1585  END_TEST;
1586 }
1587 
1589 {
1590  ToolkitTestApplication application;
1591  tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectP");
1592 
1593  // Create a ScrollView
1594  ScrollView scrollView = ScrollView::New();
1595 
1596  // Create two scroll view effects
1597  Dali::Path path = Dali::Path::New();
1598  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);
1599  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);
1600 
1601  // Apply both effects
1602  scrollView.ApplyEffect(effect);
1603  scrollView.ApplyEffect(newEffect);
1604 
1605  // Remove both effects
1606  scrollView.RemoveEffect(effect);
1607  scrollView.RemoveEffect(newEffect);
1608 
1609  DALI_TEST_CHECK( true );
1610 
1611  END_TEST;
1612 }
1613 
1615 {
1616  ToolkitTestApplication application;
1617  tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectN");
1618 
1619  // Create a ScrollView
1620  ScrollView scrollView = ScrollView::New();
1621 
1622  // Create two scroll view effects
1623  Dali::Path path = Dali::Path::New();
1624  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);
1625  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);
1626 
1627  // Apply the first effect
1628  scrollView.ApplyEffect(effect);
1629 
1630  // Attempt to remove the second effect which has not been applied to scroll view
1631  try
1632  {
1633  scrollView.RemoveEffect(newEffect);
1634  tet_result( TET_FAIL );
1635  }
1636  catch ( DaliException& e )
1637  {
1638  DALI_TEST_ASSERT( e, "effectExistedInScrollView", TEST_LOCATION );
1639  }
1640 
1641  END_TEST;
1642 }
1643 
1645 {
1646  ToolkitTestApplication application;
1647  tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsP");
1648 
1649  // Create a ScrollView
1650  ScrollView scrollView = ScrollView::New();
1651 
1652  // Create two scroll view effects
1653  Dali::Path path = Dali::Path::New();
1654  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);
1655  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);
1656 
1657  // Apply both effects
1658  scrollView.ApplyEffect(effect);
1659  scrollView.ApplyEffect(newEffect);
1660 
1661  // Attempt to apply the same first effect again
1662  try
1663  {
1664  scrollView.ApplyEffect(effect);
1665  tet_result( TET_FAIL );
1666  }
1667  catch ( DaliException& e )
1668  {
1669  DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
1670  }
1671 
1672  // Remove both effects
1673  scrollView.RemoveAllEffects();
1674 
1675  // Apply both effects again
1676  scrollView.ApplyEffect(effect);
1677  scrollView.ApplyEffect(newEffect);
1678 
1679  DALI_TEST_CHECK( true );
1680 
1681  END_TEST;
1682 }
1683 
1685 {
1686  ToolkitTestApplication application;
1687  tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsN");
1688 
1689  // Create a ScrollView
1690  ScrollView scrollView = ScrollView::New();
1691 
1692  // Remove effects when there is no effect applied previously
1693  scrollView.RemoveAllEffects();
1694 
1695  DALI_TEST_CHECK( true );
1696 
1697  END_TEST;
1698 }
1699 
1701 {
1702  ToolkitTestApplication application;
1703  tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEnabledP");
1704 
1705  ScrollView scrollView = ScrollView::New();
1706 
1707  scrollView.SetOvershootEnabled(true);
1708  DALI_TEST_CHECK(scrollView.IsOvershootEnabled());
1709 
1710  scrollView.SetOvershootEnabled(false);
1711  DALI_TEST_CHECK(!scrollView.IsOvershootEnabled());
1712 
1713  END_TEST;
1714 }
1715 
1717 {
1718  ToolkitTestApplication application;
1719  tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEffectColorP");
1720 
1721  ScrollView scrollView = ScrollView::New();
1722 
1725 
1728 
1729  END_TEST;
1730 }
1731 
1733 {
1734  ToolkitTestApplication application;
1735  tet_infoline(" UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP");
1736 
1737  ScrollView scrollView = ScrollView::New();
1738 
1739  scrollView.SetOvershootAnimationSpeed(55.0f);
1741 
1742  scrollView.SetOvershootAnimationSpeed(120.0f);
1744 
1745  END_TEST;
1746 }
1747 
1749 {
1750  ToolkitTestApplication application;
1751  tet_infoline(" UtcDaliToolkitScrollViewGetSet");
1752  ScrollView scrollView = ScrollView::New();
1753  scrollView.SetMaxFlickSpeed(0.5f);
1755  scrollView.SetFrictionCoefficient(0.6f);
1757  scrollView.SetFlickSpeedCoefficient(0.7f);
1759  END_TEST;
1760 }
1761 
1763 {
1764  ToolkitTestApplication application;
1765 
1766  RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
1767  DALI_TEST_EQUALS( domainX.min, 0.0f, TEST_LOCATION);
1768  DALI_TEST_EQUALS( domainX.max, 200.0f, TEST_LOCATION);
1769  DALI_TEST_EQUALS( domainX.enabled, true, TEST_LOCATION);
1770 
1771  RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
1772  DALI_TEST_EQUALS( domainY.min, 100.0f, TEST_LOCATION);
1773  DALI_TEST_EQUALS( domainY.max, 500.0f, TEST_LOCATION);
1774  DALI_TEST_EQUALS( domainY.enabled, false, TEST_LOCATION);
1775 
1776  END_TEST;
1777 }
1778 
1780 {
1781  ToolkitTestApplication application;
1782 
1783  RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
1784  DALI_TEST_EQUALS( domainX.GetSize(), 200.0f, TEST_LOCATION);
1785 
1786  RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
1787  DALI_TEST_EQUALS( domainY.GetSize(), 400.0f, TEST_LOCATION);
1788 
1789  END_TEST;
1790 }
1791 
1793 {
1794  ToolkitTestApplication application;
1795 
1796  RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
1797 
1798  float value = domainX.Clamp(50.0f, 100.0f, 1.0f);
1799  DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
1800 
1801  value = domainX.Clamp(300.0f, 20.0f, 1.0f);
1802  DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
1803 
1804  value = domainX.Clamp(300.0f, 20.0f, 0.5f);
1805  DALI_TEST_EQUALS( value, 80.0f, TEST_LOCATION);
1806 
1807  value = domainX.Clamp(250.0f, 200.0f, 2.0f);
1808  DALI_TEST_EQUALS( value, 200.0f, TEST_LOCATION);
1809 
1810  END_TEST;
1811 }
1812 
1814 {
1815  ToolkitTestApplication application;
1816 
1817  RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
1818 
1819  ClampState clamped;
1820  float value = domainX.Clamp(50.0f, 100.0f, 1.0f, clamped);
1821  DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
1823 
1824  value = domainX.Clamp(-100.0f, 200.0f, 1.0f, clamped);
1825  DALI_TEST_EQUALS( value, 0.0f, TEST_LOCATION);
1827 
1828  value = domainX.Clamp(300.0f, 20.0f, 1.0f, clamped);
1829  DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
1831 
1832  END_TEST;
1833 }
1834 
1836 {
1837  ToolkitTestApplication application;
1838  tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerConstructorP");
1839 
1840  RulerPtr defaultRuler = new DefaultRuler();
1841  DALI_TEST_CHECK( defaultRuler );
1842 
1843  END_TEST;
1844 }
1845 
1847 {
1848  ToolkitTestApplication application;
1849  tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerDestructorP");
1850 
1851  RulerPtr defaultRuler = new DefaultRuler();
1852 
1853  DALI_TEST_CHECK( true );
1854  END_TEST;
1855 }
1856 
1858 {
1859  ToolkitTestApplication application;
1860  tet_infoline(" UtcDaliToolkitScrollViewFixedRulerConstructorP");
1861 
1862  RulerPtr fixedRuler = new FixedRuler( 100.0f );
1863  DALI_TEST_CHECK( fixedRuler );
1864 
1865  fixedRuler = new FixedRuler( 0.0f );
1866  DALI_TEST_CHECK( fixedRuler );
1867 
1868  END_TEST;
1869 }
1870 
1872 {
1873  ToolkitTestApplication application;
1874  tet_infoline(" UtcDaliToolkitScrollViewFixedRulerDestructorP");
1875 
1876  RulerPtr fixedRuler = new FixedRuler( 100.0f );
1877 
1878  DALI_TEST_CHECK( true );
1879  END_TEST;
1880 }
1881 
1883 {
1884  ToolkitTestApplication application;
1885  tet_infoline(" UtcDaliToolkitScrollViewRulerGetTypeP");
1886 
1887  RulerPtr defaultRuler = new DefaultRuler();
1888  DALI_TEST_CHECK( defaultRuler );
1890 
1891  RulerPtr fixedRuler = new FixedRuler( 100.0f );
1892  DALI_TEST_CHECK( fixedRuler );
1894 
1895  END_TEST;
1896 }
1897 
1899 {
1900  ToolkitTestApplication application;
1901  tet_infoline(" UtcDaliToolkitScrollViewRulerGetExtensionP");
1902 
1903  RulerPtr defaultRuler = new DefaultRuler();
1904  DALI_TEST_CHECK( defaultRuler );
1905  DALI_TEST_CHECK( !defaultRuler->GetExtension() );
1906 
1907  RulerPtr fixedRuler = new FixedRuler( 100.0f );
1908  DALI_TEST_CHECK( fixedRuler );
1909  DALI_TEST_CHECK( !fixedRuler->GetExtension() );
1910 
1911  END_TEST;
1912 }
1913 
1915 {
1916  ToolkitTestApplication application;
1917  tet_infoline(" UtcDaliToolkitScrollViewRulerEnableDisable");
1918 
1919  RulerPtr ruler = new DefaultRuler();
1920 
1921  DALI_TEST_CHECK( ruler->IsEnabled() );
1922  ruler->Disable();
1923  DALI_TEST_CHECK( !ruler->IsEnabled() );
1924  ruler->Enable();
1925  DALI_TEST_CHECK( ruler->IsEnabled() );
1926  END_TEST;
1927 }
1928 
1930 {
1931  ToolkitTestApplication application;
1932  tet_infoline(" UtcDaliToolkitScrollViewRulerDomainEnableDisable");
1933 
1934  RulerPtr ruler = new DefaultRuler();
1935  DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
1936 
1937  ruler->SetDomain( RulerDomain(0.0f, 100.0f, true) );
1938  DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 100.0f, TEST_LOCATION );
1939  DALI_TEST_EQUALS( ruler->Clamp(-200.0f), 0.0f, TEST_LOCATION );
1940  DALI_TEST_EQUALS( ruler->Clamp(200.0f), 100.0f, TEST_LOCATION );
1941 
1942  ruler->DisableDomain();
1943  DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
1944  DALI_TEST_EQUALS( ruler->Clamp(-200.0f), -200.0f, TEST_LOCATION );
1945  DALI_TEST_EQUALS( ruler->Clamp(200.0f), 200.0f, TEST_LOCATION );
1946  END_TEST;
1947 }
1948 
1950 {
1951  ToolkitTestApplication application;
1952  tet_infoline(" UtcDaliToolkitScrollViewRulerSnapAndClamp");
1953 
1954  RulerPtr ruler = new FixedRuler( 50.0f );
1955  ruler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1956 
1957  // default testing. (snap and clamp)
1958  DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f), 50.0f, TEST_LOCATION);
1959  DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f), 50.0f, TEST_LOCATION);
1960  DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f), 0.0f, TEST_LOCATION);
1961  DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f), 0.0f, TEST_LOCATION);
1962  DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f), 400.0f, TEST_LOCATION);
1963  DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f), 400.0f, TEST_LOCATION);
1964 
1965  // bias testing.
1966  DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
1967  DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.5f), 50.0f, TEST_LOCATION); // No Flick
1968  DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
1969 
1970  DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
1971  DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.5f), 0.0f, TEST_LOCATION); // No Flick
1972  DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
1973 
1974  // length testing.
1975  DALI_TEST_EQUALS( ruler->SnapAndClamp(-10.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (over left boundary)
1976  DALI_TEST_EQUALS( ruler->SnapAndClamp(-5.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (slightly ovr left boundary)
1977  DALI_TEST_EQUALS( ruler->SnapAndClamp(300.0f, 0.5f, 10.0f), 300.0f, TEST_LOCATION); // 10 units long (not over a boundary)
1978  DALI_TEST_EQUALS( ruler->SnapAndClamp(395.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (slightly over right boundary)
1979  DALI_TEST_EQUALS( ruler->SnapAndClamp(500.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (over right boundary)
1980 
1981  // scale testing.
1982  DALI_TEST_EQUALS( ruler->SnapAndClamp(-100.0f, 0.5f, 0.0f, 2.0f), 0.0f, TEST_LOCATION);
1983  DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 2.0f), 50.0f, TEST_LOCATION);
1984  DALI_TEST_EQUALS( ruler->SnapAndClamp(700.0f, 0.5f, 0.0f, 2.0f), 700.0f, TEST_LOCATION);
1985  DALI_TEST_EQUALS( ruler->SnapAndClamp(850.0f, 0.5f, 0.0f, 2.0f), 800.0f, TEST_LOCATION);
1986 
1987  // clamp state testing.
1988  ClampState clamped;
1989  DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
1991  DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
1993  DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
1995  DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
1997  DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
1999  DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
2001  END_TEST;
2002 }
2003 
2005 {
2006  ToolkitTestApplication application;
2007  tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP");
2008 
2009  RulerPtr rulerNormal = new FixedRuler( 25.0f );
2010  rulerNormal->SetDomain( RulerDomain(10.0f, 90.0f, true) );
2011 
2012  unsigned int volume;
2013  float position;
2014 
2015  position = rulerNormal->GetPositionFromPage(1, volume, true);
2016  DALI_TEST_EQUALS( position, 35.0f, TEST_LOCATION );
2017  DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
2018 
2019  position = rulerNormal->GetPositionFromPage(2, volume, true);
2020  DALI_TEST_EQUALS( position, 60.0f, TEST_LOCATION );
2021  DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
2022 
2023  // Disable the ruler
2024  rulerNormal->Disable();
2025 
2026  position = rulerNormal->GetPositionFromPage(1, volume, true);
2027  DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
2028  DALI_TEST_EQUALS( volume, 1u, TEST_LOCATION );
2029 
2030  position = rulerNormal->GetPositionFromPage(2, volume, true);
2031  DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
2032  DALI_TEST_EQUALS( volume, 2u, TEST_LOCATION );
2033 
2034  END_TEST;
2035 }
2036 
2038 {
2039  ToolkitTestApplication application;
2040  tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP");
2041 
2042  RulerPtr defaultRuler = new DefaultRuler();
2043  DALI_TEST_CHECK( defaultRuler );
2044  DALI_TEST_EQUALS( defaultRuler->GetTotalPages(), 1u, TEST_LOCATION);
2045 
2046  END_TEST;
2047 }
2048 
2050 {
2051  ToolkitTestApplication application;
2052  tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP");
2053 
2054  RulerPtr defaultRuler = new DefaultRuler();
2055  DALI_TEST_CHECK( defaultRuler );
2056  DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(100.0f, true), 0u, TEST_LOCATION);
2057  DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(-300.0f, false), 0u, TEST_LOCATION);
2058 
2059  END_TEST;
2060 }
2061 
2063 {
2064  ToolkitTestApplication application;
2065  tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP");
2066 
2067  RulerPtr defaultRuler = new DefaultRuler();
2068  DALI_TEST_CHECK( defaultRuler );
2069 
2070  unsigned int volume;
2071  DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(0, volume, true), 0.0f, TEST_LOCATION);
2072  DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
2073 
2074  DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(3, volume, false), 0.0f, TEST_LOCATION);
2075  DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
2076 
2077  END_TEST;
2078 }
2079 
2081 {
2082  ToolkitTestApplication application;
2083  tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerSnapP");
2084 
2085  RulerPtr defaultRuler = new DefaultRuler();
2086  DALI_TEST_CHECK( defaultRuler );
2087 
2088  DALI_TEST_EQUALS( defaultRuler->Snap(50.0f, 0.5f), 50.0f, TEST_LOCATION);
2089  DALI_TEST_EQUALS( defaultRuler->Snap(-120.0f, 1.0f), -120.0f, TEST_LOCATION);
2090 
2091  END_TEST;
2092 }
2093 
2095 {
2096  ToolkitTestApplication application;
2097  tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP");
2098 
2099  RulerPtr fixedRuler = new FixedRuler( 100.0f );
2100  fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2101 
2102  fixedRuler->Enable();
2103  DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 4u, TEST_LOCATION);
2104 
2105  fixedRuler->Disable();
2106  DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 1u, TEST_LOCATION);
2107 
2108  END_TEST;
2109 }
2110 
2112 {
2113  ToolkitTestApplication application;
2114  tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP");
2115 
2116  RulerPtr fixedRuler = new FixedRuler( 100.0f );
2117  fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2118 
2119  fixedRuler->Enable();
2120  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 3u, TEST_LOCATION);
2121  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2122  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 1u, TEST_LOCATION);
2123  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2124 
2125  fixedRuler->Disable();
2126  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2127  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
2128  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2129  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2130 
2131  // Set domain size to be smaller than the ruler space
2132  fixedRuler->SetDomain( RulerDomain(0.0f, 50.0f, true) );
2133 
2134  fixedRuler->Enable();
2135  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2136  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2137  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2138  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2139 
2140  fixedRuler->Disable();
2141  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2142  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
2143  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2144  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2145 
2146  END_TEST;
2147 }
2148 
2150 {
2151  ToolkitTestApplication application;
2152  tet_infoline(" UtcDaliToolkitScrollViewFixedRulerSnapP");
2153 
2154  RulerPtr fixedRuler = new FixedRuler( 100.0f );
2155  fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2156 
2157  DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.0f), -100.0f, TEST_LOCATION);
2158  DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.0f), -100.0f, TEST_LOCATION);
2159  DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.0f), -200.0f, TEST_LOCATION);
2160  DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.0f), -500.0f, TEST_LOCATION);
2161  DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.0f), 0.0f, TEST_LOCATION);
2162  DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.0f), 0.0f, TEST_LOCATION);
2163  DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.0f), 0.0f, TEST_LOCATION);
2164  DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.0f), 100.0f, TEST_LOCATION);
2165  DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.0f), 100.0f, TEST_LOCATION);
2166  DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.0f), 200.0f, TEST_LOCATION);
2167  DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.0f), 600.0f, TEST_LOCATION);
2168 
2169  DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.5f), 0.0f, TEST_LOCATION);
2170  DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.5f), -100.0f, TEST_LOCATION);
2171  DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.5f), -100.0f, TEST_LOCATION);
2172  DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.5f), -500.0f, TEST_LOCATION);
2173  DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.5f), 0.0f, TEST_LOCATION);
2174  DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.5f), 100.0f, TEST_LOCATION);
2175  DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.5f), 100.0f, TEST_LOCATION);
2176  DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.5f), 100.0f, TEST_LOCATION);
2177  DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.5f), 100.0f, TEST_LOCATION);
2178  DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.5f), 300.0f, TEST_LOCATION);
2179  DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.5f), 600.0f, TEST_LOCATION);
2180 
2181  DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 1.0f), 0.0f, TEST_LOCATION);
2182  DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 1.0f), 0.0f, TEST_LOCATION);
2183  DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 1.0f), -100.0f, TEST_LOCATION);
2184  DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 1.0f), -400.0f, TEST_LOCATION);
2185  DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 1.0f), 100.0f, TEST_LOCATION);
2186  DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 1.0f), 100.0f, TEST_LOCATION);
2187  DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 1.0f), 100.0f, TEST_LOCATION);
2188  DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 1.0f), 200.0f, TEST_LOCATION);
2189  DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 1.0f), 200.0f, TEST_LOCATION);
2190  DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 1.0f), 300.0f, TEST_LOCATION);
2191  DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 1.0f), 700.0f, TEST_LOCATION);
2192 
2193  END_TEST;
2194 }
2195 
2197 {
2198  ToolkitTestApplication application;
2199  tet_infoline(" UtcDaliToolkitScrollViewConstraintsMove");
2200 
2201  // Set up a scrollView...
2202  ScrollView scrollView = ScrollView::New();
2203  Stage::GetCurrent().Add( scrollView );
2204  Vector2 stageSize = Stage::GetCurrent().GetSize();
2205  scrollView.SetSize(stageSize);
2208 
2209  // Position rulers.
2210  RulerPtr rulerX = new DefaultRuler();
2211  RulerPtr rulerY = new DefaultRuler();
2212  rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
2213  rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
2214  scrollView.SetRulerX(rulerX);
2215  scrollView.SetRulerY(rulerY);
2216 
2217  // Add an Actor to ScrollView,
2218  Actor a = Actor::New();
2219  scrollView.Add(a);
2221  Wait(application);
2222 
2223  const Vector2 target = Vector2(100.0f, 100.0f);
2224  const Vector2 target2 = Vector2(200.0f, 200.0f);
2225 
2226  Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, MoveActorConstraint );
2227  constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
2229  scrollView.ApplyConstraintToChildren(constraint);
2230 
2231  scrollView.ScrollTo( target, 0.0f );
2232  Wait(application);
2233  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
2234  scrollView.ScrollTo( target2 );
2235  Wait(application, RENDER_DELAY_SCROLL);
2236  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
2237 
2238  END_TEST;
2239 }
2240 
2242 {
2243  ToolkitTestApplication application;
2244  tet_infoline(" UtcDaliToolkitScrollViewConstraintsWrap");
2245 
2246  // Set up a scrollView...
2247  ScrollView scrollView = ScrollView::New();
2248  Stage::GetCurrent().Add( scrollView );
2249  Vector2 stageSize = Stage::GetCurrent().GetSize();
2250  scrollView.SetSize(stageSize);
2253 
2254  // Position rulers.
2255  RulerPtr rulerX = new DefaultRuler();
2256  RulerPtr rulerY = new DefaultRuler();
2257  rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
2258  rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
2259  scrollView.SetRulerX(rulerX);
2260  scrollView.SetRulerY(rulerY);
2261 
2262  // Add an Actor to ScrollView,
2263  Actor a = Actor::New();
2264  scrollView.Add(a);
2266  Wait(application);
2267 
2268  const Vector2 target = Vector2(100.0f, 100.0f);
2269  const Vector2 target2 = Vector2(200.0f, 200.0f);
2270 
2271  Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, WrapActorConstraint );
2272  constraint.AddSource( LocalSource( Actor::Property::SCALE ) );
2274  constraint.AddSource( LocalSource( Actor::Property::SIZE ) );
2277  constraint.AddSource( Source( scrollView, Toolkit::ScrollView::Property::WRAP ) );
2279  scrollView.ApplyConstraintToChildren(constraint);
2280 
2281  scrollView.ScrollTo( target, 0.0f );
2282  Wait(application);
2283  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
2284  scrollView.ScrollTo( target2 );
2285  Wait(application, RENDER_DELAY_SCROLL);
2286  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
2287 
2288  END_TEST;
2289 }
2290 
2291 // Non-API test (so no P or N variant).
2293 {
2294  ToolkitTestApplication application;
2295  tet_infoline( " UtcDaliToolkitScrollViewGesturePageLimit" );
2296 
2297  // Set up a scrollView.
2298  ScrollView scrollView = ScrollView::New();
2299 
2300  // Do not rely on stage size for UTC tests.
2301  Vector2 pageSize( 720.0f, 1280.0f );
2303  scrollView.SetSize( pageSize );
2304  scrollView.SetParentOrigin( ParentOrigin::CENTER );
2305  scrollView.SetAnchorPoint( AnchorPoint::CENTER );
2306  scrollView.SetPosition( 0.0f, 0.0f, 0.0f );
2307 
2308  // Position rulers.
2309  // We set the X ruler to fixed to give us pages to snap to.
2310  Dali::Toolkit::FixedRuler* rulerX = new Dali::Toolkit::FixedRuler( pageSize.width );
2311  // Note: The 3x page width is arbitary, but we need enough to show that we are
2312  // capping page movement by the page limiter, and not the domain.
2313  rulerX->SetDomain( Dali::Toolkit::RulerDomain( 0.0f, pageSize.width * 3.0f, false ) );
2315  rulerY->Disable();
2316  scrollView.SetRulerX( rulerX );
2317  scrollView.SetRulerY( rulerY );
2318 
2319  scrollView.SetWrapMode( false );
2320  scrollView.SetScrollSensitive( true );
2321 
2322  Stage::GetCurrent().Add( scrollView );
2323 
2324  // Set up a gesture to perform.
2325  Vector2 startPos( 50.0f, 0.0f );
2326  Vector2 direction( -5.0f, 0.0f );
2327  int frames = 200;
2328 
2329  // Force starting position.
2330  scrollView.ScrollTo( startPos, 0.0f );
2331  Wait( application );
2332 
2333  // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
2334  Vector2 currentPos( PerformGestureDiagonalSwipe( application, startPos, direction, frames - 1, false ) );
2335 
2336  // Confirm the final X coord has not moved more than one page from the start X position.
2337  DALI_TEST_GREATER( ( startPos.x + pageSize.width ), scrollView.GetCurrentScrollPosition().x, TEST_LOCATION );
2338 
2339  // Finish the gesture and wait for the snap.
2340  currentPos += direction;
2341  SendPan( application, Gesture::Finished, currentPos );
2342  // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
2344 
2345  // Confirm the final X coord has snapped to exactly one page ahead of the start page.
2347 
2348  END_TEST;
2349 }
2350 
2352 {
2353  ToolkitTestApplication application;
2354 
2355  // Create the ScrollView actor
2356  ScrollView scrollView = ScrollView::New();
2357  DALI_TEST_CHECK(scrollView);
2358 
2359  // Event side properties
2360 
2361  // Test "wrapEnabled" property
2363  scrollView.SetProperty( ScrollView::Property::WRAP_ENABLED, true );
2365 
2366  // Test "panningEnabled" property
2367  DALI_TEST_CHECK( scrollView.GetPropertyIndex("panningEnabled") == ScrollView::Property::PANNING_ENABLED );
2370 
2371  // Test "axisAutoLockEnabled" property
2372  DALI_TEST_CHECK( scrollView.GetPropertyIndex("axisAutoLockEnabled") == ScrollView::Property::AXIS_AUTO_LOCK_ENABLED );
2375 
2376  // Test "wheelScrollDistanceStep" property
2377  DALI_TEST_CHECK( scrollView.GetPropertyIndex("wheelScrollDistanceStep") == ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP );
2380 
2381  // Test "overshootEnabled" property
2382  DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootEnabled") == Scrollable::Property::OVERSHOOT_ENABLED );
2386 
2387  // Animatable properties
2388 
2389  // Test "scrollPosition" property
2390  DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPosition") == ScrollView::Property::SCROLL_POSITION );
2391  scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(320.0f, 550.0f) );
2392  Wait(application);
2394 
2395  // Test "scrollPrePosition", "scrollPrePositionX" and "scrollPrePositionY" properties
2396  DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePosition") == ScrollView::Property::SCROLL_PRE_POSITION );
2397  scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION, Vector2(300.0f, 500.0f) );
2398  Wait(application);
2400 
2401  DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionX") == ScrollView::Property::SCROLL_PRE_POSITION_X );
2402  DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionY") == ScrollView::Property::SCROLL_PRE_POSITION_Y );
2407  Wait(application);
2411 
2412  // Test "scrollPrePositionMax", "scrollPrePositionMaxX" and "scrollPrePositionMaxY" properties
2413  DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMax") == ScrollView::Property::SCROLL_PRE_POSITION_MAX );
2414  scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX, Vector2(100.0f, 200.0f) );
2415  Wait(application);
2417 
2418  DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMaxX") == ScrollView::Property::SCROLL_PRE_POSITION_MAX_X );
2419  DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMaxY") == ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y );
2424  Wait(application);
2428 
2429  // Test "overshootX" property
2431  scrollView.SetProperty( ScrollView::Property::OVERSHOOT_X, 0.8f );
2432  Wait(application);
2434 
2435  // Test "overshootY" property
2437  scrollView.SetProperty( ScrollView::Property::OVERSHOOT_Y, 0.8f );
2438  Wait(application);
2440 
2441  // Test "scrollFinal", "scrollFinalX" and "scrollFinalY" properties
2443  scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL, Vector2(200.0f, 300.0f) );
2444  Wait(application);
2446 
2451  scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL_X, 500.0f );
2452  scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL_Y, 600.0f );
2453  Wait(application);
2457 
2458  // Test "wrap" property
2460  scrollView.SetProperty( ScrollView::Property::WRAP, false );
2461  Wait(application);
2462  DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WRAP).Get<bool>(), false, TEST_LOCATION );
2463 
2464  // Test "panning" property
2466  scrollView.SetProperty( ScrollView::Property::PANNING, true );
2467  Wait(application);
2468  DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::PANNING).Get<bool>(), true, TEST_LOCATION );
2469 
2470  // Test "scrolling" property
2472  scrollView.SetProperty( ScrollView::Property::SCROLLING, false );
2473  Wait(application);
2475 
2476  // Test "scrollDomainSize", "scrollDomainSizeX" and "scrollDomainSizeY" properties
2477  DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSize") == ScrollView::Property::SCROLL_DOMAIN_SIZE );
2478  scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE, Vector2(1200.0f, 1300.0f) );
2479  Wait(application);
2481 
2482  DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSizeX") == ScrollView::Property::SCROLL_DOMAIN_SIZE_X );
2483  DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSizeY") == ScrollView::Property::SCROLL_DOMAIN_SIZE_Y );
2488  Wait(application);
2492 
2493  // Test "scrollDomainOffset" property
2494  DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainOffset") == ScrollView::Property::SCROLL_DOMAIN_OFFSET );
2495  scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_OFFSET, Vector2(500.0f, 200.0f) );
2496  Wait(application);
2498 
2499  // Test "scrollPositionDelta" property
2500  DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPositionDelta") == ScrollView::Property::SCROLL_POSITION_DELTA );
2502  Wait(application);
2504 
2505  // Test "startPagePosition" property
2506  DALI_TEST_CHECK( scrollView.GetPropertyIndex("startPagePosition") == ScrollView::Property::START_PAGE_POSITION );
2507  scrollView.SetProperty( ScrollView::Property::START_PAGE_POSITION, Vector3(50.0f, 100.0f, 20.0f) );
2508  Wait(application);
2510 
2511  END_TEST;
2512 }
Dali Docs Home
Read more about Dali