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);
1202 Vector2 overshootSize = Vector2(100.0f,100.0f);
1203 scrollView.SetProperty( Scrollable::Property::OVERSHOOT_SIZE, overshootSize );
1204 DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_SIZE).Get<Vector2>(), overshootSize, TEST_LOCATION );
1206 Stage::GetCurrent().Add( scrollView );
1207 Vector2 stageSize = Stage::GetCurrent().GetSize();
1208 scrollView.SetSize(stageSize);
1209 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1210 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1213 RulerPtr rulerX = new DefaultRuler();
1214 RulerPtr rulerY = new DefaultRuler();
1215 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1216 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1217 scrollView.SetRulerX(rulerX);
1218 scrollView.SetRulerY(rulerY);
1219 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1220 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1221 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1223 scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1226 // 1. Scroll page in NW (-500,-500 pixels), then inspect overshoot. (don't release touch)
1227 Vector2 currentPos = Vector2(100.0f, 100.0f);
1228 currentPos = PerformGestureDiagonalSwipe(application, currentPos, Vector2(5.0f, 5.0f), 100, false);
1229 float overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1230 float overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1231 Vector2 positionValue = scrollView.GetProperty<Vector2>(ScrollView::Property::SCROLL_POSITION);
1232 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1233 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1234 DALI_TEST_EQUALS(positionValue, Vector2::ZERO, TEST_LOCATION);
1236 float timeToReachOrigin;
1238 // Now release touch. Overshoot should snap back to zero.
1239 SendPan(application, Gesture::Finished, currentPos);
1240 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1242 float minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1243 float maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1245 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1246 (timeToReachOrigin < maxTimeToReachOrigin) );
1248 // 2. Repeat Scroll, but this time change overshoot snap duration to shorter time
1249 scrollView.SetSnapOvershootDuration(TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION);
1251 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1252 // Now release touch. Overshoot should snap back to zero.
1253 SendPan(application, Gesture::Finished, currentPos);
1254 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1256 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1257 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1259 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1260 (timeToReachOrigin < maxTimeToReachOrigin) );
1262 // 3. Repeat Scroll, but this time change overshoot snap duration to longer time.
1263 scrollView.SetSnapOvershootDuration(TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION);
1265 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1266 // Now release touch. Overshoot should snap back to zero.
1267 SendPan(application, Gesture::Finished, currentPos);
1268 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1270 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1271 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1273 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1274 (timeToReachOrigin < maxTimeToReachOrigin) );
1276 // 4. Repeat Scroll, but this time change overshoot function.
1277 scrollView.SetSnapOvershootDuration(TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION);
1278 scrollView.SetSnapOvershootAlphaFunction(TestAlphaFunction);
1280 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1281 // Now release touch. Overshoot should snap back to zero.
1282 SendPan(application, Gesture::Finished, currentPos);
1283 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1285 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1286 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1288 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1289 (timeToReachOrigin < maxTimeToReachOrigin) );
1293 int UtcDaliToolkitScrollViewSnapAlphaFunction(void)
1295 ToolkitTestApplication application;
1296 tet_infoline(" UtcDaliToolkitScrollViewSnapAlphaFunction");
1298 // Set up a scrollView...
1299 ScrollView scrollView = ScrollView::New();
1300 scrollView.SetScrollSnapAlphaFunction( AlphaFunction::EASE_IN );
1301 DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_IN );
1302 scrollView.SetScrollSnapAlphaFunction( AlphaFunction::EASE_OUT );
1303 DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_OUT );
1305 scrollView.SetScrollFlickAlphaFunction( AlphaFunction::BOUNCE );
1306 DALI_TEST_CHECK( scrollView.GetScrollFlickAlphaFunction().GetBuiltinFunction() == AlphaFunction::BOUNCE );
1311 int UtcDaliToolkitScrollViewSnapDuration(void)
1313 ToolkitTestApplication application;
1314 tet_infoline(" UtcDaliToolkitScrollViewSnapDuration");
1316 // Set up a scrollView...
1317 ScrollView scrollView = ScrollView::New();
1318 scrollView.SetScrollSnapDuration( 1.0f );
1319 DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 1.0f, TEST_LOCATION );
1320 scrollView.SetScrollSnapDuration( 0.5f );
1321 DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 0.5f, TEST_LOCATION );
1323 scrollView.SetScrollFlickDuration( 2.0f );
1324 DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 2.0f, TEST_LOCATION );
1325 scrollView.SetScrollFlickDuration( 1.5f );
1326 DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 1.5f, TEST_LOCATION );
1330 int UtcDaliToolkitScrollViewSnapStartedSignalP(void)
1332 ToolkitTestApplication application;
1333 tet_infoline(" UtcDaliToolkitScrollViewSnapStartedSignalP");
1335 // Set up a scrollView...
1336 ScrollView scrollView = ScrollView::New();
1337 Stage::GetCurrent().Add( scrollView );
1338 Vector2 stageSize = Stage::GetCurrent().GetSize();
1339 scrollView.SetSize(stageSize);
1340 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1341 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1344 RulerPtr rulerX = new DefaultRuler();
1345 RulerPtr rulerY = new DefaultRuler();
1346 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1347 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1348 scrollView.SetRulerX(rulerX);
1349 scrollView.SetRulerY(rulerY);
1350 scrollView.SnapStartedSignal().Connect( &OnSnapStart );
1352 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1355 // First try a snap.
1356 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(0.5f, 0.0f), 60, true);
1358 DALI_TEST_CHECK( gOnSnapStartCalled );
1359 DALI_TEST_CHECK( gLastSnapType == Toolkit::Snap );
1361 // Second try a swipe.
1362 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(20.0f, 0.0f), 60, true);
1364 DALI_TEST_CHECK( gOnSnapStartCalled );
1365 DALI_TEST_CHECK( gLastSnapType == Toolkit::Flick );
1369 int UtcDaliToolkitScrollViewGetCurrentPageP(void)
1371 ToolkitTestApplication application;
1372 tet_infoline(" UtcDaliToolkitScrollViewGetCurrentPageP");
1374 ScrollView scrollView = ScrollView::New();
1375 Stage::GetCurrent().Add( scrollView );
1376 RulerPtr rulerX = new FixedRuler( 100.0f );
1377 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1378 RulerPtr rulerY = new FixedRuler( 100.0f );
1379 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1381 scrollView.SetRulerX( rulerX );
1382 scrollView.SetRulerY( rulerY );
1384 scrollView.ScrollTo( 15 );
1385 Wait(application, RENDER_DELAY_SCROLL);
1386 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION );
1388 scrollView.ScrollTo( 3 );
1389 Wait(application, RENDER_DELAY_SCROLL);
1390 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION );
1392 scrollView.ScrollTo( 9 );
1393 Wait(application, RENDER_DELAY_SCROLL);
1394 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION );
1399 int UtcDaliToolkitScrollViewSetMaxOvershootP(void)
1401 ToolkitTestApplication application;
1402 tet_infoline(" UtcDaliToolkitScrollViewSetMaxOvershootP");
1404 // Set up a scrollView...
1405 ScrollView scrollView = ScrollView::New();
1406 Stage::GetCurrent().Add( scrollView );
1407 Vector2 stageSize = Stage::GetCurrent().GetSize();
1408 scrollView.SetSize(stageSize);
1409 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1410 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1413 RulerPtr rulerX = new DefaultRuler();
1414 RulerPtr rulerY = new DefaultRuler();
1415 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1416 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1417 scrollView.SetRulerX(rulerX);
1418 scrollView.SetRulerY(rulerY);
1420 // Set the max overshoot to be 50 pixels in both X axis and Y axis
1421 scrollView.SetMaxOvershoot(50.0f, 50.0f);
1423 scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1426 // Scroll page in NW (-20,-20 pixels), then check that overshoot should be 0. (don't release touch)
1427 Vector2 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 20, false);
1428 float overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1429 float overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1430 DALI_TEST_EQUALS(overshootXValue, 0.0f, TEST_LOCATION);
1431 DALI_TEST_EQUALS(overshootYValue, 0.0f, TEST_LOCATION);
1433 // Scroll page further in NW (-105,-105 pixels), then check that overshoot should be around 0.5. (don't release touch)
1434 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 105, false);
1435 overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1436 overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1437 // The overshoot value is a 0.0f - 1.0f ranged value of the amount overshot related to the maximum overshoot.
1438 // EG. If we move 105, max overshoot is 50, then we overshot 50 / 105.
1439 float correctOvershootValue = 50.0f / 105.f;
1440 DALI_TEST_EQUALS( overshootXValue, correctOvershootValue, 0.001f, TEST_LOCATION );
1441 DALI_TEST_EQUALS( overshootYValue, correctOvershootValue, 0.001f, TEST_LOCATION );
1443 // Scroll page further in NW (-30,-30 pixels), then check that overshoot should be now 1.0. (don't release touch)
1444 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 30, false);
1445 overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1446 overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1447 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1448 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1450 // Change the max overshoot to be 100 pixels in both X axis and Y axis
1451 scrollView.SetMaxOvershoot(100.0f, 100.0f);
1454 // Check that overshoot should be now around 0.8.
1455 overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1456 overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1457 DALI_TEST_CHECK(overshootXValue > 0.79f && overshootXValue < 0.81f);
1458 DALI_TEST_CHECK(overshootYValue > 0.79f && overshootYValue < 0.81f);
1460 // Scroll page further in NW (-30,-30 pixels), then check that overshoot should be now 1.0. (don't release touch)
1461 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 30, false);
1462 overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1463 overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1464 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1465 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1470 int UtcDaliToolkitScrollViewSetScrollingDirectionP(void)
1472 ToolkitTestApplication application;
1473 tet_infoline(" UtcDaliToolkitScrollViewSetScrollingDirectionP");
1475 // Set up a scrollView...
1476 ScrollView scrollView = ScrollView::New();
1477 Stage::GetCurrent().Add( scrollView );
1478 Vector2 stageSize = Stage::GetCurrent().GetSize();
1479 scrollView.SetSize(stageSize);
1480 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1481 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1483 Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1485 scrollView.ScrollTo(START_POSITION, 0.0f);
1487 // Try a vertical swipe.
1488 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1489 // Take into account resampling done when prediction is off.
1490 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1492 scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1494 scrollView.ScrollTo(START_POSITION, 0.0f);
1496 // Try a vertical swipe.
1497 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1498 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION );
1500 scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1502 scrollView.ScrollTo(Vector2(10.0f, 10.0f), 0.0f);
1504 // Try a vertical swipe.
1505 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1506 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1511 int UtcDaliToolkitScrollViewRemoveScrollingDirectionP(void)
1513 ToolkitTestApplication application;
1514 tet_infoline(" UtcDaliToolkitScrollViewRemoveScrollingDirectionP");
1516 // Set up a scrollView...
1517 ScrollView scrollView = ScrollView::New();
1518 Stage::GetCurrent().Add( scrollView );
1519 Vector2 stageSize = Stage::GetCurrent().GetSize();
1520 scrollView.SetSize(stageSize);
1521 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1522 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1524 Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1526 scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1528 scrollView.ScrollTo(START_POSITION, 0.0f);
1530 // Try a vertical swipe.
1531 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1532 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION );
1534 scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1536 scrollView.ScrollTo(Vector2(10.0f, 10.0f), 0.0f);
1538 // Try a vertical swipe.
1539 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1540 // Take into account resampling done when prediction is off.
1541 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION );
1546 int UtcDaliToolkitScrollViewSetRulerXP(void)
1548 ToolkitTestApplication application;
1549 tet_infoline(" UtcDaliToolkitScrollViewSetRulerXP");
1551 ScrollView scrollView = ScrollView::New();
1552 Stage::GetCurrent().Add( scrollView );
1553 RulerPtr rulerX = new FixedRuler( 100.0f );
1554 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1556 scrollView.SetRulerX( rulerX );
1558 scrollView.ScrollTo( 1, 0.0f );
1560 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION );
1562 RulerPtr newRulerX = new FixedRuler( 200.0f );
1563 newRulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1565 scrollView.SetRulerX( newRulerX );
1567 scrollView.ScrollTo( 1, 0.0f );
1569 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 0.0f), TEST_LOCATION );
1574 int UtcDaliToolkitScrollViewSetRulerYP(void)
1576 ToolkitTestApplication application;
1577 tet_infoline(" UtcDaliToolkitScrollViewSetRulerYP");
1579 ScrollView scrollView = ScrollView::New();
1580 Stage::GetCurrent().Add( scrollView );
1582 RulerPtr rulerY = new FixedRuler( 200.0f );
1583 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1585 scrollView.SetRulerY( rulerY );
1587 scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f );
1589 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 350.0f), TEST_LOCATION );
1591 RulerPtr newRulerY = new FixedRuler( 100.0f );
1592 newRulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
1593 scrollView.SetRulerY( newRulerY );
1595 scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f );
1597 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 200.0f), TEST_LOCATION );
1602 int UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP(void)
1604 ToolkitTestApplication application;
1605 tet_infoline(" UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP");
1607 ScrollView scrollView = ScrollView::New();
1608 scrollView.SetMinimumSpeedForFlick(25.0f);
1609 DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 25.0f, TEST_LOCATION );
1610 scrollView.SetMinimumSpeedForFlick(60.0f);
1611 DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 60.0f, TEST_LOCATION );
1615 int UtcDaliToolkitScrollViewSetMinimumDistanceForFlickP(void)
1617 ToolkitTestApplication application;
1618 tet_infoline(" UtcDaliToolkitScrollViewSetMinimumDistanceForFlick");
1620 ScrollView scrollView = ScrollView::New();
1622 scrollView.SetMinimumDistanceForFlick(Vector2(30.0f, 15.0f));
1623 DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(30.0f, 15.0f), TEST_LOCATION );
1624 scrollView.SetMinimumDistanceForFlick(Vector2(60.0f, 30.0f));
1625 DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(60.0f, 30.0f), TEST_LOCATION);
1629 int UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP(void)
1631 ToolkitTestApplication application;
1632 tet_infoline(" UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP");
1634 ScrollView scrollView = ScrollView::New();
1635 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
1636 scrollView.SetWheelScrollDistanceStep(Vector2(30.0f, 15.0f));
1637 DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(30.0f, 15.0f), TEST_LOCATION );
1638 scrollView.SetWheelScrollDistanceStep(Vector2(60.0f, 30.0f));
1639 DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(60.0f, 30.0f), TEST_LOCATION);
1643 int UtcDaliToolkitScrollViewApplyEffectP(void)
1645 ToolkitTestApplication application;
1646 tet_infoline(" UtcDaliToolkitScrollViewApplyEffectP");
1648 // Create a ScrollView
1649 ScrollView scrollView = ScrollView::New();
1651 // Create two scroll view effects
1652 Dali::Path path = Dali::Path::New();
1653 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);
1654 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);
1656 // Apply both effects
1657 scrollView.ApplyEffect(effect);
1658 scrollView.ApplyEffect(newEffect);
1660 DALI_TEST_CHECK( true );
1665 int UtcDaliToolkitScrollViewApplyEffectN(void)
1667 ToolkitTestApplication application;
1668 tet_infoline(" UtcDaliToolkitScrollViewApplyEffectN");
1670 // Create a ScrollView
1671 ScrollView scrollView = ScrollView::New();
1673 // Create two scroll view effects
1674 Dali::Path path = Dali::Path::New();
1675 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);
1676 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);
1678 // Apply both effects
1679 scrollView.ApplyEffect(effect);
1680 scrollView.ApplyEffect(newEffect);
1682 // Attempt to apply the same effect again
1685 scrollView.ApplyEffect(newEffect);
1686 tet_result( TET_FAIL );
1688 catch ( DaliException& e )
1690 DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
1696 int UtcDaliToolkitScrollViewRemoveEffectP(void)
1698 ToolkitTestApplication application;
1699 tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectP");
1701 // Create a ScrollView
1702 ScrollView scrollView = ScrollView::New();
1704 // Create two scroll view effects
1705 Dali::Path path = Dali::Path::New();
1706 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);
1707 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);
1709 // Apply both effects
1710 scrollView.ApplyEffect(effect);
1711 scrollView.ApplyEffect(newEffect);
1713 // Remove both effects
1714 scrollView.RemoveEffect(effect);
1715 scrollView.RemoveEffect(newEffect);
1717 DALI_TEST_CHECK( true );
1722 int UtcDaliToolkitScrollViewRemoveEffectN(void)
1724 ToolkitTestApplication application;
1725 tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectN");
1727 // Create a ScrollView
1728 ScrollView scrollView = ScrollView::New();
1730 // Create two scroll view effects
1731 Dali::Path path = Dali::Path::New();
1732 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);
1733 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);
1735 // Apply the first effect
1736 scrollView.ApplyEffect(effect);
1738 // Attempt to remove the second effect which has not been applied to scroll view
1741 scrollView.RemoveEffect(newEffect);
1742 tet_result( TET_FAIL );
1744 catch ( DaliException& e )
1746 DALI_TEST_ASSERT( e, "effectExistedInScrollView", TEST_LOCATION );
1752 int UtcDaliToolkitScrollViewRemoveAllEffectsP(void)
1754 ToolkitTestApplication application;
1755 tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsP");
1757 // Create a ScrollView
1758 ScrollView scrollView = ScrollView::New();
1760 // Create two scroll view effects
1761 Dali::Path path = Dali::Path::New();
1762 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);
1763 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);
1765 // Apply both effects
1766 scrollView.ApplyEffect(effect);
1767 scrollView.ApplyEffect(newEffect);
1769 // Attempt to apply the same first effect again
1772 scrollView.ApplyEffect(effect);
1773 tet_result( TET_FAIL );
1775 catch ( DaliException& e )
1777 DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
1780 // Remove both effects
1781 scrollView.RemoveAllEffects();
1783 // Apply both effects again
1784 scrollView.ApplyEffect(effect);
1785 scrollView.ApplyEffect(newEffect);
1787 DALI_TEST_CHECK( true );
1792 int UtcDaliToolkitScrollViewRemoveAllEffectsN(void)
1794 ToolkitTestApplication application;
1795 tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsN");
1797 // Create a ScrollView
1798 ScrollView scrollView = ScrollView::New();
1800 // Remove effects when there is no effect applied previously
1801 scrollView.RemoveAllEffects();
1803 DALI_TEST_CHECK( true );
1808 int UtcDaliToolkitScrollViewSetOvershootEnabledP(void)
1810 ToolkitTestApplication application;
1811 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEnabledP");
1813 ScrollView scrollView = ScrollView::New();
1815 scrollView.SetOvershootEnabled(true);
1816 DALI_TEST_CHECK(scrollView.IsOvershootEnabled());
1818 scrollView.SetOvershootEnabled(false);
1819 DALI_TEST_CHECK(!scrollView.IsOvershootEnabled());
1824 int UtcDaliToolkitScrollViewSetOvershootEffectColorP(void)
1826 ToolkitTestApplication application;
1827 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEffectColorP");
1829 ScrollView scrollView = ScrollView::New();
1831 scrollView.SetOvershootEffectColor(Dali::Color::RED);
1832 DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::RED, TEST_LOCATION);
1834 scrollView.SetOvershootEffectColor(Dali::Color::YELLOW);
1835 DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::YELLOW, TEST_LOCATION);
1840 int UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP(void)
1842 ToolkitTestApplication application;
1843 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP");
1845 ScrollView scrollView = ScrollView::New();
1847 scrollView.SetOvershootAnimationSpeed(55.0f);
1848 DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 55.0f, TEST_LOCATION);
1850 scrollView.SetOvershootAnimationSpeed(120.0f);
1851 DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 120.0f, TEST_LOCATION);
1856 int UtcDaliToolkitScrollViewGetSet(void)
1858 ToolkitTestApplication application;
1859 tet_infoline(" UtcDaliToolkitScrollViewGetSet");
1860 ScrollView scrollView = ScrollView::New();
1861 scrollView.SetMaxFlickSpeed(0.5f);
1862 DALI_TEST_EQUALS(scrollView.GetMaxFlickSpeed(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1863 scrollView.SetFrictionCoefficient(0.6f);
1864 DALI_TEST_EQUALS(scrollView.GetFrictionCoefficient(), 0.6f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1865 scrollView.SetFlickSpeedCoefficient(0.7f);
1866 DALI_TEST_EQUALS(scrollView.GetFlickSpeedCoefficient(), 0.7f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1870 int UtcDaliToolkitScrollViewRulerDomainConstructorP(void)
1872 ToolkitTestApplication application;
1874 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
1875 DALI_TEST_EQUALS( domainX.min, 0.0f, TEST_LOCATION);
1876 DALI_TEST_EQUALS( domainX.max, 200.0f, TEST_LOCATION);
1877 DALI_TEST_EQUALS( domainX.enabled, true, TEST_LOCATION);
1879 RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
1880 DALI_TEST_EQUALS( domainY.min, 100.0f, TEST_LOCATION);
1881 DALI_TEST_EQUALS( domainY.max, 500.0f, TEST_LOCATION);
1882 DALI_TEST_EQUALS( domainY.enabled, false, TEST_LOCATION);
1887 int UtcDaliToolkitScrollViewRulerDomainGetSizeP(void)
1889 ToolkitTestApplication application;
1891 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
1892 DALI_TEST_EQUALS( domainX.GetSize(), 200.0f, TEST_LOCATION);
1894 RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
1895 DALI_TEST_EQUALS( domainY.GetSize(), 400.0f, TEST_LOCATION);
1900 int UtcDaliToolkitScrollViewRulerDomainClampP(void)
1902 ToolkitTestApplication application;
1904 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
1906 float value = domainX.Clamp(50.0f, 100.0f, 1.0f);
1907 DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
1909 value = domainX.Clamp(300.0f, 20.0f, 1.0f);
1910 DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
1912 value = domainX.Clamp(300.0f, 20.0f, 0.5f);
1913 DALI_TEST_EQUALS( value, 80.0f, TEST_LOCATION);
1915 value = domainX.Clamp(250.0f, 200.0f, 2.0f);
1916 DALI_TEST_EQUALS( value, 200.0f, TEST_LOCATION);
1921 int UtcDaliToolkitScrollViewRulerDomainClampWithStateP(void)
1923 ToolkitTestApplication application;
1925 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
1928 float value = domainX.Clamp(50.0f, 100.0f, 1.0f, clamped);
1929 DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
1930 DALI_TEST_EQUALS( clamped, Dali::Toolkit::NotClamped, TEST_LOCATION);
1932 value = domainX.Clamp(-100.0f, 200.0f, 1.0f, clamped);
1933 DALI_TEST_EQUALS( value, 0.0f, TEST_LOCATION);
1934 DALI_TEST_EQUALS( clamped, Dali::Toolkit::ClampedToMin, TEST_LOCATION);
1936 value = domainX.Clamp(300.0f, 20.0f, 1.0f, clamped);
1937 DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
1938 DALI_TEST_EQUALS( clamped, Dali::Toolkit::ClampedToMax, TEST_LOCATION);
1943 int UtcDaliToolkitScrollViewDefaultRulerConstructorP(void)
1945 ToolkitTestApplication application;
1946 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerConstructorP");
1948 RulerPtr defaultRuler = new DefaultRuler();
1949 DALI_TEST_CHECK( defaultRuler );
1954 int UtcDaliToolkitScrollViewDefaultRulerDestructorP(void)
1956 ToolkitTestApplication application;
1957 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerDestructorP");
1959 RulerPtr defaultRuler = new DefaultRuler();
1961 DALI_TEST_CHECK( true );
1965 int UtcDaliToolkitScrollViewFixedRulerConstructorP(void)
1967 ToolkitTestApplication application;
1968 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerConstructorP");
1970 RulerPtr fixedRuler = new FixedRuler( 100.0f );
1971 DALI_TEST_CHECK( fixedRuler );
1973 fixedRuler = new FixedRuler( 0.0f );
1974 DALI_TEST_CHECK( fixedRuler );
1979 int UtcDaliToolkitScrollViewFixedRulerDestructorP(void)
1981 ToolkitTestApplication application;
1982 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerDestructorP");
1984 RulerPtr fixedRuler = new FixedRuler( 100.0f );
1986 DALI_TEST_CHECK( true );
1990 int UtcDaliToolkitScrollViewRulerGetTypeP(void)
1992 ToolkitTestApplication application;
1993 tet_infoline(" UtcDaliToolkitScrollViewRulerGetTypeP");
1995 RulerPtr defaultRuler = new DefaultRuler();
1996 DALI_TEST_CHECK( defaultRuler );
1997 DALI_TEST_EQUALS( defaultRuler->GetType(), Dali::Toolkit::Ruler::Free, TEST_LOCATION);
1999 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2000 DALI_TEST_CHECK( fixedRuler );
2001 DALI_TEST_EQUALS( fixedRuler->GetType(), Dali::Toolkit::Ruler::Fixed, TEST_LOCATION);
2006 int UtcDaliToolkitScrollViewRulerGetExtensionP(void)
2008 ToolkitTestApplication application;
2009 tet_infoline(" UtcDaliToolkitScrollViewRulerGetExtensionP");
2011 RulerPtr defaultRuler = new DefaultRuler();
2012 DALI_TEST_CHECK( defaultRuler );
2013 DALI_TEST_CHECK( !defaultRuler->GetExtension() );
2015 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2016 DALI_TEST_CHECK( fixedRuler );
2017 DALI_TEST_CHECK( !fixedRuler->GetExtension() );
2022 int UtcDaliToolkitScrollViewRulerEnableDisable(void)
2024 ToolkitTestApplication application;
2025 tet_infoline(" UtcDaliToolkitScrollViewRulerEnableDisable");
2027 RulerPtr ruler = new DefaultRuler();
2029 DALI_TEST_CHECK( ruler->IsEnabled() );
2031 DALI_TEST_CHECK( !ruler->IsEnabled() );
2033 DALI_TEST_CHECK( ruler->IsEnabled() );
2037 int UtcDaliToolkitScrollViewRulerDomainEnableDisable(void)
2039 ToolkitTestApplication application;
2040 tet_infoline(" UtcDaliToolkitScrollViewRulerDomainEnableDisable");
2042 RulerPtr ruler = new DefaultRuler();
2043 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
2045 ruler->SetDomain( RulerDomain(0.0f, 100.0f, true) );
2046 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 100.0f, TEST_LOCATION );
2047 DALI_TEST_EQUALS( ruler->Clamp(-200.0f), 0.0f, TEST_LOCATION );
2048 DALI_TEST_EQUALS( ruler->Clamp(200.0f), 100.0f, TEST_LOCATION );
2050 ruler->DisableDomain();
2051 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
2052 DALI_TEST_EQUALS( ruler->Clamp(-200.0f), -200.0f, TEST_LOCATION );
2053 DALI_TEST_EQUALS( ruler->Clamp(200.0f), 200.0f, TEST_LOCATION );
2057 int UtcDaliToolkitScrollViewRulerSnapAndClamp(void)
2059 ToolkitTestApplication application;
2060 tet_infoline(" UtcDaliToolkitScrollViewRulerSnapAndClamp");
2062 RulerPtr ruler = new FixedRuler( 50.0f );
2063 ruler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2065 // default testing. (snap and clamp)
2066 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f), 50.0f, TEST_LOCATION);
2067 DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f), 50.0f, TEST_LOCATION);
2068 DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f), 0.0f, TEST_LOCATION);
2069 DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f), 0.0f, TEST_LOCATION);
2070 DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f), 400.0f, TEST_LOCATION);
2071 DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f), 400.0f, TEST_LOCATION);
2074 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
2075 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.5f), 50.0f, TEST_LOCATION); // No Flick
2076 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
2078 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
2079 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.5f), 0.0f, TEST_LOCATION); // No Flick
2080 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
2083 DALI_TEST_EQUALS( ruler->SnapAndClamp(-10.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (over left boundary)
2084 DALI_TEST_EQUALS( ruler->SnapAndClamp(-5.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (slightly ovr left boundary)
2085 DALI_TEST_EQUALS( ruler->SnapAndClamp(300.0f, 0.5f, 10.0f), 300.0f, TEST_LOCATION); // 10 units long (not over a boundary)
2086 DALI_TEST_EQUALS( ruler->SnapAndClamp(395.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (slightly over right boundary)
2087 DALI_TEST_EQUALS( ruler->SnapAndClamp(500.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (over right boundary)
2090 DALI_TEST_EQUALS( ruler->SnapAndClamp(-100.0f, 0.5f, 0.0f, 2.0f), 0.0f, TEST_LOCATION);
2091 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 2.0f), 50.0f, TEST_LOCATION);
2092 DALI_TEST_EQUALS( ruler->SnapAndClamp(700.0f, 0.5f, 0.0f, 2.0f), 700.0f, TEST_LOCATION);
2093 DALI_TEST_EQUALS( ruler->SnapAndClamp(850.0f, 0.5f, 0.0f, 2.0f), 800.0f, TEST_LOCATION);
2095 // clamp state testing.
2097 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
2098 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2099 DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
2100 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2101 DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
2102 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2103 DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
2104 DALI_TEST_EQUALS( clamped, ClampedToMin, TEST_LOCATION );
2105 DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
2106 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
2107 DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
2108 DALI_TEST_EQUALS( clamped, ClampedToMax, TEST_LOCATION );
2112 int UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP(void)
2114 ToolkitTestApplication application;
2115 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP");
2117 RulerPtr rulerNormal = new FixedRuler( 25.0f );
2118 rulerNormal->SetDomain( RulerDomain(10.0f, 90.0f, true) );
2120 unsigned int volume;
2123 position = rulerNormal->GetPositionFromPage(1, volume, true);
2124 DALI_TEST_EQUALS( position, 35.0f, TEST_LOCATION );
2125 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
2127 position = rulerNormal->GetPositionFromPage(2, volume, true);
2128 DALI_TEST_EQUALS( position, 60.0f, TEST_LOCATION );
2129 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
2131 // Disable the ruler
2132 rulerNormal->Disable();
2134 position = rulerNormal->GetPositionFromPage(1, volume, true);
2135 DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
2136 DALI_TEST_EQUALS( volume, 1u, TEST_LOCATION );
2138 position = rulerNormal->GetPositionFromPage(2, volume, true);
2139 DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
2140 DALI_TEST_EQUALS( volume, 2u, TEST_LOCATION );
2145 int UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP(void)
2147 ToolkitTestApplication application;
2148 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP");
2150 RulerPtr defaultRuler = new DefaultRuler();
2151 DALI_TEST_CHECK( defaultRuler );
2152 DALI_TEST_EQUALS( defaultRuler->GetTotalPages(), 1u, TEST_LOCATION);
2157 int UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP(void)
2159 ToolkitTestApplication application;
2160 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP");
2162 RulerPtr defaultRuler = new DefaultRuler();
2163 DALI_TEST_CHECK( defaultRuler );
2164 DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(100.0f, true), 0u, TEST_LOCATION);
2165 DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(-300.0f, false), 0u, TEST_LOCATION);
2170 int UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP(void)
2172 ToolkitTestApplication application;
2173 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP");
2175 RulerPtr defaultRuler = new DefaultRuler();
2176 DALI_TEST_CHECK( defaultRuler );
2178 unsigned int volume;
2179 DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(0, volume, true), 0.0f, TEST_LOCATION);
2180 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
2182 DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(3, volume, false), 0.0f, TEST_LOCATION);
2183 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
2188 int UtcDaliToolkitScrollViewDefaultRulerSnapP(void)
2190 ToolkitTestApplication application;
2191 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerSnapP");
2193 RulerPtr defaultRuler = new DefaultRuler();
2194 DALI_TEST_CHECK( defaultRuler );
2196 DALI_TEST_EQUALS( defaultRuler->Snap(50.0f, 0.5f), 50.0f, TEST_LOCATION);
2197 DALI_TEST_EQUALS( defaultRuler->Snap(-120.0f, 1.0f), -120.0f, TEST_LOCATION);
2202 int UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP(void)
2204 ToolkitTestApplication application;
2205 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP");
2207 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2208 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2210 fixedRuler->Enable();
2211 DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 4u, TEST_LOCATION);
2213 fixedRuler->Disable();
2214 DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 1u, TEST_LOCATION);
2219 int UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP(void)
2221 ToolkitTestApplication application;
2222 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP");
2224 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2225 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2227 fixedRuler->Enable();
2228 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 3u, TEST_LOCATION);
2229 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2230 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 1u, TEST_LOCATION);
2231 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2233 fixedRuler->Disable();
2234 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2235 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
2236 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2237 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2239 // Set domain size to be smaller than the ruler space
2240 fixedRuler->SetDomain( RulerDomain(0.0f, 50.0f, true) );
2242 fixedRuler->Enable();
2243 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2244 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2245 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2246 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2248 fixedRuler->Disable();
2249 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2250 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
2251 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2252 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2257 int UtcDaliToolkitScrollViewFixedRulerSnapP(void)
2259 ToolkitTestApplication application;
2260 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerSnapP");
2262 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2263 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2265 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.0f), -100.0f, TEST_LOCATION);
2266 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.0f), -100.0f, TEST_LOCATION);
2267 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.0f), -200.0f, TEST_LOCATION);
2268 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.0f), -500.0f, TEST_LOCATION);
2269 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.0f), 0.0f, TEST_LOCATION);
2270 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.0f), 0.0f, TEST_LOCATION);
2271 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.0f), 0.0f, TEST_LOCATION);
2272 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.0f), 100.0f, TEST_LOCATION);
2273 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.0f), 100.0f, TEST_LOCATION);
2274 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.0f), 200.0f, TEST_LOCATION);
2275 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.0f), 600.0f, TEST_LOCATION);
2277 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.5f), 0.0f, TEST_LOCATION);
2278 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.5f), -100.0f, TEST_LOCATION);
2279 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.5f), -100.0f, TEST_LOCATION);
2280 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.5f), -500.0f, TEST_LOCATION);
2281 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.5f), 0.0f, TEST_LOCATION);
2282 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.5f), 100.0f, TEST_LOCATION);
2283 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.5f), 100.0f, TEST_LOCATION);
2284 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.5f), 100.0f, TEST_LOCATION);
2285 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.5f), 100.0f, TEST_LOCATION);
2286 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.5f), 300.0f, TEST_LOCATION);
2287 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.5f), 600.0f, TEST_LOCATION);
2289 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 1.0f), 0.0f, TEST_LOCATION);
2290 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 1.0f), 0.0f, TEST_LOCATION);
2291 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 1.0f), -100.0f, TEST_LOCATION);
2292 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 1.0f), -400.0f, TEST_LOCATION);
2293 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 1.0f), 100.0f, TEST_LOCATION);
2294 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 1.0f), 100.0f, TEST_LOCATION);
2295 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 1.0f), 100.0f, TEST_LOCATION);
2296 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 1.0f), 200.0f, TEST_LOCATION);
2297 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 1.0f), 200.0f, TEST_LOCATION);
2298 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 1.0f), 300.0f, TEST_LOCATION);
2299 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 1.0f), 700.0f, TEST_LOCATION);
2304 int UtcDaliToolkitScrollViewConstraintsMove(void)
2306 ToolkitTestApplication application;
2307 tet_infoline(" UtcDaliToolkitScrollViewConstraintsMove");
2309 // Set up a scrollView...
2310 ScrollView scrollView = ScrollView::New();
2311 Stage::GetCurrent().Add( scrollView );
2312 Vector2 stageSize = Stage::GetCurrent().GetSize();
2313 scrollView.SetSize(stageSize);
2314 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
2315 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2318 RulerPtr rulerX = new DefaultRuler();
2319 RulerPtr rulerY = new DefaultRuler();
2320 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
2321 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
2322 scrollView.SetRulerX(rulerX);
2323 scrollView.SetRulerY(rulerY);
2325 // Add an Actor to ScrollView,
2326 Actor a = Actor::New();
2328 a.SetPosition( TEST_ACTOR_POSITION );
2331 const Vector2 target = Vector2(100.0f, 100.0f);
2332 const Vector2 target2 = Vector2(200.0f, 200.0f);
2334 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, MoveActorConstraint );
2335 constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
2336 constraint.SetRemoveAction(Constraint::Discard);
2337 scrollView.ApplyConstraintToChildren(constraint);
2339 scrollView.ScrollTo( target, 0.0f );
2341 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
2342 scrollView.ScrollTo( target2 );
2343 Wait(application, RENDER_DELAY_SCROLL);
2344 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
2349 int UtcDaliToolkitScrollViewConstraintsWrap(void)
2351 ToolkitTestApplication application;
2352 tet_infoline(" UtcDaliToolkitScrollViewConstraintsWrap");
2354 // Set up a scrollView...
2355 ScrollView scrollView = ScrollView::New();
2356 Stage::GetCurrent().Add( scrollView );
2357 Vector2 stageSize = Stage::GetCurrent().GetSize();
2358 scrollView.SetSize(stageSize);
2359 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
2360 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
2363 RulerPtr rulerX = new DefaultRuler();
2364 RulerPtr rulerY = new DefaultRuler();
2365 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
2366 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
2367 scrollView.SetRulerX(rulerX);
2368 scrollView.SetRulerY(rulerY);
2370 // Add an Actor to ScrollView,
2371 Actor a = Actor::New();
2373 a.SetPosition( TEST_ACTOR_POSITION );
2376 const Vector2 target = Vector2(100.0f, 100.0f);
2377 const Vector2 target2 = Vector2(200.0f, 200.0f);
2379 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, WrapActorConstraint );
2380 constraint.AddSource( LocalSource( Actor::Property::SCALE ) );
2381 constraint.AddSource( LocalSource( Actor::Property::ANCHOR_POINT ) );
2382 constraint.AddSource( LocalSource( Actor::Property::SIZE ) );
2383 constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
2384 constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
2385 constraint.AddSource( Source( scrollView, Toolkit::ScrollView::Property::WRAP ) );
2386 constraint.SetRemoveAction(Constraint::Discard);
2387 scrollView.ApplyConstraintToChildren(constraint);
2389 scrollView.ScrollTo( target, 0.0f );
2391 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
2392 scrollView.ScrollTo( target2 );
2393 Wait(application, RENDER_DELAY_SCROLL);
2394 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
2396 scrollView.Remove(a);
2402 // Non-API test (so no P or N variant).
2403 int UtcDaliToolkitScrollViewGesturePageLimit(void)
2405 ToolkitTestApplication application;
2406 tet_infoline( " UtcDaliToolkitScrollViewGesturePageLimit" );
2408 // Set up a scrollView.
2409 ScrollView scrollView = ScrollView::New();
2411 // Do not rely on stage size for UTC tests.
2412 Vector2 pageSize( 720.0f, 1280.0f );
2413 scrollView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
2414 scrollView.SetSize( pageSize );
2415 scrollView.SetParentOrigin( ParentOrigin::CENTER );
2416 scrollView.SetAnchorPoint( AnchorPoint::CENTER );
2417 scrollView.SetPosition( 0.0f, 0.0f, 0.0f );
2420 // We set the X ruler to fixed to give us pages to snap to.
2421 Dali::Toolkit::FixedRuler* rulerX = new Dali::Toolkit::FixedRuler( pageSize.width );
2422 // Note: The 3x page width is arbitary, but we need enough to show that we are
2423 // capping page movement by the page limiter, and not the domain.
2424 rulerX->SetDomain( Dali::Toolkit::RulerDomain( 0.0f, pageSize.width * 3.0f, false ) );
2425 Dali::Toolkit::RulerPtr rulerY = new Dali::Toolkit::DefaultRuler();
2427 scrollView.SetRulerX( rulerX );
2428 scrollView.SetRulerY( rulerY );
2430 scrollView.SetWrapMode( false );
2431 scrollView.SetScrollSensitive( true );
2433 Stage::GetCurrent().Add( scrollView );
2435 // Set up a gesture to perform.
2436 Vector2 startPos( 50.0f, 0.0f );
2437 Vector2 direction( -5.0f, 0.0f );
2440 // Force starting position.
2441 scrollView.ScrollTo( startPos, 0.0f );
2442 Wait( application );
2444 // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
2445 Vector2 currentPos( PerformGestureDiagonalSwipe( application, startPos, direction, frames - 1, false ) );
2447 // Confirm the final X coord has not moved more than one page from the start X position.
2448 DALI_TEST_GREATER( ( startPos.x + pageSize.width ), scrollView.GetCurrentScrollPosition().x, TEST_LOCATION );
2450 // Finish the gesture and wait for the snap.
2451 currentPos += direction;
2452 SendPan( application, Gesture::Finished, currentPos );
2453 // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
2454 Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL );
2456 // Confirm the final X coord has snapped to exactly one page ahead of the start page.
2457 DALI_TEST_EQUALS( pageSize.width, scrollView.GetCurrentScrollPosition().x, Math::MACHINE_EPSILON_0, TEST_LOCATION );
2462 int UtcDaliScrollViewSetGetProperty(void)
2464 ToolkitTestApplication application;
2466 // Create the ScrollView actor
2467 ScrollView scrollView = ScrollView::New();
2468 DALI_TEST_CHECK(scrollView);
2470 // Event side properties
2472 // Test "wrapEnabled" property
2473 DALI_TEST_CHECK( scrollView.GetPropertyIndex("wrapEnabled") == ScrollView::Property::WRAP_ENABLED );
2474 scrollView.SetProperty( ScrollView::Property::WRAP_ENABLED, true );
2475 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WRAP_ENABLED).Get<bool>(), true, TEST_LOCATION );
2477 // Test "panningEnabled" property
2478 DALI_TEST_CHECK( scrollView.GetPropertyIndex("panningEnabled") == ScrollView::Property::PANNING_ENABLED );
2479 scrollView.SetProperty( ScrollView::Property::PANNING_ENABLED, false );
2480 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::PANNING_ENABLED).Get<bool>(), false, TEST_LOCATION );
2482 // Test "axisAutoLockEnabled" property
2483 DALI_TEST_CHECK( scrollView.GetPropertyIndex("axisAutoLockEnabled") == ScrollView::Property::AXIS_AUTO_LOCK_ENABLED );
2484 scrollView.SetProperty( ScrollView::Property::AXIS_AUTO_LOCK_ENABLED, false );
2485 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::AXIS_AUTO_LOCK_ENABLED).Get<bool>(), false, TEST_LOCATION );
2487 // Test "wheelScrollDistanceStep" property
2488 DALI_TEST_CHECK( scrollView.GetPropertyIndex("wheelScrollDistanceStep") == ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP );
2489 scrollView.SetProperty( ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP, Vector2(100.0f, 50.0f) );
2490 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP).Get<Vector2>(), Vector2(100.0f, 50.0f), TEST_LOCATION );
2492 // Test "overshootEnabled" property
2493 DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootEnabled") == Scrollable::Property::OVERSHOOT_ENABLED );
2494 DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), scrollView.IsOvershootEnabled(), TEST_LOCATION );
2495 scrollView.SetProperty( Scrollable::Property::OVERSHOOT_ENABLED, false );
2496 DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), false, TEST_LOCATION );
2498 // Animatable properties
2500 // Test "scrollPosition" property
2501 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPosition") == ScrollView::Property::SCROLL_POSITION );
2502 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(320.0f, 550.0f) );
2504 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION).Get<Vector2>(), Vector2(320.0f, 550.0f), TEST_LOCATION );
2506 // Test "scrollPrePosition", "scrollPrePositionX" and "scrollPrePositionY" properties
2507 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePosition") == ScrollView::Property::SCROLL_PRE_POSITION );
2508 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION, Vector2(300.0f, 500.0f) );
2510 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION).Get<Vector2>(), Vector2(300.0f, 500.0f), TEST_LOCATION );
2512 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionX") == ScrollView::Property::SCROLL_PRE_POSITION_X );
2513 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionY") == ScrollView::Property::SCROLL_PRE_POSITION_Y );
2514 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_X).Get<float>(), 300.0f, TEST_LOCATION );
2515 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_Y).Get<float>(), 500.0f, TEST_LOCATION );
2516 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_X, 400.0f );
2517 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_Y, 600.0f );
2519 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_X).Get<float>(), 400.0f, TEST_LOCATION );
2520 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_Y).Get<float>(), 600.0f, TEST_LOCATION );
2521 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION).Get<Vector2>(), Vector2(400.0f, 600.0f), TEST_LOCATION );
2523 // Test "scrollPrePositionMax", "scrollPrePositionMaxX" and "scrollPrePositionMaxY" properties
2524 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMax") == ScrollView::Property::SCROLL_PRE_POSITION_MAX );
2525 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX, Vector2(100.0f, 200.0f) );
2527 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX).Get<Vector2>(), Vector2(100.0f, 200.0f), TEST_LOCATION );
2529 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMaxX") == ScrollView::Property::SCROLL_PRE_POSITION_MAX_X );
2530 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPrePositionMaxY") == ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y );
2531 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_X).Get<float>(), 100.0f, TEST_LOCATION );
2532 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y).Get<float>(), 200.0f, TEST_LOCATION );
2533 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX_X, 300.0f );
2534 scrollView.SetProperty( ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y, 400.0f );
2536 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_X).Get<float>(), 300.0f, TEST_LOCATION );
2537 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y).Get<float>(), 400.0f, TEST_LOCATION );
2538 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX).Get<Vector2>(), Vector2(300.0f, 400.0f), TEST_LOCATION );
2540 // Test "overshootX" property
2541 DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootX") == ScrollView::Property::OVERSHOOT_X );
2542 scrollView.SetProperty( ScrollView::Property::OVERSHOOT_X, 0.8f );
2544 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::OVERSHOOT_X).Get<float>(), 0.8f, TEST_LOCATION );
2546 // Test "overshootY" property
2547 DALI_TEST_CHECK( scrollView.GetPropertyIndex("overshootY") == ScrollView::Property::OVERSHOOT_Y );
2548 scrollView.SetProperty( ScrollView::Property::OVERSHOOT_Y, 0.8f );
2550 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y).Get<float>(), 0.8f, TEST_LOCATION );
2552 // Test "scrollFinal", "scrollFinalX" and "scrollFinalY" properties
2553 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinal") == ScrollView::Property::SCROLL_FINAL );
2554 scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL, Vector2(200.0f, 300.0f) );
2556 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL).Get<Vector2>(), Vector2(200.0f, 300.0f), TEST_LOCATION );
2558 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinalX") == ScrollView::Property::SCROLL_FINAL_X );
2559 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollFinalY") == ScrollView::Property::SCROLL_FINAL_Y );
2560 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_X).Get<float>(), 200.0f, TEST_LOCATION );
2561 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_Y).Get<float>(), 300.0f, TEST_LOCATION );
2562 scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL_X, 500.0f );
2563 scrollView.SetProperty( ScrollView::Property::SCROLL_FINAL_Y, 600.0f );
2565 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_X).Get<float>(), 500.0f, TEST_LOCATION );
2566 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_Y).Get<float>(), 600.0f, TEST_LOCATION );
2567 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL).Get<Vector2>(), Vector2(500.0f, 600.0f), TEST_LOCATION );
2569 // Test "wrap" property
2570 DALI_TEST_CHECK( scrollView.GetPropertyIndex("wrap") == ScrollView::Property::WRAP );
2571 scrollView.SetProperty( ScrollView::Property::WRAP, false );
2573 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::WRAP).Get<bool>(), false, TEST_LOCATION );
2575 // Test "panning" property
2576 DALI_TEST_CHECK( scrollView.GetPropertyIndex("panning") == ScrollView::Property::PANNING );
2577 scrollView.SetProperty( ScrollView::Property::PANNING, true );
2579 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::PANNING).Get<bool>(), true, TEST_LOCATION );
2581 // Test "scrolling" property
2582 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrolling") == ScrollView::Property::SCROLLING );
2583 scrollView.SetProperty( ScrollView::Property::SCROLLING, false );
2585 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLLING).Get<bool>(), false, TEST_LOCATION );
2587 // Test "scrollDomainSize", "scrollDomainSizeX" and "scrollDomainSizeY" properties
2588 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSize") == ScrollView::Property::SCROLL_DOMAIN_SIZE );
2589 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE, Vector2(1200.0f, 1300.0f) );
2591 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE).Get<Vector2>(), Vector2(1200.0f, 1300.0f), TEST_LOCATION );
2593 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSizeX") == ScrollView::Property::SCROLL_DOMAIN_SIZE_X );
2594 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainSizeY") == ScrollView::Property::SCROLL_DOMAIN_SIZE_Y );
2595 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_X).Get<float>(), 1200.0f, TEST_LOCATION );
2596 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_Y).Get<float>(), 1300.0f, TEST_LOCATION );
2597 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE_X, 1500.0f );
2598 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_SIZE_Y, 1600.0f );
2600 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_X).Get<float>(), 1500.0f, TEST_LOCATION );
2601 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_Y).Get<float>(), 1600.0f, TEST_LOCATION );
2602 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE).Get<Vector2>(), Vector2(1500.0f, 1600.0f), TEST_LOCATION );
2604 // Test "scrollDomainOffset" property
2605 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollDomainOffset") == ScrollView::Property::SCROLL_DOMAIN_OFFSET );
2606 scrollView.SetProperty( ScrollView::Property::SCROLL_DOMAIN_OFFSET, Vector2(500.0f, 200.0f) );
2608 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_OFFSET).Get<Vector2>(), Vector2(500.0f, 200.0f), TEST_LOCATION );
2610 // Test "scrollPositionDelta" property
2611 DALI_TEST_CHECK( scrollView.GetPropertyIndex("scrollPositionDelta") == ScrollView::Property::SCROLL_POSITION_DELTA );
2612 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION_DELTA, Vector2(10.0f, 30.0f) );
2614 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION_DELTA).Get<Vector2>(), Vector2(10.0f, 30.0f), TEST_LOCATION );
2616 // Test "startPagePosition" property
2617 DALI_TEST_CHECK( scrollView.GetPropertyIndex("startPagePosition") == ScrollView::Property::START_PAGE_POSITION );
2618 scrollView.SetProperty( ScrollView::Property::START_PAGE_POSITION, Vector3(50.0f, 100.0f, 20.0f) );
2620 DALI_TEST_EQUALS( scrollView.GetProperty(ScrollView::Property::START_PAGE_POSITION).Get<Vector3>(), Vector3(50.0f, 100.0f, 20.0f), TEST_LOCATION );