2 * Copyright (c) 2020 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/wheel-event-integ.h>
26 using namespace Toolkit;
28 void scroll_view_startup(void)
30 test_return_value = TET_UNDEF;
33 void scroll_view_cleanup(void)
35 test_return_value = TET_PASS;
40 static bool gObjectCreatedCallBackCalled;
42 static void TestCallback(BaseHandle handle)
44 gObjectCreatedCallBackCalled = true;
47 struct CallbackFunctor
49 CallbackFunctor(bool* callbackFlag)
50 : mCallbackFlag( callbackFlag )
56 *mCallbackFlag = true;
61 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
63 const int RENDER_DELAY_SCROLL = 1000; ///< duration to wait for any scroll to complete.
65 // For Clamp Signal testing...
66 const float CLAMP_EXCESS_WIDTH = 200.0f; ///< Amount of width that can be panned outside scrollview
67 const float CLAMP_EXCESS_HEIGHT = 200.0f; ///< Amount of height that can be panned outside scrollview
68 const Vector2 CLAMP_START_SCROLL_POSITION(30.0f, 100.0f); ///< Scroll start position for the Clamping tests.
69 const Vector2 CLAMP_TOUCH_START( 100.0f, 100.0f ); ///< Start point to touch from for the Clamping tests.
70 const Vector2 CLAMP_TOUCH_MOVEMENT( 5.0f, -5.0f ); ///< Amount to move touch for each frame for the Clamping tests.
71 const int CLAMP_GESTURE_FRAMES = 100; ///< Number of Frames to synthesize a gesture for the Clamping tests.
72 const Vector3 TEST_ACTOR_POSITION(100.0f, 100.0f, 0.0f); ///< A Test actor position offset (arbitrary value)
73 const Vector3 TEST_CONSTRAINT_OFFSET(1.0f, 2.0f, 0.0f); ///< A Test constraint offset (arbitrary value to test effects)
75 const float DEFAULT_SNAP_OVERSHOOT_DURATION(0.5f); ///< Default overshoot snapping animation time.
76 const float DEFAULT_MAX_OVERSHOOT(100.0f); ///< Default maximum allowed overshoot in pixels
78 const int MAX_FRAMES_TO_TEST_OVERSHOOT = 600; ///< 10 seconds (at 60 frames per second).
79 const Vector2 OVERSHOOT_START_SCROLL_POSITION(100.0f, 100.0f); ///< Scroll start position for the Overshoot tests.
80 const float SCROLL_ANIMATION_DURATION(0.33f); ///< Duration of scroll animation in Overshoot tests (i.e. 100 pixels of overshoot in the speed of 500 pixels per 100 frames, 100/(500/(100/60)) = 0.33)
81 const Vector2 SNAP_POSITION_WITH_DECELERATED_VELOCITY(74.0f, 74.0f); ///< the snap position for Overshoot tests with the decelerated velocity (i.e. Decelerated from 500 pixels per 100 frames).
82 const float TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION = 0.05f; ///< a Test duration
83 const float TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION = 1.5f; ///< another Test duration
84 const float TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION = TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * 0.5f; // Same as above, but different alpha function.
85 const float TIME_TOLERANCE = 0.05f; ///< Allow testing tolerance between a 10th of second (+/- 3 frames)
89 * Simulate time passed by.
91 * @note this will always process at least 1 frame (1/60 sec)
93 * @param application Test application instance
94 * @param duration Time to pass in milliseconds.
95 * @return The actual time passed in milliseconds
97 int Wait(ToolkitTestApplication& application, int duration = 0)
101 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
103 application.SendNotification();
104 application.Render(RENDER_FRAME_INTERVAL);
105 time += RENDER_FRAME_INTERVAL;
113 static bool gOnScrollStartCalled; ///< Whether the OnScrollStart signal was invoked.
114 static bool gOnScrollUpdateCalled; ///< Whether the OnScrollUpdate signal was invoked.
115 static bool gOnScrollCompleteCalled; ///< Whether the OnScrollComplete signal was invoked.
116 static bool gOnSnapStartCalled; ///< Whether the OnSnapStart signal was invoked.
117 static bool gOnWheelEventCalled; ///< Whether the WheelEventSignal signal was invoked.
118 static SnapType gLastSnapType; ///< Snaping information from SnapEvent.
119 static Vector3 gConstraintResult; ///< Result from constraint.
122 * Invoked when scrolling starts.
124 * @param[in] position The current scroll position.
126 static void OnScrollStart( const Vector2& position )
128 gOnScrollStartCalled = true;
132 * Invoked when scrolling updates (via dragging)
134 * @param[in] position The current scroll position.
136 static void OnScrollUpdate( const Vector2& position )
138 gOnScrollUpdateCalled = true;
142 * Invoked when scrolling finishes
144 * @param[in] position The current scroll position.
146 static void OnScrollComplete( const Vector2& position )
148 gOnScrollCompleteCalled = true;
152 * Invoked when a snap or flick started.
154 * @param[in] event The type of snap and the target position/scale/rotation.
156 static void OnSnapStart( const ScrollView::SnapEvent& event )
158 gOnSnapStartCalled = true;
159 gLastSnapType = event.type;
163 * Invoked after a wheel-event is received
165 * @param[in] actor The owing actor
166 * @param[in] event The wheel event
167 * @return True if the event should be consumed
169 static bool OnWheelEvent( Actor actor, const Dali::WheelEvent& wheelEvent )
171 gOnWheelEventCalled = true;
178 * Summation of current value, property, and offset.
180 * current' = current + mOffset + property;
182 struct TestSumConstraint
185 * @param[in] offset The offset to be added to current.
187 TestSumConstraint(const Vector3& offset)
193 * @param[in] current The current base value
194 * @param[in] inputs Contains the property to be added to current.
195 * @return The new current Vector.
197 void operator()( Vector3& current, const PropertyInputContainer& inputs )
199 gConstraintResult = current + Vector3(inputs[0]->GetVector2()) + mOffset;
200 current = gConstraintResult;
208 * @param[in] application The application instance
209 * @param[in] scrollView The scrollView instance
210 * @return The time taken for the overshoot to reach origin (zero)
212 static float TestOvershootSnapDuration(ToolkitTestApplication &application, ScrollView scrollView)
214 int timeToReachOrigin = -1;
215 for(int i = 0;i<MAX_FRAMES_TO_TEST_OVERSHOOT;i++)
217 float overshootXValue = scrollView.GetCurrentProperty<float>( ScrollView::Property::OVERSHOOT_X );
218 float overshootYValue = scrollView.GetCurrentProperty<float>( ScrollView::Property::OVERSHOOT_Y );
219 if(overshootXValue == 0.0f && overshootYValue == 0.0f)
224 timeToReachOrigin += Wait(application);
227 return static_cast<float>(timeToReachOrigin) * 0.001f; // return in seconds not ms.
231 * y = 2x alpha function, which is clamped between 0.0f - 1.0f
233 * Animations should appear to finish (reach 100% point)
234 * at just half the time of a regular Linear AlphaFunction.
236 * @param[in] progress value (ranges from 0.0f - 1.0f)
237 * @return interpolation value (ranges from 0.0f - 1.0f)
239 float TestAlphaFunction(float progress)
241 return std::min( progress * 2.0f, 1.0f );
245 * Generate a complete pan gesture
246 * Note: To initiate the gesture it will go from start, diagonally SE on the screen, then continue in the direction for frames touches
248 static Vector2 PerformGestureSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, uint32_t& time, bool finish = true)
250 gOnScrollStartCalled = false;
251 gOnScrollUpdateCalled = false;
252 gOnScrollCompleteCalled = false;
253 gOnSnapStartCalled = false;
255 Vector2 pos( start );
257 // This is created to ensure a pan is started
258 Vector2 pos_start_jump( start + Vector2(11.0f, 11.0f) );
259 TestStartPan( application, start, pos_start_jump, time );
260 pos = pos_start_jump;
264 for(int i = 0;i<frames;i++)
266 pos += direction; // Move in this direction
267 TestMovePan(application, pos, time );
268 time += Wait(application);
273 pos += direction; // Move in this direction.
274 TestEndPan(application, pos, time );
275 time += Wait(application, RENDER_DELAY_SCROLL);
282 } // unnamed namespace
285 int UtcDaliToolkitScrollViewConstructorP(void)
287 ToolkitTestApplication application;
289 ScrollView scrollView;
290 DALI_TEST_CHECK( !scrollView );
294 int UtcDaliToolkitScrollViewCopyConstructorP(void)
296 ToolkitTestApplication application;
298 ScrollView scrollView = ScrollView::New();
299 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) );
301 ScrollView copy( scrollView );
302 DALI_TEST_CHECK( copy );
303 DALI_TEST_CHECK( copy.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) == scrollView.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) );
307 int UtcDaliScrollViewMoveConstructor(void)
309 ToolkitTestApplication application;
311 ScrollView scrollView = ScrollView::New();
312 DALI_TEST_EQUALS( 1, scrollView.GetBaseObject().ReferenceCount(), TEST_LOCATION );
313 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) );
314 DALI_TEST_EQUALS( scrollView.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ), Vector2(10.0f, 10.0f), TEST_LOCATION );
316 ScrollView moved = std::move( scrollView );
317 DALI_TEST_CHECK( moved );
318 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
319 DALI_TEST_EQUALS( moved.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ), Vector2(10.0f, 10.0f), TEST_LOCATION );
320 DALI_TEST_CHECK( !scrollView );
325 int UtcDaliToolkitScrollViewAssignmentOperatorP(void)
327 ToolkitTestApplication application;
329 ScrollView scrollView = ScrollView::New();
330 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) );
334 DALI_TEST_CHECK( copy );
335 DALI_TEST_CHECK( copy.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) == scrollView.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) );
339 int UtcDaliScrollViewMoveAssignment(void)
341 ToolkitTestApplication application;
343 ScrollView scrollView = ScrollView::New();
344 DALI_TEST_EQUALS( 1, scrollView.GetBaseObject().ReferenceCount(), TEST_LOCATION );
345 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) );
346 DALI_TEST_EQUALS( scrollView.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ), Vector2(10.0f, 10.0f), TEST_LOCATION );
349 moved = std::move( scrollView );
350 DALI_TEST_CHECK( moved );
351 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
352 DALI_TEST_EQUALS( moved.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ), Vector2(10.0f, 10.0f), TEST_LOCATION );
353 DALI_TEST_CHECK( !scrollView );
358 int UtcDaliScrollViewDestructorP(void)
360 ToolkitTestApplication application;
362 ScrollView* scrollView = new ScrollView();
365 DALI_TEST_CHECK( true );
369 int UtcDaliToolkitScrollViewNewP1(void)
371 ToolkitTestApplication application;
372 tet_infoline(" UtcDaliToolkitScrollViewNewP1");
374 ScrollView scrollView;
376 DALI_TEST_CHECK( !scrollView );
378 scrollView = ScrollView::New();
380 DALI_TEST_CHECK( scrollView );
382 ScrollView scrollView2(scrollView);
384 DALI_TEST_CHECK( scrollView2 == scrollView );
386 //Additional check to ensure object is created by checking if it's registered
387 ObjectRegistry registry = application.GetCore().GetObjectRegistry();
388 DALI_TEST_CHECK( registry );
390 gObjectCreatedCallBackCalled = false;
391 registry.ObjectCreatedSignal().Connect( &TestCallback );
393 ScrollView scrollView = ScrollView::New();
395 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
399 int UtcDaliToolkitScrollViewNewP2(void)
401 ToolkitTestApplication application;
402 tet_infoline(" UtcDaliToolkitScrollViewNewP2 - create thru type registry");
404 ScrollView scrollView;
405 DALI_TEST_CHECK( !scrollView );
407 TypeRegistry typeRegistry = TypeRegistry::Get();
408 TypeInfo scrollViewType = typeRegistry.GetTypeInfo("ScrollView");
409 BaseHandle handle = scrollViewType.CreateInstance();
410 DALI_TEST_CHECK( handle );
412 scrollView = ScrollView::DownCast(handle);
413 DALI_TEST_CHECK( scrollView );
418 int UtcDaliToolkitScrollViewDownCastP(void)
420 ToolkitTestApplication application;
421 tet_infoline(" UtcDaliToolkitScrollViewDownCastP");
423 ScrollView scrollView = ScrollView::New();
424 BaseHandle handle(scrollView);
426 ScrollView newScrollView = ScrollView::DownCast( handle );
427 DALI_TEST_CHECK( scrollView );
428 DALI_TEST_CHECK( newScrollView == scrollView );
432 int UtcDaliToolkitScrollViewScrollToPositionP(void)
434 ToolkitTestApplication application;
435 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionP");
437 // Create the ScrollView actor
438 ScrollView scrollView = ScrollView::New();
439 application.GetScene().Add( scrollView );
441 const Vector2 target = Vector2(100.0f, 200.0f);
442 const Vector2 target2 = Vector2(300.0f, 100.0f);
444 scrollView.ScrollTo( target, 0.0f );
446 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
447 scrollView.ScrollTo( target2 );
448 Wait(application, RENDER_DELAY_SCROLL);
449 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
454 int UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP(void)
456 ToolkitTestApplication application;
457 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP");
459 ScrollView scrollView = ScrollView::New();
460 application.GetScene().Add( scrollView );
461 RulerPtr rulerX = new FixedRuler( 100.0f );
462 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
463 RulerPtr rulerY = new FixedRuler( 100.0f );
464 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
466 scrollView.SetRulerX( rulerX );
467 scrollView.SetRulerY( rulerY );
469 scrollView.SetWrapMode(true);
471 Property::Value wrapMode = scrollView.GetProperty( Toolkit::ScrollView::Property::WRAP_ENABLED );
472 DALI_TEST_EQUALS( wrapMode.Get<bool>(), true, TEST_LOCATION );
474 const Vector2 target = Vector2(50.0f, 50.0f);
475 const Vector2 target2 = Vector2(150.0f, 150.0f);
477 scrollView.ScrollTo( target, 0.0f );
478 Wait(application, RENDER_DELAY_SCROLL);
479 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
481 scrollView.ScrollTo( target2, 0.25f, Dali::Toolkit::DIRECTION_BIAS_LEFT, Dali::Toolkit::DIRECTION_BIAS_LEFT );
482 Wait(application, RENDER_DELAY_SCROLL);
483 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
485 scrollView.ScrollTo( target, 0.0f );
486 Wait(application, RENDER_DELAY_SCROLL);
487 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
489 scrollView.ScrollTo( target2, 0.25f, Dali::Toolkit::DIRECTION_BIAS_RIGHT, Dali::Toolkit::DIRECTION_BIAS_RIGHT );
490 Wait(application, RENDER_DELAY_SCROLL);
491 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
496 int UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionP(void)
498 ToolkitTestApplication application;
499 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionP");
501 // Create the ScrollView actor
502 ScrollView scrollView = ScrollView::New();
503 application.GetScene().Add( scrollView );
505 const Vector2 target = Vector2(100.0f, 200.0f);
506 const Vector2 target2 = Vector2(300.0f, 100.0f);
508 scrollView.ScrollTo( target, 0.5f, TestAlphaFunction );
509 Wait(application, 250);
510 // Check that the scroll animation should finish within just half of the specified duration with the above alpha function
511 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
513 scrollView.ScrollTo( target2, 0.5f, AlphaFunction::LINEAR );
514 Wait(application, 250);
515 // Check that the scroll animation has not finished within half of the specified duration with the linear alpha function
516 DALI_TEST_CHECK( scrollView.GetCurrentScrollPosition() != target2 );
518 // Wait till the end of the specified duration
519 Wait(application, 250);
520 // Check that the scroll animation has finished
521 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
526 int UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionAndDirectionBiasP(void)
528 ToolkitTestApplication application;
529 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionAndDirectionBiasP");
531 ScrollView scrollView = ScrollView::New();
532 application.GetScene().Add( scrollView );
533 RulerPtr rulerX = new FixedRuler( 100.0f );
534 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
535 RulerPtr rulerY = new FixedRuler( 100.0f );
536 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
538 scrollView.SetRulerX( rulerX );
539 scrollView.SetRulerY( rulerY );
541 scrollView.SetWrapMode(true);
543 const Vector2 target = Vector2(50.0f, 50.0f);
544 const Vector2 target2 = Vector2(150.0f, 150.0f);
546 scrollView.ScrollTo( target, 0.0f );
547 Wait(application, RENDER_DELAY_SCROLL);
548 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
550 scrollView.ScrollTo( target2, 0.25f, AlphaFunction::LINEAR, Dali::Toolkit::DIRECTION_BIAS_LEFT, Dali::Toolkit::DIRECTION_BIAS_LEFT );
551 Wait(application, RENDER_DELAY_SCROLL);
552 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
554 scrollView.ScrollTo( target, 0.0f );
555 Wait(application, RENDER_DELAY_SCROLL);
556 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
558 scrollView.ScrollTo( target2, 0.25f, AlphaFunction::LINEAR, Dali::Toolkit::DIRECTION_BIAS_RIGHT, Dali::Toolkit::DIRECTION_BIAS_RIGHT );
559 Wait(application, RENDER_DELAY_SCROLL);
560 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
562 scrollView.ScrollTo( target, 0.0f );
563 Wait(application, RENDER_DELAY_SCROLL);
564 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
566 scrollView.ScrollTo( target2, 0.25f, TestAlphaFunction, Dali::Toolkit::DIRECTION_BIAS_RIGHT, Dali::Toolkit::DIRECTION_BIAS_RIGHT );
567 Wait(application, 125);
568 // Check that the scroll animation should finish within just half of the specified duration with the above alpha function
569 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
574 int UtcDaliToolkitScrollViewScrollToPageP(void)
576 ToolkitTestApplication application;
577 tet_infoline(" UtcDaliToolkitScrollViewScrollToPageP");
579 ScrollView scrollView = ScrollView::New();
580 application.GetScene().Add( scrollView );
581 RulerPtr rulerX = new FixedRuler( 100.0f );
582 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
583 RulerPtr rulerY = new FixedRuler( 100.0f );
584 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
586 scrollView.SetRulerX( rulerX );
587 scrollView.SetRulerY( rulerY );
589 scrollView.ScrollTo( 1, 0.0f );
591 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION );
593 scrollView.ScrollTo( 5, 0.0f );
595 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(500.0f, 0.0f), TEST_LOCATION );
597 scrollView.ScrollTo( 10, 0.0f );
599 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 100.0f), TEST_LOCATION );
601 scrollView.ScrollTo( 15, 0.0f );
603 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(700.0f, 100.0f), TEST_LOCATION );
604 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION );
606 scrollView.ScrollTo( 3 );
607 Wait(application, RENDER_DELAY_SCROLL);
608 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(300.0f, 0.0f), TEST_LOCATION );
609 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION );
611 scrollView.ScrollTo( 9 );
612 Wait(application, RENDER_DELAY_SCROLL);
613 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 100.0f), TEST_LOCATION );
614 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION );
616 // Apply DefaultRulers instead and see what happens.
617 rulerX = new DefaultRuler();
618 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
619 rulerY = new DefaultRuler();
620 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
622 scrollView.SetRulerX( rulerX );
623 scrollView.SetRulerY( rulerY );
625 // This time should always scroll to origin (0.0f, 0.0f)
626 scrollView.ScrollTo( 1, 0.0f );
628 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
629 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
635 int UtcDaliToolkitScrollModeP1(void)
637 ToolkitTestApplication application;
638 tet_infoline( " UtcDaliToolkitScrollView ScrollMode property" );
640 // Set up a scrollView.
641 ScrollView scrollView = ScrollView::New();
643 // Do not rely on stage size for UTC tests.
644 Vector2 viewPageSize( 720.0f, 1280.0f );
645 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
646 scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
647 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
648 scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
649 scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
652 Property::Map rulerMap;
653 rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, true );
654 rulerMap.Add( ScrollMode::X_AXIS_SNAP_TO_INTERVAL, viewPageSize.width );
655 rulerMap.Add( ScrollMode::X_AXIS_SCROLL_BOUNDARY, viewPageSize.width*3 );
656 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, false );
657 scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
659 scrollView.SetWrapMode( false );
660 scrollView.SetScrollSensitive( true );
662 application.GetScene().Add( scrollView );
664 // Set up a gesture to perform.
665 Vector2 startPos( 50.0f, 0.0f );
666 Vector2 direction( -5.0f, 0.0f );
670 // Force starting position.
671 scrollView.ScrollTo( startPos, 0.0f );
672 time += Wait( application );
674 // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
675 Vector2 currentPos( PerformGestureSwipe( application, startPos, direction, frames - 1, time, false ) );
677 // Confirm the final X coord has not moved more than one page from the start X position.
678 DALI_TEST_GREATER( ( startPos.x + viewPageSize.width ), scrollView.GetCurrentScrollPosition().x, TEST_LOCATION );
680 // Finish the gesture and wait for the snap.
681 currentPos += direction;
682 TestEndPan( application, currentPos, time );
683 // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
684 time += Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
686 // Confirm the final X coord has snapped to exactly one page ahead of the start page.
687 DALI_TEST_EQUALS( viewPageSize.width, scrollView.GetCurrentScrollPosition().x, Math::MACHINE_EPSILON_0, TEST_LOCATION );
689 // Change scroll mode during pan, should not crash
690 PerformGestureSwipe( application, startPos, direction, frames - 1, time, false );
693 scrollView.SetScrollSensitive(false);
694 DALI_TEST_CHECK(true);
698 DALI_TEST_CHECK(false);
704 int UtcDaliToolkitScrollModeP2(void)
706 ToolkitTestApplication application;
707 tet_infoline( " UtcDaliToolkitScrollView ScrollMode property" );
709 // Set up a scrollView.
710 ScrollView scrollView = ScrollView::New();
712 // Do not rely on stage size for UTC tests.
713 Vector2 viewPageSize( 720.0f, 1280.0f );
714 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
715 scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
716 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
717 scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
718 scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
721 Property::Map rulerMap;
722 rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, false );
723 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, true );
724 rulerMap.Add( ScrollMode::Y_AXIS_SNAP_TO_INTERVAL, viewPageSize.height );
725 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_BOUNDARY, viewPageSize.height*3 );
726 scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
728 scrollView.SetWrapMode( false );
729 scrollView.SetScrollSensitive( true );
731 application.GetScene().Add( scrollView );
733 // Set up a gesture to perform.
734 Vector2 startPos( 0.0f, 50.0f );
735 Vector2 direction( 0.0f, -6.0f );
739 // Force starting position.
740 scrollView.ScrollTo( startPos, 0.0f );
741 time += Wait( application );
743 // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
744 Vector2 currentPos( PerformGestureSwipe( application, startPos, direction, frames - 1, time, false ) );
746 // Confirm the final X coord has not moved more than one page from the start X position.
747 DALI_TEST_GREATER( ( startPos.y + viewPageSize.height ), scrollView.GetCurrentScrollPosition().y, TEST_LOCATION );
749 // Finish the gesture and wait for the snap.
750 currentPos += direction;
751 time += Wait( application );
752 TestEndPan( application, currentPos, time );
753 // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
754 Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
756 // Confirm the final Y coord has snapped to exactly one page ahead of the start page.
757 DALI_TEST_EQUALS( viewPageSize.height, scrollView.GetCurrentScrollPosition().y, Math::MACHINE_EPSILON_0, TEST_LOCATION );
762 int UtcDaliToolkitScrollModeP3(void)
764 ToolkitTestApplication application;
765 tet_infoline( " UtcDaliToolkitScrollView ScrollMode property" );
767 // Set up a scrollView.
768 ScrollView scrollView = ScrollView::New();
770 // Do not rely on stage size for UTC tests.
771 Vector2 viewPageSize( 720.0f, 1280.0f );
772 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
773 scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
774 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
775 scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
776 scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
779 Property::Map rulerMap;
780 rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, false );
781 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, true );
782 rulerMap.Add( ScrollMode::Y_AXIS_SNAP_TO_INTERVAL, viewPageSize.height );
783 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_BOUNDARY, viewPageSize.height*3 );
784 scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
786 scrollView.SetWrapMode( false );
787 scrollView.SetScrollSensitive( true );
789 application.GetScene().Add( scrollView );
791 // Set up a gesture to perform.
792 Vector2 startPos( 0.0f, 50.0f );
793 Vector2 direction( 0.0f, -6.0f );
797 // Force starting position.
798 scrollView.ScrollTo( startPos, 0.0f );
799 time += Wait( application );
801 // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
802 Vector2 currentPos( PerformGestureSwipe( application, startPos, direction, frames - 1, time, false ) );
804 // Confirm the final X coord has not moved more than one page from the start X position.
805 DALI_TEST_GREATER( ( startPos.y + viewPageSize.height ), scrollView.GetCurrentScrollPosition().y, TEST_LOCATION );
807 // Finish the gesture and wait for the snap.
808 currentPos += direction;
809 TestEndPan( application, currentPos, time );
810 // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
811 Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
813 // Confirm the final Y coord has snapped to exactly one page ahead of the start page.
814 DALI_TEST_EQUALS( viewPageSize.height, scrollView.GetCurrentScrollPosition().y, Math::MACHINE_EPSILON_0, TEST_LOCATION );
819 int UtcDaliToolkitScrollModeP4(void)
821 ToolkitTestApplication application;
822 tet_infoline( " UtcDaliToolkitScrollView ScrollMode property, DefaultRulers" );
824 // Set up a scrollView.
825 ScrollView scrollView = ScrollView::New();
827 // Do not rely on stage size for UTC tests.
828 Vector2 viewPageSize( 720.0f, 1280.0f );
829 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
830 scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
831 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
832 scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
833 scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
835 // Position rulers - expect Default rulers to be used which don't snap
836 Property::Map rulerMap;
837 rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, true );
838 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, true );
839 scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
841 scrollView.SetWrapMode( false );
842 scrollView.SetScrollSensitive( true );
844 application.GetScene().Add( scrollView );
846 Vector2 START_POSITION = Vector2(10.0f, 10.0f);
849 scrollView.ScrollTo(START_POSITION, 0.0f);
850 time += Wait(application);
852 // Try a vertical swipe.
853 // PerformGestureSwipe not used as a different initial direction was required
854 Vector2 pos( START_POSITION + Vector2(0.0f, 15.0f) );
855 Vector2 dir( 0.0f, 1.0f );
857 TestStartPan( application, START_POSITION, pos, time );
861 for( int i = 0; i<45; i++ )
864 TestMovePan( application, pos, time );
865 time += Wait( application );
870 TestEndPan( application, pos, time );
871 Wait( application, RENDER_DELAY_SCROLL );
873 // Take into account resampling done when prediction is off.
874 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
879 int UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP(void)
881 ToolkitTestApplication application;
882 tet_infoline(" UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP");
884 ScrollView scrollView = ScrollView::New();
885 application.GetScene().Add( scrollView );
886 RulerPtr rulerX = new FixedRuler( 100.0f );
887 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
888 RulerPtr rulerY = new FixedRuler( 100.0f );
889 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
891 scrollView.SetRulerX( rulerX );
892 scrollView.SetRulerY( rulerY );
894 scrollView.SetWrapMode(true);
896 scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DIRECTION_BIAS_LEFT );
898 Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame
899 // Check that the scroll position remains the same
900 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
902 Wait(application, RENDER_DELAY_SCROLL); // Wait for one second
903 // Check that it stays at the same page (i.e. the same scroll position)
904 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
905 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
907 scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DIRECTION_BIAS_RIGHT );
909 Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame
910 // Check that it scrolls towards the right
911 DALI_TEST_CHECK( scrollView.GetCurrentScrollPosition().x > 0.0f );
913 Wait(application, RENDER_DELAY_SCROLL); // Wait for one second
914 // Check that it scrolls back to the same page (i.e. the same scroll position)
915 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
916 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
921 int UtcDaliToolkitScrollViewScrollToActorP(void)
923 ToolkitTestApplication application;
924 tet_infoline(" UtcDaliToolkitScrollViewScrollToActorP");
926 ScrollView scrollView = ScrollView::New();
927 application.GetScene().Add( scrollView );
929 Actor actorA = Actor::New();
930 const Vector3 positionA = Vector3(100.0f, 400.0f, 0.0f);
931 actorA.SetProperty( Actor::Property::POSITION, positionA );
932 scrollView.Add(actorA);
934 Actor actorB = Actor::New();
935 const Vector3 positionB = Vector3(500.0f, 200.0f, 0.0f);
936 actorB.SetProperty( Actor::Property::POSITION, positionB );
937 scrollView.Add(actorB);
941 scrollView.ScrollTo(actorA, 0.0f);
943 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION );
946 scrollView.ScrollTo(actorB, 0.0f);
948 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION );
950 scrollView.ScrollTo(actorA);
951 Wait(application, RENDER_DELAY_SCROLL);
952 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION );
954 scrollView.ScrollTo(actorB);
955 Wait(application, RENDER_DELAY_SCROLL);
956 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION );
960 int UtcDaliToolkitScrollViewScrollToSnapPointP(void)
962 ToolkitTestApplication application;
963 tet_infoline(" UtcDaliToolkitScrollViewScrollToSnapPointP");
965 ScrollView scrollView = ScrollView::New();
966 application.GetScene().Add( scrollView );
967 RulerPtr rulerX = new FixedRuler( 100.0f );
968 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
969 RulerPtr rulerY = new FixedRuler( 100.0f );
970 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
972 scrollView.SetRulerX( rulerX );
973 scrollView.SetRulerY( rulerY );
975 scrollView.ScrollTo( Vector2(120.0f, 190.0f), 0.0f );
977 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(120.0f, 190.0f), TEST_LOCATION );
979 scrollView.ScrollToSnapPoint();
981 Wait(application, RENDER_DELAY_SCROLL);
982 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 200.0f), TEST_LOCATION );
986 int UtcDaliToolkitScrollViewSetScrollUpdateDistanceP(void)
988 ToolkitTestApplication application;
989 tet_infoline(" UtcDaliToolkitScrollViewSetScrollUpdateDistanceP");
991 ScrollView scrollView = ScrollView::New();
993 scrollView.SetScrollUpdateDistance(0);
994 DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 0, TEST_LOCATION);
995 scrollView.SetScrollUpdateDistance(10);
996 DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 10, TEST_LOCATION);
997 scrollView.SetScrollUpdateDistance(1000);
998 DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 1000, TEST_LOCATION);
1002 int UtcDaliToolkitScrollViewSetWrapModeP(void)
1004 ToolkitTestApplication application;
1005 tet_infoline(" UtcDaliToolkitScrollViewSetWrapModeP");
1007 ScrollView scrollView = ScrollView::New();
1008 application.GetScene().Add( scrollView );
1010 Actor actor = Actor::New();
1011 scrollView.Add( actor );
1013 // Position rulers. 4x4 grid.
1014 RulerPtr rulerX = new FixedRuler(50.0f);
1015 RulerPtr rulerY = new FixedRuler(50.0f);
1016 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, false) );
1017 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, false) );
1018 scrollView.SetRulerX(rulerX);
1019 scrollView.SetRulerY(rulerY);
1021 scrollView.SetWrapMode(false);
1022 scrollView.ScrollTo(Vector2(225.0f, 125.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
1024 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 17, TEST_LOCATION );
1026 scrollView.SetWrapMode(true);
1027 scrollView.ScrollTo(Vector2(230.0f, 130.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
1029 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 13, TEST_LOCATION );
1033 int UtcDaliToolkitScrollViewActorAutoSnap(void)
1035 ToolkitTestApplication application;
1036 tet_infoline(" UtcDaliToolkitScrollViewActorAutoSnap");
1038 ScrollView scrollView = ScrollView::New();
1039 application.GetScene().Add( scrollView );
1042 RulerPtr rulerX = new DefaultRuler();
1043 RulerPtr rulerY = new DefaultRuler();
1044 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1045 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1046 scrollView.SetRulerX(rulerX);
1047 scrollView.SetRulerY(rulerY);
1049 const Vector3 aPosition = Vector3(200.0f, 50.0f, 0.0f);
1050 Actor a = Actor::New();
1052 a.SetProperty( Actor::Property::POSITION, aPosition );
1054 const Vector3 bPosition = Vector3(600.0f, 600.0f, 0.0f);
1055 Actor b = Actor::New();
1057 b.SetProperty( Actor::Property::POSITION, bPosition );
1059 // Goto a random position, and execute snap (should not move)
1060 Vector2 targetScroll = Vector2(500.0f, 500.0f);
1061 scrollView.ScrollTo(targetScroll, 0.0f);
1063 scrollView.ScrollToSnapPoint();
1064 Wait(application, RENDER_DELAY_SCROLL);
1065 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), targetScroll, TEST_LOCATION );
1067 // Enable ActorAutoSnap, and now try snapping.
1068 scrollView.SetActorAutoSnap(true);
1069 scrollView.ScrollToSnapPoint();
1070 Wait(application, RENDER_DELAY_SCROLL);
1071 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), bPosition.GetVectorXY(), TEST_LOCATION );
1073 scrollView.ScrollTo(Vector2(0.0f, 0.0f), 0.0f);
1075 scrollView.ScrollToSnapPoint();
1076 Wait(application, RENDER_DELAY_SCROLL);
1077 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), aPosition.GetVectorXY(), TEST_LOCATION );
1081 int UtcDaliToolkitScrollViewSignalsStartComplete(void)
1083 ToolkitTestApplication application;
1084 tet_infoline(" UtcDaliToolkitScrollViewSignalsStartComplete");
1086 gOnScrollStartCalled = false;
1087 gOnScrollCompleteCalled = false;
1089 ScrollView scrollView = ScrollView::New();
1090 application.GetScene().Add( scrollView );
1093 RulerPtr rulerX = new DefaultRuler();
1094 RulerPtr rulerY = new DefaultRuler();
1095 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1096 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1097 scrollView.SetRulerX(rulerX);
1098 scrollView.SetRulerY(rulerY);
1099 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1100 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1101 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1102 scrollView.ScrollTo( Vector2(100.0f, 100.0f) );
1103 Wait(application, RENDER_DELAY_SCROLL);
1105 DALI_TEST_CHECK(gOnScrollStartCalled);
1106 DALI_TEST_CHECK(gOnScrollCompleteCalled);
1110 int UtcDaliToolkitScrollViewSignalsUpdate01(void)
1112 ToolkitTestApplication application;
1113 tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate");
1115 gOnScrollStartCalled = false;
1116 gOnScrollUpdateCalled = false;
1117 gOnScrollCompleteCalled = false;
1119 ScrollView scrollView = ScrollView::New();
1120 application.GetScene().Add( scrollView );
1121 Vector2 stageSize = application.GetScene().GetSize();
1122 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1123 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1124 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1127 RulerPtr rulerX = new DefaultRuler();
1128 RulerPtr rulerY = new DefaultRuler();
1129 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1130 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1131 scrollView.SetRulerX(rulerX);
1132 scrollView.SetRulerY(rulerY);
1133 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1134 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1135 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1137 Actor image = Actor::New();
1138 image.SetProperty( Actor::Property::SIZE, stageSize);
1139 image.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1140 image.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1141 scrollView.Add(image);
1145 // Do a pan starting from 100,100 and moving down diagonally.
1146 Vector2 pos(100.0f, 100.0f);
1147 uint32_t time = 100;
1148 TestStartPan( application, pos, pos, time );
1151 Wait(application, 100);
1153 for(int i = 0;i<20;i++)
1155 time += RENDER_FRAME_INTERVAL;
1156 TestMovePan( application, pos, time);
1162 time += RENDER_FRAME_INTERVAL;
1163 TestEndPan(application, pos, time );
1164 Wait(application, RENDER_DELAY_SCROLL);
1166 DALI_TEST_CHECK(gOnScrollStartCalled);
1167 DALI_TEST_CHECK(gOnScrollUpdateCalled);
1168 DALI_TEST_CHECK(gOnScrollCompleteCalled);
1172 int UtcDaliToolkitScrollViewSignalsUpdate02(void)
1174 ToolkitTestApplication application;
1175 tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate");
1177 gOnScrollStartCalled = false;
1178 gOnScrollUpdateCalled = false;
1179 gOnScrollCompleteCalled = false;
1181 ScrollView scrollView = ScrollView::New();
1182 application.GetScene().Add( scrollView );
1183 Vector2 stageSize = application.GetScene().GetSize();
1184 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1185 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1186 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1189 RulerPtr rulerX = new DefaultRuler();
1190 RulerPtr rulerY = new DefaultRuler();
1191 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1192 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1193 scrollView.SetRulerX(rulerX);
1194 scrollView.SetRulerY(rulerY);
1195 Dali::ConnectionTracker tracker;
1196 bool scrollStarted=false;
1197 bool scrollUpdated=false;
1198 bool scrollCompleted=false;
1199 DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollStarted", CallbackFunctor(&scrollStarted) ));
1200 DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollUpdated", CallbackFunctor(&scrollUpdated) ));
1201 DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollCompleted", CallbackFunctor(&scrollCompleted) ));
1203 Actor image = Actor::New();
1204 image.SetProperty( Actor::Property::SIZE, stageSize);
1205 image.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1206 image.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1207 scrollView.Add(image);
1211 // Do a pan starting from 100,100 and moving down diagonally.
1212 Vector2 pos(100.0f, 100.0f);
1213 uint32_t time = 100;
1214 TestStartPan( application, pos, pos, time );
1217 Wait(application, 100);
1219 for(int i = 0;i<20;i++)
1221 time += RENDER_FRAME_INTERVAL;
1222 TestMovePan( application, pos, time);
1228 time += RENDER_FRAME_INTERVAL;
1229 TestEndPan(application, pos, time );
1230 Wait(application, RENDER_DELAY_SCROLL);
1232 DALI_TEST_CHECK(scrollStarted);
1233 DALI_TEST_CHECK(scrollUpdated);
1234 DALI_TEST_CHECK(scrollCompleted);
1236 application.GetScene().Remove( scrollView );
1241 int UtcDaliToolkitScrollViewScrollSensitive(void)
1243 ToolkitTestApplication application;
1244 tet_infoline(" UtcDaliToolkitScrollViewScrollSensitive");
1246 // Set up a scrollView...
1247 ScrollView scrollView = ScrollView::New();
1248 scrollView.SetOvershootEnabled(true);
1249 application.GetScene().Add( scrollView );
1250 Vector2 stageSize = application.GetScene().GetSize();
1251 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1252 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1253 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1256 RulerPtr rulerX = new DefaultRuler();
1257 RulerPtr rulerY = new DefaultRuler();
1258 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1259 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1260 scrollView.SetRulerX(rulerX);
1261 scrollView.SetRulerY(rulerY);
1262 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1263 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1264 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1265 scrollView.SnapStartedSignal().Connect( &OnSnapStart );
1267 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1269 time +=Wait(application);
1271 // First try insensitive swipe.
1272 scrollView.SetScrollSensitive(false);
1273 PerformGestureSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, time, true);
1275 DALI_TEST_CHECK( !gOnScrollStartCalled );
1276 DALI_TEST_CHECK( !gOnScrollCompleteCalled );
1277 DALI_TEST_CHECK( !gOnSnapStartCalled );
1279 // Second try sensitive swipe.
1280 scrollView.SetScrollSensitive(true);
1281 PerformGestureSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, time, true);
1283 DALI_TEST_CHECK( gOnScrollStartCalled );
1284 DALI_TEST_CHECK( gOnScrollCompleteCalled );
1285 DALI_TEST_CHECK( gOnSnapStartCalled );
1289 int UtcDaliToolkitScrollViewAxisAutoLock(void)
1291 ToolkitTestApplication application;
1292 tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLock");
1294 // Set up a scrollView...
1295 ScrollView scrollView = ScrollView::New();
1296 application.GetScene().Add( scrollView );
1297 Vector2 stageSize = application.GetScene().GetSize();
1298 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1299 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1300 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1303 RulerPtr rulerX = new DefaultRuler();
1304 RulerPtr rulerY = new DefaultRuler();
1305 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1306 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1307 scrollView.SetRulerX(rulerX);
1308 scrollView.SetRulerY(rulerY);
1309 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1310 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1311 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1314 scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
1316 time += Wait(application);
1318 Vector2 startPosition = scrollView.GetCurrentScrollPosition();
1319 Vector2 dir(5.0f, 1.0f);
1321 // PerformGestureSwipe not used as a different initial direction was required
1323 Vector2 pos( CLAMP_TOUCH_START + Vector2(15.0f, 3.0f) );
1325 TestStartPan( application, CLAMP_TOUCH_START, pos, time );
1327 time += Wait(application);
1329 for( int i = 0; i<47; i++ )
1332 TestMovePan( application, pos, time );
1333 time += Wait( application );
1338 TestEndPan( application, pos, time );
1340 const Vector2 positionAfterNormal = scrollView.GetCurrentScrollPosition();
1343 scrollView.SetAxisAutoLock(true);
1344 DALI_TEST_CHECK(scrollView.GetAxisAutoLock());
1346 scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
1347 time += Wait(application);
1349 Vector2 pos2( CLAMP_TOUCH_START + Vector2(15.0f, 3.0f) );
1351 TestStartPan( application, CLAMP_TOUCH_START, pos2, time );
1353 time += Wait(application);
1355 for( int i = 0; i<47; i++ )
1358 TestMovePan( application, pos2, time );
1359 time += Wait( application );
1364 TestEndPan( application, pos2, time );
1366 const Vector2 positionAfterAutoLock = scrollView.GetCurrentScrollPosition();
1368 // compare how much the Y position has deviated for normal and autolock.
1369 const float devianceNormal = fabsf(startPosition.y - positionAfterNormal.y);
1370 const float devianceAutoLock = fabsf(startPosition.y - positionAfterAutoLock.y);
1372 // in auto-lock it should be a mostly horizontal pan (thus deviance should be much lower)
1373 DALI_TEST_CHECK(devianceAutoLock < devianceNormal);
1375 scrollView.SetAxisAutoLock(false);
1376 DALI_TEST_CHECK(!scrollView.GetAxisAutoLock());
1380 int UtcDaliToolkitScrollViewAxisAutoLockGradient(void)
1382 ToolkitTestApplication application;
1383 tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLockGradient");
1385 // Set up a scrollView...
1386 ScrollView scrollView = ScrollView::New();
1387 scrollView.SetAxisAutoLockGradient(0.5f);
1388 DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 0.5f, TEST_LOCATION);
1389 scrollView.SetAxisAutoLockGradient(1.0f);
1390 DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 1.0f, TEST_LOCATION);
1394 int UtcDaliToolkitScrollViewConstraints(void)
1396 ToolkitTestApplication application;
1397 tet_infoline(" UtcDaliToolkitScrollViewConstraints");
1399 // Set up a scrollView...
1400 ScrollView scrollView = ScrollView::New();
1401 application.GetScene().Add( scrollView );
1402 Vector2 stageSize = application.GetScene().GetSize();
1403 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1404 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1405 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1408 RulerPtr rulerX = new DefaultRuler();
1409 RulerPtr rulerY = new DefaultRuler();
1410 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1411 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1412 scrollView.SetRulerX(rulerX);
1413 scrollView.SetRulerY(rulerY);
1415 // Add an Actor to ScrollView,
1416 // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1417 gConstraintResult = Vector3::ZERO;
1418 Actor a = Actor::New();
1420 a.SetProperty( Actor::Property::POSITION, TEST_ACTOR_POSITION);
1423 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1424 constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
1425 constraint.SetRemoveAction(Constraint::DISCARD);
1426 scrollView.ApplyConstraintToChildren(constraint);
1429 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1431 gConstraintResult = Vector3::ZERO;
1432 scrollView.RemoveConstraintsFromChildren();
1435 DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
1439 int UtcDaliToolkitScrollViewBind(void)
1441 ToolkitTestApplication application;
1442 tet_infoline(" UtcDaliToolkitScrollViewBind");
1444 // Set up a scrollView...
1445 ScrollView scrollView = ScrollView::New();
1446 application.GetScene().Add( scrollView );
1447 Vector2 stageSize = application.GetScene().GetSize();
1448 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1449 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1450 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1453 RulerPtr rulerX = new DefaultRuler();
1454 RulerPtr rulerY = new DefaultRuler();
1455 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1456 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1457 scrollView.SetRulerX(rulerX);
1458 scrollView.SetRulerY(rulerY);
1460 // Add an Actor to ScrollView,
1461 // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1463 gConstraintResult = Vector3::ZERO;
1464 Actor a = Actor::New();
1466 a.SetProperty( Actor::Property::POSITION, TEST_ACTOR_POSITION);
1469 // apply this constraint to scrollview
1470 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1471 constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
1472 constraint.SetRemoveAction(Constraint::DISCARD);
1473 scrollView.ApplyConstraintToChildren(constraint);
1477 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1480 gConstraintResult = Vector3::ZERO;
1481 scrollView.UnbindActor( a );
1483 DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
1486 gConstraintResult = Vector3::ZERO;
1487 scrollView.BindActor( a );
1489 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1493 int UtcDaliToolkitScrollViewOvershoot(void)
1495 ToolkitTestApplication application;
1496 tet_infoline(" UtcDaliToolkitScrollViewOvershoot");
1498 // Set up a scrollView...
1499 ScrollView scrollView = ScrollView::New();
1500 scrollView.SetOvershootEnabled(true);
1503 Vector2 overshootSize = Vector2(100.0f,100.0f);
1504 scrollView.SetProperty( Scrollable::Property::OVERSHOOT_SIZE, overshootSize );
1505 DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_SIZE).Get<Vector2>(), overshootSize, TEST_LOCATION );
1507 application.GetScene().Add( scrollView );
1508 Vector2 stageSize = application.GetScene().GetSize();
1509 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1510 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1511 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1514 RulerPtr rulerX = new DefaultRuler();
1515 RulerPtr rulerY = new DefaultRuler();
1516 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1517 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1518 scrollView.SetRulerX(rulerX);
1519 scrollView.SetRulerY(rulerY);
1520 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1521 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1522 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1524 scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1525 time += Wait(application);
1527 // 1. Scroll page in NW (-500,-500 pixels), then inspect overshoot. (don't release touch)
1528 Vector2 currentPos = Vector2(100.0f, 100.0f);
1529 currentPos = PerformGestureSwipe(application, currentPos, Vector2(5.0f, 5.0f), 100, time, false);
1530 float overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1531 float overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1532 Vector2 positionValue = scrollView.GetCurrentProperty< Vector2 >( ScrollView::Property::SCROLL_POSITION );
1533 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1534 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1535 DALI_TEST_EQUALS(positionValue, Vector2::ZERO, TEST_LOCATION);
1537 float timeToReachOrigin;
1539 // Now release touch. Overshoot should snap back to zero.
1540 TestEndPan(application, currentPos, time);
1542 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1544 float minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1545 float maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1547 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1548 (timeToReachOrigin < maxTimeToReachOrigin) );
1550 // 2. Repeat Scroll, but this time change overshoot snap duration to shorter time
1551 scrollView.SetSnapOvershootDuration(TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION);
1553 currentPos = PerformGestureSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, time, false);
1554 // Now release touch. Overshoot should snap back to zero.
1555 TestEndPan(application, currentPos, time);
1556 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1558 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1559 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1561 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1562 (timeToReachOrigin < maxTimeToReachOrigin) );
1564 // 3. Repeat Scroll, but this time change overshoot snap duration to longer time.
1565 scrollView.SetSnapOvershootDuration(TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION);
1567 currentPos = PerformGestureSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, time, false);
1568 // Now release touch. Overshoot should snap back to zero.
1569 TestEndPan(application, currentPos, time);
1570 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1572 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1573 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1575 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1576 (timeToReachOrigin < maxTimeToReachOrigin) );
1578 // 4. Repeat Scroll, but this time change overshoot function.
1579 scrollView.SetSnapOvershootDuration(TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION);
1580 scrollView.SetSnapOvershootAlphaFunction(TestAlphaFunction);
1582 currentPos = PerformGestureSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, time, false);
1583 // Now release touch. Overshoot should snap back to zero.
1584 TestEndPan(application, currentPos, time);
1585 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1587 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1588 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1590 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1591 (timeToReachOrigin < maxTimeToReachOrigin) );
1595 int UtcDaliToolkitScrollViewSnapAlphaFunction(void)
1597 ToolkitTestApplication application;
1598 tet_infoline(" UtcDaliToolkitScrollViewSnapAlphaFunction");
1600 // Set up a scrollView...
1601 ScrollView scrollView = ScrollView::New();
1602 scrollView.SetScrollSnapAlphaFunction( AlphaFunction::EASE_IN );
1603 DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_IN );
1604 scrollView.SetScrollSnapAlphaFunction( AlphaFunction::EASE_OUT );
1605 DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_OUT );
1607 scrollView.SetScrollFlickAlphaFunction( AlphaFunction::BOUNCE );
1608 DALI_TEST_CHECK( scrollView.GetScrollFlickAlphaFunction().GetBuiltinFunction() == AlphaFunction::BOUNCE );
1613 int UtcDaliToolkitScrollViewSnapDuration(void)
1615 ToolkitTestApplication application;
1616 tet_infoline(" UtcDaliToolkitScrollViewSnapDuration");
1618 // Set up a scrollView...
1619 ScrollView scrollView = ScrollView::New();
1620 scrollView.SetScrollSnapDuration( 1.0f );
1621 DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 1.0f, TEST_LOCATION );
1622 scrollView.SetScrollSnapDuration( 0.5f );
1623 DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 0.5f, TEST_LOCATION );
1625 scrollView.SetScrollFlickDuration( 2.0f );
1626 DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 2.0f, TEST_LOCATION );
1627 scrollView.SetScrollFlickDuration( 1.5f );
1628 DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 1.5f, TEST_LOCATION );
1632 int UtcDaliToolkitScrollViewSnapStartedSignalP(void)
1634 ToolkitTestApplication application;
1635 tet_infoline(" UtcDaliToolkitScrollViewSnapStartedSignalP");
1637 // Set up a scrollView...
1638 ScrollView scrollView = ScrollView::New();
1639 application.GetScene().Add( scrollView );
1640 Vector2 stageSize = application.GetScene().GetSize();
1641 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1642 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1643 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1646 RulerPtr rulerX = new DefaultRuler();
1647 RulerPtr rulerY = new DefaultRuler();
1648 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1649 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1650 scrollView.SetRulerX(rulerX);
1651 scrollView.SetRulerY(rulerY);
1652 scrollView.SnapStartedSignal().Connect( &OnSnapStart );
1654 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1656 time += Wait(application);
1658 // First try a snap.
1659 PerformGestureSwipe(application, CLAMP_TOUCH_START, Vector2(0.5f, 0.0f), 60, time, true);
1661 DALI_TEST_CHECK( gOnSnapStartCalled );
1662 DALI_TEST_CHECK( gLastSnapType == Toolkit::SNAP );
1664 // Second try a swipe.
1665 PerformGestureSwipe(application, CLAMP_TOUCH_START, Vector2(20.0f, 0.0f), 60, time, true);
1667 DALI_TEST_CHECK( gOnSnapStartCalled );
1668 DALI_TEST_CHECK( gLastSnapType == Toolkit::FLICK );
1672 int UtcDaliToolkitScrollViewGetCurrentPageP(void)
1674 ToolkitTestApplication application;
1675 tet_infoline(" UtcDaliToolkitScrollViewGetCurrentPageP");
1677 ScrollView scrollView = ScrollView::New();
1678 application.GetScene().Add( scrollView );
1679 RulerPtr rulerX = new FixedRuler( 100.0f );
1680 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1681 RulerPtr rulerY = new FixedRuler( 100.0f );
1682 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1684 scrollView.SetRulerX( rulerX );
1685 scrollView.SetRulerY( rulerY );
1687 scrollView.ScrollTo( 15 );
1688 Wait(application, RENDER_DELAY_SCROLL);
1689 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION );
1691 scrollView.ScrollTo( 3 );
1692 Wait(application, RENDER_DELAY_SCROLL);
1693 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION );
1695 scrollView.ScrollTo( 9 );
1696 Wait(application, RENDER_DELAY_SCROLL);
1697 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION );
1702 int UtcDaliToolkitScrollViewSetMaxOvershootP(void)
1704 ToolkitTestApplication application;
1705 tet_infoline(" UtcDaliToolkitScrollViewSetMaxOvershootP");
1707 // Set up a scrollView...
1708 ScrollView scrollView = ScrollView::New();
1709 application.GetScene().Add( scrollView );
1710 Vector2 stageSize = application.GetScene().GetSize();
1711 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1712 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1713 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1716 RulerPtr rulerX = new DefaultRuler();
1717 RulerPtr rulerY = new DefaultRuler();
1718 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1719 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1720 scrollView.SetRulerX(rulerX);
1721 scrollView.SetRulerY(rulerY);
1723 // Set the max overshoot to be 50 pixels in both X axis and Y axis
1724 scrollView.SetMaxOvershoot(50.0f, 50.0f);
1726 scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1728 time += Wait(application);
1730 // Scroll page in NW (-20,-20 pixels), then check that overshoot should be 0. (don't release touch)
1731 Vector2 currentPos = PerformGestureSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 10, time, false);
1732 float overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1733 float overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1734 DALI_TEST_EQUALS(overshootXValue, 0.0f, TEST_LOCATION);
1735 DALI_TEST_EQUALS(overshootYValue, 0.0f, TEST_LOCATION);
1737 time += Wait(application);
1738 // Scroll page further in NW (-105,-105 pixels), then check that overshoot should be around 0.5. (don't release touch)
1739 for(int i = 0; i<106; i++)
1741 TestMovePan(application, currentPos, time );
1742 currentPos += Vector2(1.0f, 1.0f);
1743 time += Wait(application);
1746 overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1747 overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1748 // The overshoot value is a 0.0f - 1.0f ranged value of the amount overshot related to the maximum overshoot.
1749 // EG. If we move 105, max overshoot is 50, then we overshot 50 / 105.
1750 float correctOvershootValue = 0.508f; // This was measured and then set as the limit
1751 DALI_TEST_EQUALS( overshootXValue, correctOvershootValue, 0.001f, TEST_LOCATION );
1752 DALI_TEST_EQUALS( overshootYValue, correctOvershootValue, 0.001f, TEST_LOCATION );
1754 // Scroll page further in NW (-25,-25 pixels), then check that overshoot should be now 1.0. (don't release touch)
1755 for(int i = 0;i<25;i++)
1757 TestMovePan(application, currentPos, time );
1758 currentPos += Vector2(1.0f, 1.0f); // Move in this direction
1759 time += Wait(application);
1762 overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1763 overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1764 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1765 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1767 // Change the max overshoot to be 250 pixels in both X axis and Y axis
1768 scrollView.SetMaxOvershoot(250.0f, 250.0f);
1769 time += Wait(application);
1771 // Check that overshoot should be now around 0.8.
1772 overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1773 overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1774 DALI_TEST_CHECK(overshootXValue > 0.79f && overshootXValue < 0.81f);
1775 DALI_TEST_CHECK(overshootYValue > 0.79f && overshootYValue < 0.81f);
1777 // Scroll page further in NW (-50,-50 pixels), then check that overshoot should be now 1.0. (don't release touch)
1778 for(int i = 0;i<50;i++)
1780 TestMovePan(application, currentPos, time );
1781 currentPos += Vector2(1.0f, 1.0f); // Move in this direction
1782 time += Wait(application);
1785 overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1786 overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1787 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1788 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1793 int UtcDaliToolkitScrollViewSetScrollingDirectionP(void)
1795 ToolkitTestApplication application;
1796 tet_infoline(" UtcDaliToolkitScrollViewSetScrollingDirectionP");
1798 // Set up a scrollView...
1799 ScrollView scrollView = ScrollView::New();
1800 application.GetScene().Add( scrollView );
1801 Vector2 stageSize = application.GetScene().GetSize();
1802 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1803 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1804 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1806 Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1808 scrollView.ScrollTo(START_POSITION, 0.0f);
1810 time += Wait(application);
1812 // Try a vertical swipe.
1813 // PerformGestureSwipe not used as a different initial direction was required
1815 Vector2 pos( START_POSITION + Vector2(0.0f, 15.0f) );
1816 TestStartPan( application, START_POSITION, pos, time );
1817 time += Wait(application);
1818 for( int i = 0; i<45; i++ )
1820 pos += Vector2(0.0f, 1.0f);
1821 TestMovePan( application, pos, time );
1822 time += Wait( application );
1824 pos += Vector2(0.0f, 1.0f);
1825 TestEndPan( application, pos, time );
1826 time += Wait( application );
1828 // Take into account resampling done when prediction is off.
1829 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1831 scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1833 scrollView.ScrollTo(START_POSITION, 0.0f);
1834 time += Wait(application);
1836 // Try a vertical swipe.
1837 // PerformGestureSwipe not used as a different initial direction was required
1838 pos = ( START_POSITION + Vector2(0.0f, 15.0f) );
1839 TestStartPan( application, START_POSITION, pos, time );
1840 time += Wait(application);
1841 for( int i = 0; i<45; i++ )
1843 pos += Vector2(0.0f, 1.0f);
1844 TestMovePan( application, pos, time );
1845 time += Wait( application );
1847 pos += Vector2(0.0f, 1.0f);
1848 TestEndPan( application, pos, time );
1849 time += Wait( application );
1851 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1853 scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1855 scrollView.ScrollTo(START_POSITION, 0.0f);
1857 time += Wait(application);
1859 // Try a vertical swipe.
1860 // PerformGestureSwipe not used as a different initial direction was required
1861 pos = ( START_POSITION + Vector2(0.0f, 15.0f) );
1862 TestStartPan( application, START_POSITION, pos, time );
1863 time += Wait(application);
1864 for( int i = 0; i<45; i++ )
1866 pos += Vector2(0.0f, 1.0f);
1867 TestMovePan( application, pos, time );
1868 time += Wait( application );
1870 pos += Vector2(0.0f, 1.0f);
1871 TestEndPan( application, pos, time );
1872 time += Wait( application );
1874 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1879 int UtcDaliToolkitScrollViewRemoveScrollingDirectionP(void)
1881 ToolkitTestApplication application;
1882 tet_infoline(" UtcDaliToolkitScrollViewRemoveScrollingDirectionP");
1884 // Set up a scrollView...
1885 ScrollView scrollView = ScrollView::New();
1886 application.GetScene().Add( scrollView );
1887 Vector2 stageSize = application.GetScene().GetSize();
1888 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1889 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1890 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1892 Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1895 scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1897 scrollView.ScrollTo(START_POSITION, 0.0f);
1899 time += Wait(application);
1901 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION );
1903 // Try a vertical swipe.
1904 // PerformGestureSwipe not used as a different initial direction was required
1905 Vector2 pos( START_POSITION + Vector2(0.0f, 15.0f) );
1906 TestStartPan( application, START_POSITION, pos, time );
1907 time += Wait(application);
1908 for( int i = 0; i<45; i++ )
1910 pos += Vector2(0.0f, 1.0f);
1911 TestMovePan( application, pos, time );
1912 time += Wait( application );
1914 pos += Vector2(0.0f, 1.0f);
1915 TestEndPan( application, pos, time );
1916 time += Wait( application );
1918 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1920 scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1921 // When the horizontal direction is removed, there are no directions set and therefore all will work
1922 scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_HORIZONTAL);
1924 time += Wait(application);
1925 // Try a vertical swipe.
1926 Vector2 pos2( pos + Vector2(0.0f, 15.0f) );
1927 TestStartPan( application, pos, pos2, time );
1928 time += Wait(application);
1929 for( int i = 0; i<45; i++ )
1931 pos2 += Vector2(0.0f, 1.0f);
1932 TestMovePan( application, pos2, time );
1933 time += Wait( application );
1935 pos2 += Vector2(0.0f, 1.0f);
1936 TestEndPan( application, pos2, time );
1938 // The previous scroll should not have had any effect
1939 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1944 int UtcDaliToolkitScrollViewSetRulerXP(void)
1946 ToolkitTestApplication application;
1947 tet_infoline(" UtcDaliToolkitScrollViewSetRulerXP");
1949 ScrollView scrollView = ScrollView::New();
1950 application.GetScene().Add( scrollView );
1951 RulerPtr rulerX = new FixedRuler( 100.0f );
1952 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1954 scrollView.SetRulerX( rulerX );
1956 scrollView.ScrollTo( 1, 0.0f );
1958 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION );
1960 RulerPtr newRulerX = new FixedRuler( 200.0f );
1961 newRulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1963 scrollView.SetRulerX( newRulerX );
1965 scrollView.ScrollTo( 1, 0.0f );
1967 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 0.0f), TEST_LOCATION );
1972 int UtcDaliToolkitScrollViewSetRulerYP(void)
1974 ToolkitTestApplication application;
1975 tet_infoline(" UtcDaliToolkitScrollViewSetRulerYP");
1977 ScrollView scrollView = ScrollView::New();
1978 application.GetScene().Add( scrollView );
1980 RulerPtr rulerY = new FixedRuler( 200.0f );
1981 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1983 scrollView.SetRulerY( rulerY );
1985 scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f );
1987 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 350.0f), TEST_LOCATION );
1989 RulerPtr newRulerY = new FixedRuler( 100.0f );
1990 newRulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
1991 scrollView.SetRulerY( newRulerY );
1993 scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f );
1995 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 200.0f), TEST_LOCATION );
2000 int UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP(void)
2002 ToolkitTestApplication application;
2003 tet_infoline(" UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP");
2005 ScrollView scrollView = ScrollView::New();
2006 scrollView.SetMinimumSpeedForFlick(25.0f);
2007 DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 25.0f, TEST_LOCATION );
2008 scrollView.SetMinimumSpeedForFlick(60.0f);
2009 DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 60.0f, TEST_LOCATION );
2013 int UtcDaliToolkitScrollViewSetMinimumDistanceForFlickP(void)
2015 ToolkitTestApplication application;
2016 tet_infoline(" UtcDaliToolkitScrollViewSetMinimumDistanceForFlick");
2018 ScrollView scrollView = ScrollView::New();
2020 scrollView.SetMinimumDistanceForFlick(Vector2(30.0f, 15.0f));
2021 DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(30.0f, 15.0f), TEST_LOCATION );
2022 scrollView.SetMinimumDistanceForFlick(Vector2(60.0f, 30.0f));
2023 DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(60.0f, 30.0f), TEST_LOCATION);
2027 int UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP(void)
2029 ToolkitTestApplication application;
2030 tet_infoline(" UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP");
2032 ScrollView scrollView = ScrollView::New();
2033 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
2034 scrollView.SetWheelScrollDistanceStep(Vector2(30.0f, 15.0f));
2035 DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(30.0f, 15.0f), TEST_LOCATION );
2036 scrollView.SetWheelScrollDistanceStep(Vector2(60.0f, 30.0f));
2037 DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(60.0f, 30.0f), TEST_LOCATION);
2041 int UtcDaliToolkitScrollViewApplyEffectP(void)
2043 ToolkitTestApplication application;
2044 tet_infoline(" UtcDaliToolkitScrollViewApplyEffectP");
2046 // Create a ScrollView
2047 ScrollView scrollView = ScrollView::New();
2049 // Create two scroll view effects
2050 Dali::Path path = Dali::Path::New();
2051 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);
2052 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);
2054 // Apply both effects
2055 scrollView.ApplyEffect(effect);
2056 scrollView.ApplyEffect(newEffect);
2058 DALI_TEST_CHECK( true );
2063 int UtcDaliToolkitScrollViewApplyEffectN(void)
2065 ToolkitTestApplication application;
2066 tet_infoline(" UtcDaliToolkitScrollViewApplyEffectN");
2068 // Create a ScrollView
2069 ScrollView scrollView = ScrollView::New();
2071 // Create two scroll view effects
2072 Dali::Path path = Dali::Path::New();
2073 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);
2074 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);
2076 // Apply both effects
2077 scrollView.ApplyEffect(effect);
2078 scrollView.ApplyEffect(newEffect);
2080 // Attempt to apply the same effect again
2083 scrollView.ApplyEffect(newEffect);
2084 tet_result( TET_FAIL );
2086 catch ( DaliException& e )
2088 DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
2094 int UtcDaliToolkitScrollViewRemoveEffectP(void)
2096 ToolkitTestApplication application;
2097 tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectP");
2099 // Create a ScrollView
2100 ScrollView scrollView = ScrollView::New();
2102 // Create two scroll view effects
2103 Dali::Path path = Dali::Path::New();
2104 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);
2105 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);
2107 // Apply both effects
2108 scrollView.ApplyEffect(effect);
2109 scrollView.ApplyEffect(newEffect);
2111 // Remove both effects
2112 scrollView.RemoveEffect(effect);
2113 scrollView.RemoveEffect(newEffect);
2115 DALI_TEST_CHECK( true );
2120 int UtcDaliToolkitScrollViewRemoveEffectN(void)
2122 ToolkitTestApplication application;
2123 tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectN");
2125 // Create a ScrollView
2126 ScrollView scrollView = ScrollView::New();
2128 // Create two scroll view effects
2129 Dali::Path path = Dali::Path::New();
2130 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);
2131 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);
2133 // Apply the first effect
2134 scrollView.ApplyEffect(effect);
2136 // Attempt to remove the second effect which has not been applied to scroll view
2139 scrollView.RemoveEffect(newEffect);
2140 tet_result( TET_FAIL );
2142 catch ( DaliException& e )
2144 DALI_TEST_ASSERT( e, "effectExistedInScrollView", TEST_LOCATION );
2150 int UtcDaliToolkitScrollViewRemoveAllEffectsP(void)
2152 ToolkitTestApplication application;
2153 tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsP");
2155 // Create a ScrollView
2156 ScrollView scrollView = ScrollView::New();
2158 // Create two scroll view effects
2159 Dali::Path path = Dali::Path::New();
2160 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);
2161 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);
2163 // Apply both effects
2164 scrollView.ApplyEffect(effect);
2165 scrollView.ApplyEffect(newEffect);
2167 // Attempt to apply the same first effect again
2170 scrollView.ApplyEffect(effect);
2171 tet_result( TET_FAIL );
2173 catch ( DaliException& e )
2175 DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
2178 // Remove both effects
2179 scrollView.RemoveAllEffects();
2181 // Apply both effects again
2182 scrollView.ApplyEffect(effect);
2183 scrollView.ApplyEffect(newEffect);
2185 DALI_TEST_CHECK( true );
2190 int UtcDaliToolkitScrollViewRemoveAllEffectsN(void)
2192 ToolkitTestApplication application;
2193 tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsN");
2195 // Create a ScrollView
2196 ScrollView scrollView = ScrollView::New();
2198 // Remove effects when there is no effect applied previously
2199 scrollView.RemoveAllEffects();
2201 DALI_TEST_CHECK( true );
2206 int UtcDaliToolkitScrollViewSetOvershootEnabledP(void)
2208 ToolkitTestApplication application;
2209 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEnabledP");
2211 ScrollView scrollView = ScrollView::New();
2213 scrollView.SetOvershootEnabled(true);
2214 DALI_TEST_CHECK(scrollView.IsOvershootEnabled());
2216 scrollView.SetOvershootEnabled(false);
2217 DALI_TEST_CHECK(!scrollView.IsOvershootEnabled());
2222 int UtcDaliToolkitScrollViewSetOvershootEffectColorP(void)
2224 ToolkitTestApplication application;
2225 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEffectColorP");
2227 ScrollView scrollView = ScrollView::New();
2229 scrollView.SetOvershootEffectColor(Dali::Color::RED);
2230 DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::RED, TEST_LOCATION);
2232 scrollView.SetOvershootEffectColor(Dali::Color::YELLOW);
2233 DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::YELLOW, TEST_LOCATION);
2238 int UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP(void)
2240 ToolkitTestApplication application;
2241 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP");
2243 ScrollView scrollView = ScrollView::New();
2245 scrollView.SetOvershootAnimationSpeed(55.0f);
2246 DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 55.0f, TEST_LOCATION);
2248 scrollView.SetOvershootAnimationSpeed(120.0f);
2249 DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 120.0f, TEST_LOCATION);
2254 int UtcDaliToolkitScrollViewGetSet(void)
2256 ToolkitTestApplication application;
2257 tet_infoline(" UtcDaliToolkitScrollViewGetSet");
2258 ScrollView scrollView = ScrollView::New();
2259 scrollView.SetMaxFlickSpeed(0.5f);
2260 DALI_TEST_EQUALS(scrollView.GetMaxFlickSpeed(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
2261 scrollView.SetFrictionCoefficient(0.6f);
2262 DALI_TEST_EQUALS(scrollView.GetFrictionCoefficient(), 0.6f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
2263 scrollView.SetFlickSpeedCoefficient(0.7f);
2264 DALI_TEST_EQUALS(scrollView.GetFlickSpeedCoefficient(), 0.7f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
2268 int UtcDaliToolkitScrollViewRulerDomainConstructorP(void)
2270 ToolkitTestApplication application;
2272 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2273 DALI_TEST_EQUALS( domainX.min, 0.0f, TEST_LOCATION);
2274 DALI_TEST_EQUALS( domainX.max, 200.0f, TEST_LOCATION);
2275 DALI_TEST_EQUALS( domainX.enabled, true, TEST_LOCATION);
2277 RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
2278 DALI_TEST_EQUALS( domainY.min, 100.0f, TEST_LOCATION);
2279 DALI_TEST_EQUALS( domainY.max, 500.0f, TEST_LOCATION);
2280 DALI_TEST_EQUALS( domainY.enabled, false, TEST_LOCATION);
2285 int UtcDaliToolkitScrollViewRulerDomainGetSizeP(void)
2287 ToolkitTestApplication application;
2289 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2290 DALI_TEST_EQUALS( domainX.GetSize(), 200.0f, TEST_LOCATION);
2292 RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
2293 DALI_TEST_EQUALS( domainY.GetSize(), 400.0f, TEST_LOCATION);
2298 int UtcDaliToolkitScrollViewRulerDomainClampP(void)
2300 ToolkitTestApplication application;
2302 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2304 float value = domainX.Clamp(50.0f, 100.0f, 1.0f);
2305 DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
2307 value = domainX.Clamp(300.0f, 20.0f, 1.0f);
2308 DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
2310 value = domainX.Clamp(300.0f, 20.0f, 0.5f);
2311 DALI_TEST_EQUALS( value, 80.0f, TEST_LOCATION);
2313 value = domainX.Clamp(250.0f, 200.0f, 2.0f);
2314 DALI_TEST_EQUALS( value, 200.0f, TEST_LOCATION);
2319 int UtcDaliToolkitScrollViewRulerDomainClampWithStateP(void)
2321 ToolkitTestApplication application;
2323 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2326 float value = domainX.Clamp(50.0f, 100.0f, 1.0f, clamped);
2327 DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
2328 DALI_TEST_EQUALS( clamped, Dali::Toolkit::NOT_CLAMPED, TEST_LOCATION);
2330 value = domainX.Clamp(-100.0f, 200.0f, 1.0f, clamped);
2331 DALI_TEST_EQUALS( value, 0.0f, TEST_LOCATION);
2332 DALI_TEST_EQUALS( clamped, Dali::Toolkit::CLAMPED_TO_MIN, TEST_LOCATION);
2334 value = domainX.Clamp(300.0f, 20.0f, 1.0f, clamped);
2335 DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
2336 DALI_TEST_EQUALS( clamped, Dali::Toolkit::CLAMPED_TO_MAX, TEST_LOCATION);
2341 int UtcDaliToolkitScrollViewDefaultRulerConstructorP(void)
2343 ToolkitTestApplication application;
2344 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerConstructorP");
2346 RulerPtr defaultRuler = new DefaultRuler();
2347 DALI_TEST_CHECK( defaultRuler );
2352 int UtcDaliToolkitScrollViewDefaultRulerDestructorP(void)
2354 ToolkitTestApplication application;
2355 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerDestructorP");
2357 RulerPtr defaultRuler = new DefaultRuler();
2359 DALI_TEST_CHECK( true );
2363 int UtcDaliToolkitScrollViewFixedRulerConstructorP(void)
2365 ToolkitTestApplication application;
2366 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerConstructorP");
2368 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2369 DALI_TEST_CHECK( fixedRuler );
2371 fixedRuler = new FixedRuler( 0.0f );
2372 DALI_TEST_CHECK( fixedRuler );
2377 int UtcDaliToolkitScrollViewFixedRulerDestructorP(void)
2379 ToolkitTestApplication application;
2380 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerDestructorP");
2382 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2384 DALI_TEST_CHECK( true );
2388 int UtcDaliToolkitScrollViewRulerGetTypeP(void)
2390 ToolkitTestApplication application;
2391 tet_infoline(" UtcDaliToolkitScrollViewRulerGetTypeP");
2393 RulerPtr defaultRuler = new DefaultRuler();
2394 DALI_TEST_CHECK( defaultRuler );
2395 DALI_TEST_EQUALS( defaultRuler->GetType(), Dali::Toolkit::Ruler::FREE, TEST_LOCATION);
2397 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2398 DALI_TEST_CHECK( fixedRuler );
2399 DALI_TEST_EQUALS( fixedRuler->GetType(), Dali::Toolkit::Ruler::FIXED, TEST_LOCATION);
2404 int UtcDaliToolkitScrollViewRulerGetExtensionP(void)
2406 ToolkitTestApplication application;
2407 tet_infoline(" UtcDaliToolkitScrollViewRulerGetExtensionP");
2409 RulerPtr defaultRuler = new DefaultRuler();
2410 DALI_TEST_CHECK( defaultRuler );
2411 DALI_TEST_CHECK( !defaultRuler->GetExtension() );
2413 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2414 DALI_TEST_CHECK( fixedRuler );
2415 DALI_TEST_CHECK( !fixedRuler->GetExtension() );
2420 int UtcDaliToolkitScrollViewRulerEnableDisable(void)
2422 ToolkitTestApplication application;
2423 tet_infoline(" UtcDaliToolkitScrollViewRulerEnableDisable");
2425 RulerPtr ruler = new DefaultRuler();
2427 DALI_TEST_CHECK( ruler->IsEnabled() );
2429 DALI_TEST_CHECK( !ruler->IsEnabled() );
2431 DALI_TEST_CHECK( ruler->IsEnabled() );
2435 int UtcDaliToolkitScrollViewRulerDomainEnableDisable(void)
2437 ToolkitTestApplication application;
2438 tet_infoline(" UtcDaliToolkitScrollViewRulerDomainEnableDisable");
2440 RulerPtr ruler = new DefaultRuler();
2441 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
2443 ruler->SetDomain( RulerDomain(0.0f, 100.0f, true) );
2444 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 100.0f, TEST_LOCATION );
2445 DALI_TEST_EQUALS( ruler->Clamp(-200.0f), 0.0f, TEST_LOCATION );
2446 DALI_TEST_EQUALS( ruler->Clamp(200.0f), 100.0f, TEST_LOCATION );
2448 ruler->DisableDomain();
2449 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
2450 DALI_TEST_EQUALS( ruler->Clamp(-200.0f), -200.0f, TEST_LOCATION );
2451 DALI_TEST_EQUALS( ruler->Clamp(200.0f), 200.0f, TEST_LOCATION );
2455 int UtcDaliToolkitScrollViewRulerSnapAndClamp(void)
2457 ToolkitTestApplication application;
2458 tet_infoline(" UtcDaliToolkitScrollViewRulerSnapAndClamp");
2460 RulerPtr ruler = new FixedRuler( 50.0f );
2461 ruler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2463 // default testing. (snap and clamp)
2464 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f), 50.0f, TEST_LOCATION);
2465 DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f), 50.0f, TEST_LOCATION);
2466 DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f), 0.0f, TEST_LOCATION);
2467 DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f), 0.0f, TEST_LOCATION);
2468 DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f), 400.0f, TEST_LOCATION);
2469 DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f), 400.0f, TEST_LOCATION);
2472 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
2473 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.5f), 50.0f, TEST_LOCATION); // No Flick
2474 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
2476 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
2477 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.5f), 0.0f, TEST_LOCATION); // No Flick
2478 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
2481 DALI_TEST_EQUALS( ruler->SnapAndClamp(-10.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (over left boundary)
2482 DALI_TEST_EQUALS( ruler->SnapAndClamp(-5.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (slightly ovr left boundary)
2483 DALI_TEST_EQUALS( ruler->SnapAndClamp(300.0f, 0.5f, 10.0f), 300.0f, TEST_LOCATION); // 10 units long (not over a boundary)
2484 DALI_TEST_EQUALS( ruler->SnapAndClamp(395.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (slightly over right boundary)
2485 DALI_TEST_EQUALS( ruler->SnapAndClamp(500.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (over right boundary)
2488 DALI_TEST_EQUALS( ruler->SnapAndClamp(-100.0f, 0.5f, 0.0f, 2.0f), 0.0f, TEST_LOCATION);
2489 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 2.0f), 50.0f, TEST_LOCATION);
2490 DALI_TEST_EQUALS( ruler->SnapAndClamp(700.0f, 0.5f, 0.0f, 2.0f), 700.0f, TEST_LOCATION);
2491 DALI_TEST_EQUALS( ruler->SnapAndClamp(850.0f, 0.5f, 0.0f, 2.0f), 800.0f, TEST_LOCATION);
2493 // clamp state testing.
2495 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
2496 DALI_TEST_EQUALS( clamped, NOT_CLAMPED, TEST_LOCATION );
2497 DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
2498 DALI_TEST_EQUALS( clamped, NOT_CLAMPED, TEST_LOCATION );
2499 DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
2500 DALI_TEST_EQUALS( clamped, NOT_CLAMPED, TEST_LOCATION );
2501 DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
2502 DALI_TEST_EQUALS( clamped, CLAMPED_TO_MIN, TEST_LOCATION );
2503 DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
2504 DALI_TEST_EQUALS( clamped, NOT_CLAMPED, TEST_LOCATION );
2505 DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
2506 DALI_TEST_EQUALS( clamped, CLAMPED_TO_MAX, TEST_LOCATION );
2510 int UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP(void)
2512 ToolkitTestApplication application;
2513 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP");
2515 RulerPtr rulerNormal = new FixedRuler( 25.0f );
2516 rulerNormal->SetDomain( RulerDomain(10.0f, 90.0f, true) );
2518 unsigned int volume;
2521 position = rulerNormal->GetPositionFromPage(1, volume, true);
2522 DALI_TEST_EQUALS( position, 35.0f, TEST_LOCATION );
2523 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
2525 position = rulerNormal->GetPositionFromPage(2, volume, true);
2526 DALI_TEST_EQUALS( position, 60.0f, TEST_LOCATION );
2527 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
2529 // Disable the ruler
2530 rulerNormal->Disable();
2532 position = rulerNormal->GetPositionFromPage(1, volume, true);
2533 DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
2534 DALI_TEST_EQUALS( volume, 1u, TEST_LOCATION );
2536 position = rulerNormal->GetPositionFromPage(2, volume, true);
2537 DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
2538 DALI_TEST_EQUALS( volume, 2u, TEST_LOCATION );
2543 int UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP(void)
2545 ToolkitTestApplication application;
2546 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP");
2548 RulerPtr defaultRuler = new DefaultRuler();
2549 DALI_TEST_CHECK( defaultRuler );
2550 DALI_TEST_EQUALS( defaultRuler->GetTotalPages(), 1u, TEST_LOCATION);
2555 int UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP(void)
2557 ToolkitTestApplication application;
2558 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP");
2560 RulerPtr defaultRuler = new DefaultRuler();
2561 DALI_TEST_CHECK( defaultRuler );
2562 DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(100.0f, true), 0u, TEST_LOCATION);
2563 DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(-300.0f, false), 0u, TEST_LOCATION);
2568 int UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP(void)
2570 ToolkitTestApplication application;
2571 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP");
2573 RulerPtr defaultRuler = new DefaultRuler();
2574 DALI_TEST_CHECK( defaultRuler );
2576 unsigned int volume;
2577 DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(0, volume, true), 0.0f, TEST_LOCATION);
2578 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
2580 DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(3, volume, false), 0.0f, TEST_LOCATION);
2581 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
2586 int UtcDaliToolkitScrollViewDefaultRulerSnapP(void)
2588 ToolkitTestApplication application;
2589 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerSnapP");
2591 RulerPtr defaultRuler = new DefaultRuler();
2592 DALI_TEST_CHECK( defaultRuler );
2594 DALI_TEST_EQUALS( defaultRuler->Snap(50.0f, 0.5f), 50.0f, TEST_LOCATION);
2595 DALI_TEST_EQUALS( defaultRuler->Snap(-120.0f, 1.0f), -120.0f, TEST_LOCATION);
2600 int UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP(void)
2602 ToolkitTestApplication application;
2603 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP");
2605 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2606 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2608 fixedRuler->Enable();
2609 DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 4u, TEST_LOCATION);
2611 fixedRuler->Disable();
2612 DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 1u, TEST_LOCATION);
2617 int UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP(void)
2619 ToolkitTestApplication application;
2620 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP");
2622 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2623 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2625 fixedRuler->Enable();
2626 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 3u, TEST_LOCATION);
2627 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2628 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 1u, TEST_LOCATION);
2629 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2631 fixedRuler->Disable();
2632 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2633 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
2634 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2635 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2637 // Set domain size to be smaller than the ruler space
2638 fixedRuler->SetDomain( RulerDomain(0.0f, 50.0f, true) );
2640 fixedRuler->Enable();
2641 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2642 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2643 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2644 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2646 fixedRuler->Disable();
2647 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2648 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
2649 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2650 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2655 int UtcDaliToolkitScrollViewFixedRulerSnapP(void)
2657 ToolkitTestApplication application;
2658 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerSnapP");
2660 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2661 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2663 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.0f), -100.0f, TEST_LOCATION);
2664 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.0f), -100.0f, TEST_LOCATION);
2665 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.0f), -200.0f, TEST_LOCATION);
2666 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.0f), -500.0f, TEST_LOCATION);
2667 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.0f), 0.0f, TEST_LOCATION);
2668 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.0f), 0.0f, TEST_LOCATION);
2669 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.0f), 0.0f, TEST_LOCATION);
2670 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.0f), 100.0f, TEST_LOCATION);
2671 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.0f), 100.0f, TEST_LOCATION);
2672 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.0f), 200.0f, TEST_LOCATION);
2673 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.0f), 600.0f, TEST_LOCATION);
2675 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.5f), 0.0f, TEST_LOCATION);
2676 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.5f), -100.0f, TEST_LOCATION);
2677 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.5f), -100.0f, TEST_LOCATION);
2678 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.5f), -500.0f, TEST_LOCATION);
2679 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.5f), 0.0f, TEST_LOCATION);
2680 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.5f), 100.0f, TEST_LOCATION);
2681 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.5f), 100.0f, TEST_LOCATION);
2682 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.5f), 100.0f, TEST_LOCATION);
2683 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.5f), 100.0f, TEST_LOCATION);
2684 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.5f), 300.0f, TEST_LOCATION);
2685 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.5f), 600.0f, TEST_LOCATION);
2687 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 1.0f), 0.0f, TEST_LOCATION);
2688 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 1.0f), 0.0f, TEST_LOCATION);
2689 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 1.0f), -100.0f, TEST_LOCATION);
2690 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 1.0f), -400.0f, TEST_LOCATION);
2691 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 1.0f), 100.0f, TEST_LOCATION);
2692 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 1.0f), 100.0f, TEST_LOCATION);
2693 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 1.0f), 100.0f, TEST_LOCATION);
2694 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 1.0f), 200.0f, TEST_LOCATION);
2695 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 1.0f), 200.0f, TEST_LOCATION);
2696 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 1.0f), 300.0f, TEST_LOCATION);
2697 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 1.0f), 700.0f, TEST_LOCATION);
2702 int UtcDaliToolkitScrollViewConstraintsMove(void)
2704 ToolkitTestApplication application;
2705 tet_infoline(" UtcDaliToolkitScrollViewConstraintsMove");
2707 // Set up a scrollView...
2708 ScrollView scrollView = ScrollView::New();
2709 application.GetScene().Add( scrollView );
2710 Vector2 stageSize = application.GetScene().GetSize();
2711 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
2712 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
2713 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2716 RulerPtr rulerX = new DefaultRuler();
2717 RulerPtr rulerY = new DefaultRuler();
2718 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
2719 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
2720 scrollView.SetRulerX(rulerX);
2721 scrollView.SetRulerY(rulerY);
2723 // Add an Actor to ScrollView,
2724 Actor a = Actor::New();
2726 a.SetProperty( Actor::Property::POSITION, TEST_ACTOR_POSITION);
2729 const Vector2 target = Vector2(100.0f, 100.0f);
2730 const Vector2 target2 = Vector2(200.0f, 200.0f);
2732 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, MoveActorConstraint );
2733 constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
2734 constraint.SetRemoveAction(Constraint::DISCARD);
2735 scrollView.ApplyConstraintToChildren(constraint);
2737 scrollView.ScrollTo( target, 0.0f );
2739 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
2740 scrollView.ScrollTo( target2 );
2741 Wait(application, RENDER_DELAY_SCROLL);
2742 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
2747 int UtcDaliToolkitScrollViewConstraintsWrap(void)
2749 ToolkitTestApplication application;
2750 tet_infoline(" UtcDaliToolkitScrollViewConstraintsWrap");
2752 // Set up a scrollView...
2753 ScrollView scrollView = ScrollView::New();
2754 application.GetScene().Add( scrollView );
2755 Vector2 stageSize = application.GetScene().GetSize();
2756 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
2757 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
2758 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2761 RulerPtr rulerX = new DefaultRuler();
2762 RulerPtr rulerY = new DefaultRuler();
2763 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
2764 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
2765 scrollView.SetRulerX(rulerX);
2766 scrollView.SetRulerY(rulerY);
2768 // Add an Actor to ScrollView,
2769 Actor a = Actor::New();
2771 a.SetProperty( Actor::Property::POSITION, TEST_ACTOR_POSITION);
2774 const Vector2 target = Vector2(100.0f, 100.0f);
2775 const Vector2 target2 = Vector2(200.0f, 200.0f);
2777 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, WrapActorConstraint );
2778 constraint.AddSource( LocalSource( Actor::Property::SCALE ) );
2779 constraint.AddSource( LocalSource( Actor::Property::ANCHOR_POINT ) );
2780 constraint.AddSource( LocalSource( Actor::Property::SIZE ) );
2781 constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
2782 constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
2783 constraint.AddSource( Source( scrollView, Toolkit::ScrollView::Property::WRAP ) );
2784 constraint.SetRemoveAction(Constraint::DISCARD);
2785 scrollView.ApplyConstraintToChildren(constraint);
2787 scrollView.ScrollTo( target, 0.0f );
2789 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
2790 scrollView.ScrollTo( target2 );
2791 Wait(application, RENDER_DELAY_SCROLL);
2792 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
2794 scrollView.Remove(a);
2800 // Non-API test (so no P or N variant).
2801 int UtcDaliToolkitScrollViewGesturePageLimit(void)
2803 ToolkitTestApplication application;
2804 tet_infoline( " UtcDaliToolkitScrollViewGesturePageLimit" );
2806 // Set up a scrollView.
2807 ScrollView scrollView = ScrollView::New();
2809 // Do not rely on stage size for UTC tests.
2810 Vector2 viewPageSize( 720.0f, 1280.0f );
2811 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
2812 scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
2813 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
2814 scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
2815 scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
2818 // We set the X ruler to fixed to give us pages to snap to.
2819 Dali::Toolkit::FixedRuler* rulerX = new Dali::Toolkit::FixedRuler( viewPageSize.width );
2820 // Note: The 3x page width is arbitary, but we need enough to show that we are
2821 // capping page movement by the page limiter, and not the domain.
2822 rulerX->SetDomain( Dali::Toolkit::RulerDomain( 0.0f, viewPageSize.width * 3.0f, false ) );
2823 Dali::Toolkit::RulerPtr rulerY = new Dali::Toolkit::DefaultRuler();
2825 scrollView.SetRulerX( rulerX );
2826 scrollView.SetRulerY( rulerY );
2828 scrollView.SetWrapMode( false );
2829 scrollView.SetScrollSensitive( true );
2831 application.GetScene().Add( scrollView );
2833 // Set up a gesture to perform.
2834 Vector2 startPos( 50.0f, 0.0f );
2835 Vector2 direction( -5.0f, 0.0f );
2838 // Force starting position.
2839 scrollView.ScrollTo( startPos, 0.0f );
2841 time += Wait( application );
2843 // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
2844 Vector2 currentPos( PerformGestureSwipe( application, startPos, direction, frames - 1, time, false ) );
2846 // Confirm the final X coord has not moved more than one page from the start X position.
2847 DALI_TEST_GREATER( ( startPos.x + viewPageSize.width ), scrollView.GetCurrentScrollPosition().x, TEST_LOCATION );
2849 // Finish the gesture and wait for the snap.
2850 currentPos += direction;
2851 TestEndPan(application, currentPos, time);
2852 // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
2853 time += Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
2855 // Confirm the final X coord has snapped to exactly one page ahead of the start page.
2856 DALI_TEST_EQUALS( viewPageSize.width, scrollView.GetCurrentScrollPosition().x, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2861 int UtcDaliScrollViewSetGetProperty(void)
2863 ToolkitTestApplication application;
2865 // Create the ScrollView actor
2866 ScrollView scrollView = ScrollView::New();
2867 DALI_TEST_CHECK(scrollView);
2869 // Event side properties
2871 // Test "wrapEnabled" property
2872 DALI_TEST_CHECK( scrollView.GetPropertyIndex("wrapEnabled") == ScrollView::Property::WRAP_ENABLED );
2873 scrollView.SetProperty( ScrollView::Property::WRAP_ENABLED, true );
2874 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WRAP_ENABLED).Get<bool>(), true, TEST_LOCATION );
2876 // Test "panningEnabled" property
2877 DALI_TEST_CHECK( scrollView.GetPropertyIndex("panningEnabled") == ScrollView::Property::PANNING_ENABLED );
2878 scrollView.SetProperty( ScrollView::Property::PANNING_ENABLED, false );
2879 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::PANNING_ENABLED).Get<bool>(), false, TEST_LOCATION );
2881 // Test "axisAutoLockEnabled" property
2882 DALI_TEST_CHECK( scrollView.GetPropertyIndex("axisAutoLockEnabled") == ScrollView::Property::AXIS_AUTO_LOCK_ENABLED );
2883 scrollView.SetProperty( ScrollView::Property::AXIS_AUTO_LOCK_ENABLED, false );
2884 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::AXIS_AUTO_LOCK_ENABLED).Get<bool>(), false, TEST_LOCATION );
2886 // Test "wheelScrollDistanceStep" property
2887 DALI_TEST_CHECK( scrollView.GetPropertyIndex("wheelScrollDistanceStep") == ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP );
2888 scrollView.SetProperty( ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP, Vector2(100.0f, 50.0f) );
2889 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP).Get<Vector2>(), Vector2(100.0f, 50.0f), TEST_LOCATION );
2891 // Test "overshootEnabled" property
2892 DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootEnabled") == Scrollable::Property::OVERSHOOT_ENABLED );
2893 DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), scrollView.IsOvershootEnabled(), TEST_LOCATION );
2894 scrollView.SetProperty( Scrollable::Property::OVERSHOOT_ENABLED, false );
2895 DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), false, TEST_LOCATION );
2897 // Animatable properties
2899 // Test "scrollPosition" property
2900 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPosition") == ScrollView::Property::SCROLL_POSITION );
2901 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(320.0f, 550.0f) );
2903 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION).Get<Vector2>(), Vector2(320.0f, 550.0f), TEST_LOCATION );
2905 // Test "scrollPrePosition", "scrollPrePositionX" and "scrollPrePositionY" properties
2906 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePosition") == ScrollView::Property::SCROLL_PRE_POSITION );
2907 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION, Vector2(300.0f, 500.0f) );
2909 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION).Get<Vector2>(), Vector2(300.0f, 500.0f), TEST_LOCATION );
2911 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionX") == ScrollView::Property::SCROLL_PRE_POSITION_X );
2912 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionY") == ScrollView::Property::SCROLL_PRE_POSITION_Y );
2913 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_X).Get<float>(), 300.0f, TEST_LOCATION );
2914 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_Y).Get<float>(), 500.0f, TEST_LOCATION );
2915 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_X, 400.0f );
2916 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_Y, 600.0f );
2918 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_X).Get<float>(), 400.0f, TEST_LOCATION );
2919 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_Y).Get<float>(), 600.0f, TEST_LOCATION );
2920 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION).Get<Vector2>(), Vector2(400.0f, 600.0f), TEST_LOCATION );
2922 // Test "scrollPrePositionMax", "scrollPrePositionMaxX" and "scrollPrePositionMaxY" properties
2923 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMax") == ScrollView::Property::SCROLL_PRE_POSITION_MAX );
2924 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX, Vector2(100.0f, 200.0f) );
2926 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX).Get<Vector2>(), Vector2(100.0f, 200.0f), TEST_LOCATION );
2928 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMaxX") == ScrollView::Property::SCROLL_PRE_POSITION_MAX_X );
2929 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMaxY") == ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y );
2930 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_X).Get<float>(), 100.0f, TEST_LOCATION );
2931 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y).Get<float>(), 200.0f, TEST_LOCATION );
2932 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX_X, 300.0f );
2933 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y, 400.0f );
2935 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_X).Get<float>(), 300.0f, TEST_LOCATION );
2936 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y).Get<float>(), 400.0f, TEST_LOCATION );
2937 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX).Get<Vector2>(), Vector2(300.0f, 400.0f), TEST_LOCATION );
2939 // Test "overshootX" property
2940 DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootX") == ScrollView::Property::OVERSHOOT_X );
2941 scrollView.SetProperty( ScrollView::Property::OVERSHOOT_X, 0.8f );
2943 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::OVERSHOOT_X).Get<float>(), 0.8f, TEST_LOCATION );
2945 // Test "overshootY" property
2946 DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootY") == ScrollView::Property::OVERSHOOT_Y );
2947 scrollView.SetProperty( ScrollView::Property::OVERSHOOT_Y, 0.8f );
2949 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y).Get<float>(), 0.8f, TEST_LOCATION );
2951 // Test "scrollFinal", "scrollFinalX" and "scrollFinalY" properties
2952 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinal") == ScrollView::Property::SCROLL_FINAL );
2953 scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL, Vector2(200.0f, 300.0f) );
2955 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL).Get<Vector2>(), Vector2(200.0f, 300.0f), TEST_LOCATION );
2957 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinalX") == ScrollView::Property::SCROLL_FINAL_X );
2958 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinalY") == ScrollView::Property::SCROLL_FINAL_Y );
2959 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_X).Get<float>(), 200.0f, TEST_LOCATION );
2960 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_Y).Get<float>(), 300.0f, TEST_LOCATION );
2961 scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL_X, 500.0f );
2962 scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL_Y, 600.0f );
2964 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_X).Get<float>(), 500.0f, TEST_LOCATION );
2965 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_Y).Get<float>(), 600.0f, TEST_LOCATION );
2966 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL).Get<Vector2>(), Vector2(500.0f, 600.0f), TEST_LOCATION );
2968 // Test "wrap" property
2969 DALI_TEST_CHECK( scrollView.GetPropertyIndex("wrap") == ScrollView::Property::WRAP );
2970 scrollView.SetProperty( ScrollView::Property::WRAP, false );
2972 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WRAP).Get<bool>(), false, TEST_LOCATION );
2974 // Test "panning" property
2975 DALI_TEST_CHECK( scrollView.GetPropertyIndex("panning") == ScrollView::Property::PANNING );
2976 scrollView.SetProperty( ScrollView::Property::PANNING, true );
2978 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::PANNING).Get<bool>(), true, TEST_LOCATION );
2980 // Test "scrolling" property
2981 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrolling") == ScrollView::Property::SCROLLING );
2982 scrollView.SetProperty( ScrollView::Property::SCROLLING, false );
2984 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLLING).Get<bool>(), false, TEST_LOCATION );
2986 // Test "scrollDomainSize", "scrollDomainSizeX" and "scrollDomainSizeY" properties
2987 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSize") == ScrollView::Property::SCROLL_DOMAIN_SIZE );
2988 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE, Vector2(1200.0f, 1300.0f) );
2990 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE).Get<Vector2>(), Vector2(1200.0f, 1300.0f), TEST_LOCATION );
2992 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSizeX") == ScrollView::Property::SCROLL_DOMAIN_SIZE_X );
2993 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSizeY") == ScrollView::Property::SCROLL_DOMAIN_SIZE_Y );
2994 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_X).Get<float>(), 1200.0f, TEST_LOCATION );
2995 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_Y).Get<float>(), 1300.0f, TEST_LOCATION );
2996 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE_X, 1500.0f );
2997 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE_Y, 1600.0f );
2999 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_X).Get<float>(), 1500.0f, TEST_LOCATION );
3000 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_Y).Get<float>(), 1600.0f, TEST_LOCATION );
3001 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE).Get<Vector2>(), Vector2(1500.0f, 1600.0f), TEST_LOCATION );
3003 // Test "scrollDomainOffset" property
3004 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainOffset") == ScrollView::Property::SCROLL_DOMAIN_OFFSET );
3005 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_OFFSET, Vector2(500.0f, 200.0f) );
3007 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_OFFSET).Get<Vector2>(), Vector2(500.0f, 200.0f), TEST_LOCATION );
3009 // Test "scrollPositionDelta" property
3010 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPositionDelta") == ScrollView::Property::SCROLL_POSITION_DELTA );
3011 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION_DELTA, Vector2(10.0f, 30.0f) );
3013 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION_DELTA).Get<Vector2>(), Vector2(10.0f, 30.0f), TEST_LOCATION );
3015 // Test "startPagePosition" property
3016 DALI_TEST_CHECK( scrollView.GetPropertyIndex("startPagePosition") == ScrollView::Property::START_PAGE_POSITION );
3017 scrollView.SetProperty( ScrollView::Property::START_PAGE_POSITION, Vector3(50.0f, 100.0f, 20.0f) );
3019 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::START_PAGE_POSITION).Get<Vector3>(), Vector3(50.0f, 100.0f, 20.0f), TEST_LOCATION );
3024 int UtcDaliToolkitScrollViewWheelEvent(void)
3026 ToolkitTestApplication application;
3028 // Set up a scrollView.
3029 ScrollView scrollView = ScrollView::New();
3031 // Do not rely on stage size for UTC tests.
3032 Vector2 viewPageSize( 720.0f, 1280.0f );
3033 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3034 scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
3035 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
3036 scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
3037 scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
3040 // We set the X ruler to fixed to give us pages to snap to.
3041 Dali::Toolkit::FixedRuler* rulerX = new Dali::Toolkit::FixedRuler( viewPageSize.width );
3042 // Note: The 3x page width is arbitary, but we need enough to show that we are
3043 // capping page movement by the page limiter, and not the domain.
3044 rulerX->SetDomain( Dali::Toolkit::RulerDomain( 0.0f, viewPageSize.width * 3.0f, false ) );
3045 Dali::Toolkit::RulerPtr rulerY = new Dali::Toolkit::DefaultRuler();
3047 scrollView.SetRulerX( rulerX );
3048 scrollView.SetRulerY( rulerY );
3050 scrollView.SetWrapMode( false );
3052 application.GetScene().Add( scrollView );
3054 //Connect to wheel event signal
3055 scrollView.WheelEventSignal().Connect( &OnWheelEvent );
3057 DALI_TEST_CHECK( !gOnWheelEventCalled );
3059 // Render and notify
3060 application.Render();
3061 application.SendNotification();
3062 application.Render();
3063 application.SendNotification();
3065 // Perform a wheel event
3066 Dali::Integration::WheelEvent wheelEvent( Dali::Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, Vector2( 10.0f, 10.0f ), 1, 1000u );
3067 application.ProcessEvent( wheelEvent );
3068 DALI_TEST_CHECK( gOnWheelEventCalled );
3070 // Set X ruler to free
3071 Dali::Toolkit::DefaultRuler* defaultRuler = new Dali::Toolkit::DefaultRuler();
3072 scrollView.SetRulerX( defaultRuler );
3074 // Perform a wheel event
3075 gOnWheelEventCalled = false;
3076 application.ProcessEvent( wheelEvent );
3077 DALI_TEST_CHECK( gOnWheelEventCalled );
3082 // Perform a wheel event
3083 gOnWheelEventCalled = false;
3084 application.ProcessEvent( wheelEvent );
3085 DALI_TEST_CHECK( gOnWheelEventCalled );
3087 // Wait until it finishes scrolling
3088 Wait(application, RENDER_DELAY_SCROLL);
3090 // Set Y ruler to fixed
3091 Dali::Toolkit::FixedRuler* fixedRulerY = new Dali::Toolkit::FixedRuler( viewPageSize.height );
3092 scrollView.SetRulerY( fixedRulerY );
3094 // Perform a wheel event
3095 gOnWheelEventCalled = false;
3096 application.ProcessEvent( wheelEvent );
3097 DALI_TEST_CHECK( gOnWheelEventCalled );