2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
22 #include <dali/integration-api/events/touch-event-integ.h>
23 #include <dali/integration-api/events/pan-gesture-event.h>
24 #include <dali/dali.h>
25 #include <dali-toolkit/dali-toolkit.h>
27 #include <dali-toolkit-test-suite-utils.h>
30 using namespace Toolkit;
32 static void Startup();
33 static void Cleanup();
37 static bool gObjectCreatedCallBackCalled;
39 static void TestCallback(BaseHandle handle)
41 gObjectCreatedCallBackCalled = true;
46 void (*tet_startup)() = Startup;
47 void (*tet_cleanup)() = Cleanup;
52 POSITIVE_TC_IDX = 0x01,
56 // Add test functionality for all APIs in the class (Positive and Negative)
57 #define MAX_NUMBER_OF_TESTS 10000
59 struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
62 TEST_FUNCTION( UtcDaliScrollViewNew, POSITIVE_TC_IDX );
63 TEST_FUNCTION( UtcDaliScrollViewDownCast, POSITIVE_TC_IDX );
64 TEST_FUNCTION( UtcDaliScrollViewScrollToPosition, POSITIVE_TC_IDX );
65 TEST_FUNCTION( UtcDaliScrollViewScrollToPage, POSITIVE_TC_IDX );
66 TEST_FUNCTION( UtcDaliScrollViewScrollToActor, POSITIVE_TC_IDX );
67 TEST_FUNCTION( UtcDaliScrollViewScrollToSnapPoint, POSITIVE_TC_IDX );
68 TEST_FUNCTION( UtcDaliScrollViewRulerScale, POSITIVE_TC_IDX );
69 TEST_FUNCTION( UtcDaliScrollViewTransformTo, POSITIVE_TC_IDX );
70 TEST_FUNCTION( UtcDaliScrollViewRefreshInterval, POSITIVE_TC_IDX );
71 TEST_FUNCTION( UtcDaliScrollViewWrapMode, POSITIVE_TC_IDX );
72 TEST_FUNCTION( UtcDaliScrollViewActorAutoSnap, POSITIVE_TC_IDX );
73 TEST_FUNCTION( UtcDaliScrollViewSignalsStartComplete, POSITIVE_TC_IDX );
74 TEST_FUNCTION( UtcDaliScrollViewSignalsUpdate, POSITIVE_TC_IDX );
75 TEST_FUNCTION( UtcDaliScrollViewSignalsClamped, POSITIVE_TC_IDX );
76 TEST_FUNCTION( UtcDaliScrollViewSignalsSnapStart, POSITIVE_TC_IDX );
77 TEST_FUNCTION( UtcDaliScrollViewScrollSensitive, POSITIVE_TC_IDX );
78 TEST_FUNCTION( UtcDaliScrollViewTouchesRequired, POSITIVE_TC_IDX );
79 TEST_FUNCTION( UtcDaliScrollViewAxisAutoLock, POSITIVE_TC_IDX );
80 TEST_FUNCTION( UtcDaliScrollViewAxisAutoLockGradient, POSITIVE_TC_IDX );
81 TEST_FUNCTION( UtcDaliScrollViewConstraints, POSITIVE_TC_IDX );
82 TEST_FUNCTION( UtcDaliScrollViewBind, POSITIVE_TC_IDX );
83 TEST_FUNCTION( UtcDaliScrollViewOvershoot, POSITIVE_TC_IDX );
84 TEST_FUNCTION( UtcDaliScrollViewSnapAlphaFunction, POSITIVE_TC_IDX );
85 TEST_FUNCTION( UtcDaliScrollViewSnapDuration, POSITIVE_TC_IDX );
86 TEST_FUNCTION( UtcDaliRulerEnableDisable, POSITIVE_TC_IDX );
87 TEST_FUNCTION( UtcDaliRulerDomainEnableDisable, POSITIVE_TC_IDX );
88 TEST_FUNCTION( UtcDaliRulerSnapAndClamp, POSITIVE_TC_IDX );
89 TEST_FUNCTION( UtcDaliRulerFixedRulerSpacing, POSITIVE_TC_IDX );
90 TEST_FUNCTION( UtcDaliScrollViewUIComponent, POSITIVE_TC_IDX );
91 TEST_FUNCTION( UtcDaliScrollViewSetMouseWheelScrollDistanceStep, POSITIVE_TC_IDX );
92 TEST_FUNCTION( UtcDaliScrollViewGetSet, POSITIVE_TC_IDX );
95 namespace // unnamed namespace
98 const int MILLISECONDS_PER_SECOND = 1000;
99 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
100 const int RENDER_ANIMATION_TEST_DURATION_MS = 1000; ///< 1000ms to test animation
101 const int RENDER_DELAY_SCROLL = 1000; ///< duration to wait for any scroll to complete.
103 // For Clamp Signal testing...
104 const float CLAMP_EXCESS_WIDTH = 200.0f; ///< Amount of width that can be panned outside scrollview
105 const float CLAMP_EXCESS_HEIGHT = 200.0f; ///< Amount of height that can be panned outside scrollview
106 const int CLAMP_STEP_0_CHECK_NOTCLAMPED = 0; ///< FSM: "First check that scrollview isn't clamped"
107 const int CLAMP_STEP_1_CHECK_CLAMPED_WEST = 1; ///< FSM: "Next check that scrollview clamps against left side"
108 const int CLAMP_STEP_2_CHECK_CLAMPED_SOUTH_WEST = 2; ///< FSM: "Then check that scrollview clamps against bottom-left side"
109 const int CLAMP_STEP_3_SUCCESS = 3; ///< FSM: "Finished (Success)"
110 const Vector3 CLAMP_START_SCROLL_POSITION(30.0f, 100.0f, 0.0f); ///< Scroll start position for the Clamping tests.
111 const Vector2 CLAMP_TOUCH_START( 100.0f, 100.0f ); ///< Start point to touch from for the Clamping tests.
112 const Vector2 CLAMP_TOUCH_MOVEMENT( 5.0f, -5.0f ); ///< Amount to move touch for each frame for the Clamping tests.
113 const int CLAMP_GESTURE_FRAMES = 100; ///< Number of Frames to synthesize a gesture for the Clamping tests.
114 const Vector3 TEST_ACTOR_POSITION(100.0f, 100.0f, 0.0f); ///< A Test actor position offset (arbitrary value)
115 const Vector3 TEST_CONSTRAINT_OFFSET(1.0f, 2.0f, 0.0f); ///< A Test constraint offset (arbitrary value to test effects)
116 const float TEST_RATIO_TOLERANCE = 0.05; ///< +/-5% tolerance for ratio comparisons.
118 const int MAX_FRAMES_TO_TEST_OVERSHOOT = 600; ///< 10 seconds (at 60 frames per second).
119 const Vector3 OVERSHOOT_START_SCROLL_POSITION(100.0f, 100.0f, 0.0f); ///< Scroll start position for the Overshoot tests.
120 const float TEST_DEFAULT_SNAP_OVERSHOOT_DURATION = 0.25f; ///< 0.25 seconds should be default snap overshoot duration
121 const float TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION = 0.05f; ///< a Test duration
122 const float TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION = 1.5f; ///< another Test duration
123 const float TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION = TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * 0.5f; // Same as above, but different alpha function.
124 const float TIME_TOLERANCE = 0.05f; ///< Allow testing tolerance between a 10th of second (+/- 3 frames)
126 // Create bitmap image
127 BitmapImage CreateBitmapImage()
129 BitmapImage image = BitmapImage::New(4,4,Pixel::RGBA8888);
131 PixelBuffer* pixbuf = image.GetBuffer();
133 // Using a 4x4 image gives a better blend with the GL implementation
135 for(size_t i=0; i<16; i++)
137 pixbuf[i*4+0] = 0xFF;
138 pixbuf[i*4+1] = 0xFF;
139 pixbuf[i*4+2] = 0xFF;
140 pixbuf[i*4+3] = 0xFF;
146 // Generate a PanGestureEvent to send to Core
147 Integration::PanGestureEvent GeneratePan(
148 Gesture::State state,
149 const Vector2& previousPosition,
150 const Vector2& currentPosition,
151 unsigned long timeDelta,
152 unsigned int numberOfTouches = 1)
154 Integration::PanGestureEvent pan(state);
156 pan.previousPosition = previousPosition;
157 pan.currentPosition = currentPosition;
158 pan.timeDelta = timeDelta;
159 pan.numberOfTouches = numberOfTouches;
165 * Helper to generate PanGestureEvent
167 * @param[in] application Application instance
168 * @param[in] state The Gesture State
169 * @param[in] pos The current position of touch.
171 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
175 if( (state == Gesture::Started) ||
176 (state == Gesture::Possible) )
182 application.ProcessEvent(GeneratePan(state, last, pos, RENDER_FRAME_INTERVAL));
189 * Simulate time passed by.
191 * @note this will always process at least 1 frame (1/60 sec)
193 * @param application Test application instance
194 * @param duration Time to pass in milliseconds.
195 * @return The actual time passed in milliseconds
197 int Wait(ToolkitTestApplication& application, int duration = 0)
201 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
203 application.SendNotification();
204 application.Render(RENDER_FRAME_INTERVAL);
205 time += RENDER_FRAME_INTERVAL;
213 static bool gOnScrollStartCalled; ///< Whether the OnScrollStart signal was invoked.
214 static bool gOnScrollUpdateCalled; ///< Whether the OnScrollUpdate signal was invoked.
215 static bool gOnScrollCompleteCalled; ///< Whether the OnScrollComplete signal was invoked.
216 static bool gOnScrollClampedCalled; ///< Whether the OnScrollClamped signal was invoked.
217 static bool gOnSnapStartCalled; ///< Whether the OnSnapStart signal was invoked.
218 static ClampState3 gLastClampPosition; ///< Clamping information from OnScrollClampedEvent.
219 static SnapType gLastSnapType; ///< Snaping information from SnapEvent.
220 static Vector3 gConstraintResult; ///< Result from constraint.
223 * Invoked when scrolling starts.
225 * @param[in] position The current scroll position.
227 static void OnScrollStart( const Vector3& position )
229 gOnScrollStartCalled = true;
233 * Invoked when scrolling updates (via dragging)
235 * @param[in] position The current scroll position.
237 static void OnScrollUpdate( const Vector3& position )
239 gOnScrollUpdateCalled = true;
243 * Invoked when scrolling finishes
245 * @param[in] position The current scroll position.
247 static void OnScrollComplete( const Vector3& position )
249 gOnScrollCompleteCalled = true;
253 * Invoked when scrolling clamped.
255 * @param[in] event The position/scale/rotation axes that were clamped.
257 static void OnScrollClamped( const ScrollView::ClampEvent& event )
259 gOnScrollClampedCalled = true;
260 gLastClampPosition = event.position;
264 * Invoked when a snap or flick started.
266 * @param[in] event The type of snap and the target position/scale/rotation.
268 static void OnSnapStart( const ScrollView::SnapEvent& event )
270 gOnSnapStartCalled = true;
271 gLastSnapType = event.type;
277 * Summation of current value, property, and offset.
279 * current' = current + mOffset + property;
281 struct TestSumConstraint
284 * @param[in] offset The offset to be added to current.
286 TestSumConstraint(const Vector3& offset)
292 * @param[in] current The current base value
293 * @param[in] property The property to be added to current.
294 * @return The new current Vector.
296 Vector3 operator()(const Vector3& current)
298 gConstraintResult = current + mOffset;
299 return gConstraintResult;
303 * @param[in] current The current base value
304 * @param[in] property The property to be added to current.
305 * @return The new current Vector.
307 Vector3 operator()(const Vector3& current,
308 const PropertyInput& property)
310 gConstraintResult = current + property.GetVector3() + mOffset;
311 return gConstraintResult;
319 * @param[in] application The application instance
320 * @param[in] scrollView The scrollView instance
321 * @return The time taken for the overshoot to reach origin (zero)
323 static float TestOvershootSnapDuration(ToolkitTestApplication &application, ScrollView scrollView)
325 Property::Index overshootPropertyX = scrollView.GetPropertyIndex(ScrollView::SCROLL_OVERSHOOT_X_PROPERTY_NAME);
326 Property::Index overshootPropertyY = scrollView.GetPropertyIndex(ScrollView::SCROLL_OVERSHOOT_Y_PROPERTY_NAME);
328 int timeToReachOrigin = -1;
329 for(int i = 0;i<MAX_FRAMES_TO_TEST_OVERSHOOT;i++)
331 float overshootXValue = scrollView.GetProperty<float>(overshootPropertyX);
332 float overshootYValue = scrollView.GetProperty<float>(overshootPropertyY);
333 if(overshootXValue == 0.0f && overshootYValue == 0.0f)
338 timeToReachOrigin += Wait(application);
341 return static_cast<float>(timeToReachOrigin) * 0.001f; // return in seconds not ms.
345 * y = 2x alpha function, which is clamped between 0.0f - 1.0f
347 * Animations should appear to finish (reach 100% point)
348 * at just half the time of a regular Linear AlphaFunction.
350 * @param[in] progress value (ranges from 0.0f - 1.0f)
351 * @return interpolation value (ranges from 0.0f - 1.0f)
353 float TestAlphaFunction(float progress)
355 return std::min( progress * 2.0f, 1.0f );
358 } // unnamed namespace
360 // Called only once before first test is run.
361 static void Startup()
365 // Called only once after last test is run
366 static void Cleanup()
370 static void UtcDaliScrollViewNew()
372 ToolkitTestApplication application;
373 tet_infoline(" UtcDaliScrollViewNew");
375 ScrollView scrollView;
377 DALI_TEST_CHECK( !scrollView );
379 scrollView = ScrollView::New();
381 DALI_TEST_CHECK( scrollView );
383 ScrollView scrollView2(scrollView);
385 DALI_TEST_CHECK( scrollView2 == scrollView );
387 //Additional check to ensure object is created by checking if it's registered
388 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
389 DALI_TEST_CHECK( registry );
391 gObjectCreatedCallBackCalled = false;
392 registry.ObjectCreatedSignal().Connect( &TestCallback );
394 ScrollView scrollView = ScrollView::New();
396 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
399 static void UtcDaliScrollViewDownCast()
401 ToolkitTestApplication application;
402 tet_infoline(" UtcDaliScrollViewDownCast");
404 ScrollView scrollView = ScrollView::New();
405 BaseHandle handle(scrollView);
407 ScrollView newScrollView = ScrollView::DownCast( handle );
408 DALI_TEST_CHECK( scrollView );
409 DALI_TEST_CHECK( newScrollView == scrollView );
412 static void UtcDaliScrollViewScrollToPosition()
414 ToolkitTestApplication application;
415 tet_infoline(" UtcDaliScrollViewScrollToPosition");
417 // Create the ScrollView actor
418 ScrollView scrollView = ScrollView::New();
419 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
420 scrollView.SetRefreshInterval(0);
421 Stage::GetCurrent().Add( scrollView );
423 const Vector3 target = Vector3(100.0f, 200.0f, 0.0f);
424 const Vector3 target2 = Vector3(300.0f, 100.0f, 0.0f);
426 scrollView.ScrollTo( target, 0.0f );
428 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
429 scrollView.ScrollTo( target2 );
430 Wait(application, RENDER_DELAY_SCROLL);
431 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
436 static void UtcDaliScrollViewScrollToPage()
438 ToolkitTestApplication application;
439 tet_infoline(" UtcDaliScrollViewScrollToPage");
441 ScrollView scrollView = ScrollView::New();
442 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
443 scrollView.SetRefreshInterval(0);
444 Stage::GetCurrent().Add( scrollView );
445 RulerPtr rulerX = new FixedRuler( 100.0f );
446 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
447 RulerPtr rulerY = new FixedRuler( 100.0f );
448 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
450 scrollView.SetRulerX( rulerX );
451 scrollView.SetRulerY( rulerY );
453 scrollView.ScrollTo( 1, 0.0f );
455 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(100.0f, 0.0f, 0.0f), TEST_LOCATION );
457 scrollView.ScrollTo( 5, 0.0f );
459 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(500.0f, 0.0f, 0.0f), TEST_LOCATION );
461 scrollView.ScrollTo( 10, 0.0f );
463 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(200.0f, 100.0f, 0.0f), TEST_LOCATION );
465 scrollView.ScrollTo( 15, 0.0f );
467 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(700.0f, 100.0f, 0.0f), TEST_LOCATION );
468 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION );
470 scrollView.ScrollTo( 3 );
471 Wait(application, RENDER_DELAY_SCROLL);
472 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(300.0f, 0.0f, 0.0f), TEST_LOCATION );
473 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION );
475 scrollView.ScrollTo( 9 );
476 Wait(application, RENDER_DELAY_SCROLL);
477 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(100.0f, 100.0f, 0.0f), TEST_LOCATION );
478 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION );
480 // Apply DefaultRulers instead and see what happens.
481 rulerX = new DefaultRuler();
482 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
483 rulerY = new DefaultRuler();
484 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
486 scrollView.SetRulerX( rulerX );
487 scrollView.SetRulerY( rulerY );
489 // This time should always scroll to origin (0.0f, 0.0f)
490 scrollView.ScrollTo( 1, 0.0f );
492 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
493 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
498 static void UtcDaliScrollViewScrollToActor()
500 ToolkitTestApplication application;
501 tet_infoline(" UtcDaliScrollViewScrollToActor");
503 ScrollView scrollView = ScrollView::New();
504 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
505 scrollView.SetRefreshInterval(0);
506 Stage::GetCurrent().Add( scrollView );
508 Actor actorA = Actor::New();
509 const Vector3 positionA = Vector3(100.0f, 400.0f, 0.0f);
510 actorA.SetPosition(positionA);
511 scrollView.Add(actorA);
513 Actor actorB = Actor::New();
514 const Vector3 positionB = Vector3(500.0f, 200.0f, 0.0f);
515 actorB.SetPosition(positionB);
516 scrollView.Add(actorB);
520 scrollView.ScrollTo(actorA, 0.0f);
522 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA, TEST_LOCATION );
525 scrollView.ScrollTo(actorB, 0.0f);
527 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB, TEST_LOCATION );
529 scrollView.ScrollTo(actorA);
530 Wait(application, RENDER_DELAY_SCROLL);
531 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA, TEST_LOCATION );
533 scrollView.ScrollTo(actorB);
534 Wait(application, RENDER_DELAY_SCROLL);
535 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB, TEST_LOCATION );
538 static void UtcDaliScrollViewScrollToSnapPoint()
540 ToolkitTestApplication application;
541 tet_infoline(" UtcDaliScrollViewScrollToSnapPoint");
543 ScrollView scrollView = ScrollView::New();
544 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
545 scrollView.SetRefreshInterval(0);
546 Stage::GetCurrent().Add( scrollView );
547 RulerPtr rulerX = new FixedRuler( 100.0f );
548 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
549 RulerPtr rulerY = new FixedRuler( 100.0f );
550 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
552 scrollView.SetRulerX( rulerX );
553 scrollView.SetRulerY( rulerY );
555 scrollView.ScrollTo( Vector3(120.0f, 190.0f, 0.0f), 0.0f );
557 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(120.0f, 190.0f, 0.0f), TEST_LOCATION );
559 scrollView.ScrollToSnapPoint();
561 Wait(application, RENDER_DELAY_SCROLL);
562 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(100.0f, 200.0f, 0.0f), TEST_LOCATION );
565 static void UtcDaliScrollViewRulerScale()
567 ToolkitTestApplication application;
568 tet_infoline(" UtcDaliScrollViewRulerScale");
570 ScrollView scrollView = ScrollView::New();
571 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
572 scrollView.SetRefreshInterval(0);
573 Stage::GetCurrent().Add( scrollView );
575 RulerPtr rulerScaleX = new FixedRuler(0.25f);
576 RulerPtr rulerScaleY = new DefaultRuler();
577 rulerScaleX->SetDomain( RulerDomain(0.1f, 0.9f, true) );
578 rulerScaleY->SetDomain( RulerDomain(0.1f, 2.0f, true) );
579 scrollView.SetRulerScaleX(rulerScaleX);
580 scrollView.SetRulerScaleY(rulerScaleY);
582 scrollView.Add(Actor::New());
584 // Scroll to a position, and then snap.
585 scrollView.ScaleTo(Vector3(1.95f, 1.4f, 1.0f), 0.0f);
586 scrollView.ScrollToSnapPoint();
587 Wait(application, RENDER_DELAY_SCROLL);
588 DALI_TEST_EQUALS( scrollView.GetCurrentScrollScale(), Vector3(0.9f, 1.4f, 1.0f), TEST_LOCATION );
590 // Scroll SLOWLY to another position, and then snap.
591 scrollView.ScaleTo(Vector3(0.45f, -1.0f, 1.0f));
592 Wait(application, RENDER_DELAY_SCROLL);
593 scrollView.ScrollToSnapPoint();
594 Wait(application, RENDER_DELAY_SCROLL);
595 DALI_TEST_EQUALS( scrollView.GetCurrentScrollScale(), Vector3(0.5f, 0.1f, 1.0f), TEST_LOCATION );
597 // Scroll to another position, and then snap.
598 scrollView.ScaleTo(Vector3(0.71f, 0.71f, 1.0f), 0.0f);
599 scrollView.ScrollToSnapPoint();
600 Wait(application, RENDER_DELAY_SCROLL);
601 DALI_TEST_EQUALS( scrollView.GetCurrentScrollScale(), Vector3(0.75f, 0.71f, 1.0f), TEST_LOCATION );
604 static void UtcDaliScrollViewTransformTo()
606 ToolkitTestApplication application;
607 tet_infoline(" UtcDaliScrollViewTransformTo");
609 ScrollView scrollView = ScrollView::New();
610 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
611 scrollView.SetRefreshInterval(0);
612 Stage::GetCurrent().Add( scrollView );
615 RulerPtr rulerX = new FixedRuler(50.0f);
616 RulerPtr rulerY = new FixedRuler(50.0f);
617 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
618 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
619 scrollView.SetRulerX(rulerX);
620 scrollView.SetRulerY(rulerY);
623 RulerPtr rulerScaleX = new FixedRuler(0.1f);
624 RulerPtr rulerScaleY = new FixedRuler(0.1f);
625 rulerScaleX->SetDomain( RulerDomain(0.0f, 1.0f, true) );
626 rulerScaleY->SetDomain( RulerDomain(0.0f, 1.0f, true) );
627 scrollView.SetRulerScaleX(rulerScaleX);
628 scrollView.SetRulerScaleY(rulerScaleY);
630 // transform to a random position/scale
631 Vector3 targetPosition = Vector3(100.0f, 200.0f, 0.0f);
632 Vector3 targetScale = Vector3(0.44f, 0.58f, 1.0f);
633 float targetRotation = 0.0f;
634 scrollView.TransformTo(targetPosition, targetScale, targetRotation, 0.0f);
637 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), targetPosition, TEST_LOCATION );
638 DALI_TEST_EQUALS( scrollView.GetCurrentScrollScale(), targetScale, TEST_LOCATION );
640 // transform to another random position/scale (SLOWLY)
641 targetPosition = Vector3(60.0f, 40.0f, 0.0f);
642 targetScale = Vector3(0.4f, 0.6f, 1.0f);
643 targetRotation = 0.0f;
644 scrollView.TransformTo(targetPosition, targetScale, targetRotation);
645 Wait(application, RENDER_DELAY_SCROLL);
647 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), targetPosition, TEST_LOCATION );
648 DALI_TEST_EQUALS( scrollView.GetCurrentScrollScale(), targetScale, TEST_LOCATION );
651 static void UtcDaliScrollViewRefreshInterval()
653 ToolkitTestApplication application;
654 tet_infoline(" UtcDaliScrollViewRefreshInterval");
656 ScrollView scrollView = ScrollView::New();
657 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
658 scrollView.SetRefreshInterval(0);
659 DALI_TEST_EQUALS( scrollView.GetRefreshInterval(), 0, TEST_LOCATION);
660 scrollView.SetRefreshInterval(10);
661 DALI_TEST_EQUALS( scrollView.GetRefreshInterval(), 10, TEST_LOCATION);
662 scrollView.SetRefreshInterval(1000);
663 DALI_TEST_EQUALS( scrollView.GetRefreshInterval(), 1000, TEST_LOCATION);
666 static void UtcDaliScrollViewWrapMode()
668 ToolkitTestApplication application;
669 tet_infoline(" UtcDaliScrollViewWrapMode");
671 ScrollView scrollView = ScrollView::New();
672 Stage::GetCurrent().Add( scrollView );
674 // Position rulers. 4x4 grid.
675 RulerPtr rulerX = new FixedRuler(50.0f);
676 RulerPtr rulerY = new FixedRuler(50.0f);
677 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, false) );
678 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, false) );
679 scrollView.SetRulerX(rulerX);
680 scrollView.SetRulerY(rulerY);
682 scrollView.SetWrapMode(false);
683 scrollView.ScrollTo(Vector3(225.0f, 125.0f, 0.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
685 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 17, TEST_LOCATION );
686 scrollView.SetWrapMode(true);
687 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 13, TEST_LOCATION );
690 static void UtcDaliScrollViewActorAutoSnap()
692 ToolkitTestApplication application;
693 tet_infoline(" UtcDaliScrollViewActorAutoSnap");
695 ScrollView scrollView = ScrollView::New();
696 Stage::GetCurrent().Add( scrollView );
697 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
698 scrollView.SetRefreshInterval(0);
701 RulerPtr rulerX = new DefaultRuler();
702 RulerPtr rulerY = new DefaultRuler();
703 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
704 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
705 scrollView.SetRulerX(rulerX);
706 scrollView.SetRulerY(rulerY);
708 const Vector3 aPosition = Vector3(200.0f, 50.0f, 0.0f);
709 Actor a = Actor::New();
711 a.SetPosition(aPosition);
713 const Vector3 bPosition = Vector3(600.0f, 600.0f, 0.0f);
714 Actor b = Actor::New();
716 b.SetPosition(bPosition);
718 // Goto a random position, and execute snap (should not move)
719 Vector3 targetScroll = Vector3(500.0f, 500.0f, 0.0f);
720 scrollView.ScrollTo(targetScroll, 0.0f);
722 scrollView.ScrollToSnapPoint();
723 Wait(application, RENDER_DELAY_SCROLL);
724 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), targetScroll, TEST_LOCATION );
726 // Enable ActorAutoSnap, and now try snapping.
727 scrollView.SetActorAutoSnap(true);
728 scrollView.ScrollToSnapPoint();
729 Wait(application, RENDER_DELAY_SCROLL);
730 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), bPosition, TEST_LOCATION );
732 scrollView.ScrollTo(Vector3(0.0f, 0.0f, 0.0f), 0.0f);
734 scrollView.ScrollToSnapPoint();
735 Wait(application, RENDER_DELAY_SCROLL);
736 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), aPosition, TEST_LOCATION );
739 static void UtcDaliScrollViewSignalsStartComplete()
741 ToolkitTestApplication application;
742 tet_infoline(" UtcDaliScrollViewSignalsStartComplete");
744 gOnScrollStartCalled = false;
745 gOnScrollCompleteCalled = false;
747 ScrollView scrollView = ScrollView::New();
748 Stage::GetCurrent().Add( scrollView );
749 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
750 scrollView.SetRefreshInterval(0);
753 RulerPtr rulerX = new DefaultRuler();
754 RulerPtr rulerY = new DefaultRuler();
755 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
756 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
757 scrollView.SetRulerX(rulerX);
758 scrollView.SetRulerY(rulerY);
759 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
760 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
761 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
762 scrollView.ScrollTo( 100.0f, 100.0f );
763 Wait(application, RENDER_DELAY_SCROLL);
765 DALI_TEST_CHECK(gOnScrollStartCalled);
766 DALI_TEST_CHECK(gOnScrollCompleteCalled);
769 static void UtcDaliScrollViewSignalsUpdate()
771 ToolkitTestApplication application;
772 tet_infoline(" UtcDaliScrollViewSignalsUpdate");
774 gOnScrollStartCalled = false;
775 gOnScrollUpdateCalled = false;
776 gOnScrollCompleteCalled = false;
778 ScrollView scrollView = ScrollView::New();
779 Stage::GetCurrent().Add( scrollView );
780 Vector2 stageSize = Stage::GetCurrent().GetSize();
781 scrollView.SetSize(stageSize);
782 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
783 scrollView.SetRefreshInterval(0);
784 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
785 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
788 RulerPtr rulerX = new DefaultRuler();
789 RulerPtr rulerY = new DefaultRuler();
790 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
791 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
792 scrollView.SetRulerX(rulerX);
793 scrollView.SetRulerY(rulerY);
794 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
795 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
796 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
798 ImageActor image = CreateSolidColorActor( Color::RED );
799 image.SetSize(stageSize);
800 image.SetParentOrigin(ParentOrigin::TOP_LEFT);
801 image.SetAnchorPoint(AnchorPoint::TOP_LEFT);
802 scrollView.Add(image);
806 // Do a pan starting from 100,100 and moving down diagonally.
807 Vector2 pos(100.0f, 100.0f);
808 SendPan(application, Gesture::Possible, pos);
809 SendPan(application, Gesture::Started, pos);
812 Wait(application, 100);
814 for(int i = 0;i<20;i++)
816 SendPan(application, Gesture::Continuing, pos);
822 SendPan(application, Gesture::Finished, pos);
823 Wait(application, RENDER_DELAY_SCROLL);
825 DALI_TEST_CHECK(gOnScrollStartCalled);
826 DALI_TEST_CHECK(gOnScrollUpdateCalled);
827 DALI_TEST_CHECK(gOnScrollCompleteCalled);
830 // Creates a scroll domain slightly bigger than the stage size.
831 // ScrollView is scrolled to center, slightly to the left.
832 // Then a pan gesture is carried out causing the scrollview
833 // to pan South-West direction. Resulting in ClampEvents
834 // to fire (first Western boundary, then both Western and
835 // Southern boundary).
836 static void UtcDaliScrollViewSignalsClamped()
838 ToolkitTestApplication application;
839 tet_infoline(" UtcDaliScrollViewSignalsClamped");
841 gOnScrollUpdateCalled = false;
842 gOnScrollCompleteCalled = false;
844 // Set up a scrollView...
845 ScrollView scrollView = ScrollView::New();
846 Stage::GetCurrent().Add( scrollView );
847 Vector2 stageSize = Stage::GetCurrent().GetSize();
848 scrollView.SetSize(stageSize);
849 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
850 scrollView.SetRefreshInterval(0);
851 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
852 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
855 RulerPtr rulerX = new DefaultRuler();
856 RulerPtr rulerY = new DefaultRuler();
857 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
858 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
859 scrollView.SetRulerX(rulerX);
860 scrollView.SetRulerY(rulerY);
861 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
862 scrollView.ScrollClampedSignal().Connect( &OnScrollClamped );
864 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
867 // Now do a pan starting from 100,100 and heading South-West
868 Vector2 pos(CLAMP_TOUCH_START);
869 SendPan(application, Gesture::Possible, pos);
870 SendPan(application, Gesture::Started, pos);
871 pos += CLAMP_TOUCH_MOVEMENT; // Move South-West a little
874 int step = CLAMP_STEP_0_CHECK_NOTCLAMPED;
875 // Move 500,500 pixels South-West
876 // should be initially not clamped (0)
877 // then it should clamp against West boundary (X Min) (1)
878 // then it should clamp against South-West boundary (X Min, Y Max) (2)
879 gLastClampPosition.x = Toolkit::NotClamped;
880 gLastClampPosition.y = Toolkit::NotClamped;
882 for(int i = 0;i<CLAMP_GESTURE_FRAMES;i++)
884 SendPan(application, Gesture::Continuing, pos);
885 pos += CLAMP_TOUCH_MOVEMENT; // Move South-West a little
888 if((gLastClampPosition.x == Toolkit::NotClamped) && (gLastClampPosition.y == Toolkit::NotClamped) && (step==CLAMP_STEP_0_CHECK_NOTCLAMPED))
890 step = CLAMP_STEP_1_CHECK_CLAMPED_WEST;
892 else if((gLastClampPosition.x == Toolkit::ClampedToMin) && (gLastClampPosition.y == Toolkit::NotClamped) && (step==CLAMP_STEP_1_CHECK_CLAMPED_WEST))
894 step = CLAMP_STEP_2_CHECK_CLAMPED_SOUTH_WEST;
896 else if((gLastClampPosition.x == Toolkit::ClampedToMin) && (gLastClampPosition.y == Toolkit::ClampedToMax) && (step==CLAMP_STEP_2_CHECK_CLAMPED_SOUTH_WEST))
898 step = CLAMP_STEP_3_SUCCESS;
902 SendPan(application, Gesture::Finished, pos);
905 DALI_TEST_CHECK( gOnScrollClampedCalled );
906 DALI_TEST_EQUALS( step, CLAMP_STEP_3_SUCCESS, TEST_LOCATION );
909 static Vector2 PerformGestureDiagonalSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, bool finish = true)
911 gOnScrollStartCalled = false;
912 gOnScrollUpdateCalled = false;
913 gOnScrollCompleteCalled = false;
914 gOnSnapStartCalled = false;
916 // Now do a pan starting from (start) and heading (direction)
918 SendPan(application, Gesture::Possible, pos);
919 SendPan(application, Gesture::Started, pos);
922 for(int i = 0;i<frames;i++)
924 pos += direction; // Move in this direction
925 SendPan(application, Gesture::Continuing, pos);
931 pos += direction; // Move in this direction.
932 SendPan(application, Gesture::Finished, pos);
933 Wait(application, RENDER_DELAY_SCROLL);
939 static void UtcDaliScrollViewScrollSensitive()
941 ToolkitTestApplication application;
942 tet_infoline(" UtcDaliScrollViewScrollSensitive");
944 // Set up a scrollView...
945 ScrollView scrollView = ScrollView::New();
946 Stage::GetCurrent().Add( scrollView );
947 Vector2 stageSize = Stage::GetCurrent().GetSize();
948 scrollView.SetSize(stageSize);
949 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
950 scrollView.SetRefreshInterval(0);
951 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
952 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
955 RulerPtr rulerX = new DefaultRuler();
956 RulerPtr rulerY = new DefaultRuler();
957 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
958 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
959 scrollView.SetRulerX(rulerX);
960 scrollView.SetRulerY(rulerY);
961 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
962 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
963 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
964 scrollView.SnapStartedSignal().Connect( &OnSnapStart );
966 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
969 // First try insensitive swipe.
970 scrollView.SetScrollSensitive(false);
971 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, true);
973 DALI_TEST_CHECK( !gOnScrollStartCalled );
974 DALI_TEST_CHECK( !gOnScrollUpdateCalled );
975 DALI_TEST_CHECK( !gOnScrollCompleteCalled );
976 DALI_TEST_CHECK( !gOnSnapStartCalled );
978 // Second try sensitive swipe.
979 scrollView.SetScrollSensitive(true);
980 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, true);
982 DALI_TEST_CHECK( gOnScrollStartCalled );
983 DALI_TEST_CHECK( gOnScrollUpdateCalled );
984 DALI_TEST_CHECK( gOnScrollCompleteCalled );
985 DALI_TEST_CHECK( gOnSnapStartCalled );
988 static void UtcDaliScrollViewTouchesRequired()
990 ToolkitTestApplication application;
991 tet_infoline(" UtcDaliScrollViewTouchesRequired");
993 // Set up a scrollView...
994 ScrollView scrollView = ScrollView::New();
995 Stage::GetCurrent().Add( scrollView );
996 Vector2 stageSize = Stage::GetCurrent().GetSize();
997 scrollView.SetSize(stageSize);
998 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
999 scrollView.SetRefreshInterval(0);
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);
1010 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1011 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1012 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1013 scrollView.SnapStartedSignal().Connect( &OnSnapStart );
1015 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1018 // First try touches required being a minimum and maximum of 2.
1019 scrollView.SetTouchesRequiredForPanning(2, 2, true);
1020 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, true);
1022 DALI_TEST_CHECK( !gOnScrollStartCalled );
1023 DALI_TEST_CHECK( !gOnScrollUpdateCalled );
1024 DALI_TEST_CHECK( !gOnScrollCompleteCalled );
1025 DALI_TEST_CHECK( !gOnSnapStartCalled );
1027 // Second try touches required being a minimum and maximum of 1.
1028 scrollView.SetTouchesRequiredForPanning(1, 1, true);
1029 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, true);
1031 DALI_TEST_CHECK( gOnScrollStartCalled );
1032 DALI_TEST_CHECK( gOnScrollUpdateCalled );
1033 DALI_TEST_CHECK( gOnScrollCompleteCalled );
1034 DALI_TEST_CHECK( gOnSnapStartCalled );
1037 static void UtcDaliScrollViewAxisAutoLock()
1039 ToolkitTestApplication application;
1040 tet_infoline(" UtcDaliScrollViewAxisAutoLock");
1042 // Set up a scrollView...
1043 ScrollView scrollView = ScrollView::New();
1044 Stage::GetCurrent().Add( scrollView );
1045 Vector2 stageSize = Stage::GetCurrent().GetSize();
1046 scrollView.SetSize(stageSize);
1047 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
1048 scrollView.SetRefreshInterval(0);
1049 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1050 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1053 RulerPtr rulerX = new DefaultRuler();
1054 RulerPtr rulerY = new DefaultRuler();
1055 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1056 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1057 scrollView.SetRulerX(rulerX);
1058 scrollView.SetRulerY(rulerY);
1059 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1060 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1061 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1064 scrollView.ScrollTo(Vector3(100.0f, 100.0f, 0.0f), 0.0f); // move in a little.
1066 Vector3 startPosition = scrollView.GetCurrentScrollPosition();
1067 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(5.0f, 1.0f), 50, true); // mostly horizontal
1068 const Vector3 positionAfterNormal = scrollView.GetCurrentScrollPosition();
1071 scrollView.SetAxisAutoLock(true);
1072 DALI_TEST_CHECK(scrollView.GetAxisAutoLock());
1074 scrollView.ScrollTo(Vector3(100.0f, 100.0f, 0.0f), 0.0f); // move in a little.
1076 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(5.0f, 1.0f), 50, true); // mostly horizontal
1077 const Vector3 positionAfterAutoLock = scrollView.GetCurrentScrollPosition();
1079 // compare how much the Y position has deviated for normal and autolock.
1080 const float devianceNormal = fabsf(startPosition.y - positionAfterNormal.y);
1081 const float devianceAutoLock = fabsf(startPosition.y - positionAfterAutoLock.y);
1083 // in auto-lock it should be a mostly horizontal pan (thus deviance should be much lower)
1084 DALI_TEST_CHECK(devianceAutoLock < devianceNormal);
1086 scrollView.SetAxisAutoLock(false);
1087 DALI_TEST_CHECK(!scrollView.GetAxisAutoLock());
1090 static void UtcDaliScrollViewAxisAutoLockGradient()
1092 ToolkitTestApplication application;
1093 tet_infoline(" UtcDaliScrollViewAxisAutoLockGradient");
1095 // Set up a scrollView...
1096 ScrollView scrollView = ScrollView::New();
1097 scrollView.SetAxisAutoLockGradient(0.5f);
1098 DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 0.5f, TEST_LOCATION);
1099 scrollView.SetAxisAutoLockGradient(1.0f);
1100 DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 1.0f, TEST_LOCATION);
1103 static void UtcDaliScrollViewConstraints()
1105 ToolkitTestApplication application;
1106 tet_infoline(" UtcDaliScrollViewConstraints");
1108 // Set up a scrollView...
1109 ScrollView scrollView = ScrollView::New();
1110 Stage::GetCurrent().Add( scrollView );
1111 Vector2 stageSize = Stage::GetCurrent().GetSize();
1112 scrollView.SetSize(stageSize);
1113 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
1114 scrollView.SetRefreshInterval(0);
1115 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1116 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1119 RulerPtr rulerX = new DefaultRuler();
1120 RulerPtr rulerY = new DefaultRuler();
1121 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1122 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1123 scrollView.SetRulerX(rulerX);
1124 scrollView.SetRulerY(rulerY);
1126 // Add an Actor to ScrollView,
1127 // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1128 gConstraintResult = Vector3::ZERO;
1129 Actor a = Actor::New();
1131 a.SetPosition( TEST_ACTOR_POSITION );
1134 Property::Index scrollPositionProperty = scrollView.GetPropertyIndex(ScrollView::SCROLL_POSITION_PROPERTY_NAME);
1135 Constraint constraint = Constraint::New<Vector3>( Actor::POSITION,
1136 Source(scrollView, scrollPositionProperty),
1137 TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1138 constraint.SetRemoveAction(Constraint::Discard);
1139 scrollView.ApplyConstraintToChildren(constraint);
1142 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1144 gConstraintResult = Vector3::ZERO;
1145 scrollView.RemoveConstraintsFromChildren();
1148 DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
1151 static void UtcDaliScrollViewBind()
1153 ToolkitTestApplication application;
1154 tet_infoline(" UtcDaliScrollViewBind");
1156 // Set up a scrollView...
1157 ScrollView scrollView = ScrollView::New();
1158 Stage::GetCurrent().Add( scrollView );
1159 Vector2 stageSize = Stage::GetCurrent().GetSize();
1160 scrollView.SetSize(stageSize);
1161 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
1162 scrollView.SetRefreshInterval(0);
1163 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1164 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1167 RulerPtr rulerX = new DefaultRuler();
1168 RulerPtr rulerY = new DefaultRuler();
1169 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1170 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1171 scrollView.SetRulerX(rulerX);
1172 scrollView.SetRulerY(rulerY);
1174 // Add an Actor to ScrollView,
1175 // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1177 gConstraintResult = Vector3::ZERO;
1178 Actor a = Actor::New();
1180 a.SetPosition( TEST_ACTOR_POSITION );
1183 Property::Index scrollPositionProperty = scrollView.GetPropertyIndex(ScrollView::SCROLL_POSITION_PROPERTY_NAME);
1184 // apply this constraint to scrollview
1185 Constraint constraint = Constraint::New<Vector3>( Actor::POSITION,
1186 Source(scrollView, scrollPositionProperty),
1187 TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1189 constraint.SetRemoveAction(Constraint::Discard);
1190 scrollView.ApplyConstraintToChildren(constraint);
1194 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1197 gConstraintResult = Vector3::ZERO;
1198 scrollView.UnbindActor( a );
1200 DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
1203 gConstraintResult = Vector3::ZERO;
1204 scrollView.BindActor( a );
1206 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1209 static void UtcDaliRulerEnableDisable()
1211 ToolkitTestApplication application;
1212 tet_infoline(" UtcDaliRulerEnableDisable");
1214 RulerPtr ruler = new DefaultRuler();
1216 DALI_TEST_CHECK( ruler->IsEnabled() );
1218 DALI_TEST_CHECK( !ruler->IsEnabled() );
1220 DALI_TEST_CHECK( ruler->IsEnabled() );
1223 static void UtcDaliRulerDomainEnableDisable()
1225 ToolkitTestApplication application;
1226 tet_infoline(" UtcDaliRulerDomainEnableDisable");
1228 RulerPtr ruler = new DefaultRuler();
1229 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
1232 ruler->SetDomain( RulerDomain(0.0f, 100.0f, true) );
1233 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 100.0f, TEST_LOCATION );
1234 DALI_TEST_EQUALS( ruler->Clamp(-200.0f), 0.0f, TEST_LOCATION );
1235 DALI_TEST_EQUALS( ruler->Clamp(200.0f), 100.0f, TEST_LOCATION );
1237 ruler->DisableDomain();
1238 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
1239 DALI_TEST_EQUALS( ruler->Clamp(-200.0f), -200.0f, TEST_LOCATION );
1240 DALI_TEST_EQUALS( ruler->Clamp(200.0f), 200.0f, TEST_LOCATION );
1243 static void UtcDaliRulerSnapAndClamp()
1245 ToolkitTestApplication application;
1246 tet_infoline(" UtcDaliRulerSnapAndClamp");
1248 RulerPtr ruler = new FixedRuler( 50.0f );
1249 ruler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1251 // default testing. (snap and clamp)
1252 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f), 50.0f, TEST_LOCATION);
1253 DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f), 50.0f, TEST_LOCATION);
1254 DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f), 0.0f, TEST_LOCATION);
1255 DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f), 0.0f, TEST_LOCATION);
1256 DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f), 400.0f, TEST_LOCATION);
1257 DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f), 400.0f, TEST_LOCATION);
1260 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
1261 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.5f), 50.0f, TEST_LOCATION); // No Flick
1262 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
1264 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
1265 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.5f), 0.0f, TEST_LOCATION); // No Flick
1266 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
1269 DALI_TEST_EQUALS( ruler->SnapAndClamp(-10.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (over left boundary)
1270 DALI_TEST_EQUALS( ruler->SnapAndClamp(-5.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (slightly ovr left boundary)
1271 DALI_TEST_EQUALS( ruler->SnapAndClamp(300.0f, 0.5f, 10.0f), 300.0f, TEST_LOCATION); // 10 units long (not over a boundary)
1272 DALI_TEST_EQUALS( ruler->SnapAndClamp(395.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (slightly over right boundary)
1273 DALI_TEST_EQUALS( ruler->SnapAndClamp(500.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (over right boundary)
1276 DALI_TEST_EQUALS( ruler->SnapAndClamp(-100.0f, 0.5f, 0.0f, 2.0f), 0.0f, TEST_LOCATION);
1277 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 2.0f), 50.0f, TEST_LOCATION);
1278 DALI_TEST_EQUALS( ruler->SnapAndClamp(700.0f, 0.5f, 0.0f, 2.0f), 700.0f, TEST_LOCATION);
1279 DALI_TEST_EQUALS( ruler->SnapAndClamp(850.0f, 0.5f, 0.0f, 2.0f), 800.0f, TEST_LOCATION);
1281 // clamp state testing.
1283 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
1284 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
1285 DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
1286 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
1287 DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
1288 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
1289 DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
1290 DALI_TEST_EQUALS( clamped, ClampedToMin, TEST_LOCATION );
1291 DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
1292 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
1293 DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
1294 DALI_TEST_EQUALS( clamped, ClampedToMax, TEST_LOCATION );
1297 static void UtcDaliRulerFixedRulerSpacing()
1299 ToolkitTestApplication application;
1300 tet_infoline(" UtcDaliRulerFixedRulerSpacing");
1302 RulerPtr rulerZero = new FixedRuler( 0.0f );
1303 rulerZero->SetDomain( RulerDomain(10.0f, 90.0f, true) );
1305 RulerPtr rulerNormal = new FixedRuler( 25.0f );
1306 rulerNormal->SetDomain( RulerDomain(10.0f, 90.0f, true) );
1308 unsigned int volume;
1311 position = rulerZero->GetPositionFromPage(1, volume, true);
1312 DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
1313 DALI_TEST_EQUALS( volume, 1u, TEST_LOCATION );
1315 position = rulerNormal->GetPositionFromPage(1, volume, true);
1316 DALI_TEST_EQUALS( position, 35.0f, TEST_LOCATION );
1317 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
1319 position = rulerZero->GetPositionFromPage(2, volume, true);
1320 DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
1321 DALI_TEST_EQUALS( volume, 2u, TEST_LOCATION );
1323 position = rulerNormal->GetPositionFromPage(2, volume, true);
1324 DALI_TEST_EQUALS( position, 60.0f, TEST_LOCATION );
1325 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
1328 static void UtcDaliScrollViewOvershoot()
1330 ToolkitTestApplication application;
1331 tet_infoline(" UtcDaliScrollViewOvershoot");
1333 // Set up a scrollView...
1334 ScrollView scrollView = ScrollView::New();
1335 Stage::GetCurrent().Add( scrollView );
1336 Vector2 stageSize = Stage::GetCurrent().GetSize();
1337 scrollView.SetSize(stageSize);
1338 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
1339 scrollView.SetRefreshInterval(0);
1340 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1341 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1344 RulerPtr rulerX = new DefaultRuler();
1345 RulerPtr rulerY = new DefaultRuler();
1346 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1347 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1348 scrollView.SetRulerX(rulerX);
1349 scrollView.SetRulerY(rulerY);
1350 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1351 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1352 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1354 scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1357 // 1. Scroll page in NW (-500,-500 pixels), then inspect overshoot. (don't release touch)
1358 Vector2 currentPos = Vector2(100.0f, 100.0f);
1359 currentPos = PerformGestureDiagonalSwipe(application, currentPos, Vector2(5.0f, 5.0f), 100, false);
1360 Property::Index overshootXProperty = scrollView.GetPropertyIndex(ScrollView::SCROLL_OVERSHOOT_X_PROPERTY_NAME);
1361 Property::Index overshootYProperty = scrollView.GetPropertyIndex(ScrollView::SCROLL_OVERSHOOT_Y_PROPERTY_NAME);
1362 Property::Index scrollPositionProperty = scrollView.GetPropertyIndex(ScrollView::SCROLL_POSITION_PROPERTY_NAME);
1363 float overshootXValue = scrollView.GetProperty<float>(overshootXProperty);
1364 float overshootYValue = scrollView.GetProperty<float>(overshootYProperty);
1365 Vector3 positionValue = scrollView.GetProperty<Vector3>(scrollPositionProperty);
1366 DALI_TEST_EQUALS(overshootXValue, -1.0f, TEST_LOCATION);
1367 DALI_TEST_EQUALS(overshootYValue, -1.0f, TEST_LOCATION);
1368 DALI_TEST_EQUALS(positionValue, Vector3::ZERO, TEST_LOCATION);
1370 float timeToReachOrigin;
1372 // Now release touch. Overshoot should snap back to zero.
1373 SendPan(application, Gesture::Finished, currentPos);
1374 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1376 DALI_TEST_CHECK( (timeToReachOrigin > TEST_DEFAULT_SNAP_OVERSHOOT_DURATION - TIME_TOLERANCE) &&
1377 (timeToReachOrigin < TEST_DEFAULT_SNAP_OVERSHOOT_DURATION + TIME_TOLERANCE) );
1379 // 2. Repeat Scroll, but this time change overshoot snap duration to shorter time
1380 scrollView.SetSnapOvershootDuration(TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION);
1382 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1383 // Now release touch. Overshoot should snap back to zero.
1384 SendPan(application, Gesture::Finished, currentPos);
1385 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1387 DALI_TEST_CHECK( (timeToReachOrigin > TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION - TIME_TOLERANCE) &&
1388 (timeToReachOrigin < TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION + TIME_TOLERANCE) );
1390 // 3. Repeat Scroll, but this time change overshoot snap duration to longer time.
1391 scrollView.SetSnapOvershootDuration(TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION);
1393 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1394 // Now release touch. Overshoot should snap back to zero.
1395 SendPan(application, Gesture::Finished, currentPos);
1396 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1398 DALI_TEST_CHECK( (timeToReachOrigin > TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION - TIME_TOLERANCE) &&
1399 (timeToReachOrigin < TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION + TIME_TOLERANCE) );
1401 // 4. Repeat Scroll, but this time change overshoot function.
1402 scrollView.SetSnapOvershootAlphaFunction(TestAlphaFunction);
1404 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1405 // Now release touch. Overshoot should snap back to zero.
1406 SendPan(application, Gesture::Finished, currentPos);
1407 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1409 DALI_TEST_CHECK( (timeToReachOrigin > TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION - TIME_TOLERANCE) &&
1410 (timeToReachOrigin < TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION + TIME_TOLERANCE) );
1413 static void UtcDaliScrollViewSnapAlphaFunction()
1415 ToolkitTestApplication application;
1416 tet_infoline(" UtcDaliScrollViewSnapAlphaFunction");
1418 // Set up a scrollView...
1419 ScrollView scrollView = ScrollView::New();
1420 scrollView.SetScrollSnapAlphaFunction( AlphaFunctions::EaseIn );
1421 DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction() == AlphaFunctions::EaseIn );
1422 scrollView.SetScrollSnapAlphaFunction( AlphaFunctions::EaseOut );
1423 DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction() == AlphaFunctions::EaseOut );
1425 scrollView.SetScrollFlickAlphaFunction( AlphaFunctions::Bounce );
1426 DALI_TEST_CHECK( scrollView.GetScrollFlickAlphaFunction() == AlphaFunctions::Bounce );
1427 scrollView.SetScrollFlickAlphaFunction( AlphaFunctions::BounceBack );
1428 DALI_TEST_CHECK( scrollView.GetScrollFlickAlphaFunction() == AlphaFunctions::BounceBack );
1431 static void UtcDaliScrollViewSnapDuration()
1433 ToolkitTestApplication application;
1434 tet_infoline(" UtcDaliScrollViewSnapDuration");
1436 // Set up a scrollView...
1437 ScrollView scrollView = ScrollView::New();
1438 scrollView.SetScrollSnapDuration( 1.0f );
1439 DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 1.0f, TEST_LOCATION );
1440 scrollView.SetScrollSnapDuration( 0.5f );
1441 DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 0.5f, TEST_LOCATION );
1443 scrollView.SetScrollFlickDuration( 2.0f );
1444 DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 2.0f, TEST_LOCATION );
1445 scrollView.SetScrollFlickDuration( 1.5f );
1446 DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 1.5f, TEST_LOCATION );
1449 static void UtcDaliScrollViewSignalsSnapStart()
1451 ToolkitTestApplication application;
1452 tet_infoline(" UtcDaliScrollViewSignalsSnapStart");
1454 // Set up a scrollView...
1455 ScrollView scrollView = ScrollView::New();
1456 Stage::GetCurrent().Add( scrollView );
1457 Vector2 stageSize = Stage::GetCurrent().GetSize();
1458 scrollView.SetSize(stageSize);
1459 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
1460 scrollView.SetRefreshInterval(0);
1461 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1462 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1465 RulerPtr rulerX = new DefaultRuler();
1466 RulerPtr rulerY = new DefaultRuler();
1467 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1468 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1469 scrollView.SetRulerX(rulerX);
1470 scrollView.SetRulerY(rulerY);
1471 scrollView.SnapStartedSignal().Connect( &OnSnapStart );
1473 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1476 DALI_TEST_CHECK( !gOnSnapStartCalled );
1478 // First try a snap.
1479 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(0.5f, 0.0f), 60, true);
1481 DALI_TEST_CHECK( gOnSnapStartCalled );
1482 DALI_TEST_CHECK( gLastSnapType == Toolkit::Snap );
1484 // Second try a swipe.
1485 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(20.0f, 0.0f), 60, true);
1487 DALI_TEST_CHECK( gOnSnapStartCalled );
1488 DALI_TEST_CHECK( gLastSnapType == Toolkit::Flick );
1491 static void UtcDaliScrollViewUIComponent()
1493 ToolkitTestApplication application;
1494 tet_infoline(" UtcDaliScrollViewUIComponent");
1496 // Set up a scrollView...
1497 ScrollView scrollView = ScrollView::New();
1498 DALI_TEST_CHECK( !scrollView.IsScrollComponentEnabled(Scrollable::HorizontalScrollBar) );
1499 DALI_TEST_CHECK( !scrollView.IsScrollComponentEnabled(Scrollable::VerticalScrollBar) );
1500 DALI_TEST_CHECK( scrollView.IsScrollComponentEnabled(Scrollable::OvershootIndicator) );
1502 scrollView.EnableScrollComponent( Scrollable::VerticalScrollBar );
1503 DALI_TEST_CHECK( !scrollView.IsScrollComponentEnabled(Scrollable::HorizontalScrollBar) );
1504 DALI_TEST_CHECK( scrollView.IsScrollComponentEnabled(Scrollable::VerticalScrollBar) );
1505 DALI_TEST_CHECK( scrollView.IsScrollComponentEnabled(Scrollable::OvershootIndicator) );
1507 scrollView.EnableScrollComponent( Scrollable::HorizontalScrollBar );
1508 DALI_TEST_CHECK( scrollView.IsScrollComponentEnabled(Scrollable::HorizontalScrollBar) );
1509 DALI_TEST_CHECK( scrollView.IsScrollComponentEnabled(Scrollable::VerticalScrollBar) );
1510 DALI_TEST_CHECK( scrollView.IsScrollComponentEnabled(Scrollable::OvershootIndicator) );
1512 scrollView.EnableScrollComponent( Scrollable::OvershootIndicator );
1513 DALI_TEST_CHECK( scrollView.IsScrollComponentEnabled(Scrollable::HorizontalScrollBar) );
1514 DALI_TEST_CHECK( scrollView.IsScrollComponentEnabled(Scrollable::VerticalScrollBar) );
1515 DALI_TEST_CHECK( scrollView.IsScrollComponentEnabled(Scrollable::OvershootIndicator) );
1517 scrollView.DisableScrollComponent( Scrollable::VerticalScrollBar );
1518 DALI_TEST_CHECK( scrollView.IsScrollComponentEnabled(Scrollable::HorizontalScrollBar) );
1519 DALI_TEST_CHECK( !scrollView.IsScrollComponentEnabled(Scrollable::VerticalScrollBar) );
1520 DALI_TEST_CHECK( scrollView.IsScrollComponentEnabled(Scrollable::OvershootIndicator) );
1522 scrollView.DisableScrollComponent( Scrollable::HorizontalScrollBar );
1523 DALI_TEST_CHECK( !scrollView.IsScrollComponentEnabled(Scrollable::HorizontalScrollBar) );
1524 DALI_TEST_CHECK( !scrollView.IsScrollComponentEnabled(Scrollable::VerticalScrollBar) );
1525 DALI_TEST_CHECK( scrollView.IsScrollComponentEnabled(Scrollable::OvershootIndicator) );
1527 scrollView.DisableScrollComponent( Scrollable::OvershootIndicator );
1528 DALI_TEST_CHECK( !scrollView.IsScrollComponentEnabled(Scrollable::HorizontalScrollBar) );
1529 DALI_TEST_CHECK( !scrollView.IsScrollComponentEnabled(Scrollable::VerticalScrollBar) );
1530 DALI_TEST_CHECK( !scrollView.IsScrollComponentEnabled(Scrollable::OvershootIndicator) );
1532 // Create scroll bar
1533 ScrollBar scrollBar = ScrollBar::New(scrollView, true);
1538 const ScrollBar scrollBarVertical = ScrollBar(scrollBar);
1539 BaseHandle handle(scrollBarVertical);
1541 ScrollBar newScrollBar = ScrollBar::DownCast( handle );
1542 DALI_TEST_CHECK( scrollBarVertical );
1543 DALI_TEST_CHECK( newScrollBar == scrollBarVertical );
1545 ScrollComponent scrollComponent = ScrollComponent(scrollBarVertical);
1546 handle = scrollComponent;
1548 ScrollComponent newScrollComponent = ScrollComponent::DownCast( handle );
1549 DALI_TEST_CHECK( scrollComponent );
1550 DALI_TEST_CHECK( scrollComponent == scrollComponent );
1553 static void UtcDaliScrollViewSetMouseWheelScrollDistanceStep()
1555 ToolkitTestApplication application;
1556 tet_infoline(" UtcDaliScrollViewSetMouseWheelScrollDistanceStep");
1558 ScrollView scrollView = ScrollView::New();
1559 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
1560 scrollView.SetMouseWheelScrollDistanceStep(Vector2(30.0f, 15.0f));
1561 DALI_TEST_EQUALS( scrollView.GetMouseWheelScrollDistanceStep(), Vector2(30.0f, 15.0f), TEST_LOCATION );
1562 scrollView.SetMouseWheelScrollDistanceStep(Vector2(60.0f, 30.0f));
1563 DALI_TEST_EQUALS( scrollView.GetMouseWheelScrollDistanceStep(), Vector2(60.0f, 30.0f), TEST_LOCATION);
1566 static void UtcDaliScrollViewGetSet()
1568 ToolkitTestApplication application;
1569 tet_infoline(" UtcDaliScrollViewGetSet");
1570 ScrollView scrollView = ScrollView::New();
1571 scrollView.SetMaxOvershoot(50.0f, 50.0f);
1572 scrollView.SetMaxFlickSpeed(0.5f);
1573 DALI_TEST_EQUALS(scrollView.GetMaxFlickSpeed(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1574 scrollView.SetFrictionCoefficient(0.6f);
1575 DALI_TEST_EQUALS(scrollView.GetFrictionCoefficient(), 0.6f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1576 scrollView.SetFlickSpeedCoefficient(0.7f);
1577 DALI_TEST_EQUALS(scrollView.GetFlickSpeedCoefficient(), 0.7f, Math::MACHINE_EPSILON_0, TEST_LOCATION);