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::DirectionBiasLeft, Dali::Toolkit::DirectionBiasLeft );
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::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
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::DirectionBiasLeft, Dali::Toolkit::DirectionBiasLeft );
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::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
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::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
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 );
692 int UtcDaliToolkitScrollModeP2(void)
694 ToolkitTestApplication application;
695 tet_infoline( " UtcDaliToolkitScrollView ScrollMode property" );
697 // Set up a scrollView.
698 ScrollView scrollView = ScrollView::New();
700 // Do not rely on stage size for UTC tests.
701 Vector2 viewPageSize( 720.0f, 1280.0f );
702 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
703 scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
704 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
705 scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
706 scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
709 Property::Map rulerMap;
710 rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, false );
711 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, true );
712 rulerMap.Add( ScrollMode::Y_AXIS_SNAP_TO_INTERVAL, viewPageSize.height );
713 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_BOUNDARY, viewPageSize.height*3 );
714 scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
716 scrollView.SetWrapMode( false );
717 scrollView.SetScrollSensitive( true );
719 application.GetScene().Add( scrollView );
721 // Set up a gesture to perform.
722 Vector2 startPos( 0.0f, 50.0f );
723 Vector2 direction( 0.0f, -6.0f );
727 // Force starting position.
728 scrollView.ScrollTo( startPos, 0.0f );
729 time += Wait( application );
731 // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
732 Vector2 currentPos( PerformGestureSwipe( application, startPos, direction, frames - 1, time, false ) );
734 // Confirm the final X coord has not moved more than one page from the start X position.
735 DALI_TEST_GREATER( ( startPos.y + viewPageSize.height ), scrollView.GetCurrentScrollPosition().y, TEST_LOCATION );
737 // Finish the gesture and wait for the snap.
738 currentPos += direction;
739 time += Wait( application );
740 TestEndPan( application, currentPos, time );
741 // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
742 Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
744 // Confirm the final Y coord has snapped to exactly one page ahead of the start page.
745 DALI_TEST_EQUALS( viewPageSize.height, scrollView.GetCurrentScrollPosition().y, Math::MACHINE_EPSILON_0, TEST_LOCATION );
750 int UtcDaliToolkitScrollModeP3(void)
752 ToolkitTestApplication application;
753 tet_infoline( " UtcDaliToolkitScrollView ScrollMode property" );
755 // Set up a scrollView.
756 ScrollView scrollView = ScrollView::New();
758 // Do not rely on stage size for UTC tests.
759 Vector2 viewPageSize( 720.0f, 1280.0f );
760 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
761 scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
762 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
763 scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
764 scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
767 Property::Map rulerMap;
768 rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, false );
769 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, true );
770 rulerMap.Add( ScrollMode::Y_AXIS_SNAP_TO_INTERVAL, viewPageSize.height );
771 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_BOUNDARY, viewPageSize.height*3 );
772 scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
774 scrollView.SetWrapMode( false );
775 scrollView.SetScrollSensitive( true );
777 application.GetScene().Add( scrollView );
779 // Set up a gesture to perform.
780 Vector2 startPos( 0.0f, 50.0f );
781 Vector2 direction( 0.0f, -6.0f );
785 // Force starting position.
786 scrollView.ScrollTo( startPos, 0.0f );
787 time += Wait( application );
789 // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
790 Vector2 currentPos( PerformGestureSwipe( application, startPos, direction, frames - 1, time, false ) );
792 // Confirm the final X coord has not moved more than one page from the start X position.
793 DALI_TEST_GREATER( ( startPos.y + viewPageSize.height ), scrollView.GetCurrentScrollPosition().y, TEST_LOCATION );
795 // Finish the gesture and wait for the snap.
796 currentPos += direction;
797 TestEndPan( application, currentPos, time );
798 // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
799 Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
801 // Confirm the final Y coord has snapped to exactly one page ahead of the start page.
802 DALI_TEST_EQUALS( viewPageSize.height, scrollView.GetCurrentScrollPosition().y, Math::MACHINE_EPSILON_0, TEST_LOCATION );
807 int UtcDaliToolkitScrollModeP4(void)
809 ToolkitTestApplication application;
810 tet_infoline( " UtcDaliToolkitScrollView ScrollMode property, DefaultRulers" );
812 // Set up a scrollView.
813 ScrollView scrollView = ScrollView::New();
815 // Do not rely on stage size for UTC tests.
816 Vector2 viewPageSize( 720.0f, 1280.0f );
817 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
818 scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
819 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
820 scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
821 scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
823 // Position rulers - expect Default rulers to be used which don't snap
824 Property::Map rulerMap;
825 rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, true );
826 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, true );
827 scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
829 scrollView.SetWrapMode( false );
830 scrollView.SetScrollSensitive( true );
832 application.GetScene().Add( scrollView );
834 Vector2 START_POSITION = Vector2(10.0f, 10.0f);
837 scrollView.ScrollTo(START_POSITION, 0.0f);
838 time += Wait(application);
840 // Try a vertical swipe.
841 // PerformGestureSwipe not used as a different initial direction was required
842 Vector2 pos( START_POSITION + Vector2(0.0f, 15.0f) );
843 Vector2 dir( 0.0f, 1.0f );
845 TestStartPan( application, START_POSITION, pos, time );
849 for( int i = 0; i<45; i++ )
852 TestMovePan( application, pos, time );
853 time += Wait( application );
858 TestEndPan( application, pos, time );
859 Wait( application, RENDER_DELAY_SCROLL );
861 // Take into account resampling done when prediction is off.
862 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
867 int UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP(void)
869 ToolkitTestApplication application;
870 tet_infoline(" UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP");
872 ScrollView scrollView = ScrollView::New();
873 application.GetScene().Add( scrollView );
874 RulerPtr rulerX = new FixedRuler( 100.0f );
875 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
876 RulerPtr rulerY = new FixedRuler( 100.0f );
877 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
879 scrollView.SetRulerX( rulerX );
880 scrollView.SetRulerY( rulerY );
882 scrollView.SetWrapMode(true);
884 scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DirectionBiasLeft );
886 Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame
887 // Check that the scroll position remains the same
888 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
890 Wait(application, RENDER_DELAY_SCROLL); // Wait for one second
891 // Check that it stays at the same page (i.e. the same scroll position)
892 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
893 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
895 scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DirectionBiasRight );
897 Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame
898 // Check that it scrolls towards the right
899 DALI_TEST_CHECK( scrollView.GetCurrentScrollPosition().x > 0.0f );
901 Wait(application, RENDER_DELAY_SCROLL); // Wait for one second
902 // Check that it scrolls back to the same page (i.e. the same scroll position)
903 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
904 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
909 int UtcDaliToolkitScrollViewScrollToActorP(void)
911 ToolkitTestApplication application;
912 tet_infoline(" UtcDaliToolkitScrollViewScrollToActorP");
914 ScrollView scrollView = ScrollView::New();
915 application.GetScene().Add( scrollView );
917 Actor actorA = Actor::New();
918 const Vector3 positionA = Vector3(100.0f, 400.0f, 0.0f);
919 actorA.SetProperty( Actor::Property::POSITION, positionA );
920 scrollView.Add(actorA);
922 Actor actorB = Actor::New();
923 const Vector3 positionB = Vector3(500.0f, 200.0f, 0.0f);
924 actorB.SetProperty( Actor::Property::POSITION, positionB );
925 scrollView.Add(actorB);
929 scrollView.ScrollTo(actorA, 0.0f);
931 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION );
934 scrollView.ScrollTo(actorB, 0.0f);
936 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION );
938 scrollView.ScrollTo(actorA);
939 Wait(application, RENDER_DELAY_SCROLL);
940 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION );
942 scrollView.ScrollTo(actorB);
943 Wait(application, RENDER_DELAY_SCROLL);
944 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION );
948 int UtcDaliToolkitScrollViewScrollToSnapPointP(void)
950 ToolkitTestApplication application;
951 tet_infoline(" UtcDaliToolkitScrollViewScrollToSnapPointP");
953 ScrollView scrollView = ScrollView::New();
954 application.GetScene().Add( scrollView );
955 RulerPtr rulerX = new FixedRuler( 100.0f );
956 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
957 RulerPtr rulerY = new FixedRuler( 100.0f );
958 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
960 scrollView.SetRulerX( rulerX );
961 scrollView.SetRulerY( rulerY );
963 scrollView.ScrollTo( Vector2(120.0f, 190.0f), 0.0f );
965 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(120.0f, 190.0f), TEST_LOCATION );
967 scrollView.ScrollToSnapPoint();
969 Wait(application, RENDER_DELAY_SCROLL);
970 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 200.0f), TEST_LOCATION );
974 int UtcDaliToolkitScrollViewSetScrollUpdateDistanceP(void)
976 ToolkitTestApplication application;
977 tet_infoline(" UtcDaliToolkitScrollViewSetScrollUpdateDistanceP");
979 ScrollView scrollView = ScrollView::New();
981 scrollView.SetScrollUpdateDistance(0);
982 DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 0, TEST_LOCATION);
983 scrollView.SetScrollUpdateDistance(10);
984 DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 10, TEST_LOCATION);
985 scrollView.SetScrollUpdateDistance(1000);
986 DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 1000, TEST_LOCATION);
990 int UtcDaliToolkitScrollViewSetWrapModeP(void)
992 ToolkitTestApplication application;
993 tet_infoline(" UtcDaliToolkitScrollViewSetWrapModeP");
995 ScrollView scrollView = ScrollView::New();
996 application.GetScene().Add( scrollView );
998 Actor actor = Actor::New();
999 scrollView.Add( actor );
1001 // Position rulers. 4x4 grid.
1002 RulerPtr rulerX = new FixedRuler(50.0f);
1003 RulerPtr rulerY = new FixedRuler(50.0f);
1004 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, false) );
1005 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, false) );
1006 scrollView.SetRulerX(rulerX);
1007 scrollView.SetRulerY(rulerY);
1009 scrollView.SetWrapMode(false);
1010 scrollView.ScrollTo(Vector2(225.0f, 125.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
1012 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 17, TEST_LOCATION );
1014 scrollView.SetWrapMode(true);
1015 scrollView.ScrollTo(Vector2(230.0f, 130.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
1017 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 13, TEST_LOCATION );
1021 int UtcDaliToolkitScrollViewActorAutoSnap(void)
1023 ToolkitTestApplication application;
1024 tet_infoline(" UtcDaliToolkitScrollViewActorAutoSnap");
1026 ScrollView scrollView = ScrollView::New();
1027 application.GetScene().Add( scrollView );
1030 RulerPtr rulerX = new DefaultRuler();
1031 RulerPtr rulerY = new DefaultRuler();
1032 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1033 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1034 scrollView.SetRulerX(rulerX);
1035 scrollView.SetRulerY(rulerY);
1037 const Vector3 aPosition = Vector3(200.0f, 50.0f, 0.0f);
1038 Actor a = Actor::New();
1040 a.SetProperty( Actor::Property::POSITION, aPosition );
1042 const Vector3 bPosition = Vector3(600.0f, 600.0f, 0.0f);
1043 Actor b = Actor::New();
1045 b.SetProperty( Actor::Property::POSITION, bPosition );
1047 // Goto a random position, and execute snap (should not move)
1048 Vector2 targetScroll = Vector2(500.0f, 500.0f);
1049 scrollView.ScrollTo(targetScroll, 0.0f);
1051 scrollView.ScrollToSnapPoint();
1052 Wait(application, RENDER_DELAY_SCROLL);
1053 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), targetScroll, TEST_LOCATION );
1055 // Enable ActorAutoSnap, and now try snapping.
1056 scrollView.SetActorAutoSnap(true);
1057 scrollView.ScrollToSnapPoint();
1058 Wait(application, RENDER_DELAY_SCROLL);
1059 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), bPosition.GetVectorXY(), TEST_LOCATION );
1061 scrollView.ScrollTo(Vector2(0.0f, 0.0f), 0.0f);
1063 scrollView.ScrollToSnapPoint();
1064 Wait(application, RENDER_DELAY_SCROLL);
1065 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), aPosition.GetVectorXY(), TEST_LOCATION );
1069 int UtcDaliToolkitScrollViewSignalsStartComplete(void)
1071 ToolkitTestApplication application;
1072 tet_infoline(" UtcDaliToolkitScrollViewSignalsStartComplete");
1074 gOnScrollStartCalled = false;
1075 gOnScrollCompleteCalled = false;
1077 ScrollView scrollView = ScrollView::New();
1078 application.GetScene().Add( scrollView );
1081 RulerPtr rulerX = new DefaultRuler();
1082 RulerPtr rulerY = new DefaultRuler();
1083 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1084 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1085 scrollView.SetRulerX(rulerX);
1086 scrollView.SetRulerY(rulerY);
1087 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1088 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1089 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1090 scrollView.ScrollTo( Vector2(100.0f, 100.0f) );
1091 Wait(application, RENDER_DELAY_SCROLL);
1093 DALI_TEST_CHECK(gOnScrollStartCalled);
1094 DALI_TEST_CHECK(gOnScrollCompleteCalled);
1098 int UtcDaliToolkitScrollViewSignalsUpdate01(void)
1100 ToolkitTestApplication application;
1101 tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate");
1103 gOnScrollStartCalled = false;
1104 gOnScrollUpdateCalled = false;
1105 gOnScrollCompleteCalled = false;
1107 ScrollView scrollView = ScrollView::New();
1108 application.GetScene().Add( scrollView );
1109 Vector2 stageSize = application.GetScene().GetSize();
1110 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1111 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1112 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1115 RulerPtr rulerX = new DefaultRuler();
1116 RulerPtr rulerY = new DefaultRuler();
1117 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1118 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1119 scrollView.SetRulerX(rulerX);
1120 scrollView.SetRulerY(rulerY);
1121 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1122 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1123 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1125 Actor image = Actor::New();
1126 image.SetProperty( Actor::Property::SIZE, stageSize);
1127 image.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1128 image.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1129 scrollView.Add(image);
1133 // Do a pan starting from 100,100 and moving down diagonally.
1134 Vector2 pos(100.0f, 100.0f);
1135 uint32_t time = 100;
1136 TestStartPan( application, pos, pos, time );
1139 Wait(application, 100);
1141 for(int i = 0;i<20;i++)
1143 time += RENDER_FRAME_INTERVAL;
1144 TestMovePan( application, pos, time);
1150 time += RENDER_FRAME_INTERVAL;
1151 TestEndPan(application, pos, time );
1152 Wait(application, RENDER_DELAY_SCROLL);
1154 DALI_TEST_CHECK(gOnScrollStartCalled);
1155 DALI_TEST_CHECK(gOnScrollUpdateCalled);
1156 DALI_TEST_CHECK(gOnScrollCompleteCalled);
1160 int UtcDaliToolkitScrollViewSignalsUpdate02(void)
1162 ToolkitTestApplication application;
1163 tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate");
1165 gOnScrollStartCalled = false;
1166 gOnScrollUpdateCalled = false;
1167 gOnScrollCompleteCalled = false;
1169 ScrollView scrollView = ScrollView::New();
1170 application.GetScene().Add( scrollView );
1171 Vector2 stageSize = application.GetScene().GetSize();
1172 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1173 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1174 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1177 RulerPtr rulerX = new DefaultRuler();
1178 RulerPtr rulerY = new DefaultRuler();
1179 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1180 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1181 scrollView.SetRulerX(rulerX);
1182 scrollView.SetRulerY(rulerY);
1183 Dali::ConnectionTracker tracker;
1184 bool scrollStarted=false;
1185 bool scrollUpdated=false;
1186 bool scrollCompleted=false;
1187 DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollStarted", CallbackFunctor(&scrollStarted) ));
1188 DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollUpdated", CallbackFunctor(&scrollUpdated) ));
1189 DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollCompleted", CallbackFunctor(&scrollCompleted) ));
1191 Actor image = Actor::New();
1192 image.SetProperty( Actor::Property::SIZE, stageSize);
1193 image.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1194 image.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1195 scrollView.Add(image);
1199 // Do a pan starting from 100,100 and moving down diagonally.
1200 Vector2 pos(100.0f, 100.0f);
1201 uint32_t time = 100;
1202 TestStartPan( application, pos, pos, time );
1205 Wait(application, 100);
1207 for(int i = 0;i<20;i++)
1209 time += RENDER_FRAME_INTERVAL;
1210 TestMovePan( application, pos, time);
1216 time += RENDER_FRAME_INTERVAL;
1217 TestEndPan(application, pos, time );
1218 Wait(application, RENDER_DELAY_SCROLL);
1220 DALI_TEST_CHECK(scrollStarted);
1221 DALI_TEST_CHECK(scrollUpdated);
1222 DALI_TEST_CHECK(scrollCompleted);
1224 application.GetScene().Remove( scrollView );
1229 int UtcDaliToolkitScrollViewScrollSensitive(void)
1231 ToolkitTestApplication application;
1232 tet_infoline(" UtcDaliToolkitScrollViewScrollSensitive");
1234 // Set up a scrollView...
1235 ScrollView scrollView = ScrollView::New();
1236 scrollView.SetOvershootEnabled(true);
1237 application.GetScene().Add( scrollView );
1238 Vector2 stageSize = application.GetScene().GetSize();
1239 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1240 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1241 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1244 RulerPtr rulerX = new DefaultRuler();
1245 RulerPtr rulerY = new DefaultRuler();
1246 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1247 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1248 scrollView.SetRulerX(rulerX);
1249 scrollView.SetRulerY(rulerY);
1250 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1251 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1252 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1253 scrollView.SnapStartedSignal().Connect( &OnSnapStart );
1255 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1257 time +=Wait(application);
1259 // First try insensitive swipe.
1260 scrollView.SetScrollSensitive(false);
1261 PerformGestureSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, time, true);
1263 DALI_TEST_CHECK( !gOnScrollStartCalled );
1264 DALI_TEST_CHECK( !gOnScrollCompleteCalled );
1265 DALI_TEST_CHECK( !gOnSnapStartCalled );
1267 // Second try sensitive swipe.
1268 scrollView.SetScrollSensitive(true);
1269 PerformGestureSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, time, true);
1271 DALI_TEST_CHECK( gOnScrollStartCalled );
1272 DALI_TEST_CHECK( gOnScrollCompleteCalled );
1273 DALI_TEST_CHECK( gOnSnapStartCalled );
1277 int UtcDaliToolkitScrollViewAxisAutoLock(void)
1279 ToolkitTestApplication application;
1280 tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLock");
1282 // Set up a scrollView...
1283 ScrollView scrollView = ScrollView::New();
1284 application.GetScene().Add( scrollView );
1285 Vector2 stageSize = application.GetScene().GetSize();
1286 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1287 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1288 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1291 RulerPtr rulerX = new DefaultRuler();
1292 RulerPtr rulerY = new DefaultRuler();
1293 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1294 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1295 scrollView.SetRulerX(rulerX);
1296 scrollView.SetRulerY(rulerY);
1297 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1298 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1299 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1302 scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
1304 time += Wait(application);
1306 Vector2 startPosition = scrollView.GetCurrentScrollPosition();
1307 Vector2 dir(5.0f, 1.0f);
1309 // PerformGestureSwipe not used as a different initial direction was required
1311 Vector2 pos( CLAMP_TOUCH_START + Vector2(15.0f, 3.0f) );
1313 TestStartPan( application, CLAMP_TOUCH_START, pos, time );
1315 time += Wait(application);
1317 for( int i = 0; i<47; i++ )
1320 TestMovePan( application, pos, time );
1321 time += Wait( application );
1326 TestEndPan( application, pos, time );
1328 const Vector2 positionAfterNormal = scrollView.GetCurrentScrollPosition();
1331 scrollView.SetAxisAutoLock(true);
1332 DALI_TEST_CHECK(scrollView.GetAxisAutoLock());
1334 scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
1335 time += Wait(application);
1337 Vector2 pos2( CLAMP_TOUCH_START + Vector2(15.0f, 3.0f) );
1339 TestStartPan( application, CLAMP_TOUCH_START, pos2, time );
1341 time += Wait(application);
1343 for( int i = 0; i<47; i++ )
1346 TestMovePan( application, pos2, time );
1347 time += Wait( application );
1352 TestEndPan( application, pos2, time );
1354 const Vector2 positionAfterAutoLock = scrollView.GetCurrentScrollPosition();
1356 // compare how much the Y position has deviated for normal and autolock.
1357 const float devianceNormal = fabsf(startPosition.y - positionAfterNormal.y);
1358 const float devianceAutoLock = fabsf(startPosition.y - positionAfterAutoLock.y);
1360 // in auto-lock it should be a mostly horizontal pan (thus deviance should be much lower)
1361 DALI_TEST_CHECK(devianceAutoLock < devianceNormal);
1363 scrollView.SetAxisAutoLock(false);
1364 DALI_TEST_CHECK(!scrollView.GetAxisAutoLock());
1368 int UtcDaliToolkitScrollViewAxisAutoLockGradient(void)
1370 ToolkitTestApplication application;
1371 tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLockGradient");
1373 // Set up a scrollView...
1374 ScrollView scrollView = ScrollView::New();
1375 scrollView.SetAxisAutoLockGradient(0.5f);
1376 DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 0.5f, TEST_LOCATION);
1377 scrollView.SetAxisAutoLockGradient(1.0f);
1378 DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 1.0f, TEST_LOCATION);
1382 int UtcDaliToolkitScrollViewConstraints(void)
1384 ToolkitTestApplication application;
1385 tet_infoline(" UtcDaliToolkitScrollViewConstraints");
1387 // Set up a scrollView...
1388 ScrollView scrollView = ScrollView::New();
1389 application.GetScene().Add( scrollView );
1390 Vector2 stageSize = application.GetScene().GetSize();
1391 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1392 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1393 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1396 RulerPtr rulerX = new DefaultRuler();
1397 RulerPtr rulerY = new DefaultRuler();
1398 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1399 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1400 scrollView.SetRulerX(rulerX);
1401 scrollView.SetRulerY(rulerY);
1403 // Add an Actor to ScrollView,
1404 // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1405 gConstraintResult = Vector3::ZERO;
1406 Actor a = Actor::New();
1408 a.SetProperty( Actor::Property::POSITION, TEST_ACTOR_POSITION);
1411 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1412 constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
1413 constraint.SetRemoveAction(Constraint::Discard);
1414 scrollView.ApplyConstraintToChildren(constraint);
1417 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1419 gConstraintResult = Vector3::ZERO;
1420 scrollView.RemoveConstraintsFromChildren();
1423 DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
1427 int UtcDaliToolkitScrollViewBind(void)
1429 ToolkitTestApplication application;
1430 tet_infoline(" UtcDaliToolkitScrollViewBind");
1432 // Set up a scrollView...
1433 ScrollView scrollView = ScrollView::New();
1434 application.GetScene().Add( scrollView );
1435 Vector2 stageSize = application.GetScene().GetSize();
1436 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1437 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1438 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1441 RulerPtr rulerX = new DefaultRuler();
1442 RulerPtr rulerY = new DefaultRuler();
1443 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1444 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1445 scrollView.SetRulerX(rulerX);
1446 scrollView.SetRulerY(rulerY);
1448 // Add an Actor to ScrollView,
1449 // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1451 gConstraintResult = Vector3::ZERO;
1452 Actor a = Actor::New();
1454 a.SetProperty( Actor::Property::POSITION, TEST_ACTOR_POSITION);
1457 // apply this constraint to scrollview
1458 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1459 constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
1460 constraint.SetRemoveAction(Constraint::Discard);
1461 scrollView.ApplyConstraintToChildren(constraint);
1465 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1468 gConstraintResult = Vector3::ZERO;
1469 scrollView.UnbindActor( a );
1471 DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
1474 gConstraintResult = Vector3::ZERO;
1475 scrollView.BindActor( a );
1477 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1481 int UtcDaliToolkitScrollViewOvershoot(void)
1483 ToolkitTestApplication application;
1484 tet_infoline(" UtcDaliToolkitScrollViewOvershoot");
1486 // Set up a scrollView...
1487 ScrollView scrollView = ScrollView::New();
1488 scrollView.SetOvershootEnabled(true);
1491 Vector2 overshootSize = Vector2(100.0f,100.0f);
1492 scrollView.SetProperty( Scrollable::Property::OVERSHOOT_SIZE, overshootSize );
1493 DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_SIZE).Get<Vector2>(), overshootSize, TEST_LOCATION );
1495 application.GetScene().Add( scrollView );
1496 Vector2 stageSize = application.GetScene().GetSize();
1497 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1498 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1499 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1502 RulerPtr rulerX = new DefaultRuler();
1503 RulerPtr rulerY = new DefaultRuler();
1504 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1505 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1506 scrollView.SetRulerX(rulerX);
1507 scrollView.SetRulerY(rulerY);
1508 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1509 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1510 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1512 scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1513 time += Wait(application);
1515 // 1. Scroll page in NW (-500,-500 pixels), then inspect overshoot. (don't release touch)
1516 Vector2 currentPos = Vector2(100.0f, 100.0f);
1517 currentPos = PerformGestureSwipe(application, currentPos, Vector2(5.0f, 5.0f), 100, time, false);
1518 float overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1519 float overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1520 Vector2 positionValue = scrollView.GetCurrentProperty< Vector2 >( ScrollView::Property::SCROLL_POSITION );
1521 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1522 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1523 DALI_TEST_EQUALS(positionValue, Vector2::ZERO, TEST_LOCATION);
1525 float timeToReachOrigin;
1527 // Now release touch. Overshoot should snap back to zero.
1528 TestEndPan(application, currentPos, time);
1530 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1532 float minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1533 float maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1535 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1536 (timeToReachOrigin < maxTimeToReachOrigin) );
1538 // 2. Repeat Scroll, but this time change overshoot snap duration to shorter time
1539 scrollView.SetSnapOvershootDuration(TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION);
1541 currentPos = PerformGestureSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, time, false);
1542 // Now release touch. Overshoot should snap back to zero.
1543 TestEndPan(application, currentPos, time);
1544 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1546 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1547 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1549 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1550 (timeToReachOrigin < maxTimeToReachOrigin) );
1552 // 3. Repeat Scroll, but this time change overshoot snap duration to longer time.
1553 scrollView.SetSnapOvershootDuration(TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION);
1555 currentPos = PerformGestureSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, time, false);
1556 // Now release touch. Overshoot should snap back to zero.
1557 TestEndPan(application, currentPos, time);
1558 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1560 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1561 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1563 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1564 (timeToReachOrigin < maxTimeToReachOrigin) );
1566 // 4. Repeat Scroll, but this time change overshoot function.
1567 scrollView.SetSnapOvershootDuration(TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION);
1568 scrollView.SetSnapOvershootAlphaFunction(TestAlphaFunction);
1570 currentPos = PerformGestureSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, time, false);
1571 // Now release touch. Overshoot should snap back to zero.
1572 TestEndPan(application, currentPos, time);
1573 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1575 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1576 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1578 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1579 (timeToReachOrigin < maxTimeToReachOrigin) );
1583 int UtcDaliToolkitScrollViewSnapAlphaFunction(void)
1585 ToolkitTestApplication application;
1586 tet_infoline(" UtcDaliToolkitScrollViewSnapAlphaFunction");
1588 // Set up a scrollView...
1589 ScrollView scrollView = ScrollView::New();
1590 scrollView.SetScrollSnapAlphaFunction( AlphaFunction::EASE_IN );
1591 DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_IN );
1592 scrollView.SetScrollSnapAlphaFunction( AlphaFunction::EASE_OUT );
1593 DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_OUT );
1595 scrollView.SetScrollFlickAlphaFunction( AlphaFunction::BOUNCE );
1596 DALI_TEST_CHECK( scrollView.GetScrollFlickAlphaFunction().GetBuiltinFunction() == AlphaFunction::BOUNCE );
1601 int UtcDaliToolkitScrollViewSnapDuration(void)
1603 ToolkitTestApplication application;
1604 tet_infoline(" UtcDaliToolkitScrollViewSnapDuration");
1606 // Set up a scrollView...
1607 ScrollView scrollView = ScrollView::New();
1608 scrollView.SetScrollSnapDuration( 1.0f );
1609 DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 1.0f, TEST_LOCATION );
1610 scrollView.SetScrollSnapDuration( 0.5f );
1611 DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 0.5f, TEST_LOCATION );
1613 scrollView.SetScrollFlickDuration( 2.0f );
1614 DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 2.0f, TEST_LOCATION );
1615 scrollView.SetScrollFlickDuration( 1.5f );
1616 DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 1.5f, TEST_LOCATION );
1620 int UtcDaliToolkitScrollViewSnapStartedSignalP(void)
1622 ToolkitTestApplication application;
1623 tet_infoline(" UtcDaliToolkitScrollViewSnapStartedSignalP");
1625 // Set up a scrollView...
1626 ScrollView scrollView = ScrollView::New();
1627 application.GetScene().Add( scrollView );
1628 Vector2 stageSize = application.GetScene().GetSize();
1629 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1630 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1631 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1634 RulerPtr rulerX = new DefaultRuler();
1635 RulerPtr rulerY = new DefaultRuler();
1636 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1637 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1638 scrollView.SetRulerX(rulerX);
1639 scrollView.SetRulerY(rulerY);
1640 scrollView.SnapStartedSignal().Connect( &OnSnapStart );
1642 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1644 time += Wait(application);
1646 // First try a snap.
1647 PerformGestureSwipe(application, CLAMP_TOUCH_START, Vector2(0.5f, 0.0f), 60, time, true);
1649 DALI_TEST_CHECK( gOnSnapStartCalled );
1650 DALI_TEST_CHECK( gLastSnapType == Toolkit::Snap );
1652 // Second try a swipe.
1653 PerformGestureSwipe(application, CLAMP_TOUCH_START, Vector2(20.0f, 0.0f), 60, time, true);
1655 DALI_TEST_CHECK( gOnSnapStartCalled );
1656 DALI_TEST_CHECK( gLastSnapType == Toolkit::Flick );
1660 int UtcDaliToolkitScrollViewGetCurrentPageP(void)
1662 ToolkitTestApplication application;
1663 tet_infoline(" UtcDaliToolkitScrollViewGetCurrentPageP");
1665 ScrollView scrollView = ScrollView::New();
1666 application.GetScene().Add( scrollView );
1667 RulerPtr rulerX = new FixedRuler( 100.0f );
1668 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1669 RulerPtr rulerY = new FixedRuler( 100.0f );
1670 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1672 scrollView.SetRulerX( rulerX );
1673 scrollView.SetRulerY( rulerY );
1675 scrollView.ScrollTo( 15 );
1676 Wait(application, RENDER_DELAY_SCROLL);
1677 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION );
1679 scrollView.ScrollTo( 3 );
1680 Wait(application, RENDER_DELAY_SCROLL);
1681 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION );
1683 scrollView.ScrollTo( 9 );
1684 Wait(application, RENDER_DELAY_SCROLL);
1685 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION );
1690 int UtcDaliToolkitScrollViewSetMaxOvershootP(void)
1692 ToolkitTestApplication application;
1693 tet_infoline(" UtcDaliToolkitScrollViewSetMaxOvershootP");
1695 // Set up a scrollView...
1696 ScrollView scrollView = ScrollView::New();
1697 application.GetScene().Add( scrollView );
1698 Vector2 stageSize = application.GetScene().GetSize();
1699 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1700 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1701 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1704 RulerPtr rulerX = new DefaultRuler();
1705 RulerPtr rulerY = new DefaultRuler();
1706 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1707 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1708 scrollView.SetRulerX(rulerX);
1709 scrollView.SetRulerY(rulerY);
1711 // Set the max overshoot to be 50 pixels in both X axis and Y axis
1712 scrollView.SetMaxOvershoot(50.0f, 50.0f);
1714 scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1716 time += Wait(application);
1718 // Scroll page in NW (-20,-20 pixels), then check that overshoot should be 0. (don't release touch)
1719 Vector2 currentPos = PerformGestureSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 10, time, false);
1720 float overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1721 float overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1722 DALI_TEST_EQUALS(overshootXValue, 0.0f, TEST_LOCATION);
1723 DALI_TEST_EQUALS(overshootYValue, 0.0f, TEST_LOCATION);
1725 time += Wait(application);
1726 // Scroll page further in NW (-105,-105 pixels), then check that overshoot should be around 0.5. (don't release touch)
1727 for(int i = 0; i<106; i++)
1729 TestMovePan(application, currentPos, time );
1730 currentPos += Vector2(1.0f, 1.0f);
1731 time += Wait(application);
1734 overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1735 overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1736 // The overshoot value is a 0.0f - 1.0f ranged value of the amount overshot related to the maximum overshoot.
1737 // EG. If we move 105, max overshoot is 50, then we overshot 50 / 105.
1738 float correctOvershootValue = 0.508f; // This was measured and then set as the limit
1739 DALI_TEST_EQUALS( overshootXValue, correctOvershootValue, 0.001f, TEST_LOCATION );
1740 DALI_TEST_EQUALS( overshootYValue, correctOvershootValue, 0.001f, TEST_LOCATION );
1742 // Scroll page further in NW (-25,-25 pixels), then check that overshoot should be now 1.0. (don't release touch)
1743 for(int i = 0;i<25;i++)
1745 TestMovePan(application, currentPos, time );
1746 currentPos += Vector2(1.0f, 1.0f); // Move in this direction
1747 time += Wait(application);
1750 overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1751 overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1752 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1753 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1755 // Change the max overshoot to be 250 pixels in both X axis and Y axis
1756 scrollView.SetMaxOvershoot(250.0f, 250.0f);
1757 time += Wait(application);
1759 // Check that overshoot should be now around 0.8.
1760 overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1761 overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1762 DALI_TEST_CHECK(overshootXValue > 0.79f && overshootXValue < 0.81f);
1763 DALI_TEST_CHECK(overshootYValue > 0.79f && overshootYValue < 0.81f);
1765 // Scroll page further in NW (-50,-50 pixels), then check that overshoot should be now 1.0. (don't release touch)
1766 for(int i = 0;i<50;i++)
1768 TestMovePan(application, currentPos, time );
1769 currentPos += Vector2(1.0f, 1.0f); // Move in this direction
1770 time += Wait(application);
1773 overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1774 overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1775 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1776 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1781 int UtcDaliToolkitScrollViewSetScrollingDirectionP(void)
1783 ToolkitTestApplication application;
1784 tet_infoline(" UtcDaliToolkitScrollViewSetScrollingDirectionP");
1786 // Set up a scrollView...
1787 ScrollView scrollView = ScrollView::New();
1788 application.GetScene().Add( scrollView );
1789 Vector2 stageSize = application.GetScene().GetSize();
1790 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1791 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1792 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1794 Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1796 scrollView.ScrollTo(START_POSITION, 0.0f);
1798 time += Wait(application);
1800 // Try a vertical swipe.
1801 // PerformGestureSwipe not used as a different initial direction was required
1803 Vector2 pos( START_POSITION + Vector2(0.0f, 15.0f) );
1804 TestStartPan( application, START_POSITION, pos, time );
1805 time += Wait(application);
1806 for( int i = 0; i<45; i++ )
1808 pos += Vector2(0.0f, 1.0f);
1809 TestMovePan( application, pos, time );
1810 time += Wait( application );
1812 pos += Vector2(0.0f, 1.0f);
1813 TestEndPan( application, pos, time );
1814 time += Wait( application );
1816 // Take into account resampling done when prediction is off.
1817 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1819 scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1821 scrollView.ScrollTo(START_POSITION, 0.0f);
1822 time += Wait(application);
1824 // Try a vertical swipe.
1825 // PerformGestureSwipe not used as a different initial direction was required
1826 pos = ( START_POSITION + Vector2(0.0f, 15.0f) );
1827 TestStartPan( application, START_POSITION, pos, time );
1828 time += Wait(application);
1829 for( int i = 0; i<45; i++ )
1831 pos += Vector2(0.0f, 1.0f);
1832 TestMovePan( application, pos, time );
1833 time += Wait( application );
1835 pos += Vector2(0.0f, 1.0f);
1836 TestEndPan( application, pos, time );
1837 time += Wait( application );
1839 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1841 scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1843 scrollView.ScrollTo(START_POSITION, 0.0f);
1845 time += Wait(application);
1847 // Try a vertical swipe.
1848 // PerformGestureSwipe not used as a different initial direction was required
1849 pos = ( START_POSITION + Vector2(0.0f, 15.0f) );
1850 TestStartPan( application, START_POSITION, pos, time );
1851 time += Wait(application);
1852 for( int i = 0; i<45; i++ )
1854 pos += Vector2(0.0f, 1.0f);
1855 TestMovePan( application, pos, time );
1856 time += Wait( application );
1858 pos += Vector2(0.0f, 1.0f);
1859 TestEndPan( application, pos, time );
1860 time += Wait( application );
1862 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1867 int UtcDaliToolkitScrollViewRemoveScrollingDirectionP(void)
1869 ToolkitTestApplication application;
1870 tet_infoline(" UtcDaliToolkitScrollViewRemoveScrollingDirectionP");
1872 // Set up a scrollView...
1873 ScrollView scrollView = ScrollView::New();
1874 application.GetScene().Add( scrollView );
1875 Vector2 stageSize = application.GetScene().GetSize();
1876 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1877 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1878 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1880 Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1883 scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1885 scrollView.ScrollTo(START_POSITION, 0.0f);
1887 time += Wait(application);
1889 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION );
1891 // Try a vertical swipe.
1892 // PerformGestureSwipe not used as a different initial direction was required
1893 Vector2 pos( START_POSITION + Vector2(0.0f, 15.0f) );
1894 TestStartPan( application, START_POSITION, pos, time );
1895 time += Wait(application);
1896 for( int i = 0; i<45; i++ )
1898 pos += Vector2(0.0f, 1.0f);
1899 TestMovePan( application, pos, time );
1900 time += Wait( application );
1902 pos += Vector2(0.0f, 1.0f);
1903 TestEndPan( application, pos, time );
1904 time += Wait( application );
1906 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1908 scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1909 // When the horizontal direction is removed, there are no directions set and therefore all will work
1910 scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_HORIZONTAL);
1912 time += Wait(application);
1913 // Try a vertical swipe.
1914 Vector2 pos2( pos + Vector2(0.0f, 15.0f) );
1915 TestStartPan( application, pos, pos2, time );
1916 time += Wait(application);
1917 for( int i = 0; i<45; i++ )
1919 pos2 += Vector2(0.0f, 1.0f);
1920 TestMovePan( application, pos2, time );
1921 time += Wait( application );
1923 pos2 += Vector2(0.0f, 1.0f);
1924 TestEndPan( application, pos2, time );
1926 // The previous scroll should not have had any effect
1927 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1932 int UtcDaliToolkitScrollViewSetRulerXP(void)
1934 ToolkitTestApplication application;
1935 tet_infoline(" UtcDaliToolkitScrollViewSetRulerXP");
1937 ScrollView scrollView = ScrollView::New();
1938 application.GetScene().Add( scrollView );
1939 RulerPtr rulerX = new FixedRuler( 100.0f );
1940 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1942 scrollView.SetRulerX( rulerX );
1944 scrollView.ScrollTo( 1, 0.0f );
1946 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION );
1948 RulerPtr newRulerX = new FixedRuler( 200.0f );
1949 newRulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1951 scrollView.SetRulerX( newRulerX );
1953 scrollView.ScrollTo( 1, 0.0f );
1955 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 0.0f), TEST_LOCATION );
1960 int UtcDaliToolkitScrollViewSetRulerYP(void)
1962 ToolkitTestApplication application;
1963 tet_infoline(" UtcDaliToolkitScrollViewSetRulerYP");
1965 ScrollView scrollView = ScrollView::New();
1966 application.GetScene().Add( scrollView );
1968 RulerPtr rulerY = new FixedRuler( 200.0f );
1969 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1971 scrollView.SetRulerY( rulerY );
1973 scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f );
1975 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 350.0f), TEST_LOCATION );
1977 RulerPtr newRulerY = new FixedRuler( 100.0f );
1978 newRulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
1979 scrollView.SetRulerY( newRulerY );
1981 scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f );
1983 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 200.0f), TEST_LOCATION );
1988 int UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP(void)
1990 ToolkitTestApplication application;
1991 tet_infoline(" UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP");
1993 ScrollView scrollView = ScrollView::New();
1994 scrollView.SetMinimumSpeedForFlick(25.0f);
1995 DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 25.0f, TEST_LOCATION );
1996 scrollView.SetMinimumSpeedForFlick(60.0f);
1997 DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 60.0f, TEST_LOCATION );
2001 int UtcDaliToolkitScrollViewSetMinimumDistanceForFlickP(void)
2003 ToolkitTestApplication application;
2004 tet_infoline(" UtcDaliToolkitScrollViewSetMinimumDistanceForFlick");
2006 ScrollView scrollView = ScrollView::New();
2008 scrollView.SetMinimumDistanceForFlick(Vector2(30.0f, 15.0f));
2009 DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(30.0f, 15.0f), TEST_LOCATION );
2010 scrollView.SetMinimumDistanceForFlick(Vector2(60.0f, 30.0f));
2011 DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(60.0f, 30.0f), TEST_LOCATION);
2015 int UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP(void)
2017 ToolkitTestApplication application;
2018 tet_infoline(" UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP");
2020 ScrollView scrollView = ScrollView::New();
2021 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
2022 scrollView.SetWheelScrollDistanceStep(Vector2(30.0f, 15.0f));
2023 DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(30.0f, 15.0f), TEST_LOCATION );
2024 scrollView.SetWheelScrollDistanceStep(Vector2(60.0f, 30.0f));
2025 DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(60.0f, 30.0f), TEST_LOCATION);
2029 int UtcDaliToolkitScrollViewApplyEffectP(void)
2031 ToolkitTestApplication application;
2032 tet_infoline(" UtcDaliToolkitScrollViewApplyEffectP");
2034 // Create a ScrollView
2035 ScrollView scrollView = ScrollView::New();
2037 // Create two scroll view effects
2038 Dali::Path path = Dali::Path::New();
2039 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);
2040 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);
2042 // Apply both effects
2043 scrollView.ApplyEffect(effect);
2044 scrollView.ApplyEffect(newEffect);
2046 DALI_TEST_CHECK( true );
2051 int UtcDaliToolkitScrollViewApplyEffectN(void)
2053 ToolkitTestApplication application;
2054 tet_infoline(" UtcDaliToolkitScrollViewApplyEffectN");
2056 // Create a ScrollView
2057 ScrollView scrollView = ScrollView::New();
2059 // Create two scroll view effects
2060 Dali::Path path = Dali::Path::New();
2061 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);
2062 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);
2064 // Apply both effects
2065 scrollView.ApplyEffect(effect);
2066 scrollView.ApplyEffect(newEffect);
2068 // Attempt to apply the same effect again
2071 scrollView.ApplyEffect(newEffect);
2072 tet_result( TET_FAIL );
2074 catch ( DaliException& e )
2076 DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
2082 int UtcDaliToolkitScrollViewRemoveEffectP(void)
2084 ToolkitTestApplication application;
2085 tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectP");
2087 // Create a ScrollView
2088 ScrollView scrollView = ScrollView::New();
2090 // Create two scroll view effects
2091 Dali::Path path = Dali::Path::New();
2092 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);
2093 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);
2095 // Apply both effects
2096 scrollView.ApplyEffect(effect);
2097 scrollView.ApplyEffect(newEffect);
2099 // Remove both effects
2100 scrollView.RemoveEffect(effect);
2101 scrollView.RemoveEffect(newEffect);
2103 DALI_TEST_CHECK( true );
2108 int UtcDaliToolkitScrollViewRemoveEffectN(void)
2110 ToolkitTestApplication application;
2111 tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectN");
2113 // Create a ScrollView
2114 ScrollView scrollView = ScrollView::New();
2116 // Create two scroll view effects
2117 Dali::Path path = Dali::Path::New();
2118 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);
2119 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);
2121 // Apply the first effect
2122 scrollView.ApplyEffect(effect);
2124 // Attempt to remove the second effect which has not been applied to scroll view
2127 scrollView.RemoveEffect(newEffect);
2128 tet_result( TET_FAIL );
2130 catch ( DaliException& e )
2132 DALI_TEST_ASSERT( e, "effectExistedInScrollView", TEST_LOCATION );
2138 int UtcDaliToolkitScrollViewRemoveAllEffectsP(void)
2140 ToolkitTestApplication application;
2141 tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsP");
2143 // Create a ScrollView
2144 ScrollView scrollView = ScrollView::New();
2146 // Create two scroll view effects
2147 Dali::Path path = Dali::Path::New();
2148 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);
2149 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);
2151 // Apply both effects
2152 scrollView.ApplyEffect(effect);
2153 scrollView.ApplyEffect(newEffect);
2155 // Attempt to apply the same first effect again
2158 scrollView.ApplyEffect(effect);
2159 tet_result( TET_FAIL );
2161 catch ( DaliException& e )
2163 DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
2166 // Remove both effects
2167 scrollView.RemoveAllEffects();
2169 // Apply both effects again
2170 scrollView.ApplyEffect(effect);
2171 scrollView.ApplyEffect(newEffect);
2173 DALI_TEST_CHECK( true );
2178 int UtcDaliToolkitScrollViewRemoveAllEffectsN(void)
2180 ToolkitTestApplication application;
2181 tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsN");
2183 // Create a ScrollView
2184 ScrollView scrollView = ScrollView::New();
2186 // Remove effects when there is no effect applied previously
2187 scrollView.RemoveAllEffects();
2189 DALI_TEST_CHECK( true );
2194 int UtcDaliToolkitScrollViewSetOvershootEnabledP(void)
2196 ToolkitTestApplication application;
2197 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEnabledP");
2199 ScrollView scrollView = ScrollView::New();
2201 scrollView.SetOvershootEnabled(true);
2202 DALI_TEST_CHECK(scrollView.IsOvershootEnabled());
2204 scrollView.SetOvershootEnabled(false);
2205 DALI_TEST_CHECK(!scrollView.IsOvershootEnabled());
2210 int UtcDaliToolkitScrollViewSetOvershootEffectColorP(void)
2212 ToolkitTestApplication application;
2213 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEffectColorP");
2215 ScrollView scrollView = ScrollView::New();
2217 scrollView.SetOvershootEffectColor(Dali::Color::RED);
2218 DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::RED, TEST_LOCATION);
2220 scrollView.SetOvershootEffectColor(Dali::Color::YELLOW);
2221 DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::YELLOW, TEST_LOCATION);
2226 int UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP(void)
2228 ToolkitTestApplication application;
2229 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP");
2231 ScrollView scrollView = ScrollView::New();
2233 scrollView.SetOvershootAnimationSpeed(55.0f);
2234 DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 55.0f, TEST_LOCATION);
2236 scrollView.SetOvershootAnimationSpeed(120.0f);
2237 DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 120.0f, TEST_LOCATION);
2242 int UtcDaliToolkitScrollViewGetSet(void)
2244 ToolkitTestApplication application;
2245 tet_infoline(" UtcDaliToolkitScrollViewGetSet");
2246 ScrollView scrollView = ScrollView::New();
2247 scrollView.SetMaxFlickSpeed(0.5f);
2248 DALI_TEST_EQUALS(scrollView.GetMaxFlickSpeed(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
2249 scrollView.SetFrictionCoefficient(0.6f);
2250 DALI_TEST_EQUALS(scrollView.GetFrictionCoefficient(), 0.6f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
2251 scrollView.SetFlickSpeedCoefficient(0.7f);
2252 DALI_TEST_EQUALS(scrollView.GetFlickSpeedCoefficient(), 0.7f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
2256 int UtcDaliToolkitScrollViewRulerDomainConstructorP(void)
2258 ToolkitTestApplication application;
2260 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2261 DALI_TEST_EQUALS( domainX.min, 0.0f, TEST_LOCATION);
2262 DALI_TEST_EQUALS( domainX.max, 200.0f, TEST_LOCATION);
2263 DALI_TEST_EQUALS( domainX.enabled, true, TEST_LOCATION);
2265 RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
2266 DALI_TEST_EQUALS( domainY.min, 100.0f, TEST_LOCATION);
2267 DALI_TEST_EQUALS( domainY.max, 500.0f, TEST_LOCATION);
2268 DALI_TEST_EQUALS( domainY.enabled, false, TEST_LOCATION);
2273 int UtcDaliToolkitScrollViewRulerDomainGetSizeP(void)
2275 ToolkitTestApplication application;
2277 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2278 DALI_TEST_EQUALS( domainX.GetSize(), 200.0f, TEST_LOCATION);
2280 RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
2281 DALI_TEST_EQUALS( domainY.GetSize(), 400.0f, TEST_LOCATION);
2286 int UtcDaliToolkitScrollViewRulerDomainClampP(void)
2288 ToolkitTestApplication application;
2290 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2292 float value = domainX.Clamp(50.0f, 100.0f, 1.0f);
2293 DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
2295 value = domainX.Clamp(300.0f, 20.0f, 1.0f);
2296 DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
2298 value = domainX.Clamp(300.0f, 20.0f, 0.5f);
2299 DALI_TEST_EQUALS( value, 80.0f, TEST_LOCATION);
2301 value = domainX.Clamp(250.0f, 200.0f, 2.0f);
2302 DALI_TEST_EQUALS( value, 200.0f, TEST_LOCATION);
2307 int UtcDaliToolkitScrollViewRulerDomainClampWithStateP(void)
2309 ToolkitTestApplication application;
2311 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2314 float value = domainX.Clamp(50.0f, 100.0f, 1.0f, clamped);
2315 DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
2316 DALI_TEST_EQUALS( clamped, Dali::Toolkit::NotClamped, TEST_LOCATION);
2318 value = domainX.Clamp(-100.0f, 200.0f, 1.0f, clamped);
2319 DALI_TEST_EQUALS( value, 0.0f, TEST_LOCATION);
2320 DALI_TEST_EQUALS( clamped, Dali::Toolkit::ClampedToMin, TEST_LOCATION);
2322 value = domainX.Clamp(300.0f, 20.0f, 1.0f, clamped);
2323 DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
2324 DALI_TEST_EQUALS( clamped, Dali::Toolkit::ClampedToMax, TEST_LOCATION);
2329 int UtcDaliToolkitScrollViewDefaultRulerConstructorP(void)
2331 ToolkitTestApplication application;
2332 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerConstructorP");
2334 RulerPtr defaultRuler = new DefaultRuler();
2335 DALI_TEST_CHECK( defaultRuler );
2340 int UtcDaliToolkitScrollViewDefaultRulerDestructorP(void)
2342 ToolkitTestApplication application;
2343 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerDestructorP");
2345 RulerPtr defaultRuler = new DefaultRuler();
2347 DALI_TEST_CHECK( true );
2351 int UtcDaliToolkitScrollViewFixedRulerConstructorP(void)
2353 ToolkitTestApplication application;
2354 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerConstructorP");
2356 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2357 DALI_TEST_CHECK( fixedRuler );
2359 fixedRuler = new FixedRuler( 0.0f );
2360 DALI_TEST_CHECK( fixedRuler );
2365 int UtcDaliToolkitScrollViewFixedRulerDestructorP(void)
2367 ToolkitTestApplication application;
2368 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerDestructorP");
2370 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2372 DALI_TEST_CHECK( true );
2376 int UtcDaliToolkitScrollViewRulerGetTypeP(void)
2378 ToolkitTestApplication application;
2379 tet_infoline(" UtcDaliToolkitScrollViewRulerGetTypeP");
2381 RulerPtr defaultRuler = new DefaultRuler();
2382 DALI_TEST_CHECK( defaultRuler );
2383 DALI_TEST_EQUALS( defaultRuler->GetType(), Dali::Toolkit::Ruler::Free, TEST_LOCATION);
2385 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2386 DALI_TEST_CHECK( fixedRuler );
2387 DALI_TEST_EQUALS( fixedRuler->GetType(), Dali::Toolkit::Ruler::Fixed, TEST_LOCATION);
2392 int UtcDaliToolkitScrollViewRulerGetExtensionP(void)
2394 ToolkitTestApplication application;
2395 tet_infoline(" UtcDaliToolkitScrollViewRulerGetExtensionP");
2397 RulerPtr defaultRuler = new DefaultRuler();
2398 DALI_TEST_CHECK( defaultRuler );
2399 DALI_TEST_CHECK( !defaultRuler->GetExtension() );
2401 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2402 DALI_TEST_CHECK( fixedRuler );
2403 DALI_TEST_CHECK( !fixedRuler->GetExtension() );
2408 int UtcDaliToolkitScrollViewRulerEnableDisable(void)
2410 ToolkitTestApplication application;
2411 tet_infoline(" UtcDaliToolkitScrollViewRulerEnableDisable");
2413 RulerPtr ruler = new DefaultRuler();
2415 DALI_TEST_CHECK( ruler->IsEnabled() );
2417 DALI_TEST_CHECK( !ruler->IsEnabled() );
2419 DALI_TEST_CHECK( ruler->IsEnabled() );
2423 int UtcDaliToolkitScrollViewRulerDomainEnableDisable(void)
2425 ToolkitTestApplication application;
2426 tet_infoline(" UtcDaliToolkitScrollViewRulerDomainEnableDisable");
2428 RulerPtr ruler = new DefaultRuler();
2429 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
2431 ruler->SetDomain( RulerDomain(0.0f, 100.0f, true) );
2432 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 100.0f, TEST_LOCATION );
2433 DALI_TEST_EQUALS( ruler->Clamp(-200.0f), 0.0f, TEST_LOCATION );
2434 DALI_TEST_EQUALS( ruler->Clamp(200.0f), 100.0f, TEST_LOCATION );
2436 ruler->DisableDomain();
2437 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
2438 DALI_TEST_EQUALS( ruler->Clamp(-200.0f), -200.0f, TEST_LOCATION );
2439 DALI_TEST_EQUALS( ruler->Clamp(200.0f), 200.0f, TEST_LOCATION );
2443 int UtcDaliToolkitScrollViewRulerSnapAndClamp(void)
2445 ToolkitTestApplication application;
2446 tet_infoline(" UtcDaliToolkitScrollViewRulerSnapAndClamp");
2448 RulerPtr ruler = new FixedRuler( 50.0f );
2449 ruler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2451 // default testing. (snap and clamp)
2452 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f), 50.0f, TEST_LOCATION);
2453 DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f), 50.0f, TEST_LOCATION);
2454 DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f), 0.0f, TEST_LOCATION);
2455 DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f), 0.0f, TEST_LOCATION);
2456 DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f), 400.0f, TEST_LOCATION);
2457 DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f), 400.0f, TEST_LOCATION);
2460 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
2461 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.5f), 50.0f, TEST_LOCATION); // No Flick
2462 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
2464 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
2465 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.5f), 0.0f, TEST_LOCATION); // No Flick
2466 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
2469 DALI_TEST_EQUALS( ruler->SnapAndClamp(-10.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (over left boundary)
2470 DALI_TEST_EQUALS( ruler->SnapAndClamp(-5.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (slightly ovr left boundary)
2471 DALI_TEST_EQUALS( ruler->SnapAndClamp(300.0f, 0.5f, 10.0f), 300.0f, TEST_LOCATION); // 10 units long (not over a boundary)
2472 DALI_TEST_EQUALS( ruler->SnapAndClamp(395.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (slightly over right boundary)
2473 DALI_TEST_EQUALS( ruler->SnapAndClamp(500.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (over right boundary)
2476 DALI_TEST_EQUALS( ruler->SnapAndClamp(-100.0f, 0.5f, 0.0f, 2.0f), 0.0f, TEST_LOCATION);
2477 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 2.0f), 50.0f, TEST_LOCATION);
2478 DALI_TEST_EQUALS( ruler->SnapAndClamp(700.0f, 0.5f, 0.0f, 2.0f), 700.0f, TEST_LOCATION);
2479 DALI_TEST_EQUALS( ruler->SnapAndClamp(850.0f, 0.5f, 0.0f, 2.0f), 800.0f, TEST_LOCATION);
2481 // clamp state testing.
2483 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
2484 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2485 DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
2486 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2487 DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
2488 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2489 DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
2490 DALI_TEST_EQUALS( clamped, ClampedToMin, TEST_LOCATION );
2491 DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
2492 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2493 DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
2494 DALI_TEST_EQUALS( clamped, ClampedToMax, TEST_LOCATION );
2498 int UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP(void)
2500 ToolkitTestApplication application;
2501 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP");
2503 RulerPtr rulerNormal = new FixedRuler( 25.0f );
2504 rulerNormal->SetDomain( RulerDomain(10.0f, 90.0f, true) );
2506 unsigned int volume;
2509 position = rulerNormal->GetPositionFromPage(1, volume, true);
2510 DALI_TEST_EQUALS( position, 35.0f, TEST_LOCATION );
2511 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
2513 position = rulerNormal->GetPositionFromPage(2, volume, true);
2514 DALI_TEST_EQUALS( position, 60.0f, TEST_LOCATION );
2515 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
2517 // Disable the ruler
2518 rulerNormal->Disable();
2520 position = rulerNormal->GetPositionFromPage(1, volume, true);
2521 DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
2522 DALI_TEST_EQUALS( volume, 1u, TEST_LOCATION );
2524 position = rulerNormal->GetPositionFromPage(2, volume, true);
2525 DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
2526 DALI_TEST_EQUALS( volume, 2u, TEST_LOCATION );
2531 int UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP(void)
2533 ToolkitTestApplication application;
2534 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP");
2536 RulerPtr defaultRuler = new DefaultRuler();
2537 DALI_TEST_CHECK( defaultRuler );
2538 DALI_TEST_EQUALS( defaultRuler->GetTotalPages(), 1u, TEST_LOCATION);
2543 int UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP(void)
2545 ToolkitTestApplication application;
2546 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP");
2548 RulerPtr defaultRuler = new DefaultRuler();
2549 DALI_TEST_CHECK( defaultRuler );
2550 DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(100.0f, true), 0u, TEST_LOCATION);
2551 DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(-300.0f, false), 0u, TEST_LOCATION);
2556 int UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP(void)
2558 ToolkitTestApplication application;
2559 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP");
2561 RulerPtr defaultRuler = new DefaultRuler();
2562 DALI_TEST_CHECK( defaultRuler );
2564 unsigned int volume;
2565 DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(0, volume, true), 0.0f, TEST_LOCATION);
2566 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
2568 DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(3, volume, false), 0.0f, TEST_LOCATION);
2569 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
2574 int UtcDaliToolkitScrollViewDefaultRulerSnapP(void)
2576 ToolkitTestApplication application;
2577 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerSnapP");
2579 RulerPtr defaultRuler = new DefaultRuler();
2580 DALI_TEST_CHECK( defaultRuler );
2582 DALI_TEST_EQUALS( defaultRuler->Snap(50.0f, 0.5f), 50.0f, TEST_LOCATION);
2583 DALI_TEST_EQUALS( defaultRuler->Snap(-120.0f, 1.0f), -120.0f, TEST_LOCATION);
2588 int UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP(void)
2590 ToolkitTestApplication application;
2591 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP");
2593 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2594 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2596 fixedRuler->Enable();
2597 DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 4u, TEST_LOCATION);
2599 fixedRuler->Disable();
2600 DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 1u, TEST_LOCATION);
2605 int UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP(void)
2607 ToolkitTestApplication application;
2608 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP");
2610 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2611 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2613 fixedRuler->Enable();
2614 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 3u, TEST_LOCATION);
2615 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2616 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 1u, TEST_LOCATION);
2617 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2619 fixedRuler->Disable();
2620 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2621 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
2622 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2623 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2625 // Set domain size to be smaller than the ruler space
2626 fixedRuler->SetDomain( RulerDomain(0.0f, 50.0f, true) );
2628 fixedRuler->Enable();
2629 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2630 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2631 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2632 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2634 fixedRuler->Disable();
2635 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2636 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
2637 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2638 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2643 int UtcDaliToolkitScrollViewFixedRulerSnapP(void)
2645 ToolkitTestApplication application;
2646 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerSnapP");
2648 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2649 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2651 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.0f), -100.0f, TEST_LOCATION);
2652 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.0f), -100.0f, TEST_LOCATION);
2653 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.0f), -200.0f, TEST_LOCATION);
2654 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.0f), -500.0f, TEST_LOCATION);
2655 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.0f), 0.0f, TEST_LOCATION);
2656 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.0f), 0.0f, TEST_LOCATION);
2657 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.0f), 0.0f, TEST_LOCATION);
2658 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.0f), 100.0f, TEST_LOCATION);
2659 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.0f), 100.0f, TEST_LOCATION);
2660 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.0f), 200.0f, TEST_LOCATION);
2661 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.0f), 600.0f, TEST_LOCATION);
2663 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.5f), 0.0f, TEST_LOCATION);
2664 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.5f), -100.0f, TEST_LOCATION);
2665 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.5f), -100.0f, TEST_LOCATION);
2666 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.5f), -500.0f, TEST_LOCATION);
2667 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.5f), 0.0f, TEST_LOCATION);
2668 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.5f), 100.0f, TEST_LOCATION);
2669 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.5f), 100.0f, TEST_LOCATION);
2670 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.5f), 100.0f, TEST_LOCATION);
2671 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.5f), 100.0f, TEST_LOCATION);
2672 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.5f), 300.0f, TEST_LOCATION);
2673 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.5f), 600.0f, TEST_LOCATION);
2675 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 1.0f), 0.0f, TEST_LOCATION);
2676 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 1.0f), 0.0f, TEST_LOCATION);
2677 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 1.0f), -100.0f, TEST_LOCATION);
2678 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 1.0f), -400.0f, TEST_LOCATION);
2679 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 1.0f), 100.0f, TEST_LOCATION);
2680 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 1.0f), 100.0f, TEST_LOCATION);
2681 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 1.0f), 100.0f, TEST_LOCATION);
2682 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 1.0f), 200.0f, TEST_LOCATION);
2683 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 1.0f), 200.0f, TEST_LOCATION);
2684 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 1.0f), 300.0f, TEST_LOCATION);
2685 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 1.0f), 700.0f, TEST_LOCATION);
2690 int UtcDaliToolkitScrollViewConstraintsMove(void)
2692 ToolkitTestApplication application;
2693 tet_infoline(" UtcDaliToolkitScrollViewConstraintsMove");
2695 // Set up a scrollView...
2696 ScrollView scrollView = ScrollView::New();
2697 application.GetScene().Add( scrollView );
2698 Vector2 stageSize = application.GetScene().GetSize();
2699 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
2700 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
2701 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2704 RulerPtr rulerX = new DefaultRuler();
2705 RulerPtr rulerY = new DefaultRuler();
2706 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
2707 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
2708 scrollView.SetRulerX(rulerX);
2709 scrollView.SetRulerY(rulerY);
2711 // Add an Actor to ScrollView,
2712 Actor a = Actor::New();
2714 a.SetProperty( Actor::Property::POSITION, TEST_ACTOR_POSITION);
2717 const Vector2 target = Vector2(100.0f, 100.0f);
2718 const Vector2 target2 = Vector2(200.0f, 200.0f);
2720 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, MoveActorConstraint );
2721 constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
2722 constraint.SetRemoveAction(Constraint::Discard);
2723 scrollView.ApplyConstraintToChildren(constraint);
2725 scrollView.ScrollTo( target, 0.0f );
2727 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
2728 scrollView.ScrollTo( target2 );
2729 Wait(application, RENDER_DELAY_SCROLL);
2730 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
2735 int UtcDaliToolkitScrollViewConstraintsWrap(void)
2737 ToolkitTestApplication application;
2738 tet_infoline(" UtcDaliToolkitScrollViewConstraintsWrap");
2740 // Set up a scrollView...
2741 ScrollView scrollView = ScrollView::New();
2742 application.GetScene().Add( scrollView );
2743 Vector2 stageSize = application.GetScene().GetSize();
2744 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
2745 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
2746 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2749 RulerPtr rulerX = new DefaultRuler();
2750 RulerPtr rulerY = new DefaultRuler();
2751 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
2752 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
2753 scrollView.SetRulerX(rulerX);
2754 scrollView.SetRulerY(rulerY);
2756 // Add an Actor to ScrollView,
2757 Actor a = Actor::New();
2759 a.SetProperty( Actor::Property::POSITION, TEST_ACTOR_POSITION);
2762 const Vector2 target = Vector2(100.0f, 100.0f);
2763 const Vector2 target2 = Vector2(200.0f, 200.0f);
2765 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, WrapActorConstraint );
2766 constraint.AddSource( LocalSource( Actor::Property::SCALE ) );
2767 constraint.AddSource( LocalSource( Actor::Property::ANCHOR_POINT ) );
2768 constraint.AddSource( LocalSource( Actor::Property::SIZE ) );
2769 constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
2770 constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
2771 constraint.AddSource( Source( scrollView, Toolkit::ScrollView::Property::WRAP ) );
2772 constraint.SetRemoveAction(Constraint::Discard);
2773 scrollView.ApplyConstraintToChildren(constraint);
2775 scrollView.ScrollTo( target, 0.0f );
2777 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
2778 scrollView.ScrollTo( target2 );
2779 Wait(application, RENDER_DELAY_SCROLL);
2780 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
2782 scrollView.Remove(a);
2788 // Non-API test (so no P or N variant).
2789 int UtcDaliToolkitScrollViewGesturePageLimit(void)
2791 ToolkitTestApplication application;
2792 tet_infoline( " UtcDaliToolkitScrollViewGesturePageLimit" );
2794 // Set up a scrollView.
2795 ScrollView scrollView = ScrollView::New();
2797 // Do not rely on stage size for UTC tests.
2798 Vector2 viewPageSize( 720.0f, 1280.0f );
2799 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
2800 scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
2801 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
2802 scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
2803 scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
2806 // We set the X ruler to fixed to give us pages to snap to.
2807 Dali::Toolkit::FixedRuler* rulerX = new Dali::Toolkit::FixedRuler( viewPageSize.width );
2808 // Note: The 3x page width is arbitary, but we need enough to show that we are
2809 // capping page movement by the page limiter, and not the domain.
2810 rulerX->SetDomain( Dali::Toolkit::RulerDomain( 0.0f, viewPageSize.width * 3.0f, false ) );
2811 Dali::Toolkit::RulerPtr rulerY = new Dali::Toolkit::DefaultRuler();
2813 scrollView.SetRulerX( rulerX );
2814 scrollView.SetRulerY( rulerY );
2816 scrollView.SetWrapMode( false );
2817 scrollView.SetScrollSensitive( true );
2819 application.GetScene().Add( scrollView );
2821 // Set up a gesture to perform.
2822 Vector2 startPos( 50.0f, 0.0f );
2823 Vector2 direction( -5.0f, 0.0f );
2826 // Force starting position.
2827 scrollView.ScrollTo( startPos, 0.0f );
2829 time += Wait( application );
2831 // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
2832 Vector2 currentPos( PerformGestureSwipe( application, startPos, direction, frames - 1, time, false ) );
2834 // Confirm the final X coord has not moved more than one page from the start X position.
2835 DALI_TEST_GREATER( ( startPos.x + viewPageSize.width ), scrollView.GetCurrentScrollPosition().x, TEST_LOCATION );
2837 // Finish the gesture and wait for the snap.
2838 currentPos += direction;
2839 TestEndPan(application, currentPos, time);
2840 // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
2841 time += Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
2843 // Confirm the final X coord has snapped to exactly one page ahead of the start page.
2844 DALI_TEST_EQUALS( viewPageSize.width, scrollView.GetCurrentScrollPosition().x, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2849 int UtcDaliScrollViewSetGetProperty(void)
2851 ToolkitTestApplication application;
2853 // Create the ScrollView actor
2854 ScrollView scrollView = ScrollView::New();
2855 DALI_TEST_CHECK(scrollView);
2857 // Event side properties
2859 // Test "wrapEnabled" property
2860 DALI_TEST_CHECK( scrollView.GetPropertyIndex("wrapEnabled") == ScrollView::Property::WRAP_ENABLED );
2861 scrollView.SetProperty( ScrollView::Property::WRAP_ENABLED, true );
2862 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WRAP_ENABLED).Get<bool>(), true, TEST_LOCATION );
2864 // Test "panningEnabled" property
2865 DALI_TEST_CHECK( scrollView.GetPropertyIndex("panningEnabled") == ScrollView::Property::PANNING_ENABLED );
2866 scrollView.SetProperty( ScrollView::Property::PANNING_ENABLED, false );
2867 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::PANNING_ENABLED).Get<bool>(), false, TEST_LOCATION );
2869 // Test "axisAutoLockEnabled" property
2870 DALI_TEST_CHECK( scrollView.GetPropertyIndex("axisAutoLockEnabled") == ScrollView::Property::AXIS_AUTO_LOCK_ENABLED );
2871 scrollView.SetProperty( ScrollView::Property::AXIS_AUTO_LOCK_ENABLED, false );
2872 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::AXIS_AUTO_LOCK_ENABLED).Get<bool>(), false, TEST_LOCATION );
2874 // Test "wheelScrollDistanceStep" property
2875 DALI_TEST_CHECK( scrollView.GetPropertyIndex("wheelScrollDistanceStep") == ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP );
2876 scrollView.SetProperty( ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP, Vector2(100.0f, 50.0f) );
2877 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP).Get<Vector2>(), Vector2(100.0f, 50.0f), TEST_LOCATION );
2879 // Test "overshootEnabled" property
2880 DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootEnabled") == Scrollable::Property::OVERSHOOT_ENABLED );
2881 DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), scrollView.IsOvershootEnabled(), TEST_LOCATION );
2882 scrollView.SetProperty( Scrollable::Property::OVERSHOOT_ENABLED, false );
2883 DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), false, TEST_LOCATION );
2885 // Animatable properties
2887 // Test "scrollPosition" property
2888 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPosition") == ScrollView::Property::SCROLL_POSITION );
2889 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(320.0f, 550.0f) );
2891 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION).Get<Vector2>(), Vector2(320.0f, 550.0f), TEST_LOCATION );
2893 // Test "scrollPrePosition", "scrollPrePositionX" and "scrollPrePositionY" properties
2894 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePosition") == ScrollView::Property::SCROLL_PRE_POSITION );
2895 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION, Vector2(300.0f, 500.0f) );
2897 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION).Get<Vector2>(), Vector2(300.0f, 500.0f), TEST_LOCATION );
2899 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionX") == ScrollView::Property::SCROLL_PRE_POSITION_X );
2900 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionY") == ScrollView::Property::SCROLL_PRE_POSITION_Y );
2901 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_X).Get<float>(), 300.0f, TEST_LOCATION );
2902 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_Y).Get<float>(), 500.0f, TEST_LOCATION );
2903 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_X, 400.0f );
2904 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_Y, 600.0f );
2906 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_X).Get<float>(), 400.0f, TEST_LOCATION );
2907 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_Y).Get<float>(), 600.0f, TEST_LOCATION );
2908 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION).Get<Vector2>(), Vector2(400.0f, 600.0f), TEST_LOCATION );
2910 // Test "scrollPrePositionMax", "scrollPrePositionMaxX" and "scrollPrePositionMaxY" properties
2911 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMax") == ScrollView::Property::SCROLL_PRE_POSITION_MAX );
2912 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX, Vector2(100.0f, 200.0f) );
2914 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX).Get<Vector2>(), Vector2(100.0f, 200.0f), TEST_LOCATION );
2916 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMaxX") == ScrollView::Property::SCROLL_PRE_POSITION_MAX_X );
2917 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMaxY") == ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y );
2918 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_X).Get<float>(), 100.0f, TEST_LOCATION );
2919 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y).Get<float>(), 200.0f, TEST_LOCATION );
2920 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX_X, 300.0f );
2921 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y, 400.0f );
2923 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_X).Get<float>(), 300.0f, TEST_LOCATION );
2924 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y).Get<float>(), 400.0f, TEST_LOCATION );
2925 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX).Get<Vector2>(), Vector2(300.0f, 400.0f), TEST_LOCATION );
2927 // Test "overshootX" property
2928 DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootX") == ScrollView::Property::OVERSHOOT_X );
2929 scrollView.SetProperty( ScrollView::Property::OVERSHOOT_X, 0.8f );
2931 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::OVERSHOOT_X).Get<float>(), 0.8f, TEST_LOCATION );
2933 // Test "overshootY" property
2934 DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootY") == ScrollView::Property::OVERSHOOT_Y );
2935 scrollView.SetProperty( ScrollView::Property::OVERSHOOT_Y, 0.8f );
2937 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y).Get<float>(), 0.8f, TEST_LOCATION );
2939 // Test "scrollFinal", "scrollFinalX" and "scrollFinalY" properties
2940 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinal") == ScrollView::Property::SCROLL_FINAL );
2941 scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL, Vector2(200.0f, 300.0f) );
2943 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL).Get<Vector2>(), Vector2(200.0f, 300.0f), TEST_LOCATION );
2945 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinalX") == ScrollView::Property::SCROLL_FINAL_X );
2946 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinalY") == ScrollView::Property::SCROLL_FINAL_Y );
2947 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_X).Get<float>(), 200.0f, TEST_LOCATION );
2948 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_Y).Get<float>(), 300.0f, TEST_LOCATION );
2949 scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL_X, 500.0f );
2950 scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL_Y, 600.0f );
2952 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_X).Get<float>(), 500.0f, TEST_LOCATION );
2953 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_Y).Get<float>(), 600.0f, TEST_LOCATION );
2954 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL).Get<Vector2>(), Vector2(500.0f, 600.0f), TEST_LOCATION );
2956 // Test "wrap" property
2957 DALI_TEST_CHECK( scrollView.GetPropertyIndex("wrap") == ScrollView::Property::WRAP );
2958 scrollView.SetProperty( ScrollView::Property::WRAP, false );
2960 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WRAP).Get<bool>(), false, TEST_LOCATION );
2962 // Test "panning" property
2963 DALI_TEST_CHECK( scrollView.GetPropertyIndex("panning") == ScrollView::Property::PANNING );
2964 scrollView.SetProperty( ScrollView::Property::PANNING, true );
2966 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::PANNING).Get<bool>(), true, TEST_LOCATION );
2968 // Test "scrolling" property
2969 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrolling") == ScrollView::Property::SCROLLING );
2970 scrollView.SetProperty( ScrollView::Property::SCROLLING, false );
2972 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLLING).Get<bool>(), false, TEST_LOCATION );
2974 // Test "scrollDomainSize", "scrollDomainSizeX" and "scrollDomainSizeY" properties
2975 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSize") == ScrollView::Property::SCROLL_DOMAIN_SIZE );
2976 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE, Vector2(1200.0f, 1300.0f) );
2978 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE).Get<Vector2>(), Vector2(1200.0f, 1300.0f), TEST_LOCATION );
2980 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSizeX") == ScrollView::Property::SCROLL_DOMAIN_SIZE_X );
2981 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSizeY") == ScrollView::Property::SCROLL_DOMAIN_SIZE_Y );
2982 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_X).Get<float>(), 1200.0f, TEST_LOCATION );
2983 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_Y).Get<float>(), 1300.0f, TEST_LOCATION );
2984 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE_X, 1500.0f );
2985 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE_Y, 1600.0f );
2987 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_X).Get<float>(), 1500.0f, TEST_LOCATION );
2988 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_Y).Get<float>(), 1600.0f, TEST_LOCATION );
2989 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE).Get<Vector2>(), Vector2(1500.0f, 1600.0f), TEST_LOCATION );
2991 // Test "scrollDomainOffset" property
2992 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainOffset") == ScrollView::Property::SCROLL_DOMAIN_OFFSET );
2993 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_OFFSET, Vector2(500.0f, 200.0f) );
2995 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_OFFSET).Get<Vector2>(), Vector2(500.0f, 200.0f), TEST_LOCATION );
2997 // Test "scrollPositionDelta" property
2998 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPositionDelta") == ScrollView::Property::SCROLL_POSITION_DELTA );
2999 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION_DELTA, Vector2(10.0f, 30.0f) );
3001 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION_DELTA).Get<Vector2>(), Vector2(10.0f, 30.0f), TEST_LOCATION );
3003 // Test "startPagePosition" property
3004 DALI_TEST_CHECK( scrollView.GetPropertyIndex("startPagePosition") == ScrollView::Property::START_PAGE_POSITION );
3005 scrollView.SetProperty( ScrollView::Property::START_PAGE_POSITION, Vector3(50.0f, 100.0f, 20.0f) );
3007 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::START_PAGE_POSITION).Get<Vector3>(), Vector3(50.0f, 100.0f, 20.0f), TEST_LOCATION );
3012 int UtcDaliToolkitScrollViewWheelEvent(void)
3014 ToolkitTestApplication application;
3016 // Set up a scrollView.
3017 ScrollView scrollView = ScrollView::New();
3019 // Do not rely on stage size for UTC tests.
3020 Vector2 viewPageSize( 720.0f, 1280.0f );
3021 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
3022 scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
3023 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
3024 scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
3025 scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
3028 // We set the X ruler to fixed to give us pages to snap to.
3029 Dali::Toolkit::FixedRuler* rulerX = new Dali::Toolkit::FixedRuler( viewPageSize.width );
3030 // Note: The 3x page width is arbitary, but we need enough to show that we are
3031 // capping page movement by the page limiter, and not the domain.
3032 rulerX->SetDomain( Dali::Toolkit::RulerDomain( 0.0f, viewPageSize.width * 3.0f, false ) );
3033 Dali::Toolkit::RulerPtr rulerY = new Dali::Toolkit::DefaultRuler();
3035 scrollView.SetRulerX( rulerX );
3036 scrollView.SetRulerY( rulerY );
3038 scrollView.SetWrapMode( false );
3040 application.GetScene().Add( scrollView );
3042 //Connect to wheel event signal
3043 scrollView.WheelEventSignal().Connect( &OnWheelEvent );
3045 DALI_TEST_CHECK( !gOnWheelEventCalled );
3047 // Render and notify
3048 application.Render();
3049 application.SendNotification();
3050 application.Render();
3051 application.SendNotification();
3053 // Perform a wheel event
3054 Dali::Integration::WheelEvent wheelEvent( Dali::Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, Vector2( 10.0f, 10.0f ), 1, 1000u );
3055 application.ProcessEvent( wheelEvent );
3056 DALI_TEST_CHECK( gOnWheelEventCalled );
3058 // Set X ruler to free
3059 Dali::Toolkit::DefaultRuler* defaultRuler = new Dali::Toolkit::DefaultRuler();
3060 scrollView.SetRulerX( defaultRuler );
3062 // Perform a wheel event
3063 gOnWheelEventCalled = false;
3064 application.ProcessEvent( wheelEvent );
3065 DALI_TEST_CHECK( gOnWheelEventCalled );
3070 // Perform a wheel event
3071 gOnWheelEventCalled = false;
3072 application.ProcessEvent( wheelEvent );
3073 DALI_TEST_CHECK( gOnWheelEventCalled );
3075 // Wait until it finishes scrolling
3076 Wait(application, RENDER_DELAY_SCROLL);
3078 // Set Y ruler to fixed
3079 Dali::Toolkit::FixedRuler* fixedRulerY = new Dali::Toolkit::FixedRuler( viewPageSize.height );
3080 scrollView.SetRulerY( fixedRulerY );
3082 // Perform a wheel event
3083 gOnWheelEventCalled = false;
3084 application.ProcessEvent( wheelEvent );
3085 DALI_TEST_CHECK( gOnWheelEventCalled );