2 * Copyright (c) 2014 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 Vector3 CLAMP_START_SCROLL_POSITION(30.0f, 100.0f, 0.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 int MAX_FRAMES_TO_TEST_OVERSHOOT = 600; ///< 10 seconds (at 60 frames per second).
69 const Vector3 OVERSHOOT_START_SCROLL_POSITION(100.0f, 100.0f, 0.0f); ///< Scroll start position for the Overshoot tests.
70 const float TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION = 0.05f; ///< a Test duration
71 const float TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION = 1.5f; ///< another Test duration
72 const float TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION = TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * 0.5f; // Same as above, but different alpha function.
73 const float TIME_TOLERANCE = 0.05f; ///< Allow testing tolerance between a 10th of second (+/- 3 frames)
76 // Generate a PanGestureEvent to send to Core
77 Integration::PanGestureEvent GeneratePan(
79 const Vector2& previousPosition,
80 const Vector2& currentPosition,
81 unsigned long timeDelta,
82 unsigned int numberOfTouches = 1)
84 Integration::PanGestureEvent pan(state);
86 pan.previousPosition = previousPosition;
87 pan.currentPosition = currentPosition;
88 pan.timeDelta = timeDelta;
89 pan.numberOfTouches = numberOfTouches;
95 * Helper to generate PanGestureEvent
97 * @param[in] application Application instance
98 * @param[in] state The Gesture State
99 * @param[in] pos The current position of touch.
101 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
105 if( (state == Gesture::Started) ||
106 (state == Gesture::Possible) )
112 application.ProcessEvent(GeneratePan(state, last, pos, RENDER_FRAME_INTERVAL));
119 * Simulate time passed by.
121 * @note this will always process at least 1 frame (1/60 sec)
123 * @param application Test application instance
124 * @param duration Time to pass in milliseconds.
125 * @return The actual time passed in milliseconds
127 int Wait(ToolkitTestApplication& application, int duration = 0)
131 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
133 application.SendNotification();
134 application.Render(RENDER_FRAME_INTERVAL);
135 time += RENDER_FRAME_INTERVAL;
143 static bool gOnScrollStartCalled; ///< Whether the OnScrollStart signal was invoked.
144 static bool gOnScrollUpdateCalled; ///< Whether the OnScrollUpdate signal was invoked.
145 static bool gOnScrollCompleteCalled; ///< Whether the OnScrollComplete signal was invoked.
146 static bool gOnSnapStartCalled; ///< Whether the OnSnapStart signal was invoked.
147 static SnapType gLastSnapType; ///< Snaping information from SnapEvent.
148 static Vector3 gConstraintResult; ///< Result from constraint.
151 * Invoked when scrolling starts.
153 * @param[in] position The current scroll position.
155 static void OnScrollStart( const Vector3& position )
157 gOnScrollStartCalled = true;
161 * Invoked when scrolling updates (via dragging)
163 * @param[in] position The current scroll position.
165 static void OnScrollUpdate( const Vector3& position )
167 gOnScrollUpdateCalled = true;
171 * Invoked when scrolling finishes
173 * @param[in] position The current scroll position.
175 static void OnScrollComplete( const Vector3& position )
177 gOnScrollCompleteCalled = true;
181 * Invoked when a snap or flick started.
183 * @param[in] event The type of snap and the target position/scale/rotation.
185 static void OnSnapStart( const ScrollView::SnapEvent& event )
187 gOnSnapStartCalled = true;
188 gLastSnapType = event.type;
194 * Summation of current value, property, and offset.
196 * current' = current + mOffset + property;
198 struct TestSumConstraint
201 * @param[in] offset The offset to be added to current.
203 TestSumConstraint(const Vector3& offset)
209 * @param[in] current The current base value
210 * @param[in] inputs Contains the property to be added to current.
211 * @return The new current Vector.
213 void operator()( Vector3& current, const PropertyInputContainer& inputs )
215 gConstraintResult = current + inputs[0]->GetVector3() + mOffset;
216 current = gConstraintResult;
224 * @param[in] application The application instance
225 * @param[in] scrollView The scrollView instance
226 * @return The time taken for the overshoot to reach origin (zero)
228 static float TestOvershootSnapDuration(ToolkitTestApplication &application, ScrollView scrollView)
230 int timeToReachOrigin = -1;
231 for(int i = 0;i<MAX_FRAMES_TO_TEST_OVERSHOOT;i++)
233 float overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
234 float overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
235 if(overshootXValue == 0.0f && overshootYValue == 0.0f)
240 timeToReachOrigin += Wait(application);
243 return static_cast<float>(timeToReachOrigin) * 0.001f; // return in seconds not ms.
247 * y = 2x alpha function, which is clamped between 0.0f - 1.0f
249 * Animations should appear to finish (reach 100% point)
250 * at just half the time of a regular Linear AlphaFunction.
252 * @param[in] progress value (ranges from 0.0f - 1.0f)
253 * @return interpolation value (ranges from 0.0f - 1.0f)
255 float TestAlphaFunction(float progress)
257 return std::min( progress * 2.0f, 1.0f );
260 } // unnamed namespace
263 int UtcDaliScrollViewNew(void)
265 ToolkitTestApplication application;
266 tet_infoline(" UtcDaliScrollViewNew");
268 ScrollView scrollView;
270 DALI_TEST_CHECK( !scrollView );
272 scrollView = ScrollView::New();
274 DALI_TEST_CHECK( scrollView );
276 ScrollView scrollView2(scrollView);
278 DALI_TEST_CHECK( scrollView2 == scrollView );
280 //Additional check to ensure object is created by checking if it's registered
281 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
282 DALI_TEST_CHECK( registry );
284 gObjectCreatedCallBackCalled = false;
285 registry.ObjectCreatedSignal().Connect( &TestCallback );
287 ScrollView scrollView = ScrollView::New();
289 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
293 int UtcDaliScrollViewDownCast(void)
295 ToolkitTestApplication application;
296 tet_infoline(" UtcDaliScrollViewDownCast");
298 ScrollView scrollView = ScrollView::New();
299 BaseHandle handle(scrollView);
301 ScrollView newScrollView = ScrollView::DownCast( handle );
302 DALI_TEST_CHECK( scrollView );
303 DALI_TEST_CHECK( newScrollView == scrollView );
307 int UtcDaliScrollViewScrollToPosition(void)
309 ToolkitTestApplication application;
310 tet_infoline(" UtcDaliScrollViewScrollToPosition");
312 // Create the ScrollView actor
313 ScrollView scrollView = ScrollView::New();
314 Stage::GetCurrent().Add( scrollView );
316 const Vector3 target = Vector3(100.0f, 200.0f, 0.0f);
317 const Vector3 target2 = Vector3(300.0f, 100.0f, 0.0f);
319 scrollView.ScrollTo( target, 0.0f );
321 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
322 scrollView.ScrollTo( target2 );
323 Wait(application, RENDER_DELAY_SCROLL);
324 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
330 int UtcDaliScrollViewScrollToPage(void)
332 ToolkitTestApplication application;
333 tet_infoline(" UtcDaliScrollViewScrollToPage");
335 ScrollView scrollView = ScrollView::New();
336 Stage::GetCurrent().Add( scrollView );
337 RulerPtr rulerX = new FixedRuler( 100.0f );
338 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
339 RulerPtr rulerY = new FixedRuler( 100.0f );
340 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
342 scrollView.SetRulerX( rulerX );
343 scrollView.SetRulerY( rulerY );
345 scrollView.ScrollTo( 1, 0.0f );
347 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(100.0f, 0.0f, 0.0f), TEST_LOCATION );
349 scrollView.ScrollTo( 5, 0.0f );
351 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(500.0f, 0.0f, 0.0f), TEST_LOCATION );
353 scrollView.ScrollTo( 10, 0.0f );
355 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(200.0f, 100.0f, 0.0f), TEST_LOCATION );
357 scrollView.ScrollTo( 15, 0.0f );
359 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(700.0f, 100.0f, 0.0f), TEST_LOCATION );
360 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION );
362 scrollView.ScrollTo( 3 );
363 Wait(application, RENDER_DELAY_SCROLL);
364 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(300.0f, 0.0f, 0.0f), TEST_LOCATION );
365 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION );
367 scrollView.ScrollTo( 9 );
368 Wait(application, RENDER_DELAY_SCROLL);
369 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(100.0f, 100.0f, 0.0f), TEST_LOCATION );
370 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION );
372 // Apply DefaultRulers instead and see what happens.
373 rulerX = new DefaultRuler();
374 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
375 rulerY = new DefaultRuler();
376 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
378 scrollView.SetRulerX( rulerX );
379 scrollView.SetRulerY( rulerY );
381 // This time should always scroll to origin (0.0f, 0.0f)
382 scrollView.ScrollTo( 1, 0.0f );
384 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
385 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
391 int UtcDaliScrollViewScrollToActor(void)
393 ToolkitTestApplication application;
394 tet_infoline(" UtcDaliScrollViewScrollToActor");
396 ScrollView scrollView = ScrollView::New();
397 Stage::GetCurrent().Add( scrollView );
399 Actor actorA = Actor::New();
400 const Vector3 positionA = Vector3(100.0f, 400.0f, 0.0f);
401 actorA.SetPosition(positionA);
402 scrollView.Add(actorA);
404 Actor actorB = Actor::New();
405 const Vector3 positionB = Vector3(500.0f, 200.0f, 0.0f);
406 actorB.SetPosition(positionB);
407 scrollView.Add(actorB);
411 scrollView.ScrollTo(actorA, 0.0f);
413 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA, TEST_LOCATION );
416 scrollView.ScrollTo(actorB, 0.0f);
418 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB, TEST_LOCATION );
420 scrollView.ScrollTo(actorA);
421 Wait(application, RENDER_DELAY_SCROLL);
422 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA, TEST_LOCATION );
424 scrollView.ScrollTo(actorB);
425 Wait(application, RENDER_DELAY_SCROLL);
426 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB, TEST_LOCATION );
430 int UtcDaliScrollViewScrollToSnapPoint(void)
432 ToolkitTestApplication application;
433 tet_infoline(" UtcDaliScrollViewScrollToSnapPoint");
435 ScrollView scrollView = ScrollView::New();
436 Stage::GetCurrent().Add( scrollView );
437 RulerPtr rulerX = new FixedRuler( 100.0f );
438 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
439 RulerPtr rulerY = new FixedRuler( 100.0f );
440 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
442 scrollView.SetRulerX( rulerX );
443 scrollView.SetRulerY( rulerY );
445 scrollView.ScrollTo( Vector3(120.0f, 190.0f, 0.0f), 0.0f );
447 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(120.0f, 190.0f, 0.0f), TEST_LOCATION );
449 scrollView.ScrollToSnapPoint();
451 Wait(application, RENDER_DELAY_SCROLL);
452 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(100.0f, 200.0f, 0.0f), TEST_LOCATION );
456 int UtcDaliScrollViewSetScrollUpdateDistance(void)
458 ToolkitTestApplication application;
459 tet_infoline(" UtcDaliScrollViewRefreshInterval");
461 ScrollView scrollView = ScrollView::New();
463 scrollView.SetScrollUpdateDistance(0);
464 DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 0, TEST_LOCATION);
465 scrollView.SetScrollUpdateDistance(10);
466 DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 10, TEST_LOCATION);
467 scrollView.SetScrollUpdateDistance(1000);
468 DALI_TEST_EQUALS( scrollView.GetScrollUpdateDistance(), 1000, TEST_LOCATION);
472 int UtcDaliScrollViewWrapMode(void)
474 ToolkitTestApplication application;
475 tet_infoline(" UtcDaliScrollViewWrapMode");
477 ScrollView scrollView = ScrollView::New();
478 Stage::GetCurrent().Add( scrollView );
480 // Position rulers. 4x4 grid.
481 RulerPtr rulerX = new FixedRuler(50.0f);
482 RulerPtr rulerY = new FixedRuler(50.0f);
483 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, false) );
484 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, false) );
485 scrollView.SetRulerX(rulerX);
486 scrollView.SetRulerY(rulerY);
488 scrollView.SetWrapMode(false);
489 scrollView.ScrollTo(Vector3(225.0f, 125.0f, 0.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
491 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 17, TEST_LOCATION );
492 scrollView.SetWrapMode(true);
493 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 13, TEST_LOCATION );
497 int UtcDaliScrollViewActorAutoSnap(void)
499 ToolkitTestApplication application;
500 tet_infoline(" UtcDaliScrollViewActorAutoSnap");
502 ScrollView scrollView = ScrollView::New();
503 Stage::GetCurrent().Add( scrollView );
506 RulerPtr rulerX = new DefaultRuler();
507 RulerPtr rulerY = new DefaultRuler();
508 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
509 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
510 scrollView.SetRulerX(rulerX);
511 scrollView.SetRulerY(rulerY);
513 const Vector3 aPosition = Vector3(200.0f, 50.0f, 0.0f);
514 Actor a = Actor::New();
516 a.SetPosition(aPosition);
518 const Vector3 bPosition = Vector3(600.0f, 600.0f, 0.0f);
519 Actor b = Actor::New();
521 b.SetPosition(bPosition);
523 // Goto a random position, and execute snap (should not move)
524 Vector3 targetScroll = Vector3(500.0f, 500.0f, 0.0f);
525 scrollView.ScrollTo(targetScroll, 0.0f);
527 scrollView.ScrollToSnapPoint();
528 Wait(application, RENDER_DELAY_SCROLL);
529 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), targetScroll, TEST_LOCATION );
531 // Enable ActorAutoSnap, and now try snapping.
532 scrollView.SetActorAutoSnap(true);
533 scrollView.ScrollToSnapPoint();
534 Wait(application, RENDER_DELAY_SCROLL);
535 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), bPosition, TEST_LOCATION );
537 scrollView.ScrollTo(Vector3(0.0f, 0.0f, 0.0f), 0.0f);
539 scrollView.ScrollToSnapPoint();
540 Wait(application, RENDER_DELAY_SCROLL);
541 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), aPosition, TEST_LOCATION );
545 int UtcDaliScrollViewSignalsStartComplete(void)
547 ToolkitTestApplication application;
548 tet_infoline(" UtcDaliScrollViewSignalsStartComplete");
550 gOnScrollStartCalled = false;
551 gOnScrollCompleteCalled = false;
553 ScrollView scrollView = ScrollView::New();
554 Stage::GetCurrent().Add( scrollView );
557 RulerPtr rulerX = new DefaultRuler();
558 RulerPtr rulerY = new DefaultRuler();
559 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
560 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
561 scrollView.SetRulerX(rulerX);
562 scrollView.SetRulerY(rulerY);
563 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
564 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
565 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
566 scrollView.ScrollTo( Vector3(100.0f, 100.0f, 0.0f) );
567 Wait(application, RENDER_DELAY_SCROLL);
569 DALI_TEST_CHECK(gOnScrollStartCalled);
570 DALI_TEST_CHECK(gOnScrollCompleteCalled);
574 int UtcDaliScrollViewSignalsUpdate(void)
576 ToolkitTestApplication application;
577 tet_infoline(" UtcDaliScrollViewSignalsUpdate");
579 gOnScrollStartCalled = false;
580 gOnScrollUpdateCalled = false;
581 gOnScrollCompleteCalled = false;
583 ScrollView scrollView = ScrollView::New();
584 Stage::GetCurrent().Add( scrollView );
585 Vector2 stageSize = Stage::GetCurrent().GetSize();
586 scrollView.SetSize(stageSize);
587 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
588 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
591 RulerPtr rulerX = new DefaultRuler();
592 RulerPtr rulerY = new DefaultRuler();
593 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
594 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
595 scrollView.SetRulerX(rulerX);
596 scrollView.SetRulerY(rulerY);
597 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
598 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
599 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
601 ImageActor image = CreateSolidColorActor( Color::RED );
602 image.SetSize(stageSize);
603 image.SetParentOrigin(ParentOrigin::TOP_LEFT);
604 image.SetAnchorPoint(AnchorPoint::TOP_LEFT);
605 scrollView.Add(image);
609 // Do a pan starting from 100,100 and moving down diagonally.
610 Vector2 pos(100.0f, 100.0f);
611 SendPan(application, Gesture::Possible, pos);
612 SendPan(application, Gesture::Started, pos);
615 Wait(application, 100);
617 for(int i = 0;i<20;i++)
619 SendPan(application, Gesture::Continuing, pos);
625 SendPan(application, Gesture::Finished, pos);
626 Wait(application, RENDER_DELAY_SCROLL);
628 DALI_TEST_CHECK(gOnScrollStartCalled);
629 DALI_TEST_CHECK(gOnScrollUpdateCalled);
630 DALI_TEST_CHECK(gOnScrollCompleteCalled);
634 static Vector2 PerformGestureDiagonalSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, bool finish = true)
636 gOnScrollStartCalled = false;
637 gOnScrollUpdateCalled = false;
638 gOnScrollCompleteCalled = false;
639 gOnSnapStartCalled = false;
641 // Now do a pan starting from (start) and heading (direction)
643 SendPan(application, Gesture::Possible, pos);
644 SendPan(application, Gesture::Started, pos);
647 for(int i = 0;i<frames;i++)
649 pos += direction; // Move in this direction
650 SendPan(application, Gesture::Continuing, pos);
656 pos += direction; // Move in this direction.
657 SendPan(application, Gesture::Finished, pos);
658 Wait(application, RENDER_DELAY_SCROLL);
664 int UtcDaliScrollViewScrollSensitive(void)
666 ToolkitTestApplication application;
667 tet_infoline(" UtcDaliScrollViewScrollSensitive");
669 // Set up a scrollView...
670 ScrollView scrollView = ScrollView::New();
671 Stage::GetCurrent().Add( scrollView );
672 Vector2 stageSize = Stage::GetCurrent().GetSize();
673 scrollView.SetSize(stageSize);
674 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
675 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
678 RulerPtr rulerX = new DefaultRuler();
679 RulerPtr rulerY = new DefaultRuler();
680 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
681 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
682 scrollView.SetRulerX(rulerX);
683 scrollView.SetRulerY(rulerY);
684 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
685 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
686 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
687 scrollView.SnapStartedSignal().Connect( &OnSnapStart );
689 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
692 // First try insensitive swipe.
693 scrollView.SetScrollSensitive(false);
694 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, true);
696 DALI_TEST_CHECK( !gOnScrollStartCalled );
697 DALI_TEST_CHECK( !gOnScrollCompleteCalled );
698 DALI_TEST_CHECK( !gOnSnapStartCalled );
700 // Second try sensitive swipe.
701 scrollView.SetScrollSensitive(true);
702 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, true);
704 DALI_TEST_CHECK( gOnScrollStartCalled );
705 DALI_TEST_CHECK( gOnScrollCompleteCalled );
706 DALI_TEST_CHECK( gOnSnapStartCalled );
710 int UtcDaliScrollViewAxisAutoLock(void)
712 ToolkitTestApplication application;
713 tet_infoline(" UtcDaliScrollViewAxisAutoLock");
715 // Set up a scrollView...
716 ScrollView scrollView = ScrollView::New();
717 Stage::GetCurrent().Add( scrollView );
718 Vector2 stageSize = Stage::GetCurrent().GetSize();
719 scrollView.SetSize(stageSize);
720 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
721 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
724 RulerPtr rulerX = new DefaultRuler();
725 RulerPtr rulerY = new DefaultRuler();
726 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
727 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
728 scrollView.SetRulerX(rulerX);
729 scrollView.SetRulerY(rulerY);
730 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
731 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
732 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
735 scrollView.ScrollTo(Vector3(100.0f, 100.0f, 0.0f), 0.0f); // move in a little.
737 Vector3 startPosition = scrollView.GetCurrentScrollPosition();
738 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(5.0f, 1.0f), 50, true); // mostly horizontal
739 const Vector3 positionAfterNormal = scrollView.GetCurrentScrollPosition();
742 scrollView.SetAxisAutoLock(true);
743 DALI_TEST_CHECK(scrollView.GetAxisAutoLock());
745 scrollView.ScrollTo(Vector3(100.0f, 100.0f, 0.0f), 0.0f); // move in a little.
747 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(5.0f, 1.0f), 50, true); // mostly horizontal
748 const Vector3 positionAfterAutoLock = scrollView.GetCurrentScrollPosition();
750 // compare how much the Y position has deviated for normal and autolock.
751 const float devianceNormal = fabsf(startPosition.y - positionAfterNormal.y);
752 const float devianceAutoLock = fabsf(startPosition.y - positionAfterAutoLock.y);
754 // in auto-lock it should be a mostly horizontal pan (thus deviance should be much lower)
755 DALI_TEST_CHECK(devianceAutoLock < devianceNormal);
757 scrollView.SetAxisAutoLock(false);
758 DALI_TEST_CHECK(!scrollView.GetAxisAutoLock());
762 int UtcDaliScrollViewAxisAutoLockGradient(void)
764 ToolkitTestApplication application;
765 tet_infoline(" UtcDaliScrollViewAxisAutoLockGradient");
767 // Set up a scrollView...
768 ScrollView scrollView = ScrollView::New();
769 scrollView.SetAxisAutoLockGradient(0.5f);
770 DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 0.5f, TEST_LOCATION);
771 scrollView.SetAxisAutoLockGradient(1.0f);
772 DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 1.0f, TEST_LOCATION);
776 int UtcDaliScrollViewConstraints(void)
778 ToolkitTestApplication application;
779 tet_infoline(" UtcDaliScrollViewConstraints");
781 // Set up a scrollView...
782 ScrollView scrollView = ScrollView::New();
783 Stage::GetCurrent().Add( scrollView );
784 Vector2 stageSize = Stage::GetCurrent().GetSize();
785 scrollView.SetSize(stageSize);
786 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
787 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
790 RulerPtr rulerX = new DefaultRuler();
791 RulerPtr rulerY = new DefaultRuler();
792 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
793 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
794 scrollView.SetRulerX(rulerX);
795 scrollView.SetRulerY(rulerY);
797 // Add an Actor to ScrollView,
798 // Apply TestSumConstraint to ScrollView's children (includes this Actor)
799 gConstraintResult = Vector3::ZERO;
800 Actor a = Actor::New();
802 a.SetPosition( TEST_ACTOR_POSITION );
805 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
806 constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
807 constraint.SetRemoveAction(Constraint::Discard);
808 scrollView.ApplyConstraintToChildren(constraint);
811 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
813 gConstraintResult = Vector3::ZERO;
814 scrollView.RemoveConstraintsFromChildren();
817 DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
821 int UtcDaliScrollViewBind(void)
823 ToolkitTestApplication application;
824 tet_infoline(" UtcDaliScrollViewBind");
826 // Set up a scrollView...
827 ScrollView scrollView = ScrollView::New();
828 Stage::GetCurrent().Add( scrollView );
829 Vector2 stageSize = Stage::GetCurrent().GetSize();
830 scrollView.SetSize(stageSize);
831 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
832 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
835 RulerPtr rulerX = new DefaultRuler();
836 RulerPtr rulerY = new DefaultRuler();
837 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
838 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
839 scrollView.SetRulerX(rulerX);
840 scrollView.SetRulerY(rulerY);
842 // Add an Actor to ScrollView,
843 // Apply TestSumConstraint to ScrollView's children (includes this Actor)
845 gConstraintResult = Vector3::ZERO;
846 Actor a = Actor::New();
848 a.SetPosition( TEST_ACTOR_POSITION );
851 // apply this constraint to scrollview
852 Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
853 constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
854 constraint.SetRemoveAction(Constraint::Discard);
855 scrollView.ApplyConstraintToChildren(constraint);
859 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
862 gConstraintResult = Vector3::ZERO;
863 scrollView.UnbindActor( a );
865 DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
868 gConstraintResult = Vector3::ZERO;
869 scrollView.BindActor( a );
871 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
875 int UtcDaliRulerEnableDisable(void)
877 ToolkitTestApplication application;
878 tet_infoline(" UtcDaliRulerEnableDisable");
880 RulerPtr ruler = new DefaultRuler();
882 DALI_TEST_CHECK( ruler->IsEnabled() );
884 DALI_TEST_CHECK( !ruler->IsEnabled() );
886 DALI_TEST_CHECK( ruler->IsEnabled() );
890 int UtcDaliRulerDomainEnableDisable(void)
892 ToolkitTestApplication application;
893 tet_infoline(" UtcDaliRulerDomainEnableDisable");
895 RulerPtr ruler = new DefaultRuler();
896 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
899 ruler->SetDomain( RulerDomain(0.0f, 100.0f, true) );
900 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 100.0f, TEST_LOCATION );
901 DALI_TEST_EQUALS( ruler->Clamp(-200.0f), 0.0f, TEST_LOCATION );
902 DALI_TEST_EQUALS( ruler->Clamp(200.0f), 100.0f, TEST_LOCATION );
904 ruler->DisableDomain();
905 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
906 DALI_TEST_EQUALS( ruler->Clamp(-200.0f), -200.0f, TEST_LOCATION );
907 DALI_TEST_EQUALS( ruler->Clamp(200.0f), 200.0f, TEST_LOCATION );
911 int UtcDaliRulerSnapAndClamp(void)
913 ToolkitTestApplication application;
914 tet_infoline(" UtcDaliRulerSnapAndClamp");
916 RulerPtr ruler = new FixedRuler( 50.0f );
917 ruler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
919 // default testing. (snap and clamp)
920 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f), 50.0f, TEST_LOCATION);
921 DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f), 50.0f, TEST_LOCATION);
922 DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f), 0.0f, TEST_LOCATION);
923 DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f), 0.0f, TEST_LOCATION);
924 DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f), 400.0f, TEST_LOCATION);
925 DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f), 400.0f, TEST_LOCATION);
928 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
929 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.5f), 50.0f, TEST_LOCATION); // No Flick
930 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
932 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
933 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.5f), 0.0f, TEST_LOCATION); // No Flick
934 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
937 DALI_TEST_EQUALS( ruler->SnapAndClamp(-10.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (over left boundary)
938 DALI_TEST_EQUALS( ruler->SnapAndClamp(-5.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (slightly ovr left boundary)
939 DALI_TEST_EQUALS( ruler->SnapAndClamp(300.0f, 0.5f, 10.0f), 300.0f, TEST_LOCATION); // 10 units long (not over a boundary)
940 DALI_TEST_EQUALS( ruler->SnapAndClamp(395.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (slightly over right boundary)
941 DALI_TEST_EQUALS( ruler->SnapAndClamp(500.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (over right boundary)
944 DALI_TEST_EQUALS( ruler->SnapAndClamp(-100.0f, 0.5f, 0.0f, 2.0f), 0.0f, TEST_LOCATION);
945 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 2.0f), 50.0f, TEST_LOCATION);
946 DALI_TEST_EQUALS( ruler->SnapAndClamp(700.0f, 0.5f, 0.0f, 2.0f), 700.0f, TEST_LOCATION);
947 DALI_TEST_EQUALS( ruler->SnapAndClamp(850.0f, 0.5f, 0.0f, 2.0f), 800.0f, TEST_LOCATION);
949 // clamp state testing.
951 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
952 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
953 DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
954 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
955 DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
956 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
957 DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
958 DALI_TEST_EQUALS( clamped, ClampedToMin, TEST_LOCATION );
959 DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
960 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
961 DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
962 DALI_TEST_EQUALS( clamped, ClampedToMax, TEST_LOCATION );
966 int UtcDaliRulerFixedRulerSpacing(void)
968 ToolkitTestApplication application;
969 tet_infoline(" UtcDaliRulerFixedRulerSpacing");
971 RulerPtr rulerNormal = new FixedRuler( 25.0f );
972 rulerNormal->SetDomain( RulerDomain(10.0f, 90.0f, true) );
977 position = rulerNormal->GetPositionFromPage(1, volume, true);
978 DALI_TEST_EQUALS( position, 35.0f, TEST_LOCATION );
979 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
981 position = rulerNormal->GetPositionFromPage(2, volume, true);
982 DALI_TEST_EQUALS( position, 60.0f, TEST_LOCATION );
983 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
987 int UtcDaliScrollViewOvershoot(void)
989 ToolkitTestApplication application;
990 tet_infoline(" UtcDaliScrollViewOvershoot");
992 // Set up a scrollView...
993 ScrollView scrollView = ScrollView::New();
994 Stage::GetCurrent().Add( scrollView );
995 Vector2 stageSize = Stage::GetCurrent().GetSize();
996 scrollView.SetSize(stageSize);
997 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
998 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1001 RulerPtr rulerX = new DefaultRuler();
1002 RulerPtr rulerY = new DefaultRuler();
1003 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1004 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1005 scrollView.SetRulerX(rulerX);
1006 scrollView.SetRulerY(rulerY);
1007 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1008 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1009 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1011 scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1014 // 1. Scroll page in NW (-500,-500 pixels), then inspect overshoot. (don't release touch)
1015 Vector2 currentPos = Vector2(100.0f, 100.0f);
1016 currentPos = PerformGestureDiagonalSwipe(application, currentPos, Vector2(5.0f, 5.0f), 100, false);
1017 float overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
1018 float overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1019 Vector3 positionValue = scrollView.GetProperty<Vector3>(ScrollView::Property::SCROLL_POSITION);
1020 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1021 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1022 DALI_TEST_EQUALS(positionValue, Vector3::ZERO, TEST_LOCATION);
1024 float timeToReachOrigin;
1026 // Now release touch. Overshoot should snap back to zero.
1027 SendPan(application, Gesture::Finished, currentPos);
1028 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1030 DALI_TEST_CHECK( (timeToReachOrigin > Toolkit::ScrollView::DEFAULT_SNAP_OVERSHOOT_DURATION - TIME_TOLERANCE) &&
1031 (timeToReachOrigin < Toolkit::ScrollView::DEFAULT_SNAP_OVERSHOOT_DURATION + TIME_TOLERANCE) );
1033 // 2. Repeat Scroll, but this time change overshoot snap duration to shorter time
1034 scrollView.SetSnapOvershootDuration(TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION);
1036 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1037 // Now release touch. Overshoot should snap back to zero.
1038 SendPan(application, Gesture::Finished, currentPos);
1039 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1041 DALI_TEST_CHECK( (timeToReachOrigin > TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION - TIME_TOLERANCE) &&
1042 (timeToReachOrigin < TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION + TIME_TOLERANCE) );
1044 // 3. Repeat Scroll, but this time change overshoot snap duration to longer time.
1045 scrollView.SetSnapOvershootDuration(TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION);
1047 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1048 // Now release touch. Overshoot should snap back to zero.
1049 SendPan(application, Gesture::Finished, currentPos);
1050 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1052 DALI_TEST_CHECK( (timeToReachOrigin > TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION - TIME_TOLERANCE) &&
1053 (timeToReachOrigin < TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION + TIME_TOLERANCE) );
1055 // 4. Repeat Scroll, but this time change overshoot function.
1056 scrollView.SetSnapOvershootDuration(TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION);
1057 scrollView.SetSnapOvershootAlphaFunction(TestAlphaFunction);
1059 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1060 // Now release touch. Overshoot should snap back to zero.
1061 SendPan(application, Gesture::Finished, currentPos);
1062 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1064 DALI_TEST_CHECK( (timeToReachOrigin > TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION - TIME_TOLERANCE) &&
1065 (timeToReachOrigin < TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION + TIME_TOLERANCE) );
1069 int UtcDaliScrollViewSnapAlphaFunction(void)
1071 ToolkitTestApplication application;
1072 tet_infoline(" UtcDaliScrollViewSnapAlphaFunction");
1074 // Set up a scrollView...
1075 ScrollView scrollView = ScrollView::New();
1076 scrollView.SetScrollSnapAlphaFunction( AlphaFunctions::EaseIn );
1077 DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction() == AlphaFunctions::EaseIn );
1078 scrollView.SetScrollSnapAlphaFunction( AlphaFunctions::EaseOut );
1079 DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction() == AlphaFunctions::EaseOut );
1081 scrollView.SetScrollFlickAlphaFunction( AlphaFunctions::Bounce );
1082 DALI_TEST_CHECK( scrollView.GetScrollFlickAlphaFunction() == AlphaFunctions::Bounce );
1083 scrollView.SetScrollFlickAlphaFunction( AlphaFunctions::BounceBack );
1084 DALI_TEST_CHECK( scrollView.GetScrollFlickAlphaFunction() == AlphaFunctions::BounceBack );
1088 int UtcDaliScrollViewSnapDuration(void)
1090 ToolkitTestApplication application;
1091 tet_infoline(" UtcDaliScrollViewSnapDuration");
1093 // Set up a scrollView...
1094 ScrollView scrollView = ScrollView::New();
1095 scrollView.SetScrollSnapDuration( 1.0f );
1096 DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 1.0f, TEST_LOCATION );
1097 scrollView.SetScrollSnapDuration( 0.5f );
1098 DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 0.5f, TEST_LOCATION );
1100 scrollView.SetScrollFlickDuration( 2.0f );
1101 DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 2.0f, TEST_LOCATION );
1102 scrollView.SetScrollFlickDuration( 1.5f );
1103 DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 1.5f, TEST_LOCATION );
1107 int UtcDaliScrollViewSignalsSnapStart(void)
1109 ToolkitTestApplication application;
1110 tet_infoline(" UtcDaliScrollViewSignalsSnapStart");
1112 // Set up a scrollView...
1113 ScrollView scrollView = ScrollView::New();
1114 Stage::GetCurrent().Add( scrollView );
1115 Vector2 stageSize = Stage::GetCurrent().GetSize();
1116 scrollView.SetSize(stageSize);
1117 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1118 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1121 RulerPtr rulerX = new DefaultRuler();
1122 RulerPtr rulerY = new DefaultRuler();
1123 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1124 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1125 scrollView.SetRulerX(rulerX);
1126 scrollView.SetRulerY(rulerY);
1127 scrollView.SnapStartedSignal().Connect( &OnSnapStart );
1129 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1132 // First try a snap.
1133 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(0.5f, 0.0f), 60, true);
1135 DALI_TEST_CHECK( gOnSnapStartCalled );
1136 DALI_TEST_CHECK( gLastSnapType == Toolkit::Snap );
1138 // Second try a swipe.
1139 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(20.0f, 0.0f), 60, true);
1141 DALI_TEST_CHECK( gOnSnapStartCalled );
1142 DALI_TEST_CHECK( gLastSnapType == Toolkit::Flick );
1147 int UtcDaliScrollViewSetMouseWheelScrollDistanceStep(void)
1149 ToolkitTestApplication application;
1150 tet_infoline(" UtcDaliScrollViewSetMouseWheelScrollDistanceStep");
1152 ScrollView scrollView = ScrollView::New();
1153 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
1154 scrollView.SetMouseWheelScrollDistanceStep(Vector2(30.0f, 15.0f));
1155 DALI_TEST_EQUALS( scrollView.GetMouseWheelScrollDistanceStep(), Vector2(30.0f, 15.0f), TEST_LOCATION );
1156 scrollView.SetMouseWheelScrollDistanceStep(Vector2(60.0f, 30.0f));
1157 DALI_TEST_EQUALS( scrollView.GetMouseWheelScrollDistanceStep(), Vector2(60.0f, 30.0f), TEST_LOCATION);
1161 int UtcDaliScrollViewGetSet(void)
1163 ToolkitTestApplication application;
1164 tet_infoline(" UtcDaliScrollViewGetSet");
1165 ScrollView scrollView = ScrollView::New();
1166 scrollView.SetMaxOvershoot(50.0f, 50.0f);
1167 scrollView.SetMaxFlickSpeed(0.5f);
1168 DALI_TEST_EQUALS(scrollView.GetMaxFlickSpeed(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1169 scrollView.SetFrictionCoefficient(0.6f);
1170 DALI_TEST_EQUALS(scrollView.GetFrictionCoefficient(), 0.6f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1171 scrollView.SetFlickSpeedCoefficient(0.7f);
1172 DALI_TEST_EQUALS(scrollView.GetFlickSpeedCoefficient(), 0.7f, Math::MACHINE_EPSILON_0, TEST_LOCATION);