2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <dali/devel-api/object/handle-devel.h>
22 #include <dali-toolkit/dali-toolkit.h>
23 #include <dali/integration-api/events/touch-event-integ.h>
24 #include <dali/integration-api/events/pan-gesture-event.h>
27 using namespace Toolkit;
29 void scroll_view_startup(void)
31 test_return_value = TET_UNDEF;
34 void scroll_view_cleanup(void)
36 test_return_value = TET_PASS;
41 static bool gObjectCreatedCallBackCalled;
43 static void TestCallback(BaseHandle handle)
45 gObjectCreatedCallBackCalled = true;
48 struct CallbackFunctor
50 CallbackFunctor(bool* callbackFlag)
51 : mCallbackFlag( callbackFlag )
57 *mCallbackFlag = true;
62 const int MILLISECONDS_PER_SECOND = 1000;
63 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
64 const int RENDER_ANIMATION_TEST_DURATION_MS = 1000; ///< 1000ms to test animation
66 const int RENDER_DELAY_SCROLL = 1000; ///< duration to wait for any scroll to complete.
68 // For Clamp Signal testing...
69 const float CLAMP_EXCESS_WIDTH = 200.0f; ///< Amount of width that can be panned outside scrollview
70 const float CLAMP_EXCESS_HEIGHT = 200.0f; ///< Amount of height that can be panned outside scrollview
71 const int CLAMP_STEP_0_CHECK_NOTCLAMPED = 0; ///< FSM: "First check that scrollview isn't clamped"
72 const int CLAMP_STEP_1_CHECK_CLAMPED_WEST = 1; ///< FSM: "Next check that scrollview clamps against left side"
73 const int CLAMP_STEP_2_CHECK_CLAMPED_SOUTH_WEST = 2; ///< FSM: "Then check that scrollview clamps against bottom-left side"
74 const int CLAMP_STEP_3_SUCCESS = 3; ///< FSM: "Finished (Success)"
75 const Vector2 CLAMP_START_SCROLL_POSITION(30.0f, 100.0f); ///< Scroll start position for the Clamping tests.
76 const Vector2 CLAMP_TOUCH_START( 100.0f, 100.0f ); ///< Start point to touch from for the Clamping tests.
77 const Vector2 CLAMP_TOUCH_MOVEMENT( 5.0f, -5.0f ); ///< Amount to move touch for each frame for the Clamping tests.
78 const int CLAMP_GESTURE_FRAMES = 100; ///< Number of Frames to synthesize a gesture for the Clamping tests.
79 const Vector3 TEST_ACTOR_POSITION(100.0f, 100.0f, 0.0f); ///< A Test actor position offset (arbitrary value)
80 const Vector3 TEST_CONSTRAINT_OFFSET(1.0f, 2.0f, 0.0f); ///< A Test constraint offset (arbitrary value to test effects)
81 const float TEST_RATIO_TOLERANCE = 0.05; ///< +/-5% tolerance for ratio comparisons.
83 const float DEFAULT_SNAP_OVERSHOOT_DURATION(0.5f); ///< Default overshoot snapping animation time.
84 const float DEFAULT_MAX_OVERSHOOT(100.0f); ///< Default maximum allowed overshoot in pixels
86 const int MAX_FRAMES_TO_TEST_OVERSHOOT = 600; ///< 10 seconds (at 60 frames per second).
87 const Vector2 OVERSHOOT_START_SCROLL_POSITION(100.0f, 100.0f); ///< Scroll start position for the Overshoot tests.
88 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)
89 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).
90 const float TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION = 0.05f; ///< a Test duration
91 const float TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION = 1.5f; ///< another Test duration
92 const float TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION = TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * 0.5f; // Same as above, but different alpha function.
93 const float TIME_TOLERANCE = 0.05f; ///< Allow testing tolerance between a 10th of second (+/- 3 frames)
96 // Generate a PanGestureEvent to send to Core
97 Integration::PanGestureEvent GeneratePan(
99 const Vector2& previousPosition,
100 const Vector2& currentPosition,
101 unsigned long timeDelta,
102 unsigned int numberOfTouches = 1)
104 Integration::PanGestureEvent pan(state);
106 pan.previousPosition = previousPosition;
107 pan.currentPosition = currentPosition;
108 pan.timeDelta = timeDelta;
109 pan.numberOfTouches = numberOfTouches;
115 * Helper to generate PanGestureEvent
117 * @param[in] application Application instance
118 * @param[in] state The Gesture State
119 * @param[in] pos The current position of touch.
121 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
125 if( (state == Gesture::Started) ||
126 (state == Gesture::Possible) )
132 application.ProcessEvent(GeneratePan(state, last, pos, RENDER_FRAME_INTERVAL));
139 * Simulate time passed by.
141 * @note this will always process at least 1 frame (1/60 sec)
143 * @param application Test application instance
144 * @param duration Time to pass in milliseconds.
145 * @return The actual time passed in milliseconds
147 int Wait(ToolkitTestApplication& application, int duration = 0)
151 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
153 application.SendNotification();
154 application.Render(RENDER_FRAME_INTERVAL);
155 time += RENDER_FRAME_INTERVAL;
163 static bool gOnScrollStartCalled; ///< Whether the OnScrollStart signal was invoked.
164 static bool gOnScrollUpdateCalled; ///< Whether the OnScrollUpdate signal was invoked.
165 static bool gOnScrollCompleteCalled; ///< Whether the OnScrollComplete signal was invoked.
166 static bool gOnSnapStartCalled; ///< Whether the OnSnapStart signal was invoked.
167 static SnapType gLastSnapType; ///< Snaping information from SnapEvent.
168 static Vector3 gConstraintResult; ///< Result from constraint.
171 * Invoked when scrolling starts.
173 * @param[in] position The current scroll position.
175 static void OnScrollStart( const Vector2& position )
177 gOnScrollStartCalled = true;
181 * Invoked when scrolling updates (via dragging)
183 * @param[in] position The current scroll position.
185 static void OnScrollUpdate( const Vector2& position )
187 gOnScrollUpdateCalled = true;
191 * Invoked when scrolling finishes
193 * @param[in] position The current scroll position.
195 static void OnScrollComplete( const Vector2& position )
197 gOnScrollCompleteCalled = true;
201 * Invoked when a snap or flick started.
203 * @param[in] event The type of snap and the target position/scale/rotation.
205 static void OnSnapStart( const ScrollView::SnapEvent& event )
207 gOnSnapStartCalled = true;
208 gLastSnapType = event.type;
214 * Summation of current value, property, and offset.
216 * current' = current + mOffset + property;
218 struct TestSumConstraint
221 * @param[in] offset The offset to be added to current.
223 TestSumConstraint(const Vector3& offset)
229 * @param[in] current The current base value
230 * @param[in] inputs Contains the property to be added to current.
231 * @return The new current Vector.
233 void operator()( Vector3& current, const PropertyInputContainer& inputs )
235 gConstraintResult = current + Vector3(inputs[0]->GetVector2()) + mOffset;
236 current = gConstraintResult;
244 * @param[in] application The application instance
245 * @param[in] scrollView The scrollView instance
246 * @return The time taken for the overshoot to reach origin (zero)
248 static float TestOvershootSnapDuration(ToolkitTestApplication &application, ScrollView scrollView)
250 int timeToReachOrigin = -1;
251 for(int i = 0;i<MAX_FRAMES_TO_TEST_OVERSHOOT;i++)
253 float overshootXValue = DevelHandle::GetCurrentProperty<float>( scrollView, ScrollView::Property::OVERSHOOT_X );
254 float overshootYValue = DevelHandle::GetCurrentProperty<float>( scrollView, ScrollView::Property::OVERSHOOT_Y );
255 if(overshootXValue == 0.0f && overshootYValue == 0.0f)
260 timeToReachOrigin += Wait(application);
263 return static_cast<float>(timeToReachOrigin) * 0.001f; // return in seconds not ms.
267 * y = 2x alpha function, which is clamped between 0.0f - 1.0f
269 * Animations should appear to finish (reach 100% point)
270 * at just half the time of a regular Linear AlphaFunction.
272 * @param[in] progress value (ranges from 0.0f - 1.0f)
273 * @return interpolation value (ranges from 0.0f - 1.0f)
275 float TestAlphaFunction(float progress)
277 return std::min( progress * 2.0f, 1.0f );
280 } // unnamed namespace
283 int UtcDaliToolkitScrollViewConstructorP(void)
285 ToolkitTestApplication application;
287 ScrollView scrollView;
288 DALI_TEST_CHECK( !scrollView );
292 int UtcDaliToolkitScrollViewCopyConstructorP(void)
294 ToolkitTestApplication application;
296 ScrollView scrollView = ScrollView::New();
297 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) );
299 ScrollView copy( scrollView );
300 DALI_TEST_CHECK( copy );
301 DALI_TEST_CHECK( copy.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) == scrollView.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) );
305 int UtcDaliToolkitScrollViewAssignmentOperatorP(void)
307 ToolkitTestApplication application;
309 ScrollView scrollView = ScrollView::New();
310 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) );
312 ScrollView copy = scrollView;
313 DALI_TEST_CHECK( copy );
314 DALI_TEST_CHECK( copy.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) == scrollView.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) );
318 int UtcDaliScrollViewDestructorP(void)
320 ToolkitTestApplication application;
322 ScrollView* scrollView = new ScrollView();
325 DALI_TEST_CHECK( true );
329 int UtcDaliToolkitScrollViewNewP1(void)
331 ToolkitTestApplication application;
332 tet_infoline(" UtcDaliToolkitScrollViewNewP1");
334 ScrollView scrollView;
336 DALI_TEST_CHECK( !scrollView );
338 scrollView = ScrollView::New();
340 DALI_TEST_CHECK( scrollView );
342 ScrollView scrollView2(scrollView);
344 DALI_TEST_CHECK( scrollView2 == scrollView );
346 //Additional check to ensure object is created by checking if it's registered
347 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
348 DALI_TEST_CHECK( registry );
350 gObjectCreatedCallBackCalled = false;
351 registry.ObjectCreatedSignal().Connect( &TestCallback );
353 ScrollView scrollView = ScrollView::New();
355 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
359 int UtcDaliToolkitScrollViewNewP2(void)
361 ToolkitTestApplication application;
362 tet_infoline(" UtcDaliToolkitScrollViewNewP2 - create thru type registry");
364 ScrollView scrollView;
365 DALI_TEST_CHECK( !scrollView );
367 TypeRegistry typeRegistry = TypeRegistry::Get();
368 TypeInfo scrollViewType = typeRegistry.GetTypeInfo("ScrollView");
369 BaseHandle handle = scrollViewType.CreateInstance();
370 DALI_TEST_CHECK( handle );
372 scrollView = ScrollView::DownCast(handle);
373 DALI_TEST_CHECK( scrollView );
378 int UtcDaliToolkitScrollViewDownCastP(void)
380 ToolkitTestApplication application;
381 tet_infoline(" UtcDaliToolkitScrollViewDownCastP");
383 ScrollView scrollView = ScrollView::New();
384 BaseHandle handle(scrollView);
386 ScrollView newScrollView = ScrollView::DownCast( handle );
387 DALI_TEST_CHECK( scrollView );
388 DALI_TEST_CHECK( newScrollView == scrollView );
392 int UtcDaliToolkitScrollViewScrollToPositionP(void)
394 ToolkitTestApplication application;
395 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionP");
397 // Create the ScrollView actor
398 ScrollView scrollView = ScrollView::New();
399 Stage::GetCurrent().Add( scrollView );
401 const Vector2 target = Vector2(100.0f, 200.0f);
402 const Vector2 target2 = Vector2(300.0f, 100.0f);
404 scrollView.ScrollTo( target, 0.0f );
406 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
407 scrollView.ScrollTo( target2 );
408 Wait(application, RENDER_DELAY_SCROLL);
409 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
414 int UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP(void)
416 ToolkitTestApplication application;
417 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP");
419 ScrollView scrollView = ScrollView::New();
420 Stage::GetCurrent().Add( scrollView );
421 RulerPtr rulerX = new FixedRuler( 100.0f );
422 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
423 RulerPtr rulerY = new FixedRuler( 100.0f );
424 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
426 scrollView.SetRulerX( rulerX );
427 scrollView.SetRulerY( rulerY );
429 scrollView.SetWrapMode(true);
431 Property::Value wrapMode = scrollView.GetProperty( Toolkit::ScrollView::Property::WRAP_ENABLED );
432 DALI_TEST_EQUALS( wrapMode.Get<bool>(), true, TEST_LOCATION );
434 const Vector2 target = Vector2(50.0f, 50.0f);
435 const Vector2 target2 = Vector2(150.0f, 150.0f);
437 scrollView.ScrollTo( target, 0.0f );
438 Wait(application, RENDER_DELAY_SCROLL);
439 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
441 scrollView.ScrollTo( target2, 0.25f, Dali::Toolkit::DirectionBiasLeft, Dali::Toolkit::DirectionBiasLeft );
442 Wait(application, RENDER_DELAY_SCROLL);
443 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
445 scrollView.ScrollTo( target, 0.0f );
446 Wait(application, RENDER_DELAY_SCROLL);
447 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
449 scrollView.ScrollTo( target2, 0.25f, Dali::Toolkit::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
450 Wait(application, RENDER_DELAY_SCROLL);
451 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
456 int UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionP(void)
458 ToolkitTestApplication application;
459 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionP");
461 // Create the ScrollView actor
462 ScrollView scrollView = ScrollView::New();
463 Stage::GetCurrent().Add( scrollView );
465 const Vector2 target = Vector2(100.0f, 200.0f);
466 const Vector2 target2 = Vector2(300.0f, 100.0f);
468 scrollView.ScrollTo( target, 0.5f, TestAlphaFunction );
469 Wait(application, 250);
470 // Check that the scroll animation should finish within just half of the specified duration with the above alpha function
471 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
473 scrollView.ScrollTo( target2, 0.5f, AlphaFunction::LINEAR );
474 Wait(application, 250);
475 // Check that the scroll animation has not finished within half of the specified duration with the linear alpha function
476 DALI_TEST_CHECK( scrollView.GetCurrentScrollPosition() != target2 );
478 // Wait till the end of the specified duration
479 Wait(application, 250);
480 // Check that the scroll animation has finished
481 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
486 int UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionAndDirectionBiasP(void)
488 ToolkitTestApplication application;
489 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionAndDirectionBiasP");
491 ScrollView scrollView = ScrollView::New();
492 Stage::GetCurrent().Add( scrollView );
493 RulerPtr rulerX = new FixedRuler( 100.0f );
494 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
495 RulerPtr rulerY = new FixedRuler( 100.0f );
496 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
498 scrollView.SetRulerX( rulerX );
499 scrollView.SetRulerY( rulerY );
501 scrollView.SetWrapMode(true);
503 const Vector2 target = Vector2(50.0f, 50.0f);
504 const Vector2 target2 = Vector2(150.0f, 150.0f);
506 scrollView.ScrollTo( target, 0.0f );
507 Wait(application, RENDER_DELAY_SCROLL);
508 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
510 scrollView.ScrollTo( target2, 0.25f, AlphaFunction::LINEAR, Dali::Toolkit::DirectionBiasLeft, Dali::Toolkit::DirectionBiasLeft );
511 Wait(application, RENDER_DELAY_SCROLL);
512 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
514 scrollView.ScrollTo( target, 0.0f );
515 Wait(application, RENDER_DELAY_SCROLL);
516 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
518 scrollView.ScrollTo( target2, 0.25f, AlphaFunction::LINEAR, Dali::Toolkit::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
519 Wait(application, RENDER_DELAY_SCROLL);
520 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
522 scrollView.ScrollTo( target, 0.0f );
523 Wait(application, RENDER_DELAY_SCROLL);
524 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
526 scrollView.ScrollTo( target2, 0.25f, TestAlphaFunction, Dali::Toolkit::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
527 Wait(application, 125);
528 // Check that the scroll animation should finish within just half of the specified duration with the above alpha function
529 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
534 int UtcDaliToolkitScrollViewScrollToPageP(void)
536 ToolkitTestApplication application;
537 tet_infoline(" UtcDaliToolkitScrollViewScrollToPageP");
539 ScrollView scrollView = ScrollView::New();
540 Stage::GetCurrent().Add( scrollView );
541 RulerPtr rulerX = new FixedRuler( 100.0f );
542 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
543 RulerPtr rulerY = new FixedRuler( 100.0f );
544 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
546 scrollView.SetRulerX( rulerX );
547 scrollView.SetRulerY( rulerY );
549 scrollView.ScrollTo( 1, 0.0f );
551 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION );
553 scrollView.ScrollTo( 5, 0.0f );
555 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(500.0f, 0.0f), TEST_LOCATION );
557 scrollView.ScrollTo( 10, 0.0f );
559 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 100.0f), TEST_LOCATION );
561 scrollView.ScrollTo( 15, 0.0f );
563 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(700.0f, 100.0f), TEST_LOCATION );
564 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION );
566 scrollView.ScrollTo( 3 );
567 Wait(application, RENDER_DELAY_SCROLL);
568 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(300.0f, 0.0f), TEST_LOCATION );
569 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION );
571 scrollView.ScrollTo( 9 );
572 Wait(application, RENDER_DELAY_SCROLL);
573 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 100.0f), TEST_LOCATION );
574 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION );
576 // Apply DefaultRulers instead and see what happens.
577 rulerX = new DefaultRuler();
578 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
579 rulerY = new DefaultRuler();
580 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
582 scrollView.SetRulerX( rulerX );
583 scrollView.SetRulerY( rulerY );
585 // This time should always scroll to origin (0.0f, 0.0f)
586 scrollView.ScrollTo( 1, 0.0f );
588 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
589 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
594 int UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP(void)
596 ToolkitTestApplication application;
597 tet_infoline(" UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP");
599 ScrollView scrollView = ScrollView::New();
600 Stage::GetCurrent().Add( scrollView );
601 RulerPtr rulerX = new FixedRuler( 100.0f );
602 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
603 RulerPtr rulerY = new FixedRuler( 100.0f );
604 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
606 scrollView.SetRulerX( rulerX );
607 scrollView.SetRulerY( rulerY );
609 scrollView.SetWrapMode(true);
611 scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DirectionBiasLeft );
613 Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame
614 // Check that the scroll position remains the same
615 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
617 Wait(application, RENDER_DELAY_SCROLL); // Wait for one second
618 // Check that it stays at the same page (i.e. the same scroll position)
619 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
620 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
622 scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DirectionBiasRight );
624 Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame
625 // Check that it scrolls towards the right
626 DALI_TEST_CHECK( scrollView.GetCurrentScrollPosition().x > 0.0f );
628 Wait(application, RENDER_DELAY_SCROLL); // Wait for one second
629 // Check that it scrolls back to the same page (i.e. the same scroll position)
630 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
631 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
636 int UtcDaliToolkitScrollViewScrollToActorP(void)
638 ToolkitTestApplication application;
639 tet_infoline(" UtcDaliToolkitScrollViewScrollToActorP");
641 ScrollView scrollView = ScrollView::New();
642 Stage::GetCurrent().Add( scrollView );
644 Actor actorA = Actor::New();
645 const Vector3 positionA = Vector3(100.0f, 400.0f, 0.0f);
646 actorA.SetPosition(positionA);
647 scrollView.Add(actorA);
649 Actor actorB = Actor::New();
650 const Vector3 positionB = Vector3(500.0f, 200.0f, 0.0f);
651 actorB.SetPosition(positionB);
652 scrollView.Add(actorB);
656 scrollView.ScrollTo(actorA, 0.0f);
658 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION );
661 scrollView.ScrollTo(actorB, 0.0f);
663 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION );
665 scrollView.ScrollTo(actorA);
666 Wait(application, RENDER_DELAY_SCROLL);
667 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION );
669 scrollView.ScrollTo(actorB);
670 Wait(application, RENDER_DELAY_SCROLL);
671 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION );
675 int UtcDaliToolkitScrollViewScrollToSnapPointP(void)
677 ToolkitTestApplication application;
678 tet_infoline(" UtcDaliToolkitScrollViewScrollToSnapPointP");
680 ScrollView scrollView = ScrollView::New();
681 Stage::GetCurrent().Add( scrollView );
682 RulerPtr rulerX = new FixedRuler( 100.0f );
683 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
684 RulerPtr rulerY = new FixedRuler( 100.0f );
685 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
687 scrollView.SetRulerX( rulerX );
688 scrollView.SetRulerY( rulerY );
690 scrollView.ScrollTo( Vector2(120.0f, 190.0f), 0.0f );
692 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(120.0f, 190.0f), TEST_LOCATION );
694 scrollView.ScrollToSnapPoint();
696 Wait(application, RENDER_DELAY_SCROLL);
697 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 200.0f), TEST_LOCATION );
701 int UtcDaliToolkitScrollViewSetScrollUpdateDistanceP(void)
703 ToolkitTestApplication application;
704 tet_infoline(" UtcDaliToolkitScrollViewSetScrollUpdateDistanceP");
706 ScrollView scrollView = ScrollView::New();
708 scrollView.SetScrollUpdateDistance(0);
709 DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 0, TEST_LOCATION);
710 scrollView.SetScrollUpdateDistance(10);
711 DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 10, TEST_LOCATION);
712 scrollView.SetScrollUpdateDistance(1000);
713 DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 1000, TEST_LOCATION);
717 int UtcDaliToolkitScrollViewSetWrapModeP(void)
719 ToolkitTestApplication application;
720 tet_infoline(" UtcDaliToolkitScrollViewSetWrapModeP");
722 ScrollView scrollView = ScrollView::New();
723 Stage::GetCurrent().Add( scrollView );
725 Actor actor = Actor::New();
726 scrollView.Add( actor );
728 // Position rulers. 4x4 grid.
729 RulerPtr rulerX = new FixedRuler(50.0f);
730 RulerPtr rulerY = new FixedRuler(50.0f);
731 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, false) );
732 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, false) );
733 scrollView.SetRulerX(rulerX);
734 scrollView.SetRulerY(rulerY);
736 scrollView.SetWrapMode(false);
737 scrollView.ScrollTo(Vector2(225.0f, 125.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
739 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 17, TEST_LOCATION );
741 scrollView.SetWrapMode(true);
742 scrollView.ScrollTo(Vector2(230.0f, 130.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
744 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 13, TEST_LOCATION );
748 int UtcDaliToolkitScrollViewActorAutoSnap(void)
750 ToolkitTestApplication application;
751 tet_infoline(" UtcDaliToolkitScrollViewActorAutoSnap");
753 ScrollView scrollView = ScrollView::New();
754 Stage::GetCurrent().Add( scrollView );
757 RulerPtr rulerX = new DefaultRuler();
758 RulerPtr rulerY = new DefaultRuler();
759 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
760 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
761 scrollView.SetRulerX(rulerX);
762 scrollView.SetRulerY(rulerY);
764 const Vector3 aPosition = Vector3(200.0f, 50.0f, 0.0f);
765 Actor a = Actor::New();
767 a.SetPosition(aPosition);
769 const Vector3 bPosition = Vector3(600.0f, 600.0f, 0.0f);
770 Actor b = Actor::New();
772 b.SetPosition(bPosition);
774 // Goto a random position, and execute snap (should not move)
775 Vector2 targetScroll = Vector2(500.0f, 500.0f);
776 scrollView.ScrollTo(targetScroll, 0.0f);
778 scrollView.ScrollToSnapPoint();
779 Wait(application, RENDER_DELAY_SCROLL);
780 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), targetScroll, TEST_LOCATION );
782 // Enable ActorAutoSnap, and now try snapping.
783 scrollView.SetActorAutoSnap(true);
784 scrollView.ScrollToSnapPoint();
785 Wait(application, RENDER_DELAY_SCROLL);
786 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), bPosition.GetVectorXY(), TEST_LOCATION );
788 scrollView.ScrollTo(Vector2(0.0f, 0.0f), 0.0f);
790 scrollView.ScrollToSnapPoint();
791 Wait(application, RENDER_DELAY_SCROLL);
792 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), aPosition.GetVectorXY(), TEST_LOCATION );
796 int UtcDaliToolkitScrollViewSignalsStartComplete(void)
798 ToolkitTestApplication application;
799 tet_infoline(" UtcDaliToolkitScrollViewSignalsStartComplete");
801 gOnScrollStartCalled = false;
802 gOnScrollCompleteCalled = false;
804 ScrollView scrollView = ScrollView::New();
805 Stage::GetCurrent().Add( scrollView );
808 RulerPtr rulerX = new DefaultRuler();
809 RulerPtr rulerY = new DefaultRuler();
810 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
811 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
812 scrollView.SetRulerX(rulerX);
813 scrollView.SetRulerY(rulerY);
814 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
815 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
816 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
817 scrollView.ScrollTo( Vector2(100.0f, 100.0f) );
818 Wait(application, RENDER_DELAY_SCROLL);
820 DALI_TEST_CHECK(gOnScrollStartCalled);
821 DALI_TEST_CHECK(gOnScrollCompleteCalled);
825 int UtcDaliToolkitScrollViewSignalsUpdate01(void)
827 ToolkitTestApplication application;
828 tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate");
830 gOnScrollStartCalled = false;
831 gOnScrollUpdateCalled = false;
832 gOnScrollCompleteCalled = false;
834 ScrollView scrollView = ScrollView::New();
835 Stage::GetCurrent().Add( scrollView );
836 Vector2 stageSize = Stage::GetCurrent().GetSize();
837 scrollView.SetSize(stageSize);
838 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
839 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
842 RulerPtr rulerX = new DefaultRuler();
843 RulerPtr rulerY = new DefaultRuler();
844 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
845 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
846 scrollView.SetRulerX(rulerX);
847 scrollView.SetRulerY(rulerY);
848 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
849 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
850 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
852 Actor image = Actor::New();
853 image.SetSize(stageSize);
854 image.SetParentOrigin(ParentOrigin::TOP_LEFT);
855 image.SetAnchorPoint(AnchorPoint::TOP_LEFT);
856 scrollView.Add(image);
860 // Do a pan starting from 100,100 and moving down diagonally.
861 Vector2 pos(100.0f, 100.0f);
862 SendPan(application, Gesture::Possible, pos);
863 SendPan(application, Gesture::Started, pos);
866 Wait(application, 100);
868 for(int i = 0;i<20;i++)
870 SendPan(application, Gesture::Continuing, pos);
876 SendPan(application, Gesture::Finished, pos);
877 Wait(application, RENDER_DELAY_SCROLL);
879 DALI_TEST_CHECK(gOnScrollStartCalled);
880 DALI_TEST_CHECK(gOnScrollUpdateCalled);
881 DALI_TEST_CHECK(gOnScrollCompleteCalled);
885 int UtcDaliToolkitScrollViewSignalsUpdate02(void)
887 ToolkitTestApplication application;
888 tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate");
890 gOnScrollStartCalled = false;
891 gOnScrollUpdateCalled = false;
892 gOnScrollCompleteCalled = false;
894 ScrollView scrollView = ScrollView::New();
895 Stage::GetCurrent().Add( scrollView );
896 Vector2 stageSize = Stage::GetCurrent().GetSize();
897 scrollView.SetSize(stageSize);
898 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
899 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
902 RulerPtr rulerX = new DefaultRuler();
903 RulerPtr rulerY = new DefaultRuler();
904 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
905 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
906 scrollView.SetRulerX(rulerX);
907 scrollView.SetRulerY(rulerY);
908 Dali::ConnectionTracker tracker;
909 bool scrollStarted=false;
910 bool scrollUpdated=false;
911 bool scrollCompleted=false;
912 DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollStarted", CallbackFunctor(&scrollStarted) ));
913 DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollUpdated", CallbackFunctor(&scrollUpdated) ));
914 DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollCompleted", CallbackFunctor(&scrollCompleted) ));
916 Actor image = Actor::New();
917 image.SetSize(stageSize);
918 image.SetParentOrigin(ParentOrigin::TOP_LEFT);
919 image.SetAnchorPoint(AnchorPoint::TOP_LEFT);
920 scrollView.Add(image);
924 // Do a pan starting from 100,100 and moving down diagonally.
925 Vector2 pos(100.0f, 100.0f);
926 SendPan(application, Gesture::Possible, pos);
927 SendPan(application, Gesture::Started, pos);
930 Wait(application, 100);
932 for(int i = 0;i<20;i++)
934 SendPan(application, Gesture::Continuing, pos);
940 SendPan(application, Gesture::Finished, pos);
941 Wait(application, RENDER_DELAY_SCROLL);
943 DALI_TEST_CHECK(scrollStarted);
944 DALI_TEST_CHECK(scrollUpdated);
945 DALI_TEST_CHECK(scrollCompleted);
947 Stage::GetCurrent().Remove( scrollView );
952 static Vector2 PerformGestureDiagonalSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, bool finish = true)
954 gOnScrollStartCalled = false;
955 gOnScrollUpdateCalled = false;
956 gOnScrollCompleteCalled = false;
957 gOnSnapStartCalled = false;
959 // Now do a pan starting from (start) and heading (direction)
961 SendPan(application, Gesture::Possible, pos);
962 SendPan(application, Gesture::Started, pos);
965 for(int i = 0;i<frames;i++)
967 pos += direction; // Move in this direction
968 SendPan(application, Gesture::Continuing, pos);
974 pos += direction; // Move in this direction.
975 SendPan(application, Gesture::Finished, pos);
976 Wait(application, RENDER_DELAY_SCROLL);
982 int UtcDaliToolkitScrollViewScrollSensitive(void)
984 ToolkitTestApplication application;
985 tet_infoline(" UtcDaliToolkitScrollViewScrollSensitive");
987 // Set up a scrollView...
988 ScrollView scrollView = ScrollView::New();
989 scrollView.SetOvershootEnabled(true);
990 Stage::GetCurrent().Add( scrollView );
991 Vector2 stageSize = Stage::GetCurrent().GetSize();
992 scrollView.SetSize(stageSize);
993 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
994 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
997 RulerPtr rulerX = new DefaultRuler();
998 RulerPtr rulerY = new DefaultRuler();
999 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1000 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1001 scrollView.SetRulerX(rulerX);
1002 scrollView.SetRulerY(rulerY);
1003 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1004 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1005 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1006 scrollView.SnapStartedSignal().Connect( &OnSnapStart );
1008 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1011 // First try insensitive swipe.
1012 scrollView.SetScrollSensitive(false);
1013 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, true);
1015 DALI_TEST_CHECK( !gOnScrollStartCalled );
1016 DALI_TEST_CHECK( !gOnScrollCompleteCalled );
1017 DALI_TEST_CHECK( !gOnSnapStartCalled );
1019 // Second try sensitive swipe.
1020 scrollView.SetScrollSensitive(true);
1021 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, true);
1023 DALI_TEST_CHECK( gOnScrollStartCalled );
1024 DALI_TEST_CHECK( gOnScrollCompleteCalled );
1025 DALI_TEST_CHECK( gOnSnapStartCalled );
1029 int UtcDaliToolkitScrollViewAxisAutoLock(void)
1031 ToolkitTestApplication application;
1032 tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLock");
1034 // Set up a scrollView...
1035 ScrollView scrollView = ScrollView::New();
1036 Stage::GetCurrent().Add( scrollView );
1037 Vector2 stageSize = Stage::GetCurrent().GetSize();
1038 scrollView.SetSize(stageSize);
1039 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1040 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1043 RulerPtr rulerX = new DefaultRuler();
1044 RulerPtr rulerY = new DefaultRuler();
1045 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1046 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1047 scrollView.SetRulerX(rulerX);
1048 scrollView.SetRulerY(rulerY);
1049 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1050 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1051 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1054 scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
1056 Vector2 startPosition = scrollView.GetCurrentScrollPosition();
1057 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(5.0f, 1.0f), 50, true); // mostly horizontal
1058 const Vector2 positionAfterNormal = scrollView.GetCurrentScrollPosition();
1061 scrollView.SetAxisAutoLock(true);
1062 DALI_TEST_CHECK(scrollView.GetAxisAutoLock());
1064 scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
1066 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(5.0f, 1.0f), 50, true); // mostly horizontal
1067 const Vector2 positionAfterAutoLock = scrollView.GetCurrentScrollPosition();
1069 // compare how much the Y position has deviated for normal and autolock.
1070 const float devianceNormal = fabsf(startPosition.y - positionAfterNormal.y);
1071 const float devianceAutoLock = fabsf(startPosition.y - positionAfterAutoLock.y);
1073 // in auto-lock it should be a mostly horizontal pan (thus deviance should be much lower)
1074 DALI_TEST_CHECK(devianceAutoLock < devianceNormal);
1076 scrollView.SetAxisAutoLock(false);
1077 DALI_TEST_CHECK(!scrollView.GetAxisAutoLock());
1081 int UtcDaliToolkitScrollViewAxisAutoLockGradient(void)
1083 ToolkitTestApplication application;
1084 tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLockGradient");
1086 // Set up a scrollView...
1087 ScrollView scrollView = ScrollView::New();
1088 scrollView.SetAxisAutoLockGradient(0.5f);
1089 DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 0.5f, TEST_LOCATION);
1090 scrollView.SetAxisAutoLockGradient(1.0f);
1091 DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 1.0f, TEST_LOCATION);
1095 int UtcDaliToolkitScrollViewConstraints(void)
1097 ToolkitTestApplication application;
1098 tet_infoline(" UtcDaliToolkitScrollViewConstraints");
1100 // Set up a scrollView...
1101 ScrollView scrollView = ScrollView::New();
1102 Stage::GetCurrent().Add( scrollView );
1103 Vector2 stageSize = Stage::GetCurrent().GetSize();
1104 scrollView.SetSize(stageSize);
1105 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1106 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1109 RulerPtr rulerX = new DefaultRuler();
1110 RulerPtr rulerY = new DefaultRuler();
1111 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1112 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1113 scrollView.SetRulerX(rulerX);
1114 scrollView.SetRulerY(rulerY);
1116 // Add an Actor to ScrollView,
1117 // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1118 gConstraintResult = Vector3::ZERO;
1119 Actor a = Actor::New();
1121 a.SetPosition( TEST_ACTOR_POSITION );
1124 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1125 constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
1126 constraint.SetRemoveAction(Constraint::Discard);
1127 scrollView.ApplyConstraintToChildren(constraint);
1130 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1132 gConstraintResult = Vector3::ZERO;
1133 scrollView.RemoveConstraintsFromChildren();
1136 DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
1140 int UtcDaliToolkitScrollViewBind(void)
1142 ToolkitTestApplication application;
1143 tet_infoline(" UtcDaliToolkitScrollViewBind");
1145 // Set up a scrollView...
1146 ScrollView scrollView = ScrollView::New();
1147 Stage::GetCurrent().Add( scrollView );
1148 Vector2 stageSize = Stage::GetCurrent().GetSize();
1149 scrollView.SetSize(stageSize);
1150 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1151 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1154 RulerPtr rulerX = new DefaultRuler();
1155 RulerPtr rulerY = new DefaultRuler();
1156 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1157 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1158 scrollView.SetRulerX(rulerX);
1159 scrollView.SetRulerY(rulerY);
1161 // Add an Actor to ScrollView,
1162 // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1164 gConstraintResult = Vector3::ZERO;
1165 Actor a = Actor::New();
1167 a.SetPosition( TEST_ACTOR_POSITION );
1170 // apply this constraint to scrollview
1171 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1172 constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
1173 constraint.SetRemoveAction(Constraint::Discard);
1174 scrollView.ApplyConstraintToChildren(constraint);
1178 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1181 gConstraintResult = Vector3::ZERO;
1182 scrollView.UnbindActor( a );
1184 DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
1187 gConstraintResult = Vector3::ZERO;
1188 scrollView.BindActor( a );
1190 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1194 int UtcDaliToolkitScrollViewOvershoot(void)
1196 ToolkitTestApplication application;
1197 tet_infoline(" UtcDaliToolkitScrollViewOvershoot");
1199 // Set up a scrollView...
1200 ScrollView scrollView = ScrollView::New();
1201 scrollView.SetOvershootEnabled(true);
1203 Vector2 overshootSize = Vector2(100.0f,100.0f);
1204 scrollView.SetProperty( Scrollable::Property::OVERSHOOT_SIZE, overshootSize );
1205 DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_SIZE).Get<Vector2>(), overshootSize, TEST_LOCATION );
1207 Stage::GetCurrent().Add( scrollView );
1208 Vector2 stageSize = Stage::GetCurrent().GetSize();
1209 scrollView.SetSize(stageSize);
1210 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1211 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1214 RulerPtr rulerX = new DefaultRuler();
1215 RulerPtr rulerY = new DefaultRuler();
1216 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1217 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1218 scrollView.SetRulerX(rulerX);
1219 scrollView.SetRulerY(rulerY);
1220 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1221 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1222 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1224 scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1227 // 1. Scroll page in NW (-500,-500 pixels), then inspect overshoot. (don't release touch)
1228 Vector2 currentPos = Vector2(100.0f, 100.0f);
1229 currentPos = PerformGestureDiagonalSwipe(application, currentPos, Vector2(5.0f, 5.0f), 100, false);
1230 float overshootXValue = DevelHandle::GetCurrentProperty< float >( scrollView, ScrollView::Property::OVERSHOOT_X );
1231 float overshootYValue = DevelHandle::GetCurrentProperty< float >( scrollView, ScrollView::Property::OVERSHOOT_Y );
1232 Vector2 positionValue = DevelHandle::GetCurrentProperty< Vector2 >( scrollView, ScrollView::Property::SCROLL_POSITION );
1233 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1234 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1235 DALI_TEST_EQUALS(positionValue, Vector2::ZERO, TEST_LOCATION);
1237 float timeToReachOrigin;
1239 // Now release touch. Overshoot should snap back to zero.
1240 SendPan(application, Gesture::Finished, currentPos);
1241 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1243 float minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1244 float maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1246 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1247 (timeToReachOrigin < maxTimeToReachOrigin) );
1249 // 2. Repeat Scroll, but this time change overshoot snap duration to shorter time
1250 scrollView.SetSnapOvershootDuration(TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION);
1252 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1253 // Now release touch. Overshoot should snap back to zero.
1254 SendPan(application, Gesture::Finished, currentPos);
1255 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1257 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1258 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1260 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1261 (timeToReachOrigin < maxTimeToReachOrigin) );
1263 // 3. Repeat Scroll, but this time change overshoot snap duration to longer time.
1264 scrollView.SetSnapOvershootDuration(TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION);
1266 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1267 // Now release touch. Overshoot should snap back to zero.
1268 SendPan(application, Gesture::Finished, currentPos);
1269 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1271 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1272 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1274 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1275 (timeToReachOrigin < maxTimeToReachOrigin) );
1277 // 4. Repeat Scroll, but this time change overshoot function.
1278 scrollView.SetSnapOvershootDuration(TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION);
1279 scrollView.SetSnapOvershootAlphaFunction(TestAlphaFunction);
1281 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1282 // Now release touch. Overshoot should snap back to zero.
1283 SendPan(application, Gesture::Finished, currentPos);
1284 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1286 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1287 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1289 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1290 (timeToReachOrigin < maxTimeToReachOrigin) );
1294 int UtcDaliToolkitScrollViewSnapAlphaFunction(void)
1296 ToolkitTestApplication application;
1297 tet_infoline(" UtcDaliToolkitScrollViewSnapAlphaFunction");
1299 // Set up a scrollView...
1300 ScrollView scrollView = ScrollView::New();
1301 scrollView.SetScrollSnapAlphaFunction( AlphaFunction::EASE_IN );
1302 DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_IN );
1303 scrollView.SetScrollSnapAlphaFunction( AlphaFunction::EASE_OUT );
1304 DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_OUT );
1306 scrollView.SetScrollFlickAlphaFunction( AlphaFunction::BOUNCE );
1307 DALI_TEST_CHECK( scrollView.GetScrollFlickAlphaFunction().GetBuiltinFunction() == AlphaFunction::BOUNCE );
1312 int UtcDaliToolkitScrollViewSnapDuration(void)
1314 ToolkitTestApplication application;
1315 tet_infoline(" UtcDaliToolkitScrollViewSnapDuration");
1317 // Set up a scrollView...
1318 ScrollView scrollView = ScrollView::New();
1319 scrollView.SetScrollSnapDuration( 1.0f );
1320 DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 1.0f, TEST_LOCATION );
1321 scrollView.SetScrollSnapDuration( 0.5f );
1322 DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 0.5f, TEST_LOCATION );
1324 scrollView.SetScrollFlickDuration( 2.0f );
1325 DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 2.0f, TEST_LOCATION );
1326 scrollView.SetScrollFlickDuration( 1.5f );
1327 DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 1.5f, TEST_LOCATION );
1331 int UtcDaliToolkitScrollViewSnapStartedSignalP(void)
1333 ToolkitTestApplication application;
1334 tet_infoline(" UtcDaliToolkitScrollViewSnapStartedSignalP");
1336 // Set up a scrollView...
1337 ScrollView scrollView = ScrollView::New();
1338 Stage::GetCurrent().Add( scrollView );
1339 Vector2 stageSize = Stage::GetCurrent().GetSize();
1340 scrollView.SetSize(stageSize);
1341 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1342 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1345 RulerPtr rulerX = new DefaultRuler();
1346 RulerPtr rulerY = new DefaultRuler();
1347 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1348 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1349 scrollView.SetRulerX(rulerX);
1350 scrollView.SetRulerY(rulerY);
1351 scrollView.SnapStartedSignal().Connect( &OnSnapStart );
1353 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1356 // First try a snap.
1357 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(0.5f, 0.0f), 60, true);
1359 DALI_TEST_CHECK( gOnSnapStartCalled );
1360 DALI_TEST_CHECK( gLastSnapType == Toolkit::Snap );
1362 // Second try a swipe.
1363 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(20.0f, 0.0f), 60, true);
1365 DALI_TEST_CHECK( gOnSnapStartCalled );
1366 DALI_TEST_CHECK( gLastSnapType == Toolkit::Flick );
1370 int UtcDaliToolkitScrollViewGetCurrentPageP(void)
1372 ToolkitTestApplication application;
1373 tet_infoline(" UtcDaliToolkitScrollViewGetCurrentPageP");
1375 ScrollView scrollView = ScrollView::New();
1376 Stage::GetCurrent().Add( scrollView );
1377 RulerPtr rulerX = new FixedRuler( 100.0f );
1378 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1379 RulerPtr rulerY = new FixedRuler( 100.0f );
1380 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1382 scrollView.SetRulerX( rulerX );
1383 scrollView.SetRulerY( rulerY );
1385 scrollView.ScrollTo( 15 );
1386 Wait(application, RENDER_DELAY_SCROLL);
1387 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION );
1389 scrollView.ScrollTo( 3 );
1390 Wait(application, RENDER_DELAY_SCROLL);
1391 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION );
1393 scrollView.ScrollTo( 9 );
1394 Wait(application, RENDER_DELAY_SCROLL);
1395 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION );
1400 int UtcDaliToolkitScrollViewSetMaxOvershootP(void)
1402 ToolkitTestApplication application;
1403 tet_infoline(" UtcDaliToolkitScrollViewSetMaxOvershootP");
1405 // Set up a scrollView...
1406 ScrollView scrollView = ScrollView::New();
1407 Stage::GetCurrent().Add( scrollView );
1408 Vector2 stageSize = Stage::GetCurrent().GetSize();
1409 scrollView.SetSize(stageSize);
1410 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1411 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1414 RulerPtr rulerX = new DefaultRuler();
1415 RulerPtr rulerY = new DefaultRuler();
1416 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1417 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1418 scrollView.SetRulerX(rulerX);
1419 scrollView.SetRulerY(rulerY);
1421 // Set the max overshoot to be 50 pixels in both X axis and Y axis
1422 scrollView.SetMaxOvershoot(50.0f, 50.0f);
1424 scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1427 // Scroll page in NW (-20,-20 pixels), then check that overshoot should be 0. (don't release touch)
1428 Vector2 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 20, false);
1429 float overshootXValue = DevelHandle::GetCurrentProperty< float >( scrollView, ScrollView::Property::OVERSHOOT_X );
1430 float overshootYValue = DevelHandle::GetCurrentProperty< float >( scrollView, ScrollView::Property::OVERSHOOT_Y );
1431 DALI_TEST_EQUALS(overshootXValue, 0.0f, TEST_LOCATION);
1432 DALI_TEST_EQUALS(overshootYValue, 0.0f, TEST_LOCATION);
1434 // Scroll page further in NW (-105,-105 pixels), then check that overshoot should be around 0.5. (don't release touch)
1435 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 105, false);
1436 overshootXValue = DevelHandle::GetCurrentProperty< float >( scrollView, ScrollView::Property::OVERSHOOT_X );
1437 overshootYValue = DevelHandle::GetCurrentProperty< float >( scrollView, ScrollView::Property::OVERSHOOT_Y );
1438 // The overshoot value is a 0.0f - 1.0f ranged value of the amount overshot related to the maximum overshoot.
1439 // EG. If we move 105, max overshoot is 50, then we overshot 50 / 105.
1440 float correctOvershootValue = 50.0f / 105.f;
1441 DALI_TEST_EQUALS( overshootXValue, correctOvershootValue, 0.001f, TEST_LOCATION );
1442 DALI_TEST_EQUALS( overshootYValue, correctOvershootValue, 0.001f, TEST_LOCATION );
1444 // Scroll page further in NW (-30,-30 pixels), then check that overshoot should be now 1.0. (don't release touch)
1445 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 30, false);
1446 overshootXValue = DevelHandle::GetCurrentProperty< float >( scrollView, ScrollView::Property::OVERSHOOT_X );
1447 overshootYValue = DevelHandle::GetCurrentProperty< float >( scrollView, ScrollView::Property::OVERSHOOT_Y );
1448 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1449 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1451 // Change the max overshoot to be 100 pixels in both X axis and Y axis
1452 scrollView.SetMaxOvershoot(100.0f, 100.0f);
1455 // Check that overshoot should be now around 0.8.
1456 overshootXValue = DevelHandle::GetCurrentProperty< float >( scrollView, ScrollView::Property::OVERSHOOT_X );
1457 overshootYValue = DevelHandle::GetCurrentProperty< float >( scrollView, ScrollView::Property::OVERSHOOT_Y );
1458 DALI_TEST_CHECK(overshootXValue > 0.79f && overshootXValue < 0.81f);
1459 DALI_TEST_CHECK(overshootYValue > 0.79f && overshootYValue < 0.81f);
1461 // Scroll page further in NW (-30,-30 pixels), then check that overshoot should be now 1.0. (don't release touch)
1462 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 30, false);
1463 overshootXValue = DevelHandle::GetCurrentProperty< float >( scrollView, ScrollView::Property::OVERSHOOT_X );
1464 overshootYValue = DevelHandle::GetCurrentProperty< float >( scrollView, ScrollView::Property::OVERSHOOT_Y );
1465 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1466 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1471 int UtcDaliToolkitScrollViewSetScrollingDirectionP(void)
1473 ToolkitTestApplication application;
1474 tet_infoline(" UtcDaliToolkitScrollViewSetScrollingDirectionP");
1476 // Set up a scrollView...
1477 ScrollView scrollView = ScrollView::New();
1478 Stage::GetCurrent().Add( scrollView );
1479 Vector2 stageSize = Stage::GetCurrent().GetSize();
1480 scrollView.SetSize(stageSize);
1481 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1482 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1484 Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1486 scrollView.ScrollTo(START_POSITION, 0.0f);
1488 // Try a vertical swipe.
1489 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1490 // Take into account resampling done when prediction is off.
1491 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1493 scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1495 scrollView.ScrollTo(START_POSITION, 0.0f);
1497 // Try a vertical swipe.
1498 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1499 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION );
1501 scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1503 scrollView.ScrollTo(Vector2(10.0f, 10.0f), 0.0f);
1505 // Try a vertical swipe.
1506 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1507 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1512 int UtcDaliToolkitScrollViewRemoveScrollingDirectionP(void)
1514 ToolkitTestApplication application;
1515 tet_infoline(" UtcDaliToolkitScrollViewRemoveScrollingDirectionP");
1517 // Set up a scrollView...
1518 ScrollView scrollView = ScrollView::New();
1519 Stage::GetCurrent().Add( scrollView );
1520 Vector2 stageSize = Stage::GetCurrent().GetSize();
1521 scrollView.SetSize(stageSize);
1522 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1523 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1525 Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1527 scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1529 scrollView.ScrollTo(START_POSITION, 0.0f);
1531 // Try a vertical swipe.
1532 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1533 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION );
1535 scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1537 scrollView.ScrollTo(Vector2(10.0f, 10.0f), 0.0f);
1539 // Try a vertical swipe.
1540 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1541 // Take into account resampling done when prediction is off.
1542 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1547 int UtcDaliToolkitScrollViewSetRulerXP(void)
1549 ToolkitTestApplication application;
1550 tet_infoline(" UtcDaliToolkitScrollViewSetRulerXP");
1552 ScrollView scrollView = ScrollView::New();
1553 Stage::GetCurrent().Add( scrollView );
1554 RulerPtr rulerX = new FixedRuler( 100.0f );
1555 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1557 scrollView.SetRulerX( rulerX );
1559 scrollView.ScrollTo( 1, 0.0f );
1561 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION );
1563 RulerPtr newRulerX = new FixedRuler( 200.0f );
1564 newRulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1566 scrollView.SetRulerX( newRulerX );
1568 scrollView.ScrollTo( 1, 0.0f );
1570 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 0.0f), TEST_LOCATION );
1575 int UtcDaliToolkitScrollViewSetRulerYP(void)
1577 ToolkitTestApplication application;
1578 tet_infoline(" UtcDaliToolkitScrollViewSetRulerYP");
1580 ScrollView scrollView = ScrollView::New();
1581 Stage::GetCurrent().Add( scrollView );
1583 RulerPtr rulerY = new FixedRuler( 200.0f );
1584 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1586 scrollView.SetRulerY( rulerY );
1588 scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f );
1590 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 350.0f), TEST_LOCATION );
1592 RulerPtr newRulerY = new FixedRuler( 100.0f );
1593 newRulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
1594 scrollView.SetRulerY( newRulerY );
1596 scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f );
1598 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 200.0f), TEST_LOCATION );
1603 int UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP(void)
1605 ToolkitTestApplication application;
1606 tet_infoline(" UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP");
1608 ScrollView scrollView = ScrollView::New();
1609 scrollView.SetMinimumSpeedForFlick(25.0f);
1610 DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 25.0f, TEST_LOCATION );
1611 scrollView.SetMinimumSpeedForFlick(60.0f);
1612 DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 60.0f, TEST_LOCATION );
1616 int UtcDaliToolkitScrollViewSetMinimumDistanceForFlickP(void)
1618 ToolkitTestApplication application;
1619 tet_infoline(" UtcDaliToolkitScrollViewSetMinimumDistanceForFlick");
1621 ScrollView scrollView = ScrollView::New();
1623 scrollView.SetMinimumDistanceForFlick(Vector2(30.0f, 15.0f));
1624 DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(30.0f, 15.0f), TEST_LOCATION );
1625 scrollView.SetMinimumDistanceForFlick(Vector2(60.0f, 30.0f));
1626 DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(60.0f, 30.0f), TEST_LOCATION);
1630 int UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP(void)
1632 ToolkitTestApplication application;
1633 tet_infoline(" UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP");
1635 ScrollView scrollView = ScrollView::New();
1636 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
1637 scrollView.SetWheelScrollDistanceStep(Vector2(30.0f, 15.0f));
1638 DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(30.0f, 15.0f), TEST_LOCATION );
1639 scrollView.SetWheelScrollDistanceStep(Vector2(60.0f, 30.0f));
1640 DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(60.0f, 30.0f), TEST_LOCATION);
1644 int UtcDaliToolkitScrollViewApplyEffectP(void)
1646 ToolkitTestApplication application;
1647 tet_infoline(" UtcDaliToolkitScrollViewApplyEffectP");
1649 // Create a ScrollView
1650 ScrollView scrollView = ScrollView::New();
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);
1657 // Apply both effects
1658 scrollView.ApplyEffect(effect);
1659 scrollView.ApplyEffect(newEffect);
1661 DALI_TEST_CHECK( true );
1666 int UtcDaliToolkitScrollViewApplyEffectN(void)
1668 ToolkitTestApplication application;
1669 tet_infoline(" UtcDaliToolkitScrollViewApplyEffectN");
1671 // Create a ScrollView
1672 ScrollView scrollView = ScrollView::New();
1674 // Create two scroll view effects
1675 Dali::Path path = Dali::Path::New();
1676 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);
1677 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);
1679 // Apply both effects
1680 scrollView.ApplyEffect(effect);
1681 scrollView.ApplyEffect(newEffect);
1683 // Attempt to apply the same effect again
1686 scrollView.ApplyEffect(newEffect);
1687 tet_result( TET_FAIL );
1689 catch ( DaliException& e )
1691 DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
1697 int UtcDaliToolkitScrollViewRemoveEffectP(void)
1699 ToolkitTestApplication application;
1700 tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectP");
1702 // Create a ScrollView
1703 ScrollView scrollView = ScrollView::New();
1705 // Create two scroll view effects
1706 Dali::Path path = Dali::Path::New();
1707 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);
1708 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);
1710 // Apply both effects
1711 scrollView.ApplyEffect(effect);
1712 scrollView.ApplyEffect(newEffect);
1714 // Remove both effects
1715 scrollView.RemoveEffect(effect);
1716 scrollView.RemoveEffect(newEffect);
1718 DALI_TEST_CHECK( true );
1723 int UtcDaliToolkitScrollViewRemoveEffectN(void)
1725 ToolkitTestApplication application;
1726 tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectN");
1728 // Create a ScrollView
1729 ScrollView scrollView = ScrollView::New();
1731 // Create two scroll view effects
1732 Dali::Path path = Dali::Path::New();
1733 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);
1734 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);
1736 // Apply the first effect
1737 scrollView.ApplyEffect(effect);
1739 // Attempt to remove the second effect which has not been applied to scroll view
1742 scrollView.RemoveEffect(newEffect);
1743 tet_result( TET_FAIL );
1745 catch ( DaliException& e )
1747 DALI_TEST_ASSERT( e, "effectExistedInScrollView", TEST_LOCATION );
1753 int UtcDaliToolkitScrollViewRemoveAllEffectsP(void)
1755 ToolkitTestApplication application;
1756 tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsP");
1758 // Create a ScrollView
1759 ScrollView scrollView = ScrollView::New();
1761 // Create two scroll view effects
1762 Dali::Path path = Dali::Path::New();
1763 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);
1764 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);
1766 // Apply both effects
1767 scrollView.ApplyEffect(effect);
1768 scrollView.ApplyEffect(newEffect);
1770 // Attempt to apply the same first effect again
1773 scrollView.ApplyEffect(effect);
1774 tet_result( TET_FAIL );
1776 catch ( DaliException& e )
1778 DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
1781 // Remove both effects
1782 scrollView.RemoveAllEffects();
1784 // Apply both effects again
1785 scrollView.ApplyEffect(effect);
1786 scrollView.ApplyEffect(newEffect);
1788 DALI_TEST_CHECK( true );
1793 int UtcDaliToolkitScrollViewRemoveAllEffectsN(void)
1795 ToolkitTestApplication application;
1796 tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsN");
1798 // Create a ScrollView
1799 ScrollView scrollView = ScrollView::New();
1801 // Remove effects when there is no effect applied previously
1802 scrollView.RemoveAllEffects();
1804 DALI_TEST_CHECK( true );
1809 int UtcDaliToolkitScrollViewSetOvershootEnabledP(void)
1811 ToolkitTestApplication application;
1812 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEnabledP");
1814 ScrollView scrollView = ScrollView::New();
1816 scrollView.SetOvershootEnabled(true);
1817 DALI_TEST_CHECK(scrollView.IsOvershootEnabled());
1819 scrollView.SetOvershootEnabled(false);
1820 DALI_TEST_CHECK(!scrollView.IsOvershootEnabled());
1825 int UtcDaliToolkitScrollViewSetOvershootEffectColorP(void)
1827 ToolkitTestApplication application;
1828 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEffectColorP");
1830 ScrollView scrollView = ScrollView::New();
1832 scrollView.SetOvershootEffectColor(Dali::Color::RED);
1833 DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::RED, TEST_LOCATION);
1835 scrollView.SetOvershootEffectColor(Dali::Color::YELLOW);
1836 DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::YELLOW, TEST_LOCATION);
1841 int UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP(void)
1843 ToolkitTestApplication application;
1844 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP");
1846 ScrollView scrollView = ScrollView::New();
1848 scrollView.SetOvershootAnimationSpeed(55.0f);
1849 DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 55.0f, TEST_LOCATION);
1851 scrollView.SetOvershootAnimationSpeed(120.0f);
1852 DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 120.0f, TEST_LOCATION);
1857 int UtcDaliToolkitScrollViewGetSet(void)
1859 ToolkitTestApplication application;
1860 tet_infoline(" UtcDaliToolkitScrollViewGetSet");
1861 ScrollView scrollView = ScrollView::New();
1862 scrollView.SetMaxFlickSpeed(0.5f);
1863 DALI_TEST_EQUALS(scrollView.GetMaxFlickSpeed(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1864 scrollView.SetFrictionCoefficient(0.6f);
1865 DALI_TEST_EQUALS(scrollView.GetFrictionCoefficient(), 0.6f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1866 scrollView.SetFlickSpeedCoefficient(0.7f);
1867 DALI_TEST_EQUALS(scrollView.GetFlickSpeedCoefficient(), 0.7f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1871 int UtcDaliToolkitScrollViewRulerDomainConstructorP(void)
1873 ToolkitTestApplication application;
1875 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
1876 DALI_TEST_EQUALS( domainX.min, 0.0f, TEST_LOCATION);
1877 DALI_TEST_EQUALS( domainX.max, 200.0f, TEST_LOCATION);
1878 DALI_TEST_EQUALS( domainX.enabled, true, TEST_LOCATION);
1880 RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
1881 DALI_TEST_EQUALS( domainY.min, 100.0f, TEST_LOCATION);
1882 DALI_TEST_EQUALS( domainY.max, 500.0f, TEST_LOCATION);
1883 DALI_TEST_EQUALS( domainY.enabled, false, TEST_LOCATION);
1888 int UtcDaliToolkitScrollViewRulerDomainGetSizeP(void)
1890 ToolkitTestApplication application;
1892 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
1893 DALI_TEST_EQUALS( domainX.GetSize(), 200.0f, TEST_LOCATION);
1895 RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
1896 DALI_TEST_EQUALS( domainY.GetSize(), 400.0f, TEST_LOCATION);
1901 int UtcDaliToolkitScrollViewRulerDomainClampP(void)
1903 ToolkitTestApplication application;
1905 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
1907 float value = domainX.Clamp(50.0f, 100.0f, 1.0f);
1908 DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
1910 value = domainX.Clamp(300.0f, 20.0f, 1.0f);
1911 DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
1913 value = domainX.Clamp(300.0f, 20.0f, 0.5f);
1914 DALI_TEST_EQUALS( value, 80.0f, TEST_LOCATION);
1916 value = domainX.Clamp(250.0f, 200.0f, 2.0f);
1917 DALI_TEST_EQUALS( value, 200.0f, TEST_LOCATION);
1922 int UtcDaliToolkitScrollViewRulerDomainClampWithStateP(void)
1924 ToolkitTestApplication application;
1926 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
1929 float value = domainX.Clamp(50.0f, 100.0f, 1.0f, clamped);
1930 DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
1931 DALI_TEST_EQUALS( clamped, Dali::Toolkit::NotClamped, TEST_LOCATION);
1933 value = domainX.Clamp(-100.0f, 200.0f, 1.0f, clamped);
1934 DALI_TEST_EQUALS( value, 0.0f, TEST_LOCATION);
1935 DALI_TEST_EQUALS( clamped, Dali::Toolkit::ClampedToMin, TEST_LOCATION);
1937 value = domainX.Clamp(300.0f, 20.0f, 1.0f, clamped);
1938 DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
1939 DALI_TEST_EQUALS( clamped, Dali::Toolkit::ClampedToMax, TEST_LOCATION);
1944 int UtcDaliToolkitScrollViewDefaultRulerConstructorP(void)
1946 ToolkitTestApplication application;
1947 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerConstructorP");
1949 RulerPtr defaultRuler = new DefaultRuler();
1950 DALI_TEST_CHECK( defaultRuler );
1955 int UtcDaliToolkitScrollViewDefaultRulerDestructorP(void)
1957 ToolkitTestApplication application;
1958 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerDestructorP");
1960 RulerPtr defaultRuler = new DefaultRuler();
1962 DALI_TEST_CHECK( true );
1966 int UtcDaliToolkitScrollViewFixedRulerConstructorP(void)
1968 ToolkitTestApplication application;
1969 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerConstructorP");
1971 RulerPtr fixedRuler = new FixedRuler( 100.0f );
1972 DALI_TEST_CHECK( fixedRuler );
1974 fixedRuler = new FixedRuler( 0.0f );
1975 DALI_TEST_CHECK( fixedRuler );
1980 int UtcDaliToolkitScrollViewFixedRulerDestructorP(void)
1982 ToolkitTestApplication application;
1983 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerDestructorP");
1985 RulerPtr fixedRuler = new FixedRuler( 100.0f );
1987 DALI_TEST_CHECK( true );
1991 int UtcDaliToolkitScrollViewRulerGetTypeP(void)
1993 ToolkitTestApplication application;
1994 tet_infoline(" UtcDaliToolkitScrollViewRulerGetTypeP");
1996 RulerPtr defaultRuler = new DefaultRuler();
1997 DALI_TEST_CHECK( defaultRuler );
1998 DALI_TEST_EQUALS( defaultRuler->GetType(), Dali::Toolkit::Ruler::Free, TEST_LOCATION);
2000 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2001 DALI_TEST_CHECK( fixedRuler );
2002 DALI_TEST_EQUALS( fixedRuler->GetType(), Dali::Toolkit::Ruler::Fixed, TEST_LOCATION);
2007 int UtcDaliToolkitScrollViewRulerGetExtensionP(void)
2009 ToolkitTestApplication application;
2010 tet_infoline(" UtcDaliToolkitScrollViewRulerGetExtensionP");
2012 RulerPtr defaultRuler = new DefaultRuler();
2013 DALI_TEST_CHECK( defaultRuler );
2014 DALI_TEST_CHECK( !defaultRuler->GetExtension() );
2016 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2017 DALI_TEST_CHECK( fixedRuler );
2018 DALI_TEST_CHECK( !fixedRuler->GetExtension() );
2023 int UtcDaliToolkitScrollViewRulerEnableDisable(void)
2025 ToolkitTestApplication application;
2026 tet_infoline(" UtcDaliToolkitScrollViewRulerEnableDisable");
2028 RulerPtr ruler = new DefaultRuler();
2030 DALI_TEST_CHECK( ruler->IsEnabled() );
2032 DALI_TEST_CHECK( !ruler->IsEnabled() );
2034 DALI_TEST_CHECK( ruler->IsEnabled() );
2038 int UtcDaliToolkitScrollViewRulerDomainEnableDisable(void)
2040 ToolkitTestApplication application;
2041 tet_infoline(" UtcDaliToolkitScrollViewRulerDomainEnableDisable");
2043 RulerPtr ruler = new DefaultRuler();
2044 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
2046 ruler->SetDomain( RulerDomain(0.0f, 100.0f, true) );
2047 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 100.0f, TEST_LOCATION );
2048 DALI_TEST_EQUALS( ruler->Clamp(-200.0f), 0.0f, TEST_LOCATION );
2049 DALI_TEST_EQUALS( ruler->Clamp(200.0f), 100.0f, TEST_LOCATION );
2051 ruler->DisableDomain();
2052 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
2053 DALI_TEST_EQUALS( ruler->Clamp(-200.0f), -200.0f, TEST_LOCATION );
2054 DALI_TEST_EQUALS( ruler->Clamp(200.0f), 200.0f, TEST_LOCATION );
2058 int UtcDaliToolkitScrollViewRulerSnapAndClamp(void)
2060 ToolkitTestApplication application;
2061 tet_infoline(" UtcDaliToolkitScrollViewRulerSnapAndClamp");
2063 RulerPtr ruler = new FixedRuler( 50.0f );
2064 ruler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2066 // default testing. (snap and clamp)
2067 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f), 50.0f, TEST_LOCATION);
2068 DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f), 50.0f, TEST_LOCATION);
2069 DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f), 0.0f, TEST_LOCATION);
2070 DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f), 0.0f, TEST_LOCATION);
2071 DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f), 400.0f, TEST_LOCATION);
2072 DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f), 400.0f, TEST_LOCATION);
2075 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
2076 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.5f), 50.0f, TEST_LOCATION); // No Flick
2077 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
2079 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
2080 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.5f), 0.0f, TEST_LOCATION); // No Flick
2081 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
2084 DALI_TEST_EQUALS( ruler->SnapAndClamp(-10.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (over left boundary)
2085 DALI_TEST_EQUALS( ruler->SnapAndClamp(-5.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (slightly ovr left boundary)
2086 DALI_TEST_EQUALS( ruler->SnapAndClamp(300.0f, 0.5f, 10.0f), 300.0f, TEST_LOCATION); // 10 units long (not over a boundary)
2087 DALI_TEST_EQUALS( ruler->SnapAndClamp(395.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (slightly over right boundary)
2088 DALI_TEST_EQUALS( ruler->SnapAndClamp(500.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (over right boundary)
2091 DALI_TEST_EQUALS( ruler->SnapAndClamp(-100.0f, 0.5f, 0.0f, 2.0f), 0.0f, TEST_LOCATION);
2092 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 2.0f), 50.0f, TEST_LOCATION);
2093 DALI_TEST_EQUALS( ruler->SnapAndClamp(700.0f, 0.5f, 0.0f, 2.0f), 700.0f, TEST_LOCATION);
2094 DALI_TEST_EQUALS( ruler->SnapAndClamp(850.0f, 0.5f, 0.0f, 2.0f), 800.0f, TEST_LOCATION);
2096 // clamp state testing.
2098 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
2099 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2100 DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
2101 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2102 DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
2103 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2104 DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
2105 DALI_TEST_EQUALS( clamped, ClampedToMin, TEST_LOCATION );
2106 DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
2107 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2108 DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
2109 DALI_TEST_EQUALS( clamped, ClampedToMax, TEST_LOCATION );
2113 int UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP(void)
2115 ToolkitTestApplication application;
2116 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP");
2118 RulerPtr rulerNormal = new FixedRuler( 25.0f );
2119 rulerNormal->SetDomain( RulerDomain(10.0f, 90.0f, true) );
2121 unsigned int volume;
2124 position = rulerNormal->GetPositionFromPage(1, volume, true);
2125 DALI_TEST_EQUALS( position, 35.0f, TEST_LOCATION );
2126 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
2128 position = rulerNormal->GetPositionFromPage(2, volume, true);
2129 DALI_TEST_EQUALS( position, 60.0f, TEST_LOCATION );
2130 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
2132 // Disable the ruler
2133 rulerNormal->Disable();
2135 position = rulerNormal->GetPositionFromPage(1, volume, true);
2136 DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
2137 DALI_TEST_EQUALS( volume, 1u, TEST_LOCATION );
2139 position = rulerNormal->GetPositionFromPage(2, volume, true);
2140 DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
2141 DALI_TEST_EQUALS( volume, 2u, TEST_LOCATION );
2146 int UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP(void)
2148 ToolkitTestApplication application;
2149 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP");
2151 RulerPtr defaultRuler = new DefaultRuler();
2152 DALI_TEST_CHECK( defaultRuler );
2153 DALI_TEST_EQUALS( defaultRuler->GetTotalPages(), 1u, TEST_LOCATION);
2158 int UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP(void)
2160 ToolkitTestApplication application;
2161 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP");
2163 RulerPtr defaultRuler = new DefaultRuler();
2164 DALI_TEST_CHECK( defaultRuler );
2165 DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(100.0f, true), 0u, TEST_LOCATION);
2166 DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(-300.0f, false), 0u, TEST_LOCATION);
2171 int UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP(void)
2173 ToolkitTestApplication application;
2174 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP");
2176 RulerPtr defaultRuler = new DefaultRuler();
2177 DALI_TEST_CHECK( defaultRuler );
2179 unsigned int volume;
2180 DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(0, volume, true), 0.0f, TEST_LOCATION);
2181 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
2183 DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(3, volume, false), 0.0f, TEST_LOCATION);
2184 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
2189 int UtcDaliToolkitScrollViewDefaultRulerSnapP(void)
2191 ToolkitTestApplication application;
2192 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerSnapP");
2194 RulerPtr defaultRuler = new DefaultRuler();
2195 DALI_TEST_CHECK( defaultRuler );
2197 DALI_TEST_EQUALS( defaultRuler->Snap(50.0f, 0.5f), 50.0f, TEST_LOCATION);
2198 DALI_TEST_EQUALS( defaultRuler->Snap(-120.0f, 1.0f), -120.0f, TEST_LOCATION);
2203 int UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP(void)
2205 ToolkitTestApplication application;
2206 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP");
2208 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2209 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2211 fixedRuler->Enable();
2212 DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 4u, TEST_LOCATION);
2214 fixedRuler->Disable();
2215 DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 1u, TEST_LOCATION);
2220 int UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP(void)
2222 ToolkitTestApplication application;
2223 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP");
2225 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2226 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2228 fixedRuler->Enable();
2229 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 3u, TEST_LOCATION);
2230 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2231 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 1u, TEST_LOCATION);
2232 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2234 fixedRuler->Disable();
2235 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2236 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
2237 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2238 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2240 // Set domain size to be smaller than the ruler space
2241 fixedRuler->SetDomain( RulerDomain(0.0f, 50.0f, true) );
2243 fixedRuler->Enable();
2244 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2245 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2246 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2247 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2249 fixedRuler->Disable();
2250 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2251 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
2252 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2253 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2258 int UtcDaliToolkitScrollViewFixedRulerSnapP(void)
2260 ToolkitTestApplication application;
2261 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerSnapP");
2263 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2264 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2266 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.0f), -100.0f, TEST_LOCATION);
2267 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.0f), -100.0f, TEST_LOCATION);
2268 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.0f), -200.0f, TEST_LOCATION);
2269 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.0f), -500.0f, TEST_LOCATION);
2270 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.0f), 0.0f, TEST_LOCATION);
2271 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.0f), 0.0f, TEST_LOCATION);
2272 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.0f), 0.0f, TEST_LOCATION);
2273 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.0f), 100.0f, TEST_LOCATION);
2274 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.0f), 100.0f, TEST_LOCATION);
2275 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.0f), 200.0f, TEST_LOCATION);
2276 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.0f), 600.0f, TEST_LOCATION);
2278 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.5f), 0.0f, TEST_LOCATION);
2279 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.5f), -100.0f, TEST_LOCATION);
2280 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.5f), -100.0f, TEST_LOCATION);
2281 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.5f), -500.0f, TEST_LOCATION);
2282 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.5f), 0.0f, TEST_LOCATION);
2283 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.5f), 100.0f, TEST_LOCATION);
2284 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.5f), 100.0f, TEST_LOCATION);
2285 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.5f), 100.0f, TEST_LOCATION);
2286 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.5f), 100.0f, TEST_LOCATION);
2287 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.5f), 300.0f, TEST_LOCATION);
2288 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.5f), 600.0f, TEST_LOCATION);
2290 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 1.0f), 0.0f, TEST_LOCATION);
2291 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 1.0f), 0.0f, TEST_LOCATION);
2292 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 1.0f), -100.0f, TEST_LOCATION);
2293 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 1.0f), -400.0f, TEST_LOCATION);
2294 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 1.0f), 100.0f, TEST_LOCATION);
2295 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 1.0f), 100.0f, TEST_LOCATION);
2296 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 1.0f), 100.0f, TEST_LOCATION);
2297 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 1.0f), 200.0f, TEST_LOCATION);
2298 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 1.0f), 200.0f, TEST_LOCATION);
2299 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 1.0f), 300.0f, TEST_LOCATION);
2300 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 1.0f), 700.0f, TEST_LOCATION);
2305 int UtcDaliToolkitScrollViewConstraintsMove(void)
2307 ToolkitTestApplication application;
2308 tet_infoline(" UtcDaliToolkitScrollViewConstraintsMove");
2310 // Set up a scrollView...
2311 ScrollView scrollView = ScrollView::New();
2312 Stage::GetCurrent().Add( scrollView );
2313 Vector2 stageSize = Stage::GetCurrent().GetSize();
2314 scrollView.SetSize(stageSize);
2315 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
2316 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2319 RulerPtr rulerX = new DefaultRuler();
2320 RulerPtr rulerY = new DefaultRuler();
2321 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
2322 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
2323 scrollView.SetRulerX(rulerX);
2324 scrollView.SetRulerY(rulerY);
2326 // Add an Actor to ScrollView,
2327 Actor a = Actor::New();
2329 a.SetPosition( TEST_ACTOR_POSITION );
2332 const Vector2 target = Vector2(100.0f, 100.0f);
2333 const Vector2 target2 = Vector2(200.0f, 200.0f);
2335 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, MoveActorConstraint );
2336 constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
2337 constraint.SetRemoveAction(Constraint::Discard);
2338 scrollView.ApplyConstraintToChildren(constraint);
2340 scrollView.ScrollTo( target, 0.0f );
2342 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
2343 scrollView.ScrollTo( target2 );
2344 Wait(application, RENDER_DELAY_SCROLL);
2345 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
2350 int UtcDaliToolkitScrollViewConstraintsWrap(void)
2352 ToolkitTestApplication application;
2353 tet_infoline(" UtcDaliToolkitScrollViewConstraintsWrap");
2355 // Set up a scrollView...
2356 ScrollView scrollView = ScrollView::New();
2357 Stage::GetCurrent().Add( scrollView );
2358 Vector2 stageSize = Stage::GetCurrent().GetSize();
2359 scrollView.SetSize(stageSize);
2360 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
2361 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2364 RulerPtr rulerX = new DefaultRuler();
2365 RulerPtr rulerY = new DefaultRuler();
2366 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
2367 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
2368 scrollView.SetRulerX(rulerX);
2369 scrollView.SetRulerY(rulerY);
2371 // Add an Actor to ScrollView,
2372 Actor a = Actor::New();
2374 a.SetPosition( TEST_ACTOR_POSITION );
2377 const Vector2 target = Vector2(100.0f, 100.0f);
2378 const Vector2 target2 = Vector2(200.0f, 200.0f);
2380 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, WrapActorConstraint );
2381 constraint.AddSource( LocalSource( Actor::Property::SCALE ) );
2382 constraint.AddSource( LocalSource( Actor::Property::ANCHOR_POINT ) );
2383 constraint.AddSource( LocalSource( Actor::Property::SIZE ) );
2384 constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
2385 constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
2386 constraint.AddSource( Source( scrollView, Toolkit::ScrollView::Property::WRAP ) );
2387 constraint.SetRemoveAction(Constraint::Discard);
2388 scrollView.ApplyConstraintToChildren(constraint);
2390 scrollView.ScrollTo( target, 0.0f );
2392 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
2393 scrollView.ScrollTo( target2 );
2394 Wait(application, RENDER_DELAY_SCROLL);
2395 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
2397 scrollView.Remove(a);
2403 // Non-API test (so no P or N variant).
2404 int UtcDaliToolkitScrollViewGesturePageLimit(void)
2406 ToolkitTestApplication application;
2407 tet_infoline( " UtcDaliToolkitScrollViewGesturePageLimit" );
2409 // Set up a scrollView.
2410 ScrollView scrollView = ScrollView::New();
2412 // Do not rely on stage size for UTC tests.
2413 Vector2 pageSize( 720.0f, 1280.0f );
2414 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
2415 scrollView.SetSize( pageSize );
2416 scrollView.SetParentOrigin( ParentOrigin::CENTER );
2417 scrollView.SetAnchorPoint( AnchorPoint::CENTER );
2418 scrollView.SetPosition( 0.0f, 0.0f, 0.0f );
2421 // We set the X ruler to fixed to give us pages to snap to.
2422 Dali::Toolkit::FixedRuler* rulerX = new Dali::Toolkit::FixedRuler( pageSize.width );
2423 // Note: The 3x page width is arbitary, but we need enough to show that we are
2424 // capping page movement by the page limiter, and not the domain.
2425 rulerX->SetDomain( Dali::Toolkit::RulerDomain( 0.0f, pageSize.width * 3.0f, false ) );
2426 Dali::Toolkit::RulerPtr rulerY = new Dali::Toolkit::DefaultRuler();
2428 scrollView.SetRulerX( rulerX );
2429 scrollView.SetRulerY( rulerY );
2431 scrollView.SetWrapMode( false );
2432 scrollView.SetScrollSensitive( true );
2434 Stage::GetCurrent().Add( scrollView );
2436 // Set up a gesture to perform.
2437 Vector2 startPos( 50.0f, 0.0f );
2438 Vector2 direction( -5.0f, 0.0f );
2441 // Force starting position.
2442 scrollView.ScrollTo( startPos, 0.0f );
2443 Wait( application );
2445 // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
2446 Vector2 currentPos( PerformGestureDiagonalSwipe( application, startPos, direction, frames - 1, false ) );
2448 // Confirm the final X coord has not moved more than one page from the start X position.
2449 DALI_TEST_GREATER( ( startPos.x + pageSize.width ), scrollView.GetCurrentScrollPosition().x, TEST_LOCATION );
2451 // Finish the gesture and wait for the snap.
2452 currentPos += direction;
2453 SendPan( application, Gesture::Finished, currentPos );
2454 // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
2455 Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
2457 // Confirm the final X coord has snapped to exactly one page ahead of the start page.
2458 DALI_TEST_EQUALS( pageSize.width, scrollView.GetCurrentScrollPosition().x, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2463 int UtcDaliScrollViewSetGetProperty(void)
2465 ToolkitTestApplication application;
2467 // Create the ScrollView actor
2468 ScrollView scrollView = ScrollView::New();
2469 DALI_TEST_CHECK(scrollView);
2471 // Event side properties
2473 // Test "wrapEnabled" property
2474 DALI_TEST_CHECK( scrollView.GetPropertyIndex("wrapEnabled") == ScrollView::Property::WRAP_ENABLED );
2475 scrollView.SetProperty( ScrollView::Property::WRAP_ENABLED, true );
2476 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WRAP_ENABLED).Get<bool>(), true, TEST_LOCATION );
2478 // Test "panningEnabled" property
2479 DALI_TEST_CHECK( scrollView.GetPropertyIndex("panningEnabled") == ScrollView::Property::PANNING_ENABLED );
2480 scrollView.SetProperty( ScrollView::Property::PANNING_ENABLED, false );
2481 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::PANNING_ENABLED).Get<bool>(), false, TEST_LOCATION );
2483 // Test "axisAutoLockEnabled" property
2484 DALI_TEST_CHECK( scrollView.GetPropertyIndex("axisAutoLockEnabled") == ScrollView::Property::AXIS_AUTO_LOCK_ENABLED );
2485 scrollView.SetProperty( ScrollView::Property::AXIS_AUTO_LOCK_ENABLED, false );
2486 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::AXIS_AUTO_LOCK_ENABLED).Get<bool>(), false, TEST_LOCATION );
2488 // Test "wheelScrollDistanceStep" property
2489 DALI_TEST_CHECK( scrollView.GetPropertyIndex("wheelScrollDistanceStep") == ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP );
2490 scrollView.SetProperty( ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP, Vector2(100.0f, 50.0f) );
2491 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP).Get<Vector2>(), Vector2(100.0f, 50.0f), TEST_LOCATION );
2493 // Test "overshootEnabled" property
2494 DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootEnabled") == Scrollable::Property::OVERSHOOT_ENABLED );
2495 DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), scrollView.IsOvershootEnabled(), TEST_LOCATION );
2496 scrollView.SetProperty( Scrollable::Property::OVERSHOOT_ENABLED, false );
2497 DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), false, TEST_LOCATION );
2499 // Animatable properties
2501 // Test "scrollPosition" property
2502 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPosition") == ScrollView::Property::SCROLL_POSITION );
2503 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(320.0f, 550.0f) );
2505 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION).Get<Vector2>(), Vector2(320.0f, 550.0f), TEST_LOCATION );
2507 // Test "scrollPrePosition", "scrollPrePositionX" and "scrollPrePositionY" properties
2508 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePosition") == ScrollView::Property::SCROLL_PRE_POSITION );
2509 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION, Vector2(300.0f, 500.0f) );
2511 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION).Get<Vector2>(), Vector2(300.0f, 500.0f), TEST_LOCATION );
2513 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionX") == ScrollView::Property::SCROLL_PRE_POSITION_X );
2514 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionY") == ScrollView::Property::SCROLL_PRE_POSITION_Y );
2515 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_X).Get<float>(), 300.0f, TEST_LOCATION );
2516 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_Y).Get<float>(), 500.0f, TEST_LOCATION );
2517 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_X, 400.0f );
2518 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_Y, 600.0f );
2520 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_X).Get<float>(), 400.0f, TEST_LOCATION );
2521 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_Y).Get<float>(), 600.0f, TEST_LOCATION );
2522 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION).Get<Vector2>(), Vector2(400.0f, 600.0f), TEST_LOCATION );
2524 // Test "scrollPrePositionMax", "scrollPrePositionMaxX" and "scrollPrePositionMaxY" properties
2525 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMax") == ScrollView::Property::SCROLL_PRE_POSITION_MAX );
2526 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX, Vector2(100.0f, 200.0f) );
2528 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX).Get<Vector2>(), Vector2(100.0f, 200.0f), TEST_LOCATION );
2530 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMaxX") == ScrollView::Property::SCROLL_PRE_POSITION_MAX_X );
2531 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMaxY") == ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y );
2532 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_X).Get<float>(), 100.0f, TEST_LOCATION );
2533 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y).Get<float>(), 200.0f, TEST_LOCATION );
2534 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX_X, 300.0f );
2535 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y, 400.0f );
2537 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_X).Get<float>(), 300.0f, TEST_LOCATION );
2538 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y).Get<float>(), 400.0f, TEST_LOCATION );
2539 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX).Get<Vector2>(), Vector2(300.0f, 400.0f), TEST_LOCATION );
2541 // Test "overshootX" property
2542 DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootX") == ScrollView::Property::OVERSHOOT_X );
2543 scrollView.SetProperty( ScrollView::Property::OVERSHOOT_X, 0.8f );
2545 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::OVERSHOOT_X).Get<float>(), 0.8f, TEST_LOCATION );
2547 // Test "overshootY" property
2548 DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootY") == ScrollView::Property::OVERSHOOT_Y );
2549 scrollView.SetProperty( ScrollView::Property::OVERSHOOT_Y, 0.8f );
2551 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y).Get<float>(), 0.8f, TEST_LOCATION );
2553 // Test "scrollFinal", "scrollFinalX" and "scrollFinalY" properties
2554 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinal") == ScrollView::Property::SCROLL_FINAL );
2555 scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL, Vector2(200.0f, 300.0f) );
2557 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL).Get<Vector2>(), Vector2(200.0f, 300.0f), TEST_LOCATION );
2559 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinalX") == ScrollView::Property::SCROLL_FINAL_X );
2560 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinalY") == ScrollView::Property::SCROLL_FINAL_Y );
2561 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_X).Get<float>(), 200.0f, TEST_LOCATION );
2562 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_Y).Get<float>(), 300.0f, TEST_LOCATION );
2563 scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL_X, 500.0f );
2564 scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL_Y, 600.0f );
2566 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_X).Get<float>(), 500.0f, TEST_LOCATION );
2567 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_Y).Get<float>(), 600.0f, TEST_LOCATION );
2568 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL).Get<Vector2>(), Vector2(500.0f, 600.0f), TEST_LOCATION );
2570 // Test "wrap" property
2571 DALI_TEST_CHECK( scrollView.GetPropertyIndex("wrap") == ScrollView::Property::WRAP );
2572 scrollView.SetProperty( ScrollView::Property::WRAP, false );
2574 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WRAP).Get<bool>(), false, TEST_LOCATION );
2576 // Test "panning" property
2577 DALI_TEST_CHECK( scrollView.GetPropertyIndex("panning") == ScrollView::Property::PANNING );
2578 scrollView.SetProperty( ScrollView::Property::PANNING, true );
2580 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::PANNING).Get<bool>(), true, TEST_LOCATION );
2582 // Test "scrolling" property
2583 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrolling") == ScrollView::Property::SCROLLING );
2584 scrollView.SetProperty( ScrollView::Property::SCROLLING, false );
2586 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLLING).Get<bool>(), false, TEST_LOCATION );
2588 // Test "scrollDomainSize", "scrollDomainSizeX" and "scrollDomainSizeY" properties
2589 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSize") == ScrollView::Property::SCROLL_DOMAIN_SIZE );
2590 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE, Vector2(1200.0f, 1300.0f) );
2592 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE).Get<Vector2>(), Vector2(1200.0f, 1300.0f), TEST_LOCATION );
2594 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSizeX") == ScrollView::Property::SCROLL_DOMAIN_SIZE_X );
2595 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSizeY") == ScrollView::Property::SCROLL_DOMAIN_SIZE_Y );
2596 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_X).Get<float>(), 1200.0f, TEST_LOCATION );
2597 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_Y).Get<float>(), 1300.0f, TEST_LOCATION );
2598 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE_X, 1500.0f );
2599 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE_Y, 1600.0f );
2601 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_X).Get<float>(), 1500.0f, TEST_LOCATION );
2602 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_Y).Get<float>(), 1600.0f, TEST_LOCATION );
2603 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE).Get<Vector2>(), Vector2(1500.0f, 1600.0f), TEST_LOCATION );
2605 // Test "scrollDomainOffset" property
2606 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainOffset") == ScrollView::Property::SCROLL_DOMAIN_OFFSET );
2607 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_OFFSET, Vector2(500.0f, 200.0f) );
2609 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_OFFSET).Get<Vector2>(), Vector2(500.0f, 200.0f), TEST_LOCATION );
2611 // Test "scrollPositionDelta" property
2612 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPositionDelta") == ScrollView::Property::SCROLL_POSITION_DELTA );
2613 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION_DELTA, Vector2(10.0f, 30.0f) );
2615 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION_DELTA).Get<Vector2>(), Vector2(10.0f, 30.0f), TEST_LOCATION );
2617 // Test "startPagePosition" property
2618 DALI_TEST_CHECK( scrollView.GetPropertyIndex("startPagePosition") == ScrollView::Property::START_PAGE_POSITION );
2619 scrollView.SetProperty( ScrollView::Property::START_PAGE_POSITION, Vector3(50.0f, 100.0f, 20.0f) );
2621 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::START_PAGE_POSITION).Get<Vector3>(), Vector3(50.0f, 100.0f, 20.0f), TEST_LOCATION );