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>
25 using namespace Toolkit;
27 void scroll_view_startup(void)
29 test_return_value = TET_UNDEF;
32 void scroll_view_cleanup(void)
34 test_return_value = TET_PASS;
39 static bool gObjectCreatedCallBackCalled;
41 static void TestCallback(BaseHandle handle)
43 gObjectCreatedCallBackCalled = true;
46 struct CallbackFunctor
48 CallbackFunctor(bool* callbackFlag)
49 : mCallbackFlag( callbackFlag )
55 *mCallbackFlag = true;
60 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
62 const int RENDER_DELAY_SCROLL = 1000; ///< duration to wait for any scroll to complete.
64 // For Clamp Signal testing...
65 const float CLAMP_EXCESS_WIDTH = 200.0f; ///< Amount of width that can be panned outside scrollview
66 const float CLAMP_EXCESS_HEIGHT = 200.0f; ///< Amount of height that can be panned outside scrollview
67 const Vector2 CLAMP_START_SCROLL_POSITION(30.0f, 100.0f); ///< Scroll start position for the Clamping tests.
68 const Vector2 CLAMP_TOUCH_START( 100.0f, 100.0f ); ///< Start point to touch from for the Clamping tests.
69 const Vector2 CLAMP_TOUCH_MOVEMENT( 5.0f, -5.0f ); ///< Amount to move touch for each frame for the Clamping tests.
70 const int CLAMP_GESTURE_FRAMES = 100; ///< Number of Frames to synthesize a gesture for the Clamping tests.
71 const Vector3 TEST_ACTOR_POSITION(100.0f, 100.0f, 0.0f); ///< A Test actor position offset (arbitrary value)
72 const Vector3 TEST_CONSTRAINT_OFFSET(1.0f, 2.0f, 0.0f); ///< A Test constraint offset (arbitrary value to test effects)
74 const float DEFAULT_SNAP_OVERSHOOT_DURATION(0.5f); ///< Default overshoot snapping animation time.
75 const float DEFAULT_MAX_OVERSHOOT(100.0f); ///< Default maximum allowed overshoot in pixels
77 const int MAX_FRAMES_TO_TEST_OVERSHOOT = 600; ///< 10 seconds (at 60 frames per second).
78 const Vector2 OVERSHOOT_START_SCROLL_POSITION(100.0f, 100.0f); ///< Scroll start position for the Overshoot tests.
79 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)
80 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).
81 const float TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION = 0.05f; ///< a Test duration
82 const float TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION = 1.5f; ///< another Test duration
83 const float TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION = TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * 0.5f; // Same as above, but different alpha function.
84 const float TIME_TOLERANCE = 0.05f; ///< Allow testing tolerance between a 10th of second (+/- 3 frames)
88 * Simulate time passed by.
90 * @note this will always process at least 1 frame (1/60 sec)
92 * @param application Test application instance
93 * @param duration Time to pass in milliseconds.
94 * @return The actual time passed in milliseconds
96 int Wait(ToolkitTestApplication& application, int duration = 0)
100 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
102 application.SendNotification();
103 application.Render(RENDER_FRAME_INTERVAL);
104 time += RENDER_FRAME_INTERVAL;
112 static bool gOnScrollStartCalled; ///< Whether the OnScrollStart signal was invoked.
113 static bool gOnScrollUpdateCalled; ///< Whether the OnScrollUpdate signal was invoked.
114 static bool gOnScrollCompleteCalled; ///< Whether the OnScrollComplete signal was invoked.
115 static bool gOnSnapStartCalled; ///< Whether the OnSnapStart signal was invoked.
116 static SnapType gLastSnapType; ///< Snaping information from SnapEvent.
117 static Vector3 gConstraintResult; ///< Result from constraint.
120 * Invoked when scrolling starts.
122 * @param[in] position The current scroll position.
124 static void OnScrollStart( const Vector2& position )
126 gOnScrollStartCalled = true;
130 * Invoked when scrolling updates (via dragging)
132 * @param[in] position The current scroll position.
134 static void OnScrollUpdate( const Vector2& position )
136 gOnScrollUpdateCalled = true;
140 * Invoked when scrolling finishes
142 * @param[in] position The current scroll position.
144 static void OnScrollComplete( const Vector2& position )
146 gOnScrollCompleteCalled = true;
150 * Invoked when a snap or flick started.
152 * @param[in] event The type of snap and the target position/scale/rotation.
154 static void OnSnapStart( const ScrollView::SnapEvent& event )
156 gOnSnapStartCalled = true;
157 gLastSnapType = event.type;
163 * Summation of current value, property, and offset.
165 * current' = current + mOffset + property;
167 struct TestSumConstraint
170 * @param[in] offset The offset to be added to current.
172 TestSumConstraint(const Vector3& offset)
178 * @param[in] current The current base value
179 * @param[in] inputs Contains the property to be added to current.
180 * @return The new current Vector.
182 void operator()( Vector3& current, const PropertyInputContainer& inputs )
184 gConstraintResult = current + Vector3(inputs[0]->GetVector2()) + mOffset;
185 current = gConstraintResult;
193 * @param[in] application The application instance
194 * @param[in] scrollView The scrollView instance
195 * @return The time taken for the overshoot to reach origin (zero)
197 static float TestOvershootSnapDuration(ToolkitTestApplication &application, ScrollView scrollView)
199 int timeToReachOrigin = -1;
200 for(int i = 0;i<MAX_FRAMES_TO_TEST_OVERSHOOT;i++)
202 float overshootXValue = scrollView.GetCurrentProperty<float>( ScrollView::Property::OVERSHOOT_X );
203 float overshootYValue = scrollView.GetCurrentProperty<float>( ScrollView::Property::OVERSHOOT_Y );
204 if(overshootXValue == 0.0f && overshootYValue == 0.0f)
209 timeToReachOrigin += Wait(application);
212 return static_cast<float>(timeToReachOrigin) * 0.001f; // return in seconds not ms.
216 * y = 2x alpha function, which is clamped between 0.0f - 1.0f
218 * Animations should appear to finish (reach 100% point)
219 * at just half the time of a regular Linear AlphaFunction.
221 * @param[in] progress value (ranges from 0.0f - 1.0f)
222 * @return interpolation value (ranges from 0.0f - 1.0f)
224 float TestAlphaFunction(float progress)
226 return std::min( progress * 2.0f, 1.0f );
230 * Generate a complete pan gesture
231 * Note: To initiate the gesture it will go from start, diagonally SE on the screen, then continue in the direction for frames touches
233 static Vector2 PerformGestureSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, uint32_t& time, bool finish = true)
235 gOnScrollStartCalled = false;
236 gOnScrollUpdateCalled = false;
237 gOnScrollCompleteCalled = false;
238 gOnSnapStartCalled = false;
240 Vector2 pos( start );
242 // This is created to ensure a pan is started
243 Vector2 pos_start_jump( start + Vector2(11.0f, 11.0f) );
244 TestStartPan( application, start, pos_start_jump, time );
245 pos = pos_start_jump;
249 for(int i = 0;i<frames;i++)
251 pos += direction; // Move in this direction
252 TestMovePan(application, pos, time );
253 time += Wait(application);
258 pos += direction; // Move in this direction.
259 TestEndPan(application, pos, time );
260 time += Wait(application, RENDER_DELAY_SCROLL);
267 } // unnamed namespace
270 int UtcDaliToolkitScrollViewConstructorP(void)
272 ToolkitTestApplication application;
274 ScrollView scrollView;
275 DALI_TEST_CHECK( !scrollView );
279 int UtcDaliToolkitScrollViewCopyConstructorP(void)
281 ToolkitTestApplication application;
283 ScrollView scrollView = ScrollView::New();
284 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) );
286 ScrollView copy( scrollView );
287 DALI_TEST_CHECK( copy );
288 DALI_TEST_CHECK( copy.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) == scrollView.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) );
292 int UtcDaliScrollViewMoveConstructor(void)
294 ToolkitTestApplication application;
296 ScrollView scrollView = ScrollView::New();
297 DALI_TEST_EQUALS( 1, scrollView.GetBaseObject().ReferenceCount(), TEST_LOCATION );
298 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) );
299 DALI_TEST_EQUALS( scrollView.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ), Vector2(10.0f, 10.0f), TEST_LOCATION );
301 ScrollView moved = std::move( scrollView );
302 DALI_TEST_CHECK( moved );
303 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
304 DALI_TEST_EQUALS( moved.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ), Vector2(10.0f, 10.0f), TEST_LOCATION );
305 DALI_TEST_CHECK( !scrollView );
310 int UtcDaliToolkitScrollViewAssignmentOperatorP(void)
312 ToolkitTestApplication application;
314 ScrollView scrollView = ScrollView::New();
315 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) );
319 DALI_TEST_CHECK( copy );
320 DALI_TEST_CHECK( copy.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) == scrollView.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) );
324 int UtcDaliScrollViewMoveAssignment(void)
326 ToolkitTestApplication application;
328 ScrollView scrollView = ScrollView::New();
329 DALI_TEST_EQUALS( 1, scrollView.GetBaseObject().ReferenceCount(), TEST_LOCATION );
330 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) );
331 DALI_TEST_EQUALS( scrollView.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ), Vector2(10.0f, 10.0f), TEST_LOCATION );
334 moved = std::move( scrollView );
335 DALI_TEST_CHECK( moved );
336 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
337 DALI_TEST_EQUALS( moved.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ), Vector2(10.0f, 10.0f), TEST_LOCATION );
338 DALI_TEST_CHECK( !scrollView );
343 int UtcDaliScrollViewDestructorP(void)
345 ToolkitTestApplication application;
347 ScrollView* scrollView = new ScrollView();
350 DALI_TEST_CHECK( true );
354 int UtcDaliToolkitScrollViewNewP1(void)
356 ToolkitTestApplication application;
357 tet_infoline(" UtcDaliToolkitScrollViewNewP1");
359 ScrollView scrollView;
361 DALI_TEST_CHECK( !scrollView );
363 scrollView = ScrollView::New();
365 DALI_TEST_CHECK( scrollView );
367 ScrollView scrollView2(scrollView);
369 DALI_TEST_CHECK( scrollView2 == scrollView );
371 //Additional check to ensure object is created by checking if it's registered
372 ObjectRegistry registry = application.GetCore().GetObjectRegistry();
373 DALI_TEST_CHECK( registry );
375 gObjectCreatedCallBackCalled = false;
376 registry.ObjectCreatedSignal().Connect( &TestCallback );
378 ScrollView scrollView = ScrollView::New();
380 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
384 int UtcDaliToolkitScrollViewNewP2(void)
386 ToolkitTestApplication application;
387 tet_infoline(" UtcDaliToolkitScrollViewNewP2 - create thru type registry");
389 ScrollView scrollView;
390 DALI_TEST_CHECK( !scrollView );
392 TypeRegistry typeRegistry = TypeRegistry::Get();
393 TypeInfo scrollViewType = typeRegistry.GetTypeInfo("ScrollView");
394 BaseHandle handle = scrollViewType.CreateInstance();
395 DALI_TEST_CHECK( handle );
397 scrollView = ScrollView::DownCast(handle);
398 DALI_TEST_CHECK( scrollView );
403 int UtcDaliToolkitScrollViewDownCastP(void)
405 ToolkitTestApplication application;
406 tet_infoline(" UtcDaliToolkitScrollViewDownCastP");
408 ScrollView scrollView = ScrollView::New();
409 BaseHandle handle(scrollView);
411 ScrollView newScrollView = ScrollView::DownCast( handle );
412 DALI_TEST_CHECK( scrollView );
413 DALI_TEST_CHECK( newScrollView == scrollView );
417 int UtcDaliToolkitScrollViewScrollToPositionP(void)
419 ToolkitTestApplication application;
420 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionP");
422 // Create the ScrollView actor
423 ScrollView scrollView = ScrollView::New();
424 application.GetScene().Add( scrollView );
426 const Vector2 target = Vector2(100.0f, 200.0f);
427 const Vector2 target2 = Vector2(300.0f, 100.0f);
429 scrollView.ScrollTo( target, 0.0f );
431 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
432 scrollView.ScrollTo( target2 );
433 Wait(application, RENDER_DELAY_SCROLL);
434 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
439 int UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP(void)
441 ToolkitTestApplication application;
442 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP");
444 ScrollView scrollView = ScrollView::New();
445 application.GetScene().Add( scrollView );
446 RulerPtr rulerX = new FixedRuler( 100.0f );
447 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
448 RulerPtr rulerY = new FixedRuler( 100.0f );
449 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
451 scrollView.SetRulerX( rulerX );
452 scrollView.SetRulerY( rulerY );
454 scrollView.SetWrapMode(true);
456 Property::Value wrapMode = scrollView.GetProperty( Toolkit::ScrollView::Property::WRAP_ENABLED );
457 DALI_TEST_EQUALS( wrapMode.Get<bool>(), true, TEST_LOCATION );
459 const Vector2 target = Vector2(50.0f, 50.0f);
460 const Vector2 target2 = Vector2(150.0f, 150.0f);
462 scrollView.ScrollTo( target, 0.0f );
463 Wait(application, RENDER_DELAY_SCROLL);
464 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
466 scrollView.ScrollTo( target2, 0.25f, Dali::Toolkit::DirectionBiasLeft, Dali::Toolkit::DirectionBiasLeft );
467 Wait(application, RENDER_DELAY_SCROLL);
468 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
470 scrollView.ScrollTo( target, 0.0f );
471 Wait(application, RENDER_DELAY_SCROLL);
472 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
474 scrollView.ScrollTo( target2, 0.25f, Dali::Toolkit::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
475 Wait(application, RENDER_DELAY_SCROLL);
476 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
481 int UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionP(void)
483 ToolkitTestApplication application;
484 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionP");
486 // Create the ScrollView actor
487 ScrollView scrollView = ScrollView::New();
488 application.GetScene().Add( scrollView );
490 const Vector2 target = Vector2(100.0f, 200.0f);
491 const Vector2 target2 = Vector2(300.0f, 100.0f);
493 scrollView.ScrollTo( target, 0.5f, TestAlphaFunction );
494 Wait(application, 250);
495 // Check that the scroll animation should finish within just half of the specified duration with the above alpha function
496 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
498 scrollView.ScrollTo( target2, 0.5f, AlphaFunction::LINEAR );
499 Wait(application, 250);
500 // Check that the scroll animation has not finished within half of the specified duration with the linear alpha function
501 DALI_TEST_CHECK( scrollView.GetCurrentScrollPosition() != target2 );
503 // Wait till the end of the specified duration
504 Wait(application, 250);
505 // Check that the scroll animation has finished
506 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
511 int UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionAndDirectionBiasP(void)
513 ToolkitTestApplication application;
514 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionAndDirectionBiasP");
516 ScrollView scrollView = ScrollView::New();
517 application.GetScene().Add( scrollView );
518 RulerPtr rulerX = new FixedRuler( 100.0f );
519 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
520 RulerPtr rulerY = new FixedRuler( 100.0f );
521 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
523 scrollView.SetRulerX( rulerX );
524 scrollView.SetRulerY( rulerY );
526 scrollView.SetWrapMode(true);
528 const Vector2 target = Vector2(50.0f, 50.0f);
529 const Vector2 target2 = Vector2(150.0f, 150.0f);
531 scrollView.ScrollTo( target, 0.0f );
532 Wait(application, RENDER_DELAY_SCROLL);
533 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
535 scrollView.ScrollTo( target2, 0.25f, AlphaFunction::LINEAR, Dali::Toolkit::DirectionBiasLeft, Dali::Toolkit::DirectionBiasLeft );
536 Wait(application, RENDER_DELAY_SCROLL);
537 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
539 scrollView.ScrollTo( target, 0.0f );
540 Wait(application, RENDER_DELAY_SCROLL);
541 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
543 scrollView.ScrollTo( target2, 0.25f, AlphaFunction::LINEAR, Dali::Toolkit::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
544 Wait(application, RENDER_DELAY_SCROLL);
545 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
547 scrollView.ScrollTo( target, 0.0f );
548 Wait(application, RENDER_DELAY_SCROLL);
549 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
551 scrollView.ScrollTo( target2, 0.25f, TestAlphaFunction, Dali::Toolkit::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
552 Wait(application, 125);
553 // Check that the scroll animation should finish within just half of the specified duration with the above alpha function
554 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
559 int UtcDaliToolkitScrollViewScrollToPageP(void)
561 ToolkitTestApplication application;
562 tet_infoline(" UtcDaliToolkitScrollViewScrollToPageP");
564 ScrollView scrollView = ScrollView::New();
565 application.GetScene().Add( scrollView );
566 RulerPtr rulerX = new FixedRuler( 100.0f );
567 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
568 RulerPtr rulerY = new FixedRuler( 100.0f );
569 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
571 scrollView.SetRulerX( rulerX );
572 scrollView.SetRulerY( rulerY );
574 scrollView.ScrollTo( 1, 0.0f );
576 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION );
578 scrollView.ScrollTo( 5, 0.0f );
580 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(500.0f, 0.0f), TEST_LOCATION );
582 scrollView.ScrollTo( 10, 0.0f );
584 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 100.0f), TEST_LOCATION );
586 scrollView.ScrollTo( 15, 0.0f );
588 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(700.0f, 100.0f), TEST_LOCATION );
589 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION );
591 scrollView.ScrollTo( 3 );
592 Wait(application, RENDER_DELAY_SCROLL);
593 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(300.0f, 0.0f), TEST_LOCATION );
594 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION );
596 scrollView.ScrollTo( 9 );
597 Wait(application, RENDER_DELAY_SCROLL);
598 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 100.0f), TEST_LOCATION );
599 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION );
601 // Apply DefaultRulers instead and see what happens.
602 rulerX = new DefaultRuler();
603 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
604 rulerY = new DefaultRuler();
605 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
607 scrollView.SetRulerX( rulerX );
608 scrollView.SetRulerY( rulerY );
610 // This time should always scroll to origin (0.0f, 0.0f)
611 scrollView.ScrollTo( 1, 0.0f );
613 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
614 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
620 int UtcDaliToolkitScrollModeP1(void)
622 ToolkitTestApplication application;
623 tet_infoline( " UtcDaliToolkitScrollView ScrollMode property" );
625 // Set up a scrollView.
626 ScrollView scrollView = ScrollView::New();
628 // Do not rely on stage size for UTC tests.
629 Vector2 viewPageSize( 720.0f, 1280.0f );
630 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
631 scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
632 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
633 scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
634 scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
637 Property::Map rulerMap;
638 rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, true );
639 rulerMap.Add( ScrollMode::X_AXIS_SNAP_TO_INTERVAL, viewPageSize.width );
640 rulerMap.Add( ScrollMode::X_AXIS_SCROLL_BOUNDARY, viewPageSize.width*3 );
641 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, false );
642 scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
644 scrollView.SetWrapMode( false );
645 scrollView.SetScrollSensitive( true );
647 application.GetScene().Add( scrollView );
649 // Set up a gesture to perform.
650 Vector2 startPos( 50.0f, 0.0f );
651 Vector2 direction( -5.0f, 0.0f );
655 // Force starting position.
656 scrollView.ScrollTo( startPos, 0.0f );
657 time += Wait( application );
659 // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
660 Vector2 currentPos( PerformGestureSwipe( application, startPos, direction, frames - 1, time, false ) );
662 // Confirm the final X coord has not moved more than one page from the start X position.
663 DALI_TEST_GREATER( ( startPos.x + viewPageSize.width ), scrollView.GetCurrentScrollPosition().x, TEST_LOCATION );
665 // Finish the gesture and wait for the snap.
666 currentPos += direction;
667 TestEndPan( application, currentPos, time );
668 // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
669 time += Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
671 // Confirm the final X coord has snapped to exactly one page ahead of the start page.
672 DALI_TEST_EQUALS( viewPageSize.width, scrollView.GetCurrentScrollPosition().x, Math::MACHINE_EPSILON_0, TEST_LOCATION );
677 int UtcDaliToolkitScrollModeP2(void)
679 ToolkitTestApplication application;
680 tet_infoline( " UtcDaliToolkitScrollView ScrollMode property" );
682 // Set up a scrollView.
683 ScrollView scrollView = ScrollView::New();
685 // Do not rely on stage size for UTC tests.
686 Vector2 viewPageSize( 720.0f, 1280.0f );
687 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
688 scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
689 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
690 scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
691 scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
694 Property::Map rulerMap;
695 rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, false );
696 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, true );
697 rulerMap.Add( ScrollMode::Y_AXIS_SNAP_TO_INTERVAL, viewPageSize.height );
698 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_BOUNDARY, viewPageSize.height*3 );
699 scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
701 scrollView.SetWrapMode( false );
702 scrollView.SetScrollSensitive( true );
704 application.GetScene().Add( scrollView );
706 // Set up a gesture to perform.
707 Vector2 startPos( 0.0f, 50.0f );
708 Vector2 direction( 0.0f, -6.0f );
712 // Force starting position.
713 scrollView.ScrollTo( startPos, 0.0f );
714 time += Wait( application );
716 // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
717 Vector2 currentPos( PerformGestureSwipe( application, startPos, direction, frames - 1, time, false ) );
719 // Confirm the final X coord has not moved more than one page from the start X position.
720 DALI_TEST_GREATER( ( startPos.y + viewPageSize.height ), scrollView.GetCurrentScrollPosition().y, TEST_LOCATION );
722 // Finish the gesture and wait for the snap.
723 currentPos += direction;
724 time += Wait( application );
725 TestEndPan( application, currentPos, time );
726 // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
727 Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
729 // Confirm the final Y coord has snapped to exactly one page ahead of the start page.
730 DALI_TEST_EQUALS( viewPageSize.height, scrollView.GetCurrentScrollPosition().y, Math::MACHINE_EPSILON_0, TEST_LOCATION );
735 int UtcDaliToolkitScrollModeP3(void)
737 ToolkitTestApplication application;
738 tet_infoline( " UtcDaliToolkitScrollView ScrollMode property" );
740 // Set up a scrollView.
741 ScrollView scrollView = ScrollView::New();
743 // Do not rely on stage size for UTC tests.
744 Vector2 viewPageSize( 720.0f, 1280.0f );
745 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
746 scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
747 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
748 scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
749 scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
752 Property::Map rulerMap;
753 rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, false );
754 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, true );
755 rulerMap.Add( ScrollMode::Y_AXIS_SNAP_TO_INTERVAL, viewPageSize.height );
756 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_BOUNDARY, viewPageSize.height*3 );
757 scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
759 scrollView.SetWrapMode( false );
760 scrollView.SetScrollSensitive( true );
762 application.GetScene().Add( scrollView );
764 // Set up a gesture to perform.
765 Vector2 startPos( 0.0f, 50.0f );
766 Vector2 direction( 0.0f, -6.0f );
770 // Force starting position.
771 scrollView.ScrollTo( startPos, 0.0f );
772 time += Wait( application );
774 // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
775 Vector2 currentPos( PerformGestureSwipe( application, startPos, direction, frames - 1, time, false ) );
777 // Confirm the final X coord has not moved more than one page from the start X position.
778 DALI_TEST_GREATER( ( startPos.y + viewPageSize.height ), scrollView.GetCurrentScrollPosition().y, TEST_LOCATION );
780 // Finish the gesture and wait for the snap.
781 currentPos += direction;
782 TestEndPan( application, currentPos, time );
783 // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
784 Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
786 // Confirm the final Y coord has snapped to exactly one page ahead of the start page.
787 DALI_TEST_EQUALS( viewPageSize.height, scrollView.GetCurrentScrollPosition().y, Math::MACHINE_EPSILON_0, TEST_LOCATION );
792 int UtcDaliToolkitScrollModeP4(void)
794 ToolkitTestApplication application;
795 tet_infoline( " UtcDaliToolkitScrollView ScrollMode property, DefaultRulers" );
797 // Set up a scrollView.
798 ScrollView scrollView = ScrollView::New();
800 // Do not rely on stage size for UTC tests.
801 Vector2 viewPageSize( 720.0f, 1280.0f );
802 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
803 scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
804 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
805 scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
806 scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
808 // Position rulers - expect Default rulers to be used which don't snap
809 Property::Map rulerMap;
810 rulerMap.Add( ScrollMode::X_AXIS_SCROLL_ENABLED, true );
811 rulerMap.Add( ScrollMode::Y_AXIS_SCROLL_ENABLED, true );
812 scrollView.SetProperty( ScrollView::Property::SCROLL_MODE, rulerMap);
814 scrollView.SetWrapMode( false );
815 scrollView.SetScrollSensitive( true );
817 application.GetScene().Add( scrollView );
819 Vector2 START_POSITION = Vector2(10.0f, 10.0f);
822 scrollView.ScrollTo(START_POSITION, 0.0f);
823 time += Wait(application);
825 // Try a vertical swipe.
826 // PerformGestureSwipe not used as a different initial direction was required
827 Vector2 pos( START_POSITION + Vector2(0.0f, 15.0f) );
828 Vector2 dir( 0.0f, 1.0f );
830 TestStartPan( application, START_POSITION, pos, time );
834 for( int i = 0; i<45; i++ )
837 TestMovePan( application, pos, time );
838 time += Wait( application );
843 TestEndPan( application, pos, time );
844 Wait( application, RENDER_DELAY_SCROLL );
846 // Take into account resampling done when prediction is off.
847 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
852 int UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP(void)
854 ToolkitTestApplication application;
855 tet_infoline(" UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP");
857 ScrollView scrollView = ScrollView::New();
858 application.GetScene().Add( scrollView );
859 RulerPtr rulerX = new FixedRuler( 100.0f );
860 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
861 RulerPtr rulerY = new FixedRuler( 100.0f );
862 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
864 scrollView.SetRulerX( rulerX );
865 scrollView.SetRulerY( rulerY );
867 scrollView.SetWrapMode(true);
869 scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DirectionBiasLeft );
871 Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame
872 // Check that the scroll position remains the same
873 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
875 Wait(application, RENDER_DELAY_SCROLL); // Wait for one second
876 // Check that it stays at the same page (i.e. the same scroll position)
877 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
878 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
880 scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DirectionBiasRight );
882 Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame
883 // Check that it scrolls towards the right
884 DALI_TEST_CHECK( scrollView.GetCurrentScrollPosition().x > 0.0f );
886 Wait(application, RENDER_DELAY_SCROLL); // Wait for one second
887 // Check that it scrolls back to the same page (i.e. the same scroll position)
888 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
889 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
894 int UtcDaliToolkitScrollViewScrollToActorP(void)
896 ToolkitTestApplication application;
897 tet_infoline(" UtcDaliToolkitScrollViewScrollToActorP");
899 ScrollView scrollView = ScrollView::New();
900 application.GetScene().Add( scrollView );
902 Actor actorA = Actor::New();
903 const Vector3 positionA = Vector3(100.0f, 400.0f, 0.0f);
904 actorA.SetProperty( Actor::Property::POSITION, positionA );
905 scrollView.Add(actorA);
907 Actor actorB = Actor::New();
908 const Vector3 positionB = Vector3(500.0f, 200.0f, 0.0f);
909 actorB.SetProperty( Actor::Property::POSITION, positionB );
910 scrollView.Add(actorB);
914 scrollView.ScrollTo(actorA, 0.0f);
916 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION );
919 scrollView.ScrollTo(actorB, 0.0f);
921 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION );
923 scrollView.ScrollTo(actorA);
924 Wait(application, RENDER_DELAY_SCROLL);
925 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION );
927 scrollView.ScrollTo(actorB);
928 Wait(application, RENDER_DELAY_SCROLL);
929 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION );
933 int UtcDaliToolkitScrollViewScrollToSnapPointP(void)
935 ToolkitTestApplication application;
936 tet_infoline(" UtcDaliToolkitScrollViewScrollToSnapPointP");
938 ScrollView scrollView = ScrollView::New();
939 application.GetScene().Add( scrollView );
940 RulerPtr rulerX = new FixedRuler( 100.0f );
941 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
942 RulerPtr rulerY = new FixedRuler( 100.0f );
943 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
945 scrollView.SetRulerX( rulerX );
946 scrollView.SetRulerY( rulerY );
948 scrollView.ScrollTo( Vector2(120.0f, 190.0f), 0.0f );
950 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(120.0f, 190.0f), TEST_LOCATION );
952 scrollView.ScrollToSnapPoint();
954 Wait(application, RENDER_DELAY_SCROLL);
955 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 200.0f), TEST_LOCATION );
959 int UtcDaliToolkitScrollViewSetScrollUpdateDistanceP(void)
961 ToolkitTestApplication application;
962 tet_infoline(" UtcDaliToolkitScrollViewSetScrollUpdateDistanceP");
964 ScrollView scrollView = ScrollView::New();
966 scrollView.SetScrollUpdateDistance(0);
967 DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 0, TEST_LOCATION);
968 scrollView.SetScrollUpdateDistance(10);
969 DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 10, TEST_LOCATION);
970 scrollView.SetScrollUpdateDistance(1000);
971 DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 1000, TEST_LOCATION);
975 int UtcDaliToolkitScrollViewSetWrapModeP(void)
977 ToolkitTestApplication application;
978 tet_infoline(" UtcDaliToolkitScrollViewSetWrapModeP");
980 ScrollView scrollView = ScrollView::New();
981 application.GetScene().Add( scrollView );
983 Actor actor = Actor::New();
984 scrollView.Add( actor );
986 // Position rulers. 4x4 grid.
987 RulerPtr rulerX = new FixedRuler(50.0f);
988 RulerPtr rulerY = new FixedRuler(50.0f);
989 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, false) );
990 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, false) );
991 scrollView.SetRulerX(rulerX);
992 scrollView.SetRulerY(rulerY);
994 scrollView.SetWrapMode(false);
995 scrollView.ScrollTo(Vector2(225.0f, 125.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
997 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 17, TEST_LOCATION );
999 scrollView.SetWrapMode(true);
1000 scrollView.ScrollTo(Vector2(230.0f, 130.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
1002 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 13, TEST_LOCATION );
1006 int UtcDaliToolkitScrollViewActorAutoSnap(void)
1008 ToolkitTestApplication application;
1009 tet_infoline(" UtcDaliToolkitScrollViewActorAutoSnap");
1011 ScrollView scrollView = ScrollView::New();
1012 application.GetScene().Add( scrollView );
1015 RulerPtr rulerX = new DefaultRuler();
1016 RulerPtr rulerY = new DefaultRuler();
1017 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1018 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1019 scrollView.SetRulerX(rulerX);
1020 scrollView.SetRulerY(rulerY);
1022 const Vector3 aPosition = Vector3(200.0f, 50.0f, 0.0f);
1023 Actor a = Actor::New();
1025 a.SetProperty( Actor::Property::POSITION, aPosition );
1027 const Vector3 bPosition = Vector3(600.0f, 600.0f, 0.0f);
1028 Actor b = Actor::New();
1030 b.SetProperty( Actor::Property::POSITION, bPosition );
1032 // Goto a random position, and execute snap (should not move)
1033 Vector2 targetScroll = Vector2(500.0f, 500.0f);
1034 scrollView.ScrollTo(targetScroll, 0.0f);
1036 scrollView.ScrollToSnapPoint();
1037 Wait(application, RENDER_DELAY_SCROLL);
1038 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), targetScroll, TEST_LOCATION );
1040 // Enable ActorAutoSnap, and now try snapping.
1041 scrollView.SetActorAutoSnap(true);
1042 scrollView.ScrollToSnapPoint();
1043 Wait(application, RENDER_DELAY_SCROLL);
1044 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), bPosition.GetVectorXY(), TEST_LOCATION );
1046 scrollView.ScrollTo(Vector2(0.0f, 0.0f), 0.0f);
1048 scrollView.ScrollToSnapPoint();
1049 Wait(application, RENDER_DELAY_SCROLL);
1050 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), aPosition.GetVectorXY(), TEST_LOCATION );
1054 int UtcDaliToolkitScrollViewSignalsStartComplete(void)
1056 ToolkitTestApplication application;
1057 tet_infoline(" UtcDaliToolkitScrollViewSignalsStartComplete");
1059 gOnScrollStartCalled = false;
1060 gOnScrollCompleteCalled = false;
1062 ScrollView scrollView = ScrollView::New();
1063 application.GetScene().Add( scrollView );
1066 RulerPtr rulerX = new DefaultRuler();
1067 RulerPtr rulerY = new DefaultRuler();
1068 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1069 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1070 scrollView.SetRulerX(rulerX);
1071 scrollView.SetRulerY(rulerY);
1072 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1073 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1074 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1075 scrollView.ScrollTo( Vector2(100.0f, 100.0f) );
1076 Wait(application, RENDER_DELAY_SCROLL);
1078 DALI_TEST_CHECK(gOnScrollStartCalled);
1079 DALI_TEST_CHECK(gOnScrollCompleteCalled);
1083 int UtcDaliToolkitScrollViewSignalsUpdate01(void)
1085 ToolkitTestApplication application;
1086 tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate");
1088 gOnScrollStartCalled = false;
1089 gOnScrollUpdateCalled = false;
1090 gOnScrollCompleteCalled = false;
1092 ScrollView scrollView = ScrollView::New();
1093 application.GetScene().Add( scrollView );
1094 Vector2 stageSize = application.GetScene().GetSize();
1095 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1096 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1097 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1100 RulerPtr rulerX = new DefaultRuler();
1101 RulerPtr rulerY = new DefaultRuler();
1102 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1103 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1104 scrollView.SetRulerX(rulerX);
1105 scrollView.SetRulerY(rulerY);
1106 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1107 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1108 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1110 Actor image = Actor::New();
1111 image.SetProperty( Actor::Property::SIZE, stageSize);
1112 image.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1113 image.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1114 scrollView.Add(image);
1118 // Do a pan starting from 100,100 and moving down diagonally.
1119 Vector2 pos(100.0f, 100.0f);
1120 uint32_t time = 100;
1121 TestStartPan( application, pos, pos, time );
1124 Wait(application, 100);
1126 for(int i = 0;i<20;i++)
1128 time += RENDER_FRAME_INTERVAL;
1129 TestMovePan( application, pos, time);
1135 time += RENDER_FRAME_INTERVAL;
1136 TestEndPan(application, pos, time );
1137 Wait(application, RENDER_DELAY_SCROLL);
1139 DALI_TEST_CHECK(gOnScrollStartCalled);
1140 DALI_TEST_CHECK(gOnScrollUpdateCalled);
1141 DALI_TEST_CHECK(gOnScrollCompleteCalled);
1145 int UtcDaliToolkitScrollViewSignalsUpdate02(void)
1147 ToolkitTestApplication application;
1148 tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate");
1150 gOnScrollStartCalled = false;
1151 gOnScrollUpdateCalled = false;
1152 gOnScrollCompleteCalled = false;
1154 ScrollView scrollView = ScrollView::New();
1155 application.GetScene().Add( scrollView );
1156 Vector2 stageSize = application.GetScene().GetSize();
1157 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1158 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1159 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1162 RulerPtr rulerX = new DefaultRuler();
1163 RulerPtr rulerY = new DefaultRuler();
1164 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1165 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
1166 scrollView.SetRulerX(rulerX);
1167 scrollView.SetRulerY(rulerY);
1168 Dali::ConnectionTracker tracker;
1169 bool scrollStarted=false;
1170 bool scrollUpdated=false;
1171 bool scrollCompleted=false;
1172 DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollStarted", CallbackFunctor(&scrollStarted) ));
1173 DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollUpdated", CallbackFunctor(&scrollUpdated) ));
1174 DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollCompleted", CallbackFunctor(&scrollCompleted) ));
1176 Actor image = Actor::New();
1177 image.SetProperty( Actor::Property::SIZE, stageSize);
1178 image.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1179 image.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1180 scrollView.Add(image);
1184 // Do a pan starting from 100,100 and moving down diagonally.
1185 Vector2 pos(100.0f, 100.0f);
1186 uint32_t time = 100;
1187 TestStartPan( application, pos, pos, time );
1190 Wait(application, 100);
1192 for(int i = 0;i<20;i++)
1194 time += RENDER_FRAME_INTERVAL;
1195 TestMovePan( application, pos, time);
1201 time += RENDER_FRAME_INTERVAL;
1202 TestEndPan(application, pos, time );
1203 Wait(application, RENDER_DELAY_SCROLL);
1205 DALI_TEST_CHECK(scrollStarted);
1206 DALI_TEST_CHECK(scrollUpdated);
1207 DALI_TEST_CHECK(scrollCompleted);
1209 application.GetScene().Remove( scrollView );
1214 int UtcDaliToolkitScrollViewScrollSensitive(void)
1216 ToolkitTestApplication application;
1217 tet_infoline(" UtcDaliToolkitScrollViewScrollSensitive");
1219 // Set up a scrollView...
1220 ScrollView scrollView = ScrollView::New();
1221 scrollView.SetOvershootEnabled(true);
1222 application.GetScene().Add( scrollView );
1223 Vector2 stageSize = application.GetScene().GetSize();
1224 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1225 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1226 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1229 RulerPtr rulerX = new DefaultRuler();
1230 RulerPtr rulerY = new DefaultRuler();
1231 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1232 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1233 scrollView.SetRulerX(rulerX);
1234 scrollView.SetRulerY(rulerY);
1235 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1236 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1237 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1238 scrollView.SnapStartedSignal().Connect( &OnSnapStart );
1240 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1242 time +=Wait(application);
1244 // First try insensitive swipe.
1245 scrollView.SetScrollSensitive(false);
1246 PerformGestureSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, time, true);
1248 DALI_TEST_CHECK( !gOnScrollStartCalled );
1249 DALI_TEST_CHECK( !gOnScrollCompleteCalled );
1250 DALI_TEST_CHECK( !gOnSnapStartCalled );
1252 // Second try sensitive swipe.
1253 scrollView.SetScrollSensitive(true);
1254 PerformGestureSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, time, true);
1256 DALI_TEST_CHECK( gOnScrollStartCalled );
1257 DALI_TEST_CHECK( gOnScrollCompleteCalled );
1258 DALI_TEST_CHECK( gOnSnapStartCalled );
1262 int UtcDaliToolkitScrollViewAxisAutoLock(void)
1264 ToolkitTestApplication application;
1265 tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLock");
1267 // Set up a scrollView...
1268 ScrollView scrollView = ScrollView::New();
1269 application.GetScene().Add( scrollView );
1270 Vector2 stageSize = application.GetScene().GetSize();
1271 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1272 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1273 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1276 RulerPtr rulerX = new DefaultRuler();
1277 RulerPtr rulerY = new DefaultRuler();
1278 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1279 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1280 scrollView.SetRulerX(rulerX);
1281 scrollView.SetRulerY(rulerY);
1282 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1283 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1284 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1287 scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
1289 time += Wait(application);
1291 Vector2 startPosition = scrollView.GetCurrentScrollPosition();
1292 Vector2 dir(5.0f, 1.0f);
1294 // PerformGestureSwipe not used as a different initial direction was required
1296 Vector2 pos( CLAMP_TOUCH_START + Vector2(15.0f, 3.0f) );
1298 TestStartPan( application, CLAMP_TOUCH_START, pos, time );
1300 time += Wait(application);
1302 for( int i = 0; i<47; i++ )
1305 TestMovePan( application, pos, time );
1306 time += Wait( application );
1311 TestEndPan( application, pos, time );
1313 const Vector2 positionAfterNormal = scrollView.GetCurrentScrollPosition();
1316 scrollView.SetAxisAutoLock(true);
1317 DALI_TEST_CHECK(scrollView.GetAxisAutoLock());
1319 scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
1320 time += Wait(application);
1322 Vector2 pos2( CLAMP_TOUCH_START + Vector2(15.0f, 3.0f) );
1324 TestStartPan( application, CLAMP_TOUCH_START, pos2, time );
1326 time += Wait(application);
1328 for( int i = 0; i<47; i++ )
1331 TestMovePan( application, pos2, time );
1332 time += Wait( application );
1337 TestEndPan( application, pos2, time );
1339 const Vector2 positionAfterAutoLock = scrollView.GetCurrentScrollPosition();
1341 // compare how much the Y position has deviated for normal and autolock.
1342 const float devianceNormal = fabsf(startPosition.y - positionAfterNormal.y);
1343 const float devianceAutoLock = fabsf(startPosition.y - positionAfterAutoLock.y);
1345 // in auto-lock it should be a mostly horizontal pan (thus deviance should be much lower)
1346 DALI_TEST_CHECK(devianceAutoLock < devianceNormal);
1348 scrollView.SetAxisAutoLock(false);
1349 DALI_TEST_CHECK(!scrollView.GetAxisAutoLock());
1353 int UtcDaliToolkitScrollViewAxisAutoLockGradient(void)
1355 ToolkitTestApplication application;
1356 tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLockGradient");
1358 // Set up a scrollView...
1359 ScrollView scrollView = ScrollView::New();
1360 scrollView.SetAxisAutoLockGradient(0.5f);
1361 DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 0.5f, TEST_LOCATION);
1362 scrollView.SetAxisAutoLockGradient(1.0f);
1363 DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 1.0f, TEST_LOCATION);
1367 int UtcDaliToolkitScrollViewConstraints(void)
1369 ToolkitTestApplication application;
1370 tet_infoline(" UtcDaliToolkitScrollViewConstraints");
1372 // Set up a scrollView...
1373 ScrollView scrollView = ScrollView::New();
1374 application.GetScene().Add( scrollView );
1375 Vector2 stageSize = application.GetScene().GetSize();
1376 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1377 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1378 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1381 RulerPtr rulerX = new DefaultRuler();
1382 RulerPtr rulerY = new DefaultRuler();
1383 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1384 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1385 scrollView.SetRulerX(rulerX);
1386 scrollView.SetRulerY(rulerY);
1388 // Add an Actor to ScrollView,
1389 // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1390 gConstraintResult = Vector3::ZERO;
1391 Actor a = Actor::New();
1393 a.SetProperty( Actor::Property::POSITION, TEST_ACTOR_POSITION);
1396 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1397 constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
1398 constraint.SetRemoveAction(Constraint::Discard);
1399 scrollView.ApplyConstraintToChildren(constraint);
1402 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1404 gConstraintResult = Vector3::ZERO;
1405 scrollView.RemoveConstraintsFromChildren();
1408 DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
1412 int UtcDaliToolkitScrollViewBind(void)
1414 ToolkitTestApplication application;
1415 tet_infoline(" UtcDaliToolkitScrollViewBind");
1417 // Set up a scrollView...
1418 ScrollView scrollView = ScrollView::New();
1419 application.GetScene().Add( scrollView );
1420 Vector2 stageSize = application.GetScene().GetSize();
1421 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1422 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1423 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1426 RulerPtr rulerX = new DefaultRuler();
1427 RulerPtr rulerY = new DefaultRuler();
1428 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1429 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1430 scrollView.SetRulerX(rulerX);
1431 scrollView.SetRulerY(rulerY);
1433 // Add an Actor to ScrollView,
1434 // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1436 gConstraintResult = Vector3::ZERO;
1437 Actor a = Actor::New();
1439 a.SetProperty( Actor::Property::POSITION, TEST_ACTOR_POSITION);
1442 // apply this constraint to scrollview
1443 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1444 constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
1445 constraint.SetRemoveAction(Constraint::Discard);
1446 scrollView.ApplyConstraintToChildren(constraint);
1450 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1453 gConstraintResult = Vector3::ZERO;
1454 scrollView.UnbindActor( a );
1456 DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
1459 gConstraintResult = Vector3::ZERO;
1460 scrollView.BindActor( a );
1462 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1466 int UtcDaliToolkitScrollViewOvershoot(void)
1468 ToolkitTestApplication application;
1469 tet_infoline(" UtcDaliToolkitScrollViewOvershoot");
1471 // Set up a scrollView...
1472 ScrollView scrollView = ScrollView::New();
1473 scrollView.SetOvershootEnabled(true);
1476 Vector2 overshootSize = Vector2(100.0f,100.0f);
1477 scrollView.SetProperty( Scrollable::Property::OVERSHOOT_SIZE, overshootSize );
1478 DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_SIZE).Get<Vector2>(), overshootSize, TEST_LOCATION );
1480 application.GetScene().Add( scrollView );
1481 Vector2 stageSize = application.GetScene().GetSize();
1482 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1483 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1484 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1487 RulerPtr rulerX = new DefaultRuler();
1488 RulerPtr rulerY = new DefaultRuler();
1489 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1490 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1491 scrollView.SetRulerX(rulerX);
1492 scrollView.SetRulerY(rulerY);
1493 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1494 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1495 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1497 scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1498 time += Wait(application);
1500 // 1. Scroll page in NW (-500,-500 pixels), then inspect overshoot. (don't release touch)
1501 Vector2 currentPos = Vector2(100.0f, 100.0f);
1502 currentPos = PerformGestureSwipe(application, currentPos, Vector2(5.0f, 5.0f), 100, time, false);
1503 float overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1504 float overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1505 Vector2 positionValue = scrollView.GetCurrentProperty< Vector2 >( ScrollView::Property::SCROLL_POSITION );
1506 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1507 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1508 DALI_TEST_EQUALS(positionValue, Vector2::ZERO, TEST_LOCATION);
1510 float timeToReachOrigin;
1512 // Now release touch. Overshoot should snap back to zero.
1513 TestEndPan(application, currentPos, time);
1515 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1517 float minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1518 float maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1520 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1521 (timeToReachOrigin < maxTimeToReachOrigin) );
1523 // 2. Repeat Scroll, but this time change overshoot snap duration to shorter time
1524 scrollView.SetSnapOvershootDuration(TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION);
1526 currentPos = PerformGestureSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, time, false);
1527 // Now release touch. Overshoot should snap back to zero.
1528 TestEndPan(application, currentPos, time);
1529 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1531 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1532 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1534 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1535 (timeToReachOrigin < maxTimeToReachOrigin) );
1537 // 3. Repeat Scroll, but this time change overshoot snap duration to longer time.
1538 scrollView.SetSnapOvershootDuration(TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION);
1540 currentPos = PerformGestureSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, time, false);
1541 // Now release touch. Overshoot should snap back to zero.
1542 TestEndPan(application, currentPos, time);
1543 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1545 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1546 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1548 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1549 (timeToReachOrigin < maxTimeToReachOrigin) );
1551 // 4. Repeat Scroll, but this time change overshoot function.
1552 scrollView.SetSnapOvershootDuration(TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION);
1553 scrollView.SetSnapOvershootAlphaFunction(TestAlphaFunction);
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_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1561 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1563 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1564 (timeToReachOrigin < maxTimeToReachOrigin) );
1568 int UtcDaliToolkitScrollViewSnapAlphaFunction(void)
1570 ToolkitTestApplication application;
1571 tet_infoline(" UtcDaliToolkitScrollViewSnapAlphaFunction");
1573 // Set up a scrollView...
1574 ScrollView scrollView = ScrollView::New();
1575 scrollView.SetScrollSnapAlphaFunction( AlphaFunction::EASE_IN );
1576 DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_IN );
1577 scrollView.SetScrollSnapAlphaFunction( AlphaFunction::EASE_OUT );
1578 DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_OUT );
1580 scrollView.SetScrollFlickAlphaFunction( AlphaFunction::BOUNCE );
1581 DALI_TEST_CHECK( scrollView.GetScrollFlickAlphaFunction().GetBuiltinFunction() == AlphaFunction::BOUNCE );
1586 int UtcDaliToolkitScrollViewSnapDuration(void)
1588 ToolkitTestApplication application;
1589 tet_infoline(" UtcDaliToolkitScrollViewSnapDuration");
1591 // Set up a scrollView...
1592 ScrollView scrollView = ScrollView::New();
1593 scrollView.SetScrollSnapDuration( 1.0f );
1594 DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 1.0f, TEST_LOCATION );
1595 scrollView.SetScrollSnapDuration( 0.5f );
1596 DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 0.5f, TEST_LOCATION );
1598 scrollView.SetScrollFlickDuration( 2.0f );
1599 DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 2.0f, TEST_LOCATION );
1600 scrollView.SetScrollFlickDuration( 1.5f );
1601 DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 1.5f, TEST_LOCATION );
1605 int UtcDaliToolkitScrollViewSnapStartedSignalP(void)
1607 ToolkitTestApplication application;
1608 tet_infoline(" UtcDaliToolkitScrollViewSnapStartedSignalP");
1610 // Set up a scrollView...
1611 ScrollView scrollView = ScrollView::New();
1612 application.GetScene().Add( scrollView );
1613 Vector2 stageSize = application.GetScene().GetSize();
1614 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1615 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1616 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1619 RulerPtr rulerX = new DefaultRuler();
1620 RulerPtr rulerY = new DefaultRuler();
1621 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1622 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1623 scrollView.SetRulerX(rulerX);
1624 scrollView.SetRulerY(rulerY);
1625 scrollView.SnapStartedSignal().Connect( &OnSnapStart );
1627 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1629 time += Wait(application);
1631 // First try a snap.
1632 PerformGestureSwipe(application, CLAMP_TOUCH_START, Vector2(0.5f, 0.0f), 60, time, true);
1634 DALI_TEST_CHECK( gOnSnapStartCalled );
1635 DALI_TEST_CHECK( gLastSnapType == Toolkit::Snap );
1637 // Second try a swipe.
1638 PerformGestureSwipe(application, CLAMP_TOUCH_START, Vector2(20.0f, 0.0f), 60, time, true);
1640 DALI_TEST_CHECK( gOnSnapStartCalled );
1641 DALI_TEST_CHECK( gLastSnapType == Toolkit::Flick );
1645 int UtcDaliToolkitScrollViewGetCurrentPageP(void)
1647 ToolkitTestApplication application;
1648 tet_infoline(" UtcDaliToolkitScrollViewGetCurrentPageP");
1650 ScrollView scrollView = ScrollView::New();
1651 application.GetScene().Add( scrollView );
1652 RulerPtr rulerX = new FixedRuler( 100.0f );
1653 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1654 RulerPtr rulerY = new FixedRuler( 100.0f );
1655 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1657 scrollView.SetRulerX( rulerX );
1658 scrollView.SetRulerY( rulerY );
1660 scrollView.ScrollTo( 15 );
1661 Wait(application, RENDER_DELAY_SCROLL);
1662 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION );
1664 scrollView.ScrollTo( 3 );
1665 Wait(application, RENDER_DELAY_SCROLL);
1666 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION );
1668 scrollView.ScrollTo( 9 );
1669 Wait(application, RENDER_DELAY_SCROLL);
1670 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION );
1675 int UtcDaliToolkitScrollViewSetMaxOvershootP(void)
1677 ToolkitTestApplication application;
1678 tet_infoline(" UtcDaliToolkitScrollViewSetMaxOvershootP");
1680 // Set up a scrollView...
1681 ScrollView scrollView = ScrollView::New();
1682 application.GetScene().Add( scrollView );
1683 Vector2 stageSize = application.GetScene().GetSize();
1684 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1685 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1686 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1689 RulerPtr rulerX = new DefaultRuler();
1690 RulerPtr rulerY = new DefaultRuler();
1691 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1692 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1693 scrollView.SetRulerX(rulerX);
1694 scrollView.SetRulerY(rulerY);
1696 // Set the max overshoot to be 50 pixels in both X axis and Y axis
1697 scrollView.SetMaxOvershoot(50.0f, 50.0f);
1699 scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1701 time += Wait(application);
1703 // Scroll page in NW (-20,-20 pixels), then check that overshoot should be 0. (don't release touch)
1704 Vector2 currentPos = PerformGestureSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 10, time, false);
1705 float overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1706 float overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1707 DALI_TEST_EQUALS(overshootXValue, 0.0f, TEST_LOCATION);
1708 DALI_TEST_EQUALS(overshootYValue, 0.0f, TEST_LOCATION);
1710 time += Wait(application);
1711 // Scroll page further in NW (-105,-105 pixels), then check that overshoot should be around 0.5. (don't release touch)
1712 for(int i = 0; i<106; i++)
1714 TestMovePan(application, currentPos, time );
1715 currentPos += Vector2(1.0f, 1.0f);
1716 time += Wait(application);
1719 overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1720 overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1721 // The overshoot value is a 0.0f - 1.0f ranged value of the amount overshot related to the maximum overshoot.
1722 // EG. If we move 105, max overshoot is 50, then we overshot 50 / 105.
1723 float correctOvershootValue = 0.508f; // This was measured and then set as the limit
1724 DALI_TEST_EQUALS( overshootXValue, correctOvershootValue, 0.001f, TEST_LOCATION );
1725 DALI_TEST_EQUALS( overshootYValue, correctOvershootValue, 0.001f, TEST_LOCATION );
1727 // Scroll page further in NW (-25,-25 pixels), then check that overshoot should be now 1.0. (don't release touch)
1728 for(int i = 0;i<25;i++)
1730 TestMovePan(application, currentPos, time );
1731 currentPos += Vector2(1.0f, 1.0f); // Move in this direction
1732 time += Wait(application);
1735 overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1736 overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1737 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1738 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1740 // Change the max overshoot to be 250 pixels in both X axis and Y axis
1741 scrollView.SetMaxOvershoot(250.0f, 250.0f);
1742 time += Wait(application);
1744 // Check that overshoot should be now around 0.8.
1745 overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1746 overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1747 DALI_TEST_CHECK(overshootXValue > 0.79f && overshootXValue < 0.81f);
1748 DALI_TEST_CHECK(overshootYValue > 0.79f && overshootYValue < 0.81f);
1750 // Scroll page further in NW (-50,-50 pixels), then check that overshoot should be now 1.0. (don't release touch)
1751 for(int i = 0;i<50;i++)
1753 TestMovePan(application, currentPos, time );
1754 currentPos += Vector2(1.0f, 1.0f); // Move in this direction
1755 time += Wait(application);
1758 overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X );
1759 overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y );
1760 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1761 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1766 int UtcDaliToolkitScrollViewSetScrollingDirectionP(void)
1768 ToolkitTestApplication application;
1769 tet_infoline(" UtcDaliToolkitScrollViewSetScrollingDirectionP");
1771 // Set up a scrollView...
1772 ScrollView scrollView = ScrollView::New();
1773 application.GetScene().Add( scrollView );
1774 Vector2 stageSize = application.GetScene().GetSize();
1775 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1776 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1777 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1779 Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1781 scrollView.ScrollTo(START_POSITION, 0.0f);
1783 time += Wait(application);
1785 // Try a vertical swipe.
1786 // PerformGestureSwipe not used as a different initial direction was required
1788 Vector2 pos( START_POSITION + Vector2(0.0f, 15.0f) );
1789 TestStartPan( application, START_POSITION, pos, time );
1790 time += Wait(application);
1791 for( int i = 0; i<45; i++ )
1793 pos += Vector2(0.0f, 1.0f);
1794 TestMovePan( application, pos, time );
1795 time += Wait( application );
1797 pos += Vector2(0.0f, 1.0f);
1798 TestEndPan( application, pos, time );
1799 time += Wait( application );
1801 // Take into account resampling done when prediction is off.
1802 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1804 scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1806 scrollView.ScrollTo(START_POSITION, 0.0f);
1807 time += Wait(application);
1809 // Try a vertical swipe.
1810 // PerformGestureSwipe not used as a different initial direction was required
1811 pos = ( START_POSITION + Vector2(0.0f, 15.0f) );
1812 TestStartPan( application, START_POSITION, pos, time );
1813 time += Wait(application);
1814 for( int i = 0; i<45; i++ )
1816 pos += Vector2(0.0f, 1.0f);
1817 TestMovePan( application, pos, time );
1818 time += Wait( application );
1820 pos += Vector2(0.0f, 1.0f);
1821 TestEndPan( application, pos, time );
1822 time += Wait( application );
1824 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1826 scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1828 scrollView.ScrollTo(START_POSITION, 0.0f);
1830 time += Wait(application);
1832 // Try a vertical swipe.
1833 // PerformGestureSwipe not used as a different initial direction was required
1834 pos = ( START_POSITION + Vector2(0.0f, 15.0f) );
1835 TestStartPan( application, START_POSITION, pos, time );
1836 time += Wait(application);
1837 for( int i = 0; i<45; i++ )
1839 pos += Vector2(0.0f, 1.0f);
1840 TestMovePan( application, pos, time );
1841 time += Wait( application );
1843 pos += Vector2(0.0f, 1.0f);
1844 TestEndPan( application, pos, time );
1845 time += Wait( application );
1847 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1852 int UtcDaliToolkitScrollViewRemoveScrollingDirectionP(void)
1854 ToolkitTestApplication application;
1855 tet_infoline(" UtcDaliToolkitScrollViewRemoveScrollingDirectionP");
1857 // Set up a scrollView...
1858 ScrollView scrollView = ScrollView::New();
1859 application.GetScene().Add( scrollView );
1860 Vector2 stageSize = application.GetScene().GetSize();
1861 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
1862 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1863 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1865 Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1868 scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1870 scrollView.ScrollTo(START_POSITION, 0.0f);
1872 time += Wait(application);
1874 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION );
1876 // Try a vertical swipe.
1877 // PerformGestureSwipe not used as a different initial direction was required
1878 Vector2 pos( START_POSITION + Vector2(0.0f, 15.0f) );
1879 TestStartPan( application, START_POSITION, pos, time );
1880 time += Wait(application);
1881 for( int i = 0; i<45; i++ )
1883 pos += Vector2(0.0f, 1.0f);
1884 TestMovePan( application, pos, time );
1885 time += Wait( application );
1887 pos += Vector2(0.0f, 1.0f);
1888 TestEndPan( application, pos, time );
1889 time += Wait( application );
1891 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1893 scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1894 // When the horizontal direction is removed, there are no directions set and therefore all will work
1895 scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_HORIZONTAL);
1897 time += Wait(application);
1898 // Try a vertical swipe.
1899 Vector2 pos2( pos + Vector2(0.0f, 15.0f) );
1900 TestStartPan( application, pos, pos2, time );
1901 time += Wait(application);
1902 for( int i = 0; i<45; i++ )
1904 pos2 += Vector2(0.0f, 1.0f);
1905 TestMovePan( application, pos2, time );
1906 time += Wait( application );
1908 pos2 += Vector2(0.0f, 1.0f);
1909 TestEndPan( application, pos2, time );
1911 // The previous scroll should not have had any effect
1912 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1917 int UtcDaliToolkitScrollViewSetRulerXP(void)
1919 ToolkitTestApplication application;
1920 tet_infoline(" UtcDaliToolkitScrollViewSetRulerXP");
1922 ScrollView scrollView = ScrollView::New();
1923 application.GetScene().Add( scrollView );
1924 RulerPtr rulerX = new FixedRuler( 100.0f );
1925 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1927 scrollView.SetRulerX( rulerX );
1929 scrollView.ScrollTo( 1, 0.0f );
1931 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION );
1933 RulerPtr newRulerX = new FixedRuler( 200.0f );
1934 newRulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1936 scrollView.SetRulerX( newRulerX );
1938 scrollView.ScrollTo( 1, 0.0f );
1940 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 0.0f), TEST_LOCATION );
1945 int UtcDaliToolkitScrollViewSetRulerYP(void)
1947 ToolkitTestApplication application;
1948 tet_infoline(" UtcDaliToolkitScrollViewSetRulerYP");
1950 ScrollView scrollView = ScrollView::New();
1951 application.GetScene().Add( scrollView );
1953 RulerPtr rulerY = new FixedRuler( 200.0f );
1954 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1956 scrollView.SetRulerY( rulerY );
1958 scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f );
1960 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 350.0f), TEST_LOCATION );
1962 RulerPtr newRulerY = new FixedRuler( 100.0f );
1963 newRulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
1964 scrollView.SetRulerY( newRulerY );
1966 scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f );
1968 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 200.0f), TEST_LOCATION );
1973 int UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP(void)
1975 ToolkitTestApplication application;
1976 tet_infoline(" UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP");
1978 ScrollView scrollView = ScrollView::New();
1979 scrollView.SetMinimumSpeedForFlick(25.0f);
1980 DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 25.0f, TEST_LOCATION );
1981 scrollView.SetMinimumSpeedForFlick(60.0f);
1982 DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 60.0f, TEST_LOCATION );
1986 int UtcDaliToolkitScrollViewSetMinimumDistanceForFlickP(void)
1988 ToolkitTestApplication application;
1989 tet_infoline(" UtcDaliToolkitScrollViewSetMinimumDistanceForFlick");
1991 ScrollView scrollView = ScrollView::New();
1993 scrollView.SetMinimumDistanceForFlick(Vector2(30.0f, 15.0f));
1994 DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(30.0f, 15.0f), TEST_LOCATION );
1995 scrollView.SetMinimumDistanceForFlick(Vector2(60.0f, 30.0f));
1996 DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(60.0f, 30.0f), TEST_LOCATION);
2000 int UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP(void)
2002 ToolkitTestApplication application;
2003 tet_infoline(" UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP");
2005 ScrollView scrollView = ScrollView::New();
2006 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
2007 scrollView.SetWheelScrollDistanceStep(Vector2(30.0f, 15.0f));
2008 DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(30.0f, 15.0f), TEST_LOCATION );
2009 scrollView.SetWheelScrollDistanceStep(Vector2(60.0f, 30.0f));
2010 DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(60.0f, 30.0f), TEST_LOCATION);
2014 int UtcDaliToolkitScrollViewApplyEffectP(void)
2016 ToolkitTestApplication application;
2017 tet_infoline(" UtcDaliToolkitScrollViewApplyEffectP");
2019 // Create a ScrollView
2020 ScrollView scrollView = ScrollView::New();
2022 // Create two scroll view effects
2023 Dali::Path path = Dali::Path::New();
2024 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);
2025 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);
2027 // Apply both effects
2028 scrollView.ApplyEffect(effect);
2029 scrollView.ApplyEffect(newEffect);
2031 DALI_TEST_CHECK( true );
2036 int UtcDaliToolkitScrollViewApplyEffectN(void)
2038 ToolkitTestApplication application;
2039 tet_infoline(" UtcDaliToolkitScrollViewApplyEffectN");
2041 // Create a ScrollView
2042 ScrollView scrollView = ScrollView::New();
2044 // Create two scroll view effects
2045 Dali::Path path = Dali::Path::New();
2046 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);
2047 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);
2049 // Apply both effects
2050 scrollView.ApplyEffect(effect);
2051 scrollView.ApplyEffect(newEffect);
2053 // Attempt to apply the same effect again
2056 scrollView.ApplyEffect(newEffect);
2057 tet_result( TET_FAIL );
2059 catch ( DaliException& e )
2061 DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
2067 int UtcDaliToolkitScrollViewRemoveEffectP(void)
2069 ToolkitTestApplication application;
2070 tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectP");
2072 // Create a ScrollView
2073 ScrollView scrollView = ScrollView::New();
2075 // Create two scroll view effects
2076 Dali::Path path = Dali::Path::New();
2077 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);
2078 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);
2080 // Apply both effects
2081 scrollView.ApplyEffect(effect);
2082 scrollView.ApplyEffect(newEffect);
2084 // Remove both effects
2085 scrollView.RemoveEffect(effect);
2086 scrollView.RemoveEffect(newEffect);
2088 DALI_TEST_CHECK( true );
2093 int UtcDaliToolkitScrollViewRemoveEffectN(void)
2095 ToolkitTestApplication application;
2096 tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectN");
2098 // Create a ScrollView
2099 ScrollView scrollView = ScrollView::New();
2101 // Create two scroll view effects
2102 Dali::Path path = Dali::Path::New();
2103 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);
2104 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);
2106 // Apply the first effect
2107 scrollView.ApplyEffect(effect);
2109 // Attempt to remove the second effect which has not been applied to scroll view
2112 scrollView.RemoveEffect(newEffect);
2113 tet_result( TET_FAIL );
2115 catch ( DaliException& e )
2117 DALI_TEST_ASSERT( e, "effectExistedInScrollView", TEST_LOCATION );
2123 int UtcDaliToolkitScrollViewRemoveAllEffectsP(void)
2125 ToolkitTestApplication application;
2126 tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsP");
2128 // Create a ScrollView
2129 ScrollView scrollView = ScrollView::New();
2131 // Create two scroll view effects
2132 Dali::Path path = Dali::Path::New();
2133 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);
2134 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);
2136 // Apply both effects
2137 scrollView.ApplyEffect(effect);
2138 scrollView.ApplyEffect(newEffect);
2140 // Attempt to apply the same first effect again
2143 scrollView.ApplyEffect(effect);
2144 tet_result( TET_FAIL );
2146 catch ( DaliException& e )
2148 DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
2151 // Remove both effects
2152 scrollView.RemoveAllEffects();
2154 // Apply both effects again
2155 scrollView.ApplyEffect(effect);
2156 scrollView.ApplyEffect(newEffect);
2158 DALI_TEST_CHECK( true );
2163 int UtcDaliToolkitScrollViewRemoveAllEffectsN(void)
2165 ToolkitTestApplication application;
2166 tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsN");
2168 // Create a ScrollView
2169 ScrollView scrollView = ScrollView::New();
2171 // Remove effects when there is no effect applied previously
2172 scrollView.RemoveAllEffects();
2174 DALI_TEST_CHECK( true );
2179 int UtcDaliToolkitScrollViewSetOvershootEnabledP(void)
2181 ToolkitTestApplication application;
2182 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEnabledP");
2184 ScrollView scrollView = ScrollView::New();
2186 scrollView.SetOvershootEnabled(true);
2187 DALI_TEST_CHECK(scrollView.IsOvershootEnabled());
2189 scrollView.SetOvershootEnabled(false);
2190 DALI_TEST_CHECK(!scrollView.IsOvershootEnabled());
2195 int UtcDaliToolkitScrollViewSetOvershootEffectColorP(void)
2197 ToolkitTestApplication application;
2198 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEffectColorP");
2200 ScrollView scrollView = ScrollView::New();
2202 scrollView.SetOvershootEffectColor(Dali::Color::RED);
2203 DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::RED, TEST_LOCATION);
2205 scrollView.SetOvershootEffectColor(Dali::Color::YELLOW);
2206 DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::YELLOW, TEST_LOCATION);
2211 int UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP(void)
2213 ToolkitTestApplication application;
2214 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP");
2216 ScrollView scrollView = ScrollView::New();
2218 scrollView.SetOvershootAnimationSpeed(55.0f);
2219 DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 55.0f, TEST_LOCATION);
2221 scrollView.SetOvershootAnimationSpeed(120.0f);
2222 DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 120.0f, TEST_LOCATION);
2227 int UtcDaliToolkitScrollViewGetSet(void)
2229 ToolkitTestApplication application;
2230 tet_infoline(" UtcDaliToolkitScrollViewGetSet");
2231 ScrollView scrollView = ScrollView::New();
2232 scrollView.SetMaxFlickSpeed(0.5f);
2233 DALI_TEST_EQUALS(scrollView.GetMaxFlickSpeed(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
2234 scrollView.SetFrictionCoefficient(0.6f);
2235 DALI_TEST_EQUALS(scrollView.GetFrictionCoefficient(), 0.6f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
2236 scrollView.SetFlickSpeedCoefficient(0.7f);
2237 DALI_TEST_EQUALS(scrollView.GetFlickSpeedCoefficient(), 0.7f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
2241 int UtcDaliToolkitScrollViewRulerDomainConstructorP(void)
2243 ToolkitTestApplication application;
2245 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2246 DALI_TEST_EQUALS( domainX.min, 0.0f, TEST_LOCATION);
2247 DALI_TEST_EQUALS( domainX.max, 200.0f, TEST_LOCATION);
2248 DALI_TEST_EQUALS( domainX.enabled, true, TEST_LOCATION);
2250 RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
2251 DALI_TEST_EQUALS( domainY.min, 100.0f, TEST_LOCATION);
2252 DALI_TEST_EQUALS( domainY.max, 500.0f, TEST_LOCATION);
2253 DALI_TEST_EQUALS( domainY.enabled, false, TEST_LOCATION);
2258 int UtcDaliToolkitScrollViewRulerDomainGetSizeP(void)
2260 ToolkitTestApplication application;
2262 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2263 DALI_TEST_EQUALS( domainX.GetSize(), 200.0f, TEST_LOCATION);
2265 RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
2266 DALI_TEST_EQUALS( domainY.GetSize(), 400.0f, TEST_LOCATION);
2271 int UtcDaliToolkitScrollViewRulerDomainClampP(void)
2273 ToolkitTestApplication application;
2275 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2277 float value = domainX.Clamp(50.0f, 100.0f, 1.0f);
2278 DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
2280 value = domainX.Clamp(300.0f, 20.0f, 1.0f);
2281 DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
2283 value = domainX.Clamp(300.0f, 20.0f, 0.5f);
2284 DALI_TEST_EQUALS( value, 80.0f, TEST_LOCATION);
2286 value = domainX.Clamp(250.0f, 200.0f, 2.0f);
2287 DALI_TEST_EQUALS( value, 200.0f, TEST_LOCATION);
2292 int UtcDaliToolkitScrollViewRulerDomainClampWithStateP(void)
2294 ToolkitTestApplication application;
2296 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2299 float value = domainX.Clamp(50.0f, 100.0f, 1.0f, clamped);
2300 DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
2301 DALI_TEST_EQUALS( clamped, Dali::Toolkit::NotClamped, TEST_LOCATION);
2303 value = domainX.Clamp(-100.0f, 200.0f, 1.0f, clamped);
2304 DALI_TEST_EQUALS( value, 0.0f, TEST_LOCATION);
2305 DALI_TEST_EQUALS( clamped, Dali::Toolkit::ClampedToMin, TEST_LOCATION);
2307 value = domainX.Clamp(300.0f, 20.0f, 1.0f, clamped);
2308 DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
2309 DALI_TEST_EQUALS( clamped, Dali::Toolkit::ClampedToMax, TEST_LOCATION);
2314 int UtcDaliToolkitScrollViewDefaultRulerConstructorP(void)
2316 ToolkitTestApplication application;
2317 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerConstructorP");
2319 RulerPtr defaultRuler = new DefaultRuler();
2320 DALI_TEST_CHECK( defaultRuler );
2325 int UtcDaliToolkitScrollViewDefaultRulerDestructorP(void)
2327 ToolkitTestApplication application;
2328 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerDestructorP");
2330 RulerPtr defaultRuler = new DefaultRuler();
2332 DALI_TEST_CHECK( true );
2336 int UtcDaliToolkitScrollViewFixedRulerConstructorP(void)
2338 ToolkitTestApplication application;
2339 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerConstructorP");
2341 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2342 DALI_TEST_CHECK( fixedRuler );
2344 fixedRuler = new FixedRuler( 0.0f );
2345 DALI_TEST_CHECK( fixedRuler );
2350 int UtcDaliToolkitScrollViewFixedRulerDestructorP(void)
2352 ToolkitTestApplication application;
2353 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerDestructorP");
2355 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2357 DALI_TEST_CHECK( true );
2361 int UtcDaliToolkitScrollViewRulerGetTypeP(void)
2363 ToolkitTestApplication application;
2364 tet_infoline(" UtcDaliToolkitScrollViewRulerGetTypeP");
2366 RulerPtr defaultRuler = new DefaultRuler();
2367 DALI_TEST_CHECK( defaultRuler );
2368 DALI_TEST_EQUALS( defaultRuler->GetType(), Dali::Toolkit::Ruler::Free, TEST_LOCATION);
2370 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2371 DALI_TEST_CHECK( fixedRuler );
2372 DALI_TEST_EQUALS( fixedRuler->GetType(), Dali::Toolkit::Ruler::Fixed, TEST_LOCATION);
2377 int UtcDaliToolkitScrollViewRulerGetExtensionP(void)
2379 ToolkitTestApplication application;
2380 tet_infoline(" UtcDaliToolkitScrollViewRulerGetExtensionP");
2382 RulerPtr defaultRuler = new DefaultRuler();
2383 DALI_TEST_CHECK( defaultRuler );
2384 DALI_TEST_CHECK( !defaultRuler->GetExtension() );
2386 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2387 DALI_TEST_CHECK( fixedRuler );
2388 DALI_TEST_CHECK( !fixedRuler->GetExtension() );
2393 int UtcDaliToolkitScrollViewRulerEnableDisable(void)
2395 ToolkitTestApplication application;
2396 tet_infoline(" UtcDaliToolkitScrollViewRulerEnableDisable");
2398 RulerPtr ruler = new DefaultRuler();
2400 DALI_TEST_CHECK( ruler->IsEnabled() );
2402 DALI_TEST_CHECK( !ruler->IsEnabled() );
2404 DALI_TEST_CHECK( ruler->IsEnabled() );
2408 int UtcDaliToolkitScrollViewRulerDomainEnableDisable(void)
2410 ToolkitTestApplication application;
2411 tet_infoline(" UtcDaliToolkitScrollViewRulerDomainEnableDisable");
2413 RulerPtr ruler = new DefaultRuler();
2414 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
2416 ruler->SetDomain( RulerDomain(0.0f, 100.0f, true) );
2417 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 100.0f, TEST_LOCATION );
2418 DALI_TEST_EQUALS( ruler->Clamp(-200.0f), 0.0f, TEST_LOCATION );
2419 DALI_TEST_EQUALS( ruler->Clamp(200.0f), 100.0f, TEST_LOCATION );
2421 ruler->DisableDomain();
2422 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
2423 DALI_TEST_EQUALS( ruler->Clamp(-200.0f), -200.0f, TEST_LOCATION );
2424 DALI_TEST_EQUALS( ruler->Clamp(200.0f), 200.0f, TEST_LOCATION );
2428 int UtcDaliToolkitScrollViewRulerSnapAndClamp(void)
2430 ToolkitTestApplication application;
2431 tet_infoline(" UtcDaliToolkitScrollViewRulerSnapAndClamp");
2433 RulerPtr ruler = new FixedRuler( 50.0f );
2434 ruler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2436 // default testing. (snap and clamp)
2437 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f), 50.0f, TEST_LOCATION);
2438 DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f), 50.0f, TEST_LOCATION);
2439 DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f), 0.0f, TEST_LOCATION);
2440 DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f), 0.0f, TEST_LOCATION);
2441 DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f), 400.0f, TEST_LOCATION);
2442 DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f), 400.0f, TEST_LOCATION);
2445 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
2446 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.5f), 50.0f, TEST_LOCATION); // No Flick
2447 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
2449 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
2450 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.5f), 0.0f, TEST_LOCATION); // No Flick
2451 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
2454 DALI_TEST_EQUALS( ruler->SnapAndClamp(-10.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (over left boundary)
2455 DALI_TEST_EQUALS( ruler->SnapAndClamp(-5.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (slightly ovr left boundary)
2456 DALI_TEST_EQUALS( ruler->SnapAndClamp(300.0f, 0.5f, 10.0f), 300.0f, TEST_LOCATION); // 10 units long (not over a boundary)
2457 DALI_TEST_EQUALS( ruler->SnapAndClamp(395.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (slightly over right boundary)
2458 DALI_TEST_EQUALS( ruler->SnapAndClamp(500.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (over right boundary)
2461 DALI_TEST_EQUALS( ruler->SnapAndClamp(-100.0f, 0.5f, 0.0f, 2.0f), 0.0f, TEST_LOCATION);
2462 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 2.0f), 50.0f, TEST_LOCATION);
2463 DALI_TEST_EQUALS( ruler->SnapAndClamp(700.0f, 0.5f, 0.0f, 2.0f), 700.0f, TEST_LOCATION);
2464 DALI_TEST_EQUALS( ruler->SnapAndClamp(850.0f, 0.5f, 0.0f, 2.0f), 800.0f, TEST_LOCATION);
2466 // clamp state testing.
2468 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
2469 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2470 DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
2471 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2472 DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
2473 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2474 DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
2475 DALI_TEST_EQUALS( clamped, ClampedToMin, TEST_LOCATION );
2476 DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
2477 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2478 DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
2479 DALI_TEST_EQUALS( clamped, ClampedToMax, TEST_LOCATION );
2483 int UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP(void)
2485 ToolkitTestApplication application;
2486 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP");
2488 RulerPtr rulerNormal = new FixedRuler( 25.0f );
2489 rulerNormal->SetDomain( RulerDomain(10.0f, 90.0f, true) );
2491 unsigned int volume;
2494 position = rulerNormal->GetPositionFromPage(1, volume, true);
2495 DALI_TEST_EQUALS( position, 35.0f, TEST_LOCATION );
2496 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
2498 position = rulerNormal->GetPositionFromPage(2, volume, true);
2499 DALI_TEST_EQUALS( position, 60.0f, TEST_LOCATION );
2500 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
2502 // Disable the ruler
2503 rulerNormal->Disable();
2505 position = rulerNormal->GetPositionFromPage(1, volume, true);
2506 DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
2507 DALI_TEST_EQUALS( volume, 1u, TEST_LOCATION );
2509 position = rulerNormal->GetPositionFromPage(2, volume, true);
2510 DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
2511 DALI_TEST_EQUALS( volume, 2u, TEST_LOCATION );
2516 int UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP(void)
2518 ToolkitTestApplication application;
2519 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP");
2521 RulerPtr defaultRuler = new DefaultRuler();
2522 DALI_TEST_CHECK( defaultRuler );
2523 DALI_TEST_EQUALS( defaultRuler->GetTotalPages(), 1u, TEST_LOCATION);
2528 int UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP(void)
2530 ToolkitTestApplication application;
2531 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP");
2533 RulerPtr defaultRuler = new DefaultRuler();
2534 DALI_TEST_CHECK( defaultRuler );
2535 DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(100.0f, true), 0u, TEST_LOCATION);
2536 DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(-300.0f, false), 0u, TEST_LOCATION);
2541 int UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP(void)
2543 ToolkitTestApplication application;
2544 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP");
2546 RulerPtr defaultRuler = new DefaultRuler();
2547 DALI_TEST_CHECK( defaultRuler );
2549 unsigned int volume;
2550 DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(0, volume, true), 0.0f, TEST_LOCATION);
2551 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
2553 DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(3, volume, false), 0.0f, TEST_LOCATION);
2554 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
2559 int UtcDaliToolkitScrollViewDefaultRulerSnapP(void)
2561 ToolkitTestApplication application;
2562 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerSnapP");
2564 RulerPtr defaultRuler = new DefaultRuler();
2565 DALI_TEST_CHECK( defaultRuler );
2567 DALI_TEST_EQUALS( defaultRuler->Snap(50.0f, 0.5f), 50.0f, TEST_LOCATION);
2568 DALI_TEST_EQUALS( defaultRuler->Snap(-120.0f, 1.0f), -120.0f, TEST_LOCATION);
2573 int UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP(void)
2575 ToolkitTestApplication application;
2576 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP");
2578 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2579 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2581 fixedRuler->Enable();
2582 DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 4u, TEST_LOCATION);
2584 fixedRuler->Disable();
2585 DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 1u, TEST_LOCATION);
2590 int UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP(void)
2592 ToolkitTestApplication application;
2593 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP");
2595 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2596 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2598 fixedRuler->Enable();
2599 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 3u, TEST_LOCATION);
2600 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2601 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 1u, TEST_LOCATION);
2602 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2604 fixedRuler->Disable();
2605 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2606 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
2607 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2608 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2610 // Set domain size to be smaller than the ruler space
2611 fixedRuler->SetDomain( RulerDomain(0.0f, 50.0f, true) );
2613 fixedRuler->Enable();
2614 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2615 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2616 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, 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);
2628 int UtcDaliToolkitScrollViewFixedRulerSnapP(void)
2630 ToolkitTestApplication application;
2631 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerSnapP");
2633 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2634 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2636 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.0f), -100.0f, TEST_LOCATION);
2637 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.0f), -100.0f, TEST_LOCATION);
2638 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.0f), -200.0f, TEST_LOCATION);
2639 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.0f), -500.0f, TEST_LOCATION);
2640 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.0f), 0.0f, TEST_LOCATION);
2641 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.0f), 0.0f, TEST_LOCATION);
2642 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.0f), 0.0f, TEST_LOCATION);
2643 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.0f), 100.0f, TEST_LOCATION);
2644 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.0f), 100.0f, TEST_LOCATION);
2645 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.0f), 200.0f, TEST_LOCATION);
2646 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.0f), 600.0f, TEST_LOCATION);
2648 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.5f), 0.0f, TEST_LOCATION);
2649 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.5f), -100.0f, TEST_LOCATION);
2650 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.5f), -100.0f, TEST_LOCATION);
2651 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.5f), -500.0f, TEST_LOCATION);
2652 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.5f), 0.0f, TEST_LOCATION);
2653 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.5f), 100.0f, TEST_LOCATION);
2654 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.5f), 100.0f, TEST_LOCATION);
2655 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.5f), 100.0f, TEST_LOCATION);
2656 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.5f), 100.0f, TEST_LOCATION);
2657 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.5f), 300.0f, TEST_LOCATION);
2658 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.5f), 600.0f, TEST_LOCATION);
2660 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 1.0f), 0.0f, TEST_LOCATION);
2661 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 1.0f), 0.0f, TEST_LOCATION);
2662 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 1.0f), -100.0f, TEST_LOCATION);
2663 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 1.0f), -400.0f, TEST_LOCATION);
2664 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 1.0f), 100.0f, TEST_LOCATION);
2665 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 1.0f), 100.0f, TEST_LOCATION);
2666 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 1.0f), 100.0f, TEST_LOCATION);
2667 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 1.0f), 200.0f, TEST_LOCATION);
2668 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 1.0f), 200.0f, TEST_LOCATION);
2669 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 1.0f), 300.0f, TEST_LOCATION);
2670 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 1.0f), 700.0f, TEST_LOCATION);
2675 int UtcDaliToolkitScrollViewConstraintsMove(void)
2677 ToolkitTestApplication application;
2678 tet_infoline(" UtcDaliToolkitScrollViewConstraintsMove");
2680 // Set up a scrollView...
2681 ScrollView scrollView = ScrollView::New();
2682 application.GetScene().Add( scrollView );
2683 Vector2 stageSize = application.GetScene().GetSize();
2684 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
2685 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
2686 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2689 RulerPtr rulerX = new DefaultRuler();
2690 RulerPtr rulerY = new DefaultRuler();
2691 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
2692 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
2693 scrollView.SetRulerX(rulerX);
2694 scrollView.SetRulerY(rulerY);
2696 // Add an Actor to ScrollView,
2697 Actor a = Actor::New();
2699 a.SetProperty( Actor::Property::POSITION, TEST_ACTOR_POSITION);
2702 const Vector2 target = Vector2(100.0f, 100.0f);
2703 const Vector2 target2 = Vector2(200.0f, 200.0f);
2705 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, MoveActorConstraint );
2706 constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
2707 constraint.SetRemoveAction(Constraint::Discard);
2708 scrollView.ApplyConstraintToChildren(constraint);
2710 scrollView.ScrollTo( target, 0.0f );
2712 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
2713 scrollView.ScrollTo( target2 );
2714 Wait(application, RENDER_DELAY_SCROLL);
2715 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
2720 int UtcDaliToolkitScrollViewConstraintsWrap(void)
2722 ToolkitTestApplication application;
2723 tet_infoline(" UtcDaliToolkitScrollViewConstraintsWrap");
2725 // Set up a scrollView...
2726 ScrollView scrollView = ScrollView::New();
2727 application.GetScene().Add( scrollView );
2728 Vector2 stageSize = application.GetScene().GetSize();
2729 scrollView.SetProperty( Actor::Property::SIZE, stageSize);
2730 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
2731 scrollView.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
2734 RulerPtr rulerX = new DefaultRuler();
2735 RulerPtr rulerY = new DefaultRuler();
2736 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
2737 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
2738 scrollView.SetRulerX(rulerX);
2739 scrollView.SetRulerY(rulerY);
2741 // Add an Actor to ScrollView,
2742 Actor a = Actor::New();
2744 a.SetProperty( Actor::Property::POSITION, TEST_ACTOR_POSITION);
2747 const Vector2 target = Vector2(100.0f, 100.0f);
2748 const Vector2 target2 = Vector2(200.0f, 200.0f);
2750 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, WrapActorConstraint );
2751 constraint.AddSource( LocalSource( Actor::Property::SCALE ) );
2752 constraint.AddSource( LocalSource( Actor::Property::ANCHOR_POINT ) );
2753 constraint.AddSource( LocalSource( Actor::Property::SIZE ) );
2754 constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
2755 constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
2756 constraint.AddSource( Source( scrollView, Toolkit::ScrollView::Property::WRAP ) );
2757 constraint.SetRemoveAction(Constraint::Discard);
2758 scrollView.ApplyConstraintToChildren(constraint);
2760 scrollView.ScrollTo( target, 0.0f );
2762 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
2763 scrollView.ScrollTo( target2 );
2764 Wait(application, RENDER_DELAY_SCROLL);
2765 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
2767 scrollView.Remove(a);
2773 // Non-API test (so no P or N variant).
2774 int UtcDaliToolkitScrollViewGesturePageLimit(void)
2776 ToolkitTestApplication application;
2777 tet_infoline( " UtcDaliToolkitScrollViewGesturePageLimit" );
2779 // Set up a scrollView.
2780 ScrollView scrollView = ScrollView::New();
2782 // Do not rely on stage size for UTC tests.
2783 Vector2 viewPageSize( 720.0f, 1280.0f );
2784 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
2785 scrollView.SetProperty( Actor::Property::SIZE, viewPageSize );
2786 scrollView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
2787 scrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
2788 scrollView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ));
2791 // We set the X ruler to fixed to give us pages to snap to.
2792 Dali::Toolkit::FixedRuler* rulerX = new Dali::Toolkit::FixedRuler( viewPageSize.width );
2793 // Note: The 3x page width is arbitary, but we need enough to show that we are
2794 // capping page movement by the page limiter, and not the domain.
2795 rulerX->SetDomain( Dali::Toolkit::RulerDomain( 0.0f, viewPageSize.width * 3.0f, false ) );
2796 Dali::Toolkit::RulerPtr rulerY = new Dali::Toolkit::DefaultRuler();
2798 scrollView.SetRulerX( rulerX );
2799 scrollView.SetRulerY( rulerY );
2801 scrollView.SetWrapMode( false );
2802 scrollView.SetScrollSensitive( true );
2804 application.GetScene().Add( scrollView );
2806 // Set up a gesture to perform.
2807 Vector2 startPos( 50.0f, 0.0f );
2808 Vector2 direction( -5.0f, 0.0f );
2811 // Force starting position.
2812 scrollView.ScrollTo( startPos, 0.0f );
2814 time += Wait( application );
2816 // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
2817 Vector2 currentPos( PerformGestureSwipe( application, startPos, direction, frames - 1, time, false ) );
2819 // Confirm the final X coord has not moved more than one page from the start X position.
2820 DALI_TEST_GREATER( ( startPos.x + viewPageSize.width ), scrollView.GetCurrentScrollPosition().x, TEST_LOCATION );
2822 // Finish the gesture and wait for the snap.
2823 currentPos += direction;
2824 TestEndPan(application, currentPos, time);
2825 // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
2826 time += Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
2828 // Confirm the final X coord has snapped to exactly one page ahead of the start page.
2829 DALI_TEST_EQUALS( viewPageSize.width, scrollView.GetCurrentScrollPosition().x, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2834 int UtcDaliScrollViewSetGetProperty(void)
2836 ToolkitTestApplication application;
2838 // Create the ScrollView actor
2839 ScrollView scrollView = ScrollView::New();
2840 DALI_TEST_CHECK(scrollView);
2842 // Event side properties
2844 // Test "wrapEnabled" property
2845 DALI_TEST_CHECK( scrollView.GetPropertyIndex("wrapEnabled") == ScrollView::Property::WRAP_ENABLED );
2846 scrollView.SetProperty( ScrollView::Property::WRAP_ENABLED, true );
2847 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WRAP_ENABLED).Get<bool>(), true, TEST_LOCATION );
2849 // Test "panningEnabled" property
2850 DALI_TEST_CHECK( scrollView.GetPropertyIndex("panningEnabled") == ScrollView::Property::PANNING_ENABLED );
2851 scrollView.SetProperty( ScrollView::Property::PANNING_ENABLED, false );
2852 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::PANNING_ENABLED).Get<bool>(), false, TEST_LOCATION );
2854 // Test "axisAutoLockEnabled" property
2855 DALI_TEST_CHECK( scrollView.GetPropertyIndex("axisAutoLockEnabled") == ScrollView::Property::AXIS_AUTO_LOCK_ENABLED );
2856 scrollView.SetProperty( ScrollView::Property::AXIS_AUTO_LOCK_ENABLED, false );
2857 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::AXIS_AUTO_LOCK_ENABLED).Get<bool>(), false, TEST_LOCATION );
2859 // Test "wheelScrollDistanceStep" property
2860 DALI_TEST_CHECK( scrollView.GetPropertyIndex("wheelScrollDistanceStep") == ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP );
2861 scrollView.SetProperty( ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP, Vector2(100.0f, 50.0f) );
2862 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP).Get<Vector2>(), Vector2(100.0f, 50.0f), TEST_LOCATION );
2864 // Test "overshootEnabled" property
2865 DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootEnabled") == Scrollable::Property::OVERSHOOT_ENABLED );
2866 DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), scrollView.IsOvershootEnabled(), TEST_LOCATION );
2867 scrollView.SetProperty( Scrollable::Property::OVERSHOOT_ENABLED, false );
2868 DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), false, TEST_LOCATION );
2870 // Animatable properties
2872 // Test "scrollPosition" property
2873 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPosition") == ScrollView::Property::SCROLL_POSITION );
2874 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(320.0f, 550.0f) );
2876 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION).Get<Vector2>(), Vector2(320.0f, 550.0f), TEST_LOCATION );
2878 // Test "scrollPrePosition", "scrollPrePositionX" and "scrollPrePositionY" properties
2879 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePosition") == ScrollView::Property::SCROLL_PRE_POSITION );
2880 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION, Vector2(300.0f, 500.0f) );
2882 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION).Get<Vector2>(), Vector2(300.0f, 500.0f), TEST_LOCATION );
2884 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionX") == ScrollView::Property::SCROLL_PRE_POSITION_X );
2885 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionY") == ScrollView::Property::SCROLL_PRE_POSITION_Y );
2886 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_X).Get<float>(), 300.0f, TEST_LOCATION );
2887 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_Y).Get<float>(), 500.0f, TEST_LOCATION );
2888 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_X, 400.0f );
2889 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_Y, 600.0f );
2891 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_X).Get<float>(), 400.0f, TEST_LOCATION );
2892 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_Y).Get<float>(), 600.0f, TEST_LOCATION );
2893 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION).Get<Vector2>(), Vector2(400.0f, 600.0f), TEST_LOCATION );
2895 // Test "scrollPrePositionMax", "scrollPrePositionMaxX" and "scrollPrePositionMaxY" properties
2896 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMax") == ScrollView::Property::SCROLL_PRE_POSITION_MAX );
2897 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX, Vector2(100.0f, 200.0f) );
2899 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX).Get<Vector2>(), Vector2(100.0f, 200.0f), TEST_LOCATION );
2901 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMaxX") == ScrollView::Property::SCROLL_PRE_POSITION_MAX_X );
2902 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMaxY") == ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y );
2903 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_X).Get<float>(), 100.0f, TEST_LOCATION );
2904 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y).Get<float>(), 200.0f, TEST_LOCATION );
2905 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX_X, 300.0f );
2906 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y, 400.0f );
2908 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_X).Get<float>(), 300.0f, TEST_LOCATION );
2909 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y).Get<float>(), 400.0f, TEST_LOCATION );
2910 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX).Get<Vector2>(), Vector2(300.0f, 400.0f), TEST_LOCATION );
2912 // Test "overshootX" property
2913 DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootX") == ScrollView::Property::OVERSHOOT_X );
2914 scrollView.SetProperty( ScrollView::Property::OVERSHOOT_X, 0.8f );
2916 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::OVERSHOOT_X).Get<float>(), 0.8f, TEST_LOCATION );
2918 // Test "overshootY" property
2919 DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootY") == ScrollView::Property::OVERSHOOT_Y );
2920 scrollView.SetProperty( ScrollView::Property::OVERSHOOT_Y, 0.8f );
2922 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y).Get<float>(), 0.8f, TEST_LOCATION );
2924 // Test "scrollFinal", "scrollFinalX" and "scrollFinalY" properties
2925 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinal") == ScrollView::Property::SCROLL_FINAL );
2926 scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL, Vector2(200.0f, 300.0f) );
2928 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL).Get<Vector2>(), Vector2(200.0f, 300.0f), TEST_LOCATION );
2930 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinalX") == ScrollView::Property::SCROLL_FINAL_X );
2931 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinalY") == ScrollView::Property::SCROLL_FINAL_Y );
2932 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_X).Get<float>(), 200.0f, TEST_LOCATION );
2933 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_Y).Get<float>(), 300.0f, TEST_LOCATION );
2934 scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL_X, 500.0f );
2935 scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL_Y, 600.0f );
2937 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_X).Get<float>(), 500.0f, TEST_LOCATION );
2938 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_Y).Get<float>(), 600.0f, TEST_LOCATION );
2939 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL).Get<Vector2>(), Vector2(500.0f, 600.0f), TEST_LOCATION );
2941 // Test "wrap" property
2942 DALI_TEST_CHECK( scrollView.GetPropertyIndex("wrap") == ScrollView::Property::WRAP );
2943 scrollView.SetProperty( ScrollView::Property::WRAP, false );
2945 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WRAP).Get<bool>(), false, TEST_LOCATION );
2947 // Test "panning" property
2948 DALI_TEST_CHECK( scrollView.GetPropertyIndex("panning") == ScrollView::Property::PANNING );
2949 scrollView.SetProperty( ScrollView::Property::PANNING, true );
2951 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::PANNING).Get<bool>(), true, TEST_LOCATION );
2953 // Test "scrolling" property
2954 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrolling") == ScrollView::Property::SCROLLING );
2955 scrollView.SetProperty( ScrollView::Property::SCROLLING, false );
2957 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLLING).Get<bool>(), false, TEST_LOCATION );
2959 // Test "scrollDomainSize", "scrollDomainSizeX" and "scrollDomainSizeY" properties
2960 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSize") == ScrollView::Property::SCROLL_DOMAIN_SIZE );
2961 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE, Vector2(1200.0f, 1300.0f) );
2963 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE).Get<Vector2>(), Vector2(1200.0f, 1300.0f), TEST_LOCATION );
2965 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSizeX") == ScrollView::Property::SCROLL_DOMAIN_SIZE_X );
2966 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSizeY") == ScrollView::Property::SCROLL_DOMAIN_SIZE_Y );
2967 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_X).Get<float>(), 1200.0f, TEST_LOCATION );
2968 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_Y).Get<float>(), 1300.0f, TEST_LOCATION );
2969 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE_X, 1500.0f );
2970 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE_Y, 1600.0f );
2972 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_X).Get<float>(), 1500.0f, TEST_LOCATION );
2973 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_Y).Get<float>(), 1600.0f, TEST_LOCATION );
2974 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE).Get<Vector2>(), Vector2(1500.0f, 1600.0f), TEST_LOCATION );
2976 // Test "scrollDomainOffset" property
2977 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainOffset") == ScrollView::Property::SCROLL_DOMAIN_OFFSET );
2978 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_OFFSET, Vector2(500.0f, 200.0f) );
2980 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_OFFSET).Get<Vector2>(), Vector2(500.0f, 200.0f), TEST_LOCATION );
2982 // Test "scrollPositionDelta" property
2983 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPositionDelta") == ScrollView::Property::SCROLL_POSITION_DELTA );
2984 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION_DELTA, Vector2(10.0f, 30.0f) );
2986 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION_DELTA).Get<Vector2>(), Vector2(10.0f, 30.0f), TEST_LOCATION );
2988 // Test "startPagePosition" property
2989 DALI_TEST_CHECK( scrollView.GetPropertyIndex("startPagePosition") == ScrollView::Property::START_PAGE_POSITION );
2990 scrollView.SetProperty( ScrollView::Property::START_PAGE_POSITION, Vector3(50.0f, 100.0f, 20.0f) );
2992 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::START_PAGE_POSITION).Get<Vector3>(), Vector3(50.0f, 100.0f, 20.0f), TEST_LOCATION );