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 Actor actor = Actor::New();
689 scrollView.Add( actor );
691 // Position rulers. 4x4 grid.
692 RulerPtr rulerX = new FixedRuler(50.0f);
693 RulerPtr rulerY = new FixedRuler(50.0f);
694 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, false) );
695 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, false) );
696 scrollView.SetRulerX(rulerX);
697 scrollView.SetRulerY(rulerY);
699 scrollView.SetWrapMode(false);
700 scrollView.ScrollTo(Vector2(225.0f, 125.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
702 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 17, TEST_LOCATION );
704 scrollView.SetWrapMode(true);
705 scrollView.ScrollTo(Vector2(230.0f, 130.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
707 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 13, TEST_LOCATION );
711 int UtcDaliToolkitScrollViewActorAutoSnap(void)
713 ToolkitTestApplication application;
714 tet_infoline(" UtcDaliToolkitScrollViewActorAutoSnap");
716 ScrollView scrollView = ScrollView::New();
717 Stage::GetCurrent().Add( scrollView );
720 RulerPtr rulerX = new DefaultRuler();
721 RulerPtr rulerY = new DefaultRuler();
722 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
723 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
724 scrollView.SetRulerX(rulerX);
725 scrollView.SetRulerY(rulerY);
727 const Vector3 aPosition = Vector3(200.0f, 50.0f, 0.0f);
728 Actor a = Actor::New();
730 a.SetPosition(aPosition);
732 const Vector3 bPosition = Vector3(600.0f, 600.0f, 0.0f);
733 Actor b = Actor::New();
735 b.SetPosition(bPosition);
737 // Goto a random position, and execute snap (should not move)
738 Vector2 targetScroll = Vector2(500.0f, 500.0f);
739 scrollView.ScrollTo(targetScroll, 0.0f);
741 scrollView.ScrollToSnapPoint();
742 Wait(application, RENDER_DELAY_SCROLL);
743 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), targetScroll, TEST_LOCATION );
745 // Enable ActorAutoSnap, and now try snapping.
746 scrollView.SetActorAutoSnap(true);
747 scrollView.ScrollToSnapPoint();
748 Wait(application, RENDER_DELAY_SCROLL);
749 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), bPosition.GetVectorXY(), TEST_LOCATION );
751 scrollView.ScrollTo(Vector2(0.0f, 0.0f), 0.0f);
753 scrollView.ScrollToSnapPoint();
754 Wait(application, RENDER_DELAY_SCROLL);
755 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), aPosition.GetVectorXY(), TEST_LOCATION );
759 int UtcDaliToolkitScrollViewSignalsStartComplete(void)
761 ToolkitTestApplication application;
762 tet_infoline(" UtcDaliToolkitScrollViewSignalsStartComplete");
764 gOnScrollStartCalled = false;
765 gOnScrollCompleteCalled = false;
767 ScrollView scrollView = ScrollView::New();
768 Stage::GetCurrent().Add( scrollView );
771 RulerPtr rulerX = new DefaultRuler();
772 RulerPtr rulerY = new DefaultRuler();
773 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
774 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
775 scrollView.SetRulerX(rulerX);
776 scrollView.SetRulerY(rulerY);
777 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
778 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
779 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
780 scrollView.ScrollTo( Vector2(100.0f, 100.0f) );
781 Wait(application, RENDER_DELAY_SCROLL);
783 DALI_TEST_CHECK(gOnScrollStartCalled);
784 DALI_TEST_CHECK(gOnScrollCompleteCalled);
788 int UtcDaliToolkitScrollViewSignalsUpdate(void)
790 ToolkitTestApplication application;
791 tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate");
793 gOnScrollStartCalled = false;
794 gOnScrollUpdateCalled = false;
795 gOnScrollCompleteCalled = false;
797 ScrollView scrollView = ScrollView::New();
798 Stage::GetCurrent().Add( scrollView );
799 Vector2 stageSize = Stage::GetCurrent().GetSize();
800 scrollView.SetSize(stageSize);
801 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
802 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
805 RulerPtr rulerX = new DefaultRuler();
806 RulerPtr rulerY = new DefaultRuler();
807 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
808 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
809 scrollView.SetRulerX(rulerX);
810 scrollView.SetRulerY(rulerY);
811 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
812 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
813 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
815 ImageActor image = CreateSolidColorActor( Color::RED );
816 image.SetSize(stageSize);
817 image.SetParentOrigin(ParentOrigin::TOP_LEFT);
818 image.SetAnchorPoint(AnchorPoint::TOP_LEFT);
819 scrollView.Add(image);
823 // Do a pan starting from 100,100 and moving down diagonally.
824 Vector2 pos(100.0f, 100.0f);
825 SendPan(application, Gesture::Possible, pos);
826 SendPan(application, Gesture::Started, pos);
829 Wait(application, 100);
831 for(int i = 0;i<20;i++)
833 SendPan(application, Gesture::Continuing, pos);
839 SendPan(application, Gesture::Finished, pos);
840 Wait(application, RENDER_DELAY_SCROLL);
842 DALI_TEST_CHECK(gOnScrollStartCalled);
843 DALI_TEST_CHECK(gOnScrollUpdateCalled);
844 DALI_TEST_CHECK(gOnScrollCompleteCalled);
848 static Vector2 PerformGestureDiagonalSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, bool finish = true)
850 gOnScrollStartCalled = false;
851 gOnScrollUpdateCalled = false;
852 gOnScrollCompleteCalled = false;
853 gOnSnapStartCalled = false;
855 // Now do a pan starting from (start) and heading (direction)
857 SendPan(application, Gesture::Possible, pos);
858 SendPan(application, Gesture::Started, pos);
861 for(int i = 0;i<frames;i++)
863 pos += direction; // Move in this direction
864 SendPan(application, Gesture::Continuing, pos);
870 pos += direction; // Move in this direction.
871 SendPan(application, Gesture::Finished, pos);
872 Wait(application, RENDER_DELAY_SCROLL);
878 int UtcDaliToolkitScrollViewScrollSensitive(void)
880 ToolkitTestApplication application;
881 tet_infoline(" UtcDaliToolkitScrollViewScrollSensitive");
883 // Set up a scrollView...
884 ScrollView scrollView = ScrollView::New();
885 Stage::GetCurrent().Add( scrollView );
886 Vector2 stageSize = Stage::GetCurrent().GetSize();
887 scrollView.SetSize(stageSize);
888 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
889 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
892 RulerPtr rulerX = new DefaultRuler();
893 RulerPtr rulerY = new DefaultRuler();
894 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
895 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
896 scrollView.SetRulerX(rulerX);
897 scrollView.SetRulerY(rulerY);
898 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
899 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
900 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
901 scrollView.SnapStartedSignal().Connect( &OnSnapStart );
903 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
906 // First try insensitive swipe.
907 scrollView.SetScrollSensitive(false);
908 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, true);
910 DALI_TEST_CHECK( !gOnScrollStartCalled );
911 DALI_TEST_CHECK( !gOnScrollCompleteCalled );
912 DALI_TEST_CHECK( !gOnSnapStartCalled );
914 // Second try sensitive swipe.
915 scrollView.SetScrollSensitive(true);
916 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, true);
918 DALI_TEST_CHECK( gOnScrollStartCalled );
919 DALI_TEST_CHECK( gOnScrollCompleteCalled );
920 DALI_TEST_CHECK( gOnSnapStartCalled );
924 int UtcDaliToolkitScrollViewAxisAutoLock(void)
926 ToolkitTestApplication application;
927 tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLock");
929 // Set up a scrollView...
930 ScrollView scrollView = ScrollView::New();
931 Stage::GetCurrent().Add( scrollView );
932 Vector2 stageSize = Stage::GetCurrent().GetSize();
933 scrollView.SetSize(stageSize);
934 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
935 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
938 RulerPtr rulerX = new DefaultRuler();
939 RulerPtr rulerY = new DefaultRuler();
940 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
941 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
942 scrollView.SetRulerX(rulerX);
943 scrollView.SetRulerY(rulerY);
944 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
945 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
946 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
949 scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
951 Vector2 startPosition = scrollView.GetCurrentScrollPosition();
952 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(5.0f, 1.0f), 50, true); // mostly horizontal
953 const Vector2 positionAfterNormal = scrollView.GetCurrentScrollPosition();
956 scrollView.SetAxisAutoLock(true);
957 DALI_TEST_CHECK(scrollView.GetAxisAutoLock());
959 scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
961 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(5.0f, 1.0f), 50, true); // mostly horizontal
962 const Vector2 positionAfterAutoLock = scrollView.GetCurrentScrollPosition();
964 // compare how much the Y position has deviated for normal and autolock.
965 const float devianceNormal = fabsf(startPosition.y - positionAfterNormal.y);
966 const float devianceAutoLock = fabsf(startPosition.y - positionAfterAutoLock.y);
968 // in auto-lock it should be a mostly horizontal pan (thus deviance should be much lower)
969 DALI_TEST_CHECK(devianceAutoLock < devianceNormal);
971 scrollView.SetAxisAutoLock(false);
972 DALI_TEST_CHECK(!scrollView.GetAxisAutoLock());
976 int UtcDaliToolkitScrollViewAxisAutoLockGradient(void)
978 ToolkitTestApplication application;
979 tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLockGradient");
981 // Set up a scrollView...
982 ScrollView scrollView = ScrollView::New();
983 scrollView.SetAxisAutoLockGradient(0.5f);
984 DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 0.5f, TEST_LOCATION);
985 scrollView.SetAxisAutoLockGradient(1.0f);
986 DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 1.0f, TEST_LOCATION);
990 int UtcDaliToolkitScrollViewConstraints(void)
992 ToolkitTestApplication application;
993 tet_infoline(" UtcDaliToolkitScrollViewConstraints");
995 // Set up a scrollView...
996 ScrollView scrollView = ScrollView::New();
997 Stage::GetCurrent().Add( scrollView );
998 Vector2 stageSize = Stage::GetCurrent().GetSize();
999 scrollView.SetSize(stageSize);
1000 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1001 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1004 RulerPtr rulerX = new DefaultRuler();
1005 RulerPtr rulerY = new DefaultRuler();
1006 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1007 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1008 scrollView.SetRulerX(rulerX);
1009 scrollView.SetRulerY(rulerY);
1011 // Add an Actor to ScrollView,
1012 // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1013 gConstraintResult = Vector3::ZERO;
1014 Actor a = Actor::New();
1016 a.SetPosition( TEST_ACTOR_POSITION );
1019 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1020 constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
1021 constraint.SetRemoveAction(Constraint::Discard);
1022 scrollView.ApplyConstraintToChildren(constraint);
1025 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1027 gConstraintResult = Vector3::ZERO;
1028 scrollView.RemoveConstraintsFromChildren();
1031 DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
1035 int UtcDaliToolkitScrollViewBind(void)
1037 ToolkitTestApplication application;
1038 tet_infoline(" UtcDaliToolkitScrollViewBind");
1040 // Set up a scrollView...
1041 ScrollView scrollView = ScrollView::New();
1042 Stage::GetCurrent().Add( scrollView );
1043 Vector2 stageSize = Stage::GetCurrent().GetSize();
1044 scrollView.SetSize(stageSize);
1045 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1046 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1049 RulerPtr rulerX = new DefaultRuler();
1050 RulerPtr rulerY = new DefaultRuler();
1051 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1052 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1053 scrollView.SetRulerX(rulerX);
1054 scrollView.SetRulerY(rulerY);
1056 // Add an Actor to ScrollView,
1057 // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1059 gConstraintResult = Vector3::ZERO;
1060 Actor a = Actor::New();
1062 a.SetPosition( TEST_ACTOR_POSITION );
1065 // apply this constraint to scrollview
1066 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1067 constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
1068 constraint.SetRemoveAction(Constraint::Discard);
1069 scrollView.ApplyConstraintToChildren(constraint);
1073 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1076 gConstraintResult = Vector3::ZERO;
1077 scrollView.UnbindActor( a );
1079 DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
1082 gConstraintResult = Vector3::ZERO;
1083 scrollView.BindActor( a );
1085 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1089 int UtcDaliToolkitScrollViewOvershoot(void)
1091 ToolkitTestApplication application;
1092 tet_infoline(" UtcDaliToolkitScrollViewOvershoot");
1094 // Set up a scrollView...
1095 ScrollView scrollView = ScrollView::New();
1096 Stage::GetCurrent().Add( scrollView );
1097 Vector2 stageSize = Stage::GetCurrent().GetSize();
1098 scrollView.SetSize(stageSize);
1099 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1100 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1103 RulerPtr rulerX = new DefaultRuler();
1104 RulerPtr rulerY = new DefaultRuler();
1105 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1106 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1107 scrollView.SetRulerX(rulerX);
1108 scrollView.SetRulerY(rulerY);
1109 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1110 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1111 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1113 scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1116 // 1. Scroll page in NW (-500,-500 pixels), then inspect overshoot. (don't release touch)
1117 Vector2 currentPos = Vector2(100.0f, 100.0f);
1118 currentPos = PerformGestureDiagonalSwipe(application, currentPos, Vector2(5.0f, 5.0f), 100, false);
1119 float overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1120 float overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1121 Vector2 positionValue = scrollView.GetProperty<Vector2>(ScrollView::Property::SCROLL_POSITION);
1122 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1123 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1124 DALI_TEST_EQUALS(positionValue, Vector2::ZERO, TEST_LOCATION);
1126 float timeToReachOrigin;
1128 // Now release touch. Overshoot should snap back to zero.
1129 SendPan(application, Gesture::Finished, currentPos);
1130 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1132 float minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1133 float maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1135 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1136 (timeToReachOrigin < maxTimeToReachOrigin) );
1138 // 2. Repeat Scroll, but this time change overshoot snap duration to shorter time
1139 scrollView.SetSnapOvershootDuration(TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION);
1141 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1142 // Now release touch. Overshoot should snap back to zero.
1143 SendPan(application, Gesture::Finished, currentPos);
1144 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1146 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1147 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1149 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1150 (timeToReachOrigin < maxTimeToReachOrigin) );
1152 // 3. Repeat Scroll, but this time change overshoot snap duration to longer time.
1153 scrollView.SetSnapOvershootDuration(TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION);
1155 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1156 // Now release touch. Overshoot should snap back to zero.
1157 SendPan(application, Gesture::Finished, currentPos);
1158 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1160 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1161 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1163 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1164 (timeToReachOrigin < maxTimeToReachOrigin) );
1166 // 4. Repeat Scroll, but this time change overshoot function.
1167 scrollView.SetSnapOvershootDuration(TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION);
1168 scrollView.SetSnapOvershootAlphaFunction(TestAlphaFunction);
1170 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1171 // Now release touch. Overshoot should snap back to zero.
1172 SendPan(application, Gesture::Finished, currentPos);
1173 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1175 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1176 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1178 DALI_TEST_CHECK( (timeToReachOrigin > minTimeToReachOrigin) &&
1179 (timeToReachOrigin < maxTimeToReachOrigin) );
1183 int UtcDaliToolkitScrollViewSnapAlphaFunction(void)
1185 ToolkitTestApplication application;
1186 tet_infoline(" UtcDaliToolkitScrollViewSnapAlphaFunction");
1188 // Set up a scrollView...
1189 ScrollView scrollView = ScrollView::New();
1190 scrollView.SetScrollSnapAlphaFunction( AlphaFunction::EASE_IN );
1191 DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_IN );
1192 scrollView.SetScrollSnapAlphaFunction( AlphaFunction::EASE_OUT );
1193 DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_OUT );
1195 scrollView.SetScrollFlickAlphaFunction( AlphaFunction::BOUNCE );
1196 DALI_TEST_CHECK( scrollView.GetScrollFlickAlphaFunction().GetBuiltinFunction() == AlphaFunction::BOUNCE );
1201 int UtcDaliToolkitScrollViewSnapDuration(void)
1203 ToolkitTestApplication application;
1204 tet_infoline(" UtcDaliToolkitScrollViewSnapDuration");
1206 // Set up a scrollView...
1207 ScrollView scrollView = ScrollView::New();
1208 scrollView.SetScrollSnapDuration( 1.0f );
1209 DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 1.0f, TEST_LOCATION );
1210 scrollView.SetScrollSnapDuration( 0.5f );
1211 DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 0.5f, TEST_LOCATION );
1213 scrollView.SetScrollFlickDuration( 2.0f );
1214 DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 2.0f, TEST_LOCATION );
1215 scrollView.SetScrollFlickDuration( 1.5f );
1216 DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 1.5f, TEST_LOCATION );
1220 int UtcDaliToolkitScrollViewSnapStartedSignalP(void)
1222 ToolkitTestApplication application;
1223 tet_infoline(" UtcDaliToolkitScrollViewSnapStartedSignalP");
1225 // Set up a scrollView...
1226 ScrollView scrollView = ScrollView::New();
1227 Stage::GetCurrent().Add( scrollView );
1228 Vector2 stageSize = Stage::GetCurrent().GetSize();
1229 scrollView.SetSize(stageSize);
1230 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1231 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1234 RulerPtr rulerX = new DefaultRuler();
1235 RulerPtr rulerY = new DefaultRuler();
1236 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1237 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1238 scrollView.SetRulerX(rulerX);
1239 scrollView.SetRulerY(rulerY);
1240 scrollView.SnapStartedSignal().Connect( &OnSnapStart );
1242 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1245 // First try a snap.
1246 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(0.5f, 0.0f), 60, true);
1248 DALI_TEST_CHECK( gOnSnapStartCalled );
1249 DALI_TEST_CHECK( gLastSnapType == Toolkit::Snap );
1251 // Second try a swipe.
1252 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(20.0f, 0.0f), 60, true);
1254 DALI_TEST_CHECK( gOnSnapStartCalled );
1255 DALI_TEST_CHECK( gLastSnapType == Toolkit::Flick );
1259 int UtcDaliToolkitScrollViewGetCurrentPageP(void)
1261 ToolkitTestApplication application;
1262 tet_infoline(" UtcDaliToolkitScrollViewGetCurrentPageP");
1264 ScrollView scrollView = ScrollView::New();
1265 Stage::GetCurrent().Add( scrollView );
1266 RulerPtr rulerX = new FixedRuler( 100.0f );
1267 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1268 RulerPtr rulerY = new FixedRuler( 100.0f );
1269 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1271 scrollView.SetRulerX( rulerX );
1272 scrollView.SetRulerY( rulerY );
1274 scrollView.ScrollTo( 15 );
1275 Wait(application, RENDER_DELAY_SCROLL);
1276 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION );
1278 scrollView.ScrollTo( 3 );
1279 Wait(application, RENDER_DELAY_SCROLL);
1280 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION );
1282 scrollView.ScrollTo( 9 );
1283 Wait(application, RENDER_DELAY_SCROLL);
1284 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION );
1289 int UtcDaliToolkitScrollViewSetMaxOvershootP(void)
1291 ToolkitTestApplication application;
1292 tet_infoline(" UtcDaliToolkitScrollViewSetMaxOvershootP");
1294 // Set up a scrollView...
1295 ScrollView scrollView = ScrollView::New();
1296 Stage::GetCurrent().Add( scrollView );
1297 Vector2 stageSize = Stage::GetCurrent().GetSize();
1298 scrollView.SetSize(stageSize);
1299 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1300 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1303 RulerPtr rulerX = new DefaultRuler();
1304 RulerPtr rulerY = new DefaultRuler();
1305 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1306 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1307 scrollView.SetRulerX(rulerX);
1308 scrollView.SetRulerY(rulerY);
1310 // Set the max overshoot to be 50 pixels in both X axis and Y axis
1311 scrollView.SetMaxOvershoot(50.0f, 50.0f);
1313 scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1316 // Scroll page in NW (-20,-20 pixels), then check that overshoot should be 0. (don't release touch)
1317 Vector2 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 20, false);
1318 float overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1319 float overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1320 DALI_TEST_EQUALS(overshootXValue, 0.0f, TEST_LOCATION);
1321 DALI_TEST_EQUALS(overshootYValue, 0.0f, TEST_LOCATION);
1323 // Scroll page further in NW (-105,-105 pixels), then check that overshoot should be around 0.5. (don't release touch)
1324 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 105, false);
1325 overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1326 overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1327 DALI_TEST_CHECK(overshootXValue > 0.49f && overshootXValue < 0.51f);
1328 DALI_TEST_CHECK(overshootYValue > 0.49f && overshootYValue < 0.51f);
1330 // Scroll page further in NW (-30,-30 pixels), then check that overshoot should be now 1.0. (don't release touch)
1331 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 30, false);
1332 overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1333 overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1334 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1335 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1337 // Change the max overshoot to be 100 pixels in both X axis and Y axis
1338 scrollView.SetMaxOvershoot(100.0f, 100.0f);
1341 // Check that overshoot should be now around 0.8.
1342 overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1343 overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1344 DALI_TEST_CHECK(overshootXValue > 0.79f && overshootXValue < 0.81f);
1345 DALI_TEST_CHECK(overshootYValue > 0.79f && overshootYValue < 0.81f);
1347 // Scroll page further in NW (-30,-30 pixels), then check that overshoot should be now 1.0. (don't release touch)
1348 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 30, false);
1349 overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1350 overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1351 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1352 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1357 int UtcDaliToolkitScrollViewSetScrollingDirectionP(void)
1359 ToolkitTestApplication application;
1360 tet_infoline(" UtcDaliToolkitScrollViewSetScrollingDirectionP");
1362 // Set up a scrollView...
1363 ScrollView scrollView = ScrollView::New();
1364 Stage::GetCurrent().Add( scrollView );
1365 Vector2 stageSize = Stage::GetCurrent().GetSize();
1366 scrollView.SetSize(stageSize);
1367 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1368 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1370 Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1372 scrollView.ScrollTo(START_POSITION, 0.0f);
1374 // Try a vertical swipe.
1375 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1376 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(10.0f, -50.0f), TEST_LOCATION );
1378 scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1380 scrollView.ScrollTo(START_POSITION, 0.0f);
1382 // Try a vertical swipe.
1383 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1384 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION );
1386 scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1388 scrollView.ScrollTo(Vector2(10.0f, 10.0f), 0.0f);
1390 // Try a vertical swipe.
1391 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1392 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(10.0f, -50.0f), TEST_LOCATION );
1397 int UtcDaliToolkitScrollViewRemoveScrollingDirectionP(void)
1399 ToolkitTestApplication application;
1400 tet_infoline(" UtcDaliToolkitScrollViewRemoveScrollingDirectionP");
1402 // Set up a scrollView...
1403 ScrollView scrollView = ScrollView::New();
1404 Stage::GetCurrent().Add( scrollView );
1405 Vector2 stageSize = Stage::GetCurrent().GetSize();
1406 scrollView.SetSize(stageSize);
1407 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1408 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1410 Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1412 scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1414 scrollView.ScrollTo(START_POSITION, 0.0f);
1416 // Try a vertical swipe.
1417 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1418 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION );
1420 scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1422 scrollView.ScrollTo(Vector2(10.0f, 10.0f), 0.0f);
1424 // Try a vertical swipe.
1425 PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true);
1426 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(10.0f, -50.0f), TEST_LOCATION );
1431 int UtcDaliToolkitScrollViewSetRulerXP(void)
1433 ToolkitTestApplication application;
1434 tet_infoline(" UtcDaliToolkitScrollViewSetRulerXP");
1436 ScrollView scrollView = ScrollView::New();
1437 Stage::GetCurrent().Add( scrollView );
1438 RulerPtr rulerX = new FixedRuler( 100.0f );
1439 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1441 scrollView.SetRulerX( rulerX );
1443 scrollView.ScrollTo( 1, 0.0f );
1445 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION );
1447 RulerPtr newRulerX = new FixedRuler( 200.0f );
1448 newRulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
1450 scrollView.SetRulerX( newRulerX );
1452 scrollView.ScrollTo( 1, 0.0f );
1454 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 0.0f), TEST_LOCATION );
1459 int UtcDaliToolkitScrollViewSetRulerYP(void)
1461 ToolkitTestApplication application;
1462 tet_infoline(" UtcDaliToolkitScrollViewSetRulerYP");
1464 ScrollView scrollView = ScrollView::New();
1465 Stage::GetCurrent().Add( scrollView );
1467 RulerPtr rulerY = new FixedRuler( 200.0f );
1468 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1470 scrollView.SetRulerY( rulerY );
1472 scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f );
1474 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 350.0f), TEST_LOCATION );
1476 RulerPtr newRulerY = new FixedRuler( 100.0f );
1477 newRulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
1478 scrollView.SetRulerY( newRulerY );
1480 scrollView.ScrollTo( Vector2(0.0f, 350.0f), 0.0f );
1482 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 200.0f), TEST_LOCATION );
1487 int UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP(void)
1489 ToolkitTestApplication application;
1490 tet_infoline(" UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP");
1492 ScrollView scrollView = ScrollView::New();
1493 scrollView.SetMinimumSpeedForFlick(25.0f);
1494 DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 25.0f, TEST_LOCATION );
1495 scrollView.SetMinimumSpeedForFlick(60.0f);
1496 DALI_TEST_EQUALS( scrollView.GetMinimumSpeedForFlick(), 60.0f, TEST_LOCATION );
1500 int UtcDaliToolkitScrollViewSetMinimumDistanceForFlickP(void)
1502 ToolkitTestApplication application;
1503 tet_infoline(" UtcDaliToolkitScrollViewSetMinimumDistanceForFlick");
1505 ScrollView scrollView = ScrollView::New();
1507 scrollView.SetMinimumDistanceForFlick(Vector2(30.0f, 15.0f));
1508 DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(30.0f, 15.0f), TEST_LOCATION );
1509 scrollView.SetMinimumDistanceForFlick(Vector2(60.0f, 30.0f));
1510 DALI_TEST_EQUALS( scrollView.GetMinimumDistanceForFlick(), Vector2(60.0f, 30.0f), TEST_LOCATION);
1514 int UtcDaliToolkitScrollViewSetMouseWheelScrollDistanceStepP(void)
1516 ToolkitTestApplication application;
1517 tet_infoline(" UtcDaliToolkitScrollViewSetMouseWheelScrollDistanceStepP");
1519 ScrollView scrollView = ScrollView::New();
1520 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
1521 scrollView.SetMouseWheelScrollDistanceStep(Vector2(30.0f, 15.0f));
1522 DALI_TEST_EQUALS( scrollView.GetMouseWheelScrollDistanceStep(), Vector2(30.0f, 15.0f), TEST_LOCATION );
1523 scrollView.SetMouseWheelScrollDistanceStep(Vector2(60.0f, 30.0f));
1524 DALI_TEST_EQUALS( scrollView.GetMouseWheelScrollDistanceStep(), Vector2(60.0f, 30.0f), TEST_LOCATION);
1528 int UtcDaliToolkitScrollViewApplyEffectP(void)
1530 ToolkitTestApplication application;
1531 tet_infoline(" UtcDaliToolkitScrollViewApplyEffectP");
1533 // Create a ScrollView
1534 ScrollView scrollView = ScrollView::New();
1536 // Create two scroll view effects
1537 Dali::Path path = Dali::Path::New();
1538 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);
1539 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);
1541 // Apply both effects
1542 scrollView.ApplyEffect(effect);
1543 scrollView.ApplyEffect(newEffect);
1545 DALI_TEST_CHECK( true );
1550 int UtcDaliToolkitScrollViewApplyEffectN(void)
1552 ToolkitTestApplication application;
1553 tet_infoline(" UtcDaliToolkitScrollViewApplyEffectN");
1555 // Create a ScrollView
1556 ScrollView scrollView = ScrollView::New();
1558 // Create two scroll view effects
1559 Dali::Path path = Dali::Path::New();
1560 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);
1561 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);
1563 // Apply both effects
1564 scrollView.ApplyEffect(effect);
1565 scrollView.ApplyEffect(newEffect);
1567 // Attempt to apply the same effect again
1570 scrollView.ApplyEffect(newEffect);
1571 tet_result( TET_FAIL );
1573 catch ( DaliException& e )
1575 DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
1581 int UtcDaliToolkitScrollViewRemoveEffectP(void)
1583 ToolkitTestApplication application;
1584 tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectP");
1586 // Create a ScrollView
1587 ScrollView scrollView = ScrollView::New();
1589 // Create two scroll view effects
1590 Dali::Path path = Dali::Path::New();
1591 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);
1592 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);
1594 // Apply both effects
1595 scrollView.ApplyEffect(effect);
1596 scrollView.ApplyEffect(newEffect);
1598 // Remove both effects
1599 scrollView.RemoveEffect(effect);
1600 scrollView.RemoveEffect(newEffect);
1602 DALI_TEST_CHECK( true );
1607 int UtcDaliToolkitScrollViewRemoveEffectN(void)
1609 ToolkitTestApplication application;
1610 tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectN");
1612 // Create a ScrollView
1613 ScrollView scrollView = ScrollView::New();
1615 // Create two scroll view effects
1616 Dali::Path path = Dali::Path::New();
1617 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);
1618 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);
1620 // Apply the first effect
1621 scrollView.ApplyEffect(effect);
1623 // Attempt to remove the second effect which has not been applied to scroll view
1626 scrollView.RemoveEffect(newEffect);
1627 tet_result( TET_FAIL );
1629 catch ( DaliException& e )
1631 DALI_TEST_ASSERT( e, "effectExistedInScrollView", TEST_LOCATION );
1637 int UtcDaliToolkitScrollViewRemoveAllEffectsP(void)
1639 ToolkitTestApplication application;
1640 tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsP");
1642 // Create a ScrollView
1643 ScrollView scrollView = ScrollView::New();
1645 // Create two scroll view effects
1646 Dali::Path path = Dali::Path::New();
1647 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);
1648 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);
1650 // Apply both effects
1651 scrollView.ApplyEffect(effect);
1652 scrollView.ApplyEffect(newEffect);
1654 // Attempt to apply the same first effect again
1657 scrollView.ApplyEffect(effect);
1658 tet_result( TET_FAIL );
1660 catch ( DaliException& e )
1662 DALI_TEST_ASSERT( e, "!effectAlreadyExistsInScrollView", TEST_LOCATION );
1665 // Remove both effects
1666 scrollView.RemoveAllEffects();
1668 // Apply both effects again
1669 scrollView.ApplyEffect(effect);
1670 scrollView.ApplyEffect(newEffect);
1672 DALI_TEST_CHECK( true );
1677 int UtcDaliToolkitScrollViewRemoveAllEffectsN(void)
1679 ToolkitTestApplication application;
1680 tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsN");
1682 // Create a ScrollView
1683 ScrollView scrollView = ScrollView::New();
1685 // Remove effects when there is no effect applied previously
1686 scrollView.RemoveAllEffects();
1688 DALI_TEST_CHECK( true );
1693 int UtcDaliToolkitScrollViewSetOvershootEnabledP(void)
1695 ToolkitTestApplication application;
1696 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEnabledP");
1698 ScrollView scrollView = ScrollView::New();
1700 scrollView.SetOvershootEnabled(true);
1701 DALI_TEST_CHECK(scrollView.IsOvershootEnabled());
1703 scrollView.SetOvershootEnabled(false);
1704 DALI_TEST_CHECK(!scrollView.IsOvershootEnabled());
1709 int UtcDaliToolkitScrollViewSetOvershootEffectColorP(void)
1711 ToolkitTestApplication application;
1712 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEffectColorP");
1714 ScrollView scrollView = ScrollView::New();
1716 scrollView.SetOvershootEffectColor(Dali::Color::RED);
1717 DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::RED, TEST_LOCATION);
1719 scrollView.SetOvershootEffectColor(Dali::Color::YELLOW);
1720 DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::YELLOW, TEST_LOCATION);
1725 int UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP(void)
1727 ToolkitTestApplication application;
1728 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP");
1730 ScrollView scrollView = ScrollView::New();
1732 scrollView.SetOvershootAnimationSpeed(55.0f);
1733 DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 55.0f, TEST_LOCATION);
1735 scrollView.SetOvershootAnimationSpeed(120.0f);
1736 DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 120.0f, TEST_LOCATION);
1741 int UtcDaliToolkitScrollViewGetSet(void)
1743 ToolkitTestApplication application;
1744 tet_infoline(" UtcDaliToolkitScrollViewGetSet");
1745 ScrollView scrollView = ScrollView::New();
1746 scrollView.SetMaxFlickSpeed(0.5f);
1747 DALI_TEST_EQUALS(scrollView.GetMaxFlickSpeed(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1748 scrollView.SetFrictionCoefficient(0.6f);
1749 DALI_TEST_EQUALS(scrollView.GetFrictionCoefficient(), 0.6f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1750 scrollView.SetFlickSpeedCoefficient(0.7f);
1751 DALI_TEST_EQUALS(scrollView.GetFlickSpeedCoefficient(), 0.7f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1755 int UtcDaliToolkitScrollViewRulerDomainConstructorP(void)
1757 ToolkitTestApplication application;
1759 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
1760 DALI_TEST_EQUALS( domainX.min, 0.0f, TEST_LOCATION);
1761 DALI_TEST_EQUALS( domainX.max, 200.0f, TEST_LOCATION);
1762 DALI_TEST_EQUALS( domainX.enabled, true, TEST_LOCATION);
1764 RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
1765 DALI_TEST_EQUALS( domainY.min, 100.0f, TEST_LOCATION);
1766 DALI_TEST_EQUALS( domainY.max, 500.0f, TEST_LOCATION);
1767 DALI_TEST_EQUALS( domainY.enabled, false, TEST_LOCATION);
1772 int UtcDaliToolkitScrollViewRulerDomainGetSizeP(void)
1774 ToolkitTestApplication application;
1776 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
1777 DALI_TEST_EQUALS( domainX.GetSize(), 200.0f, TEST_LOCATION);
1779 RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
1780 DALI_TEST_EQUALS( domainY.GetSize(), 400.0f, TEST_LOCATION);
1785 int UtcDaliToolkitScrollViewRulerDomainClampP(void)
1787 ToolkitTestApplication application;
1789 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
1791 float value = domainX.Clamp(50.0f, 100.0f, 1.0f);
1792 DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
1794 value = domainX.Clamp(300.0f, 20.0f, 1.0f);
1795 DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
1797 value = domainX.Clamp(300.0f, 20.0f, 0.5f);
1798 DALI_TEST_EQUALS( value, 80.0f, TEST_LOCATION);
1800 value = domainX.Clamp(250.0f, 200.0f, 2.0f);
1801 DALI_TEST_EQUALS( value, 200.0f, TEST_LOCATION);
1806 int UtcDaliToolkitScrollViewRulerDomainClampWithStateP(void)
1808 ToolkitTestApplication application;
1810 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
1813 float value = domainX.Clamp(50.0f, 100.0f, 1.0f, clamped);
1814 DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION);
1815 DALI_TEST_EQUALS( clamped, Dali::Toolkit::NotClamped, TEST_LOCATION);
1817 value = domainX.Clamp(-100.0f, 200.0f, 1.0f, clamped);
1818 DALI_TEST_EQUALS( value, 0.0f, TEST_LOCATION);
1819 DALI_TEST_EQUALS( clamped, Dali::Toolkit::ClampedToMin, TEST_LOCATION);
1821 value = domainX.Clamp(300.0f, 20.0f, 1.0f, clamped);
1822 DALI_TEST_EQUALS( value, 180.0f, TEST_LOCATION);
1823 DALI_TEST_EQUALS( clamped, Dali::Toolkit::ClampedToMax, TEST_LOCATION);
1828 int UtcDaliToolkitScrollViewDefaultRulerConstructorP(void)
1830 ToolkitTestApplication application;
1831 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerConstructorP");
1833 RulerPtr defaultRuler = new DefaultRuler();
1834 DALI_TEST_CHECK( defaultRuler );
1839 int UtcDaliToolkitScrollViewDefaultRulerDestructorP(void)
1841 ToolkitTestApplication application;
1842 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerDestructorP");
1844 RulerPtr defaultRuler = new DefaultRuler();
1846 DALI_TEST_CHECK( true );
1850 int UtcDaliToolkitScrollViewFixedRulerConstructorP(void)
1852 ToolkitTestApplication application;
1853 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerConstructorP");
1855 RulerPtr fixedRuler = new FixedRuler( 100.0f );
1856 DALI_TEST_CHECK( fixedRuler );
1858 fixedRuler = new FixedRuler( 0.0f );
1859 DALI_TEST_CHECK( fixedRuler );
1864 int UtcDaliToolkitScrollViewFixedRulerDestructorP(void)
1866 ToolkitTestApplication application;
1867 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerDestructorP");
1869 RulerPtr fixedRuler = new FixedRuler( 100.0f );
1871 DALI_TEST_CHECK( true );
1875 int UtcDaliToolkitScrollViewRulerGetTypeP(void)
1877 ToolkitTestApplication application;
1878 tet_infoline(" UtcDaliToolkitScrollViewRulerGetTypeP");
1880 RulerPtr defaultRuler = new DefaultRuler();
1881 DALI_TEST_CHECK( defaultRuler );
1882 DALI_TEST_EQUALS( defaultRuler->GetType(), Dali::Toolkit::Ruler::Free, TEST_LOCATION);
1884 RulerPtr fixedRuler = new FixedRuler( 100.0f );
1885 DALI_TEST_CHECK( fixedRuler );
1886 DALI_TEST_EQUALS( fixedRuler->GetType(), Dali::Toolkit::Ruler::Fixed, TEST_LOCATION);
1891 int UtcDaliToolkitScrollViewRulerGetExtensionP(void)
1893 ToolkitTestApplication application;
1894 tet_infoline(" UtcDaliToolkitScrollViewRulerGetExtensionP");
1896 RulerPtr defaultRuler = new DefaultRuler();
1897 DALI_TEST_CHECK( defaultRuler );
1898 DALI_TEST_CHECK( !defaultRuler->GetExtension() );
1900 RulerPtr fixedRuler = new FixedRuler( 100.0f );
1901 DALI_TEST_CHECK( fixedRuler );
1902 DALI_TEST_CHECK( !fixedRuler->GetExtension() );
1907 int UtcDaliToolkitScrollViewRulerEnableDisable(void)
1909 ToolkitTestApplication application;
1910 tet_infoline(" UtcDaliToolkitScrollViewRulerEnableDisable");
1912 RulerPtr ruler = new DefaultRuler();
1914 DALI_TEST_CHECK( ruler->IsEnabled() );
1916 DALI_TEST_CHECK( !ruler->IsEnabled() );
1918 DALI_TEST_CHECK( ruler->IsEnabled() );
1922 int UtcDaliToolkitScrollViewRulerDomainEnableDisable(void)
1924 ToolkitTestApplication application;
1925 tet_infoline(" UtcDaliToolkitScrollViewRulerDomainEnableDisable");
1927 RulerPtr ruler = new DefaultRuler();
1928 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
1930 ruler->SetDomain( RulerDomain(0.0f, 100.0f, true) );
1931 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 100.0f, TEST_LOCATION );
1932 DALI_TEST_EQUALS( ruler->Clamp(-200.0f), 0.0f, TEST_LOCATION );
1933 DALI_TEST_EQUALS( ruler->Clamp(200.0f), 100.0f, TEST_LOCATION );
1935 ruler->DisableDomain();
1936 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
1937 DALI_TEST_EQUALS( ruler->Clamp(-200.0f), -200.0f, TEST_LOCATION );
1938 DALI_TEST_EQUALS( ruler->Clamp(200.0f), 200.0f, TEST_LOCATION );
1942 int UtcDaliToolkitScrollViewRulerSnapAndClamp(void)
1944 ToolkitTestApplication application;
1945 tet_infoline(" UtcDaliToolkitScrollViewRulerSnapAndClamp");
1947 RulerPtr ruler = new FixedRuler( 50.0f );
1948 ruler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1950 // default testing. (snap and clamp)
1951 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f), 50.0f, TEST_LOCATION);
1952 DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f), 50.0f, TEST_LOCATION);
1953 DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f), 0.0f, TEST_LOCATION);
1954 DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f), 0.0f, TEST_LOCATION);
1955 DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f), 400.0f, TEST_LOCATION);
1956 DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f), 400.0f, TEST_LOCATION);
1959 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
1960 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.5f), 50.0f, TEST_LOCATION); // No Flick
1961 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
1963 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
1964 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.5f), 0.0f, TEST_LOCATION); // No Flick
1965 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
1968 DALI_TEST_EQUALS( ruler->SnapAndClamp(-10.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (over left boundary)
1969 DALI_TEST_EQUALS( ruler->SnapAndClamp(-5.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (slightly ovr left boundary)
1970 DALI_TEST_EQUALS( ruler->SnapAndClamp(300.0f, 0.5f, 10.0f), 300.0f, TEST_LOCATION); // 10 units long (not over a boundary)
1971 DALI_TEST_EQUALS( ruler->SnapAndClamp(395.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (slightly over right boundary)
1972 DALI_TEST_EQUALS( ruler->SnapAndClamp(500.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (over right boundary)
1975 DALI_TEST_EQUALS( ruler->SnapAndClamp(-100.0f, 0.5f, 0.0f, 2.0f), 0.0f, TEST_LOCATION);
1976 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 2.0f), 50.0f, TEST_LOCATION);
1977 DALI_TEST_EQUALS( ruler->SnapAndClamp(700.0f, 0.5f, 0.0f, 2.0f), 700.0f, TEST_LOCATION);
1978 DALI_TEST_EQUALS( ruler->SnapAndClamp(850.0f, 0.5f, 0.0f, 2.0f), 800.0f, TEST_LOCATION);
1980 // clamp state testing.
1982 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
1983 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
1984 DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
1985 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
1986 DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
1987 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
1988 DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
1989 DALI_TEST_EQUALS( clamped, ClampedToMin, TEST_LOCATION );
1990 DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
1991 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
1992 DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
1993 DALI_TEST_EQUALS( clamped, ClampedToMax, TEST_LOCATION );
1997 int UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP(void)
1999 ToolkitTestApplication application;
2000 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP");
2002 RulerPtr rulerNormal = new FixedRuler( 25.0f );
2003 rulerNormal->SetDomain( RulerDomain(10.0f, 90.0f, true) );
2005 unsigned int volume;
2008 position = rulerNormal->GetPositionFromPage(1, volume, true);
2009 DALI_TEST_EQUALS( position, 35.0f, TEST_LOCATION );
2010 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
2012 position = rulerNormal->GetPositionFromPage(2, volume, true);
2013 DALI_TEST_EQUALS( position, 60.0f, TEST_LOCATION );
2014 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
2016 // Disable the ruler
2017 rulerNormal->Disable();
2019 position = rulerNormal->GetPositionFromPage(1, volume, true);
2020 DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
2021 DALI_TEST_EQUALS( volume, 1u, TEST_LOCATION );
2023 position = rulerNormal->GetPositionFromPage(2, volume, true);
2024 DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
2025 DALI_TEST_EQUALS( volume, 2u, TEST_LOCATION );
2030 int UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP(void)
2032 ToolkitTestApplication application;
2033 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP");
2035 RulerPtr defaultRuler = new DefaultRuler();
2036 DALI_TEST_CHECK( defaultRuler );
2037 DALI_TEST_EQUALS( defaultRuler->GetTotalPages(), 1u, TEST_LOCATION);
2042 int UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP(void)
2044 ToolkitTestApplication application;
2045 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP");
2047 RulerPtr defaultRuler = new DefaultRuler();
2048 DALI_TEST_CHECK( defaultRuler );
2049 DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(100.0f, true), 0u, TEST_LOCATION);
2050 DALI_TEST_EQUALS( defaultRuler->GetPageFromPosition(-300.0f, false), 0u, TEST_LOCATION);
2055 int UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP(void)
2057 ToolkitTestApplication application;
2058 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP");
2060 RulerPtr defaultRuler = new DefaultRuler();
2061 DALI_TEST_CHECK( defaultRuler );
2063 unsigned int volume;
2064 DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(0, volume, true), 0.0f, TEST_LOCATION);
2065 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
2067 DALI_TEST_EQUALS( defaultRuler->GetPositionFromPage(3, volume, false), 0.0f, TEST_LOCATION);
2068 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION);
2073 int UtcDaliToolkitScrollViewDefaultRulerSnapP(void)
2075 ToolkitTestApplication application;
2076 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerSnapP");
2078 RulerPtr defaultRuler = new DefaultRuler();
2079 DALI_TEST_CHECK( defaultRuler );
2081 DALI_TEST_EQUALS( defaultRuler->Snap(50.0f, 0.5f), 50.0f, TEST_LOCATION);
2082 DALI_TEST_EQUALS( defaultRuler->Snap(-120.0f, 1.0f), -120.0f, TEST_LOCATION);
2087 int UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP(void)
2089 ToolkitTestApplication application;
2090 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP");
2092 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2093 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2095 fixedRuler->Enable();
2096 DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 4u, TEST_LOCATION);
2098 fixedRuler->Disable();
2099 DALI_TEST_EQUALS( fixedRuler->GetTotalPages(), 1u, TEST_LOCATION);
2104 int UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP(void)
2106 ToolkitTestApplication application;
2107 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP");
2109 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2110 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2112 fixedRuler->Enable();
2113 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 3u, TEST_LOCATION);
2114 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2115 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 1u, TEST_LOCATION);
2116 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2118 fixedRuler->Disable();
2119 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2120 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
2121 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2122 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2124 // Set domain size to be smaller than the ruler space
2125 fixedRuler->SetDomain( RulerDomain(0.0f, 50.0f, true) );
2127 fixedRuler->Enable();
2128 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2129 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2130 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2131 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2133 fixedRuler->Disable();
2134 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2135 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
2136 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2137 DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2142 int UtcDaliToolkitScrollViewFixedRulerSnapP(void)
2144 ToolkitTestApplication application;
2145 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerSnapP");
2147 RulerPtr fixedRuler = new FixedRuler( 100.0f );
2148 fixedRuler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
2150 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.0f), -100.0f, TEST_LOCATION);
2151 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.0f), -100.0f, TEST_LOCATION);
2152 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.0f), -200.0f, TEST_LOCATION);
2153 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.0f), -500.0f, TEST_LOCATION);
2154 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.0f), 0.0f, TEST_LOCATION);
2155 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.0f), 0.0f, TEST_LOCATION);
2156 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.0f), 0.0f, TEST_LOCATION);
2157 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.0f), 100.0f, TEST_LOCATION);
2158 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.0f), 100.0f, TEST_LOCATION);
2159 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.0f), 200.0f, TEST_LOCATION);
2160 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.0f), 600.0f, TEST_LOCATION);
2162 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 0.5f), 0.0f, TEST_LOCATION);
2163 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 0.5f), -100.0f, TEST_LOCATION);
2164 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 0.5f), -100.0f, TEST_LOCATION);
2165 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 0.5f), -500.0f, TEST_LOCATION);
2166 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 0.5f), 0.0f, TEST_LOCATION);
2167 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 0.5f), 100.0f, TEST_LOCATION);
2168 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 0.5f), 100.0f, TEST_LOCATION);
2169 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 0.5f), 100.0f, TEST_LOCATION);
2170 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 0.5f), 100.0f, TEST_LOCATION);
2171 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 0.5f), 300.0f, TEST_LOCATION);
2172 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 0.5f), 600.0f, TEST_LOCATION);
2174 DALI_TEST_EQUALS( fixedRuler->Snap(-30.0f, 1.0f), 0.0f, TEST_LOCATION);
2175 DALI_TEST_EQUALS( fixedRuler->Snap(-70.0f, 1.0f), 0.0f, TEST_LOCATION);
2176 DALI_TEST_EQUALS( fixedRuler->Snap(-120.0f, 1.0f), -100.0f, TEST_LOCATION);
2177 DALI_TEST_EQUALS( fixedRuler->Snap(-480.0f, 1.0f), -400.0f, TEST_LOCATION);
2178 DALI_TEST_EQUALS( fixedRuler->Snap(20.0f, 1.0f), 100.0f, TEST_LOCATION);
2179 DALI_TEST_EQUALS( fixedRuler->Snap(50.0f, 1.0f), 100.0f, TEST_LOCATION);
2180 DALI_TEST_EQUALS( fixedRuler->Snap(80.0f, 1.0f), 100.0f, TEST_LOCATION);
2181 DALI_TEST_EQUALS( fixedRuler->Snap(100.0f, 1.0f), 200.0f, TEST_LOCATION);
2182 DALI_TEST_EQUALS( fixedRuler->Snap(120.0f, 1.0f), 200.0f, TEST_LOCATION);
2183 DALI_TEST_EQUALS( fixedRuler->Snap(250.0f, 1.0f), 300.0f, TEST_LOCATION);
2184 DALI_TEST_EQUALS( fixedRuler->Snap(620.0f, 1.0f), 700.0f, TEST_LOCATION);