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;
48 const int MILLISECONDS_PER_SECOND = 1000;
49 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
50 const int RENDER_ANIMATION_TEST_DURATION_MS = 1000; ///< 1000ms to test animation
51 const int RENDER_DELAY_SCROLL = 1000; ///< duration to wait for any scroll to complete.
53 // For Clamp Signal testing...
54 const float CLAMP_EXCESS_WIDTH = 200.0f; ///< Amount of width that can be panned outside scrollview
55 const float CLAMP_EXCESS_HEIGHT = 200.0f; ///< Amount of height that can be panned outside scrollview
56 const int CLAMP_STEP_0_CHECK_NOTCLAMPED = 0; ///< FSM: "First check that scrollview isn't clamped"
57 const int CLAMP_STEP_1_CHECK_CLAMPED_WEST = 1; ///< FSM: "Next check that scrollview clamps against left side"
58 const int CLAMP_STEP_2_CHECK_CLAMPED_SOUTH_WEST = 2; ///< FSM: "Then check that scrollview clamps against bottom-left side"
59 const int CLAMP_STEP_3_SUCCESS = 3; ///< FSM: "Finished (Success)"
60 const Vector2 CLAMP_START_SCROLL_POSITION(30.0f, 100.0f); ///< Scroll start position for the Clamping tests.
61 const Vector2 CLAMP_TOUCH_START( 100.0f, 100.0f ); ///< Start point to touch from for the Clamping tests.
62 const Vector2 CLAMP_TOUCH_MOVEMENT( 5.0f, -5.0f ); ///< Amount to move touch for each frame for the Clamping tests.
63 const int CLAMP_GESTURE_FRAMES = 100; ///< Number of Frames to synthesize a gesture for the Clamping tests.
64 const Vector3 TEST_ACTOR_POSITION(100.0f, 100.0f, 0.0f); ///< A Test actor position offset (arbitrary value)
65 const Vector3 TEST_CONSTRAINT_OFFSET(1.0f, 2.0f, 0.0f); ///< A Test constraint offset (arbitrary value to test effects)
66 const float TEST_RATIO_TOLERANCE = 0.05; ///< +/-5% tolerance for ratio comparisons.
68 const float DEFAULT_SNAP_OVERSHOOT_DURATION(0.5f); ///< Default overshoot snapping animation time.
69 const float DEFAULT_MAX_OVERSHOOT(100.0f); ///< Default maximum allowed overshoot in pixels
71 const int MAX_FRAMES_TO_TEST_OVERSHOOT = 600; ///< 10 seconds (at 60 frames per second).
72 const Vector2 OVERSHOOT_START_SCROLL_POSITION(100.0f, 100.0f); ///< Scroll start position for the Overshoot tests.
73 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)
74 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).
75 const float TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION = 0.05f; ///< a Test duration
76 const float TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION = 1.5f; ///< another Test duration
77 const float TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION = TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * 0.5f; // Same as above, but different alpha function.
78 const float TIME_TOLERANCE = 0.05f; ///< Allow testing tolerance between a 10th of second (+/- 3 frames)
81 // Generate a PanGestureEvent to send to Core
82 Integration::PanGestureEvent GeneratePan(
84 const Vector2& previousPosition,
85 const Vector2& currentPosition,
86 unsigned long timeDelta,
87 unsigned int numberOfTouches = 1)
89 Integration::PanGestureEvent pan(state);
91 pan.previousPosition = previousPosition;
92 pan.currentPosition = currentPosition;
93 pan.timeDelta = timeDelta;
94 pan.numberOfTouches = numberOfTouches;
100 * Helper to generate PanGestureEvent
102 * @param[in] application Application instance
103 * @param[in] state The Gesture State
104 * @param[in] pos The current position of touch.
106 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
110 if( (state == Gesture::Started) ||
111 (state == Gesture::Possible) )
117 application.ProcessEvent(GeneratePan(state, last, pos, RENDER_FRAME_INTERVAL));
124 * Simulate time passed by.
126 * @note this will always process at least 1 frame (1/60 sec)
128 * @param application Test application instance
129 * @param duration Time to pass in milliseconds.
130 * @return The actual time passed in milliseconds
132 int Wait(ToolkitTestApplication& application, int duration = 0)
136 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
138 application.SendNotification();
139 application.Render(RENDER_FRAME_INTERVAL);
140 time += RENDER_FRAME_INTERVAL;
148 static bool gOnScrollStartCalled; ///< Whether the OnScrollStart signal was invoked.
149 static bool gOnScrollUpdateCalled; ///< Whether the OnScrollUpdate signal was invoked.
150 static bool gOnScrollCompleteCalled; ///< Whether the OnScrollComplete signal was invoked.
151 static bool gOnSnapStartCalled; ///< Whether the OnSnapStart signal was invoked.
152 static SnapType gLastSnapType; ///< Snaping information from SnapEvent.
153 static Vector3 gConstraintResult; ///< Result from constraint.
156 * Invoked when scrolling starts.
158 * @param[in] position The current scroll position.
160 static void OnScrollStart( const Vector2& position )
162 gOnScrollStartCalled = true;
166 * Invoked when scrolling updates (via dragging)
168 * @param[in] position The current scroll position.
170 static void OnScrollUpdate( const Vector2& position )
172 gOnScrollUpdateCalled = true;
176 * Invoked when scrolling finishes
178 * @param[in] position The current scroll position.
180 static void OnScrollComplete( const Vector2& position )
182 gOnScrollCompleteCalled = true;
186 * Invoked when a snap or flick started.
188 * @param[in] event The type of snap and the target position/scale/rotation.
190 static void OnSnapStart( const ScrollView::SnapEvent& event )
192 gOnSnapStartCalled = true;
193 gLastSnapType = event.type;
199 * Summation of current value, property, and offset.
201 * current' = current + mOffset + property;
203 struct TestSumConstraint
206 * @param[in] offset The offset to be added to current.
208 TestSumConstraint(const Vector3& offset)
214 * @param[in] current The current base value
215 * @param[in] inputs Contains the property to be added to current.
216 * @return The new current Vector.
218 void operator()( Vector3& current, const PropertyInputContainer& inputs )
220 gConstraintResult = current + Vector3(inputs[0]->GetVector2()) + mOffset;
221 current = gConstraintResult;
229 * @param[in] application The application instance
230 * @param[in] scrollView The scrollView instance
231 * @return The time taken for the overshoot to reach origin (zero)
233 static float TestOvershootSnapDuration(ToolkitTestApplication &application, ScrollView scrollView)
235 int timeToReachOrigin = -1;
236 for(int i = 0;i<MAX_FRAMES_TO_TEST_OVERSHOOT;i++)
238 float overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
239 float overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
240 if(overshootXValue == 0.0f && overshootYValue == 0.0f)
245 timeToReachOrigin += Wait(application);
248 return static_cast<float>(timeToReachOrigin) * 0.001f; // return in seconds not ms.
252 * y = 2x alpha function, which is clamped between 0.0f - 1.0f
254 * Animations should appear to finish (reach 100% point)
255 * at just half the time of a regular Linear AlphaFunction.
257 * @param[in] progress value (ranges from 0.0f - 1.0f)
258 * @return interpolation value (ranges from 0.0f - 1.0f)
260 float TestAlphaFunction(float progress)
262 return std::min( progress * 2.0f, 1.0f );
265 } // unnamed namespace
268 int UtcDaliToolkitScrollViewConstructorP(void)
270 ToolkitTestApplication application;
272 ScrollView scrollView;
273 DALI_TEST_CHECK( !scrollView );
277 int UtcDaliToolkitScrollViewCopyConstructorP(void)
279 ToolkitTestApplication application;
281 ScrollView scrollView = ScrollView::New();
282 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) );
284 ScrollView copy( scrollView );
285 DALI_TEST_CHECK( copy );
286 DALI_TEST_CHECK( copy.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) == scrollView.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) );
290 int UtcDaliToolkitScrollViewAssignmentOperatorP(void)
292 ToolkitTestApplication application;
294 ScrollView scrollView = ScrollView::New();
295 scrollView.SetProperty( ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f) );
297 ScrollView copy = scrollView;
298 DALI_TEST_CHECK( copy );
299 DALI_TEST_CHECK( copy.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) == scrollView.GetProperty<Vector2>( ScrollView::Property::SCROLL_POSITION ) );
303 int UtcDaliScrollViewDestructorP(void)
305 ToolkitTestApplication application;
307 ScrollView* scrollView = new ScrollView();
310 DALI_TEST_CHECK( true );
314 int UtcDaliToolkitScrollViewNewP(void)
316 ToolkitTestApplication application;
317 tet_infoline(" UtcDaliToolkitScrollViewNewP");
319 ScrollView scrollView;
321 DALI_TEST_CHECK( !scrollView );
323 scrollView = ScrollView::New();
325 DALI_TEST_CHECK( scrollView );
327 ScrollView scrollView2(scrollView);
329 DALI_TEST_CHECK( scrollView2 == scrollView );
331 //Additional check to ensure object is created by checking if it's registered
332 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
333 DALI_TEST_CHECK( registry );
335 gObjectCreatedCallBackCalled = false;
336 registry.ObjectCreatedSignal().Connect( &TestCallback );
338 ScrollView scrollView = ScrollView::New();
340 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
344 int UtcDaliToolkitScrollViewDownCastP(void)
346 ToolkitTestApplication application;
347 tet_infoline(" UtcDaliToolkitScrollViewDownCastP");
349 ScrollView scrollView = ScrollView::New();
350 BaseHandle handle(scrollView);
352 ScrollView newScrollView = ScrollView::DownCast( handle );
353 DALI_TEST_CHECK( scrollView );
354 DALI_TEST_CHECK( newScrollView == scrollView );
358 int UtcDaliToolkitScrollViewScrollToPositionP(void)
360 ToolkitTestApplication application;
361 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionP");
363 // Create the ScrollView actor
364 ScrollView scrollView = ScrollView::New();
365 Stage::GetCurrent().Add( scrollView );
367 const Vector2 target = Vector2(100.0f, 200.0f);
368 const Vector2 target2 = Vector2(300.0f, 100.0f);
370 scrollView.ScrollTo( target, 0.0f );
372 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
373 scrollView.ScrollTo( target2 );
374 Wait(application, RENDER_DELAY_SCROLL);
375 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
380 int UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP(void)
382 ToolkitTestApplication application;
383 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP");
385 ScrollView scrollView = ScrollView::New();
386 Stage::GetCurrent().Add( scrollView );
387 RulerPtr rulerX = new FixedRuler( 100.0f );
388 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
389 RulerPtr rulerY = new FixedRuler( 100.0f );
390 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
392 scrollView.SetRulerX( rulerX );
393 scrollView.SetRulerY( rulerY );
395 scrollView.SetWrapMode(true);
397 const Vector2 target = Vector2(50.0f, 50.0f);
398 const Vector2 target2 = Vector2(150.0f, 150.0f);
400 scrollView.ScrollTo( target, 0.0f );
401 Wait(application, RENDER_DELAY_SCROLL);
402 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
404 scrollView.ScrollTo( target2, 0.25f, Dali::Toolkit::DirectionBiasLeft, Dali::Toolkit::DirectionBiasLeft );
405 Wait(application, RENDER_DELAY_SCROLL);
406 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2::ZERO, TEST_LOCATION );
408 scrollView.ScrollTo( target, 0.0f );
409 Wait(application, RENDER_DELAY_SCROLL);
410 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
412 scrollView.ScrollTo( target2, 0.25f, Dali::Toolkit::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
413 Wait(application, RENDER_DELAY_SCROLL);
414 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
419 int UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionP(void)
421 ToolkitTestApplication application;
422 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionP");
424 // Create the ScrollView actor
425 ScrollView scrollView = ScrollView::New();
426 Stage::GetCurrent().Add( scrollView );
428 const Vector2 target = Vector2(100.0f, 200.0f);
429 const Vector2 target2 = Vector2(300.0f, 100.0f);
431 scrollView.ScrollTo( target, 0.5f, TestAlphaFunction );
432 Wait(application, 250);
433 // Check that the scroll animation should finish within just half of the specified duration with the above alpha function
434 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
436 scrollView.ScrollTo( target2, 0.5f, AlphaFunction::LINEAR );
437 Wait(application, 250);
438 // Check that the scroll animation has not finished within half of the specified duration with the linear alpha function
439 DALI_TEST_CHECK( scrollView.GetCurrentScrollPosition() != target2 );
441 // Wait till the end of the specified duration
442 Wait(application, 250);
443 // Check that the scroll animation has finished
444 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
449 int UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionAndDirectionBiasP(void)
451 ToolkitTestApplication application;
452 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionAndDirectionBiasP");
454 ScrollView scrollView = ScrollView::New();
455 Stage::GetCurrent().Add( scrollView );
456 RulerPtr rulerX = new FixedRuler( 100.0f );
457 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
458 RulerPtr rulerY = new FixedRuler( 100.0f );
459 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
461 scrollView.SetRulerX( rulerX );
462 scrollView.SetRulerY( rulerY );
464 scrollView.SetWrapMode(true);
466 const Vector2 target = Vector2(50.0f, 50.0f);
467 const Vector2 target2 = Vector2(150.0f, 150.0f);
469 scrollView.ScrollTo( target, 0.0f );
470 Wait(application, RENDER_DELAY_SCROLL);
471 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
473 scrollView.ScrollTo( target2, 0.25f, AlphaFunction::LINEAR, Dali::Toolkit::DirectionBiasLeft, Dali::Toolkit::DirectionBiasLeft );
474 Wait(application, RENDER_DELAY_SCROLL);
475 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2::ZERO, TEST_LOCATION );
477 scrollView.ScrollTo( target, 0.0f );
478 Wait(application, RENDER_DELAY_SCROLL);
479 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
481 scrollView.ScrollTo( target2, 0.25f, AlphaFunction::LINEAR, Dali::Toolkit::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
482 Wait(application, RENDER_DELAY_SCROLL);
483 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
485 scrollView.ScrollTo( target, 0.0f );
486 Wait(application, RENDER_DELAY_SCROLL);
487 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
489 scrollView.ScrollTo( target2, 0.25f, TestAlphaFunction, Dali::Toolkit::DirectionBiasRight, Dali::Toolkit::DirectionBiasRight );
490 Wait(application, 125);
491 // Check that the scroll animation should finish within just half of the specified duration with the above alpha function
492 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
497 int UtcDaliToolkitScrollViewScrollToPageP(void)
499 ToolkitTestApplication application;
500 tet_infoline(" UtcDaliToolkitScrollViewScrollToPageP");
502 ScrollView scrollView = ScrollView::New();
503 Stage::GetCurrent().Add( scrollView );
504 RulerPtr rulerX = new FixedRuler( 100.0f );
505 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
506 RulerPtr rulerY = new FixedRuler( 100.0f );
507 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
509 scrollView.SetRulerX( rulerX );
510 scrollView.SetRulerY( rulerY );
512 scrollView.ScrollTo( 1, 0.0f );
514 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION );
516 scrollView.ScrollTo( 5, 0.0f );
518 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(500.0f, 0.0f), TEST_LOCATION );
520 scrollView.ScrollTo( 10, 0.0f );
522 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 100.0f), TEST_LOCATION );
524 scrollView.ScrollTo( 15, 0.0f );
526 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(700.0f, 100.0f), TEST_LOCATION );
527 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION );
529 scrollView.ScrollTo( 3 );
530 Wait(application, RENDER_DELAY_SCROLL);
531 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(300.0f, 0.0f), TEST_LOCATION );
532 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION );
534 scrollView.ScrollTo( 9 );
535 Wait(application, RENDER_DELAY_SCROLL);
536 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 100.0f), TEST_LOCATION );
537 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION );
539 // Apply DefaultRulers instead and see what happens.
540 rulerX = new DefaultRuler();
541 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
542 rulerY = new DefaultRuler();
543 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
545 scrollView.SetRulerX( rulerX );
546 scrollView.SetRulerY( rulerY );
548 // This time should always scroll to origin (0.0f, 0.0f)
549 scrollView.ScrollTo( 1, 0.0f );
551 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
552 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
557 int UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP(void)
559 ToolkitTestApplication application;
560 tet_infoline(" UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP");
562 ScrollView scrollView = ScrollView::New();
563 Stage::GetCurrent().Add( scrollView );
564 RulerPtr rulerX = new FixedRuler( 100.0f );
565 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
566 RulerPtr rulerY = new FixedRuler( 100.0f );
567 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
569 scrollView.SetRulerX( rulerX );
570 scrollView.SetRulerY( rulerY );
572 scrollView.SetWrapMode(true);
574 scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DirectionBiasLeft );
576 Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame
577 // Check that the scroll position remains the same
578 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
580 Wait(application, RENDER_DELAY_SCROLL); // Wait for one second
581 // Check that it stays at the same page (i.e. the same scroll position)
582 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
583 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
585 scrollView.ScrollTo( 0, 0.25, Dali::Toolkit::DirectionBiasRight );
587 Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame
588 // Check that it scrolls towards the right
589 DALI_TEST_CHECK( scrollView.GetCurrentScrollPosition().x > 0.0f );
591 Wait(application, RENDER_DELAY_SCROLL); // Wait for one second
592 // Check that it scrolls back to the same page (i.e. the same scroll position)
593 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
594 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION );
599 int UtcDaliToolkitScrollViewScrollToActorP(void)
601 ToolkitTestApplication application;
602 tet_infoline(" UtcDaliToolkitScrollViewScrollToActorP");
604 ScrollView scrollView = ScrollView::New();
605 Stage::GetCurrent().Add( scrollView );
607 Actor actorA = Actor::New();
608 const Vector3 positionA = Vector3(100.0f, 400.0f, 0.0f);
609 actorA.SetPosition(positionA);
610 scrollView.Add(actorA);
612 Actor actorB = Actor::New();
613 const Vector3 positionB = Vector3(500.0f, 200.0f, 0.0f);
614 actorB.SetPosition(positionB);
615 scrollView.Add(actorB);
619 scrollView.ScrollTo(actorA, 0.0f);
621 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION );
624 scrollView.ScrollTo(actorB, 0.0f);
626 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION );
628 scrollView.ScrollTo(actorA);
629 Wait(application, RENDER_DELAY_SCROLL);
630 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION );
632 scrollView.ScrollTo(actorB);
633 Wait(application, RENDER_DELAY_SCROLL);
634 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION );
638 int UtcDaliToolkitScrollViewScrollToSnapPointP(void)
640 ToolkitTestApplication application;
641 tet_infoline(" UtcDaliToolkitScrollViewScrollToSnapPointP");
643 ScrollView scrollView = ScrollView::New();
644 Stage::GetCurrent().Add( scrollView );
645 RulerPtr rulerX = new FixedRuler( 100.0f );
646 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
647 RulerPtr rulerY = new FixedRuler( 100.0f );
648 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
650 scrollView.SetRulerX( rulerX );
651 scrollView.SetRulerY( rulerY );
653 scrollView.ScrollTo( Vector2(120.0f, 190.0f), 0.0f );
655 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(120.0f, 190.0f), TEST_LOCATION );
657 scrollView.ScrollToSnapPoint();
659 Wait(application, RENDER_DELAY_SCROLL);
660 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 200.0f), TEST_LOCATION );
664 int UtcDaliToolkitScrollViewSetScrollUpdateDistanceP(void)
666 ToolkitTestApplication application;
667 tet_infoline(" UtcDaliToolkitScrollViewSetScrollUpdateDistanceP");
669 ScrollView scrollView = ScrollView::New();
671 scrollView.SetScrollUpdateDistance(0);
672 DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 0, TEST_LOCATION);
673 scrollView.SetScrollUpdateDistance(10);
674 DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 10, TEST_LOCATION);
675 scrollView.SetScrollUpdateDistance(1000);
676 DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 1000, TEST_LOCATION);
680 int UtcDaliToolkitScrollViewSetWrapModeP(void)
682 ToolkitTestApplication application;
683 tet_infoline(" UtcDaliToolkitScrollViewSetWrapModeP");
685 ScrollView scrollView = ScrollView::New();
686 Stage::GetCurrent().Add( scrollView );
688 // Position rulers. 4x4 grid.
689 RulerPtr rulerX = new FixedRuler(50.0f);
690 RulerPtr rulerY = new FixedRuler(50.0f);
691 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, false) );
692 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, false) );
693 scrollView.SetRulerX(rulerX);
694 scrollView.SetRulerY(rulerY);
696 scrollView.SetWrapMode(false);
697 scrollView.ScrollTo(Vector2(225.0f, 125.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
699 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 17, TEST_LOCATION );
700 scrollView.SetWrapMode(true);
701 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 13, TEST_LOCATION );
705 int UtcDaliToolkitScrollViewActorAutoSnap(void)
707 ToolkitTestApplication application;
708 tet_infoline(" UtcDaliToolkitScrollViewActorAutoSnap");
710 ScrollView scrollView = ScrollView::New();
711 Stage::GetCurrent().Add( scrollView );
714 RulerPtr rulerX = new DefaultRuler();
715 RulerPtr rulerY = new DefaultRuler();
716 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
717 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
718 scrollView.SetRulerX(rulerX);
719 scrollView.SetRulerY(rulerY);
721 const Vector3 aPosition = Vector3(200.0f, 50.0f, 0.0f);
722 Actor a = Actor::New();
724 a.SetPosition(aPosition);
726 const Vector3 bPosition = Vector3(600.0f, 600.0f, 0.0f);
727 Actor b = Actor::New();
729 b.SetPosition(bPosition);
731 // Goto a random position, and execute snap (should not move)
732 Vector2 targetScroll = Vector2(500.0f, 500.0f);
733 scrollView.ScrollTo(targetScroll, 0.0f);
735 scrollView.ScrollToSnapPoint();
736 Wait(application, RENDER_DELAY_SCROLL);
737 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), targetScroll, TEST_LOCATION );
739 // Enable ActorAutoSnap, and now try snapping.
740 scrollView.SetActorAutoSnap(true);
741 scrollView.ScrollToSnapPoint();
742 Wait(application, RENDER_DELAY_SCROLL);
743 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), bPosition.GetVectorXY(), TEST_LOCATION );
745 scrollView.ScrollTo(Vector2(0.0f, 0.0f), 0.0f);
747 scrollView.ScrollToSnapPoint();
748 Wait(application, RENDER_DELAY_SCROLL);
749 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), aPosition.GetVectorXY(), TEST_LOCATION );
753 int UtcDaliToolkitScrollViewSignalsStartComplete(void)
755 ToolkitTestApplication application;
756 tet_infoline(" UtcDaliToolkitScrollViewSignalsStartComplete");
758 gOnScrollStartCalled = false;
759 gOnScrollCompleteCalled = false;
761 ScrollView scrollView = ScrollView::New();
762 Stage::GetCurrent().Add( scrollView );
765 RulerPtr rulerX = new DefaultRuler();
766 RulerPtr rulerY = new DefaultRuler();
767 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
768 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
769 scrollView.SetRulerX(rulerX);
770 scrollView.SetRulerY(rulerY);
771 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
772 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
773 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
774 scrollView.ScrollTo( Vector2(100.0f, 100.0f) );
775 Wait(application, RENDER_DELAY_SCROLL);
777 DALI_TEST_CHECK(gOnScrollStartCalled);
778 DALI_TEST_CHECK(gOnScrollCompleteCalled);
782 int UtcDaliToolkitScrollViewSignalsUpdate(void)
784 ToolkitTestApplication application;
785 tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate");
787 gOnScrollStartCalled = false;
788 gOnScrollUpdateCalled = false;
789 gOnScrollCompleteCalled = false;
791 ScrollView scrollView = ScrollView::New();
792 Stage::GetCurrent().Add( scrollView );
793 Vector2 stageSize = Stage::GetCurrent().GetSize();
794 scrollView.SetSize(stageSize);
795 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
796 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
799 RulerPtr rulerX = new DefaultRuler();
800 RulerPtr rulerY = new DefaultRuler();
801 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
802 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
803 scrollView.SetRulerX(rulerX);
804 scrollView.SetRulerY(rulerY);
805 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
806 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
807 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
809 ImageActor image = CreateSolidColorActor( Color::RED );
810 image.SetSize(stageSize);
811 image.SetParentOrigin(ParentOrigin::TOP_LEFT);
812 image.SetAnchorPoint(AnchorPoint::TOP_LEFT);
813 scrollView.Add(image);
817 // Do a pan starting from 100,100 and moving down diagonally.
818 Vector2 pos(100.0f, 100.0f);
819 SendPan(application, Gesture::Possible, pos);
820 SendPan(application, Gesture::Started, pos);
823 Wait(application, 100);
825 for(int i = 0;i<20;i++)
827 SendPan(application, Gesture::Continuing, pos);
833 SendPan(application, Gesture::Finished, pos);
834 Wait(application, RENDER_DELAY_SCROLL);
836 DALI_TEST_CHECK(gOnScrollStartCalled);
837 DALI_TEST_CHECK(gOnScrollUpdateCalled);
838 DALI_TEST_CHECK(gOnScrollCompleteCalled);
842 static Vector2 PerformGestureDiagonalSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, bool finish = true)
844 gOnScrollStartCalled = false;
845 gOnScrollUpdateCalled = false;
846 gOnScrollCompleteCalled = false;
847 gOnSnapStartCalled = false;
849 // Now do a pan starting from (start) and heading (direction)
851 SendPan(application, Gesture::Possible, pos);
852 SendPan(application, Gesture::Started, pos);
855 for(int i = 0;i<frames;i++)
857 pos += direction; // Move in this direction
858 SendPan(application, Gesture::Continuing, pos);
864 pos += direction; // Move in this direction.
865 SendPan(application, Gesture::Finished, pos);
866 Wait(application, RENDER_DELAY_SCROLL);
872 int UtcDaliToolkitScrollViewScrollSensitive(void)
874 ToolkitTestApplication application;
875 tet_infoline(" UtcDaliToolkitScrollViewScrollSensitive");
877 // Set up a scrollView...
878 ScrollView scrollView = ScrollView::New();
879 Stage::GetCurrent().Add( scrollView );
880 Vector2 stageSize = Stage::GetCurrent().GetSize();
881 scrollView.SetSize(stageSize);
882 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
883 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
886 RulerPtr rulerX = new DefaultRuler();
887 RulerPtr rulerY = new DefaultRuler();
888 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
889 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
890 scrollView.SetRulerX(rulerX);
891 scrollView.SetRulerY(rulerY);
892 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
893 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
894 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
895 scrollView.SnapStartedSignal().Connect( &OnSnapStart );
897 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
900 // First try insensitive swipe.
901 scrollView.SetScrollSensitive(false);
902 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, true);
904 DALI_TEST_CHECK( !gOnScrollStartCalled );
905 DALI_TEST_CHECK( !gOnScrollCompleteCalled );
906 DALI_TEST_CHECK( !gOnSnapStartCalled );
908 // Second try sensitive swipe.
909 scrollView.SetScrollSensitive(true);
910 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, true);
912 DALI_TEST_CHECK( gOnScrollStartCalled );
913 DALI_TEST_CHECK( gOnScrollCompleteCalled );
914 DALI_TEST_CHECK( gOnSnapStartCalled );
918 int UtcDaliToolkitScrollViewAxisAutoLock(void)
920 ToolkitTestApplication application;
921 tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLock");
923 // Set up a scrollView...
924 ScrollView scrollView = ScrollView::New();
925 Stage::GetCurrent().Add( scrollView );
926 Vector2 stageSize = Stage::GetCurrent().GetSize();
927 scrollView.SetSize(stageSize);
928 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
929 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
932 RulerPtr rulerX = new DefaultRuler();
933 RulerPtr rulerY = new DefaultRuler();
934 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
935 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
936 scrollView.SetRulerX(rulerX);
937 scrollView.SetRulerY(rulerY);
938 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
939 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
940 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
943 scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
945 Vector2 startPosition = scrollView.GetCurrentScrollPosition();
946 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(5.0f, 1.0f), 50, true); // mostly horizontal
947 const Vector2 positionAfterNormal = scrollView.GetCurrentScrollPosition();
950 scrollView.SetAxisAutoLock(true);
951 DALI_TEST_CHECK(scrollView.GetAxisAutoLock());
953 scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
955 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(5.0f, 1.0f), 50, true); // mostly horizontal
956 const Vector2 positionAfterAutoLock = scrollView.GetCurrentScrollPosition();
958 // compare how much the Y position has deviated for normal and autolock.
959 const float devianceNormal = fabsf(startPosition.y - positionAfterNormal.y);
960 const float devianceAutoLock = fabsf(startPosition.y - positionAfterAutoLock.y);
962 // in auto-lock it should be a mostly horizontal pan (thus deviance should be much lower)
963 DALI_TEST_CHECK(devianceAutoLock < devianceNormal);
965 scrollView.SetAxisAutoLock(false);
966 DALI_TEST_CHECK(!scrollView.GetAxisAutoLock());
970 int UtcDaliToolkitScrollViewAxisAutoLockGradient(void)
972 ToolkitTestApplication application;
973 tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLockGradient");
975 // Set up a scrollView...
976 ScrollView scrollView = ScrollView::New();
977 scrollView.SetAxisAutoLockGradient(0.5f);
978 DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 0.5f, TEST_LOCATION);
979 scrollView.SetAxisAutoLockGradient(1.0f);
980 DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 1.0f, TEST_LOCATION);
984 int UtcDaliToolkitScrollViewConstraints(void)
986 ToolkitTestApplication application;
987 tet_infoline(" UtcDaliToolkitScrollViewConstraints");
989 // Set up a scrollView...
990 ScrollView scrollView = ScrollView::New();
991 Stage::GetCurrent().Add( scrollView );
992 Vector2 stageSize = Stage::GetCurrent().GetSize();
993 scrollView.SetSize(stageSize);
994 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
995 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
998 RulerPtr rulerX = new DefaultRuler();
999 RulerPtr rulerY = new DefaultRuler();
1000 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1001 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1002 scrollView.SetRulerX(rulerX);
1003 scrollView.SetRulerY(rulerY);
1005 // Add an Actor to ScrollView,
1006 // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1007 gConstraintResult = Vector3::ZERO;
1008 Actor a = Actor::New();
1010 a.SetPosition( TEST_ACTOR_POSITION );
1013 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1014 constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
1015 constraint.SetRemoveAction(Constraint::Discard);
1016 scrollView.ApplyConstraintToChildren(constraint);
1019 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1021 gConstraintResult = Vector3::ZERO;
1022 scrollView.RemoveConstraintsFromChildren();
1025 DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
1029 int UtcDaliToolkitScrollViewBind(void)
1031 ToolkitTestApplication application;
1032 tet_infoline(" UtcDaliToolkitScrollViewBind");
1034 // Set up a scrollView...
1035 ScrollView scrollView = ScrollView::New();
1036 Stage::GetCurrent().Add( scrollView );
1037 Vector2 stageSize = Stage::GetCurrent().GetSize();
1038 scrollView.SetSize(stageSize);
1039 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1040 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1043 RulerPtr rulerX = new DefaultRuler();
1044 RulerPtr rulerY = new DefaultRuler();
1045 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1046 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1047 scrollView.SetRulerX(rulerX);
1048 scrollView.SetRulerY(rulerY);
1050 // Add an Actor to ScrollView,
1051 // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1053 gConstraintResult = Vector3::ZERO;
1054 Actor a = Actor::New();
1056 a.SetPosition( TEST_ACTOR_POSITION );
1059 // apply this constraint to scrollview
1060 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1061 constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
1062 constraint.SetRemoveAction(Constraint::Discard);
1063 scrollView.ApplyConstraintToChildren(constraint);
1067 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1070 gConstraintResult = Vector3::ZERO;
1071 scrollView.UnbindActor( a );
1073 DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
1076 gConstraintResult = Vector3::ZERO;
1077 scrollView.BindActor( a );
1079 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1083 int UtcDaliToolkitScrollViewOvershoot(void)
1085 ToolkitTestApplication application;
1086 tet_infoline(" UtcDaliToolkitScrollViewOvershoot");
1088 // Set up a scrollView...
1089 ScrollView scrollView = ScrollView::New();
1090 Stage::GetCurrent().Add( scrollView );
1091 Vector2 stageSize = Stage::GetCurrent().GetSize();
1092 scrollView.SetSize(stageSize);
1093 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1094 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1097 RulerPtr rulerX = new DefaultRuler();
1098 RulerPtr rulerY = new DefaultRuler();
1099 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1100 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1101 scrollView.SetRulerX(rulerX);
1102 scrollView.SetRulerY(rulerY);
1103 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1104 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1105 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1107 scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1110 // 1. Scroll page in NW (-500,-500 pixels), then inspect overshoot. (don't release touch)
1111 Vector2 currentPos = Vector2(100.0f, 100.0f);
1112 currentPos = PerformGestureDiagonalSwipe(application, currentPos, Vector2(5.0f, 5.0f), 100, false);
1113 float overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1114 float overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1115 Vector2 positionValue = scrollView.GetProperty<Vector2>(ScrollView::Property::SCROLL_POSITION);
1116 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1117 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1118 DALI_TEST_EQUALS(positionValue, Vector2::ZERO, TEST_LOCATION);
1120 float timeToReachOrigin;
1122 // Now release touch. Overshoot should snap back to zero.
1123 SendPan(application, Gesture::Finished, currentPos);
1124 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1126 float minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1127 float maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1129 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1130 (timeToReachOrigin < maxTimeToReachOrigin) );
1132 // 2. Repeat Scroll, but this time change overshoot snap duration to shorter time
1133 scrollView.SetSnapOvershootDuration(TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION);
1135 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1136 // Now release touch. Overshoot should snap back to zero.
1137 SendPan(application, Gesture::Finished, currentPos);
1138 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1140 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1141 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1143 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1144 (timeToReachOrigin < maxTimeToReachOrigin) );
1146 // 3. Repeat Scroll, but this time change overshoot snap duration to longer time.
1147 scrollView.SetSnapOvershootDuration(TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION);
1149 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1150 // Now release touch. Overshoot should snap back to zero.
1151 SendPan(application, Gesture::Finished, currentPos);
1152 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1154 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1155 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1157 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1158 (timeToReachOrigin < maxTimeToReachOrigin) );
1160 // 4. Repeat Scroll, but this time change overshoot function.
1161 scrollView.SetSnapOvershootDuration(TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION);
1162 scrollView.SetSnapOvershootAlphaFunction(TestAlphaFunction);
1164 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1165 // Now release touch. Overshoot should snap back to zero.
1166 SendPan(application, Gesture::Finished, currentPos);
1167 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1169 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1170 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1172 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1173 (timeToReachOrigin < maxTimeToReachOrigin) );
1177 int UtcDaliToolkitScrollViewSnapAlphaFunction(void)
1179 ToolkitTestApplication application;
1180 tet_infoline(" UtcDaliToolkitScrollViewSnapAlphaFunction");
1182 // Set up a scrollView...
1183 ScrollView scrollView = ScrollView::New();
1184 scrollView.SetScrollSnapAlphaFunction( AlphaFunction::EASE_IN );
1185 DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_IN );
1186 scrollView.SetScrollSnapAlphaFunction( AlphaFunction::EASE_OUT );
1187 DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_OUT );
1189 scrollView.SetScrollFlickAlphaFunction( AlphaFunction::BOUNCE );
1190 DALI_TEST_CHECK( scrollView.GetScrollFlickAlphaFunction().GetBuiltinFunction() == AlphaFunction::BOUNCE );
1195 int UtcDaliToolkitScrollViewSnapDuration(void)
1197 ToolkitTestApplication application;
1198 tet_infoline(" UtcDaliToolkitScrollViewSnapDuration");
1200 // Set up a scrollView...
1201 ScrollView scrollView = ScrollView::New();
1202 scrollView.SetScrollSnapDuration( 1.0f );
1203 DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 1.0f, TEST_LOCATION );
1204 scrollView.SetScrollSnapDuration( 0.5f );
1205 DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 0.5f, TEST_LOCATION );
1207 scrollView.SetScrollFlickDuration( 2.0f );
1208 DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 2.0f, TEST_LOCATION );
1209 scrollView.SetScrollFlickDuration( 1.5f );
1210 DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 1.5f, TEST_LOCATION );
1214 int UtcDaliToolkitScrollViewSnapStartedSignalP(void)
1216 ToolkitTestApplication application;
1217 tet_infoline(" UtcDaliToolkitScrollViewSnapStartedSignalP");
1219 // Set up a scrollView...
1220 ScrollView scrollView = ScrollView::New();
1221 Stage::GetCurrent().Add( scrollView );
1222 Vector2 stageSize = Stage::GetCurrent().GetSize();
1223 scrollView.SetSize(stageSize);
1224 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1225 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1228 RulerPtr rulerX = new DefaultRuler();
1229 RulerPtr rulerY = new DefaultRuler();
1230 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1231 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1232 scrollView.SetRulerX(rulerX);
1233 scrollView.SetRulerY(rulerY);
1234 scrollView.SnapStartedSignal().Connect( &OnSnapStart );
1236 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1239 // First try a snap.
1240 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(0.5f, 0.0f), 60, true);
1242 DALI_TEST_CHECK( gOnSnapStartCalled );
1243 DALI_TEST_CHECK( gLastSnapType == Toolkit::Snap );
1245 // Second try a swipe.
1246 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(20.0f, 0.0f), 60, true);
1248 DALI_TEST_CHECK( gOnSnapStartCalled );
1249 DALI_TEST_CHECK( gLastSnapType == Toolkit::Flick );
1253 int UtcDaliToolkitScrollViewGetCurrentPageP(void)
1255 ToolkitTestApplication application;
1256 tet_infoline(" UtcDaliToolkitScrollViewGetCurrentPageP");
1258 ScrollView scrollView = ScrollView::New();
1259 Stage::GetCurrent().Add( scrollView );
1260 RulerPtr rulerX = new FixedRuler( 100.0f );
1261 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1262 RulerPtr rulerY = new FixedRuler( 100.0f );
1263 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1265 scrollView.SetRulerX( rulerX );
1266 scrollView.SetRulerY( rulerY );
1268 scrollView.ScrollTo( 15 );
1269 Wait(application, RENDER_DELAY_SCROLL);
1270 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION );
1272 scrollView.ScrollTo( 3 );
1273 Wait(application, RENDER_DELAY_SCROLL);
1274 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION );
1276 scrollView.ScrollTo( 9 );
1277 Wait(application, RENDER_DELAY_SCROLL);
1278 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION );
1283 int UtcDaliToolkitScrollViewSetMaxOvershootP(void)
1285 ToolkitTestApplication application;
1286 tet_infoline(" UtcDaliToolkitScrollViewSetMaxOvershootP");
1288 // Set up a scrollView...
1289 ScrollView scrollView = ScrollView::New();
1290 Stage::GetCurrent().Add( scrollView );
1291 Vector2 stageSize = Stage::GetCurrent().GetSize();
1292 scrollView.SetSize(stageSize);
1293 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1294 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1297 RulerPtr rulerX = new DefaultRuler();
1298 RulerPtr rulerY = new DefaultRuler();
1299 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1300 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1301 scrollView.SetRulerX(rulerX);
1302 scrollView.SetRulerY(rulerY);
1304 // Set the max overshoot to be 50 pixels in both X axis and Y axis
1305 scrollView.SetMaxOvershoot(50.0f, 50.0f);
1307 scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1310 // Scroll page in NW (-20,-20 pixels), then check that overshoot should be 0. (don't release touch)
1311 Vector2 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 20, false);
1312 float overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1313 float overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1314 DALI_TEST_EQUALS(overshootXValue, 0.0f, TEST_LOCATION);
1315 DALI_TEST_EQUALS(overshootYValue, 0.0f, TEST_LOCATION);
1317 // Scroll page further in NW (-105,-105 pixels), then check that overshoot should be around 0.5. (don't release touch)
1318 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 105, false);
1319 overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1320 overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1321 DALI_TEST_CHECK(overshootXValue > 0.49f && overshootXValue < 0.51f);
1322 DALI_TEST_CHECK(overshootYValue > 0.49f && overshootYValue < 0.51f);
1324 // Scroll page further in NW (-30,-30 pixels), then check that overshoot should be now 1.0. (don't release touch)
1325 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 30, false);
1326 overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1327 overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1328 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1329 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1331 // Change the max overshoot to be 100 pixels in both X axis and Y axis
1332 scrollView.SetMaxOvershoot(100.0f, 100.0f);
1335 // Check that overshoot should be now around 0.8.
1336 overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1337 overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1338 DALI_TEST_CHECK(overshootXValue > 0.79f && overshootXValue < 0.81f);
1339 DALI_TEST_CHECK(overshootYValue > 0.79f && overshootYValue < 0.81f);
1341 // Scroll page further in NW (-30,-30 pixels), then check that overshoot should be now 1.0. (don't release touch)
1342 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 30, false);
1343 overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1344 overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1345 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1346 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1351 int UtcDaliToolkitScrollViewSetScrollingDirectionP(void)
1353 ToolkitTestApplication application;
1354 tet_infoline(" UtcDaliToolkitScrollViewSetScrollingDirectionP");
1356 // Set up a scrollView...
1357 ScrollView scrollView = ScrollView::New();
1358 Stage::GetCurrent().Add( scrollView );
1359 Vector2 stageSize = Stage::GetCurrent().GetSize();
1360 scrollView.SetSize(stageSize);
1361 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1362 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1364 Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1366 scrollView.ScrollTo(START_POSITION, 0.0f);
1368 // Try a vertical swipe.
1369 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1370 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(10.0f, -50.0f), TEST_LOCATION );
1372 scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1374 scrollView.ScrollTo(START_POSITION, 0.0f);
1376 // Try a vertical swipe.
1377 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1378 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION );
1380 scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1382 scrollView.ScrollTo(Vector2(10.0f, 10.0f), 0.0f);
1384 // Try a vertical swipe.
1385 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1386 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(10.0f, -50.0f), TEST_LOCATION );
1391 int UtcDaliToolkitScrollViewRemoveScrollingDirectionP(void)
1393 ToolkitTestApplication application;
1394 tet_infoline(" UtcDaliToolkitScrollViewRemoveScrollingDirectionP");
1396 // Set up a scrollView...
1397 ScrollView scrollView = ScrollView::New();
1398 Stage::GetCurrent().Add( scrollView );
1399 Vector2 stageSize = Stage::GetCurrent().GetSize();
1400 scrollView.SetSize(stageSize);
1401 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1402 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1404 Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1406 scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1408 scrollView.ScrollTo(START_POSITION, 0.0f);
1410 // Try a vertical swipe.
1411 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1412 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION );
1414 scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1416 scrollView.ScrollTo(Vector2(10.0f, 10.0f), 0.0f);
1418 // Try a vertical swipe.
1419 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1420 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(10.0f, -50.0f), TEST_LOCATION );
1425 int UtcDaliToolkitScrollViewSetRulerXP(void)
1427 ToolkitTestApplication application;
1428 tet_infoline(" UtcDaliToolkitScrollViewSetRulerXP");
1430 ScrollView scrollView = ScrollView::New();
1431 Stage::GetCurrent().Add( scrollView );
1432 RulerPtr rulerX = new FixedRuler( 100.0f );
1433 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1435 scrollView.SetRulerX( rulerX );
1437 scrollView.ScrollTo( 1, 0.0f );
1439 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION );
1441 RulerPtr newRulerX = new FixedRuler( 200.0f );
1442 newRulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1444 scrollView.SetRulerX( newRulerX );
1446 scrollView.ScrollTo( 1, 0.0f );
1448 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 0.0f), TEST_LOCATION );
1453 int UtcDaliToolkitScrollViewSetRulerYP(void)
1455 ToolkitTestApplication application;
1456 tet_infoline(" UtcDaliToolkitScrollViewSetRulerYP");
1458 ScrollView scrollView = ScrollView::New();
1459 Stage::GetCurrent().Add( scrollView );
1461 RulerPtr rulerY = new FixedRuler( 200.0f );
1462 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1464 scrollView.SetRulerY( rulerY );
1466 scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f );
1468 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 350.0f), TEST_LOCATION );
1470 RulerPtr newRulerY = new FixedRuler( 100.0f );
1471 newRulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
1472 scrollView.SetRulerY( newRulerY );
1474 scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f );
1476 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 200.0f), TEST_LOCATION );
1481 int UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP(void)
1483 ToolkitTestApplication application;
1484 tet_infoline(" UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP");
1486 ScrollView scrollView = ScrollView::New();
1487 scrollView.SetMinimumSpeedForFlick(25.0f);
1488 DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 25.0f, TEST_LOCATION );
1489 scrollView.SetMinimumSpeedForFlick(60.0f);
1490 DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 60.0f, TEST_LOCATION );
1494 int UtcDaliToolkitScrollViewSetMinimumDistanceForFlickP(void)
1496 ToolkitTestApplication application;
1497 tet_infoline(" UtcDaliToolkitScrollViewSetMinimumDistanceForFlick");
1499 ScrollView scrollView = ScrollView::New();
1501 scrollView.SetMinimumDistanceForFlick(Vector2(30.0f, 15.0f));
1502 DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(30.0f, 15.0f), TEST_LOCATION );
1503 scrollView.SetMinimumDistanceForFlick(Vector2(60.0f, 30.0f));
1504 DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(60.0f, 30.0f), TEST_LOCATION);
1508 int UtcDaliToolkitScrollViewSetMouseWheelScrollDistanceStepP(void)
1510 ToolkitTestApplication application;
1511 tet_infoline(" UtcDaliToolkitScrollViewSetMouseWheelScrollDistanceStepP");
1513 ScrollView scrollView = ScrollView::New();
1514 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
1515 scrollView.SetMouseWheelScrollDistanceStep(Vector2(30.0f, 15.0f));
1516 DALI_TEST_EQUALS( scrollView.GetMouseWheelScrollDistanceStep(), Vector2(30.0f, 15.0f), TEST_LOCATION );
1517 scrollView.SetMouseWheelScrollDistanceStep(Vector2(60.0f, 30.0f));
1518 DALI_TEST_EQUALS( scrollView.GetMouseWheelScrollDistanceStep(), Vector2(60.0f, 30.0f), TEST_LOCATION);
1522 int UtcDaliToolkitScrollViewApplyEffectP(void)
1524 ToolkitTestApplication application;
1525 tet_infoline(" UtcDaliToolkitScrollViewApplyEffectP");
1527 // Create a ScrollView
1528 ScrollView scrollView = ScrollView::New();
1530 // Create two scroll view effects
1531 Dali::Path path = Dali::Path::New();
1532 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);
1533 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);
1535 // Apply both effects
1536 scrollView.ApplyEffect(effect);
1537 scrollView.ApplyEffect(newEffect);
1539 DALI_TEST_CHECK( true );
1544 int UtcDaliToolkitScrollViewApplyEffectN(void)
1546 ToolkitTestApplication application;
1547 tet_infoline(" UtcDaliToolkitScrollViewApplyEffectN");
1549 // Create a ScrollView
1550 ScrollView scrollView = ScrollView::New();
1552 // Create two scroll view effects
1553 Dali::Path path = Dali::Path::New();
1554 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);
1555 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);
1557 // Apply both effects
1558 scrollView.ApplyEffect(effect);
1559 scrollView.ApplyEffect(newEffect);
1561 // Attempt to apply the same effect again
1564 scrollView.ApplyEffect(newEffect);
1565 tet_result( TET_FAIL );
1567 catch ( DaliException& e )
1569 DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
1575 int UtcDaliToolkitScrollViewRemoveEffectP(void)
1577 ToolkitTestApplication application;
1578 tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectP");
1580 // Create a ScrollView
1581 ScrollView scrollView = ScrollView::New();
1583 // Create two scroll view effects
1584 Dali::Path path = Dali::Path::New();
1585 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);
1586 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);
1588 // Apply both effects
1589 scrollView.ApplyEffect(effect);
1590 scrollView.ApplyEffect(newEffect);
1592 // Remove both effects
1593 scrollView.RemoveEffect(effect);
1594 scrollView.RemoveEffect(newEffect);
1596 DALI_TEST_CHECK( true );
1601 int UtcDaliToolkitScrollViewRemoveEffectN(void)
1603 ToolkitTestApplication application;
1604 tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectN");
1606 // Create a ScrollView
1607 ScrollView scrollView = ScrollView::New();
1609 // Create two scroll view effects
1610 Dali::Path path = Dali::Path::New();
1611 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);
1612 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);
1614 // Apply the first effect
1615 scrollView.ApplyEffect(effect);
1617 // Attempt to remove the second effect which has not been applied to scroll view
1620 scrollView.RemoveEffect(newEffect);
1621 tet_result( TET_FAIL );
1623 catch ( DaliException& e )
1625 DALI_TEST_ASSERT( e, "effectExistedInScrollView", TEST_LOCATION );
1631 int UtcDaliToolkitScrollViewRemoveAllEffectsP(void)
1633 ToolkitTestApplication application;
1634 tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsP");
1636 // Create a ScrollView
1637 ScrollView scrollView = ScrollView::New();
1639 // Create two scroll view effects
1640 Dali::Path path = Dali::Path::New();
1641 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);
1642 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);
1644 // Apply both effects
1645 scrollView.ApplyEffect(effect);
1646 scrollView.ApplyEffect(newEffect);
1648 // Attempt to apply the same first effect again
1651 scrollView.ApplyEffect(effect);
1652 tet_result( TET_FAIL );
1654 catch ( DaliException& e )
1656 DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
1659 // Remove both effects
1660 scrollView.RemoveAllEffects();
1662 // Apply both effects again
1663 scrollView.ApplyEffect(effect);
1664 scrollView.ApplyEffect(newEffect);
1666 DALI_TEST_CHECK( true );
1671 int UtcDaliToolkitScrollViewRemoveAllEffectsN(void)
1673 ToolkitTestApplication application;
1674 tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsN");
1676 // Create a ScrollView
1677 ScrollView scrollView = ScrollView::New();
1679 // Remove effects when there is no effect applied previously
1680 scrollView.RemoveAllEffects();
1682 DALI_TEST_CHECK( true );
1687 int UtcDaliToolkitScrollViewSetOvershootEnabledP(void)
1689 ToolkitTestApplication application;
1690 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEnabledP");
1692 ScrollView scrollView = ScrollView::New();
1694 scrollView.SetOvershootEnabled(true);
1695 DALI_TEST_CHECK(scrollView.IsOvershootEnabled());
1697 scrollView.SetOvershootEnabled(false);
1698 DALI_TEST_CHECK(!scrollView.IsOvershootEnabled());
1703 int UtcDaliToolkitScrollViewSetOvershootEffectColorP(void)
1705 ToolkitTestApplication application;
1706 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEffectColorP");
1708 ScrollView scrollView = ScrollView::New();
1710 scrollView.SetOvershootEffectColor(Dali::Color::RED);
1711 DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::RED, TEST_LOCATION);
1713 scrollView.SetOvershootEffectColor(Dali::Color::YELLOW);
1714 DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::YELLOW, TEST_LOCATION);
1719 int UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP(void)
1721 ToolkitTestApplication application;
1722 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP");
1724 ScrollView scrollView = ScrollView::New();
1726 scrollView.SetOvershootAnimationSpeed(55.0f);
1727 DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 55.0f, TEST_LOCATION);
1729 scrollView.SetOvershootAnimationSpeed(120.0f);
1730 DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 120.0f, TEST_LOCATION);
1735 int UtcDaliToolkitScrollViewGetSet(void)
1737 ToolkitTestApplication application;
1738 tet_infoline(" UtcDaliToolkitScrollViewGetSet");
1739 ScrollView scrollView = ScrollView::New();
1740 scrollView.SetMaxFlickSpeed(0.5f);
1741 DALI_TEST_EQUALS(scrollView.GetMaxFlickSpeed(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1742 scrollView.SetFrictionCoefficient(0.6f);
1743 DALI_TEST_EQUALS(scrollView.GetFrictionCoefficient(), 0.6f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1744 scrollView.SetFlickSpeedCoefficient(0.7f);
1745 DALI_TEST_EQUALS(scrollView.GetFlickSpeedCoefficient(), 0.7f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1749 int UtcDaliToolkitScrollViewRulerDomainConstructorP(void)
1751 ToolkitTestApplication application;
1753 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
1754 DALI_TEST_EQUALS( domainX.min, 0.0f, TEST_LOCATION);
1755 DALI_TEST_EQUALS( domainX.max, 200.0f, TEST_LOCATION);
1756 DALI_TEST_EQUALS( domainX.enabled, true, TEST_LOCATION);
1758 RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
1759 DALI_TEST_EQUALS( domainY.min, 100.0f, TEST_LOCATION);
1760 DALI_TEST_EQUALS( domainY.max, 500.0f, TEST_LOCATION);
1761 DALI_TEST_EQUALS( domainY.enabled, false, TEST_LOCATION);
1766 int UtcDaliToolkitScrollViewRulerDomainGetSizeP(void)
1768 ToolkitTestApplication application;
1770 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
1771 DALI_TEST_EQUALS( domainX.GetSize(), 200.0f, TEST_LOCATION);
1773 RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
1774 DALI_TEST_EQUALS( domainY.GetSize(), 400.0f, TEST_LOCATION);
1779 int UtcDaliToolkitScrollViewRulerDomainClampP(void)
1781 ToolkitTestApplication application;
1783 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
1785 float value = domainX.Clamp(50.0f, 100.0f, 1.0f);
1786 DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
1788 value = domainX.Clamp(300.0f, 20.0f, 1.0f);
1789 DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
1791 value = domainX.Clamp(300.0f, 20.0f, 0.5f);
1792 DALI_TEST_EQUALS( value, 80.0f, TEST_LOCATION);
1794 value = domainX.Clamp(250.0f, 200.0f, 2.0f);
1795 DALI_TEST_EQUALS( value, 200.0f, TEST_LOCATION);
1800 int UtcDaliToolkitScrollViewRulerDomainClampWithStateP(void)
1802 ToolkitTestApplication application;
1804 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
1807 float value = domainX.Clamp(50.0f, 100.0f, 1.0f, clamped);
1808 DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
1809 DALI_TEST_EQUALS( clamped, Dali::Toolkit::NotClamped, TEST_LOCATION);
1811 value = domainX.Clamp(-100.0f, 200.0f, 1.0f, clamped);
1812 DALI_TEST_EQUALS( value, 0.0f, TEST_LOCATION);
1813 DALI_TEST_EQUALS( clamped, Dali::Toolkit::ClampedToMin, TEST_LOCATION);
1815 value = domainX.Clamp(300.0f, 20.0f, 1.0f, clamped);
1816 DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
1817 DALI_TEST_EQUALS( clamped, Dali::Toolkit::ClampedToMax, TEST_LOCATION);
1822 int UtcDaliToolkitScrollViewDefaultRulerConstructorP(void)
1824 ToolkitTestApplication application;
1825 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerConstructorP");
1827 RulerPtr defaultRuler = new DefaultRuler();
1828 DALI_TEST_CHECK( defaultRuler );
1833 int UtcDaliToolkitScrollViewDefaultRulerDestructorP(void)
1835 ToolkitTestApplication application;
1836 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerDestructorP");
1838 RulerPtr defaultRuler = new DefaultRuler();
1840 DALI_TEST_CHECK( true );
1844 int UtcDaliToolkitScrollViewFixedRulerConstructorP(void)
1846 ToolkitTestApplication application;
1847 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerConstructorP");
1849 RulerPtr fixedRuler = new FixedRuler( 100.0f );
1850 DALI_TEST_CHECK( fixedRuler );
1852 fixedRuler = new FixedRuler( 0.0f );
1853 DALI_TEST_CHECK( fixedRuler );
1858 int UtcDaliToolkitScrollViewFixedRulerDestructorP(void)
1860 ToolkitTestApplication application;
1861 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerDestructorP");
1863 RulerPtr fixedRuler = new FixedRuler( 100.0f );
1865 DALI_TEST_CHECK( true );
1869 int UtcDaliToolkitScrollViewRulerGetTypeP(void)
1871 ToolkitTestApplication application;
1872 tet_infoline(" UtcDaliToolkitScrollViewRulerGetTypeP");
1874 RulerPtr defaultRuler = new DefaultRuler();
1875 DALI_TEST_CHECK( defaultRuler );
1876 DALI_TEST_EQUALS( defaultRuler->GetType(), Dali::Toolkit::Ruler::Free, TEST_LOCATION);
1878 RulerPtr fixedRuler = new FixedRuler( 100.0f );
1879 DALI_TEST_CHECK( fixedRuler );
1880 DALI_TEST_EQUALS( fixedRuler->GetType(), Dali::Toolkit::Ruler::Fixed, TEST_LOCATION);
1885 int UtcDaliToolkitScrollViewRulerGetExtensionP(void)
1887 ToolkitTestApplication application;
1888 tet_infoline(" UtcDaliToolkitScrollViewRulerGetExtensionP");
1890 RulerPtr defaultRuler = new DefaultRuler();
1891 DALI_TEST_CHECK( defaultRuler );
1892 DALI_TEST_CHECK( !defaultRuler->GetExtension() );
1894 RulerPtr fixedRuler = new FixedRuler( 100.0f );
1895 DALI_TEST_CHECK( fixedRuler );
1896 DALI_TEST_CHECK( !fixedRuler->GetExtension() );
1901 int UtcDaliToolkitScrollViewRulerEnableDisable(void)
1903 ToolkitTestApplication application;
1904 tet_infoline(" UtcDaliToolkitScrollViewRulerEnableDisable");
1906 RulerPtr ruler = new DefaultRuler();
1908 DALI_TEST_CHECK( ruler->IsEnabled() );
1910 DALI_TEST_CHECK( !ruler->IsEnabled() );
1912 DALI_TEST_CHECK( ruler->IsEnabled() );
1916 int UtcDaliToolkitScrollViewRulerDomainEnableDisable(void)
1918 ToolkitTestApplication application;
1919 tet_infoline(" UtcDaliToolkitScrollViewRulerDomainEnableDisable");
1921 RulerPtr ruler = new DefaultRuler();
1922 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
1924 ruler->SetDomain( RulerDomain(0.0f, 100.0f, true) );
1925 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 100.0f, TEST_LOCATION );
1926 DALI_TEST_EQUALS( ruler->Clamp(-200.0f), 0.0f, TEST_LOCATION );
1927 DALI_TEST_EQUALS( ruler->Clamp(200.0f), 100.0f, TEST_LOCATION );
1929 ruler->DisableDomain();
1930 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
1931 DALI_TEST_EQUALS( ruler->Clamp(-200.0f), -200.0f, TEST_LOCATION );
1932 DALI_TEST_EQUALS( ruler->Clamp(200.0f), 200.0f, TEST_LOCATION );
1936 int UtcDaliToolkitScrollViewRulerSnapAndClamp(void)
1938 ToolkitTestApplication application;
1939 tet_infoline(" UtcDaliToolkitScrollViewRulerSnapAndClamp");
1941 RulerPtr ruler = new FixedRuler( 50.0f );
1942 ruler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1944 // default testing. (snap and clamp)
1945 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f), 50.0f, TEST_LOCATION);
1946 DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f), 50.0f, TEST_LOCATION);
1947 DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f), 0.0f, TEST_LOCATION);
1948 DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f), 0.0f, TEST_LOCATION);
1949 DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f), 400.0f, TEST_LOCATION);
1950 DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f), 400.0f, TEST_LOCATION);
1953 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
1954 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.5f), 50.0f, TEST_LOCATION); // No Flick
1955 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
1957 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
1958 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.5f), 0.0f, TEST_LOCATION); // No Flick
1959 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
1962 DALI_TEST_EQUALS( ruler->SnapAndClamp(-10.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (over left boundary)
1963 DALI_TEST_EQUALS( ruler->SnapAndClamp(-5.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (slightly ovr left boundary)
1964 DALI_TEST_EQUALS( ruler->SnapAndClamp(300.0f, 0.5f, 10.0f), 300.0f, TEST_LOCATION); // 10 units long (not over a boundary)
1965 DALI_TEST_EQUALS( ruler->SnapAndClamp(395.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (slightly over right boundary)
1966 DALI_TEST_EQUALS( ruler->SnapAndClamp(500.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (over right boundary)
1969 DALI_TEST_EQUALS( ruler->SnapAndClamp(-100.0f, 0.5f, 0.0f, 2.0f), 0.0f, TEST_LOCATION);
1970 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 2.0f), 50.0f, TEST_LOCATION);
1971 DALI_TEST_EQUALS( ruler->SnapAndClamp(700.0f, 0.5f, 0.0f, 2.0f), 700.0f, TEST_LOCATION);
1972 DALI_TEST_EQUALS( ruler->SnapAndClamp(850.0f, 0.5f, 0.0f, 2.0f), 800.0f, TEST_LOCATION);
1974 // clamp state testing.
1976 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
1977 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
1978 DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
1979 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
1980 DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
1981 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
1982 DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
1983 DALI_TEST_EQUALS( clamped, ClampedToMin, TEST_LOCATION );
1984 DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
1985 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
1986 DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
1987 DALI_TEST_EQUALS( clamped, ClampedToMax, TEST_LOCATION );
1991 int UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP(void)
1993 ToolkitTestApplication application;
1994 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP");
1996 RulerPtr rulerNormal = new FixedRuler( 25.0f );
1997 rulerNormal->SetDomain( RulerDomain(10.0f, 90.0f, true) );
1999 unsigned int volume;
2002 position = rulerNormal->GetPositionFromPage(1, volume, true);
2003 DALI_TEST_EQUALS( position, 35.0f, TEST_LOCATION );
2004 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
2006 position = rulerNormal->GetPositionFromPage(2, volume, true);
2007 DALI_TEST_EQUALS( position, 60.0f, TEST_LOCATION );
2008 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
2012 int UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP(void)
2014 ToolkitTestApplication application;
2015 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP");
2017 RulerPtr defaultRuler = new DefaultRuler();
2018 DALI_TEST_CHECK( defaultRuler );
2019 DALI_TEST_EQUALS( defaultRuler->GetTotalPages(), 1u, TEST_LOCATION);
2024 int UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP(void)
2026 ToolkitTestApplication application;
2027 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP");
2029 RulerPtr defaultRuler = new DefaultRuler();
2030 DALI_TEST_CHECK( defaultRuler );
2031 DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(100.0f, true), 0u, TEST_LOCATION);
2032 DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(-300.0f, false), 0u, TEST_LOCATION);
2037 int UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP(void)
2039 ToolkitTestApplication application;
2040 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP");
2042 RulerPtr defaultRuler = new DefaultRuler();
2043 DALI_TEST_CHECK( defaultRuler );
2045 unsigned int volume;
2046 DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(0, volume, true), 0.0f, TEST_LOCATION);
2047 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
2049 DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(3, volume, false), 0.0f, TEST_LOCATION);
2050 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
2055 int UtcDaliToolkitScrollViewDefaultRulerSnapP(void)
2057 ToolkitTestApplication application;
2058 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerSnapP");
2060 RulerPtr defaultRuler = new DefaultRuler();
2061 DALI_TEST_CHECK( defaultRuler );
2063 DALI_TEST_EQUALS( defaultRuler->Snap(50.0f, 0.5f), 50.0f, TEST_LOCATION);
2064 DALI_TEST_EQUALS( defaultRuler->Snap(-120.0f, 1.0f), -120.0f, TEST_LOCATION);
2069 int UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP(void)
2071 ToolkitTestApplication application;
2072 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP");
2074 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2075 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2077 fixedRuler->Enable();
2078 DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 4u, TEST_LOCATION);
2080 fixedRuler->Disable();
2081 DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 1u, TEST_LOCATION);
2086 int UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP(void)
2088 ToolkitTestApplication application;
2089 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP");
2091 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2092 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2094 fixedRuler->Enable();
2095 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 3u, TEST_LOCATION);
2096 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2097 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 1u, TEST_LOCATION);
2098 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2100 fixedRuler->Disable();
2101 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2102 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
2103 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2104 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2109 int UtcDaliToolkitScrollViewFixedRulerSnapP(void)
2111 ToolkitTestApplication application;
2112 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerSnapP");
2114 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2115 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2117 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.0f), -100.0f, TEST_LOCATION);
2118 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.0f), -100.0f, TEST_LOCATION);
2119 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.0f), -200.0f, TEST_LOCATION);
2120 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.0f), -500.0f, TEST_LOCATION);
2121 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.0f), 0.0f, TEST_LOCATION);
2122 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.0f), 0.0f, TEST_LOCATION);
2123 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.0f), 0.0f, TEST_LOCATION);
2124 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.0f), 100.0f, TEST_LOCATION);
2125 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.0f), 100.0f, TEST_LOCATION);
2126 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.0f), 200.0f, TEST_LOCATION);
2127 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.0f), 600.0f, TEST_LOCATION);
2129 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.5f), 0.0f, TEST_LOCATION);
2130 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.5f), -100.0f, TEST_LOCATION);
2131 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.5f), -100.0f, TEST_LOCATION);
2132 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.5f), -500.0f, TEST_LOCATION);
2133 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.5f), 0.0f, TEST_LOCATION);
2134 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.5f), 100.0f, TEST_LOCATION);
2135 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.5f), 100.0f, TEST_LOCATION);
2136 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.5f), 100.0f, TEST_LOCATION);
2137 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.5f), 100.0f, TEST_LOCATION);
2138 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.5f), 300.0f, TEST_LOCATION);
2139 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.5f), 600.0f, TEST_LOCATION);
2141 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 1.0f), 0.0f, TEST_LOCATION);
2142 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 1.0f), 0.0f, TEST_LOCATION);
2143 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 1.0f), -100.0f, TEST_LOCATION);
2144 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 1.0f), -400.0f, TEST_LOCATION);
2145 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 1.0f), 100.0f, TEST_LOCATION);
2146 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 1.0f), 100.0f, TEST_LOCATION);
2147 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 1.0f), 100.0f, TEST_LOCATION);
2148 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 1.0f), 200.0f, TEST_LOCATION);
2149 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 1.0f), 200.0f, TEST_LOCATION);
2150 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 1.0f), 300.0f, TEST_LOCATION);
2151 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 1.0f), 700.0f, TEST_LOCATION);