2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <dali-toolkit/dali-toolkit.h>
22 #include <dali/integration-api/events/touch-event-integ.h>
23 #include <dali/integration-api/events/pan-gesture-event.h>
26 using namespace Toolkit;
28 void scroll_view_startup(void)
30 test_return_value = TET_UNDEF;
33 void scroll_view_cleanup(void)
35 test_return_value = TET_PASS;
40 static bool gObjectCreatedCallBackCalled;
42 static void TestCallback(BaseHandle handle)
44 gObjectCreatedCallBackCalled = true;
47 struct CallbackFunctor
49 CallbackFunctor(bool* callbackFlag)
50 : mCallbackFlag( callbackFlag )
56 *mCallbackFlag = true;
61 const int MILLISECONDS_PER_SECOND = 1000;
62 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
63 const int RENDER_ANIMATION_TEST_DURATION_MS = 1000; ///< 1000ms to test animation
65 const int RENDER_DELAY_SCROLL = 1000; ///< duration to wait for any scroll to complete.
67 // For Clamp Signal testing...
68 const float CLAMP_EXCESS_WIDTH = 200.0f; ///< Amount of width that can be panned outside scrollview
69 const float CLAMP_EXCESS_HEIGHT = 200.0f; ///< Amount of height that can be panned outside scrollview
70 const int CLAMP_STEP_0_CHECK_NOTCLAMPED = 0; ///< FSM: "First check that scrollview isn't clamped"
71 const int CLAMP_STEP_1_CHECK_CLAMPED_WEST = 1; ///< FSM: "Next check that scrollview clamps against left side"
72 const int CLAMP_STEP_2_CHECK_CLAMPED_SOUTH_WEST = 2; ///< FSM: "Then check that scrollview clamps against bottom-left side"
73 const int CLAMP_STEP_3_SUCCESS = 3; ///< FSM: "Finished (Success)"
74 const Vector2 CLAMP_START_SCROLL_POSITION(30.0f, 100.0f); ///< Scroll start position for the Clamping tests.
75 const Vector2 CLAMP_TOUCH_START( 100.0f, 100.0f ); ///< Start point to touch from for the Clamping tests.
76 const Vector2 CLAMP_TOUCH_MOVEMENT( 5.0f, -5.0f ); ///< Amount to move touch for each frame for the Clamping tests.
77 const int CLAMP_GESTURE_FRAMES = 100; ///< Number of Frames to synthesize a gesture for the Clamping tests.
78 const Vector3 TEST_ACTOR_POSITION(100.0f, 100.0f, 0.0f); ///< A Test actor position offset (arbitrary value)
79 const Vector3 TEST_CONSTRAINT_OFFSET(1.0f, 2.0f, 0.0f); ///< A Test constraint offset (arbitrary value to test effects)
80 const float TEST_RATIO_TOLERANCE = 0.05; ///< +/-5% tolerance for ratio comparisons.
82 const float DEFAULT_SNAP_OVERSHOOT_DURATION(0.5f); ///< Default overshoot snapping animation time.
83 const float DEFAULT_MAX_OVERSHOOT(100.0f); ///< Default maximum allowed overshoot in pixels
85 const int MAX_FRAMES_TO_TEST_OVERSHOOT = 600; ///< 10 seconds (at 60 frames per second).
86 const Vector2 OVERSHOOT_START_SCROLL_POSITION(100.0f, 100.0f); ///< Scroll start position for the Overshoot tests.
87 const float SCROLL_ANIMATION_DURATION(0.33f); ///< Duration of scroll animation in Overshoot tests (i.e. 100 pixels of overshoot in the speed of 500 pixels per 100 frames, 100/(500/(100/60)) = 0.33)
88 const Vector2 SNAP_POSITION_WITH_DECELERATED_VELOCITY(74.0f, 74.0f); ///< the snap position for Overshoot tests with the decelerated velocity (i.e. Decelerated from 500 pixels per 100 frames).
89 const float TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION = 0.05f; ///< a Test duration
90 const float TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION = 1.5f; ///< another Test duration
91 const float TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION = TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * 0.5f; // Same as above, but different alpha function.
92 const float TIME_TOLERANCE = 0.05f; ///< Allow testing tolerance between a 10th of second (+/- 3 frames)
95 // Generate a PanGestureEvent to send to Core
96 Integration::PanGestureEvent GeneratePan(
98 const Vector2& previousPosition,
99 const Vector2& currentPosition,
100 unsigned long timeDelta,
101 unsigned int numberOfTouches = 1)
103 Integration::PanGestureEvent pan(state);
105 pan.previousPosition = previousPosition;
106 pan.currentPosition = currentPosition;
107 pan.timeDelta = timeDelta;
108 pan.numberOfTouches = numberOfTouches;
114 * Helper to generate PanGestureEvent
116 * @param[in] application Application instance
117 * @param[in] state The Gesture State
118 * @param[in] pos The current position of touch.
120 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
124 if( (state == Gesture::Started) ||
125 (state == Gesture::Possible) )
131 application.ProcessEvent(GeneratePan(state, last, pos, RENDER_FRAME_INTERVAL));
138 * Simulate time passed by.
140 * @note this will always process at least 1 frame (1/60 sec)
142 * @param application Test application instance
143 * @param duration Time to pass in milliseconds.
144 * @return The actual time passed in milliseconds
146 int Wait(ToolkitTestApplication& application, int duration = 0)
150 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
152 application.SendNotification();
153 application.Render(RENDER_FRAME_INTERVAL);
154 time += RENDER_FRAME_INTERVAL;
162 static bool gOnScrollStartCalled; ///< Whether the OnScrollStart signal was invoked.
163 static bool gOnScrollUpdateCalled; ///< Whether the OnScrollUpdate signal was invoked.
164 static bool gOnScrollCompleteCalled; ///< Whether the OnScrollComplete signal was invoked.
165 static bool gOnSnapStartCalled; ///< Whether the OnSnapStart signal was invoked.
166 static SnapType gLastSnapType; ///< Snaping information from SnapEvent.
167 static Vector3 gConstraintResult; ///< Result from constraint.
170 * Invoked when scrolling starts.
172 * @param[in] position The current scroll position.
174 static void OnScrollStart( const Vector2& position )
176 gOnScrollStartCalled = true;
180 * Invoked when scrolling updates (via dragging)
182 * @param[in] position The current scroll position.
184 static void OnScrollUpdate( const Vector2& position )
186 gOnScrollUpdateCalled = true;
190 * Invoked when scrolling finishes
192 * @param[in] position The current scroll position.
194 static void OnScrollComplete( const Vector2& position )
196 gOnScrollCompleteCalled = true;
200 * Invoked when a snap or flick started.
202 * @param[in] event The type of snap and the target position/scale/rotation.
204 static void OnSnapStart( const ScrollView::SnapEvent& event )
206 gOnSnapStartCalled = true;
207 gLastSnapType = event.type;
213 * Summation of current value, property, and offset.
215 * current' = current + mOffset + property;
217 struct TestSumConstraint
220 * @param[in] offset The offset to be added to current.
222 TestSumConstraint(const Vector3& offset)
228 * @param[in] current The current base value
229 * @param[in] inputs Contains the property to be added to current.
230 * @return The new current Vector.
232 void operator()( Vector3& current, const PropertyInputContainer& inputs )
234 gConstraintResult = current + Vector3(inputs[0]->GetVector2()) + mOffset;
235 current = gConstraintResult;
243 * @param[in] application The application instance
244 * @param[in] scrollView The scrollView instance
245 * @return The time taken for the overshoot to reach origin (zero)
247 static float TestOvershootSnapDuration(ToolkitTestApplication &application, ScrollView scrollView)
249 int timeToReachOrigin = -1;
250 for(int i = 0;i<MAX_FRAMES_TO_TEST_OVERSHOOT;i++)
252 float overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
253 float overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
254 if(overshootXValue == 0.0f && overshootYValue == 0.0f)
259 timeToReachOrigin += Wait(application);
262 return static_cast<float>(timeToReachOrigin) * 0.001f; // return in seconds not ms.
266 * y = 2x alpha function, which is clamped between 0.0f - 1.0f
268 * Animations should appear to finish (reach 100% point)
269 * at just half the time of a regular Linear AlphaFunction.
271 * @param[in] progress value (ranges from 0.0f - 1.0f)
272 * @return interpolation value (ranges from 0.0f - 1.0f)
274 float TestAlphaFunction(float progress)
276 return std::min( progress * 2.0f, 1.0f );
279 } // unnamed namespace
282 int UtcDaliToolkitScrollViewConstructorP(void)
284 ToolkitTestApplication application;
286 ScrollView scrollView;
287 DALI_TEST_CHECK( !scrollView );
291 int UtcDaliToolkitScrollViewCopyConstructorP(void)
293 ToolkitTestApplication application;
295 ScrollView scrollView = ScrollView::New();
296 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) );
298 ScrollView copy( scrollView );
299 DALI_TEST_CHECK( copy );
300 DALI_TEST_CHECK( copy.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) == scrollView.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) );
304 int UtcDaliToolkitScrollViewAssignmentOperatorP(void)
306 ToolkitTestApplication application;
308 ScrollView scrollView = ScrollView::New();
309 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) );
311 ScrollView copy = scrollView;
312 DALI_TEST_CHECK( copy );
313 DALI_TEST_CHECK( copy.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) == scrollView.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) );
317 int UtcDaliScrollViewDestructorP(void)
319 ToolkitTestApplication application;
321 ScrollView* scrollView = new ScrollView();
324 DALI_TEST_CHECK( true );
328 int UtcDaliToolkitScrollViewNewP1(void)
330 ToolkitTestApplication application;
331 tet_infoline(" UtcDaliToolkitScrollViewNewP1");
333 ScrollView scrollView;
335 DALI_TEST_CHECK( !scrollView );
337 scrollView = ScrollView::New();
339 DALI_TEST_CHECK( scrollView );
341 ScrollView scrollView2(scrollView);
343 DALI_TEST_CHECK( scrollView2 == scrollView );
345 //Additional check to ensure object is created by checking if it's registered
346 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
347 DALI_TEST_CHECK( registry );
349 gObjectCreatedCallBackCalled = false;
350 registry.ObjectCreatedSignal().Connect( &TestCallback );
352 ScrollView scrollView = ScrollView::New();
354 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
358 int UtcDaliToolkitScrollViewNewP2(void)
360 ToolkitTestApplication application;
361 tet_infoline(" UtcDaliToolkitScrollViewNewP2 - create thru type registry");
363 ScrollView scrollView;
364 DALI_TEST_CHECK( !scrollView );
366 TypeRegistry typeRegistry = TypeRegistry::Get();
367 TypeInfo scrollViewType = typeRegistry.GetTypeInfo("ScrollView");
368 BaseHandle handle = scrollViewType.CreateInstance();
369 DALI_TEST_CHECK( handle );
371 scrollView = ScrollView::DownCast(handle);
372 DALI_TEST_CHECK( scrollView );
377 int UtcDaliToolkitScrollViewDownCastP(void)
379 ToolkitTestApplication application;
380 tet_infoline(" UtcDaliToolkitScrollViewDownCastP");
382 ScrollView scrollView = ScrollView::New();
383 BaseHandle handle(scrollView);
385 ScrollView newScrollView = ScrollView::DownCast( handle );
386 DALI_TEST_CHECK( scrollView );
387 DALI_TEST_CHECK( newScrollView == scrollView );
391 int UtcDaliToolkitScrollViewScrollToPositionP(void)
393 ToolkitTestApplication application;
394 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionP");
396 // Create the ScrollView actor
397 ScrollView scrollView = ScrollView::New();
398 Stage::GetCurrent().Add( scrollView );
400 const Vector2 target = Vector2(100.0f, 200.0f);
401 const Vector2 target2 = Vector2(300.0f, 100.0f);
403 scrollView.ScrollTo( target, 0.0f );
405 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
406 scrollView.ScrollTo( target2 );
407 Wait(application, RENDER_DELAY_SCROLL);
408 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
413 int UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP(void)
415 ToolkitTestApplication application;
416 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP");
418 ScrollView scrollView = ScrollView::New();
419 Stage::GetCurrent().Add( scrollView );
420 RulerPtr rulerX = new FixedRuler( 100.0f );
421 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
422 RulerPtr rulerY = new FixedRuler( 100.0f );
423 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
425 scrollView.SetRulerX( rulerX );
426 scrollView.SetRulerY( rulerY );
428 scrollView.SetWrapMode(true);
430 Property::Value wrapMode = scrollView.GetProperty( Toolkit::ScrollView::Property::WRAP_ENABLED );
431 DALI_TEST_EQUALS( wrapMode.Get<bool>(), true, TEST_LOCATION );
433 const Vector2 target = Vector2(50.0f, 50.0f);
434 const Vector2 target2 = Vector2(150.0f, 150.0f);
436 scrollView.ScrollTo( target, 0.0f );
437 Wait(application, RENDER_DELAY_SCROLL);
438 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
440 scrollView.ScrollTo( target2, 0.25f, Dali::Toolkit::DirectionBiasLeft, Dali::Toolkit::DirectionBiasLeft );
441 Wait(application, RENDER_DELAY_SCROLL);
442 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
444 scrollView.ScrollTo( target, 0.0f );
445 Wait(application, RENDER_DELAY_SCROLL);
446 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
448 scrollView.ScrollTo( target2, 0.25f, Dali::Toolkit::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
449 Wait(application, RENDER_DELAY_SCROLL);
450 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
455 int UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionP(void)
457 ToolkitTestApplication application;
458 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionP");
460 // Create the ScrollView actor
461 ScrollView scrollView = ScrollView::New();
462 Stage::GetCurrent().Add( scrollView );
464 const Vector2 target = Vector2(100.0f, 200.0f);
465 const Vector2 target2 = Vector2(300.0f, 100.0f);
467 scrollView.ScrollTo( target, 0.5f, TestAlphaFunction );
468 Wait(application, 250);
469 // Check that the scroll animation should finish within just half of the specified duration with the above alpha function
470 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
472 scrollView.ScrollTo( target2, 0.5f, AlphaFunction::LINEAR );
473 Wait(application, 250);
474 // Check that the scroll animation has not finished within half of the specified duration with the linear alpha function
475 DALI_TEST_CHECK( scrollView.GetCurrentScrollPosition() != target2 );
477 // Wait till the end of the specified duration
478 Wait(application, 250);
479 // Check that the scroll animation has finished
480 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
485 int UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionAndDirectionBiasP(void)
487 ToolkitTestApplication application;
488 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionAndDirectionBiasP");
490 ScrollView scrollView = ScrollView::New();
491 Stage::GetCurrent().Add( scrollView );
492 RulerPtr rulerX = new FixedRuler( 100.0f );
493 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
494 RulerPtr rulerY = new FixedRuler( 100.0f );
495 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
497 scrollView.SetRulerX( rulerX );
498 scrollView.SetRulerY( rulerY );
500 scrollView.SetWrapMode(true);
502 const Vector2 target = Vector2(50.0f, 50.0f);
503 const Vector2 target2 = Vector2(150.0f, 150.0f);
505 scrollView.ScrollTo( target, 0.0f );
506 Wait(application, RENDER_DELAY_SCROLL);
507 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
509 scrollView.ScrollTo( target2, 0.25f, AlphaFunction::LINEAR, Dali::Toolkit::DirectionBiasLeft, Dali::Toolkit::DirectionBiasLeft );
510 Wait(application, RENDER_DELAY_SCROLL);
511 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
513 scrollView.ScrollTo( target, 0.0f );
514 Wait(application, RENDER_DELAY_SCROLL);
515 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
517 scrollView.ScrollTo( target2, 0.25f, AlphaFunction::LINEAR, Dali::Toolkit::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
518 Wait(application, RENDER_DELAY_SCROLL);
519 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
521 scrollView.ScrollTo( target, 0.0f );
522 Wait(application, RENDER_DELAY_SCROLL);
523 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
525 scrollView.ScrollTo( target2, 0.25f, TestAlphaFunction, Dali::Toolkit::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
526 Wait(application, 125);
527 // Check that the scroll animation should finish within just half of the specified duration with the above alpha function
528 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
533 int UtcDaliToolkitScrollViewScrollToPageP(void)
535 ToolkitTestApplication application;
536 tet_infoline(" UtcDaliToolkitScrollViewScrollToPageP");
538 ScrollView scrollView = ScrollView::New();
539 Stage::GetCurrent().Add( scrollView );
540 RulerPtr rulerX = new FixedRuler( 100.0f );
541 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
542 RulerPtr rulerY = new FixedRuler( 100.0f );
543 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
545 scrollView.SetRulerX( rulerX );
546 scrollView.SetRulerY( rulerY );
548 scrollView.ScrollTo( 1, 0.0f );
550 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION );
552 scrollView.ScrollTo( 5, 0.0f );
554 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(500.0f, 0.0f), TEST_LOCATION );
556 scrollView.ScrollTo( 10, 0.0f );
558 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 100.0f), TEST_LOCATION );
560 scrollView.ScrollTo( 15, 0.0f );
562 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(700.0f, 100.0f), TEST_LOCATION );
563 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION );
565 scrollView.ScrollTo( 3 );
566 Wait(application, RENDER_DELAY_SCROLL);
567 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(300.0f, 0.0f), TEST_LOCATION );
568 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION );
570 scrollView.ScrollTo( 9 );
571 Wait(application, RENDER_DELAY_SCROLL);
572 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 100.0f), TEST_LOCATION );
573 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION );
575 // Apply DefaultRulers instead and see what happens.
576 rulerX = new DefaultRuler();
577 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
578 rulerY = new DefaultRuler();
579 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
581 scrollView.SetRulerX( rulerX );
582 scrollView.SetRulerY( rulerY );
584 // This time should always scroll to origin (0.0f, 0.0f)
585 scrollView.ScrollTo( 1, 0.0f );
587 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
588 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
593 int UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP(void)
595 ToolkitTestApplication application;
596 tet_infoline(" UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP");
598 ScrollView scrollView = ScrollView::New();
599 Stage::GetCurrent().Add( scrollView );
600 RulerPtr rulerX = new FixedRuler( 100.0f );
601 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
602 RulerPtr rulerY = new FixedRuler( 100.0f );
603 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
605 scrollView.SetRulerX( rulerX );
606 scrollView.SetRulerY( rulerY );
608 scrollView.SetWrapMode(true);
610 scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DirectionBiasLeft );
612 Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame
613 // Check that the scroll position remains the same
614 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
616 Wait(application, RENDER_DELAY_SCROLL); // Wait for one second
617 // Check that it stays at the same page (i.e. the same scroll position)
618 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
619 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
621 scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DirectionBiasRight );
623 Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame
624 // Check that it scrolls towards the right
625 DALI_TEST_CHECK( scrollView.GetCurrentScrollPosition().x > 0.0f );
627 Wait(application, RENDER_DELAY_SCROLL); // Wait for one second
628 // Check that it scrolls back to the same page (i.e. the same scroll position)
629 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
630 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
635 int UtcDaliToolkitScrollViewScrollToActorP(void)
637 ToolkitTestApplication application;
638 tet_infoline(" UtcDaliToolkitScrollViewScrollToActorP");
640 ScrollView scrollView = ScrollView::New();
641 Stage::GetCurrent().Add( scrollView );
643 Actor actorA = Actor::New();
644 const Vector3 positionA = Vector3(100.0f, 400.0f, 0.0f);
645 actorA.SetPosition(positionA);
646 scrollView.Add(actorA);
648 Actor actorB = Actor::New();
649 const Vector3 positionB = Vector3(500.0f, 200.0f, 0.0f);
650 actorB.SetPosition(positionB);
651 scrollView.Add(actorB);
655 scrollView.ScrollTo(actorA, 0.0f);
657 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION );
660 scrollView.ScrollTo(actorB, 0.0f);
662 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION );
664 scrollView.ScrollTo(actorA);
665 Wait(application, RENDER_DELAY_SCROLL);
666 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION );
668 scrollView.ScrollTo(actorB);
669 Wait(application, RENDER_DELAY_SCROLL);
670 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION );
674 int UtcDaliToolkitScrollViewScrollToSnapPointP(void)
676 ToolkitTestApplication application;
677 tet_infoline(" UtcDaliToolkitScrollViewScrollToSnapPointP");
679 ScrollView scrollView = ScrollView::New();
680 Stage::GetCurrent().Add( scrollView );
681 RulerPtr rulerX = new FixedRuler( 100.0f );
682 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
683 RulerPtr rulerY = new FixedRuler( 100.0f );
684 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
686 scrollView.SetRulerX( rulerX );
687 scrollView.SetRulerY( rulerY );
689 scrollView.ScrollTo( Vector2(120.0f, 190.0f), 0.0f );
691 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(120.0f, 190.0f), TEST_LOCATION );
693 scrollView.ScrollToSnapPoint();
695 Wait(application, RENDER_DELAY_SCROLL);
696 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 200.0f), TEST_LOCATION );
700 int UtcDaliToolkitScrollViewSetScrollUpdateDistanceP(void)
702 ToolkitTestApplication application;
703 tet_infoline(" UtcDaliToolkitScrollViewSetScrollUpdateDistanceP");
705 ScrollView scrollView = ScrollView::New();
707 scrollView.SetScrollUpdateDistance(0);
708 DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 0, TEST_LOCATION);
709 scrollView.SetScrollUpdateDistance(10);
710 DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 10, TEST_LOCATION);
711 scrollView.SetScrollUpdateDistance(1000);
712 DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 1000, TEST_LOCATION);
716 int UtcDaliToolkitScrollViewSetWrapModeP(void)
718 ToolkitTestApplication application;
719 tet_infoline(" UtcDaliToolkitScrollViewSetWrapModeP");
721 ScrollView scrollView = ScrollView::New();
722 Stage::GetCurrent().Add( scrollView );
724 Actor actor = Actor::New();
725 scrollView.Add( actor );
727 // Position rulers. 4x4 grid.
728 RulerPtr rulerX = new FixedRuler(50.0f);
729 RulerPtr rulerY = new FixedRuler(50.0f);
730 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, false) );
731 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, false) );
732 scrollView.SetRulerX(rulerX);
733 scrollView.SetRulerY(rulerY);
735 scrollView.SetWrapMode(false);
736 scrollView.ScrollTo(Vector2(225.0f, 125.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
738 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 17, TEST_LOCATION );
740 scrollView.SetWrapMode(true);
741 scrollView.ScrollTo(Vector2(230.0f, 130.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
743 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 13, TEST_LOCATION );
747 int UtcDaliToolkitScrollViewActorAutoSnap(void)
749 ToolkitTestApplication application;
750 tet_infoline(" UtcDaliToolkitScrollViewActorAutoSnap");
752 ScrollView scrollView = ScrollView::New();
753 Stage::GetCurrent().Add( scrollView );
756 RulerPtr rulerX = new DefaultRuler();
757 RulerPtr rulerY = new DefaultRuler();
758 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
759 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
760 scrollView.SetRulerX(rulerX);
761 scrollView.SetRulerY(rulerY);
763 const Vector3 aPosition = Vector3(200.0f, 50.0f, 0.0f);
764 Actor a = Actor::New();
766 a.SetPosition(aPosition);
768 const Vector3 bPosition = Vector3(600.0f, 600.0f, 0.0f);
769 Actor b = Actor::New();
771 b.SetPosition(bPosition);
773 // Goto a random position, and execute snap (should not move)
774 Vector2 targetScroll = Vector2(500.0f, 500.0f);
775 scrollView.ScrollTo(targetScroll, 0.0f);
777 scrollView.ScrollToSnapPoint();
778 Wait(application, RENDER_DELAY_SCROLL);
779 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), targetScroll, TEST_LOCATION );
781 // Enable ActorAutoSnap, and now try snapping.
782 scrollView.SetActorAutoSnap(true);
783 scrollView.ScrollToSnapPoint();
784 Wait(application, RENDER_DELAY_SCROLL);
785 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), bPosition.GetVectorXY(), TEST_LOCATION );
787 scrollView.ScrollTo(Vector2(0.0f, 0.0f), 0.0f);
789 scrollView.ScrollToSnapPoint();
790 Wait(application, RENDER_DELAY_SCROLL);
791 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), aPosition.GetVectorXY(), TEST_LOCATION );
795 int UtcDaliToolkitScrollViewSignalsStartComplete(void)
797 ToolkitTestApplication application;
798 tet_infoline(" UtcDaliToolkitScrollViewSignalsStartComplete");
800 gOnScrollStartCalled = false;
801 gOnScrollCompleteCalled = false;
803 ScrollView scrollView = ScrollView::New();
804 Stage::GetCurrent().Add( scrollView );
807 RulerPtr rulerX = new DefaultRuler();
808 RulerPtr rulerY = new DefaultRuler();
809 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
810 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
811 scrollView.SetRulerX(rulerX);
812 scrollView.SetRulerY(rulerY);
813 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
814 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
815 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
816 scrollView.ScrollTo( Vector2(100.0f, 100.0f) );
817 Wait(application, RENDER_DELAY_SCROLL);
819 DALI_TEST_CHECK(gOnScrollStartCalled);
820 DALI_TEST_CHECK(gOnScrollCompleteCalled);
824 int UtcDaliToolkitScrollViewSignalsUpdate01(void)
826 ToolkitTestApplication application;
827 tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate");
829 gOnScrollStartCalled = false;
830 gOnScrollUpdateCalled = false;
831 gOnScrollCompleteCalled = false;
833 ScrollView scrollView = ScrollView::New();
834 Stage::GetCurrent().Add( scrollView );
835 Vector2 stageSize = Stage::GetCurrent().GetSize();
836 scrollView.SetSize(stageSize);
837 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
838 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
841 RulerPtr rulerX = new DefaultRuler();
842 RulerPtr rulerY = new DefaultRuler();
843 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
844 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
845 scrollView.SetRulerX(rulerX);
846 scrollView.SetRulerY(rulerY);
847 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
848 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
849 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
851 Actor image = Actor::New();
852 image.SetSize(stageSize);
853 image.SetParentOrigin(ParentOrigin::TOP_LEFT);
854 image.SetAnchorPoint(AnchorPoint::TOP_LEFT);
855 scrollView.Add(image);
859 // Do a pan starting from 100,100 and moving down diagonally.
860 Vector2 pos(100.0f, 100.0f);
861 SendPan(application, Gesture::Possible, pos);
862 SendPan(application, Gesture::Started, pos);
865 Wait(application, 100);
867 for(int i = 0;i<20;i++)
869 SendPan(application, Gesture::Continuing, pos);
875 SendPan(application, Gesture::Finished, pos);
876 Wait(application, RENDER_DELAY_SCROLL);
878 DALI_TEST_CHECK(gOnScrollStartCalled);
879 DALI_TEST_CHECK(gOnScrollUpdateCalled);
880 DALI_TEST_CHECK(gOnScrollCompleteCalled);
884 int UtcDaliToolkitScrollViewSignalsUpdate02(void)
886 ToolkitTestApplication application;
887 tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate");
889 gOnScrollStartCalled = false;
890 gOnScrollUpdateCalled = false;
891 gOnScrollCompleteCalled = false;
893 ScrollView scrollView = ScrollView::New();
894 Stage::GetCurrent().Add( scrollView );
895 Vector2 stageSize = Stage::GetCurrent().GetSize();
896 scrollView.SetSize(stageSize);
897 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
898 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
901 RulerPtr rulerX = new DefaultRuler();
902 RulerPtr rulerY = new DefaultRuler();
903 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
904 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
905 scrollView.SetRulerX(rulerX);
906 scrollView.SetRulerY(rulerY);
907 Dali::ConnectionTracker tracker;
908 bool scrollStarted=false;
909 bool scrollUpdated=false;
910 bool scrollCompleted=false;
911 DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollStarted", CallbackFunctor(&scrollStarted) ));
912 DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollUpdated", CallbackFunctor(&scrollUpdated) ));
913 DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollCompleted", CallbackFunctor(&scrollCompleted) ));
915 Actor image = Actor::New();
916 image.SetSize(stageSize);
917 image.SetParentOrigin(ParentOrigin::TOP_LEFT);
918 image.SetAnchorPoint(AnchorPoint::TOP_LEFT);
919 scrollView.Add(image);
923 // Do a pan starting from 100,100 and moving down diagonally.
924 Vector2 pos(100.0f, 100.0f);
925 SendPan(application, Gesture::Possible, pos);
926 SendPan(application, Gesture::Started, pos);
929 Wait(application, 100);
931 for(int i = 0;i<20;i++)
933 SendPan(application, Gesture::Continuing, pos);
939 SendPan(application, Gesture::Finished, pos);
940 Wait(application, RENDER_DELAY_SCROLL);
942 DALI_TEST_CHECK(scrollStarted);
943 DALI_TEST_CHECK(scrollUpdated);
944 DALI_TEST_CHECK(scrollCompleted);
946 Stage::GetCurrent().Remove( scrollView );
951 static Vector2 PerformGestureDiagonalSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, bool finish = true)
953 gOnScrollStartCalled = false;
954 gOnScrollUpdateCalled = false;
955 gOnScrollCompleteCalled = false;
956 gOnSnapStartCalled = false;
958 // Now do a pan starting from (start) and heading (direction)
960 SendPan(application, Gesture::Possible, pos);
961 SendPan(application, Gesture::Started, pos);
964 for(int i = 0;i<frames;i++)
966 pos += direction; // Move in this direction
967 SendPan(application, Gesture::Continuing, pos);
973 pos += direction; // Move in this direction.
974 SendPan(application, Gesture::Finished, pos);
975 Wait(application, RENDER_DELAY_SCROLL);
981 int UtcDaliToolkitScrollViewScrollSensitive(void)
983 ToolkitTestApplication application;
984 tet_infoline(" UtcDaliToolkitScrollViewScrollSensitive");
986 // Set up a scrollView...
987 ScrollView scrollView = ScrollView::New();
988 scrollView.SetOvershootEnabled(true);
989 Stage::GetCurrent().Add( scrollView );
990 Vector2 stageSize = Stage::GetCurrent().GetSize();
991 scrollView.SetSize(stageSize);
992 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
993 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
996 RulerPtr rulerX = new DefaultRuler();
997 RulerPtr rulerY = new DefaultRuler();
998 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
999 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1000 scrollView.SetRulerX(rulerX);
1001 scrollView.SetRulerY(rulerY);
1002 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1003 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1004 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1005 scrollView.SnapStartedSignal().Connect( &OnSnapStart );
1007 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1010 // First try insensitive swipe.
1011 scrollView.SetScrollSensitive(false);
1012 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, true);
1014 DALI_TEST_CHECK( !gOnScrollStartCalled );
1015 DALI_TEST_CHECK( !gOnScrollCompleteCalled );
1016 DALI_TEST_CHECK( !gOnSnapStartCalled );
1018 // Second try sensitive swipe.
1019 scrollView.SetScrollSensitive(true);
1020 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, true);
1022 DALI_TEST_CHECK( gOnScrollStartCalled );
1023 DALI_TEST_CHECK( gOnScrollCompleteCalled );
1024 DALI_TEST_CHECK( gOnSnapStartCalled );
1028 int UtcDaliToolkitScrollViewAxisAutoLock(void)
1030 ToolkitTestApplication application;
1031 tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLock");
1033 // Set up a scrollView...
1034 ScrollView scrollView = ScrollView::New();
1035 Stage::GetCurrent().Add( scrollView );
1036 Vector2 stageSize = Stage::GetCurrent().GetSize();
1037 scrollView.SetSize(stageSize);
1038 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1039 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1042 RulerPtr rulerX = new DefaultRuler();
1043 RulerPtr rulerY = new DefaultRuler();
1044 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1045 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1046 scrollView.SetRulerX(rulerX);
1047 scrollView.SetRulerY(rulerY);
1048 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1049 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1050 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1053 scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
1055 Vector2 startPosition = scrollView.GetCurrentScrollPosition();
1056 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(5.0f, 1.0f), 50, true); // mostly horizontal
1057 const Vector2 positionAfterNormal = scrollView.GetCurrentScrollPosition();
1060 scrollView.SetAxisAutoLock(true);
1061 DALI_TEST_CHECK(scrollView.GetAxisAutoLock());
1063 scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
1065 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(5.0f, 1.0f), 50, true); // mostly horizontal
1066 const Vector2 positionAfterAutoLock = scrollView.GetCurrentScrollPosition();
1068 // compare how much the Y position has deviated for normal and autolock.
1069 const float devianceNormal = fabsf(startPosition.y - positionAfterNormal.y);
1070 const float devianceAutoLock = fabsf(startPosition.y - positionAfterAutoLock.y);
1072 // in auto-lock it should be a mostly horizontal pan (thus deviance should be much lower)
1073 DALI_TEST_CHECK(devianceAutoLock < devianceNormal);
1075 scrollView.SetAxisAutoLock(false);
1076 DALI_TEST_CHECK(!scrollView.GetAxisAutoLock());
1080 int UtcDaliToolkitScrollViewAxisAutoLockGradient(void)
1082 ToolkitTestApplication application;
1083 tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLockGradient");
1085 // Set up a scrollView...
1086 ScrollView scrollView = ScrollView::New();
1087 scrollView.SetAxisAutoLockGradient(0.5f);
1088 DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 0.5f, TEST_LOCATION);
1089 scrollView.SetAxisAutoLockGradient(1.0f);
1090 DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 1.0f, TEST_LOCATION);
1094 int UtcDaliToolkitScrollViewConstraints(void)
1096 ToolkitTestApplication application;
1097 tet_infoline(" UtcDaliToolkitScrollViewConstraints");
1099 // Set up a scrollView...
1100 ScrollView scrollView = ScrollView::New();
1101 Stage::GetCurrent().Add( scrollView );
1102 Vector2 stageSize = Stage::GetCurrent().GetSize();
1103 scrollView.SetSize(stageSize);
1104 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1105 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1108 RulerPtr rulerX = new DefaultRuler();
1109 RulerPtr rulerY = new DefaultRuler();
1110 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1111 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1112 scrollView.SetRulerX(rulerX);
1113 scrollView.SetRulerY(rulerY);
1115 // Add an Actor to ScrollView,
1116 // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1117 gConstraintResult = Vector3::ZERO;
1118 Actor a = Actor::New();
1120 a.SetPosition( TEST_ACTOR_POSITION );
1123 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1124 constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
1125 constraint.SetRemoveAction(Constraint::Discard);
1126 scrollView.ApplyConstraintToChildren(constraint);
1129 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1131 gConstraintResult = Vector3::ZERO;
1132 scrollView.RemoveConstraintsFromChildren();
1135 DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
1139 int UtcDaliToolkitScrollViewBind(void)
1141 ToolkitTestApplication application;
1142 tet_infoline(" UtcDaliToolkitScrollViewBind");
1144 // Set up a scrollView...
1145 ScrollView scrollView = ScrollView::New();
1146 Stage::GetCurrent().Add( scrollView );
1147 Vector2 stageSize = Stage::GetCurrent().GetSize();
1148 scrollView.SetSize(stageSize);
1149 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1150 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1153 RulerPtr rulerX = new DefaultRuler();
1154 RulerPtr rulerY = new DefaultRuler();
1155 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1156 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1157 scrollView.SetRulerX(rulerX);
1158 scrollView.SetRulerY(rulerY);
1160 // Add an Actor to ScrollView,
1161 // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1163 gConstraintResult = Vector3::ZERO;
1164 Actor a = Actor::New();
1166 a.SetPosition( TEST_ACTOR_POSITION );
1169 // apply this constraint to scrollview
1170 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1171 constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
1172 constraint.SetRemoveAction(Constraint::Discard);
1173 scrollView.ApplyConstraintToChildren(constraint);
1177 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1180 gConstraintResult = Vector3::ZERO;
1181 scrollView.UnbindActor( a );
1183 DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
1186 gConstraintResult = Vector3::ZERO;
1187 scrollView.BindActor( a );
1189 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1193 int UtcDaliToolkitScrollViewOvershoot(void)
1195 ToolkitTestApplication application;
1196 tet_infoline(" UtcDaliToolkitScrollViewOvershoot");
1198 // Set up a scrollView...
1199 ScrollView scrollView = ScrollView::New();
1200 scrollView.SetOvershootEnabled(true);
1201 Stage::GetCurrent().Add( scrollView );
1202 Vector2 stageSize = Stage::GetCurrent().GetSize();
1203 scrollView.SetSize(stageSize);
1204 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1205 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1208 RulerPtr rulerX = new DefaultRuler();
1209 RulerPtr rulerY = new DefaultRuler();
1210 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1211 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1212 scrollView.SetRulerX(rulerX);
1213 scrollView.SetRulerY(rulerY);
1214 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1215 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1216 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1218 scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1221 // 1. Scroll page in NW (-500,-500 pixels), then inspect overshoot. (don't release touch)
1222 Vector2 currentPos = Vector2(100.0f, 100.0f);
1223 currentPos = PerformGestureDiagonalSwipe(application, currentPos, Vector2(5.0f, 5.0f), 100, false);
1224 float overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1225 float overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1226 Vector2 positionValue = scrollView.GetProperty<Vector2>(ScrollView::Property::SCROLL_POSITION);
1227 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1228 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1229 DALI_TEST_EQUALS(positionValue, Vector2::ZERO, TEST_LOCATION);
1231 float timeToReachOrigin;
1233 // Now release touch. Overshoot should snap back to zero.
1234 SendPan(application, Gesture::Finished, currentPos);
1235 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1237 float minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1238 float maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1240 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1241 (timeToReachOrigin < maxTimeToReachOrigin) );
1243 // 2. Repeat Scroll, but this time change overshoot snap duration to shorter time
1244 scrollView.SetSnapOvershootDuration(TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION);
1246 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1247 // Now release touch. Overshoot should snap back to zero.
1248 SendPan(application, Gesture::Finished, currentPos);
1249 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1251 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1252 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1254 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1255 (timeToReachOrigin < maxTimeToReachOrigin) );
1257 // 3. Repeat Scroll, but this time change overshoot snap duration to longer time.
1258 scrollView.SetSnapOvershootDuration(TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION);
1260 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1261 // Now release touch. Overshoot should snap back to zero.
1262 SendPan(application, Gesture::Finished, currentPos);
1263 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1265 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1266 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1268 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1269 (timeToReachOrigin < maxTimeToReachOrigin) );
1271 // 4. Repeat Scroll, but this time change overshoot function.
1272 scrollView.SetSnapOvershootDuration(TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION);
1273 scrollView.SetSnapOvershootAlphaFunction(TestAlphaFunction);
1275 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1276 // Now release touch. Overshoot should snap back to zero.
1277 SendPan(application, Gesture::Finished, currentPos);
1278 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1280 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1281 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1283 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1284 (timeToReachOrigin < maxTimeToReachOrigin) );
1288 int UtcDaliToolkitScrollViewSnapAlphaFunction(void)
1290 ToolkitTestApplication application;
1291 tet_infoline(" UtcDaliToolkitScrollViewSnapAlphaFunction");
1293 // Set up a scrollView...
1294 ScrollView scrollView = ScrollView::New();
1295 scrollView.SetScrollSnapAlphaFunction( AlphaFunction::EASE_IN );
1296 DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_IN );
1297 scrollView.SetScrollSnapAlphaFunction( AlphaFunction::EASE_OUT );
1298 DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_OUT );
1300 scrollView.SetScrollFlickAlphaFunction( AlphaFunction::BOUNCE );
1301 DALI_TEST_CHECK( scrollView.GetScrollFlickAlphaFunction().GetBuiltinFunction() == AlphaFunction::BOUNCE );
1306 int UtcDaliToolkitScrollViewSnapDuration(void)
1308 ToolkitTestApplication application;
1309 tet_infoline(" UtcDaliToolkitScrollViewSnapDuration");
1311 // Set up a scrollView...
1312 ScrollView scrollView = ScrollView::New();
1313 scrollView.SetScrollSnapDuration( 1.0f );
1314 DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 1.0f, TEST_LOCATION );
1315 scrollView.SetScrollSnapDuration( 0.5f );
1316 DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 0.5f, TEST_LOCATION );
1318 scrollView.SetScrollFlickDuration( 2.0f );
1319 DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 2.0f, TEST_LOCATION );
1320 scrollView.SetScrollFlickDuration( 1.5f );
1321 DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 1.5f, TEST_LOCATION );
1325 int UtcDaliToolkitScrollViewSnapStartedSignalP(void)
1327 ToolkitTestApplication application;
1328 tet_infoline(" UtcDaliToolkitScrollViewSnapStartedSignalP");
1330 // Set up a scrollView...
1331 ScrollView scrollView = ScrollView::New();
1332 Stage::GetCurrent().Add( scrollView );
1333 Vector2 stageSize = Stage::GetCurrent().GetSize();
1334 scrollView.SetSize(stageSize);
1335 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1336 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1339 RulerPtr rulerX = new DefaultRuler();
1340 RulerPtr rulerY = new DefaultRuler();
1341 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1342 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1343 scrollView.SetRulerX(rulerX);
1344 scrollView.SetRulerY(rulerY);
1345 scrollView.SnapStartedSignal().Connect( &OnSnapStart );
1347 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1350 // First try a snap.
1351 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(0.5f, 0.0f), 60, true);
1353 DALI_TEST_CHECK( gOnSnapStartCalled );
1354 DALI_TEST_CHECK( gLastSnapType == Toolkit::Snap );
1356 // Second try a swipe.
1357 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(20.0f, 0.0f), 60, true);
1359 DALI_TEST_CHECK( gOnSnapStartCalled );
1360 DALI_TEST_CHECK( gLastSnapType == Toolkit::Flick );
1364 int UtcDaliToolkitScrollViewGetCurrentPageP(void)
1366 ToolkitTestApplication application;
1367 tet_infoline(" UtcDaliToolkitScrollViewGetCurrentPageP");
1369 ScrollView scrollView = ScrollView::New();
1370 Stage::GetCurrent().Add( scrollView );
1371 RulerPtr rulerX = new FixedRuler( 100.0f );
1372 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1373 RulerPtr rulerY = new FixedRuler( 100.0f );
1374 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1376 scrollView.SetRulerX( rulerX );
1377 scrollView.SetRulerY( rulerY );
1379 scrollView.ScrollTo( 15 );
1380 Wait(application, RENDER_DELAY_SCROLL);
1381 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION );
1383 scrollView.ScrollTo( 3 );
1384 Wait(application, RENDER_DELAY_SCROLL);
1385 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION );
1387 scrollView.ScrollTo( 9 );
1388 Wait(application, RENDER_DELAY_SCROLL);
1389 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION );
1394 int UtcDaliToolkitScrollViewSetMaxOvershootP(void)
1396 ToolkitTestApplication application;
1397 tet_infoline(" UtcDaliToolkitScrollViewSetMaxOvershootP");
1399 // Set up a scrollView...
1400 ScrollView scrollView = ScrollView::New();
1401 Stage::GetCurrent().Add( scrollView );
1402 Vector2 stageSize = Stage::GetCurrent().GetSize();
1403 scrollView.SetSize(stageSize);
1404 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1405 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1408 RulerPtr rulerX = new DefaultRuler();
1409 RulerPtr rulerY = new DefaultRuler();
1410 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1411 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1412 scrollView.SetRulerX(rulerX);
1413 scrollView.SetRulerY(rulerY);
1415 // Set the max overshoot to be 50 pixels in both X axis and Y axis
1416 scrollView.SetMaxOvershoot(50.0f, 50.0f);
1418 scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1421 // Scroll page in NW (-20,-20 pixels), then check that overshoot should be 0. (don't release touch)
1422 Vector2 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 20, false);
1423 float overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1424 float overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1425 DALI_TEST_EQUALS(overshootXValue, 0.0f, TEST_LOCATION);
1426 DALI_TEST_EQUALS(overshootYValue, 0.0f, TEST_LOCATION);
1428 // Scroll page further in NW (-105,-105 pixels), then check that overshoot should be around 0.5. (don't release touch)
1429 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 105, false);
1430 overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1431 overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1432 // The overshoot value is a 0.0f - 1.0f ranged value of the amount overshot related to the maximum overshoot.
1433 // EG. If we move 105, max overshoot is 50, then we overshot 50 / 105.
1434 float correctOvershootValue = 50.0f / 105.f;
1435 DALI_TEST_EQUALS( overshootXValue, correctOvershootValue, 0.001f, TEST_LOCATION );
1436 DALI_TEST_EQUALS( overshootYValue, correctOvershootValue, 0.001f, TEST_LOCATION );
1438 // Scroll page further in NW (-30,-30 pixels), then check that overshoot should be now 1.0. (don't release touch)
1439 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 30, false);
1440 overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1441 overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1442 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1443 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1445 // Change the max overshoot to be 100 pixels in both X axis and Y axis
1446 scrollView.SetMaxOvershoot(100.0f, 100.0f);
1449 // Check that overshoot should be now around 0.8.
1450 overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1451 overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1452 DALI_TEST_CHECK(overshootXValue > 0.79f && overshootXValue < 0.81f);
1453 DALI_TEST_CHECK(overshootYValue > 0.79f && overshootYValue < 0.81f);
1455 // Scroll page further in NW (-30,-30 pixels), then check that overshoot should be now 1.0. (don't release touch)
1456 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 30, false);
1457 overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1458 overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1459 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1460 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1465 int UtcDaliToolkitScrollViewSetScrollingDirectionP(void)
1467 ToolkitTestApplication application;
1468 tet_infoline(" UtcDaliToolkitScrollViewSetScrollingDirectionP");
1470 // Set up a scrollView...
1471 ScrollView scrollView = ScrollView::New();
1472 Stage::GetCurrent().Add( scrollView );
1473 Vector2 stageSize = Stage::GetCurrent().GetSize();
1474 scrollView.SetSize(stageSize);
1475 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1476 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1478 Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1480 scrollView.ScrollTo(START_POSITION, 0.0f);
1482 // Try a vertical swipe.
1483 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1484 // Take into account resampling done when prediction is off.
1485 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1487 scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1489 scrollView.ScrollTo(START_POSITION, 0.0f);
1491 // Try a vertical swipe.
1492 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1493 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION );
1495 scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1497 scrollView.ScrollTo(Vector2(10.0f, 10.0f), 0.0f);
1499 // Try a vertical swipe.
1500 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1501 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1506 int UtcDaliToolkitScrollViewRemoveScrollingDirectionP(void)
1508 ToolkitTestApplication application;
1509 tet_infoline(" UtcDaliToolkitScrollViewRemoveScrollingDirectionP");
1511 // Set up a scrollView...
1512 ScrollView scrollView = ScrollView::New();
1513 Stage::GetCurrent().Add( scrollView );
1514 Vector2 stageSize = Stage::GetCurrent().GetSize();
1515 scrollView.SetSize(stageSize);
1516 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1517 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1519 Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1521 scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1523 scrollView.ScrollTo(START_POSITION, 0.0f);
1525 // Try a vertical swipe.
1526 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1527 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION );
1529 scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1531 scrollView.ScrollTo(Vector2(10.0f, 10.0f), 0.0f);
1533 // Try a vertical swipe.
1534 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1535 // Take into account resampling done when prediction is off.
1536 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1541 int UtcDaliToolkitScrollViewSetRulerXP(void)
1543 ToolkitTestApplication application;
1544 tet_infoline(" UtcDaliToolkitScrollViewSetRulerXP");
1546 ScrollView scrollView = ScrollView::New();
1547 Stage::GetCurrent().Add( scrollView );
1548 RulerPtr rulerX = new FixedRuler( 100.0f );
1549 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1551 scrollView.SetRulerX( rulerX );
1553 scrollView.ScrollTo( 1, 0.0f );
1555 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION );
1557 RulerPtr newRulerX = new FixedRuler( 200.0f );
1558 newRulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1560 scrollView.SetRulerX( newRulerX );
1562 scrollView.ScrollTo( 1, 0.0f );
1564 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 0.0f), TEST_LOCATION );
1569 int UtcDaliToolkitScrollViewSetRulerYP(void)
1571 ToolkitTestApplication application;
1572 tet_infoline(" UtcDaliToolkitScrollViewSetRulerYP");
1574 ScrollView scrollView = ScrollView::New();
1575 Stage::GetCurrent().Add( scrollView );
1577 RulerPtr rulerY = new FixedRuler( 200.0f );
1578 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1580 scrollView.SetRulerY( rulerY );
1582 scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f );
1584 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 350.0f), TEST_LOCATION );
1586 RulerPtr newRulerY = new FixedRuler( 100.0f );
1587 newRulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
1588 scrollView.SetRulerY( newRulerY );
1590 scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f );
1592 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 200.0f), TEST_LOCATION );
1597 int UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP(void)
1599 ToolkitTestApplication application;
1600 tet_infoline(" UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP");
1602 ScrollView scrollView = ScrollView::New();
1603 scrollView.SetMinimumSpeedForFlick(25.0f);
1604 DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 25.0f, TEST_LOCATION );
1605 scrollView.SetMinimumSpeedForFlick(60.0f);
1606 DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 60.0f, TEST_LOCATION );
1610 int UtcDaliToolkitScrollViewSetMinimumDistanceForFlickP(void)
1612 ToolkitTestApplication application;
1613 tet_infoline(" UtcDaliToolkitScrollViewSetMinimumDistanceForFlick");
1615 ScrollView scrollView = ScrollView::New();
1617 scrollView.SetMinimumDistanceForFlick(Vector2(30.0f, 15.0f));
1618 DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(30.0f, 15.0f), TEST_LOCATION );
1619 scrollView.SetMinimumDistanceForFlick(Vector2(60.0f, 30.0f));
1620 DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(60.0f, 30.0f), TEST_LOCATION);
1624 int UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP(void)
1626 ToolkitTestApplication application;
1627 tet_infoline(" UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP");
1629 ScrollView scrollView = ScrollView::New();
1630 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
1631 scrollView.SetWheelScrollDistanceStep(Vector2(30.0f, 15.0f));
1632 DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(30.0f, 15.0f), TEST_LOCATION );
1633 scrollView.SetWheelScrollDistanceStep(Vector2(60.0f, 30.0f));
1634 DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(60.0f, 30.0f), TEST_LOCATION);
1638 int UtcDaliToolkitScrollViewApplyEffectP(void)
1640 ToolkitTestApplication application;
1641 tet_infoline(" UtcDaliToolkitScrollViewApplyEffectP");
1643 // Create a ScrollView
1644 ScrollView scrollView = ScrollView::New();
1646 // Create two scroll view effects
1647 Dali::Path path = Dali::Path::New();
1648 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);
1649 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);
1651 // Apply both effects
1652 scrollView.ApplyEffect(effect);
1653 scrollView.ApplyEffect(newEffect);
1655 DALI_TEST_CHECK( true );
1660 int UtcDaliToolkitScrollViewApplyEffectN(void)
1662 ToolkitTestApplication application;
1663 tet_infoline(" UtcDaliToolkitScrollViewApplyEffectN");
1665 // Create a ScrollView
1666 ScrollView scrollView = ScrollView::New();
1668 // Create two scroll view effects
1669 Dali::Path path = Dali::Path::New();
1670 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);
1671 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);
1673 // Apply both effects
1674 scrollView.ApplyEffect(effect);
1675 scrollView.ApplyEffect(newEffect);
1677 // Attempt to apply the same effect again
1680 scrollView.ApplyEffect(newEffect);
1681 tet_result( TET_FAIL );
1683 catch ( DaliException& e )
1685 DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
1691 int UtcDaliToolkitScrollViewRemoveEffectP(void)
1693 ToolkitTestApplication application;
1694 tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectP");
1696 // Create a ScrollView
1697 ScrollView scrollView = ScrollView::New();
1699 // Create two scroll view effects
1700 Dali::Path path = Dali::Path::New();
1701 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);
1702 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);
1704 // Apply both effects
1705 scrollView.ApplyEffect(effect);
1706 scrollView.ApplyEffect(newEffect);
1708 // Remove both effects
1709 scrollView.RemoveEffect(effect);
1710 scrollView.RemoveEffect(newEffect);
1712 DALI_TEST_CHECK( true );
1717 int UtcDaliToolkitScrollViewRemoveEffectN(void)
1719 ToolkitTestApplication application;
1720 tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectN");
1722 // Create a ScrollView
1723 ScrollView scrollView = ScrollView::New();
1725 // Create two scroll view effects
1726 Dali::Path path = Dali::Path::New();
1727 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);
1728 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);
1730 // Apply the first effect
1731 scrollView.ApplyEffect(effect);
1733 // Attempt to remove the second effect which has not been applied to scroll view
1736 scrollView.RemoveEffect(newEffect);
1737 tet_result( TET_FAIL );
1739 catch ( DaliException& e )
1741 DALI_TEST_ASSERT( e, "effectExistedInScrollView", TEST_LOCATION );
1747 int UtcDaliToolkitScrollViewRemoveAllEffectsP(void)
1749 ToolkitTestApplication application;
1750 tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsP");
1752 // Create a ScrollView
1753 ScrollView scrollView = ScrollView::New();
1755 // Create two scroll view effects
1756 Dali::Path path = Dali::Path::New();
1757 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);
1758 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);
1760 // Apply both effects
1761 scrollView.ApplyEffect(effect);
1762 scrollView.ApplyEffect(newEffect);
1764 // Attempt to apply the same first effect again
1767 scrollView.ApplyEffect(effect);
1768 tet_result( TET_FAIL );
1770 catch ( DaliException& e )
1772 DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
1775 // Remove both effects
1776 scrollView.RemoveAllEffects();
1778 // Apply both effects again
1779 scrollView.ApplyEffect(effect);
1780 scrollView.ApplyEffect(newEffect);
1782 DALI_TEST_CHECK( true );
1787 int UtcDaliToolkitScrollViewRemoveAllEffectsN(void)
1789 ToolkitTestApplication application;
1790 tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsN");
1792 // Create a ScrollView
1793 ScrollView scrollView = ScrollView::New();
1795 // Remove effects when there is no effect applied previously
1796 scrollView.RemoveAllEffects();
1798 DALI_TEST_CHECK( true );
1803 int UtcDaliToolkitScrollViewSetOvershootEnabledP(void)
1805 ToolkitTestApplication application;
1806 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEnabledP");
1808 ScrollView scrollView = ScrollView::New();
1810 scrollView.SetOvershootEnabled(true);
1811 DALI_TEST_CHECK(scrollView.IsOvershootEnabled());
1813 scrollView.SetOvershootEnabled(false);
1814 DALI_TEST_CHECK(!scrollView.IsOvershootEnabled());
1819 int UtcDaliToolkitScrollViewSetOvershootEffectColorP(void)
1821 ToolkitTestApplication application;
1822 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEffectColorP");
1824 ScrollView scrollView = ScrollView::New();
1826 scrollView.SetOvershootEffectColor(Dali::Color::RED);
1827 DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::RED, TEST_LOCATION);
1829 scrollView.SetOvershootEffectColor(Dali::Color::YELLOW);
1830 DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::YELLOW, TEST_LOCATION);
1835 int UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP(void)
1837 ToolkitTestApplication application;
1838 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP");
1840 ScrollView scrollView = ScrollView::New();
1842 scrollView.SetOvershootAnimationSpeed(55.0f);
1843 DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 55.0f, TEST_LOCATION);
1845 scrollView.SetOvershootAnimationSpeed(120.0f);
1846 DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 120.0f, TEST_LOCATION);
1851 int UtcDaliToolkitScrollViewGetSet(void)
1853 ToolkitTestApplication application;
1854 tet_infoline(" UtcDaliToolkitScrollViewGetSet");
1855 ScrollView scrollView = ScrollView::New();
1856 scrollView.SetMaxFlickSpeed(0.5f);
1857 DALI_TEST_EQUALS(scrollView.GetMaxFlickSpeed(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1858 scrollView.SetFrictionCoefficient(0.6f);
1859 DALI_TEST_EQUALS(scrollView.GetFrictionCoefficient(), 0.6f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1860 scrollView.SetFlickSpeedCoefficient(0.7f);
1861 DALI_TEST_EQUALS(scrollView.GetFlickSpeedCoefficient(), 0.7f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1865 int UtcDaliToolkitScrollViewRulerDomainConstructorP(void)
1867 ToolkitTestApplication application;
1869 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
1870 DALI_TEST_EQUALS( domainX.min, 0.0f, TEST_LOCATION);
1871 DALI_TEST_EQUALS( domainX.max, 200.0f, TEST_LOCATION);
1872 DALI_TEST_EQUALS( domainX.enabled, true, TEST_LOCATION);
1874 RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
1875 DALI_TEST_EQUALS( domainY.min, 100.0f, TEST_LOCATION);
1876 DALI_TEST_EQUALS( domainY.max, 500.0f, TEST_LOCATION);
1877 DALI_TEST_EQUALS( domainY.enabled, false, TEST_LOCATION);
1882 int UtcDaliToolkitScrollViewRulerDomainGetSizeP(void)
1884 ToolkitTestApplication application;
1886 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
1887 DALI_TEST_EQUALS( domainX.GetSize(), 200.0f, TEST_LOCATION);
1889 RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
1890 DALI_TEST_EQUALS( domainY.GetSize(), 400.0f, TEST_LOCATION);
1895 int UtcDaliToolkitScrollViewRulerDomainClampP(void)
1897 ToolkitTestApplication application;
1899 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
1901 float value = domainX.Clamp(50.0f, 100.0f, 1.0f);
1902 DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
1904 value = domainX.Clamp(300.0f, 20.0f, 1.0f);
1905 DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
1907 value = domainX.Clamp(300.0f, 20.0f, 0.5f);
1908 DALI_TEST_EQUALS( value, 80.0f, TEST_LOCATION);
1910 value = domainX.Clamp(250.0f, 200.0f, 2.0f);
1911 DALI_TEST_EQUALS( value, 200.0f, TEST_LOCATION);
1916 int UtcDaliToolkitScrollViewRulerDomainClampWithStateP(void)
1918 ToolkitTestApplication application;
1920 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
1923 float value = domainX.Clamp(50.0f, 100.0f, 1.0f, clamped);
1924 DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
1925 DALI_TEST_EQUALS( clamped, Dali::Toolkit::NotClamped, TEST_LOCATION);
1927 value = domainX.Clamp(-100.0f, 200.0f, 1.0f, clamped);
1928 DALI_TEST_EQUALS( value, 0.0f, TEST_LOCATION);
1929 DALI_TEST_EQUALS( clamped, Dali::Toolkit::ClampedToMin, TEST_LOCATION);
1931 value = domainX.Clamp(300.0f, 20.0f, 1.0f, clamped);
1932 DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
1933 DALI_TEST_EQUALS( clamped, Dali::Toolkit::ClampedToMax, TEST_LOCATION);
1938 int UtcDaliToolkitScrollViewDefaultRulerConstructorP(void)
1940 ToolkitTestApplication application;
1941 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerConstructorP");
1943 RulerPtr defaultRuler = new DefaultRuler();
1944 DALI_TEST_CHECK( defaultRuler );
1949 int UtcDaliToolkitScrollViewDefaultRulerDestructorP(void)
1951 ToolkitTestApplication application;
1952 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerDestructorP");
1954 RulerPtr defaultRuler = new DefaultRuler();
1956 DALI_TEST_CHECK( true );
1960 int UtcDaliToolkitScrollViewFixedRulerConstructorP(void)
1962 ToolkitTestApplication application;
1963 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerConstructorP");
1965 RulerPtr fixedRuler = new FixedRuler( 100.0f );
1966 DALI_TEST_CHECK( fixedRuler );
1968 fixedRuler = new FixedRuler( 0.0f );
1969 DALI_TEST_CHECK( fixedRuler );
1974 int UtcDaliToolkitScrollViewFixedRulerDestructorP(void)
1976 ToolkitTestApplication application;
1977 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerDestructorP");
1979 RulerPtr fixedRuler = new FixedRuler( 100.0f );
1981 DALI_TEST_CHECK( true );
1985 int UtcDaliToolkitScrollViewRulerGetTypeP(void)
1987 ToolkitTestApplication application;
1988 tet_infoline(" UtcDaliToolkitScrollViewRulerGetTypeP");
1990 RulerPtr defaultRuler = new DefaultRuler();
1991 DALI_TEST_CHECK( defaultRuler );
1992 DALI_TEST_EQUALS( defaultRuler->GetType(), Dali::Toolkit::Ruler::Free, TEST_LOCATION);
1994 RulerPtr fixedRuler = new FixedRuler( 100.0f );
1995 DALI_TEST_CHECK( fixedRuler );
1996 DALI_TEST_EQUALS( fixedRuler->GetType(), Dali::Toolkit::Ruler::Fixed, TEST_LOCATION);
2001 int UtcDaliToolkitScrollViewRulerGetExtensionP(void)
2003 ToolkitTestApplication application;
2004 tet_infoline(" UtcDaliToolkitScrollViewRulerGetExtensionP");
2006 RulerPtr defaultRuler = new DefaultRuler();
2007 DALI_TEST_CHECK( defaultRuler );
2008 DALI_TEST_CHECK( !defaultRuler->GetExtension() );
2010 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2011 DALI_TEST_CHECK( fixedRuler );
2012 DALI_TEST_CHECK( !fixedRuler->GetExtension() );
2017 int UtcDaliToolkitScrollViewRulerEnableDisable(void)
2019 ToolkitTestApplication application;
2020 tet_infoline(" UtcDaliToolkitScrollViewRulerEnableDisable");
2022 RulerPtr ruler = new DefaultRuler();
2024 DALI_TEST_CHECK( ruler->IsEnabled() );
2026 DALI_TEST_CHECK( !ruler->IsEnabled() );
2028 DALI_TEST_CHECK( ruler->IsEnabled() );
2032 int UtcDaliToolkitScrollViewRulerDomainEnableDisable(void)
2034 ToolkitTestApplication application;
2035 tet_infoline(" UtcDaliToolkitScrollViewRulerDomainEnableDisable");
2037 RulerPtr ruler = new DefaultRuler();
2038 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
2040 ruler->SetDomain( RulerDomain(0.0f, 100.0f, true) );
2041 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 100.0f, TEST_LOCATION );
2042 DALI_TEST_EQUALS( ruler->Clamp(-200.0f), 0.0f, TEST_LOCATION );
2043 DALI_TEST_EQUALS( ruler->Clamp(200.0f), 100.0f, TEST_LOCATION );
2045 ruler->DisableDomain();
2046 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
2047 DALI_TEST_EQUALS( ruler->Clamp(-200.0f), -200.0f, TEST_LOCATION );
2048 DALI_TEST_EQUALS( ruler->Clamp(200.0f), 200.0f, TEST_LOCATION );
2052 int UtcDaliToolkitScrollViewRulerSnapAndClamp(void)
2054 ToolkitTestApplication application;
2055 tet_infoline(" UtcDaliToolkitScrollViewRulerSnapAndClamp");
2057 RulerPtr ruler = new FixedRuler( 50.0f );
2058 ruler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2060 // default testing. (snap and clamp)
2061 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f), 50.0f, TEST_LOCATION);
2062 DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f), 50.0f, TEST_LOCATION);
2063 DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f), 0.0f, TEST_LOCATION);
2064 DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f), 0.0f, TEST_LOCATION);
2065 DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f), 400.0f, TEST_LOCATION);
2066 DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f), 400.0f, TEST_LOCATION);
2069 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
2070 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.5f), 50.0f, TEST_LOCATION); // No Flick
2071 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
2073 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
2074 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.5f), 0.0f, TEST_LOCATION); // No Flick
2075 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
2078 DALI_TEST_EQUALS( ruler->SnapAndClamp(-10.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (over left boundary)
2079 DALI_TEST_EQUALS( ruler->SnapAndClamp(-5.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (slightly ovr left boundary)
2080 DALI_TEST_EQUALS( ruler->SnapAndClamp(300.0f, 0.5f, 10.0f), 300.0f, TEST_LOCATION); // 10 units long (not over a boundary)
2081 DALI_TEST_EQUALS( ruler->SnapAndClamp(395.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (slightly over right boundary)
2082 DALI_TEST_EQUALS( ruler->SnapAndClamp(500.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (over right boundary)
2085 DALI_TEST_EQUALS( ruler->SnapAndClamp(-100.0f, 0.5f, 0.0f, 2.0f), 0.0f, TEST_LOCATION);
2086 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 2.0f), 50.0f, TEST_LOCATION);
2087 DALI_TEST_EQUALS( ruler->SnapAndClamp(700.0f, 0.5f, 0.0f, 2.0f), 700.0f, TEST_LOCATION);
2088 DALI_TEST_EQUALS( ruler->SnapAndClamp(850.0f, 0.5f, 0.0f, 2.0f), 800.0f, TEST_LOCATION);
2090 // clamp state testing.
2092 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
2093 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2094 DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
2095 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2096 DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
2097 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2098 DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
2099 DALI_TEST_EQUALS( clamped, ClampedToMin, TEST_LOCATION );
2100 DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
2101 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2102 DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
2103 DALI_TEST_EQUALS( clamped, ClampedToMax, TEST_LOCATION );
2107 int UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP(void)
2109 ToolkitTestApplication application;
2110 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP");
2112 RulerPtr rulerNormal = new FixedRuler( 25.0f );
2113 rulerNormal->SetDomain( RulerDomain(10.0f, 90.0f, true) );
2115 unsigned int volume;
2118 position = rulerNormal->GetPositionFromPage(1, volume, true);
2119 DALI_TEST_EQUALS( position, 35.0f, TEST_LOCATION );
2120 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
2122 position = rulerNormal->GetPositionFromPage(2, volume, true);
2123 DALI_TEST_EQUALS( position, 60.0f, TEST_LOCATION );
2124 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
2126 // Disable the ruler
2127 rulerNormal->Disable();
2129 position = rulerNormal->GetPositionFromPage(1, volume, true);
2130 DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
2131 DALI_TEST_EQUALS( volume, 1u, TEST_LOCATION );
2133 position = rulerNormal->GetPositionFromPage(2, volume, true);
2134 DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
2135 DALI_TEST_EQUALS( volume, 2u, TEST_LOCATION );
2140 int UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP(void)
2142 ToolkitTestApplication application;
2143 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP");
2145 RulerPtr defaultRuler = new DefaultRuler();
2146 DALI_TEST_CHECK( defaultRuler );
2147 DALI_TEST_EQUALS( defaultRuler->GetTotalPages(), 1u, TEST_LOCATION);
2152 int UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP(void)
2154 ToolkitTestApplication application;
2155 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP");
2157 RulerPtr defaultRuler = new DefaultRuler();
2158 DALI_TEST_CHECK( defaultRuler );
2159 DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(100.0f, true), 0u, TEST_LOCATION);
2160 DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(-300.0f, false), 0u, TEST_LOCATION);
2165 int UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP(void)
2167 ToolkitTestApplication application;
2168 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP");
2170 RulerPtr defaultRuler = new DefaultRuler();
2171 DALI_TEST_CHECK( defaultRuler );
2173 unsigned int volume;
2174 DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(0, volume, true), 0.0f, TEST_LOCATION);
2175 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
2177 DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(3, volume, false), 0.0f, TEST_LOCATION);
2178 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
2183 int UtcDaliToolkitScrollViewDefaultRulerSnapP(void)
2185 ToolkitTestApplication application;
2186 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerSnapP");
2188 RulerPtr defaultRuler = new DefaultRuler();
2189 DALI_TEST_CHECK( defaultRuler );
2191 DALI_TEST_EQUALS( defaultRuler->Snap(50.0f, 0.5f), 50.0f, TEST_LOCATION);
2192 DALI_TEST_EQUALS( defaultRuler->Snap(-120.0f, 1.0f), -120.0f, TEST_LOCATION);
2197 int UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP(void)
2199 ToolkitTestApplication application;
2200 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP");
2202 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2203 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2205 fixedRuler->Enable();
2206 DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 4u, TEST_LOCATION);
2208 fixedRuler->Disable();
2209 DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 1u, TEST_LOCATION);
2214 int UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP(void)
2216 ToolkitTestApplication application;
2217 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP");
2219 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2220 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2222 fixedRuler->Enable();
2223 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 3u, TEST_LOCATION);
2224 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2225 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 1u, TEST_LOCATION);
2226 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2228 fixedRuler->Disable();
2229 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2230 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
2231 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2232 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2234 // Set domain size to be smaller than the ruler space
2235 fixedRuler->SetDomain( RulerDomain(0.0f, 50.0f, true) );
2237 fixedRuler->Enable();
2238 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2239 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2240 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2241 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2243 fixedRuler->Disable();
2244 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2245 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
2246 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2247 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2252 int UtcDaliToolkitScrollViewFixedRulerSnapP(void)
2254 ToolkitTestApplication application;
2255 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerSnapP");
2257 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2258 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2260 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.0f), -100.0f, TEST_LOCATION);
2261 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.0f), -100.0f, TEST_LOCATION);
2262 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.0f), -200.0f, TEST_LOCATION);
2263 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.0f), -500.0f, TEST_LOCATION);
2264 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.0f), 0.0f, TEST_LOCATION);
2265 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.0f), 0.0f, TEST_LOCATION);
2266 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.0f), 0.0f, TEST_LOCATION);
2267 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.0f), 100.0f, TEST_LOCATION);
2268 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.0f), 100.0f, TEST_LOCATION);
2269 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.0f), 200.0f, TEST_LOCATION);
2270 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.0f), 600.0f, TEST_LOCATION);
2272 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.5f), 0.0f, TEST_LOCATION);
2273 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.5f), -100.0f, TEST_LOCATION);
2274 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.5f), -100.0f, TEST_LOCATION);
2275 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.5f), -500.0f, TEST_LOCATION);
2276 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.5f), 0.0f, TEST_LOCATION);
2277 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.5f), 100.0f, TEST_LOCATION);
2278 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.5f), 100.0f, TEST_LOCATION);
2279 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.5f), 100.0f, TEST_LOCATION);
2280 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.5f), 100.0f, TEST_LOCATION);
2281 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.5f), 300.0f, TEST_LOCATION);
2282 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.5f), 600.0f, TEST_LOCATION);
2284 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 1.0f), 0.0f, TEST_LOCATION);
2285 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 1.0f), 0.0f, TEST_LOCATION);
2286 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 1.0f), -100.0f, TEST_LOCATION);
2287 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 1.0f), -400.0f, TEST_LOCATION);
2288 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 1.0f), 100.0f, TEST_LOCATION);
2289 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 1.0f), 100.0f, TEST_LOCATION);
2290 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 1.0f), 100.0f, TEST_LOCATION);
2291 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 1.0f), 200.0f, TEST_LOCATION);
2292 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 1.0f), 200.0f, TEST_LOCATION);
2293 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 1.0f), 300.0f, TEST_LOCATION);
2294 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 1.0f), 700.0f, TEST_LOCATION);
2299 int UtcDaliToolkitScrollViewConstraintsMove(void)
2301 ToolkitTestApplication application;
2302 tet_infoline(" UtcDaliToolkitScrollViewConstraintsMove");
2304 // Set up a scrollView...
2305 ScrollView scrollView = ScrollView::New();
2306 Stage::GetCurrent().Add( scrollView );
2307 Vector2 stageSize = Stage::GetCurrent().GetSize();
2308 scrollView.SetSize(stageSize);
2309 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
2310 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2313 RulerPtr rulerX = new DefaultRuler();
2314 RulerPtr rulerY = new DefaultRuler();
2315 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
2316 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
2317 scrollView.SetRulerX(rulerX);
2318 scrollView.SetRulerY(rulerY);
2320 // Add an Actor to ScrollView,
2321 Actor a = Actor::New();
2323 a.SetPosition( TEST_ACTOR_POSITION );
2326 const Vector2 target = Vector2(100.0f, 100.0f);
2327 const Vector2 target2 = Vector2(200.0f, 200.0f);
2329 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, MoveActorConstraint );
2330 constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
2331 constraint.SetRemoveAction(Constraint::Discard);
2332 scrollView.ApplyConstraintToChildren(constraint);
2334 scrollView.ScrollTo( target, 0.0f );
2336 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
2337 scrollView.ScrollTo( target2 );
2338 Wait(application, RENDER_DELAY_SCROLL);
2339 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
2344 int UtcDaliToolkitScrollViewConstraintsWrap(void)
2346 ToolkitTestApplication application;
2347 tet_infoline(" UtcDaliToolkitScrollViewConstraintsWrap");
2349 // Set up a scrollView...
2350 ScrollView scrollView = ScrollView::New();
2351 Stage::GetCurrent().Add( scrollView );
2352 Vector2 stageSize = Stage::GetCurrent().GetSize();
2353 scrollView.SetSize(stageSize);
2354 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
2355 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2358 RulerPtr rulerX = new DefaultRuler();
2359 RulerPtr rulerY = new DefaultRuler();
2360 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
2361 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
2362 scrollView.SetRulerX(rulerX);
2363 scrollView.SetRulerY(rulerY);
2365 // Add an Actor to ScrollView,
2366 Actor a = Actor::New();
2368 a.SetPosition( TEST_ACTOR_POSITION );
2371 const Vector2 target = Vector2(100.0f, 100.0f);
2372 const Vector2 target2 = Vector2(200.0f, 200.0f);
2374 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, WrapActorConstraint );
2375 constraint.AddSource( LocalSource( Actor::Property::SCALE ) );
2376 constraint.AddSource( LocalSource( Actor::Property::ANCHOR_POINT ) );
2377 constraint.AddSource( LocalSource( Actor::Property::SIZE ) );
2378 constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
2379 constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
2380 constraint.AddSource( Source( scrollView, Toolkit::ScrollView::Property::WRAP ) );
2381 constraint.SetRemoveAction(Constraint::Discard);
2382 scrollView.ApplyConstraintToChildren(constraint);
2384 scrollView.ScrollTo( target, 0.0f );
2386 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
2387 scrollView.ScrollTo( target2 );
2388 Wait(application, RENDER_DELAY_SCROLL);
2389 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
2391 scrollView.Remove(a);
2397 // Non-API test (so no P or N variant).
2398 int UtcDaliToolkitScrollViewGesturePageLimit(void)
2400 ToolkitTestApplication application;
2401 tet_infoline( " UtcDaliToolkitScrollViewGesturePageLimit" );
2403 // Set up a scrollView.
2404 ScrollView scrollView = ScrollView::New();
2406 // Do not rely on stage size for UTC tests.
2407 Vector2 pageSize( 720.0f, 1280.0f );
2408 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
2409 scrollView.SetSize( pageSize );
2410 scrollView.SetParentOrigin( ParentOrigin::CENTER );
2411 scrollView.SetAnchorPoint( AnchorPoint::CENTER );
2412 scrollView.SetPosition( 0.0f, 0.0f, 0.0f );
2415 // We set the X ruler to fixed to give us pages to snap to.
2416 Dali::Toolkit::FixedRuler* rulerX = new Dali::Toolkit::FixedRuler( pageSize.width );
2417 // Note: The 3x page width is arbitary, but we need enough to show that we are
2418 // capping page movement by the page limiter, and not the domain.
2419 rulerX->SetDomain( Dali::Toolkit::RulerDomain( 0.0f, pageSize.width * 3.0f, false ) );
2420 Dali::Toolkit::RulerPtr rulerY = new Dali::Toolkit::DefaultRuler();
2422 scrollView.SetRulerX( rulerX );
2423 scrollView.SetRulerY( rulerY );
2425 scrollView.SetWrapMode( false );
2426 scrollView.SetScrollSensitive( true );
2428 Stage::GetCurrent().Add( scrollView );
2430 // Set up a gesture to perform.
2431 Vector2 startPos( 50.0f, 0.0f );
2432 Vector2 direction( -5.0f, 0.0f );
2435 // Force starting position.
2436 scrollView.ScrollTo( startPos, 0.0f );
2437 Wait( application );
2439 // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
2440 Vector2 currentPos( PerformGestureDiagonalSwipe( application, startPos, direction, frames - 1, false ) );
2442 // Confirm the final X coord has not moved more than one page from the start X position.
2443 DALI_TEST_GREATER( ( startPos.x + pageSize.width ), scrollView.GetCurrentScrollPosition().x, TEST_LOCATION );
2445 // Finish the gesture and wait for the snap.
2446 currentPos += direction;
2447 SendPan( application, Gesture::Finished, currentPos );
2448 // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
2449 Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
2451 // Confirm the final X coord has snapped to exactly one page ahead of the start page.
2452 DALI_TEST_EQUALS( pageSize.width, scrollView.GetCurrentScrollPosition().x, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2457 int UtcDaliScrollViewSetGetProperty(void)
2459 ToolkitTestApplication application;
2461 // Create the ScrollView actor
2462 ScrollView scrollView = ScrollView::New();
2463 DALI_TEST_CHECK(scrollView);
2465 // Event side properties
2467 // Test "wrapEnabled" property
2468 DALI_TEST_CHECK( scrollView.GetPropertyIndex("wrapEnabled") == ScrollView::Property::WRAP_ENABLED );
2469 scrollView.SetProperty( ScrollView::Property::WRAP_ENABLED, true );
2470 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WRAP_ENABLED).Get<bool>(), true, TEST_LOCATION );
2472 // Test "panningEnabled" property
2473 DALI_TEST_CHECK( scrollView.GetPropertyIndex("panningEnabled") == ScrollView::Property::PANNING_ENABLED );
2474 scrollView.SetProperty( ScrollView::Property::PANNING_ENABLED, false );
2475 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::PANNING_ENABLED).Get<bool>(), false, TEST_LOCATION );
2477 // Test "axisAutoLockEnabled" property
2478 DALI_TEST_CHECK( scrollView.GetPropertyIndex("axisAutoLockEnabled") == ScrollView::Property::AXIS_AUTO_LOCK_ENABLED );
2479 scrollView.SetProperty( ScrollView::Property::AXIS_AUTO_LOCK_ENABLED, false );
2480 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::AXIS_AUTO_LOCK_ENABLED).Get<bool>(), false, TEST_LOCATION );
2482 // Test "wheelScrollDistanceStep" property
2483 DALI_TEST_CHECK( scrollView.GetPropertyIndex("wheelScrollDistanceStep") == ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP );
2484 scrollView.SetProperty( ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP, Vector2(100.0f, 50.0f) );
2485 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP).Get<Vector2>(), Vector2(100.0f, 50.0f), TEST_LOCATION );
2487 // Test "overshootEnabled" property
2488 DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootEnabled") == Scrollable::Property::OVERSHOOT_ENABLED );
2489 DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), scrollView.IsOvershootEnabled(), TEST_LOCATION );
2490 scrollView.SetProperty( Scrollable::Property::OVERSHOOT_ENABLED, false );
2491 DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), false, TEST_LOCATION );
2493 // Animatable properties
2495 // Test "scrollPosition" property
2496 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPosition") == ScrollView::Property::SCROLL_POSITION );
2497 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(320.0f, 550.0f) );
2499 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION).Get<Vector2>(), Vector2(320.0f, 550.0f), TEST_LOCATION );
2501 // Test "scrollPrePosition", "scrollPrePositionX" and "scrollPrePositionY" properties
2502 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePosition") == ScrollView::Property::SCROLL_PRE_POSITION );
2503 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION, Vector2(300.0f, 500.0f) );
2505 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION).Get<Vector2>(), Vector2(300.0f, 500.0f), TEST_LOCATION );
2507 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionX") == ScrollView::Property::SCROLL_PRE_POSITION_X );
2508 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionY") == ScrollView::Property::SCROLL_PRE_POSITION_Y );
2509 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_X).Get<float>(), 300.0f, TEST_LOCATION );
2510 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_Y).Get<float>(), 500.0f, TEST_LOCATION );
2511 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_X, 400.0f );
2512 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_Y, 600.0f );
2514 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_X).Get<float>(), 400.0f, TEST_LOCATION );
2515 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_Y).Get<float>(), 600.0f, TEST_LOCATION );
2516 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION).Get<Vector2>(), Vector2(400.0f, 600.0f), TEST_LOCATION );
2518 // Test "scrollPrePositionMax", "scrollPrePositionMaxX" and "scrollPrePositionMaxY" properties
2519 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMax") == ScrollView::Property::SCROLL_PRE_POSITION_MAX );
2520 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX, Vector2(100.0f, 200.0f) );
2522 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX).Get<Vector2>(), Vector2(100.0f, 200.0f), TEST_LOCATION );
2524 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMaxX") == ScrollView::Property::SCROLL_PRE_POSITION_MAX_X );
2525 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMaxY") == ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y );
2526 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_X).Get<float>(), 100.0f, TEST_LOCATION );
2527 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y).Get<float>(), 200.0f, TEST_LOCATION );
2528 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX_X, 300.0f );
2529 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y, 400.0f );
2531 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_X).Get<float>(), 300.0f, TEST_LOCATION );
2532 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y).Get<float>(), 400.0f, TEST_LOCATION );
2533 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX).Get<Vector2>(), Vector2(300.0f, 400.0f), TEST_LOCATION );
2535 // Test "overshootX" property
2536 DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootX") == ScrollView::Property::OVERSHOOT_X );
2537 scrollView.SetProperty( ScrollView::Property::OVERSHOOT_X, 0.8f );
2539 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::OVERSHOOT_X).Get<float>(), 0.8f, TEST_LOCATION );
2541 // Test "overshootY" property
2542 DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootY") == ScrollView::Property::OVERSHOOT_Y );
2543 scrollView.SetProperty( ScrollView::Property::OVERSHOOT_Y, 0.8f );
2545 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y).Get<float>(), 0.8f, TEST_LOCATION );
2547 // Test "scrollFinal", "scrollFinalX" and "scrollFinalY" properties
2548 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinal") == ScrollView::Property::SCROLL_FINAL );
2549 scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL, Vector2(200.0f, 300.0f) );
2551 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL).Get<Vector2>(), Vector2(200.0f, 300.0f), TEST_LOCATION );
2553 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinalX") == ScrollView::Property::SCROLL_FINAL_X );
2554 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinalY") == ScrollView::Property::SCROLL_FINAL_Y );
2555 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_X).Get<float>(), 200.0f, TEST_LOCATION );
2556 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_Y).Get<float>(), 300.0f, TEST_LOCATION );
2557 scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL_X, 500.0f );
2558 scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL_Y, 600.0f );
2560 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_X).Get<float>(), 500.0f, TEST_LOCATION );
2561 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_Y).Get<float>(), 600.0f, TEST_LOCATION );
2562 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL).Get<Vector2>(), Vector2(500.0f, 600.0f), TEST_LOCATION );
2564 // Test "wrap" property
2565 DALI_TEST_CHECK( scrollView.GetPropertyIndex("wrap") == ScrollView::Property::WRAP );
2566 scrollView.SetProperty( ScrollView::Property::WRAP, false );
2568 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WRAP).Get<bool>(), false, TEST_LOCATION );
2570 // Test "panning" property
2571 DALI_TEST_CHECK( scrollView.GetPropertyIndex("panning") == ScrollView::Property::PANNING );
2572 scrollView.SetProperty( ScrollView::Property::PANNING, true );
2574 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::PANNING).Get<bool>(), true, TEST_LOCATION );
2576 // Test "scrolling" property
2577 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrolling") == ScrollView::Property::SCROLLING );
2578 scrollView.SetProperty( ScrollView::Property::SCROLLING, false );
2580 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLLING).Get<bool>(), false, TEST_LOCATION );
2582 // Test "scrollDomainSize", "scrollDomainSizeX" and "scrollDomainSizeY" properties
2583 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSize") == ScrollView::Property::SCROLL_DOMAIN_SIZE );
2584 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE, Vector2(1200.0f, 1300.0f) );
2586 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE).Get<Vector2>(), Vector2(1200.0f, 1300.0f), TEST_LOCATION );
2588 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSizeX") == ScrollView::Property::SCROLL_DOMAIN_SIZE_X );
2589 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSizeY") == ScrollView::Property::SCROLL_DOMAIN_SIZE_Y );
2590 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_X).Get<float>(), 1200.0f, TEST_LOCATION );
2591 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_Y).Get<float>(), 1300.0f, TEST_LOCATION );
2592 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE_X, 1500.0f );
2593 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE_Y, 1600.0f );
2595 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_X).Get<float>(), 1500.0f, TEST_LOCATION );
2596 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_Y).Get<float>(), 1600.0f, TEST_LOCATION );
2597 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE).Get<Vector2>(), Vector2(1500.0f, 1600.0f), TEST_LOCATION );
2599 // Test "scrollDomainOffset" property
2600 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainOffset") == ScrollView::Property::SCROLL_DOMAIN_OFFSET );
2601 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_OFFSET, Vector2(500.0f, 200.0f) );
2603 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_OFFSET).Get<Vector2>(), Vector2(500.0f, 200.0f), TEST_LOCATION );
2605 // Test "scrollPositionDelta" property
2606 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPositionDelta") == ScrollView::Property::SCROLL_POSITION_DELTA );
2607 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION_DELTA, Vector2(10.0f, 30.0f) );
2609 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION_DELTA).Get<Vector2>(), Vector2(10.0f, 30.0f), TEST_LOCATION );
2611 // Test "startPagePosition" property
2612 DALI_TEST_CHECK( scrollView.GetPropertyIndex("startPagePosition") == ScrollView::Property::START_PAGE_POSITION );
2613 scrollView.SetProperty( ScrollView::Property::START_PAGE_POSITION, Vector3(50.0f, 100.0f, 20.0f) );
2615 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::START_PAGE_POSITION).Get<Vector3>(), Vector3(50.0f, 100.0f, 20.0f), TEST_LOCATION );