2 * Copyright (c) 2019 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-toolkit/dali-toolkit.h>
22 #include <dali/integration-api/events/touch-event-integ.h>
23 #include <dali/integration-api/events/pan-gesture-event.h>
26 using namespace Toolkit;
28 void scroll_view_startup(void)
30 test_return_value = TET_UNDEF;
33 void scroll_view_cleanup(void)
35 test_return_value = TET_PASS;
40 static bool gObjectCreatedCallBackCalled;
42 static void TestCallback(BaseHandle handle)
44 gObjectCreatedCallBackCalled = true;
47 struct CallbackFunctor
49 CallbackFunctor(bool* callbackFlag)
50 : mCallbackFlag( callbackFlag )
56 *mCallbackFlag = true;
61 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
63 const int RENDER_DELAY_SCROLL = 1000; ///< duration to wait for any scroll to complete.
65 // For Clamp Signal testing...
66 const float CLAMP_EXCESS_WIDTH = 200.0f; ///< Amount of width that can be panned outside scrollview
67 const float CLAMP_EXCESS_HEIGHT = 200.0f; ///< Amount of height that can be panned outside scrollview
68 const Vector2 CLAMP_START_SCROLL_POSITION(30.0f, 100.0f); ///< Scroll start position for the Clamping tests.
69 const Vector2 CLAMP_TOUCH_START( 100.0f, 100.0f ); ///< Start point to touch from for the Clamping tests.
70 const Vector2 CLAMP_TOUCH_MOVEMENT( 5.0f, -5.0f ); ///< Amount to move touch for each frame for the Clamping tests.
71 const int CLAMP_GESTURE_FRAMES = 100; ///< Number of Frames to synthesize a gesture for the Clamping tests.
72 const Vector3 TEST_ACTOR_POSITION(100.0f, 100.0f, 0.0f); ///< A Test actor position offset (arbitrary value)
73 const Vector3 TEST_CONSTRAINT_OFFSET(1.0f, 2.0f, 0.0f); ///< A Test constraint offset (arbitrary value to test effects)
75 const float DEFAULT_SNAP_OVERSHOOT_DURATION(0.5f); ///< Default overshoot snapping animation time.
76 const float DEFAULT_MAX_OVERSHOOT(100.0f); ///< Default maximum allowed overshoot in pixels
78 const int MAX_FRAMES_TO_TEST_OVERSHOOT = 600; ///< 10 seconds (at 60 frames per second).
79 const Vector2 OVERSHOOT_START_SCROLL_POSITION(100.0f, 100.0f); ///< Scroll start position for the Overshoot tests.
80 const float SCROLL_ANIMATION_DURATION(0.33f); ///< Duration of scroll animation in Overshoot tests (i.e. 100 pixels of overshoot in the speed of 500 pixels per 100 frames, 100/(500/(100/60)) = 0.33)
81 const Vector2 SNAP_POSITION_WITH_DECELERATED_VELOCITY(74.0f, 74.0f); ///< the snap position for Overshoot tests with the decelerated velocity (i.e. Decelerated from 500 pixels per 100 frames).
82 const float TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION = 0.05f; ///< a Test duration
83 const float TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION = 1.5f; ///< another Test duration
84 const float TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION = TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * 0.5f; // Same as above, but different alpha function.
85 const float TIME_TOLERANCE = 0.05f; ///< Allow testing tolerance between a 10th of second (+/- 3 frames)
88 // Generate a PanGestureEvent to send to Core
89 Integration::PanGestureEvent GeneratePan(
91 const Vector2& previousPosition,
92 const Vector2& currentPosition,
93 unsigned long timeDelta,
94 unsigned int numberOfTouches = 1)
96 Integration::PanGestureEvent pan(state);
98 pan.previousPosition = previousPosition;
99 pan.currentPosition = currentPosition;
100 pan.timeDelta = timeDelta;
101 pan.numberOfTouches = numberOfTouches;
107 * Helper to generate PanGestureEvent
109 * @param[in] application Application instance
110 * @param[in] state The Gesture State
111 * @param[in] pos The current position of touch.
113 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
117 if( (state == Gesture::Started) ||
118 (state == Gesture::Possible) )
124 application.ProcessEvent(GeneratePan(state, last, pos, RENDER_FRAME_INTERVAL));
131 * Simulate time passed by.
133 * @note this will always process at least 1 frame (1/60 sec)
135 * @param application Test application instance
136 * @param duration Time to pass in milliseconds.
137 * @return The actual time passed in milliseconds
139 int Wait(ToolkitTestApplication& application, int duration = 0)
143 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
145 application.SendNotification();
146 application.Render(RENDER_FRAME_INTERVAL);
147 time += RENDER_FRAME_INTERVAL;
155 static bool gOnScrollStartCalled; ///< Whether the OnScrollStart signal was invoked.
156 static bool gOnScrollUpdateCalled; ///< Whether the OnScrollUpdate signal was invoked.
157 static bool gOnScrollCompleteCalled; ///< Whether the OnScrollComplete signal was invoked.
158 static bool gOnSnapStartCalled; ///< Whether the OnSnapStart signal was invoked.
159 static SnapType gLastSnapType; ///< Snaping information from SnapEvent.
160 static Vector3 gConstraintResult; ///< Result from constraint.
163 * Invoked when scrolling starts.
165 * @param[in] position The current scroll position.
167 static void OnScrollStart( const Vector2& position )
169 gOnScrollStartCalled = true;
173 * Invoked when scrolling updates (via dragging)
175 * @param[in] position The current scroll position.
177 static void OnScrollUpdate( const Vector2& position )
179 gOnScrollUpdateCalled = true;
183 * Invoked when scrolling finishes
185 * @param[in] position The current scroll position.
187 static void OnScrollComplete( const Vector2& position )
189 gOnScrollCompleteCalled = true;
193 * Invoked when a snap or flick started.
195 * @param[in] event The type of snap and the target position/scale/rotation.
197 static void OnSnapStart( const ScrollView::SnapEvent& event )
199 gOnSnapStartCalled = true;
200 gLastSnapType = event.type;
206 * Summation of current value, property, and offset.
208 * current' = current + mOffset + property;
210 struct TestSumConstraint
213 * @param[in] offset The offset to be added to current.
215 TestSumConstraint(const Vector3& offset)
221 * @param[in] current The current base value
222 * @param[in] inputs Contains the property to be added to current.
223 * @return The new current Vector.
225 void operator()( Vector3& current, const PropertyInputContainer& inputs )
227 gConstraintResult = current + Vector3(inputs[0]->GetVector2()) + mOffset;
228 current = gConstraintResult;
236 * @param[in] application The application instance
237 * @param[in] scrollView The scrollView instance
238 * @return The time taken for the overshoot to reach origin (zero)
240 static float TestOvershootSnapDuration(ToolkitTestApplication &application, ScrollView scrollView)
242 int timeToReachOrigin = -1;
243 for(int i = 0;i<MAX_FRAMES_TO_TEST_OVERSHOOT;i++)
245 float overshootXValue = scrollView.GetCurrentProperty<float>( ScrollView::Property::OVERSHOOT_X );
246 float overshootYValue = scrollView.GetCurrentProperty<float>( ScrollView::Property::OVERSHOOT_Y );
247 if(overshootXValue == 0.0f && overshootYValue == 0.0f)
252 timeToReachOrigin += Wait(application);
255 return static_cast<float>(timeToReachOrigin) * 0.001f; // return in seconds not ms.
259 * y = 2x alpha function, which is clamped between 0.0f - 1.0f
261 * Animations should appear to finish (reach 100% point)
262 * at just half the time of a regular Linear AlphaFunction.
264 * @param[in] progress value (ranges from 0.0f - 1.0f)
265 * @return interpolation value (ranges from 0.0f - 1.0f)
267 float TestAlphaFunction(float progress)
269 return std::min( progress * 2.0f, 1.0f );
272 static Vector2 PerformGestureDiagonalSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, bool finish = true)
274 gOnScrollStartCalled = false;
275 gOnScrollUpdateCalled = false;
276 gOnScrollCompleteCalled = false;
277 gOnSnapStartCalled = false;
279 // Now do a pan starting from (start) and heading (direction)
281 SendPan(application, Gesture::Possible, pos);
282 SendPan(application, Gesture::Started, pos);
285 for(int i = 0;i<frames;i++)
287 pos += direction; // Move in this direction
288 SendPan(application, Gesture::Continuing, pos);
294 pos += direction; // Move in this direction.
295 SendPan(application, Gesture::Finished, pos);
296 Wait(application, RENDER_DELAY_SCROLL);
303 } // unnamed namespace
306 int UtcDaliToolkitScrollViewConstructorP(void)
308 ToolkitTestApplication application;
310 ScrollView scrollView;
311 DALI_TEST_CHECK( !scrollView );
315 int UtcDaliToolkitScrollViewCopyConstructorP(void)
317 ToolkitTestApplication application;
319 ScrollView scrollView = ScrollView::New();
320 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) );
322 ScrollView copy( scrollView );
323 DALI_TEST_CHECK( copy );
324 DALI_TEST_CHECK( copy.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) == scrollView.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) );
328 int UtcDaliToolkitScrollViewAssignmentOperatorP(void)
330 ToolkitTestApplication application;
332 ScrollView scrollView = ScrollView::New();
333 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) );
335 ScrollView copy = scrollView;
336 DALI_TEST_CHECK( copy );
337 DALI_TEST_CHECK( copy.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) == scrollView.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) );
341 int UtcDaliScrollViewDestructorP(void)
343 ToolkitTestApplication application;
345 ScrollView* scrollView = new ScrollView();
348 DALI_TEST_CHECK( true );
352 int UtcDaliToolkitScrollViewNewP1(void)
354 ToolkitTestApplication application;
355 tet_infoline(" UtcDaliToolkitScrollViewNewP1");
357 ScrollView scrollView;
359 DALI_TEST_CHECK( !scrollView );
361 scrollView = ScrollView::New();
363 DALI_TEST_CHECK( scrollView );
365 ScrollView scrollView2(scrollView);
367 DALI_TEST_CHECK( scrollView2 == scrollView );
369 //Additional check to ensure object is created by checking if it's registered
370 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
371 DALI_TEST_CHECK( registry );
373 gObjectCreatedCallBackCalled = false;
374 registry.ObjectCreatedSignal().Connect( &TestCallback );
376 ScrollView scrollView = ScrollView::New();
378 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
382 int UtcDaliToolkitScrollViewNewP2(void)
384 ToolkitTestApplication application;
385 tet_infoline(" UtcDaliToolkitScrollViewNewP2 - create thru type registry");
387 ScrollView scrollView;
388 DALI_TEST_CHECK( !scrollView );
390 TypeRegistry typeRegistry = TypeRegistry::Get();
391 TypeInfo scrollViewType = typeRegistry.GetTypeInfo("ScrollView");
392 BaseHandle handle = scrollViewType.CreateInstance();
393 DALI_TEST_CHECK( handle );
395 scrollView = ScrollView::DownCast(handle);
396 DALI_TEST_CHECK( scrollView );
401 int UtcDaliToolkitScrollViewDownCastP(void)
403 ToolkitTestApplication application;
404 tet_infoline(" UtcDaliToolkitScrollViewDownCastP");
406 ScrollView scrollView = ScrollView::New();
407 BaseHandle handle(scrollView);
409 ScrollView newScrollView = ScrollView::DownCast( handle );
410 DALI_TEST_CHECK( scrollView );
411 DALI_TEST_CHECK( newScrollView == scrollView );
415 int UtcDaliToolkitScrollViewScrollToPositionP(void)
417 ToolkitTestApplication application;
418 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionP");
420 // Create the ScrollView actor
421 ScrollView scrollView = ScrollView::New();
422 Stage::GetCurrent().Add( scrollView );
424 const Vector2 target = Vector2(100.0f, 200.0f);
425 const Vector2 target2 = Vector2(300.0f, 100.0f);
427 scrollView.ScrollTo( target, 0.0f );
429 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
430 scrollView.ScrollTo( target2 );
431 Wait(application, RENDER_DELAY_SCROLL);
432 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
437 int UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP(void)
439 ToolkitTestApplication application;
440 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP");
442 ScrollView scrollView = ScrollView::New();
443 Stage::GetCurrent().Add( scrollView );
444 RulerPtr rulerX = new FixedRuler( 100.0f );
445 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
446 RulerPtr rulerY = new FixedRuler( 100.0f );
447 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
449 scrollView.SetRulerX( rulerX );
450 scrollView.SetRulerY( rulerY );
452 scrollView.SetWrapMode(true);
454 Property::Value wrapMode = scrollView.GetProperty( Toolkit::ScrollView::Property::WRAP_ENABLED );
455 DALI_TEST_EQUALS( wrapMode.Get<bool>(), true, TEST_LOCATION );
457 const Vector2 target = Vector2(50.0f, 50.0f);
458 const Vector2 target2 = Vector2(150.0f, 150.0f);
460 scrollView.ScrollTo( target, 0.0f );
461 Wait(application, RENDER_DELAY_SCROLL);
462 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
464 scrollView.ScrollTo( target2, 0.25f, Dali::Toolkit::DirectionBiasLeft, Dali::Toolkit::DirectionBiasLeft );
465 Wait(application, RENDER_DELAY_SCROLL);
466 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
468 scrollView.ScrollTo( target, 0.0f );
469 Wait(application, RENDER_DELAY_SCROLL);
470 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
472 scrollView.ScrollTo( target2, 0.25f, Dali::Toolkit::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
473 Wait(application, RENDER_DELAY_SCROLL);
474 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
479 int UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionP(void)
481 ToolkitTestApplication application;
482 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionP");
484 // Create the ScrollView actor
485 ScrollView scrollView = ScrollView::New();
486 Stage::GetCurrent().Add( scrollView );
488 const Vector2 target = Vector2(100.0f, 200.0f);
489 const Vector2 target2 = Vector2(300.0f, 100.0f);
491 scrollView.ScrollTo( target, 0.5f, TestAlphaFunction );
492 Wait(application, 250);
493 // Check that the scroll animation should finish within just half of the specified duration with the above alpha function
494 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
496 scrollView.ScrollTo( target2, 0.5f, AlphaFunction::LINEAR );
497 Wait(application, 250);
498 // Check that the scroll animation has not finished within half of the specified duration with the linear alpha function
499 DALI_TEST_CHECK( scrollView.GetCurrentScrollPosition() != target2 );
501 // Wait till the end of the specified duration
502 Wait(application, 250);
503 // Check that the scroll animation has finished
504 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
509 int UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionAndDirectionBiasP(void)
511 ToolkitTestApplication application;
512 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionAndDirectionBiasP");
514 ScrollView scrollView = ScrollView::New();
515 Stage::GetCurrent().Add( scrollView );
516 RulerPtr rulerX = new FixedRuler( 100.0f );
517 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
518 RulerPtr rulerY = new FixedRuler( 100.0f );
519 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
521 scrollView.SetRulerX( rulerX );
522 scrollView.SetRulerY( rulerY );
524 scrollView.SetWrapMode(true);
526 const Vector2 target = Vector2(50.0f, 50.0f);
527 const Vector2 target2 = Vector2(150.0f, 150.0f);
529 scrollView.ScrollTo( target, 0.0f );
530 Wait(application, RENDER_DELAY_SCROLL);
531 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
533 scrollView.ScrollTo( target2, 0.25f, AlphaFunction::LINEAR, Dali::Toolkit::DirectionBiasLeft, Dali::Toolkit::DirectionBiasLeft );
534 Wait(application, RENDER_DELAY_SCROLL);
535 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
537 scrollView.ScrollTo( target, 0.0f );
538 Wait(application, RENDER_DELAY_SCROLL);
539 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
541 scrollView.ScrollTo( target2, 0.25f, AlphaFunction::LINEAR, Dali::Toolkit::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
542 Wait(application, RENDER_DELAY_SCROLL);
543 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
545 scrollView.ScrollTo( target, 0.0f );
546 Wait(application, RENDER_DELAY_SCROLL);
547 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
549 scrollView.ScrollTo( target2, 0.25f, TestAlphaFunction, Dali::Toolkit::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
550 Wait(application, 125);
551 // Check that the scroll animation should finish within just half of the specified duration with the above alpha function
552 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
557 int UtcDaliToolkitScrollViewScrollToPageP(void)
559 ToolkitTestApplication application;
560 tet_infoline(" UtcDaliToolkitScrollViewScrollToPageP");
562 ScrollView scrollView = ScrollView::New();
563 Stage::GetCurrent().Add( scrollView );
564 RulerPtr rulerX = new FixedRuler( 100.0f );
565 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
566 RulerPtr rulerY = new FixedRuler( 100.0f );
567 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
569 scrollView.SetRulerX( rulerX );
570 scrollView.SetRulerY( rulerY );
572 scrollView.ScrollTo( 1, 0.0f );
574 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION );
576 scrollView.ScrollTo( 5, 0.0f );
578 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(500.0f, 0.0f), TEST_LOCATION );
580 scrollView.ScrollTo( 10, 0.0f );
582 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 100.0f), TEST_LOCATION );
584 scrollView.ScrollTo( 15, 0.0f );
586 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(700.0f, 100.0f), TEST_LOCATION );
587 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION );
589 scrollView.ScrollTo( 3 );
590 Wait(application, RENDER_DELAY_SCROLL);
591 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(300.0f, 0.0f), TEST_LOCATION );
592 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION );
594 scrollView.ScrollTo( 9 );
595 Wait(application, RENDER_DELAY_SCROLL);
596 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 100.0f), TEST_LOCATION );
597 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION );
599 // Apply DefaultRulers instead and see what happens.
600 rulerX = new DefaultRuler();
601 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
602 rulerY = new DefaultRuler();
603 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
605 scrollView.SetRulerX( rulerX );
606 scrollView.SetRulerY( rulerY );
608 // This time should always scroll to origin (0.0f, 0.0f)
609 scrollView.ScrollTo( 1, 0.0f );
611 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
612 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
618 int UtcDaliToolkitScrollModeP1(void)
620 ToolkitTestApplication application;
621 tet_infoline( " UtcDaliToolkitScrollView ScrollMode property" );
623 // Set up a scrollView.
624 ScrollView scrollView = ScrollView::New();
626 // Do not rely on stage size for UTC tests.
627 Vector2 pageSize( 720.0f, 1280.0f );
628 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
629 scrollView.SetSize( pageSize );
630 scrollView.SetParentOrigin( ParentOrigin::CENTER );
631 scrollView.SetAnchorPoint( AnchorPoint::CENTER );
632 scrollView.SetPosition( 0.0f, 0.0f, 0.0f );
635 Property::Map rulerMap;
636 rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, true );
637 rulerMap.Add( ScrollMode::X_AXIS_SNAP_TO_INTERVAL, pageSize.width );
638 rulerMap.Add( ScrollMode::X_AXIS_SCROLL_BOUNDARY, pageSize.width*3 );
639 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, false );
640 scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
642 scrollView.SetWrapMode( false );
643 scrollView.SetScrollSensitive( true );
645 Stage::GetCurrent().Add( scrollView );
647 // Set up a gesture to perform.
648 Vector2 startPos( 50.0f, 0.0f );
649 Vector2 direction( -5.0f, 0.0f );
652 // Force starting position.
653 scrollView.ScrollTo( startPos, 0.0f );
656 // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
657 Vector2 currentPos( PerformGestureDiagonalSwipe( application, startPos, direction, frames - 1, false ) );
659 // Confirm the final X coord has not moved more than one page from the start X position.
660 DALI_TEST_GREATER( ( startPos.x + pageSize.width ), scrollView.GetCurrentScrollPosition().x, TEST_LOCATION );
662 // Finish the gesture and wait for the snap.
663 currentPos += direction;
664 SendPan( application, Gesture::Finished, currentPos );
665 // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
666 Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
668 // Confirm the final X coord has snapped to exactly one page ahead of the start page.
669 DALI_TEST_EQUALS( pageSize.width, scrollView.GetCurrentScrollPosition().x, Math::MACHINE_EPSILON_0, TEST_LOCATION );
674 int UtcDaliToolkitScrollModeP2(void)
676 ToolkitTestApplication application;
677 tet_infoline( " UtcDaliToolkitScrollView ScrollMode property" );
679 // Set up a scrollView.
680 ScrollView scrollView = ScrollView::New();
682 // Do not rely on stage size for UTC tests.
683 Vector2 pageSize( 720.0f, 1280.0f );
684 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
685 scrollView.SetSize( pageSize );
686 scrollView.SetParentOrigin( ParentOrigin::CENTER );
687 scrollView.SetAnchorPoint( AnchorPoint::CENTER );
688 scrollView.SetPosition( 0.0f, 0.0f, 0.0f );
691 Property::Map rulerMap;
692 rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, false );
693 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, true );
694 rulerMap.Add( ScrollMode::Y_AXIS_SNAP_TO_INTERVAL, pageSize.height );
695 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_BOUNDARY, pageSize.height*3 );
696 scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
698 scrollView.SetWrapMode( false );
699 scrollView.SetScrollSensitive( true );
701 Stage::GetCurrent().Add( scrollView );
703 // Set up a gesture to perform.
704 Vector2 startPos( 0.0f, 50.0f );
705 Vector2 direction( 0.0f, -6.0f );
708 // Force starting position.
709 scrollView.ScrollTo( startPos, 0.0f );
712 // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
713 Vector2 currentPos( PerformGestureDiagonalSwipe( application, startPos, direction, frames - 1, false ) );
715 // Confirm the final X coord has not moved more than one page from the start X position.
716 DALI_TEST_GREATER( ( startPos.y + pageSize.height ), scrollView.GetCurrentScrollPosition().y, TEST_LOCATION );
718 // Finish the gesture and wait for the snap.
719 currentPos += direction;
720 SendPan( application, Gesture::Finished, currentPos );
721 // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
722 Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
724 // Confirm the final Y coord has snapped to exactly one page ahead of the start page.
725 DALI_TEST_EQUALS( pageSize.height, scrollView.GetCurrentScrollPosition().y, Math::MACHINE_EPSILON_0, TEST_LOCATION );
730 int UtcDaliToolkitScrollModeP3(void)
732 ToolkitTestApplication application;
733 tet_infoline( " UtcDaliToolkitScrollView ScrollMode property" );
735 // Set up a scrollView.
736 ScrollView scrollView = ScrollView::New();
738 // Do not rely on stage size for UTC tests.
739 Vector2 pageSize( 720.0f, 1280.0f );
740 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
741 scrollView.SetSize( pageSize );
742 scrollView.SetParentOrigin( ParentOrigin::CENTER );
743 scrollView.SetAnchorPoint( AnchorPoint::CENTER );
744 scrollView.SetPosition( 0.0f, 0.0f, 0.0f );
747 Property::Map rulerMap;
748 rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, false );
749 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, true );
750 rulerMap.Add( ScrollMode::Y_AXIS_SNAP_TO_INTERVAL, pageSize.height );
751 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_BOUNDARY, pageSize.height*3 );
752 scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
754 scrollView.SetWrapMode( false );
755 scrollView.SetScrollSensitive( true );
757 Stage::GetCurrent().Add( scrollView );
759 // Set up a gesture to perform.
760 Vector2 startPos( 0.0f, 50.0f );
761 Vector2 direction( 0.0f, -6.0f );
764 // Force starting position.
765 scrollView.ScrollTo( startPos, 0.0f );
768 // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
769 Vector2 currentPos( PerformGestureDiagonalSwipe( application, startPos, direction, frames - 1, false ) );
771 // Confirm the final X coord has not moved more than one page from the start X position.
772 DALI_TEST_GREATER( ( startPos.y + pageSize.height ), scrollView.GetCurrentScrollPosition().y, TEST_LOCATION );
774 // Finish the gesture and wait for the snap.
775 currentPos += direction;
776 SendPan( application, Gesture::Finished, currentPos );
777 // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
778 Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
780 // Confirm the final Y coord has snapped to exactly one page ahead of the start page.
781 DALI_TEST_EQUALS( pageSize.height, scrollView.GetCurrentScrollPosition().y, Math::MACHINE_EPSILON_0, TEST_LOCATION );
786 int UtcDaliToolkitScrollModeP4(void)
788 ToolkitTestApplication application;
789 tet_infoline( " UtcDaliToolkitScrollView ScrollMode property, DefaultRulers" );
791 // Set up a scrollView.
792 ScrollView scrollView = ScrollView::New();
794 // Do not rely on stage size for UTC tests.
795 Vector2 pageSize( 720.0f, 1280.0f );
796 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
797 scrollView.SetSize( pageSize );
798 scrollView.SetParentOrigin( ParentOrigin::TOP_LEFT );
799 scrollView.SetAnchorPoint( AnchorPoint::TOP_LEFT );
800 scrollView.SetPosition( 0.0f, 0.0f, 0.0f );
802 // Position rulers - expect Default rulers to be used which don't snap
803 Property::Map rulerMap;
804 rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, true );
805 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, true );
806 scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
808 scrollView.SetWrapMode( false );
809 scrollView.SetScrollSensitive( true );
811 Stage::GetCurrent().Add( scrollView );
813 Vector2 START_POSITION = Vector2(10.0f, 10.0f);
815 scrollView.ScrollTo(START_POSITION, 0.0f);
817 // Try a vertical swipe.
818 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
819 // Take into account resampling done when prediction is off.
820 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
826 int UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP(void)
828 ToolkitTestApplication application;
829 tet_infoline(" UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP");
831 ScrollView scrollView = ScrollView::New();
832 Stage::GetCurrent().Add( scrollView );
833 RulerPtr rulerX = new FixedRuler( 100.0f );
834 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
835 RulerPtr rulerY = new FixedRuler( 100.0f );
836 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
838 scrollView.SetRulerX( rulerX );
839 scrollView.SetRulerY( rulerY );
841 scrollView.SetWrapMode(true);
843 scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DirectionBiasLeft );
845 Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame
846 // Check that the scroll position remains the same
847 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
849 Wait(application, RENDER_DELAY_SCROLL); // Wait for one second
850 // Check that it stays at the same page (i.e. the same scroll position)
851 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
852 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
854 scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DirectionBiasRight );
856 Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame
857 // Check that it scrolls towards the right
858 DALI_TEST_CHECK( scrollView.GetCurrentScrollPosition().x > 0.0f );
860 Wait(application, RENDER_DELAY_SCROLL); // Wait for one second
861 // Check that it scrolls back to the same page (i.e. the same scroll position)
862 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
863 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
868 int UtcDaliToolkitScrollViewScrollToActorP(void)
870 ToolkitTestApplication application;
871 tet_infoline(" UtcDaliToolkitScrollViewScrollToActorP");
873 ScrollView scrollView = ScrollView::New();
874 Stage::GetCurrent().Add( scrollView );
876 Actor actorA = Actor::New();
877 const Vector3 positionA = Vector3(100.0f, 400.0f, 0.0f);
878 actorA.SetPosition(positionA);
879 scrollView.Add(actorA);
881 Actor actorB = Actor::New();
882 const Vector3 positionB = Vector3(500.0f, 200.0f, 0.0f);
883 actorB.SetPosition(positionB);
884 scrollView.Add(actorB);
888 scrollView.ScrollTo(actorA, 0.0f);
890 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION );
893 scrollView.ScrollTo(actorB, 0.0f);
895 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION );
897 scrollView.ScrollTo(actorA);
898 Wait(application, RENDER_DELAY_SCROLL);
899 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION );
901 scrollView.ScrollTo(actorB);
902 Wait(application, RENDER_DELAY_SCROLL);
903 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION );
907 int UtcDaliToolkitScrollViewScrollToSnapPointP(void)
909 ToolkitTestApplication application;
910 tet_infoline(" UtcDaliToolkitScrollViewScrollToSnapPointP");
912 ScrollView scrollView = ScrollView::New();
913 Stage::GetCurrent().Add( scrollView );
914 RulerPtr rulerX = new FixedRuler( 100.0f );
915 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
916 RulerPtr rulerY = new FixedRuler( 100.0f );
917 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
919 scrollView.SetRulerX( rulerX );
920 scrollView.SetRulerY( rulerY );
922 scrollView.ScrollTo( Vector2(120.0f, 190.0f), 0.0f );
924 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(120.0f, 190.0f), TEST_LOCATION );
926 scrollView.ScrollToSnapPoint();
928 Wait(application, RENDER_DELAY_SCROLL);
929 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 200.0f), TEST_LOCATION );
933 int UtcDaliToolkitScrollViewSetScrollUpdateDistanceP(void)
935 ToolkitTestApplication application;
936 tet_infoline(" UtcDaliToolkitScrollViewSetScrollUpdateDistanceP");
938 ScrollView scrollView = ScrollView::New();
940 scrollView.SetScrollUpdateDistance(0);
941 DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 0, TEST_LOCATION);
942 scrollView.SetScrollUpdateDistance(10);
943 DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 10, TEST_LOCATION);
944 scrollView.SetScrollUpdateDistance(1000);
945 DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 1000, TEST_LOCATION);
949 int UtcDaliToolkitScrollViewSetWrapModeP(void)
951 ToolkitTestApplication application;
952 tet_infoline(" UtcDaliToolkitScrollViewSetWrapModeP");
954 ScrollView scrollView = ScrollView::New();
955 Stage::GetCurrent().Add( scrollView );
957 Actor actor = Actor::New();
958 scrollView.Add( actor );
960 // Position rulers. 4x4 grid.
961 RulerPtr rulerX = new FixedRuler(50.0f);
962 RulerPtr rulerY = new FixedRuler(50.0f);
963 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, false) );
964 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, false) );
965 scrollView.SetRulerX(rulerX);
966 scrollView.SetRulerY(rulerY);
968 scrollView.SetWrapMode(false);
969 scrollView.ScrollTo(Vector2(225.0f, 125.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
971 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 17, TEST_LOCATION );
973 scrollView.SetWrapMode(true);
974 scrollView.ScrollTo(Vector2(230.0f, 130.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
976 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 13, TEST_LOCATION );
980 int UtcDaliToolkitScrollViewActorAutoSnap(void)
982 ToolkitTestApplication application;
983 tet_infoline(" UtcDaliToolkitScrollViewActorAutoSnap");
985 ScrollView scrollView = ScrollView::New();
986 Stage::GetCurrent().Add( scrollView );
989 RulerPtr rulerX = new DefaultRuler();
990 RulerPtr rulerY = new DefaultRuler();
991 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
992 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
993 scrollView.SetRulerX(rulerX);
994 scrollView.SetRulerY(rulerY);
996 const Vector3 aPosition = Vector3(200.0f, 50.0f, 0.0f);
997 Actor a = Actor::New();
999 a.SetPosition(aPosition);
1001 const Vector3 bPosition = Vector3(600.0f, 600.0f, 0.0f);
1002 Actor b = Actor::New();
1004 b.SetPosition(bPosition);
1006 // Goto a random position, and execute snap (should not move)
1007 Vector2 targetScroll = Vector2(500.0f, 500.0f);
1008 scrollView.ScrollTo(targetScroll, 0.0f);
1010 scrollView.ScrollToSnapPoint();
1011 Wait(application, RENDER_DELAY_SCROLL);
1012 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), targetScroll, TEST_LOCATION );
1014 // Enable ActorAutoSnap, and now try snapping.
1015 scrollView.SetActorAutoSnap(true);
1016 scrollView.ScrollToSnapPoint();
1017 Wait(application, RENDER_DELAY_SCROLL);
1018 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), bPosition.GetVectorXY(), TEST_LOCATION );
1020 scrollView.ScrollTo(Vector2(0.0f, 0.0f), 0.0f);
1022 scrollView.ScrollToSnapPoint();
1023 Wait(application, RENDER_DELAY_SCROLL);
1024 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), aPosition.GetVectorXY(), TEST_LOCATION );
1028 int UtcDaliToolkitScrollViewSignalsStartComplete(void)
1030 ToolkitTestApplication application;
1031 tet_infoline(" UtcDaliToolkitScrollViewSignalsStartComplete");
1033 gOnScrollStartCalled = false;
1034 gOnScrollCompleteCalled = false;
1036 ScrollView scrollView = ScrollView::New();
1037 Stage::GetCurrent().Add( scrollView );
1040 RulerPtr rulerX = new DefaultRuler();
1041 RulerPtr rulerY = new DefaultRuler();
1042 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1043 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1044 scrollView.SetRulerX(rulerX);
1045 scrollView.SetRulerY(rulerY);
1046 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1047 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1048 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1049 scrollView.ScrollTo( Vector2(100.0f, 100.0f) );
1050 Wait(application, RENDER_DELAY_SCROLL);
1052 DALI_TEST_CHECK(gOnScrollStartCalled);
1053 DALI_TEST_CHECK(gOnScrollCompleteCalled);
1057 int UtcDaliToolkitScrollViewSignalsUpdate01(void)
1059 ToolkitTestApplication application;
1060 tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate");
1062 gOnScrollStartCalled = false;
1063 gOnScrollUpdateCalled = false;
1064 gOnScrollCompleteCalled = false;
1066 ScrollView scrollView = ScrollView::New();
1067 Stage::GetCurrent().Add( scrollView );
1068 Vector2 stageSize = Stage::GetCurrent().GetSize();
1069 scrollView.SetSize(stageSize);
1070 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1071 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1074 RulerPtr rulerX = new DefaultRuler();
1075 RulerPtr rulerY = new DefaultRuler();
1076 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1077 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1078 scrollView.SetRulerX(rulerX);
1079 scrollView.SetRulerY(rulerY);
1080 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1081 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1082 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1084 Actor image = Actor::New();
1085 image.SetSize(stageSize);
1086 image.SetParentOrigin(ParentOrigin::TOP_LEFT);
1087 image.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1088 scrollView.Add(image);
1092 // Do a pan starting from 100,100 and moving down diagonally.
1093 Vector2 pos(100.0f, 100.0f);
1094 SendPan(application, Gesture::Possible, pos);
1095 SendPan(application, Gesture::Started, pos);
1098 Wait(application, 100);
1100 for(int i = 0;i<20;i++)
1102 SendPan(application, Gesture::Continuing, pos);
1108 SendPan(application, Gesture::Finished, pos);
1109 Wait(application, RENDER_DELAY_SCROLL);
1111 DALI_TEST_CHECK(gOnScrollStartCalled);
1112 DALI_TEST_CHECK(gOnScrollUpdateCalled);
1113 DALI_TEST_CHECK(gOnScrollCompleteCalled);
1117 int UtcDaliToolkitScrollViewSignalsUpdate02(void)
1119 ToolkitTestApplication application;
1120 tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate");
1122 gOnScrollStartCalled = false;
1123 gOnScrollUpdateCalled = false;
1124 gOnScrollCompleteCalled = false;
1126 ScrollView scrollView = ScrollView::New();
1127 Stage::GetCurrent().Add( scrollView );
1128 Vector2 stageSize = Stage::GetCurrent().GetSize();
1129 scrollView.SetSize(stageSize);
1130 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1131 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1134 RulerPtr rulerX = new DefaultRuler();
1135 RulerPtr rulerY = new DefaultRuler();
1136 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1137 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1138 scrollView.SetRulerX(rulerX);
1139 scrollView.SetRulerY(rulerY);
1140 Dali::ConnectionTracker tracker;
1141 bool scrollStarted=false;
1142 bool scrollUpdated=false;
1143 bool scrollCompleted=false;
1144 DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollStarted", CallbackFunctor(&scrollStarted) ));
1145 DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollUpdated", CallbackFunctor(&scrollUpdated) ));
1146 DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollCompleted", CallbackFunctor(&scrollCompleted) ));
1148 Actor image = Actor::New();
1149 image.SetSize(stageSize);
1150 image.SetParentOrigin(ParentOrigin::TOP_LEFT);
1151 image.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1152 scrollView.Add(image);
1156 // Do a pan starting from 100,100 and moving down diagonally.
1157 Vector2 pos(100.0f, 100.0f);
1158 SendPan(application, Gesture::Possible, pos);
1159 SendPan(application, Gesture::Started, pos);
1162 Wait(application, 100);
1164 for(int i = 0;i<20;i++)
1166 SendPan(application, Gesture::Continuing, pos);
1172 SendPan(application, Gesture::Finished, pos);
1173 Wait(application, RENDER_DELAY_SCROLL);
1175 DALI_TEST_CHECK(scrollStarted);
1176 DALI_TEST_CHECK(scrollUpdated);
1177 DALI_TEST_CHECK(scrollCompleted);
1179 Stage::GetCurrent().Remove( scrollView );
1184 int UtcDaliToolkitScrollViewScrollSensitive(void)
1186 ToolkitTestApplication application;
1187 tet_infoline(" UtcDaliToolkitScrollViewScrollSensitive");
1189 // Set up a scrollView...
1190 ScrollView scrollView = ScrollView::New();
1191 scrollView.SetOvershootEnabled(true);
1192 Stage::GetCurrent().Add( scrollView );
1193 Vector2 stageSize = Stage::GetCurrent().GetSize();
1194 scrollView.SetSize(stageSize);
1195 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1196 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1199 RulerPtr rulerX = new DefaultRuler();
1200 RulerPtr rulerY = new DefaultRuler();
1201 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1202 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1203 scrollView.SetRulerX(rulerX);
1204 scrollView.SetRulerY(rulerY);
1205 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1206 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1207 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1208 scrollView.SnapStartedSignal().Connect( &OnSnapStart );
1210 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1213 // First try insensitive swipe.
1214 scrollView.SetScrollSensitive(false);
1215 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, true);
1217 DALI_TEST_CHECK( !gOnScrollStartCalled );
1218 DALI_TEST_CHECK( !gOnScrollCompleteCalled );
1219 DALI_TEST_CHECK( !gOnSnapStartCalled );
1221 // Second try sensitive swipe.
1222 scrollView.SetScrollSensitive(true);
1223 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, true);
1225 DALI_TEST_CHECK( gOnScrollStartCalled );
1226 DALI_TEST_CHECK( gOnScrollCompleteCalled );
1227 DALI_TEST_CHECK( gOnSnapStartCalled );
1231 int UtcDaliToolkitScrollViewAxisAutoLock(void)
1233 ToolkitTestApplication application;
1234 tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLock");
1236 // Set up a scrollView...
1237 ScrollView scrollView = ScrollView::New();
1238 Stage::GetCurrent().Add( scrollView );
1239 Vector2 stageSize = Stage::GetCurrent().GetSize();
1240 scrollView.SetSize(stageSize);
1241 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1242 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1245 RulerPtr rulerX = new DefaultRuler();
1246 RulerPtr rulerY = new DefaultRuler();
1247 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1248 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1249 scrollView.SetRulerX(rulerX);
1250 scrollView.SetRulerY(rulerY);
1251 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1252 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1253 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1256 scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
1258 Vector2 startPosition = scrollView.GetCurrentScrollPosition();
1259 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(5.0f, 1.0f), 50, true); // mostly horizontal
1260 const Vector2 positionAfterNormal = scrollView.GetCurrentScrollPosition();
1263 scrollView.SetAxisAutoLock(true);
1264 DALI_TEST_CHECK(scrollView.GetAxisAutoLock());
1266 scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
1268 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(5.0f, 1.0f), 50, true); // mostly horizontal
1269 const Vector2 positionAfterAutoLock = scrollView.GetCurrentScrollPosition();
1271 // compare how much the Y position has deviated for normal and autolock.
1272 const float devianceNormal = fabsf(startPosition.y - positionAfterNormal.y);
1273 const float devianceAutoLock = fabsf(startPosition.y - positionAfterAutoLock.y);
1275 // in auto-lock it should be a mostly horizontal pan (thus deviance should be much lower)
1276 DALI_TEST_CHECK(devianceAutoLock < devianceNormal);
1278 scrollView.SetAxisAutoLock(false);
1279 DALI_TEST_CHECK(!scrollView.GetAxisAutoLock());
1283 int UtcDaliToolkitScrollViewAxisAutoLockGradient(void)
1285 ToolkitTestApplication application;
1286 tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLockGradient");
1288 // Set up a scrollView...
1289 ScrollView scrollView = ScrollView::New();
1290 scrollView.SetAxisAutoLockGradient(0.5f);
1291 DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 0.5f, TEST_LOCATION);
1292 scrollView.SetAxisAutoLockGradient(1.0f);
1293 DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 1.0f, TEST_LOCATION);
1297 int UtcDaliToolkitScrollViewConstraints(void)
1299 ToolkitTestApplication application;
1300 tet_infoline(" UtcDaliToolkitScrollViewConstraints");
1302 // Set up a scrollView...
1303 ScrollView scrollView = ScrollView::New();
1304 Stage::GetCurrent().Add( scrollView );
1305 Vector2 stageSize = Stage::GetCurrent().GetSize();
1306 scrollView.SetSize(stageSize);
1307 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1308 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1311 RulerPtr rulerX = new DefaultRuler();
1312 RulerPtr rulerY = new DefaultRuler();
1313 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1314 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1315 scrollView.SetRulerX(rulerX);
1316 scrollView.SetRulerY(rulerY);
1318 // Add an Actor to ScrollView,
1319 // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1320 gConstraintResult = Vector3::ZERO;
1321 Actor a = Actor::New();
1323 a.SetPosition( TEST_ACTOR_POSITION );
1326 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1327 constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
1328 constraint.SetRemoveAction(Constraint::Discard);
1329 scrollView.ApplyConstraintToChildren(constraint);
1332 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1334 gConstraintResult = Vector3::ZERO;
1335 scrollView.RemoveConstraintsFromChildren();
1338 DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
1342 int UtcDaliToolkitScrollViewBind(void)
1344 ToolkitTestApplication application;
1345 tet_infoline(" UtcDaliToolkitScrollViewBind");
1347 // Set up a scrollView...
1348 ScrollView scrollView = ScrollView::New();
1349 Stage::GetCurrent().Add( scrollView );
1350 Vector2 stageSize = Stage::GetCurrent().GetSize();
1351 scrollView.SetSize(stageSize);
1352 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1353 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1356 RulerPtr rulerX = new DefaultRuler();
1357 RulerPtr rulerY = new DefaultRuler();
1358 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1359 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1360 scrollView.SetRulerX(rulerX);
1361 scrollView.SetRulerY(rulerY);
1363 // Add an Actor to ScrollView,
1364 // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1366 gConstraintResult = Vector3::ZERO;
1367 Actor a = Actor::New();
1369 a.SetPosition( TEST_ACTOR_POSITION );
1372 // apply this constraint to scrollview
1373 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1374 constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
1375 constraint.SetRemoveAction(Constraint::Discard);
1376 scrollView.ApplyConstraintToChildren(constraint);
1380 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1383 gConstraintResult = Vector3::ZERO;
1384 scrollView.UnbindActor( a );
1386 DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
1389 gConstraintResult = Vector3::ZERO;
1390 scrollView.BindActor( a );
1392 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1396 int UtcDaliToolkitScrollViewOvershoot(void)
1398 ToolkitTestApplication application;
1399 tet_infoline(" UtcDaliToolkitScrollViewOvershoot");
1401 // Set up a scrollView...
1402 ScrollView scrollView = ScrollView::New();
1403 scrollView.SetOvershootEnabled(true);
1405 Vector2 overshootSize = Vector2(100.0f,100.0f);
1406 scrollView.SetProperty( Scrollable::Property::OVERSHOOT_SIZE, overshootSize );
1407 DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_SIZE).Get<Vector2>(), overshootSize, TEST_LOCATION );
1409 Stage::GetCurrent().Add( scrollView );
1410 Vector2 stageSize = Stage::GetCurrent().GetSize();
1411 scrollView.SetSize(stageSize);
1412 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1413 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1416 RulerPtr rulerX = new DefaultRuler();
1417 RulerPtr rulerY = new DefaultRuler();
1418 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1419 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1420 scrollView.SetRulerX(rulerX);
1421 scrollView.SetRulerY(rulerY);
1422 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1423 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1424 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1426 scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1429 // 1. Scroll page in NW (-500,-500 pixels), then inspect overshoot. (don't release touch)
1430 Vector2 currentPos = Vector2(100.0f, 100.0f);
1431 currentPos = PerformGestureDiagonalSwipe(application, currentPos, Vector2(5.0f, 5.0f), 100, false);
1432 float overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1433 float overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1434 Vector2 positionValue = scrollView.GetCurrentProperty< Vector2 >( ScrollView::Property::SCROLL_POSITION );
1435 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1436 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1437 DALI_TEST_EQUALS(positionValue, Vector2::ZERO, TEST_LOCATION);
1439 float timeToReachOrigin;
1441 // Now release touch. Overshoot should snap back to zero.
1442 SendPan(application, Gesture::Finished, currentPos);
1443 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1445 float minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1446 float maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1448 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1449 (timeToReachOrigin < maxTimeToReachOrigin) );
1451 // 2. Repeat Scroll, but this time change overshoot snap duration to shorter time
1452 scrollView.SetSnapOvershootDuration(TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION);
1454 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1455 // Now release touch. Overshoot should snap back to zero.
1456 SendPan(application, Gesture::Finished, currentPos);
1457 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1459 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1460 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1462 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1463 (timeToReachOrigin < maxTimeToReachOrigin) );
1465 // 3. Repeat Scroll, but this time change overshoot snap duration to longer time.
1466 scrollView.SetSnapOvershootDuration(TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION);
1468 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1469 // Now release touch. Overshoot should snap back to zero.
1470 SendPan(application, Gesture::Finished, currentPos);
1471 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1473 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1474 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1476 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1477 (timeToReachOrigin < maxTimeToReachOrigin) );
1479 // 4. Repeat Scroll, but this time change overshoot function.
1480 scrollView.SetSnapOvershootDuration(TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION);
1481 scrollView.SetSnapOvershootAlphaFunction(TestAlphaFunction);
1483 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1484 // Now release touch. Overshoot should snap back to zero.
1485 SendPan(application, Gesture::Finished, currentPos);
1486 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1488 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1489 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1491 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1492 (timeToReachOrigin < maxTimeToReachOrigin) );
1496 int UtcDaliToolkitScrollViewSnapAlphaFunction(void)
1498 ToolkitTestApplication application;
1499 tet_infoline(" UtcDaliToolkitScrollViewSnapAlphaFunction");
1501 // Set up a scrollView...
1502 ScrollView scrollView = ScrollView::New();
1503 scrollView.SetScrollSnapAlphaFunction( AlphaFunction::EASE_IN );
1504 DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_IN );
1505 scrollView.SetScrollSnapAlphaFunction( AlphaFunction::EASE_OUT );
1506 DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_OUT );
1508 scrollView.SetScrollFlickAlphaFunction( AlphaFunction::BOUNCE );
1509 DALI_TEST_CHECK( scrollView.GetScrollFlickAlphaFunction().GetBuiltinFunction() == AlphaFunction::BOUNCE );
1514 int UtcDaliToolkitScrollViewSnapDuration(void)
1516 ToolkitTestApplication application;
1517 tet_infoline(" UtcDaliToolkitScrollViewSnapDuration");
1519 // Set up a scrollView...
1520 ScrollView scrollView = ScrollView::New();
1521 scrollView.SetScrollSnapDuration( 1.0f );
1522 DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 1.0f, TEST_LOCATION );
1523 scrollView.SetScrollSnapDuration( 0.5f );
1524 DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 0.5f, TEST_LOCATION );
1526 scrollView.SetScrollFlickDuration( 2.0f );
1527 DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 2.0f, TEST_LOCATION );
1528 scrollView.SetScrollFlickDuration( 1.5f );
1529 DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 1.5f, TEST_LOCATION );
1533 int UtcDaliToolkitScrollViewSnapStartedSignalP(void)
1535 ToolkitTestApplication application;
1536 tet_infoline(" UtcDaliToolkitScrollViewSnapStartedSignalP");
1538 // Set up a scrollView...
1539 ScrollView scrollView = ScrollView::New();
1540 Stage::GetCurrent().Add( scrollView );
1541 Vector2 stageSize = Stage::GetCurrent().GetSize();
1542 scrollView.SetSize(stageSize);
1543 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1544 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1547 RulerPtr rulerX = new DefaultRuler();
1548 RulerPtr rulerY = new DefaultRuler();
1549 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1550 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1551 scrollView.SetRulerX(rulerX);
1552 scrollView.SetRulerY(rulerY);
1553 scrollView.SnapStartedSignal().Connect( &OnSnapStart );
1555 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1558 // First try a snap.
1559 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(0.5f, 0.0f), 60, true);
1561 DALI_TEST_CHECK( gOnSnapStartCalled );
1562 DALI_TEST_CHECK( gLastSnapType == Toolkit::Snap );
1564 // Second try a swipe.
1565 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(20.0f, 0.0f), 60, true);
1567 DALI_TEST_CHECK( gOnSnapStartCalled );
1568 DALI_TEST_CHECK( gLastSnapType == Toolkit::Flick );
1572 int UtcDaliToolkitScrollViewGetCurrentPageP(void)
1574 ToolkitTestApplication application;
1575 tet_infoline(" UtcDaliToolkitScrollViewGetCurrentPageP");
1577 ScrollView scrollView = ScrollView::New();
1578 Stage::GetCurrent().Add( scrollView );
1579 RulerPtr rulerX = new FixedRuler( 100.0f );
1580 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1581 RulerPtr rulerY = new FixedRuler( 100.0f );
1582 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1584 scrollView.SetRulerX( rulerX );
1585 scrollView.SetRulerY( rulerY );
1587 scrollView.ScrollTo( 15 );
1588 Wait(application, RENDER_DELAY_SCROLL);
1589 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION );
1591 scrollView.ScrollTo( 3 );
1592 Wait(application, RENDER_DELAY_SCROLL);
1593 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION );
1595 scrollView.ScrollTo( 9 );
1596 Wait(application, RENDER_DELAY_SCROLL);
1597 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION );
1602 int UtcDaliToolkitScrollViewSetMaxOvershootP(void)
1604 ToolkitTestApplication application;
1605 tet_infoline(" UtcDaliToolkitScrollViewSetMaxOvershootP");
1607 // Set up a scrollView...
1608 ScrollView scrollView = ScrollView::New();
1609 Stage::GetCurrent().Add( scrollView );
1610 Vector2 stageSize = Stage::GetCurrent().GetSize();
1611 scrollView.SetSize(stageSize);
1612 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1613 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1616 RulerPtr rulerX = new DefaultRuler();
1617 RulerPtr rulerY = new DefaultRuler();
1618 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1619 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1620 scrollView.SetRulerX(rulerX);
1621 scrollView.SetRulerY(rulerY);
1623 // Set the max overshoot to be 50 pixels in both X axis and Y axis
1624 scrollView.SetMaxOvershoot(50.0f, 50.0f);
1626 scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1629 // Scroll page in NW (-20,-20 pixels), then check that overshoot should be 0. (don't release touch)
1630 Vector2 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 20, false);
1631 float overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1632 float overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1633 DALI_TEST_EQUALS(overshootXValue, 0.0f, TEST_LOCATION);
1634 DALI_TEST_EQUALS(overshootYValue, 0.0f, TEST_LOCATION);
1636 // Scroll page further in NW (-105,-105 pixels), then check that overshoot should be around 0.5. (don't release touch)
1637 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 105, false);
1638 overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1639 overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1640 // The overshoot value is a 0.0f - 1.0f ranged value of the amount overshot related to the maximum overshoot.
1641 // EG. If we move 105, max overshoot is 50, then we overshot 50 / 105.
1642 float correctOvershootValue = 50.0f / 105.f;
1643 DALI_TEST_EQUALS( overshootXValue, correctOvershootValue, 0.001f, TEST_LOCATION );
1644 DALI_TEST_EQUALS( overshootYValue, correctOvershootValue, 0.001f, TEST_LOCATION );
1646 // Scroll page further in NW (-30,-30 pixels), then check that overshoot should be now 1.0. (don't release touch)
1647 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 30, false);
1648 overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1649 overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1650 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1651 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1653 // Change the max overshoot to be 100 pixels in both X axis and Y axis
1654 scrollView.SetMaxOvershoot(100.0f, 100.0f);
1657 // Check that overshoot should be now around 0.8.
1658 overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1659 overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1660 DALI_TEST_CHECK(overshootXValue > 0.79f && overshootXValue < 0.81f);
1661 DALI_TEST_CHECK(overshootYValue > 0.79f && overshootYValue < 0.81f);
1663 // Scroll page further in NW (-30,-30 pixels), then check that overshoot should be now 1.0. (don't release touch)
1664 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 30, false);
1665 overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1666 overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1667 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1668 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1673 int UtcDaliToolkitScrollViewSetScrollingDirectionP(void)
1675 ToolkitTestApplication application;
1676 tet_infoline(" UtcDaliToolkitScrollViewSetScrollingDirectionP");
1678 // Set up a scrollView...
1679 ScrollView scrollView = ScrollView::New();
1680 Stage::GetCurrent().Add( scrollView );
1681 Vector2 stageSize = Stage::GetCurrent().GetSize();
1682 scrollView.SetSize(stageSize);
1683 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1684 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1686 Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1688 scrollView.ScrollTo(START_POSITION, 0.0f);
1690 // Try a vertical swipe.
1691 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1692 // Take into account resampling done when prediction is off.
1693 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1695 scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1697 scrollView.ScrollTo(START_POSITION, 0.0f);
1699 // Try a vertical swipe.
1700 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1701 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION );
1703 scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1705 scrollView.ScrollTo(Vector2(10.0f, 10.0f), 0.0f);
1707 // Try a vertical swipe.
1708 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1709 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1714 int UtcDaliToolkitScrollViewRemoveScrollingDirectionP(void)
1716 ToolkitTestApplication application;
1717 tet_infoline(" UtcDaliToolkitScrollViewRemoveScrollingDirectionP");
1719 // Set up a scrollView...
1720 ScrollView scrollView = ScrollView::New();
1721 Stage::GetCurrent().Add( scrollView );
1722 Vector2 stageSize = Stage::GetCurrent().GetSize();
1723 scrollView.SetSize(stageSize);
1724 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1725 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1727 Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1729 scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1731 scrollView.ScrollTo(START_POSITION, 0.0f);
1733 // Try a vertical swipe.
1734 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1735 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION );
1737 scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1739 scrollView.ScrollTo(Vector2(10.0f, 10.0f), 0.0f);
1741 // Try a vertical swipe.
1742 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1743 // Take into account resampling done when prediction is off.
1744 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1749 int UtcDaliToolkitScrollViewSetRulerXP(void)
1751 ToolkitTestApplication application;
1752 tet_infoline(" UtcDaliToolkitScrollViewSetRulerXP");
1754 ScrollView scrollView = ScrollView::New();
1755 Stage::GetCurrent().Add( scrollView );
1756 RulerPtr rulerX = new FixedRuler( 100.0f );
1757 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1759 scrollView.SetRulerX( rulerX );
1761 scrollView.ScrollTo( 1, 0.0f );
1763 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION );
1765 RulerPtr newRulerX = new FixedRuler( 200.0f );
1766 newRulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1768 scrollView.SetRulerX( newRulerX );
1770 scrollView.ScrollTo( 1, 0.0f );
1772 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 0.0f), TEST_LOCATION );
1777 int UtcDaliToolkitScrollViewSetRulerYP(void)
1779 ToolkitTestApplication application;
1780 tet_infoline(" UtcDaliToolkitScrollViewSetRulerYP");
1782 ScrollView scrollView = ScrollView::New();
1783 Stage::GetCurrent().Add( scrollView );
1785 RulerPtr rulerY = new FixedRuler( 200.0f );
1786 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1788 scrollView.SetRulerY( rulerY );
1790 scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f );
1792 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 350.0f), TEST_LOCATION );
1794 RulerPtr newRulerY = new FixedRuler( 100.0f );
1795 newRulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
1796 scrollView.SetRulerY( newRulerY );
1798 scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f );
1800 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 200.0f), TEST_LOCATION );
1805 int UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP(void)
1807 ToolkitTestApplication application;
1808 tet_infoline(" UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP");
1810 ScrollView scrollView = ScrollView::New();
1811 scrollView.SetMinimumSpeedForFlick(25.0f);
1812 DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 25.0f, TEST_LOCATION );
1813 scrollView.SetMinimumSpeedForFlick(60.0f);
1814 DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 60.0f, TEST_LOCATION );
1818 int UtcDaliToolkitScrollViewSetMinimumDistanceForFlickP(void)
1820 ToolkitTestApplication application;
1821 tet_infoline(" UtcDaliToolkitScrollViewSetMinimumDistanceForFlick");
1823 ScrollView scrollView = ScrollView::New();
1825 scrollView.SetMinimumDistanceForFlick(Vector2(30.0f, 15.0f));
1826 DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(30.0f, 15.0f), TEST_LOCATION );
1827 scrollView.SetMinimumDistanceForFlick(Vector2(60.0f, 30.0f));
1828 DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(60.0f, 30.0f), TEST_LOCATION);
1832 int UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP(void)
1834 ToolkitTestApplication application;
1835 tet_infoline(" UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP");
1837 ScrollView scrollView = ScrollView::New();
1838 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
1839 scrollView.SetWheelScrollDistanceStep(Vector2(30.0f, 15.0f));
1840 DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(30.0f, 15.0f), TEST_LOCATION );
1841 scrollView.SetWheelScrollDistanceStep(Vector2(60.0f, 30.0f));
1842 DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(60.0f, 30.0f), TEST_LOCATION);
1846 int UtcDaliToolkitScrollViewApplyEffectP(void)
1848 ToolkitTestApplication application;
1849 tet_infoline(" UtcDaliToolkitScrollViewApplyEffectP");
1851 // Create a ScrollView
1852 ScrollView scrollView = ScrollView::New();
1854 // Create two scroll view effects
1855 Dali::Path path = Dali::Path::New();
1856 ScrollViewEffect effect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 0.0f, 0.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(100.0f, 100.0f, 0.0f), 2);
1857 ScrollViewEffect newEffect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 1.0f, 1.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(200.0f, 150.0f, 0.0f), 5);
1859 // Apply both effects
1860 scrollView.ApplyEffect(effect);
1861 scrollView.ApplyEffect(newEffect);
1863 DALI_TEST_CHECK( true );
1868 int UtcDaliToolkitScrollViewApplyEffectN(void)
1870 ToolkitTestApplication application;
1871 tet_infoline(" UtcDaliToolkitScrollViewApplyEffectN");
1873 // Create a ScrollView
1874 ScrollView scrollView = ScrollView::New();
1876 // Create two scroll view effects
1877 Dali::Path path = Dali::Path::New();
1878 ScrollViewEffect effect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 0.0f, 0.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(100.0f, 100.0f, 0.0f), 2);
1879 ScrollViewEffect newEffect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 1.0f, 1.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(200.0f, 150.0f, 0.0f), 5);
1881 // Apply both effects
1882 scrollView.ApplyEffect(effect);
1883 scrollView.ApplyEffect(newEffect);
1885 // Attempt to apply the same effect again
1888 scrollView.ApplyEffect(newEffect);
1889 tet_result( TET_FAIL );
1891 catch ( DaliException& e )
1893 DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
1899 int UtcDaliToolkitScrollViewRemoveEffectP(void)
1901 ToolkitTestApplication application;
1902 tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectP");
1904 // Create a ScrollView
1905 ScrollView scrollView = ScrollView::New();
1907 // Create two scroll view effects
1908 Dali::Path path = Dali::Path::New();
1909 ScrollViewEffect effect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 0.0f, 0.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(100.0f, 100.0f, 0.0f), 2);
1910 ScrollViewEffect newEffect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 1.0f, 1.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(200.0f, 150.0f, 0.0f), 5);
1912 // Apply both effects
1913 scrollView.ApplyEffect(effect);
1914 scrollView.ApplyEffect(newEffect);
1916 // Remove both effects
1917 scrollView.RemoveEffect(effect);
1918 scrollView.RemoveEffect(newEffect);
1920 DALI_TEST_CHECK( true );
1925 int UtcDaliToolkitScrollViewRemoveEffectN(void)
1927 ToolkitTestApplication application;
1928 tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectN");
1930 // Create a ScrollView
1931 ScrollView scrollView = ScrollView::New();
1933 // Create two scroll view effects
1934 Dali::Path path = Dali::Path::New();
1935 ScrollViewEffect effect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 0.0f, 0.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(100.0f, 100.0f, 0.0f), 2);
1936 ScrollViewEffect newEffect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 1.0f, 1.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(200.0f, 150.0f, 0.0f), 5);
1938 // Apply the first effect
1939 scrollView.ApplyEffect(effect);
1941 // Attempt to remove the second effect which has not been applied to scroll view
1944 scrollView.RemoveEffect(newEffect);
1945 tet_result( TET_FAIL );
1947 catch ( DaliException& e )
1949 DALI_TEST_ASSERT( e, "effectExistedInScrollView", TEST_LOCATION );
1955 int UtcDaliToolkitScrollViewRemoveAllEffectsP(void)
1957 ToolkitTestApplication application;
1958 tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsP");
1960 // Create a ScrollView
1961 ScrollView scrollView = ScrollView::New();
1963 // Create two scroll view effects
1964 Dali::Path path = Dali::Path::New();
1965 ScrollViewEffect effect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 0.0f, 0.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(100.0f, 100.0f, 0.0f), 2);
1966 ScrollViewEffect newEffect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 1.0f, 1.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(200.0f, 150.0f, 0.0f), 5);
1968 // Apply both effects
1969 scrollView.ApplyEffect(effect);
1970 scrollView.ApplyEffect(newEffect);
1972 // Attempt to apply the same first effect again
1975 scrollView.ApplyEffect(effect);
1976 tet_result( TET_FAIL );
1978 catch ( DaliException& e )
1980 DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
1983 // Remove both effects
1984 scrollView.RemoveAllEffects();
1986 // Apply both effects again
1987 scrollView.ApplyEffect(effect);
1988 scrollView.ApplyEffect(newEffect);
1990 DALI_TEST_CHECK( true );
1995 int UtcDaliToolkitScrollViewRemoveAllEffectsN(void)
1997 ToolkitTestApplication application;
1998 tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsN");
2000 // Create a ScrollView
2001 ScrollView scrollView = ScrollView::New();
2003 // Remove effects when there is no effect applied previously
2004 scrollView.RemoveAllEffects();
2006 DALI_TEST_CHECK( true );
2011 int UtcDaliToolkitScrollViewSetOvershootEnabledP(void)
2013 ToolkitTestApplication application;
2014 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEnabledP");
2016 ScrollView scrollView = ScrollView::New();
2018 scrollView.SetOvershootEnabled(true);
2019 DALI_TEST_CHECK(scrollView.IsOvershootEnabled());
2021 scrollView.SetOvershootEnabled(false);
2022 DALI_TEST_CHECK(!scrollView.IsOvershootEnabled());
2027 int UtcDaliToolkitScrollViewSetOvershootEffectColorP(void)
2029 ToolkitTestApplication application;
2030 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEffectColorP");
2032 ScrollView scrollView = ScrollView::New();
2034 scrollView.SetOvershootEffectColor(Dali::Color::RED);
2035 DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::RED, TEST_LOCATION);
2037 scrollView.SetOvershootEffectColor(Dali::Color::YELLOW);
2038 DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::YELLOW, TEST_LOCATION);
2043 int UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP(void)
2045 ToolkitTestApplication application;
2046 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP");
2048 ScrollView scrollView = ScrollView::New();
2050 scrollView.SetOvershootAnimationSpeed(55.0f);
2051 DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 55.0f, TEST_LOCATION);
2053 scrollView.SetOvershootAnimationSpeed(120.0f);
2054 DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 120.0f, TEST_LOCATION);
2059 int UtcDaliToolkitScrollViewGetSet(void)
2061 ToolkitTestApplication application;
2062 tet_infoline(" UtcDaliToolkitScrollViewGetSet");
2063 ScrollView scrollView = ScrollView::New();
2064 scrollView.SetMaxFlickSpeed(0.5f);
2065 DALI_TEST_EQUALS(scrollView.GetMaxFlickSpeed(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
2066 scrollView.SetFrictionCoefficient(0.6f);
2067 DALI_TEST_EQUALS(scrollView.GetFrictionCoefficient(), 0.6f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
2068 scrollView.SetFlickSpeedCoefficient(0.7f);
2069 DALI_TEST_EQUALS(scrollView.GetFlickSpeedCoefficient(), 0.7f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
2073 int UtcDaliToolkitScrollViewRulerDomainConstructorP(void)
2075 ToolkitTestApplication application;
2077 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2078 DALI_TEST_EQUALS( domainX.min, 0.0f, TEST_LOCATION);
2079 DALI_TEST_EQUALS( domainX.max, 200.0f, TEST_LOCATION);
2080 DALI_TEST_EQUALS( domainX.enabled, true, TEST_LOCATION);
2082 RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
2083 DALI_TEST_EQUALS( domainY.min, 100.0f, TEST_LOCATION);
2084 DALI_TEST_EQUALS( domainY.max, 500.0f, TEST_LOCATION);
2085 DALI_TEST_EQUALS( domainY.enabled, false, TEST_LOCATION);
2090 int UtcDaliToolkitScrollViewRulerDomainGetSizeP(void)
2092 ToolkitTestApplication application;
2094 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2095 DALI_TEST_EQUALS( domainX.GetSize(), 200.0f, TEST_LOCATION);
2097 RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
2098 DALI_TEST_EQUALS( domainY.GetSize(), 400.0f, TEST_LOCATION);
2103 int UtcDaliToolkitScrollViewRulerDomainClampP(void)
2105 ToolkitTestApplication application;
2107 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2109 float value = domainX.Clamp(50.0f, 100.0f, 1.0f);
2110 DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
2112 value = domainX.Clamp(300.0f, 20.0f, 1.0f);
2113 DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
2115 value = domainX.Clamp(300.0f, 20.0f, 0.5f);
2116 DALI_TEST_EQUALS( value, 80.0f, TEST_LOCATION);
2118 value = domainX.Clamp(250.0f, 200.0f, 2.0f);
2119 DALI_TEST_EQUALS( value, 200.0f, TEST_LOCATION);
2124 int UtcDaliToolkitScrollViewRulerDomainClampWithStateP(void)
2126 ToolkitTestApplication application;
2128 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2131 float value = domainX.Clamp(50.0f, 100.0f, 1.0f, clamped);
2132 DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
2133 DALI_TEST_EQUALS( clamped, Dali::Toolkit::NotClamped, TEST_LOCATION);
2135 value = domainX.Clamp(-100.0f, 200.0f, 1.0f, clamped);
2136 DALI_TEST_EQUALS( value, 0.0f, TEST_LOCATION);
2137 DALI_TEST_EQUALS( clamped, Dali::Toolkit::ClampedToMin, TEST_LOCATION);
2139 value = domainX.Clamp(300.0f, 20.0f, 1.0f, clamped);
2140 DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
2141 DALI_TEST_EQUALS( clamped, Dali::Toolkit::ClampedToMax, TEST_LOCATION);
2146 int UtcDaliToolkitScrollViewDefaultRulerConstructorP(void)
2148 ToolkitTestApplication application;
2149 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerConstructorP");
2151 RulerPtr defaultRuler = new DefaultRuler();
2152 DALI_TEST_CHECK( defaultRuler );
2157 int UtcDaliToolkitScrollViewDefaultRulerDestructorP(void)
2159 ToolkitTestApplication application;
2160 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerDestructorP");
2162 RulerPtr defaultRuler = new DefaultRuler();
2164 DALI_TEST_CHECK( true );
2168 int UtcDaliToolkitScrollViewFixedRulerConstructorP(void)
2170 ToolkitTestApplication application;
2171 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerConstructorP");
2173 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2174 DALI_TEST_CHECK( fixedRuler );
2176 fixedRuler = new FixedRuler( 0.0f );
2177 DALI_TEST_CHECK( fixedRuler );
2182 int UtcDaliToolkitScrollViewFixedRulerDestructorP(void)
2184 ToolkitTestApplication application;
2185 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerDestructorP");
2187 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2189 DALI_TEST_CHECK( true );
2193 int UtcDaliToolkitScrollViewRulerGetTypeP(void)
2195 ToolkitTestApplication application;
2196 tet_infoline(" UtcDaliToolkitScrollViewRulerGetTypeP");
2198 RulerPtr defaultRuler = new DefaultRuler();
2199 DALI_TEST_CHECK( defaultRuler );
2200 DALI_TEST_EQUALS( defaultRuler->GetType(), Dali::Toolkit::Ruler::Free, TEST_LOCATION);
2202 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2203 DALI_TEST_CHECK( fixedRuler );
2204 DALI_TEST_EQUALS( fixedRuler->GetType(), Dali::Toolkit::Ruler::Fixed, TEST_LOCATION);
2209 int UtcDaliToolkitScrollViewRulerGetExtensionP(void)
2211 ToolkitTestApplication application;
2212 tet_infoline(" UtcDaliToolkitScrollViewRulerGetExtensionP");
2214 RulerPtr defaultRuler = new DefaultRuler();
2215 DALI_TEST_CHECK( defaultRuler );
2216 DALI_TEST_CHECK( !defaultRuler->GetExtension() );
2218 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2219 DALI_TEST_CHECK( fixedRuler );
2220 DALI_TEST_CHECK( !fixedRuler->GetExtension() );
2225 int UtcDaliToolkitScrollViewRulerEnableDisable(void)
2227 ToolkitTestApplication application;
2228 tet_infoline(" UtcDaliToolkitScrollViewRulerEnableDisable");
2230 RulerPtr ruler = new DefaultRuler();
2232 DALI_TEST_CHECK( ruler->IsEnabled() );
2234 DALI_TEST_CHECK( !ruler->IsEnabled() );
2236 DALI_TEST_CHECK( ruler->IsEnabled() );
2240 int UtcDaliToolkitScrollViewRulerDomainEnableDisable(void)
2242 ToolkitTestApplication application;
2243 tet_infoline(" UtcDaliToolkitScrollViewRulerDomainEnableDisable");
2245 RulerPtr ruler = new DefaultRuler();
2246 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
2248 ruler->SetDomain( RulerDomain(0.0f, 100.0f, true) );
2249 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 100.0f, TEST_LOCATION );
2250 DALI_TEST_EQUALS( ruler->Clamp(-200.0f), 0.0f, TEST_LOCATION );
2251 DALI_TEST_EQUALS( ruler->Clamp(200.0f), 100.0f, TEST_LOCATION );
2253 ruler->DisableDomain();
2254 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
2255 DALI_TEST_EQUALS( ruler->Clamp(-200.0f), -200.0f, TEST_LOCATION );
2256 DALI_TEST_EQUALS( ruler->Clamp(200.0f), 200.0f, TEST_LOCATION );
2260 int UtcDaliToolkitScrollViewRulerSnapAndClamp(void)
2262 ToolkitTestApplication application;
2263 tet_infoline(" UtcDaliToolkitScrollViewRulerSnapAndClamp");
2265 RulerPtr ruler = new FixedRuler( 50.0f );
2266 ruler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2268 // default testing. (snap and clamp)
2269 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f), 50.0f, TEST_LOCATION);
2270 DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f), 50.0f, TEST_LOCATION);
2271 DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f), 0.0f, TEST_LOCATION);
2272 DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f), 0.0f, TEST_LOCATION);
2273 DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f), 400.0f, TEST_LOCATION);
2274 DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f), 400.0f, TEST_LOCATION);
2277 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
2278 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.5f), 50.0f, TEST_LOCATION); // No Flick
2279 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
2281 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
2282 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.5f), 0.0f, TEST_LOCATION); // No Flick
2283 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
2286 DALI_TEST_EQUALS( ruler->SnapAndClamp(-10.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (over left boundary)
2287 DALI_TEST_EQUALS( ruler->SnapAndClamp(-5.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (slightly ovr left boundary)
2288 DALI_TEST_EQUALS( ruler->SnapAndClamp(300.0f, 0.5f, 10.0f), 300.0f, TEST_LOCATION); // 10 units long (not over a boundary)
2289 DALI_TEST_EQUALS( ruler->SnapAndClamp(395.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (slightly over right boundary)
2290 DALI_TEST_EQUALS( ruler->SnapAndClamp(500.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (over right boundary)
2293 DALI_TEST_EQUALS( ruler->SnapAndClamp(-100.0f, 0.5f, 0.0f, 2.0f), 0.0f, TEST_LOCATION);
2294 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 2.0f), 50.0f, TEST_LOCATION);
2295 DALI_TEST_EQUALS( ruler->SnapAndClamp(700.0f, 0.5f, 0.0f, 2.0f), 700.0f, TEST_LOCATION);
2296 DALI_TEST_EQUALS( ruler->SnapAndClamp(850.0f, 0.5f, 0.0f, 2.0f), 800.0f, TEST_LOCATION);
2298 // clamp state testing.
2300 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
2301 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2302 DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
2303 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2304 DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
2305 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2306 DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
2307 DALI_TEST_EQUALS( clamped, ClampedToMin, TEST_LOCATION );
2308 DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
2309 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2310 DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
2311 DALI_TEST_EQUALS( clamped, ClampedToMax, TEST_LOCATION );
2315 int UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP(void)
2317 ToolkitTestApplication application;
2318 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP");
2320 RulerPtr rulerNormal = new FixedRuler( 25.0f );
2321 rulerNormal->SetDomain( RulerDomain(10.0f, 90.0f, true) );
2323 unsigned int volume;
2326 position = rulerNormal->GetPositionFromPage(1, volume, true);
2327 DALI_TEST_EQUALS( position, 35.0f, TEST_LOCATION );
2328 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
2330 position = rulerNormal->GetPositionFromPage(2, volume, true);
2331 DALI_TEST_EQUALS( position, 60.0f, TEST_LOCATION );
2332 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
2334 // Disable the ruler
2335 rulerNormal->Disable();
2337 position = rulerNormal->GetPositionFromPage(1, volume, true);
2338 DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
2339 DALI_TEST_EQUALS( volume, 1u, TEST_LOCATION );
2341 position = rulerNormal->GetPositionFromPage(2, volume, true);
2342 DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
2343 DALI_TEST_EQUALS( volume, 2u, TEST_LOCATION );
2348 int UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP(void)
2350 ToolkitTestApplication application;
2351 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP");
2353 RulerPtr defaultRuler = new DefaultRuler();
2354 DALI_TEST_CHECK( defaultRuler );
2355 DALI_TEST_EQUALS( defaultRuler->GetTotalPages(), 1u, TEST_LOCATION);
2360 int UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP(void)
2362 ToolkitTestApplication application;
2363 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP");
2365 RulerPtr defaultRuler = new DefaultRuler();
2366 DALI_TEST_CHECK( defaultRuler );
2367 DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(100.0f, true), 0u, TEST_LOCATION);
2368 DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(-300.0f, false), 0u, TEST_LOCATION);
2373 int UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP(void)
2375 ToolkitTestApplication application;
2376 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP");
2378 RulerPtr defaultRuler = new DefaultRuler();
2379 DALI_TEST_CHECK( defaultRuler );
2381 unsigned int volume;
2382 DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(0, volume, true), 0.0f, TEST_LOCATION);
2383 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
2385 DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(3, volume, false), 0.0f, TEST_LOCATION);
2386 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
2391 int UtcDaliToolkitScrollViewDefaultRulerSnapP(void)
2393 ToolkitTestApplication application;
2394 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerSnapP");
2396 RulerPtr defaultRuler = new DefaultRuler();
2397 DALI_TEST_CHECK( defaultRuler );
2399 DALI_TEST_EQUALS( defaultRuler->Snap(50.0f, 0.5f), 50.0f, TEST_LOCATION);
2400 DALI_TEST_EQUALS( defaultRuler->Snap(-120.0f, 1.0f), -120.0f, TEST_LOCATION);
2405 int UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP(void)
2407 ToolkitTestApplication application;
2408 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP");
2410 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2411 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2413 fixedRuler->Enable();
2414 DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 4u, TEST_LOCATION);
2416 fixedRuler->Disable();
2417 DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 1u, TEST_LOCATION);
2422 int UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP(void)
2424 ToolkitTestApplication application;
2425 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP");
2427 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2428 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2430 fixedRuler->Enable();
2431 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 3u, TEST_LOCATION);
2432 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2433 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 1u, TEST_LOCATION);
2434 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2436 fixedRuler->Disable();
2437 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2438 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
2439 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2440 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2442 // Set domain size to be smaller than the ruler space
2443 fixedRuler->SetDomain( RulerDomain(0.0f, 50.0f, true) );
2445 fixedRuler->Enable();
2446 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2447 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2448 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2449 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2451 fixedRuler->Disable();
2452 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2453 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
2454 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2455 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2460 int UtcDaliToolkitScrollViewFixedRulerSnapP(void)
2462 ToolkitTestApplication application;
2463 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerSnapP");
2465 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2466 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2468 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.0f), -100.0f, TEST_LOCATION);
2469 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.0f), -100.0f, TEST_LOCATION);
2470 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.0f), -200.0f, TEST_LOCATION);
2471 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.0f), -500.0f, TEST_LOCATION);
2472 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.0f), 0.0f, TEST_LOCATION);
2473 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.0f), 0.0f, TEST_LOCATION);
2474 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.0f), 0.0f, TEST_LOCATION);
2475 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.0f), 100.0f, TEST_LOCATION);
2476 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.0f), 100.0f, TEST_LOCATION);
2477 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.0f), 200.0f, TEST_LOCATION);
2478 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.0f), 600.0f, TEST_LOCATION);
2480 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.5f), 0.0f, TEST_LOCATION);
2481 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.5f), -100.0f, TEST_LOCATION);
2482 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.5f), -100.0f, TEST_LOCATION);
2483 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.5f), -500.0f, TEST_LOCATION);
2484 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.5f), 0.0f, TEST_LOCATION);
2485 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.5f), 100.0f, TEST_LOCATION);
2486 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.5f), 100.0f, TEST_LOCATION);
2487 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.5f), 100.0f, TEST_LOCATION);
2488 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.5f), 100.0f, TEST_LOCATION);
2489 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.5f), 300.0f, TEST_LOCATION);
2490 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.5f), 600.0f, TEST_LOCATION);
2492 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 1.0f), 0.0f, TEST_LOCATION);
2493 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 1.0f), 0.0f, TEST_LOCATION);
2494 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 1.0f), -100.0f, TEST_LOCATION);
2495 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 1.0f), -400.0f, TEST_LOCATION);
2496 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 1.0f), 100.0f, TEST_LOCATION);
2497 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 1.0f), 100.0f, TEST_LOCATION);
2498 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 1.0f), 100.0f, TEST_LOCATION);
2499 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 1.0f), 200.0f, TEST_LOCATION);
2500 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 1.0f), 200.0f, TEST_LOCATION);
2501 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 1.0f), 300.0f, TEST_LOCATION);
2502 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 1.0f), 700.0f, TEST_LOCATION);
2507 int UtcDaliToolkitScrollViewConstraintsMove(void)
2509 ToolkitTestApplication application;
2510 tet_infoline(" UtcDaliToolkitScrollViewConstraintsMove");
2512 // Set up a scrollView...
2513 ScrollView scrollView = ScrollView::New();
2514 Stage::GetCurrent().Add( scrollView );
2515 Vector2 stageSize = Stage::GetCurrent().GetSize();
2516 scrollView.SetSize(stageSize);
2517 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
2518 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2521 RulerPtr rulerX = new DefaultRuler();
2522 RulerPtr rulerY = new DefaultRuler();
2523 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
2524 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
2525 scrollView.SetRulerX(rulerX);
2526 scrollView.SetRulerY(rulerY);
2528 // Add an Actor to ScrollView,
2529 Actor a = Actor::New();
2531 a.SetPosition( TEST_ACTOR_POSITION );
2534 const Vector2 target = Vector2(100.0f, 100.0f);
2535 const Vector2 target2 = Vector2(200.0f, 200.0f);
2537 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, MoveActorConstraint );
2538 constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
2539 constraint.SetRemoveAction(Constraint::Discard);
2540 scrollView.ApplyConstraintToChildren(constraint);
2542 scrollView.ScrollTo( target, 0.0f );
2544 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
2545 scrollView.ScrollTo( target2 );
2546 Wait(application, RENDER_DELAY_SCROLL);
2547 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
2552 int UtcDaliToolkitScrollViewConstraintsWrap(void)
2554 ToolkitTestApplication application;
2555 tet_infoline(" UtcDaliToolkitScrollViewConstraintsWrap");
2557 // Set up a scrollView...
2558 ScrollView scrollView = ScrollView::New();
2559 Stage::GetCurrent().Add( scrollView );
2560 Vector2 stageSize = Stage::GetCurrent().GetSize();
2561 scrollView.SetSize(stageSize);
2562 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
2563 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2566 RulerPtr rulerX = new DefaultRuler();
2567 RulerPtr rulerY = new DefaultRuler();
2568 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
2569 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
2570 scrollView.SetRulerX(rulerX);
2571 scrollView.SetRulerY(rulerY);
2573 // Add an Actor to ScrollView,
2574 Actor a = Actor::New();
2576 a.SetPosition( TEST_ACTOR_POSITION );
2579 const Vector2 target = Vector2(100.0f, 100.0f);
2580 const Vector2 target2 = Vector2(200.0f, 200.0f);
2582 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, WrapActorConstraint );
2583 constraint.AddSource( LocalSource( Actor::Property::SCALE ) );
2584 constraint.AddSource( LocalSource( Actor::Property::ANCHOR_POINT ) );
2585 constraint.AddSource( LocalSource( Actor::Property::SIZE ) );
2586 constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
2587 constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
2588 constraint.AddSource( Source( scrollView, Toolkit::ScrollView::Property::WRAP ) );
2589 constraint.SetRemoveAction(Constraint::Discard);
2590 scrollView.ApplyConstraintToChildren(constraint);
2592 scrollView.ScrollTo( target, 0.0f );
2594 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
2595 scrollView.ScrollTo( target2 );
2596 Wait(application, RENDER_DELAY_SCROLL);
2597 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
2599 scrollView.Remove(a);
2605 // Non-API test (so no P or N variant).
2606 int UtcDaliToolkitScrollViewGesturePageLimit(void)
2608 ToolkitTestApplication application;
2609 tet_infoline( " UtcDaliToolkitScrollViewGesturePageLimit" );
2611 // Set up a scrollView.
2612 ScrollView scrollView = ScrollView::New();
2614 // Do not rely on stage size for UTC tests.
2615 Vector2 pageSize( 720.0f, 1280.0f );
2616 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
2617 scrollView.SetSize( pageSize );
2618 scrollView.SetParentOrigin( ParentOrigin::CENTER );
2619 scrollView.SetAnchorPoint( AnchorPoint::CENTER );
2620 scrollView.SetPosition( 0.0f, 0.0f, 0.0f );
2623 // We set the X ruler to fixed to give us pages to snap to.
2624 Dali::Toolkit::FixedRuler* rulerX = new Dali::Toolkit::FixedRuler( pageSize.width );
2625 // Note: The 3x page width is arbitary, but we need enough to show that we are
2626 // capping page movement by the page limiter, and not the domain.
2627 rulerX->SetDomain( Dali::Toolkit::RulerDomain( 0.0f, pageSize.width * 3.0f, false ) );
2628 Dali::Toolkit::RulerPtr rulerY = new Dali::Toolkit::DefaultRuler();
2630 scrollView.SetRulerX( rulerX );
2631 scrollView.SetRulerY( rulerY );
2633 scrollView.SetWrapMode( false );
2634 scrollView.SetScrollSensitive( true );
2636 Stage::GetCurrent().Add( scrollView );
2638 // Set up a gesture to perform.
2639 Vector2 startPos( 50.0f, 0.0f );
2640 Vector2 direction( -5.0f, 0.0f );
2643 // Force starting position.
2644 scrollView.ScrollTo( startPos, 0.0f );
2645 Wait( application );
2647 // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
2648 Vector2 currentPos( PerformGestureDiagonalSwipe( application, startPos, direction, frames - 1, false ) );
2650 // Confirm the final X coord has not moved more than one page from the start X position.
2651 DALI_TEST_GREATER( ( startPos.x + pageSize.width ), scrollView.GetCurrentScrollPosition().x, TEST_LOCATION );
2653 // Finish the gesture and wait for the snap.
2654 currentPos += direction;
2655 SendPan( application, Gesture::Finished, currentPos );
2656 // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
2657 Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
2659 // Confirm the final X coord has snapped to exactly one page ahead of the start page.
2660 DALI_TEST_EQUALS( pageSize.width, scrollView.GetCurrentScrollPosition().x, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2665 int UtcDaliScrollViewSetGetProperty(void)
2667 ToolkitTestApplication application;
2669 // Create the ScrollView actor
2670 ScrollView scrollView = ScrollView::New();
2671 DALI_TEST_CHECK(scrollView);
2673 // Event side properties
2675 // Test "wrapEnabled" property
2676 DALI_TEST_CHECK( scrollView.GetPropertyIndex("wrapEnabled") == ScrollView::Property::WRAP_ENABLED );
2677 scrollView.SetProperty( ScrollView::Property::WRAP_ENABLED, true );
2678 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WRAP_ENABLED).Get<bool>(), true, TEST_LOCATION );
2680 // Test "panningEnabled" property
2681 DALI_TEST_CHECK( scrollView.GetPropertyIndex("panningEnabled") == ScrollView::Property::PANNING_ENABLED );
2682 scrollView.SetProperty( ScrollView::Property::PANNING_ENABLED, false );
2683 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::PANNING_ENABLED).Get<bool>(), false, TEST_LOCATION );
2685 // Test "axisAutoLockEnabled" property
2686 DALI_TEST_CHECK( scrollView.GetPropertyIndex("axisAutoLockEnabled") == ScrollView::Property::AXIS_AUTO_LOCK_ENABLED );
2687 scrollView.SetProperty( ScrollView::Property::AXIS_AUTO_LOCK_ENABLED, false );
2688 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::AXIS_AUTO_LOCK_ENABLED).Get<bool>(), false, TEST_LOCATION );
2690 // Test "wheelScrollDistanceStep" property
2691 DALI_TEST_CHECK( scrollView.GetPropertyIndex("wheelScrollDistanceStep") == ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP );
2692 scrollView.SetProperty( ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP, Vector2(100.0f, 50.0f) );
2693 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP).Get<Vector2>(), Vector2(100.0f, 50.0f), TEST_LOCATION );
2695 // Test "overshootEnabled" property
2696 DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootEnabled") == Scrollable::Property::OVERSHOOT_ENABLED );
2697 DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), scrollView.IsOvershootEnabled(), TEST_LOCATION );
2698 scrollView.SetProperty( Scrollable::Property::OVERSHOOT_ENABLED, false );
2699 DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), false, TEST_LOCATION );
2701 // Animatable properties
2703 // Test "scrollPosition" property
2704 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPosition") == ScrollView::Property::SCROLL_POSITION );
2705 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(320.0f, 550.0f) );
2707 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION).Get<Vector2>(), Vector2(320.0f, 550.0f), TEST_LOCATION );
2709 // Test "scrollPrePosition", "scrollPrePositionX" and "scrollPrePositionY" properties
2710 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePosition") == ScrollView::Property::SCROLL_PRE_POSITION );
2711 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION, Vector2(300.0f, 500.0f) );
2713 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION).Get<Vector2>(), Vector2(300.0f, 500.0f), TEST_LOCATION );
2715 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionX") == ScrollView::Property::SCROLL_PRE_POSITION_X );
2716 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionY") == ScrollView::Property::SCROLL_PRE_POSITION_Y );
2717 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_X).Get<float>(), 300.0f, TEST_LOCATION );
2718 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_Y).Get<float>(), 500.0f, TEST_LOCATION );
2719 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_X, 400.0f );
2720 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_Y, 600.0f );
2722 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_X).Get<float>(), 400.0f, TEST_LOCATION );
2723 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_Y).Get<float>(), 600.0f, TEST_LOCATION );
2724 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION).Get<Vector2>(), Vector2(400.0f, 600.0f), TEST_LOCATION );
2726 // Test "scrollPrePositionMax", "scrollPrePositionMaxX" and "scrollPrePositionMaxY" properties
2727 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMax") == ScrollView::Property::SCROLL_PRE_POSITION_MAX );
2728 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX, Vector2(100.0f, 200.0f) );
2730 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX).Get<Vector2>(), Vector2(100.0f, 200.0f), TEST_LOCATION );
2732 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMaxX") == ScrollView::Property::SCROLL_PRE_POSITION_MAX_X );
2733 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMaxY") == ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y );
2734 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_X).Get<float>(), 100.0f, TEST_LOCATION );
2735 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y).Get<float>(), 200.0f, TEST_LOCATION );
2736 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX_X, 300.0f );
2737 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y, 400.0f );
2739 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_X).Get<float>(), 300.0f, TEST_LOCATION );
2740 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y).Get<float>(), 400.0f, TEST_LOCATION );
2741 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX).Get<Vector2>(), Vector2(300.0f, 400.0f), TEST_LOCATION );
2743 // Test "overshootX" property
2744 DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootX") == ScrollView::Property::OVERSHOOT_X );
2745 scrollView.SetProperty( ScrollView::Property::OVERSHOOT_X, 0.8f );
2747 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::OVERSHOOT_X).Get<float>(), 0.8f, TEST_LOCATION );
2749 // Test "overshootY" property
2750 DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootY") == ScrollView::Property::OVERSHOOT_Y );
2751 scrollView.SetProperty( ScrollView::Property::OVERSHOOT_Y, 0.8f );
2753 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y).Get<float>(), 0.8f, TEST_LOCATION );
2755 // Test "scrollFinal", "scrollFinalX" and "scrollFinalY" properties
2756 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinal") == ScrollView::Property::SCROLL_FINAL );
2757 scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL, Vector2(200.0f, 300.0f) );
2759 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL).Get<Vector2>(), Vector2(200.0f, 300.0f), TEST_LOCATION );
2761 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinalX") == ScrollView::Property::SCROLL_FINAL_X );
2762 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinalY") == ScrollView::Property::SCROLL_FINAL_Y );
2763 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_X).Get<float>(), 200.0f, TEST_LOCATION );
2764 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_Y).Get<float>(), 300.0f, TEST_LOCATION );
2765 scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL_X, 500.0f );
2766 scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL_Y, 600.0f );
2768 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_X).Get<float>(), 500.0f, TEST_LOCATION );
2769 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_Y).Get<float>(), 600.0f, TEST_LOCATION );
2770 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL).Get<Vector2>(), Vector2(500.0f, 600.0f), TEST_LOCATION );
2772 // Test "wrap" property
2773 DALI_TEST_CHECK( scrollView.GetPropertyIndex("wrap") == ScrollView::Property::WRAP );
2774 scrollView.SetProperty( ScrollView::Property::WRAP, false );
2776 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WRAP).Get<bool>(), false, TEST_LOCATION );
2778 // Test "panning" property
2779 DALI_TEST_CHECK( scrollView.GetPropertyIndex("panning") == ScrollView::Property::PANNING );
2780 scrollView.SetProperty( ScrollView::Property::PANNING, true );
2782 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::PANNING).Get<bool>(), true, TEST_LOCATION );
2784 // Test "scrolling" property
2785 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrolling") == ScrollView::Property::SCROLLING );
2786 scrollView.SetProperty( ScrollView::Property::SCROLLING, false );
2788 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLLING).Get<bool>(), false, TEST_LOCATION );
2790 // Test "scrollDomainSize", "scrollDomainSizeX" and "scrollDomainSizeY" properties
2791 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSize") == ScrollView::Property::SCROLL_DOMAIN_SIZE );
2792 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE, Vector2(1200.0f, 1300.0f) );
2794 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE).Get<Vector2>(), Vector2(1200.0f, 1300.0f), TEST_LOCATION );
2796 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSizeX") == ScrollView::Property::SCROLL_DOMAIN_SIZE_X );
2797 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSizeY") == ScrollView::Property::SCROLL_DOMAIN_SIZE_Y );
2798 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_X).Get<float>(), 1200.0f, TEST_LOCATION );
2799 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_Y).Get<float>(), 1300.0f, TEST_LOCATION );
2800 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE_X, 1500.0f );
2801 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE_Y, 1600.0f );
2803 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_X).Get<float>(), 1500.0f, TEST_LOCATION );
2804 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_Y).Get<float>(), 1600.0f, TEST_LOCATION );
2805 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE).Get<Vector2>(), Vector2(1500.0f, 1600.0f), TEST_LOCATION );
2807 // Test "scrollDomainOffset" property
2808 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainOffset") == ScrollView::Property::SCROLL_DOMAIN_OFFSET );
2809 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_OFFSET, Vector2(500.0f, 200.0f) );
2811 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_OFFSET).Get<Vector2>(), Vector2(500.0f, 200.0f), TEST_LOCATION );
2813 // Test "scrollPositionDelta" property
2814 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPositionDelta") == ScrollView::Property::SCROLL_POSITION_DELTA );
2815 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION_DELTA, Vector2(10.0f, 30.0f) );
2817 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION_DELTA).Get<Vector2>(), Vector2(10.0f, 30.0f), TEST_LOCATION );
2819 // Test "startPagePosition" property
2820 DALI_TEST_CHECK( scrollView.GetPropertyIndex("startPagePosition") == ScrollView::Property::START_PAGE_POSITION );
2821 scrollView.SetProperty( ScrollView::Property::START_PAGE_POSITION, Vector3(50.0f, 100.0f, 20.0f) );
2823 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::START_PAGE_POSITION).Get<Vector3>(), Vector3(50.0f, 100.0f, 20.0f), TEST_LOCATION );