2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <dali-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 MILLISECONDS_PER_SECOND = 1000;
62 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
63 const int RENDER_ANIMATION_TEST_DURATION_MS = 1000; ///< 1000ms to test animation
65 const int RENDER_DELAY_SCROLL = 1000; ///< duration to wait for any scroll to complete.
67 // For Clamp Signal testing...
68 const float CLAMP_EXCESS_WIDTH = 200.0f; ///< Amount of width that can be panned outside scrollview
69 const float CLAMP_EXCESS_HEIGHT = 200.0f; ///< Amount of height that can be panned outside scrollview
70 const int CLAMP_STEP_0_CHECK_NOTCLAMPED = 0; ///< FSM: "First check that scrollview isn't clamped"
71 const int CLAMP_STEP_1_CHECK_CLAMPED_WEST = 1; ///< FSM: "Next check that scrollview clamps against left side"
72 const int CLAMP_STEP_2_CHECK_CLAMPED_SOUTH_WEST = 2; ///< FSM: "Then check that scrollview clamps against bottom-left side"
73 const int CLAMP_STEP_3_SUCCESS = 3; ///< FSM: "Finished (Success)"
74 const Vector2 CLAMP_START_SCROLL_POSITION(30.0f, 100.0f); ///< Scroll start position for the Clamping tests.
75 const Vector2 CLAMP_TOUCH_START( 100.0f, 100.0f ); ///< Start point to touch from for the Clamping tests.
76 const Vector2 CLAMP_TOUCH_MOVEMENT( 5.0f, -5.0f ); ///< Amount to move touch for each frame for the Clamping tests.
77 const int CLAMP_GESTURE_FRAMES = 100; ///< Number of Frames to synthesize a gesture for the Clamping tests.
78 const Vector3 TEST_ACTOR_POSITION(100.0f, 100.0f, 0.0f); ///< A Test actor position offset (arbitrary value)
79 const Vector3 TEST_CONSTRAINT_OFFSET(1.0f, 2.0f, 0.0f); ///< A Test constraint offset (arbitrary value to test effects)
80 const float TEST_RATIO_TOLERANCE = 0.05; ///< +/-5% tolerance for ratio comparisons.
82 const float DEFAULT_SNAP_OVERSHOOT_DURATION(0.5f); ///< Default overshoot snapping animation time.
83 const float DEFAULT_MAX_OVERSHOOT(100.0f); ///< Default maximum allowed overshoot in pixels
85 const int MAX_FRAMES_TO_TEST_OVERSHOOT = 600; ///< 10 seconds (at 60 frames per second).
86 const Vector2 OVERSHOOT_START_SCROLL_POSITION(100.0f, 100.0f); ///< Scroll start position for the Overshoot tests.
87 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)
88 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).
89 const float TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION = 0.05f; ///< a Test duration
90 const float TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION = 1.5f; ///< another Test duration
91 const float TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION = TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * 0.5f; // Same as above, but different alpha function.
92 const float TIME_TOLERANCE = 0.05f; ///< Allow testing tolerance between a 10th of second (+/- 3 frames)
95 // Generate a PanGestureEvent to send to Core
96 Integration::PanGestureEvent GeneratePan(
98 const Vector2& previousPosition,
99 const Vector2& currentPosition,
100 unsigned long timeDelta,
101 unsigned int numberOfTouches = 1)
103 Integration::PanGestureEvent pan(state);
105 pan.previousPosition = previousPosition;
106 pan.currentPosition = currentPosition;
107 pan.timeDelta = timeDelta;
108 pan.numberOfTouches = numberOfTouches;
114 * Helper to generate PanGestureEvent
116 * @param[in] application Application instance
117 * @param[in] state The Gesture State
118 * @param[in] pos The current position of touch.
120 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
124 if( (state == Gesture::Started) ||
125 (state == Gesture::Possible) )
131 application.ProcessEvent(GeneratePan(state, last, pos, RENDER_FRAME_INTERVAL));
138 * Simulate time passed by.
140 * @note this will always process at least 1 frame (1/60 sec)
142 * @param application Test application instance
143 * @param duration Time to pass in milliseconds.
144 * @return The actual time passed in milliseconds
146 int Wait(ToolkitTestApplication& application, int duration = 0)
150 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
152 application.SendNotification();
153 application.Render(RENDER_FRAME_INTERVAL);
154 time += RENDER_FRAME_INTERVAL;
162 static bool gOnScrollStartCalled; ///< Whether the OnScrollStart signal was invoked.
163 static bool gOnScrollUpdateCalled; ///< Whether the OnScrollUpdate signal was invoked.
164 static bool gOnScrollCompleteCalled; ///< Whether the OnScrollComplete signal was invoked.
165 static bool gOnSnapStartCalled; ///< Whether the OnSnapStart signal was invoked.
166 static SnapType gLastSnapType; ///< Snaping information from SnapEvent.
167 static Vector3 gConstraintResult; ///< Result from constraint.
170 * Invoked when scrolling starts.
172 * @param[in] position The current scroll position.
174 static void OnScrollStart( const Vector2& position )
176 gOnScrollStartCalled = true;
180 * Invoked when scrolling updates (via dragging)
182 * @param[in] position The current scroll position.
184 static void OnScrollUpdate( const Vector2& position )
186 gOnScrollUpdateCalled = true;
190 * Invoked when scrolling finishes
192 * @param[in] position The current scroll position.
194 static void OnScrollComplete( const Vector2& position )
196 gOnScrollCompleteCalled = true;
200 * Invoked when a snap or flick started.
202 * @param[in] event The type of snap and the target position/scale/rotation.
204 static void OnSnapStart( const ScrollView::SnapEvent& event )
206 gOnSnapStartCalled = true;
207 gLastSnapType = event.type;
213 * Summation of current value, property, and offset.
215 * current' = current + mOffset + property;
217 struct TestSumConstraint
220 * @param[in] offset The offset to be added to current.
222 TestSumConstraint(const Vector3& offset)
228 * @param[in] current The current base value
229 * @param[in] inputs Contains the property to be added to current.
230 * @return The new current Vector.
232 void operator()( Vector3& current, const PropertyInputContainer& inputs )
234 gConstraintResult = current + Vector3(inputs[0]->GetVector2()) + mOffset;
235 current = gConstraintResult;
243 * @param[in] application The application instance
244 * @param[in] scrollView The scrollView instance
245 * @return The time taken for the overshoot to reach origin (zero)
247 static float TestOvershootSnapDuration(ToolkitTestApplication &application, ScrollView scrollView)
249 int timeToReachOrigin = -1;
250 for(int i = 0;i<MAX_FRAMES_TO_TEST_OVERSHOOT;i++)
252 float overshootXValue = scrollView.GetCurrentProperty<float>( ScrollView::Property::OVERSHOOT_X );
253 float overshootYValue = scrollView.GetCurrentProperty<float>( ScrollView::Property::OVERSHOOT_Y );
254 if(overshootXValue == 0.0f && overshootYValue == 0.0f)
259 timeToReachOrigin += Wait(application);
262 return static_cast<float>(timeToReachOrigin) * 0.001f; // return in seconds not ms.
266 * y = 2x alpha function, which is clamped between 0.0f - 1.0f
268 * Animations should appear to finish (reach 100% point)
269 * at just half the time of a regular Linear AlphaFunction.
271 * @param[in] progress value (ranges from 0.0f - 1.0f)
272 * @return interpolation value (ranges from 0.0f - 1.0f)
274 float TestAlphaFunction(float progress)
276 return std::min( progress * 2.0f, 1.0f );
279 static Vector2 PerformGestureDiagonalSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, bool finish = true)
281 gOnScrollStartCalled = false;
282 gOnScrollUpdateCalled = false;
283 gOnScrollCompleteCalled = false;
284 gOnSnapStartCalled = false;
286 // Now do a pan starting from (start) and heading (direction)
288 SendPan(application, Gesture::Possible, pos);
289 SendPan(application, Gesture::Started, pos);
292 for(int i = 0;i<frames;i++)
294 pos += direction; // Move in this direction
295 SendPan(application, Gesture::Continuing, pos);
301 pos += direction; // Move in this direction.
302 SendPan(application, Gesture::Finished, pos);
303 Wait(application, RENDER_DELAY_SCROLL);
310 } // unnamed namespace
313 int UtcDaliToolkitScrollViewConstructorP(void)
315 ToolkitTestApplication application;
317 ScrollView scrollView;
318 DALI_TEST_CHECK( !scrollView );
322 int UtcDaliToolkitScrollViewCopyConstructorP(void)
324 ToolkitTestApplication application;
326 ScrollView scrollView = ScrollView::New();
327 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) );
329 ScrollView copy( scrollView );
330 DALI_TEST_CHECK( copy );
331 DALI_TEST_CHECK( copy.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) == scrollView.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) );
335 int UtcDaliToolkitScrollViewAssignmentOperatorP(void)
337 ToolkitTestApplication application;
339 ScrollView scrollView = ScrollView::New();
340 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) );
342 ScrollView copy = scrollView;
343 DALI_TEST_CHECK( copy );
344 DALI_TEST_CHECK( copy.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) == scrollView.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) );
348 int UtcDaliScrollViewDestructorP(void)
350 ToolkitTestApplication application;
352 ScrollView* scrollView = new ScrollView();
355 DALI_TEST_CHECK( true );
359 int UtcDaliToolkitScrollViewNewP1(void)
361 ToolkitTestApplication application;
362 tet_infoline(" UtcDaliToolkitScrollViewNewP1");
364 ScrollView scrollView;
366 DALI_TEST_CHECK( !scrollView );
368 scrollView = ScrollView::New();
370 DALI_TEST_CHECK( scrollView );
372 ScrollView scrollView2(scrollView);
374 DALI_TEST_CHECK( scrollView2 == scrollView );
376 //Additional check to ensure object is created by checking if it's registered
377 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
378 DALI_TEST_CHECK( registry );
380 gObjectCreatedCallBackCalled = false;
381 registry.ObjectCreatedSignal().Connect( &TestCallback );
383 ScrollView scrollView = ScrollView::New();
385 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
389 int UtcDaliToolkitScrollViewNewP2(void)
391 ToolkitTestApplication application;
392 tet_infoline(" UtcDaliToolkitScrollViewNewP2 - create thru type registry");
394 ScrollView scrollView;
395 DALI_TEST_CHECK( !scrollView );
397 TypeRegistry typeRegistry = TypeRegistry::Get();
398 TypeInfo scrollViewType = typeRegistry.GetTypeInfo("ScrollView");
399 BaseHandle handle = scrollViewType.CreateInstance();
400 DALI_TEST_CHECK( handle );
402 scrollView = ScrollView::DownCast(handle);
403 DALI_TEST_CHECK( scrollView );
408 int UtcDaliToolkitScrollViewDownCastP(void)
410 ToolkitTestApplication application;
411 tet_infoline(" UtcDaliToolkitScrollViewDownCastP");
413 ScrollView scrollView = ScrollView::New();
414 BaseHandle handle(scrollView);
416 ScrollView newScrollView = ScrollView::DownCast( handle );
417 DALI_TEST_CHECK( scrollView );
418 DALI_TEST_CHECK( newScrollView == scrollView );
422 int UtcDaliToolkitScrollViewScrollToPositionP(void)
424 ToolkitTestApplication application;
425 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionP");
427 // Create the ScrollView actor
428 ScrollView scrollView = ScrollView::New();
429 Stage::GetCurrent().Add( scrollView );
431 const Vector2 target = Vector2(100.0f, 200.0f);
432 const Vector2 target2 = Vector2(300.0f, 100.0f);
434 scrollView.ScrollTo( target, 0.0f );
436 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
437 scrollView.ScrollTo( target2 );
438 Wait(application, RENDER_DELAY_SCROLL);
439 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
444 int UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP(void)
446 ToolkitTestApplication application;
447 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP");
449 ScrollView scrollView = ScrollView::New();
450 Stage::GetCurrent().Add( scrollView );
451 RulerPtr rulerX = new FixedRuler( 100.0f );
452 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
453 RulerPtr rulerY = new FixedRuler( 100.0f );
454 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
456 scrollView.SetRulerX( rulerX );
457 scrollView.SetRulerY( rulerY );
459 scrollView.SetWrapMode(true);
461 Property::Value wrapMode = scrollView.GetProperty( Toolkit::ScrollView::Property::WRAP_ENABLED );
462 DALI_TEST_EQUALS( wrapMode.Get<bool>(), true, TEST_LOCATION );
464 const Vector2 target = Vector2(50.0f, 50.0f);
465 const Vector2 target2 = Vector2(150.0f, 150.0f);
467 scrollView.ScrollTo( target, 0.0f );
468 Wait(application, RENDER_DELAY_SCROLL);
469 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
471 scrollView.ScrollTo( target2, 0.25f, Dali::Toolkit::DirectionBiasLeft, Dali::Toolkit::DirectionBiasLeft );
472 Wait(application, RENDER_DELAY_SCROLL);
473 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
475 scrollView.ScrollTo( target, 0.0f );
476 Wait(application, RENDER_DELAY_SCROLL);
477 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
479 scrollView.ScrollTo( target2, 0.25f, Dali::Toolkit::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
480 Wait(application, RENDER_DELAY_SCROLL);
481 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
486 int UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionP(void)
488 ToolkitTestApplication application;
489 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionP");
491 // Create the ScrollView actor
492 ScrollView scrollView = ScrollView::New();
493 Stage::GetCurrent().Add( scrollView );
495 const Vector2 target = Vector2(100.0f, 200.0f);
496 const Vector2 target2 = Vector2(300.0f, 100.0f);
498 scrollView.ScrollTo( target, 0.5f, TestAlphaFunction );
499 Wait(application, 250);
500 // Check that the scroll animation should finish within just half of the specified duration with the above alpha function
501 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
503 scrollView.ScrollTo( target2, 0.5f, AlphaFunction::LINEAR );
504 Wait(application, 250);
505 // Check that the scroll animation has not finished within half of the specified duration with the linear alpha function
506 DALI_TEST_CHECK( scrollView.GetCurrentScrollPosition() != target2 );
508 // Wait till the end of the specified duration
509 Wait(application, 250);
510 // Check that the scroll animation has finished
511 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
516 int UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionAndDirectionBiasP(void)
518 ToolkitTestApplication application;
519 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionAndDirectionBiasP");
521 ScrollView scrollView = ScrollView::New();
522 Stage::GetCurrent().Add( scrollView );
523 RulerPtr rulerX = new FixedRuler( 100.0f );
524 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
525 RulerPtr rulerY = new FixedRuler( 100.0f );
526 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
528 scrollView.SetRulerX( rulerX );
529 scrollView.SetRulerY( rulerY );
531 scrollView.SetWrapMode(true);
533 const Vector2 target = Vector2(50.0f, 50.0f);
534 const Vector2 target2 = Vector2(150.0f, 150.0f);
536 scrollView.ScrollTo( target, 0.0f );
537 Wait(application, RENDER_DELAY_SCROLL);
538 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
540 scrollView.ScrollTo( target2, 0.25f, AlphaFunction::LINEAR, Dali::Toolkit::DirectionBiasLeft, Dali::Toolkit::DirectionBiasLeft );
541 Wait(application, RENDER_DELAY_SCROLL);
542 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
544 scrollView.ScrollTo( target, 0.0f );
545 Wait(application, RENDER_DELAY_SCROLL);
546 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
548 scrollView.ScrollTo( target2, 0.25f, AlphaFunction::LINEAR, Dali::Toolkit::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
549 Wait(application, RENDER_DELAY_SCROLL);
550 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
552 scrollView.ScrollTo( target, 0.0f );
553 Wait(application, RENDER_DELAY_SCROLL);
554 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
556 scrollView.ScrollTo( target2, 0.25f, TestAlphaFunction, Dali::Toolkit::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
557 Wait(application, 125);
558 // Check that the scroll animation should finish within just half of the specified duration with the above alpha function
559 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
564 int UtcDaliToolkitScrollViewScrollToPageP(void)
566 ToolkitTestApplication application;
567 tet_infoline(" UtcDaliToolkitScrollViewScrollToPageP");
569 ScrollView scrollView = ScrollView::New();
570 Stage::GetCurrent().Add( scrollView );
571 RulerPtr rulerX = new FixedRuler( 100.0f );
572 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
573 RulerPtr rulerY = new FixedRuler( 100.0f );
574 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
576 scrollView.SetRulerX( rulerX );
577 scrollView.SetRulerY( rulerY );
579 scrollView.ScrollTo( 1, 0.0f );
581 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION );
583 scrollView.ScrollTo( 5, 0.0f );
585 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(500.0f, 0.0f), TEST_LOCATION );
587 scrollView.ScrollTo( 10, 0.0f );
589 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 100.0f), TEST_LOCATION );
591 scrollView.ScrollTo( 15, 0.0f );
593 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(700.0f, 100.0f), TEST_LOCATION );
594 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION );
596 scrollView.ScrollTo( 3 );
597 Wait(application, RENDER_DELAY_SCROLL);
598 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(300.0f, 0.0f), TEST_LOCATION );
599 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION );
601 scrollView.ScrollTo( 9 );
602 Wait(application, RENDER_DELAY_SCROLL);
603 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 100.0f), TEST_LOCATION );
604 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION );
606 // Apply DefaultRulers instead and see what happens.
607 rulerX = new DefaultRuler();
608 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
609 rulerY = new DefaultRuler();
610 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
612 scrollView.SetRulerX( rulerX );
613 scrollView.SetRulerY( rulerY );
615 // This time should always scroll to origin (0.0f, 0.0f)
616 scrollView.ScrollTo( 1, 0.0f );
618 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
619 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
625 int UtcDaliToolkitScrollModeP1(void)
627 ToolkitTestApplication application;
628 tet_infoline( " UtcDaliToolkitScrollView ScrollMode property" );
630 // Set up a scrollView.
631 ScrollView scrollView = ScrollView::New();
633 // Do not rely on stage size for UTC tests.
634 Vector2 pageSize( 720.0f, 1280.0f );
635 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
636 scrollView.SetSize( pageSize );
637 scrollView.SetParentOrigin( ParentOrigin::CENTER );
638 scrollView.SetAnchorPoint( AnchorPoint::CENTER );
639 scrollView.SetPosition( 0.0f, 0.0f, 0.0f );
642 Property::Map rulerMap;
643 rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, true );
644 rulerMap.Add( ScrollMode::X_AXIS_SNAP_TO_INTERVAL, pageSize.width );
645 rulerMap.Add( ScrollMode::X_AXIS_SCROLL_BOUNDARY, pageSize.width*3 );
646 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, false );
647 scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
649 scrollView.SetWrapMode( false );
650 scrollView.SetScrollSensitive( true );
652 Stage::GetCurrent().Add( scrollView );
654 // Set up a gesture to perform.
655 Vector2 startPos( 50.0f, 0.0f );
656 Vector2 direction( -5.0f, 0.0f );
659 // Force starting position.
660 scrollView.ScrollTo( startPos, 0.0f );
663 // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
664 Vector2 currentPos( PerformGestureDiagonalSwipe( application, startPos, direction, frames - 1, false ) );
666 // Confirm the final X coord has not moved more than one page from the start X position.
667 DALI_TEST_GREATER( ( startPos.x + pageSize.width ), scrollView.GetCurrentScrollPosition().x, TEST_LOCATION );
669 // Finish the gesture and wait for the snap.
670 currentPos += direction;
671 SendPan( application, Gesture::Finished, currentPos );
672 // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
673 Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
675 // Confirm the final X coord has snapped to exactly one page ahead of the start page.
676 DALI_TEST_EQUALS( pageSize.width, scrollView.GetCurrentScrollPosition().x, Math::MACHINE_EPSILON_0, TEST_LOCATION );
681 int UtcDaliToolkitScrollModeP2(void)
683 ToolkitTestApplication application;
684 tet_infoline( " UtcDaliToolkitScrollView ScrollMode property" );
686 // Set up a scrollView.
687 ScrollView scrollView = ScrollView::New();
689 // Do not rely on stage size for UTC tests.
690 Vector2 pageSize( 720.0f, 1280.0f );
691 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
692 scrollView.SetSize( pageSize );
693 scrollView.SetParentOrigin( ParentOrigin::CENTER );
694 scrollView.SetAnchorPoint( AnchorPoint::CENTER );
695 scrollView.SetPosition( 0.0f, 0.0f, 0.0f );
698 Property::Map rulerMap;
699 rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, false );
700 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, true );
701 rulerMap.Add( ScrollMode::Y_AXIS_SNAP_TO_INTERVAL, pageSize.height );
702 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_BOUNDARY, pageSize.height*3 );
703 scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
705 scrollView.SetWrapMode( false );
706 scrollView.SetScrollSensitive( true );
708 Stage::GetCurrent().Add( scrollView );
710 // Set up a gesture to perform.
711 Vector2 startPos( 0.0f, 50.0f );
712 Vector2 direction( 0.0f, -6.0f );
715 // Force starting position.
716 scrollView.ScrollTo( startPos, 0.0f );
719 // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
720 Vector2 currentPos( PerformGestureDiagonalSwipe( application, startPos, direction, frames - 1, false ) );
722 // Confirm the final X coord has not moved more than one page from the start X position.
723 DALI_TEST_GREATER( ( startPos.y + pageSize.height ), scrollView.GetCurrentScrollPosition().y, TEST_LOCATION );
725 // Finish the gesture and wait for the snap.
726 currentPos += direction;
727 SendPan( application, Gesture::Finished, currentPos );
728 // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
729 Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
731 // Confirm the final Y coord has snapped to exactly one page ahead of the start page.
732 DALI_TEST_EQUALS( pageSize.height, scrollView.GetCurrentScrollPosition().y, Math::MACHINE_EPSILON_0, TEST_LOCATION );
737 int UtcDaliToolkitScrollModeP3(void)
739 ToolkitTestApplication application;
740 tet_infoline( " UtcDaliToolkitScrollView ScrollMode property" );
742 // Set up a scrollView.
743 ScrollView scrollView = ScrollView::New();
745 // Do not rely on stage size for UTC tests.
746 Vector2 pageSize( 720.0f, 1280.0f );
747 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
748 scrollView.SetSize( pageSize );
749 scrollView.SetParentOrigin( ParentOrigin::CENTER );
750 scrollView.SetAnchorPoint( AnchorPoint::CENTER );
751 scrollView.SetPosition( 0.0f, 0.0f, 0.0f );
754 Property::Map rulerMap;
755 rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, false );
756 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, true );
757 rulerMap.Add( ScrollMode::Y_AXIS_SNAP_TO_INTERVAL, pageSize.height );
758 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_BOUNDARY, pageSize.height*3 );
759 scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
761 scrollView.SetWrapMode( false );
762 scrollView.SetScrollSensitive( true );
764 Stage::GetCurrent().Add( scrollView );
766 // Set up a gesture to perform.
767 Vector2 startPos( 0.0f, 50.0f );
768 Vector2 direction( 0.0f, -6.0f );
771 // Force starting position.
772 scrollView.ScrollTo( startPos, 0.0f );
775 // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
776 Vector2 currentPos( PerformGestureDiagonalSwipe( application, startPos, direction, frames - 1, false ) );
778 // Confirm the final X coord has not moved more than one page from the start X position.
779 DALI_TEST_GREATER( ( startPos.y + pageSize.height ), scrollView.GetCurrentScrollPosition().y, TEST_LOCATION );
781 // Finish the gesture and wait for the snap.
782 currentPos += direction;
783 SendPan( application, Gesture::Finished, currentPos );
784 // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
785 Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
787 // Confirm the final Y coord has snapped to exactly one page ahead of the start page.
788 DALI_TEST_EQUALS( pageSize.height, scrollView.GetCurrentScrollPosition().y, Math::MACHINE_EPSILON_0, TEST_LOCATION );
793 int UtcDaliToolkitScrollModeP4(void)
795 ToolkitTestApplication application;
796 tet_infoline( " UtcDaliToolkitScrollView ScrollMode property, DefaultRulers" );
798 // Set up a scrollView.
799 ScrollView scrollView = ScrollView::New();
801 // Do not rely on stage size for UTC tests.
802 Vector2 pageSize( 720.0f, 1280.0f );
803 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
804 scrollView.SetSize( pageSize );
805 scrollView.SetParentOrigin( ParentOrigin::TOP_LEFT );
806 scrollView.SetAnchorPoint( AnchorPoint::TOP_LEFT );
807 scrollView.SetPosition( 0.0f, 0.0f, 0.0f );
809 // Position rulers - expect Default rulers to be used which don't snap
810 Property::Map rulerMap;
811 rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, true );
812 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, true );
813 scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
815 scrollView.SetWrapMode( false );
816 scrollView.SetScrollSensitive( true );
818 Stage::GetCurrent().Add( scrollView );
820 Vector2 START_POSITION = Vector2(10.0f, 10.0f);
822 scrollView.ScrollTo(START_POSITION, 0.0f);
824 // Try a vertical swipe.
825 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
826 // Take into account resampling done when prediction is off.
827 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
833 int UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP(void)
835 ToolkitTestApplication application;
836 tet_infoline(" UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP");
838 ScrollView scrollView = ScrollView::New();
839 Stage::GetCurrent().Add( scrollView );
840 RulerPtr rulerX = new FixedRuler( 100.0f );
841 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
842 RulerPtr rulerY = new FixedRuler( 100.0f );
843 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
845 scrollView.SetRulerX( rulerX );
846 scrollView.SetRulerY( rulerY );
848 scrollView.SetWrapMode(true);
850 scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DirectionBiasLeft );
852 Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame
853 // Check that the scroll position remains the same
854 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
856 Wait(application, RENDER_DELAY_SCROLL); // Wait for one second
857 // Check that it stays at the same page (i.e. the same scroll position)
858 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
859 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
861 scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DirectionBiasRight );
863 Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame
864 // Check that it scrolls towards the right
865 DALI_TEST_CHECK( scrollView.GetCurrentScrollPosition().x > 0.0f );
867 Wait(application, RENDER_DELAY_SCROLL); // Wait for one second
868 // Check that it scrolls back to the same page (i.e. the same scroll position)
869 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
870 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
875 int UtcDaliToolkitScrollViewScrollToActorP(void)
877 ToolkitTestApplication application;
878 tet_infoline(" UtcDaliToolkitScrollViewScrollToActorP");
880 ScrollView scrollView = ScrollView::New();
881 Stage::GetCurrent().Add( scrollView );
883 Actor actorA = Actor::New();
884 const Vector3 positionA = Vector3(100.0f, 400.0f, 0.0f);
885 actorA.SetPosition(positionA);
886 scrollView.Add(actorA);
888 Actor actorB = Actor::New();
889 const Vector3 positionB = Vector3(500.0f, 200.0f, 0.0f);
890 actorB.SetPosition(positionB);
891 scrollView.Add(actorB);
895 scrollView.ScrollTo(actorA, 0.0f);
897 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION );
900 scrollView.ScrollTo(actorB, 0.0f);
902 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION );
904 scrollView.ScrollTo(actorA);
905 Wait(application, RENDER_DELAY_SCROLL);
906 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION );
908 scrollView.ScrollTo(actorB);
909 Wait(application, RENDER_DELAY_SCROLL);
910 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION );
914 int UtcDaliToolkitScrollViewScrollToSnapPointP(void)
916 ToolkitTestApplication application;
917 tet_infoline(" UtcDaliToolkitScrollViewScrollToSnapPointP");
919 ScrollView scrollView = ScrollView::New();
920 Stage::GetCurrent().Add( scrollView );
921 RulerPtr rulerX = new FixedRuler( 100.0f );
922 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
923 RulerPtr rulerY = new FixedRuler( 100.0f );
924 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
926 scrollView.SetRulerX( rulerX );
927 scrollView.SetRulerY( rulerY );
929 scrollView.ScrollTo( Vector2(120.0f, 190.0f), 0.0f );
931 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(120.0f, 190.0f), TEST_LOCATION );
933 scrollView.ScrollToSnapPoint();
935 Wait(application, RENDER_DELAY_SCROLL);
936 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 200.0f), TEST_LOCATION );
940 int UtcDaliToolkitScrollViewSetScrollUpdateDistanceP(void)
942 ToolkitTestApplication application;
943 tet_infoline(" UtcDaliToolkitScrollViewSetScrollUpdateDistanceP");
945 ScrollView scrollView = ScrollView::New();
947 scrollView.SetScrollUpdateDistance(0);
948 DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 0, TEST_LOCATION);
949 scrollView.SetScrollUpdateDistance(10);
950 DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 10, TEST_LOCATION);
951 scrollView.SetScrollUpdateDistance(1000);
952 DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 1000, TEST_LOCATION);
956 int UtcDaliToolkitScrollViewSetWrapModeP(void)
958 ToolkitTestApplication application;
959 tet_infoline(" UtcDaliToolkitScrollViewSetWrapModeP");
961 ScrollView scrollView = ScrollView::New();
962 Stage::GetCurrent().Add( scrollView );
964 Actor actor = Actor::New();
965 scrollView.Add( actor );
967 // Position rulers. 4x4 grid.
968 RulerPtr rulerX = new FixedRuler(50.0f);
969 RulerPtr rulerY = new FixedRuler(50.0f);
970 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, false) );
971 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, false) );
972 scrollView.SetRulerX(rulerX);
973 scrollView.SetRulerY(rulerY);
975 scrollView.SetWrapMode(false);
976 scrollView.ScrollTo(Vector2(225.0f, 125.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
978 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 17, TEST_LOCATION );
980 scrollView.SetWrapMode(true);
981 scrollView.ScrollTo(Vector2(230.0f, 130.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
983 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 13, TEST_LOCATION );
987 int UtcDaliToolkitScrollViewActorAutoSnap(void)
989 ToolkitTestApplication application;
990 tet_infoline(" UtcDaliToolkitScrollViewActorAutoSnap");
992 ScrollView scrollView = ScrollView::New();
993 Stage::GetCurrent().Add( scrollView );
996 RulerPtr rulerX = new DefaultRuler();
997 RulerPtr rulerY = new DefaultRuler();
998 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
999 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1000 scrollView.SetRulerX(rulerX);
1001 scrollView.SetRulerY(rulerY);
1003 const Vector3 aPosition = Vector3(200.0f, 50.0f, 0.0f);
1004 Actor a = Actor::New();
1006 a.SetPosition(aPosition);
1008 const Vector3 bPosition = Vector3(600.0f, 600.0f, 0.0f);
1009 Actor b = Actor::New();
1011 b.SetPosition(bPosition);
1013 // Goto a random position, and execute snap (should not move)
1014 Vector2 targetScroll = Vector2(500.0f, 500.0f);
1015 scrollView.ScrollTo(targetScroll, 0.0f);
1017 scrollView.ScrollToSnapPoint();
1018 Wait(application, RENDER_DELAY_SCROLL);
1019 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), targetScroll, TEST_LOCATION );
1021 // Enable ActorAutoSnap, and now try snapping.
1022 scrollView.SetActorAutoSnap(true);
1023 scrollView.ScrollToSnapPoint();
1024 Wait(application, RENDER_DELAY_SCROLL);
1025 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), bPosition.GetVectorXY(), TEST_LOCATION );
1027 scrollView.ScrollTo(Vector2(0.0f, 0.0f), 0.0f);
1029 scrollView.ScrollToSnapPoint();
1030 Wait(application, RENDER_DELAY_SCROLL);
1031 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), aPosition.GetVectorXY(), TEST_LOCATION );
1035 int UtcDaliToolkitScrollViewSignalsStartComplete(void)
1037 ToolkitTestApplication application;
1038 tet_infoline(" UtcDaliToolkitScrollViewSignalsStartComplete");
1040 gOnScrollStartCalled = false;
1041 gOnScrollCompleteCalled = false;
1043 ScrollView scrollView = ScrollView::New();
1044 Stage::GetCurrent().Add( scrollView );
1047 RulerPtr rulerX = new DefaultRuler();
1048 RulerPtr rulerY = new DefaultRuler();
1049 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1050 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1051 scrollView.SetRulerX(rulerX);
1052 scrollView.SetRulerY(rulerY);
1053 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1054 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1055 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1056 scrollView.ScrollTo( Vector2(100.0f, 100.0f) );
1057 Wait(application, RENDER_DELAY_SCROLL);
1059 DALI_TEST_CHECK(gOnScrollStartCalled);
1060 DALI_TEST_CHECK(gOnScrollCompleteCalled);
1064 int UtcDaliToolkitScrollViewSignalsUpdate01(void)
1066 ToolkitTestApplication application;
1067 tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate");
1069 gOnScrollStartCalled = false;
1070 gOnScrollUpdateCalled = false;
1071 gOnScrollCompleteCalled = false;
1073 ScrollView scrollView = ScrollView::New();
1074 Stage::GetCurrent().Add( scrollView );
1075 Vector2 stageSize = Stage::GetCurrent().GetSize();
1076 scrollView.SetSize(stageSize);
1077 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1078 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1081 RulerPtr rulerX = new DefaultRuler();
1082 RulerPtr rulerY = new DefaultRuler();
1083 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1084 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1085 scrollView.SetRulerX(rulerX);
1086 scrollView.SetRulerY(rulerY);
1087 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1088 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1089 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1091 Actor image = Actor::New();
1092 image.SetSize(stageSize);
1093 image.SetParentOrigin(ParentOrigin::TOP_LEFT);
1094 image.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1095 scrollView.Add(image);
1099 // Do a pan starting from 100,100 and moving down diagonally.
1100 Vector2 pos(100.0f, 100.0f);
1101 SendPan(application, Gesture::Possible, pos);
1102 SendPan(application, Gesture::Started, pos);
1105 Wait(application, 100);
1107 for(int i = 0;i<20;i++)
1109 SendPan(application, Gesture::Continuing, pos);
1115 SendPan(application, Gesture::Finished, pos);
1116 Wait(application, RENDER_DELAY_SCROLL);
1118 DALI_TEST_CHECK(gOnScrollStartCalled);
1119 DALI_TEST_CHECK(gOnScrollUpdateCalled);
1120 DALI_TEST_CHECK(gOnScrollCompleteCalled);
1124 int UtcDaliToolkitScrollViewSignalsUpdate02(void)
1126 ToolkitTestApplication application;
1127 tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate");
1129 gOnScrollStartCalled = false;
1130 gOnScrollUpdateCalled = false;
1131 gOnScrollCompleteCalled = false;
1133 ScrollView scrollView = ScrollView::New();
1134 Stage::GetCurrent().Add( scrollView );
1135 Vector2 stageSize = Stage::GetCurrent().GetSize();
1136 scrollView.SetSize(stageSize);
1137 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1138 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1141 RulerPtr rulerX = new DefaultRuler();
1142 RulerPtr rulerY = new DefaultRuler();
1143 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1144 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1145 scrollView.SetRulerX(rulerX);
1146 scrollView.SetRulerY(rulerY);
1147 Dali::ConnectionTracker tracker;
1148 bool scrollStarted=false;
1149 bool scrollUpdated=false;
1150 bool scrollCompleted=false;
1151 DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollStarted", CallbackFunctor(&scrollStarted) ));
1152 DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollUpdated", CallbackFunctor(&scrollUpdated) ));
1153 DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollCompleted", CallbackFunctor(&scrollCompleted) ));
1155 Actor image = Actor::New();
1156 image.SetSize(stageSize);
1157 image.SetParentOrigin(ParentOrigin::TOP_LEFT);
1158 image.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1159 scrollView.Add(image);
1163 // Do a pan starting from 100,100 and moving down diagonally.
1164 Vector2 pos(100.0f, 100.0f);
1165 SendPan(application, Gesture::Possible, pos);
1166 SendPan(application, Gesture::Started, pos);
1169 Wait(application, 100);
1171 for(int i = 0;i<20;i++)
1173 SendPan(application, Gesture::Continuing, pos);
1179 SendPan(application, Gesture::Finished, pos);
1180 Wait(application, RENDER_DELAY_SCROLL);
1182 DALI_TEST_CHECK(scrollStarted);
1183 DALI_TEST_CHECK(scrollUpdated);
1184 DALI_TEST_CHECK(scrollCompleted);
1186 Stage::GetCurrent().Remove( scrollView );
1191 int UtcDaliToolkitScrollViewScrollSensitive(void)
1193 ToolkitTestApplication application;
1194 tet_infoline(" UtcDaliToolkitScrollViewScrollSensitive");
1196 // Set up a scrollView...
1197 ScrollView scrollView = ScrollView::New();
1198 scrollView.SetOvershootEnabled(true);
1199 Stage::GetCurrent().Add( scrollView );
1200 Vector2 stageSize = Stage::GetCurrent().GetSize();
1201 scrollView.SetSize(stageSize);
1202 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1203 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1206 RulerPtr rulerX = new DefaultRuler();
1207 RulerPtr rulerY = new DefaultRuler();
1208 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1209 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1210 scrollView.SetRulerX(rulerX);
1211 scrollView.SetRulerY(rulerY);
1212 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1213 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1214 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1215 scrollView.SnapStartedSignal().Connect( &OnSnapStart );
1217 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1220 // First try insensitive swipe.
1221 scrollView.SetScrollSensitive(false);
1222 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, true);
1224 DALI_TEST_CHECK( !gOnScrollStartCalled );
1225 DALI_TEST_CHECK( !gOnScrollCompleteCalled );
1226 DALI_TEST_CHECK( !gOnSnapStartCalled );
1228 // Second try sensitive swipe.
1229 scrollView.SetScrollSensitive(true);
1230 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, true);
1232 DALI_TEST_CHECK( gOnScrollStartCalled );
1233 DALI_TEST_CHECK( gOnScrollCompleteCalled );
1234 DALI_TEST_CHECK( gOnSnapStartCalled );
1238 int UtcDaliToolkitScrollViewAxisAutoLock(void)
1240 ToolkitTestApplication application;
1241 tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLock");
1243 // Set up a scrollView...
1244 ScrollView scrollView = ScrollView::New();
1245 Stage::GetCurrent().Add( scrollView );
1246 Vector2 stageSize = Stage::GetCurrent().GetSize();
1247 scrollView.SetSize(stageSize);
1248 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1249 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1252 RulerPtr rulerX = new DefaultRuler();
1253 RulerPtr rulerY = new DefaultRuler();
1254 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1255 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1256 scrollView.SetRulerX(rulerX);
1257 scrollView.SetRulerY(rulerY);
1258 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1259 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1260 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1263 scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
1265 Vector2 startPosition = scrollView.GetCurrentScrollPosition();
1266 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(5.0f, 1.0f), 50, true); // mostly horizontal
1267 const Vector2 positionAfterNormal = scrollView.GetCurrentScrollPosition();
1270 scrollView.SetAxisAutoLock(true);
1271 DALI_TEST_CHECK(scrollView.GetAxisAutoLock());
1273 scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
1275 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(5.0f, 1.0f), 50, true); // mostly horizontal
1276 const Vector2 positionAfterAutoLock = scrollView.GetCurrentScrollPosition();
1278 // compare how much the Y position has deviated for normal and autolock.
1279 const float devianceNormal = fabsf(startPosition.y - positionAfterNormal.y);
1280 const float devianceAutoLock = fabsf(startPosition.y - positionAfterAutoLock.y);
1282 // in auto-lock it should be a mostly horizontal pan (thus deviance should be much lower)
1283 DALI_TEST_CHECK(devianceAutoLock < devianceNormal);
1285 scrollView.SetAxisAutoLock(false);
1286 DALI_TEST_CHECK(!scrollView.GetAxisAutoLock());
1290 int UtcDaliToolkitScrollViewAxisAutoLockGradient(void)
1292 ToolkitTestApplication application;
1293 tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLockGradient");
1295 // Set up a scrollView...
1296 ScrollView scrollView = ScrollView::New();
1297 scrollView.SetAxisAutoLockGradient(0.5f);
1298 DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 0.5f, TEST_LOCATION);
1299 scrollView.SetAxisAutoLockGradient(1.0f);
1300 DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 1.0f, TEST_LOCATION);
1304 int UtcDaliToolkitScrollViewConstraints(void)
1306 ToolkitTestApplication application;
1307 tet_infoline(" UtcDaliToolkitScrollViewConstraints");
1309 // Set up a scrollView...
1310 ScrollView scrollView = ScrollView::New();
1311 Stage::GetCurrent().Add( scrollView );
1312 Vector2 stageSize = Stage::GetCurrent().GetSize();
1313 scrollView.SetSize(stageSize);
1314 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1315 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1318 RulerPtr rulerX = new DefaultRuler();
1319 RulerPtr rulerY = new DefaultRuler();
1320 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1321 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1322 scrollView.SetRulerX(rulerX);
1323 scrollView.SetRulerY(rulerY);
1325 // Add an Actor to ScrollView,
1326 // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1327 gConstraintResult = Vector3::ZERO;
1328 Actor a = Actor::New();
1330 a.SetPosition( TEST_ACTOR_POSITION );
1333 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1334 constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
1335 constraint.SetRemoveAction(Constraint::Discard);
1336 scrollView.ApplyConstraintToChildren(constraint);
1339 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1341 gConstraintResult = Vector3::ZERO;
1342 scrollView.RemoveConstraintsFromChildren();
1345 DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
1349 int UtcDaliToolkitScrollViewBind(void)
1351 ToolkitTestApplication application;
1352 tet_infoline(" UtcDaliToolkitScrollViewBind");
1354 // Set up a scrollView...
1355 ScrollView scrollView = ScrollView::New();
1356 Stage::GetCurrent().Add( scrollView );
1357 Vector2 stageSize = Stage::GetCurrent().GetSize();
1358 scrollView.SetSize(stageSize);
1359 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1360 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1363 RulerPtr rulerX = new DefaultRuler();
1364 RulerPtr rulerY = new DefaultRuler();
1365 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1366 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1367 scrollView.SetRulerX(rulerX);
1368 scrollView.SetRulerY(rulerY);
1370 // Add an Actor to ScrollView,
1371 // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1373 gConstraintResult = Vector3::ZERO;
1374 Actor a = Actor::New();
1376 a.SetPosition( TEST_ACTOR_POSITION );
1379 // apply this constraint to scrollview
1380 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1381 constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
1382 constraint.SetRemoveAction(Constraint::Discard);
1383 scrollView.ApplyConstraintToChildren(constraint);
1387 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1390 gConstraintResult = Vector3::ZERO;
1391 scrollView.UnbindActor( a );
1393 DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
1396 gConstraintResult = Vector3::ZERO;
1397 scrollView.BindActor( a );
1399 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1403 int UtcDaliToolkitScrollViewOvershoot(void)
1405 ToolkitTestApplication application;
1406 tet_infoline(" UtcDaliToolkitScrollViewOvershoot");
1408 // Set up a scrollView...
1409 ScrollView scrollView = ScrollView::New();
1410 scrollView.SetOvershootEnabled(true);
1412 Vector2 overshootSize = Vector2(100.0f,100.0f);
1413 scrollView.SetProperty( Scrollable::Property::OVERSHOOT_SIZE, overshootSize );
1414 DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_SIZE).Get<Vector2>(), overshootSize, TEST_LOCATION );
1416 Stage::GetCurrent().Add( scrollView );
1417 Vector2 stageSize = Stage::GetCurrent().GetSize();
1418 scrollView.SetSize(stageSize);
1419 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1420 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1423 RulerPtr rulerX = new DefaultRuler();
1424 RulerPtr rulerY = new DefaultRuler();
1425 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1426 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1427 scrollView.SetRulerX(rulerX);
1428 scrollView.SetRulerY(rulerY);
1429 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1430 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1431 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1433 scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1436 // 1. Scroll page in NW (-500,-500 pixels), then inspect overshoot. (don't release touch)
1437 Vector2 currentPos = Vector2(100.0f, 100.0f);
1438 currentPos = PerformGestureDiagonalSwipe(application, currentPos, Vector2(5.0f, 5.0f), 100, false);
1439 float overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1440 float overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1441 Vector2 positionValue = scrollView.GetCurrentProperty< Vector2 >( ScrollView::Property::SCROLL_POSITION );
1442 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1443 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1444 DALI_TEST_EQUALS(positionValue, Vector2::ZERO, TEST_LOCATION);
1446 float timeToReachOrigin;
1448 // Now release touch. Overshoot should snap back to zero.
1449 SendPan(application, Gesture::Finished, currentPos);
1450 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1452 float minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1453 float maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1455 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1456 (timeToReachOrigin < maxTimeToReachOrigin) );
1458 // 2. Repeat Scroll, but this time change overshoot snap duration to shorter time
1459 scrollView.SetSnapOvershootDuration(TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION);
1461 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1462 // Now release touch. Overshoot should snap back to zero.
1463 SendPan(application, Gesture::Finished, currentPos);
1464 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1466 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1467 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1469 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1470 (timeToReachOrigin < maxTimeToReachOrigin) );
1472 // 3. Repeat Scroll, but this time change overshoot snap duration to longer time.
1473 scrollView.SetSnapOvershootDuration(TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION);
1475 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1476 // Now release touch. Overshoot should snap back to zero.
1477 SendPan(application, Gesture::Finished, currentPos);
1478 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1480 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1481 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1483 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1484 (timeToReachOrigin < maxTimeToReachOrigin) );
1486 // 4. Repeat Scroll, but this time change overshoot function.
1487 scrollView.SetSnapOvershootDuration(TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION);
1488 scrollView.SetSnapOvershootAlphaFunction(TestAlphaFunction);
1490 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1491 // Now release touch. Overshoot should snap back to zero.
1492 SendPan(application, Gesture::Finished, currentPos);
1493 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1495 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1496 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1498 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1499 (timeToReachOrigin < maxTimeToReachOrigin) );
1503 int UtcDaliToolkitScrollViewSnapAlphaFunction(void)
1505 ToolkitTestApplication application;
1506 tet_infoline(" UtcDaliToolkitScrollViewSnapAlphaFunction");
1508 // Set up a scrollView...
1509 ScrollView scrollView = ScrollView::New();
1510 scrollView.SetScrollSnapAlphaFunction( AlphaFunction::EASE_IN );
1511 DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_IN );
1512 scrollView.SetScrollSnapAlphaFunction( AlphaFunction::EASE_OUT );
1513 DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_OUT );
1515 scrollView.SetScrollFlickAlphaFunction( AlphaFunction::BOUNCE );
1516 DALI_TEST_CHECK( scrollView.GetScrollFlickAlphaFunction().GetBuiltinFunction() == AlphaFunction::BOUNCE );
1521 int UtcDaliToolkitScrollViewSnapDuration(void)
1523 ToolkitTestApplication application;
1524 tet_infoline(" UtcDaliToolkitScrollViewSnapDuration");
1526 // Set up a scrollView...
1527 ScrollView scrollView = ScrollView::New();
1528 scrollView.SetScrollSnapDuration( 1.0f );
1529 DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 1.0f, TEST_LOCATION );
1530 scrollView.SetScrollSnapDuration( 0.5f );
1531 DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 0.5f, TEST_LOCATION );
1533 scrollView.SetScrollFlickDuration( 2.0f );
1534 DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 2.0f, TEST_LOCATION );
1535 scrollView.SetScrollFlickDuration( 1.5f );
1536 DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 1.5f, TEST_LOCATION );
1540 int UtcDaliToolkitScrollViewSnapStartedSignalP(void)
1542 ToolkitTestApplication application;
1543 tet_infoline(" UtcDaliToolkitScrollViewSnapStartedSignalP");
1545 // Set up a scrollView...
1546 ScrollView scrollView = ScrollView::New();
1547 Stage::GetCurrent().Add( scrollView );
1548 Vector2 stageSize = Stage::GetCurrent().GetSize();
1549 scrollView.SetSize(stageSize);
1550 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1551 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1554 RulerPtr rulerX = new DefaultRuler();
1555 RulerPtr rulerY = new DefaultRuler();
1556 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1557 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1558 scrollView.SetRulerX(rulerX);
1559 scrollView.SetRulerY(rulerY);
1560 scrollView.SnapStartedSignal().Connect( &OnSnapStart );
1562 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1565 // First try a snap.
1566 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(0.5f, 0.0f), 60, true);
1568 DALI_TEST_CHECK( gOnSnapStartCalled );
1569 DALI_TEST_CHECK( gLastSnapType == Toolkit::Snap );
1571 // Second try a swipe.
1572 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(20.0f, 0.0f), 60, true);
1574 DALI_TEST_CHECK( gOnSnapStartCalled );
1575 DALI_TEST_CHECK( gLastSnapType == Toolkit::Flick );
1579 int UtcDaliToolkitScrollViewGetCurrentPageP(void)
1581 ToolkitTestApplication application;
1582 tet_infoline(" UtcDaliToolkitScrollViewGetCurrentPageP");
1584 ScrollView scrollView = ScrollView::New();
1585 Stage::GetCurrent().Add( scrollView );
1586 RulerPtr rulerX = new FixedRuler( 100.0f );
1587 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1588 RulerPtr rulerY = new FixedRuler( 100.0f );
1589 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1591 scrollView.SetRulerX( rulerX );
1592 scrollView.SetRulerY( rulerY );
1594 scrollView.ScrollTo( 15 );
1595 Wait(application, RENDER_DELAY_SCROLL);
1596 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION );
1598 scrollView.ScrollTo( 3 );
1599 Wait(application, RENDER_DELAY_SCROLL);
1600 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION );
1602 scrollView.ScrollTo( 9 );
1603 Wait(application, RENDER_DELAY_SCROLL);
1604 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION );
1609 int UtcDaliToolkitScrollViewSetMaxOvershootP(void)
1611 ToolkitTestApplication application;
1612 tet_infoline(" UtcDaliToolkitScrollViewSetMaxOvershootP");
1614 // Set up a scrollView...
1615 ScrollView scrollView = ScrollView::New();
1616 Stage::GetCurrent().Add( scrollView );
1617 Vector2 stageSize = Stage::GetCurrent().GetSize();
1618 scrollView.SetSize(stageSize);
1619 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1620 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1623 RulerPtr rulerX = new DefaultRuler();
1624 RulerPtr rulerY = new DefaultRuler();
1625 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1626 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1627 scrollView.SetRulerX(rulerX);
1628 scrollView.SetRulerY(rulerY);
1630 // Set the max overshoot to be 50 pixels in both X axis and Y axis
1631 scrollView.SetMaxOvershoot(50.0f, 50.0f);
1633 scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1636 // Scroll page in NW (-20,-20 pixels), then check that overshoot should be 0. (don't release touch)
1637 Vector2 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 20, false);
1638 float overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1639 float overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1640 DALI_TEST_EQUALS(overshootXValue, 0.0f, TEST_LOCATION);
1641 DALI_TEST_EQUALS(overshootYValue, 0.0f, TEST_LOCATION);
1643 // Scroll page further in NW (-105,-105 pixels), then check that overshoot should be around 0.5. (don't release touch)
1644 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 105, false);
1645 overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1646 overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1647 // The overshoot value is a 0.0f - 1.0f ranged value of the amount overshot related to the maximum overshoot.
1648 // EG. If we move 105, max overshoot is 50, then we overshot 50 / 105.
1649 float correctOvershootValue = 50.0f / 105.f;
1650 DALI_TEST_EQUALS( overshootXValue, correctOvershootValue, 0.001f, TEST_LOCATION );
1651 DALI_TEST_EQUALS( overshootYValue, correctOvershootValue, 0.001f, TEST_LOCATION );
1653 // Scroll page further in NW (-30,-30 pixels), then check that overshoot should be now 1.0. (don't release touch)
1654 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 30, false);
1655 overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1656 overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1657 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1658 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1660 // Change the max overshoot to be 100 pixels in both X axis and Y axis
1661 scrollView.SetMaxOvershoot(100.0f, 100.0f);
1664 // Check that overshoot should be now around 0.8.
1665 overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1666 overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1667 DALI_TEST_CHECK(overshootXValue > 0.79f && overshootXValue < 0.81f);
1668 DALI_TEST_CHECK(overshootYValue > 0.79f && overshootYValue < 0.81f);
1670 // Scroll page further in NW (-30,-30 pixels), then check that overshoot should be now 1.0. (don't release touch)
1671 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 30, false);
1672 overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1673 overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1674 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1675 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1680 int UtcDaliToolkitScrollViewSetScrollingDirectionP(void)
1682 ToolkitTestApplication application;
1683 tet_infoline(" UtcDaliToolkitScrollViewSetScrollingDirectionP");
1685 // Set up a scrollView...
1686 ScrollView scrollView = ScrollView::New();
1687 Stage::GetCurrent().Add( scrollView );
1688 Vector2 stageSize = Stage::GetCurrent().GetSize();
1689 scrollView.SetSize(stageSize);
1690 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1691 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1693 Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1695 scrollView.ScrollTo(START_POSITION, 0.0f);
1697 // Try a vertical swipe.
1698 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1699 // Take into account resampling done when prediction is off.
1700 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1702 scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1704 scrollView.ScrollTo(START_POSITION, 0.0f);
1706 // Try a vertical swipe.
1707 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1708 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION );
1710 scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1712 scrollView.ScrollTo(Vector2(10.0f, 10.0f), 0.0f);
1714 // Try a vertical swipe.
1715 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1716 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1721 int UtcDaliToolkitScrollViewRemoveScrollingDirectionP(void)
1723 ToolkitTestApplication application;
1724 tet_infoline(" UtcDaliToolkitScrollViewRemoveScrollingDirectionP");
1726 // Set up a scrollView...
1727 ScrollView scrollView = ScrollView::New();
1728 Stage::GetCurrent().Add( scrollView );
1729 Vector2 stageSize = Stage::GetCurrent().GetSize();
1730 scrollView.SetSize(stageSize);
1731 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1732 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1734 Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1736 scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1738 scrollView.ScrollTo(START_POSITION, 0.0f);
1740 // Try a vertical swipe.
1741 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1742 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION );
1744 scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1746 scrollView.ScrollTo(Vector2(10.0f, 10.0f), 0.0f);
1748 // Try a vertical swipe.
1749 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1750 // Take into account resampling done when prediction is off.
1751 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1756 int UtcDaliToolkitScrollViewSetRulerXP(void)
1758 ToolkitTestApplication application;
1759 tet_infoline(" UtcDaliToolkitScrollViewSetRulerXP");
1761 ScrollView scrollView = ScrollView::New();
1762 Stage::GetCurrent().Add( scrollView );
1763 RulerPtr rulerX = new FixedRuler( 100.0f );
1764 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1766 scrollView.SetRulerX( rulerX );
1768 scrollView.ScrollTo( 1, 0.0f );
1770 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION );
1772 RulerPtr newRulerX = new FixedRuler( 200.0f );
1773 newRulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1775 scrollView.SetRulerX( newRulerX );
1777 scrollView.ScrollTo( 1, 0.0f );
1779 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 0.0f), TEST_LOCATION );
1784 int UtcDaliToolkitScrollViewSetRulerYP(void)
1786 ToolkitTestApplication application;
1787 tet_infoline(" UtcDaliToolkitScrollViewSetRulerYP");
1789 ScrollView scrollView = ScrollView::New();
1790 Stage::GetCurrent().Add( scrollView );
1792 RulerPtr rulerY = new FixedRuler( 200.0f );
1793 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1795 scrollView.SetRulerY( rulerY );
1797 scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f );
1799 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 350.0f), TEST_LOCATION );
1801 RulerPtr newRulerY = new FixedRuler( 100.0f );
1802 newRulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
1803 scrollView.SetRulerY( newRulerY );
1805 scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f );
1807 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 200.0f), TEST_LOCATION );
1812 int UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP(void)
1814 ToolkitTestApplication application;
1815 tet_infoline(" UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP");
1817 ScrollView scrollView = ScrollView::New();
1818 scrollView.SetMinimumSpeedForFlick(25.0f);
1819 DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 25.0f, TEST_LOCATION );
1820 scrollView.SetMinimumSpeedForFlick(60.0f);
1821 DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 60.0f, TEST_LOCATION );
1825 int UtcDaliToolkitScrollViewSetMinimumDistanceForFlickP(void)
1827 ToolkitTestApplication application;
1828 tet_infoline(" UtcDaliToolkitScrollViewSetMinimumDistanceForFlick");
1830 ScrollView scrollView = ScrollView::New();
1832 scrollView.SetMinimumDistanceForFlick(Vector2(30.0f, 15.0f));
1833 DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(30.0f, 15.0f), TEST_LOCATION );
1834 scrollView.SetMinimumDistanceForFlick(Vector2(60.0f, 30.0f));
1835 DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(60.0f, 30.0f), TEST_LOCATION);
1839 int UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP(void)
1841 ToolkitTestApplication application;
1842 tet_infoline(" UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP");
1844 ScrollView scrollView = ScrollView::New();
1845 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
1846 scrollView.SetWheelScrollDistanceStep(Vector2(30.0f, 15.0f));
1847 DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(30.0f, 15.0f), TEST_LOCATION );
1848 scrollView.SetWheelScrollDistanceStep(Vector2(60.0f, 30.0f));
1849 DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(60.0f, 30.0f), TEST_LOCATION);
1853 int UtcDaliToolkitScrollViewApplyEffectP(void)
1855 ToolkitTestApplication application;
1856 tet_infoline(" UtcDaliToolkitScrollViewApplyEffectP");
1858 // Create a ScrollView
1859 ScrollView scrollView = ScrollView::New();
1861 // Create two scroll view effects
1862 Dali::Path path = Dali::Path::New();
1863 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);
1864 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);
1866 // Apply both effects
1867 scrollView.ApplyEffect(effect);
1868 scrollView.ApplyEffect(newEffect);
1870 DALI_TEST_CHECK( true );
1875 int UtcDaliToolkitScrollViewApplyEffectN(void)
1877 ToolkitTestApplication application;
1878 tet_infoline(" UtcDaliToolkitScrollViewApplyEffectN");
1880 // Create a ScrollView
1881 ScrollView scrollView = ScrollView::New();
1883 // Create two scroll view effects
1884 Dali::Path path = Dali::Path::New();
1885 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);
1886 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);
1888 // Apply both effects
1889 scrollView.ApplyEffect(effect);
1890 scrollView.ApplyEffect(newEffect);
1892 // Attempt to apply the same effect again
1895 scrollView.ApplyEffect(newEffect);
1896 tet_result( TET_FAIL );
1898 catch ( DaliException& e )
1900 DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
1906 int UtcDaliToolkitScrollViewRemoveEffectP(void)
1908 ToolkitTestApplication application;
1909 tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectP");
1911 // Create a ScrollView
1912 ScrollView scrollView = ScrollView::New();
1914 // Create two scroll view effects
1915 Dali::Path path = Dali::Path::New();
1916 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);
1917 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);
1919 // Apply both effects
1920 scrollView.ApplyEffect(effect);
1921 scrollView.ApplyEffect(newEffect);
1923 // Remove both effects
1924 scrollView.RemoveEffect(effect);
1925 scrollView.RemoveEffect(newEffect);
1927 DALI_TEST_CHECK( true );
1932 int UtcDaliToolkitScrollViewRemoveEffectN(void)
1934 ToolkitTestApplication application;
1935 tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectN");
1937 // Create a ScrollView
1938 ScrollView scrollView = ScrollView::New();
1940 // Create two scroll view effects
1941 Dali::Path path = Dali::Path::New();
1942 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);
1943 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);
1945 // Apply the first effect
1946 scrollView.ApplyEffect(effect);
1948 // Attempt to remove the second effect which has not been applied to scroll view
1951 scrollView.RemoveEffect(newEffect);
1952 tet_result( TET_FAIL );
1954 catch ( DaliException& e )
1956 DALI_TEST_ASSERT( e, "effectExistedInScrollView", TEST_LOCATION );
1962 int UtcDaliToolkitScrollViewRemoveAllEffectsP(void)
1964 ToolkitTestApplication application;
1965 tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsP");
1967 // Create a ScrollView
1968 ScrollView scrollView = ScrollView::New();
1970 // Create two scroll view effects
1971 Dali::Path path = Dali::Path::New();
1972 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);
1973 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);
1975 // Apply both effects
1976 scrollView.ApplyEffect(effect);
1977 scrollView.ApplyEffect(newEffect);
1979 // Attempt to apply the same first effect again
1982 scrollView.ApplyEffect(effect);
1983 tet_result( TET_FAIL );
1985 catch ( DaliException& e )
1987 DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
1990 // Remove both effects
1991 scrollView.RemoveAllEffects();
1993 // Apply both effects again
1994 scrollView.ApplyEffect(effect);
1995 scrollView.ApplyEffect(newEffect);
1997 DALI_TEST_CHECK( true );
2002 int UtcDaliToolkitScrollViewRemoveAllEffectsN(void)
2004 ToolkitTestApplication application;
2005 tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsN");
2007 // Create a ScrollView
2008 ScrollView scrollView = ScrollView::New();
2010 // Remove effects when there is no effect applied previously
2011 scrollView.RemoveAllEffects();
2013 DALI_TEST_CHECK( true );
2018 int UtcDaliToolkitScrollViewSetOvershootEnabledP(void)
2020 ToolkitTestApplication application;
2021 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEnabledP");
2023 ScrollView scrollView = ScrollView::New();
2025 scrollView.SetOvershootEnabled(true);
2026 DALI_TEST_CHECK(scrollView.IsOvershootEnabled());
2028 scrollView.SetOvershootEnabled(false);
2029 DALI_TEST_CHECK(!scrollView.IsOvershootEnabled());
2034 int UtcDaliToolkitScrollViewSetOvershootEffectColorP(void)
2036 ToolkitTestApplication application;
2037 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEffectColorP");
2039 ScrollView scrollView = ScrollView::New();
2041 scrollView.SetOvershootEffectColor(Dali::Color::RED);
2042 DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::RED, TEST_LOCATION);
2044 scrollView.SetOvershootEffectColor(Dali::Color::YELLOW);
2045 DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::YELLOW, TEST_LOCATION);
2050 int UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP(void)
2052 ToolkitTestApplication application;
2053 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP");
2055 ScrollView scrollView = ScrollView::New();
2057 scrollView.SetOvershootAnimationSpeed(55.0f);
2058 DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 55.0f, TEST_LOCATION);
2060 scrollView.SetOvershootAnimationSpeed(120.0f);
2061 DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 120.0f, TEST_LOCATION);
2066 int UtcDaliToolkitScrollViewGetSet(void)
2068 ToolkitTestApplication application;
2069 tet_infoline(" UtcDaliToolkitScrollViewGetSet");
2070 ScrollView scrollView = ScrollView::New();
2071 scrollView.SetMaxFlickSpeed(0.5f);
2072 DALI_TEST_EQUALS(scrollView.GetMaxFlickSpeed(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
2073 scrollView.SetFrictionCoefficient(0.6f);
2074 DALI_TEST_EQUALS(scrollView.GetFrictionCoefficient(), 0.6f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
2075 scrollView.SetFlickSpeedCoefficient(0.7f);
2076 DALI_TEST_EQUALS(scrollView.GetFlickSpeedCoefficient(), 0.7f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
2080 int UtcDaliToolkitScrollViewRulerDomainConstructorP(void)
2082 ToolkitTestApplication application;
2084 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2085 DALI_TEST_EQUALS( domainX.min, 0.0f, TEST_LOCATION);
2086 DALI_TEST_EQUALS( domainX.max, 200.0f, TEST_LOCATION);
2087 DALI_TEST_EQUALS( domainX.enabled, true, TEST_LOCATION);
2089 RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
2090 DALI_TEST_EQUALS( domainY.min, 100.0f, TEST_LOCATION);
2091 DALI_TEST_EQUALS( domainY.max, 500.0f, TEST_LOCATION);
2092 DALI_TEST_EQUALS( domainY.enabled, false, TEST_LOCATION);
2097 int UtcDaliToolkitScrollViewRulerDomainGetSizeP(void)
2099 ToolkitTestApplication application;
2101 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2102 DALI_TEST_EQUALS( domainX.GetSize(), 200.0f, TEST_LOCATION);
2104 RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
2105 DALI_TEST_EQUALS( domainY.GetSize(), 400.0f, TEST_LOCATION);
2110 int UtcDaliToolkitScrollViewRulerDomainClampP(void)
2112 ToolkitTestApplication application;
2114 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2116 float value = domainX.Clamp(50.0f, 100.0f, 1.0f);
2117 DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
2119 value = domainX.Clamp(300.0f, 20.0f, 1.0f);
2120 DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
2122 value = domainX.Clamp(300.0f, 20.0f, 0.5f);
2123 DALI_TEST_EQUALS( value, 80.0f, TEST_LOCATION);
2125 value = domainX.Clamp(250.0f, 200.0f, 2.0f);
2126 DALI_TEST_EQUALS( value, 200.0f, TEST_LOCATION);
2131 int UtcDaliToolkitScrollViewRulerDomainClampWithStateP(void)
2133 ToolkitTestApplication application;
2135 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2138 float value = domainX.Clamp(50.0f, 100.0f, 1.0f, clamped);
2139 DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
2140 DALI_TEST_EQUALS( clamped, Dali::Toolkit::NotClamped, TEST_LOCATION);
2142 value = domainX.Clamp(-100.0f, 200.0f, 1.0f, clamped);
2143 DALI_TEST_EQUALS( value, 0.0f, TEST_LOCATION);
2144 DALI_TEST_EQUALS( clamped, Dali::Toolkit::ClampedToMin, TEST_LOCATION);
2146 value = domainX.Clamp(300.0f, 20.0f, 1.0f, clamped);
2147 DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
2148 DALI_TEST_EQUALS( clamped, Dali::Toolkit::ClampedToMax, TEST_LOCATION);
2153 int UtcDaliToolkitScrollViewDefaultRulerConstructorP(void)
2155 ToolkitTestApplication application;
2156 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerConstructorP");
2158 RulerPtr defaultRuler = new DefaultRuler();
2159 DALI_TEST_CHECK( defaultRuler );
2164 int UtcDaliToolkitScrollViewDefaultRulerDestructorP(void)
2166 ToolkitTestApplication application;
2167 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerDestructorP");
2169 RulerPtr defaultRuler = new DefaultRuler();
2171 DALI_TEST_CHECK( true );
2175 int UtcDaliToolkitScrollViewFixedRulerConstructorP(void)
2177 ToolkitTestApplication application;
2178 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerConstructorP");
2180 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2181 DALI_TEST_CHECK( fixedRuler );
2183 fixedRuler = new FixedRuler( 0.0f );
2184 DALI_TEST_CHECK( fixedRuler );
2189 int UtcDaliToolkitScrollViewFixedRulerDestructorP(void)
2191 ToolkitTestApplication application;
2192 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerDestructorP");
2194 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2196 DALI_TEST_CHECK( true );
2200 int UtcDaliToolkitScrollViewRulerGetTypeP(void)
2202 ToolkitTestApplication application;
2203 tet_infoline(" UtcDaliToolkitScrollViewRulerGetTypeP");
2205 RulerPtr defaultRuler = new DefaultRuler();
2206 DALI_TEST_CHECK( defaultRuler );
2207 DALI_TEST_EQUALS( defaultRuler->GetType(), Dali::Toolkit::Ruler::Free, TEST_LOCATION);
2209 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2210 DALI_TEST_CHECK( fixedRuler );
2211 DALI_TEST_EQUALS( fixedRuler->GetType(), Dali::Toolkit::Ruler::Fixed, TEST_LOCATION);
2216 int UtcDaliToolkitScrollViewRulerGetExtensionP(void)
2218 ToolkitTestApplication application;
2219 tet_infoline(" UtcDaliToolkitScrollViewRulerGetExtensionP");
2221 RulerPtr defaultRuler = new DefaultRuler();
2222 DALI_TEST_CHECK( defaultRuler );
2223 DALI_TEST_CHECK( !defaultRuler->GetExtension() );
2225 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2226 DALI_TEST_CHECK( fixedRuler );
2227 DALI_TEST_CHECK( !fixedRuler->GetExtension() );
2232 int UtcDaliToolkitScrollViewRulerEnableDisable(void)
2234 ToolkitTestApplication application;
2235 tet_infoline(" UtcDaliToolkitScrollViewRulerEnableDisable");
2237 RulerPtr ruler = new DefaultRuler();
2239 DALI_TEST_CHECK( ruler->IsEnabled() );
2241 DALI_TEST_CHECK( !ruler->IsEnabled() );
2243 DALI_TEST_CHECK( ruler->IsEnabled() );
2247 int UtcDaliToolkitScrollViewRulerDomainEnableDisable(void)
2249 ToolkitTestApplication application;
2250 tet_infoline(" UtcDaliToolkitScrollViewRulerDomainEnableDisable");
2252 RulerPtr ruler = new DefaultRuler();
2253 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
2255 ruler->SetDomain( RulerDomain(0.0f, 100.0f, true) );
2256 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 100.0f, TEST_LOCATION );
2257 DALI_TEST_EQUALS( ruler->Clamp(-200.0f), 0.0f, TEST_LOCATION );
2258 DALI_TEST_EQUALS( ruler->Clamp(200.0f), 100.0f, TEST_LOCATION );
2260 ruler->DisableDomain();
2261 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
2262 DALI_TEST_EQUALS( ruler->Clamp(-200.0f), -200.0f, TEST_LOCATION );
2263 DALI_TEST_EQUALS( ruler->Clamp(200.0f), 200.0f, TEST_LOCATION );
2267 int UtcDaliToolkitScrollViewRulerSnapAndClamp(void)
2269 ToolkitTestApplication application;
2270 tet_infoline(" UtcDaliToolkitScrollViewRulerSnapAndClamp");
2272 RulerPtr ruler = new FixedRuler( 50.0f );
2273 ruler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2275 // default testing. (snap and clamp)
2276 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f), 50.0f, TEST_LOCATION);
2277 DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f), 50.0f, TEST_LOCATION);
2278 DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f), 0.0f, TEST_LOCATION);
2279 DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f), 0.0f, TEST_LOCATION);
2280 DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f), 400.0f, TEST_LOCATION);
2281 DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f), 400.0f, TEST_LOCATION);
2284 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
2285 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.5f), 50.0f, TEST_LOCATION); // No Flick
2286 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
2288 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
2289 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.5f), 0.0f, TEST_LOCATION); // No Flick
2290 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
2293 DALI_TEST_EQUALS( ruler->SnapAndClamp(-10.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (over left boundary)
2294 DALI_TEST_EQUALS( ruler->SnapAndClamp(-5.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (slightly ovr left boundary)
2295 DALI_TEST_EQUALS( ruler->SnapAndClamp(300.0f, 0.5f, 10.0f), 300.0f, TEST_LOCATION); // 10 units long (not over a boundary)
2296 DALI_TEST_EQUALS( ruler->SnapAndClamp(395.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (slightly over right boundary)
2297 DALI_TEST_EQUALS( ruler->SnapAndClamp(500.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (over right boundary)
2300 DALI_TEST_EQUALS( ruler->SnapAndClamp(-100.0f, 0.5f, 0.0f, 2.0f), 0.0f, TEST_LOCATION);
2301 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 2.0f), 50.0f, TEST_LOCATION);
2302 DALI_TEST_EQUALS( ruler->SnapAndClamp(700.0f, 0.5f, 0.0f, 2.0f), 700.0f, TEST_LOCATION);
2303 DALI_TEST_EQUALS( ruler->SnapAndClamp(850.0f, 0.5f, 0.0f, 2.0f), 800.0f, TEST_LOCATION);
2305 // clamp state testing.
2307 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
2308 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2309 DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
2310 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2311 DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
2312 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2313 DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
2314 DALI_TEST_EQUALS( clamped, ClampedToMin, TEST_LOCATION );
2315 DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
2316 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2317 DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
2318 DALI_TEST_EQUALS( clamped, ClampedToMax, TEST_LOCATION );
2322 int UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP(void)
2324 ToolkitTestApplication application;
2325 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP");
2327 RulerPtr rulerNormal = new FixedRuler( 25.0f );
2328 rulerNormal->SetDomain( RulerDomain(10.0f, 90.0f, true) );
2330 unsigned int volume;
2333 position = rulerNormal->GetPositionFromPage(1, volume, true);
2334 DALI_TEST_EQUALS( position, 35.0f, TEST_LOCATION );
2335 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
2337 position = rulerNormal->GetPositionFromPage(2, volume, true);
2338 DALI_TEST_EQUALS( position, 60.0f, TEST_LOCATION );
2339 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
2341 // Disable the ruler
2342 rulerNormal->Disable();
2344 position = rulerNormal->GetPositionFromPage(1, volume, true);
2345 DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
2346 DALI_TEST_EQUALS( volume, 1u, TEST_LOCATION );
2348 position = rulerNormal->GetPositionFromPage(2, volume, true);
2349 DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
2350 DALI_TEST_EQUALS( volume, 2u, TEST_LOCATION );
2355 int UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP(void)
2357 ToolkitTestApplication application;
2358 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP");
2360 RulerPtr defaultRuler = new DefaultRuler();
2361 DALI_TEST_CHECK( defaultRuler );
2362 DALI_TEST_EQUALS( defaultRuler->GetTotalPages(), 1u, TEST_LOCATION);
2367 int UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP(void)
2369 ToolkitTestApplication application;
2370 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP");
2372 RulerPtr defaultRuler = new DefaultRuler();
2373 DALI_TEST_CHECK( defaultRuler );
2374 DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(100.0f, true), 0u, TEST_LOCATION);
2375 DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(-300.0f, false), 0u, TEST_LOCATION);
2380 int UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP(void)
2382 ToolkitTestApplication application;
2383 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP");
2385 RulerPtr defaultRuler = new DefaultRuler();
2386 DALI_TEST_CHECK( defaultRuler );
2388 unsigned int volume;
2389 DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(0, volume, true), 0.0f, TEST_LOCATION);
2390 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
2392 DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(3, volume, false), 0.0f, TEST_LOCATION);
2393 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
2398 int UtcDaliToolkitScrollViewDefaultRulerSnapP(void)
2400 ToolkitTestApplication application;
2401 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerSnapP");
2403 RulerPtr defaultRuler = new DefaultRuler();
2404 DALI_TEST_CHECK( defaultRuler );
2406 DALI_TEST_EQUALS( defaultRuler->Snap(50.0f, 0.5f), 50.0f, TEST_LOCATION);
2407 DALI_TEST_EQUALS( defaultRuler->Snap(-120.0f, 1.0f), -120.0f, TEST_LOCATION);
2412 int UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP(void)
2414 ToolkitTestApplication application;
2415 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP");
2417 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2418 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2420 fixedRuler->Enable();
2421 DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 4u, TEST_LOCATION);
2423 fixedRuler->Disable();
2424 DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 1u, TEST_LOCATION);
2429 int UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP(void)
2431 ToolkitTestApplication application;
2432 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP");
2434 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2435 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2437 fixedRuler->Enable();
2438 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 3u, TEST_LOCATION);
2439 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2440 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 1u, TEST_LOCATION);
2441 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2443 fixedRuler->Disable();
2444 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2445 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
2446 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2447 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2449 // Set domain size to be smaller than the ruler space
2450 fixedRuler->SetDomain( RulerDomain(0.0f, 50.0f, true) );
2452 fixedRuler->Enable();
2453 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2454 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2455 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2456 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2458 fixedRuler->Disable();
2459 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2460 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
2461 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2462 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2467 int UtcDaliToolkitScrollViewFixedRulerSnapP(void)
2469 ToolkitTestApplication application;
2470 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerSnapP");
2472 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2473 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2475 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.0f), -100.0f, TEST_LOCATION);
2476 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.0f), -100.0f, TEST_LOCATION);
2477 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.0f), -200.0f, TEST_LOCATION);
2478 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.0f), -500.0f, TEST_LOCATION);
2479 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.0f), 0.0f, TEST_LOCATION);
2480 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.0f), 0.0f, TEST_LOCATION);
2481 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.0f), 0.0f, TEST_LOCATION);
2482 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.0f), 100.0f, TEST_LOCATION);
2483 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.0f), 100.0f, TEST_LOCATION);
2484 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.0f), 200.0f, TEST_LOCATION);
2485 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.0f), 600.0f, TEST_LOCATION);
2487 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.5f), 0.0f, TEST_LOCATION);
2488 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.5f), -100.0f, TEST_LOCATION);
2489 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.5f), -100.0f, TEST_LOCATION);
2490 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.5f), -500.0f, TEST_LOCATION);
2491 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.5f), 0.0f, TEST_LOCATION);
2492 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.5f), 100.0f, TEST_LOCATION);
2493 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.5f), 100.0f, TEST_LOCATION);
2494 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.5f), 100.0f, TEST_LOCATION);
2495 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.5f), 100.0f, TEST_LOCATION);
2496 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.5f), 300.0f, TEST_LOCATION);
2497 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.5f), 600.0f, TEST_LOCATION);
2499 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 1.0f), 0.0f, TEST_LOCATION);
2500 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 1.0f), 0.0f, TEST_LOCATION);
2501 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 1.0f), -100.0f, TEST_LOCATION);
2502 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 1.0f), -400.0f, TEST_LOCATION);
2503 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 1.0f), 100.0f, TEST_LOCATION);
2504 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 1.0f), 100.0f, TEST_LOCATION);
2505 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 1.0f), 100.0f, TEST_LOCATION);
2506 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 1.0f), 200.0f, TEST_LOCATION);
2507 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 1.0f), 200.0f, TEST_LOCATION);
2508 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 1.0f), 300.0f, TEST_LOCATION);
2509 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 1.0f), 700.0f, TEST_LOCATION);
2514 int UtcDaliToolkitScrollViewConstraintsMove(void)
2516 ToolkitTestApplication application;
2517 tet_infoline(" UtcDaliToolkitScrollViewConstraintsMove");
2519 // Set up a scrollView...
2520 ScrollView scrollView = ScrollView::New();
2521 Stage::GetCurrent().Add( scrollView );
2522 Vector2 stageSize = Stage::GetCurrent().GetSize();
2523 scrollView.SetSize(stageSize);
2524 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
2525 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2528 RulerPtr rulerX = new DefaultRuler();
2529 RulerPtr rulerY = new DefaultRuler();
2530 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
2531 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
2532 scrollView.SetRulerX(rulerX);
2533 scrollView.SetRulerY(rulerY);
2535 // Add an Actor to ScrollView,
2536 Actor a = Actor::New();
2538 a.SetPosition( TEST_ACTOR_POSITION );
2541 const Vector2 target = Vector2(100.0f, 100.0f);
2542 const Vector2 target2 = Vector2(200.0f, 200.0f);
2544 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, MoveActorConstraint );
2545 constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
2546 constraint.SetRemoveAction(Constraint::Discard);
2547 scrollView.ApplyConstraintToChildren(constraint);
2549 scrollView.ScrollTo( target, 0.0f );
2551 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
2552 scrollView.ScrollTo( target2 );
2553 Wait(application, RENDER_DELAY_SCROLL);
2554 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
2559 int UtcDaliToolkitScrollViewConstraintsWrap(void)
2561 ToolkitTestApplication application;
2562 tet_infoline(" UtcDaliToolkitScrollViewConstraintsWrap");
2564 // Set up a scrollView...
2565 ScrollView scrollView = ScrollView::New();
2566 Stage::GetCurrent().Add( scrollView );
2567 Vector2 stageSize = Stage::GetCurrent().GetSize();
2568 scrollView.SetSize(stageSize);
2569 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
2570 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2573 RulerPtr rulerX = new DefaultRuler();
2574 RulerPtr rulerY = new DefaultRuler();
2575 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
2576 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
2577 scrollView.SetRulerX(rulerX);
2578 scrollView.SetRulerY(rulerY);
2580 // Add an Actor to ScrollView,
2581 Actor a = Actor::New();
2583 a.SetPosition( TEST_ACTOR_POSITION );
2586 const Vector2 target = Vector2(100.0f, 100.0f);
2587 const Vector2 target2 = Vector2(200.0f, 200.0f);
2589 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, WrapActorConstraint );
2590 constraint.AddSource( LocalSource( Actor::Property::SCALE ) );
2591 constraint.AddSource( LocalSource( Actor::Property::ANCHOR_POINT ) );
2592 constraint.AddSource( LocalSource( Actor::Property::SIZE ) );
2593 constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
2594 constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
2595 constraint.AddSource( Source( scrollView, Toolkit::ScrollView::Property::WRAP ) );
2596 constraint.SetRemoveAction(Constraint::Discard);
2597 scrollView.ApplyConstraintToChildren(constraint);
2599 scrollView.ScrollTo( target, 0.0f );
2601 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
2602 scrollView.ScrollTo( target2 );
2603 Wait(application, RENDER_DELAY_SCROLL);
2604 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
2606 scrollView.Remove(a);
2612 // Non-API test (so no P or N variant).
2613 int UtcDaliToolkitScrollViewGesturePageLimit(void)
2615 ToolkitTestApplication application;
2616 tet_infoline( " UtcDaliToolkitScrollViewGesturePageLimit" );
2618 // Set up a scrollView.
2619 ScrollView scrollView = ScrollView::New();
2621 // Do not rely on stage size for UTC tests.
2622 Vector2 pageSize( 720.0f, 1280.0f );
2623 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
2624 scrollView.SetSize( pageSize );
2625 scrollView.SetParentOrigin( ParentOrigin::CENTER );
2626 scrollView.SetAnchorPoint( AnchorPoint::CENTER );
2627 scrollView.SetPosition( 0.0f, 0.0f, 0.0f );
2630 // We set the X ruler to fixed to give us pages to snap to.
2631 Dali::Toolkit::FixedRuler* rulerX = new Dali::Toolkit::FixedRuler( pageSize.width );
2632 // Note: The 3x page width is arbitary, but we need enough to show that we are
2633 // capping page movement by the page limiter, and not the domain.
2634 rulerX->SetDomain( Dali::Toolkit::RulerDomain( 0.0f, pageSize.width * 3.0f, false ) );
2635 Dali::Toolkit::RulerPtr rulerY = new Dali::Toolkit::DefaultRuler();
2637 scrollView.SetRulerX( rulerX );
2638 scrollView.SetRulerY( rulerY );
2640 scrollView.SetWrapMode( false );
2641 scrollView.SetScrollSensitive( true );
2643 Stage::GetCurrent().Add( scrollView );
2645 // Set up a gesture to perform.
2646 Vector2 startPos( 50.0f, 0.0f );
2647 Vector2 direction( -5.0f, 0.0f );
2650 // Force starting position.
2651 scrollView.ScrollTo( startPos, 0.0f );
2652 Wait( application );
2654 // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
2655 Vector2 currentPos( PerformGestureDiagonalSwipe( application, startPos, direction, frames - 1, false ) );
2657 // Confirm the final X coord has not moved more than one page from the start X position.
2658 DALI_TEST_GREATER( ( startPos.x + pageSize.width ), scrollView.GetCurrentScrollPosition().x, TEST_LOCATION );
2660 // Finish the gesture and wait for the snap.
2661 currentPos += direction;
2662 SendPan( application, Gesture::Finished, currentPos );
2663 // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
2664 Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
2666 // Confirm the final X coord has snapped to exactly one page ahead of the start page.
2667 DALI_TEST_EQUALS( pageSize.width, scrollView.GetCurrentScrollPosition().x, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2672 int UtcDaliScrollViewSetGetProperty(void)
2674 ToolkitTestApplication application;
2676 // Create the ScrollView actor
2677 ScrollView scrollView = ScrollView::New();
2678 DALI_TEST_CHECK(scrollView);
2680 // Event side properties
2682 // Test "wrapEnabled" property
2683 DALI_TEST_CHECK( scrollView.GetPropertyIndex("wrapEnabled") == ScrollView::Property::WRAP_ENABLED );
2684 scrollView.SetProperty( ScrollView::Property::WRAP_ENABLED, true );
2685 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WRAP_ENABLED).Get<bool>(), true, TEST_LOCATION );
2687 // Test "panningEnabled" property
2688 DALI_TEST_CHECK( scrollView.GetPropertyIndex("panningEnabled") == ScrollView::Property::PANNING_ENABLED );
2689 scrollView.SetProperty( ScrollView::Property::PANNING_ENABLED, false );
2690 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::PANNING_ENABLED).Get<bool>(), false, TEST_LOCATION );
2692 // Test "axisAutoLockEnabled" property
2693 DALI_TEST_CHECK( scrollView.GetPropertyIndex("axisAutoLockEnabled") == ScrollView::Property::AXIS_AUTO_LOCK_ENABLED );
2694 scrollView.SetProperty( ScrollView::Property::AXIS_AUTO_LOCK_ENABLED, false );
2695 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::AXIS_AUTO_LOCK_ENABLED).Get<bool>(), false, TEST_LOCATION );
2697 // Test "wheelScrollDistanceStep" property
2698 DALI_TEST_CHECK( scrollView.GetPropertyIndex("wheelScrollDistanceStep") == ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP );
2699 scrollView.SetProperty( ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP, Vector2(100.0f, 50.0f) );
2700 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP).Get<Vector2>(), Vector2(100.0f, 50.0f), TEST_LOCATION );
2702 // Test "overshootEnabled" property
2703 DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootEnabled") == Scrollable::Property::OVERSHOOT_ENABLED );
2704 DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), scrollView.IsOvershootEnabled(), TEST_LOCATION );
2705 scrollView.SetProperty( Scrollable::Property::OVERSHOOT_ENABLED, false );
2706 DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), false, TEST_LOCATION );
2708 // Animatable properties
2710 // Test "scrollPosition" property
2711 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPosition") == ScrollView::Property::SCROLL_POSITION );
2712 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(320.0f, 550.0f) );
2714 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION).Get<Vector2>(), Vector2(320.0f, 550.0f), TEST_LOCATION );
2716 // Test "scrollPrePosition", "scrollPrePositionX" and "scrollPrePositionY" properties
2717 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePosition") == ScrollView::Property::SCROLL_PRE_POSITION );
2718 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION, Vector2(300.0f, 500.0f) );
2720 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION).Get<Vector2>(), Vector2(300.0f, 500.0f), TEST_LOCATION );
2722 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionX") == ScrollView::Property::SCROLL_PRE_POSITION_X );
2723 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionY") == ScrollView::Property::SCROLL_PRE_POSITION_Y );
2724 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_X).Get<float>(), 300.0f, TEST_LOCATION );
2725 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_Y).Get<float>(), 500.0f, TEST_LOCATION );
2726 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_X, 400.0f );
2727 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_Y, 600.0f );
2729 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_X).Get<float>(), 400.0f, TEST_LOCATION );
2730 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_Y).Get<float>(), 600.0f, TEST_LOCATION );
2731 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION).Get<Vector2>(), Vector2(400.0f, 600.0f), TEST_LOCATION );
2733 // Test "scrollPrePositionMax", "scrollPrePositionMaxX" and "scrollPrePositionMaxY" properties
2734 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMax") == ScrollView::Property::SCROLL_PRE_POSITION_MAX );
2735 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX, Vector2(100.0f, 200.0f) );
2737 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX).Get<Vector2>(), Vector2(100.0f, 200.0f), TEST_LOCATION );
2739 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMaxX") == ScrollView::Property::SCROLL_PRE_POSITION_MAX_X );
2740 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMaxY") == ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y );
2741 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_X).Get<float>(), 100.0f, TEST_LOCATION );
2742 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y).Get<float>(), 200.0f, TEST_LOCATION );
2743 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX_X, 300.0f );
2744 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y, 400.0f );
2746 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_X).Get<float>(), 300.0f, TEST_LOCATION );
2747 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y).Get<float>(), 400.0f, TEST_LOCATION );
2748 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX).Get<Vector2>(), Vector2(300.0f, 400.0f), TEST_LOCATION );
2750 // Test "overshootX" property
2751 DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootX") == ScrollView::Property::OVERSHOOT_X );
2752 scrollView.SetProperty( ScrollView::Property::OVERSHOOT_X, 0.8f );
2754 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::OVERSHOOT_X).Get<float>(), 0.8f, TEST_LOCATION );
2756 // Test "overshootY" property
2757 DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootY") == ScrollView::Property::OVERSHOOT_Y );
2758 scrollView.SetProperty( ScrollView::Property::OVERSHOOT_Y, 0.8f );
2760 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y).Get<float>(), 0.8f, TEST_LOCATION );
2762 // Test "scrollFinal", "scrollFinalX" and "scrollFinalY" properties
2763 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinal") == ScrollView::Property::SCROLL_FINAL );
2764 scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL, Vector2(200.0f, 300.0f) );
2766 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL).Get<Vector2>(), Vector2(200.0f, 300.0f), TEST_LOCATION );
2768 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinalX") == ScrollView::Property::SCROLL_FINAL_X );
2769 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinalY") == ScrollView::Property::SCROLL_FINAL_Y );
2770 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_X).Get<float>(), 200.0f, TEST_LOCATION );
2771 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_Y).Get<float>(), 300.0f, TEST_LOCATION );
2772 scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL_X, 500.0f );
2773 scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL_Y, 600.0f );
2775 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_X).Get<float>(), 500.0f, TEST_LOCATION );
2776 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_Y).Get<float>(), 600.0f, TEST_LOCATION );
2777 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL).Get<Vector2>(), Vector2(500.0f, 600.0f), TEST_LOCATION );
2779 // Test "wrap" property
2780 DALI_TEST_CHECK( scrollView.GetPropertyIndex("wrap") == ScrollView::Property::WRAP );
2781 scrollView.SetProperty( ScrollView::Property::WRAP, false );
2783 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WRAP).Get<bool>(), false, TEST_LOCATION );
2785 // Test "panning" property
2786 DALI_TEST_CHECK( scrollView.GetPropertyIndex("panning") == ScrollView::Property::PANNING );
2787 scrollView.SetProperty( ScrollView::Property::PANNING, true );
2789 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::PANNING).Get<bool>(), true, TEST_LOCATION );
2791 // Test "scrolling" property
2792 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrolling") == ScrollView::Property::SCROLLING );
2793 scrollView.SetProperty( ScrollView::Property::SCROLLING, false );
2795 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLLING).Get<bool>(), false, TEST_LOCATION );
2797 // Test "scrollDomainSize", "scrollDomainSizeX" and "scrollDomainSizeY" properties
2798 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSize") == ScrollView::Property::SCROLL_DOMAIN_SIZE );
2799 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE, Vector2(1200.0f, 1300.0f) );
2801 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE).Get<Vector2>(), Vector2(1200.0f, 1300.0f), TEST_LOCATION );
2803 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSizeX") == ScrollView::Property::SCROLL_DOMAIN_SIZE_X );
2804 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSizeY") == ScrollView::Property::SCROLL_DOMAIN_SIZE_Y );
2805 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_X).Get<float>(), 1200.0f, TEST_LOCATION );
2806 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_Y).Get<float>(), 1300.0f, TEST_LOCATION );
2807 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE_X, 1500.0f );
2808 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE_Y, 1600.0f );
2810 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_X).Get<float>(), 1500.0f, TEST_LOCATION );
2811 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_Y).Get<float>(), 1600.0f, TEST_LOCATION );
2812 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE).Get<Vector2>(), Vector2(1500.0f, 1600.0f), TEST_LOCATION );
2814 // Test "scrollDomainOffset" property
2815 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainOffset") == ScrollView::Property::SCROLL_DOMAIN_OFFSET );
2816 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_OFFSET, Vector2(500.0f, 200.0f) );
2818 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_OFFSET).Get<Vector2>(), Vector2(500.0f, 200.0f), TEST_LOCATION );
2820 // Test "scrollPositionDelta" property
2821 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPositionDelta") == ScrollView::Property::SCROLL_POSITION_DELTA );
2822 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION_DELTA, Vector2(10.0f, 30.0f) );
2824 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION_DELTA).Get<Vector2>(), Vector2(10.0f, 30.0f), TEST_LOCATION );
2826 // Test "startPagePosition" property
2827 DALI_TEST_CHECK( scrollView.GetPropertyIndex("startPagePosition") == ScrollView::Property::START_PAGE_POSITION );
2828 scrollView.SetProperty( ScrollView::Property::START_PAGE_POSITION, Vector3(50.0f, 100.0f, 20.0f) );
2830 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::START_PAGE_POSITION).Get<Vector3>(), Vector3(50.0f, 100.0f, 20.0f), TEST_LOCATION );