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.
23 #include <dali/integration-api/events/touch-event-integ.h>
24 #include <dali/integration-api/events/pan-gesture-event.h>
25 #include <dali/dali.h>
26 #include <dali-toolkit/dali-toolkit.h>
28 #include <dali-toolkit-test-suite-utils.h>
31 using namespace Toolkit;
33 static void Startup();
34 static void Cleanup();
38 static bool gObjectCreatedCallBackCalled;
40 static void TestCallback(BaseHandle handle)
42 gObjectCreatedCallBackCalled = true;
47 void (*tet_startup)() = Startup;
48 void (*tet_cleanup)() = Cleanup;
53 POSITIVE_TC_IDX = 0x01,
57 // Add test functionality for all APIs in the class (Positive and Negative)
58 #define MAX_NUMBER_OF_TESTS 10000
60 struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
63 TEST_FUNCTION( UtcDaliScrollViewNew, POSITIVE_TC_IDX );
64 TEST_FUNCTION( UtcDaliScrollViewDownCast, POSITIVE_TC_IDX );
65 TEST_FUNCTION( UtcDaliScrollViewScrollToPosition, POSITIVE_TC_IDX );
66 TEST_FUNCTION( UtcDaliScrollViewScrollToPage, POSITIVE_TC_IDX );
67 TEST_FUNCTION( UtcDaliScrollViewScrollToActor, POSITIVE_TC_IDX );
68 TEST_FUNCTION( UtcDaliScrollViewScrollToSnapPoint, POSITIVE_TC_IDX );
69 TEST_FUNCTION( UtcDaliScrollViewRulerScale, POSITIVE_TC_IDX );
70 TEST_FUNCTION( UtcDaliScrollViewTransformTo, POSITIVE_TC_IDX );
71 TEST_FUNCTION( UtcDaliScrollViewRefreshInterval, POSITIVE_TC_IDX );
72 TEST_FUNCTION( UtcDaliScrollViewWrapMode, POSITIVE_TC_IDX );
73 TEST_FUNCTION( UtcDaliScrollViewActorAutoSnap, POSITIVE_TC_IDX );
74 TEST_FUNCTION( UtcDaliScrollViewSignalsStartComplete, POSITIVE_TC_IDX );
75 TEST_FUNCTION( UtcDaliScrollViewSignalsUpdate, POSITIVE_TC_IDX );
76 TEST_FUNCTION( UtcDaliScrollViewSignalsClamped, POSITIVE_TC_IDX );
77 TEST_FUNCTION( UtcDaliScrollViewSignalsSnapStart, POSITIVE_TC_IDX );
78 TEST_FUNCTION( UtcDaliScrollViewScrollSensitive, POSITIVE_TC_IDX );
79 TEST_FUNCTION( UtcDaliScrollViewTouchesRequired, POSITIVE_TC_IDX );
80 TEST_FUNCTION( UtcDaliScrollViewAxisAutoLock, POSITIVE_TC_IDX );
81 TEST_FUNCTION( UtcDaliScrollViewAxisAutoLockGradient, POSITIVE_TC_IDX );
82 TEST_FUNCTION( UtcDaliScrollViewConstraints, POSITIVE_TC_IDX );
83 TEST_FUNCTION( UtcDaliScrollViewBind, POSITIVE_TC_IDX );
84 TEST_FUNCTION( UtcDaliScrollViewOvershoot, POSITIVE_TC_IDX );
85 TEST_FUNCTION( UtcDaliScrollViewSnapAlphaFunction, POSITIVE_TC_IDX );
86 TEST_FUNCTION( UtcDaliScrollViewSnapDuration, POSITIVE_TC_IDX );
87 TEST_FUNCTION( UtcDaliRulerEnableDisable, POSITIVE_TC_IDX );
88 TEST_FUNCTION( UtcDaliRulerDomainEnableDisable, POSITIVE_TC_IDX );
89 TEST_FUNCTION( UtcDaliRulerSnapAndClamp, POSITIVE_TC_IDX );
90 TEST_FUNCTION( UtcDaliRulerFixedRulerSpacing, POSITIVE_TC_IDX );
91 TEST_FUNCTION( UtcDaliScrollViewUIComponent, POSITIVE_TC_IDX );
92 TEST_FUNCTION( UtcDaliScrollViewSetMouseWheelScrollDistanceStep, POSITIVE_TC_IDX );
93 TEST_FUNCTION( UtcDaliScrollViewGetSet, POSITIVE_TC_IDX );
96 namespace // unnamed namespace
99 const int MILLISECONDS_PER_SECOND = 1000;
100 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
101 const int RENDER_ANIMATION_TEST_DURATION_MS = 1000; ///< 1000ms to test animation
102 const int RENDER_DELAY_SCROLL = 1000; ///< duration to wait for any scroll to complete.
104 // For Clamp Signal testing...
105 const float CLAMP_EXCESS_WIDTH = 200.0f; ///< Amount of width that can be panned outside scrollview
106 const float CLAMP_EXCESS_HEIGHT = 200.0f; ///< Amount of height that can be panned outside scrollview
107 const int CLAMP_STEP_0_CHECK_NOTCLAMPED = 0; ///< FSM: "First check that scrollview isn't clamped"
108 const int CLAMP_STEP_1_CHECK_CLAMPED_WEST = 1; ///< FSM: "Next check that scrollview clamps against left side"
109 const int CLAMP_STEP_2_CHECK_CLAMPED_SOUTH_WEST = 2; ///< FSM: "Then check that scrollview clamps against bottom-left side"
110 const int CLAMP_STEP_3_SUCCESS = 3; ///< FSM: "Finished (Success)"
111 const Vector3 CLAMP_START_SCROLL_POSITION(30.0f, 100.0f, 0.0f); ///< Scroll start position for the Clamping tests.
112 const Vector2 CLAMP_TOUCH_START( 100.0f, 100.0f ); ///< Start point to touch from for the Clamping tests.
113 const Vector2 CLAMP_TOUCH_MOVEMENT( 5.0f, -5.0f ); ///< Amount to move touch for each frame for the Clamping tests.
114 const int CLAMP_GESTURE_FRAMES = 100; ///< Number of Frames to synthesize a gesture for the Clamping tests.
115 const Vector3 TEST_ACTOR_POSITION(100.0f, 100.0f, 0.0f); ///< A Test actor position offset (arbitrary value)
116 const Vector3 TEST_CONSTRAINT_OFFSET(1.0f, 2.0f, 0.0f); ///< A Test constraint offset (arbitrary value to test effects)
117 const float TEST_RATIO_TOLERANCE = 0.05; ///< +/-5% tolerance for ratio comparisons.
119 const int MAX_FRAMES_TO_TEST_OVERSHOOT = 600; ///< 10 seconds (at 60 frames per second).
120 const Vector3 OVERSHOOT_START_SCROLL_POSITION(100.0f, 100.0f, 0.0f); ///< Scroll start position for the Overshoot tests.
121 const float TEST_DEFAULT_SNAP_OVERSHOOT_DURATION = 0.25f; ///< 0.25 seconds should be default snap overshoot duration
122 const float TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION = 0.05f; ///< a Test duration
123 const float TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION = 1.5f; ///< another Test duration
124 const float TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION = TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * 0.5f; // Same as above, but different alpha function.
125 const float TIME_TOLERANCE = 0.05f; ///< Allow testing tolerance between a 10th of second (+/- 3 frames)
127 // Create bitmap image
128 BitmapImage CreateBitmapImage()
130 BitmapImage image = BitmapImage::New(4,4,Pixel::RGBA8888);
132 PixelBuffer* pixbuf = image.GetBuffer();
134 // Using a 4x4 image gives a better blend with the GL implementation
136 for(size_t i=0; i<16; i++)
138 pixbuf[i*4+0] = 0xFF;
139 pixbuf[i*4+1] = 0xFF;
140 pixbuf[i*4+2] = 0xFF;
141 pixbuf[i*4+3] = 0xFF;
147 // Generate a PanGestureEvent to send to Core
148 Integration::PanGestureEvent GeneratePan(
149 Gesture::State state,
150 const Vector2& previousPosition,
151 const Vector2& currentPosition,
152 unsigned long timeDelta,
153 unsigned int numberOfTouches = 1)
155 Integration::PanGestureEvent pan(state);
157 pan.previousPosition = previousPosition;
158 pan.currentPosition = currentPosition;
159 pan.timeDelta = timeDelta;
160 pan.numberOfTouches = numberOfTouches;
166 * Helper to generate PanGestureEvent
168 * @param[in] application Application instance
169 * @param[in] state The Gesture State
170 * @param[in] pos The current position of touch.
172 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
176 if( (state == Gesture::Started) ||
177 (state == Gesture::Possible) )
183 application.ProcessEvent(GeneratePan(state, last, pos, RENDER_FRAME_INTERVAL));
190 * Simulate time passed by.
192 * @note this will always process at least 1 frame (1/60 sec)
194 * @param application Test application instance
195 * @param duration Time to pass in milliseconds.
196 * @return The actual time passed in milliseconds
198 int Wait(ToolkitTestApplication& application, int duration = 0)
202 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
204 application.SendNotification();
205 application.Render(RENDER_FRAME_INTERVAL);
206 time += RENDER_FRAME_INTERVAL;
214 static bool gOnScrollStartCalled; ///< Whether the OnScrollStart signal was invoked.
215 static bool gOnScrollUpdateCalled; ///< Whether the OnScrollUpdate signal was invoked.
216 static bool gOnScrollCompleteCalled; ///< Whether the OnScrollComplete signal was invoked.
217 static bool gOnScrollClampedCalled; ///< Whether the OnScrollClamped signal was invoked.
218 static bool gOnSnapStartCalled; ///< Whether the OnSnapStart signal was invoked.
219 static ClampState3 gLastClampPosition; ///< Clamping information from OnScrollClampedEvent.
220 static SnapType gLastSnapType; ///< Snaping information from SnapEvent.
221 static Vector3 gConstraintResult; ///< Result from constraint.
224 * Invoked when scrolling starts.
226 * @param[in] position The current scroll position.
228 static void OnScrollStart( const Vector3& position )
230 gOnScrollStartCalled = true;
234 * Invoked when scrolling updates (via dragging)
236 * @param[in] position The current scroll position.
238 static void OnScrollUpdate( const Vector3& position )
240 gOnScrollUpdateCalled = true;
244 * Invoked when scrolling finishes
246 * @param[in] position The current scroll position.
248 static void OnScrollComplete( const Vector3& position )
250 gOnScrollCompleteCalled = true;
254 * Invoked when scrolling clamped.
256 * @param[in] event The position/scale/rotation axes that were clamped.
258 static void OnScrollClamped( const ScrollView::ClampEvent& event )
260 gOnScrollClampedCalled = true;
261 gLastClampPosition = event.position;
265 * Invoked when a snap or flick started.
267 * @param[in] event The type of snap and the target position/scale/rotation.
269 static void OnSnapStart( const ScrollView::SnapEvent& event )
271 gOnSnapStartCalled = true;
272 gLastSnapType = event.type;
278 * Summation of current value, property, and offset.
280 * current' = current + mOffset + property;
282 struct TestSumConstraint
285 * @param[in] offset The offset to be added to current.
287 TestSumConstraint(const Vector3& offset)
293 * @param[in] current The current base value
294 * @param[in] property The property to be added to current.
295 * @return The new current Vector.
297 Vector3 operator()(const Vector3& current)
299 gConstraintResult = current + mOffset;
300 return gConstraintResult;
304 * @param[in] current The current base value
305 * @param[in] property The property to be added to current.
306 * @return The new current Vector.
308 Vector3 operator()(const Vector3& current,
309 const PropertyInput& property)
311 gConstraintResult = current + property.GetVector3() + mOffset;
312 return gConstraintResult;
320 * @param[in] application The application instance
321 * @param[in] scrollView The scrollView instance
322 * @return The time taken for the overshoot to reach origin (zero)
324 static float TestOvershootSnapDuration(ToolkitTestApplication &application, ScrollView scrollView)
326 Property::Index overshootPropertyX = scrollView.GetPropertyIndex(ScrollView::SCROLL_OVERSHOOT_X_PROPERTY_NAME);
327 Property::Index overshootPropertyY = scrollView.GetPropertyIndex(ScrollView::SCROLL_OVERSHOOT_Y_PROPERTY_NAME);
329 int timeToReachOrigin = -1;
330 for(int i = 0;i<MAX_FRAMES_TO_TEST_OVERSHOOT;i++)
332 float overshootXValue = scrollView.GetProperty<float>(overshootPropertyX);
333 float overshootYValue = scrollView.GetProperty<float>(overshootPropertyY);
334 if(overshootXValue == 0.0f && overshootYValue == 0.0f)
339 timeToReachOrigin += Wait(application);
342 return static_cast<float>(timeToReachOrigin) * 0.001f; // return in seconds not ms.
346 * y = 2x alpha function, which is clamped between 0.0f - 1.0f
348 * Animations should appear to finish (reach 100% point)
349 * at just half the time of a regular Linear AlphaFunction.
351 * @param[in] progress value (ranges from 0.0f - 1.0f)
352 * @return interpolation value (ranges from 0.0f - 1.0f)
354 float TestAlphaFunction(float progress)
356 return std::min( progress * 2.0f, 1.0f );
359 } // unnamed namespace
361 // Called only once before first test is run.
362 static void Startup()
366 // Called only once after last test is run
367 static void Cleanup()
371 static void UtcDaliScrollViewNew()
373 ToolkitTestApplication application;
374 tet_infoline(" UtcDaliScrollViewNew");
376 ScrollView scrollView;
378 DALI_TEST_CHECK( !scrollView );
380 scrollView = ScrollView::New();
382 DALI_TEST_CHECK( scrollView );
384 ScrollView scrollView2(scrollView);
386 DALI_TEST_CHECK( scrollView2 == scrollView );
388 //Additional check to ensure object is created by checking if it's registered
389 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
390 DALI_TEST_CHECK( registry );
392 gObjectCreatedCallBackCalled = false;
393 registry.ObjectCreatedSignal().Connect( &TestCallback );
395 ScrollView scrollView = ScrollView::New();
397 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
400 static void UtcDaliScrollViewDownCast()
402 ToolkitTestApplication application;
403 tet_infoline(" UtcDaliScrollViewDownCast");
405 ScrollView scrollView = ScrollView::New();
406 BaseHandle handle(scrollView);
408 ScrollView newScrollView = ScrollView::DownCast( handle );
409 DALI_TEST_CHECK( scrollView );
410 DALI_TEST_CHECK( newScrollView == scrollView );
413 static void UtcDaliScrollViewScrollToPosition()
415 ToolkitTestApplication application;
416 tet_infoline(" UtcDaliScrollViewScrollToPosition");
418 // Create the ScrollView actor
419 ScrollView scrollView = ScrollView::New();
420 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
421 scrollView.SetRefreshInterval(0);
422 Stage::GetCurrent().Add( scrollView );
424 const Vector3 target = Vector3(100.0f, 200.0f, 0.0f);
425 const Vector3 target2 = Vector3(300.0f, 100.0f, 0.0f);
427 scrollView.ScrollTo( target, 0.0f );
429 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
430 scrollView.ScrollTo( target2 );
431 Wait(application, RENDER_DELAY_SCROLL);
432 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
437 static void UtcDaliScrollViewScrollToPage()
439 ToolkitTestApplication application;
440 tet_infoline(" UtcDaliScrollViewScrollToPage");
442 ScrollView scrollView = ScrollView::New();
443 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
444 scrollView.SetRefreshInterval(0);
445 Stage::GetCurrent().Add( scrollView );
446 RulerPtr rulerX = new FixedRuler( 100.0f );
447 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
448 RulerPtr rulerY = new FixedRuler( 100.0f );
449 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
451 scrollView.SetRulerX( rulerX );
452 scrollView.SetRulerY( rulerY );
454 scrollView.ScrollTo( 1, 0.0f );
456 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(100.0f, 0.0f, 0.0f), TEST_LOCATION );
458 scrollView.ScrollTo( 5, 0.0f );
460 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(500.0f, 0.0f, 0.0f), TEST_LOCATION );
462 scrollView.ScrollTo( 10, 0.0f );
464 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(200.0f, 100.0f, 0.0f), TEST_LOCATION );
466 scrollView.ScrollTo( 15, 0.0f );
468 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(700.0f, 100.0f, 0.0f), TEST_LOCATION );
469 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION );
471 scrollView.ScrollTo( 3 );
472 Wait(application, RENDER_DELAY_SCROLL);
473 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(300.0f, 0.0f, 0.0f), TEST_LOCATION );
474 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION );
476 scrollView.ScrollTo( 9 );
477 Wait(application, RENDER_DELAY_SCROLL);
478 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(100.0f, 100.0f, 0.0f), TEST_LOCATION );
479 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION );
481 // Apply DefaultRulers instead and see what happens.
482 rulerX = new DefaultRuler();
483 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
484 rulerY = new DefaultRuler();
485 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
487 scrollView.SetRulerX( rulerX );
488 scrollView.SetRulerY( rulerY );
490 // This time should always scroll to origin (0.0f, 0.0f)
491 scrollView.ScrollTo( 1, 0.0f );
493 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
494 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION );
499 static void UtcDaliScrollViewScrollToActor()
501 ToolkitTestApplication application;
502 tet_infoline(" UtcDaliScrollViewScrollToActor");
504 ScrollView scrollView = ScrollView::New();
505 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
506 scrollView.SetRefreshInterval(0);
507 Stage::GetCurrent().Add( scrollView );
509 Actor actorA = Actor::New();
510 const Vector3 positionA = Vector3(100.0f, 400.0f, 0.0f);
511 actorA.SetPosition(positionA);
512 scrollView.Add(actorA);
514 Actor actorB = Actor::New();
515 const Vector3 positionB = Vector3(500.0f, 200.0f, 0.0f);
516 actorB.SetPosition(positionB);
517 scrollView.Add(actorB);
521 scrollView.ScrollTo(actorA, 0.0f);
523 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA, TEST_LOCATION );
526 scrollView.ScrollTo(actorB, 0.0f);
528 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB, TEST_LOCATION );
530 scrollView.ScrollTo(actorA);
531 Wait(application, RENDER_DELAY_SCROLL);
532 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionA, TEST_LOCATION );
534 scrollView.ScrollTo(actorB);
535 Wait(application, RENDER_DELAY_SCROLL);
536 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), positionB, TEST_LOCATION );
539 static void UtcDaliScrollViewScrollToSnapPoint()
541 ToolkitTestApplication application;
542 tet_infoline(" UtcDaliScrollViewScrollToSnapPoint");
544 ScrollView scrollView = ScrollView::New();
545 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
546 scrollView.SetRefreshInterval(0);
547 Stage::GetCurrent().Add( scrollView );
548 RulerPtr rulerX = new FixedRuler( 100.0f );
549 rulerX->SetDomain( RulerDomain(0.0f, 800.0f, true) );
550 RulerPtr rulerY = new FixedRuler( 100.0f );
551 rulerY->SetDomain( RulerDomain(0.0f, 400.0f, true) );
553 scrollView.SetRulerX( rulerX );
554 scrollView.SetRulerY( rulerY );
556 scrollView.ScrollTo( Vector3(120.0f, 190.0f, 0.0f), 0.0f );
558 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(120.0f, 190.0f, 0.0f), TEST_LOCATION );
560 scrollView.ScrollToSnapPoint();
562 Wait(application, RENDER_DELAY_SCROLL);
563 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector3(100.0f, 200.0f, 0.0f), TEST_LOCATION );
566 static void UtcDaliScrollViewRulerScale()
568 ToolkitTestApplication application;
569 tet_infoline(" UtcDaliScrollViewRulerScale");
571 ScrollView scrollView = ScrollView::New();
572 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
573 scrollView.SetRefreshInterval(0);
574 Stage::GetCurrent().Add( scrollView );
576 RulerPtr rulerScaleX = new FixedRuler(0.25f);
577 RulerPtr rulerScaleY = new DefaultRuler();
578 rulerScaleX->SetDomain( RulerDomain(0.1f, 0.9f, true) );
579 rulerScaleY->SetDomain( RulerDomain(0.1f, 2.0f, true) );
580 scrollView.SetRulerScaleX(rulerScaleX);
581 scrollView.SetRulerScaleY(rulerScaleY);
583 scrollView.Add(Actor::New());
585 // Scroll to a position, and then snap.
586 scrollView.ScaleTo(Vector3(1.95f, 1.4f, 1.0f), 0.0f);
587 scrollView.ScrollToSnapPoint();
588 Wait(application, RENDER_DELAY_SCROLL);
589 DALI_TEST_EQUALS( scrollView.GetCurrentScrollScale(), Vector3(0.9f, 1.4f, 1.0f), TEST_LOCATION );
591 // Scroll SLOWLY to another position, and then snap.
592 scrollView.ScaleTo(Vector3(0.45f, -1.0f, 1.0f));
593 Wait(application, RENDER_DELAY_SCROLL);
594 scrollView.ScrollToSnapPoint();
595 Wait(application, RENDER_DELAY_SCROLL);
596 DALI_TEST_EQUALS( scrollView.GetCurrentScrollScale(), Vector3(0.5f, 0.1f, 1.0f), TEST_LOCATION );
598 // Scroll to another position, and then snap.
599 scrollView.ScaleTo(Vector3(0.71f, 0.71f, 1.0f), 0.0f);
600 scrollView.ScrollToSnapPoint();
601 Wait(application, RENDER_DELAY_SCROLL);
602 DALI_TEST_EQUALS( scrollView.GetCurrentScrollScale(), Vector3(0.75f, 0.71f, 1.0f), TEST_LOCATION );
605 static void UtcDaliScrollViewTransformTo()
607 ToolkitTestApplication application;
608 tet_infoline(" UtcDaliScrollViewTransformTo");
610 ScrollView scrollView = ScrollView::New();
611 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
612 scrollView.SetRefreshInterval(0);
613 Stage::GetCurrent().Add( scrollView );
616 RulerPtr rulerX = new FixedRuler(50.0f);
617 RulerPtr rulerY = new FixedRuler(50.0f);
618 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, true) );
619 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, true) );
620 scrollView.SetRulerX(rulerX);
621 scrollView.SetRulerY(rulerY);
624 RulerPtr rulerScaleX = new FixedRuler(0.1f);
625 RulerPtr rulerScaleY = new FixedRuler(0.1f);
626 rulerScaleX->SetDomain( RulerDomain(0.0f, 1.0f, true) );
627 rulerScaleY->SetDomain( RulerDomain(0.0f, 1.0f, true) );
628 scrollView.SetRulerScaleX(rulerScaleX);
629 scrollView.SetRulerScaleY(rulerScaleY);
631 // transform to a random position/scale
632 Vector3 targetPosition = Vector3(100.0f, 200.0f, 0.0f);
633 Vector3 targetScale = Vector3(0.44f, 0.58f, 1.0f);
634 float targetRotation = 0.0f;
635 scrollView.TransformTo(targetPosition, targetScale, targetRotation, 0.0f);
638 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), targetPosition, TEST_LOCATION );
639 DALI_TEST_EQUALS( scrollView.GetCurrentScrollScale(), targetScale, TEST_LOCATION );
641 // transform to another random position/scale (SLOWLY)
642 targetPosition = Vector3(60.0f, 40.0f, 0.0f);
643 targetScale = Vector3(0.4f, 0.6f, 1.0f);
644 targetRotation = 0.0f;
645 scrollView.TransformTo(targetPosition, targetScale, targetRotation);
646 Wait(application, RENDER_DELAY_SCROLL);
648 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), targetPosition, TEST_LOCATION );
649 DALI_TEST_EQUALS( scrollView.GetCurrentScrollScale(), targetScale, TEST_LOCATION );
652 static void UtcDaliScrollViewRefreshInterval()
654 ToolkitTestApplication application;
655 tet_infoline(" UtcDaliScrollViewRefreshInterval");
657 ScrollView scrollView = ScrollView::New();
658 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
659 scrollView.SetRefreshInterval(0);
660 DALI_TEST_EQUALS( scrollView.GetRefreshInterval(), 0, TEST_LOCATION);
661 scrollView.SetRefreshInterval(10);
662 DALI_TEST_EQUALS( scrollView.GetRefreshInterval(), 10, TEST_LOCATION);
663 scrollView.SetRefreshInterval(1000);
664 DALI_TEST_EQUALS( scrollView.GetRefreshInterval(), 1000, TEST_LOCATION);
667 static void UtcDaliScrollViewWrapMode()
669 ToolkitTestApplication application;
670 tet_infoline(" UtcDaliScrollViewWrapMode");
672 ScrollView scrollView = ScrollView::New();
673 Stage::GetCurrent().Add( scrollView );
675 // Position rulers. 4x4 grid.
676 RulerPtr rulerX = new FixedRuler(50.0f);
677 RulerPtr rulerY = new FixedRuler(50.0f);
678 rulerX->SetDomain( RulerDomain(0.0f, 200.0f, false) );
679 rulerY->SetDomain( RulerDomain(0.0f, 200.0f, false) );
680 scrollView.SetRulerX(rulerX);
681 scrollView.SetRulerY(rulerY);
683 scrollView.SetWrapMode(false);
684 scrollView.ScrollTo(Vector3(225.0f, 125.0f, 0.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
686 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 17, TEST_LOCATION );
687 scrollView.SetWrapMode(true);
688 DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 13, TEST_LOCATION );
691 static void UtcDaliScrollViewActorAutoSnap()
693 ToolkitTestApplication application;
694 tet_infoline(" UtcDaliScrollViewActorAutoSnap");
696 ScrollView scrollView = ScrollView::New();
697 Stage::GetCurrent().Add( scrollView );
698 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
699 scrollView.SetRefreshInterval(0);
702 RulerPtr rulerX = new DefaultRuler();
703 RulerPtr rulerY = new DefaultRuler();
704 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
705 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
706 scrollView.SetRulerX(rulerX);
707 scrollView.SetRulerY(rulerY);
709 const Vector3 aPosition = Vector3(200.0f, 50.0f, 0.0f);
710 Actor a = Actor::New();
712 a.SetPosition(aPosition);
714 const Vector3 bPosition = Vector3(600.0f, 600.0f, 0.0f);
715 Actor b = Actor::New();
717 b.SetPosition(bPosition);
719 // Goto a random position, and execute snap (should not move)
720 Vector3 targetScroll = Vector3(500.0f, 500.0f, 0.0f);
721 scrollView.ScrollTo(targetScroll, 0.0f);
723 scrollView.ScrollToSnapPoint();
724 Wait(application, RENDER_DELAY_SCROLL);
725 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), targetScroll, TEST_LOCATION );
727 // Enable ActorAutoSnap, and now try snapping.
728 scrollView.SetActorAutoSnap(true);
729 scrollView.ScrollToSnapPoint();
730 Wait(application, RENDER_DELAY_SCROLL);
731 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), bPosition, TEST_LOCATION );
733 scrollView.ScrollTo(Vector3(0.0f, 0.0f, 0.0f), 0.0f);
735 scrollView.ScrollToSnapPoint();
736 Wait(application, RENDER_DELAY_SCROLL);
737 DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), aPosition, TEST_LOCATION );
740 static void UtcDaliScrollViewSignalsStartComplete()
742 ToolkitTestApplication application;
743 tet_infoline(" UtcDaliScrollViewSignalsStartComplete");
745 gOnScrollStartCalled = false;
746 gOnScrollCompleteCalled = false;
748 ScrollView scrollView = ScrollView::New();
749 Stage::GetCurrent().Add( scrollView );
750 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
751 scrollView.SetRefreshInterval(0);
754 RulerPtr rulerX = new DefaultRuler();
755 RulerPtr rulerY = new DefaultRuler();
756 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
757 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
758 scrollView.SetRulerX(rulerX);
759 scrollView.SetRulerY(rulerY);
760 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
761 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
762 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
763 scrollView.ScrollTo( 100.0f, 100.0f );
764 Wait(application, RENDER_DELAY_SCROLL);
766 DALI_TEST_CHECK(gOnScrollStartCalled);
767 DALI_TEST_CHECK(gOnScrollCompleteCalled);
770 static void UtcDaliScrollViewSignalsUpdate()
772 ToolkitTestApplication application;
773 tet_infoline(" UtcDaliScrollViewSignalsUpdate");
775 gOnScrollStartCalled = false;
776 gOnScrollUpdateCalled = false;
777 gOnScrollCompleteCalled = false;
779 ScrollView scrollView = ScrollView::New();
780 Stage::GetCurrent().Add( scrollView );
781 Vector2 stageSize = Stage::GetCurrent().GetSize();
782 scrollView.SetSize(stageSize);
783 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
784 scrollView.SetRefreshInterval(0);
785 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
786 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
789 RulerPtr rulerX = new DefaultRuler();
790 RulerPtr rulerY = new DefaultRuler();
791 rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
792 rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) );
793 scrollView.SetRulerX(rulerX);
794 scrollView.SetRulerY(rulerY);
795 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
796 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
797 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
799 ImageActor image = CreateSolidColorActor( Color::RED );
800 image.SetSize(stageSize);
801 image.SetParentOrigin(ParentOrigin::TOP_LEFT);
802 image.SetAnchorPoint(AnchorPoint::TOP_LEFT);
803 scrollView.Add(image);
807 // Do a pan starting from 100,100 and moving down diagonally.
808 Vector2 pos(100.0f, 100.0f);
809 SendPan(application, Gesture::Possible, pos);
810 SendPan(application, Gesture::Started, pos);
813 Wait(application, 100);
815 for(int i = 0;i<20;i++)
817 SendPan(application, Gesture::Continuing, pos);
823 SendPan(application, Gesture::Finished, pos);
824 Wait(application, RENDER_DELAY_SCROLL);
826 DALI_TEST_CHECK(gOnScrollStartCalled);
827 DALI_TEST_CHECK(gOnScrollUpdateCalled);
828 DALI_TEST_CHECK(gOnScrollCompleteCalled);
831 // Creates a scroll domain slightly bigger than the stage size.
832 // ScrollView is scrolled to center, slightly to the left.
833 // Then a pan gesture is carried out causing the scrollview
834 // to pan South-West direction. Resulting in ClampEvents
835 // to fire (first Western boundary, then both Western and
836 // Southern boundary).
837 static void UtcDaliScrollViewSignalsClamped()
839 ToolkitTestApplication application;
840 tet_infoline(" UtcDaliScrollViewSignalsClamped");
842 gOnScrollUpdateCalled = false;
843 gOnScrollCompleteCalled = false;
845 // Set up a scrollView...
846 ScrollView scrollView = ScrollView::New();
847 Stage::GetCurrent().Add( scrollView );
848 Vector2 stageSize = Stage::GetCurrent().GetSize();
849 scrollView.SetSize(stageSize);
850 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
851 scrollView.SetRefreshInterval(0);
852 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
853 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
856 RulerPtr rulerX = new DefaultRuler();
857 RulerPtr rulerY = new DefaultRuler();
858 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
859 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
860 scrollView.SetRulerX(rulerX);
861 scrollView.SetRulerY(rulerY);
862 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
863 scrollView.ScrollClampedSignal().Connect( &OnScrollClamped );
865 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
868 // Now do a pan starting from 100,100 and heading South-West
869 Vector2 pos(CLAMP_TOUCH_START);
870 SendPan(application, Gesture::Possible, pos);
871 SendPan(application, Gesture::Started, pos);
872 pos += CLAMP_TOUCH_MOVEMENT; // Move South-West a little
875 int step = CLAMP_STEP_0_CHECK_NOTCLAMPED;
876 // Move 500,500 pixels South-West
877 // should be initially not clamped (0)
878 // then it should clamp against West boundary (X Min) (1)
879 // then it should clamp against South-West boundary (X Min, Y Max) (2)
880 gLastClampPosition.x = Toolkit::NotClamped;
881 gLastClampPosition.y = Toolkit::NotClamped;
883 for(int i = 0;i<CLAMP_GESTURE_FRAMES;i++)
885 SendPan(application, Gesture::Continuing, pos);
886 pos += CLAMP_TOUCH_MOVEMENT; // Move South-West a little
889 if((gLastClampPosition.x == Toolkit::NotClamped) && (gLastClampPosition.y == Toolkit::NotClamped) && (step==CLAMP_STEP_0_CHECK_NOTCLAMPED))
891 step = CLAMP_STEP_1_CHECK_CLAMPED_WEST;
893 else if((gLastClampPosition.x == Toolkit::ClampedToMin) && (gLastClampPosition.y == Toolkit::NotClamped) && (step==CLAMP_STEP_1_CHECK_CLAMPED_WEST))
895 step = CLAMP_STEP_2_CHECK_CLAMPED_SOUTH_WEST;
897 else if((gLastClampPosition.x == Toolkit::ClampedToMin) && (gLastClampPosition.y == Toolkit::ClampedToMax) && (step==CLAMP_STEP_2_CHECK_CLAMPED_SOUTH_WEST))
899 step = CLAMP_STEP_3_SUCCESS;
903 SendPan(application, Gesture::Finished, pos);
906 DALI_TEST_CHECK( gOnScrollClampedCalled );
907 DALI_TEST_EQUALS( step, CLAMP_STEP_3_SUCCESS, TEST_LOCATION );
910 static Vector2 PerformGestureDiagonalSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, bool finish = true)
912 gOnScrollStartCalled = false;
913 gOnScrollUpdateCalled = false;
914 gOnScrollCompleteCalled = false;
915 gOnSnapStartCalled = false;
917 // Now do a pan starting from (start) and heading (direction)
919 SendPan(application, Gesture::Possible, pos);
920 SendPan(application, Gesture::Started, pos);
923 for(int i = 0;i<frames;i++)
925 pos += direction; // Move in this direction
926 SendPan(application, Gesture::Continuing, pos);
932 pos += direction; // Move in this direction.
933 SendPan(application, Gesture::Finished, pos);
934 Wait(application, RENDER_DELAY_SCROLL);
940 static void UtcDaliScrollViewScrollSensitive()
942 ToolkitTestApplication application;
943 tet_infoline(" UtcDaliScrollViewScrollSensitive");
945 // Set up a scrollView...
946 ScrollView scrollView = ScrollView::New();
947 Stage::GetCurrent().Add( scrollView );
948 Vector2 stageSize = Stage::GetCurrent().GetSize();
949 scrollView.SetSize(stageSize);
950 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
951 scrollView.SetRefreshInterval(0);
952 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
953 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
956 RulerPtr rulerX = new DefaultRuler();
957 RulerPtr rulerY = new DefaultRuler();
958 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
959 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
960 scrollView.SetRulerX(rulerX);
961 scrollView.SetRulerY(rulerY);
962 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
963 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
964 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
965 scrollView.SnapStartedSignal().Connect( &OnSnapStart );
967 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
970 // First try insensitive swipe.
971 scrollView.SetScrollSensitive(false);
972 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, true);
974 DALI_TEST_CHECK( !gOnScrollStartCalled );
975 DALI_TEST_CHECK( !gOnScrollUpdateCalled );
976 DALI_TEST_CHECK( !gOnScrollCompleteCalled );
977 DALI_TEST_CHECK( !gOnSnapStartCalled );
979 // Second try sensitive swipe.
980 scrollView.SetScrollSensitive(true);
981 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, true);
983 DALI_TEST_CHECK( gOnScrollStartCalled );
984 DALI_TEST_CHECK( gOnScrollUpdateCalled );
985 DALI_TEST_CHECK( gOnScrollCompleteCalled );
986 DALI_TEST_CHECK( gOnSnapStartCalled );
989 static void UtcDaliScrollViewTouchesRequired()
991 ToolkitTestApplication application;
992 tet_infoline(" UtcDaliScrollViewTouchesRequired");
994 // Set up a scrollView...
995 ScrollView scrollView = ScrollView::New();
996 Stage::GetCurrent().Add( scrollView );
997 Vector2 stageSize = Stage::GetCurrent().GetSize();
998 scrollView.SetSize(stageSize);
999 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
1000 scrollView.SetRefreshInterval(0);
1001 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1002 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1005 RulerPtr rulerX = new DefaultRuler();
1006 RulerPtr rulerY = new DefaultRuler();
1007 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1008 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1009 scrollView.SetRulerX(rulerX);
1010 scrollView.SetRulerY(rulerY);
1011 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1012 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1013 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1014 scrollView.SnapStartedSignal().Connect( &OnSnapStart );
1016 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1019 // First try touches required being a minimum and maximum of 2.
1020 scrollView.SetTouchesRequiredForPanning(2, 2, true);
1021 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, true);
1023 DALI_TEST_CHECK( !gOnScrollStartCalled );
1024 DALI_TEST_CHECK( !gOnScrollUpdateCalled );
1025 DALI_TEST_CHECK( !gOnScrollCompleteCalled );
1026 DALI_TEST_CHECK( !gOnSnapStartCalled );
1028 // Second try touches required being a minimum and maximum of 1.
1029 scrollView.SetTouchesRequiredForPanning(1, 1, true);
1030 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, true);
1032 DALI_TEST_CHECK( gOnScrollStartCalled );
1033 DALI_TEST_CHECK( gOnScrollUpdateCalled );
1034 DALI_TEST_CHECK( gOnScrollCompleteCalled );
1035 DALI_TEST_CHECK( gOnSnapStartCalled );
1038 static void UtcDaliScrollViewAxisAutoLock()
1040 ToolkitTestApplication application;
1041 tet_infoline(" UtcDaliScrollViewAxisAutoLock");
1043 // Set up a scrollView...
1044 ScrollView scrollView = ScrollView::New();
1045 Stage::GetCurrent().Add( scrollView );
1046 Vector2 stageSize = Stage::GetCurrent().GetSize();
1047 scrollView.SetSize(stageSize);
1048 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
1049 scrollView.SetRefreshInterval(0);
1050 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1051 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1054 RulerPtr rulerX = new DefaultRuler();
1055 RulerPtr rulerY = new DefaultRuler();
1056 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1057 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1058 scrollView.SetRulerX(rulerX);
1059 scrollView.SetRulerY(rulerY);
1060 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1061 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1062 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1065 scrollView.ScrollTo(Vector3(100.0f, 100.0f, 0.0f), 0.0f); // move in a little.
1067 Vector3 startPosition = scrollView.GetCurrentScrollPosition();
1068 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(5.0f, 1.0f), 50, true); // mostly horizontal
1069 const Vector3 positionAfterNormal = scrollView.GetCurrentScrollPosition();
1072 scrollView.SetAxisAutoLock(true);
1073 DALI_TEST_CHECK(scrollView.GetAxisAutoLock());
1075 scrollView.ScrollTo(Vector3(100.0f, 100.0f, 0.0f), 0.0f); // move in a little.
1077 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(5.0f, 1.0f), 50, true); // mostly horizontal
1078 const Vector3 positionAfterAutoLock = scrollView.GetCurrentScrollPosition();
1080 // compare how much the Y position has deviated for normal and autolock.
1081 const float devianceNormal = fabsf(startPosition.y - positionAfterNormal.y);
1082 const float devianceAutoLock = fabsf(startPosition.y - positionAfterAutoLock.y);
1084 // in auto-lock it should be a mostly horizontal pan (thus deviance should be much lower)
1085 DALI_TEST_CHECK(devianceAutoLock < devianceNormal);
1087 scrollView.SetAxisAutoLock(false);
1088 DALI_TEST_CHECK(!scrollView.GetAxisAutoLock());
1091 static void UtcDaliScrollViewAxisAutoLockGradient()
1093 ToolkitTestApplication application;
1094 tet_infoline(" UtcDaliScrollViewAxisAutoLockGradient");
1096 // Set up a scrollView...
1097 ScrollView scrollView = ScrollView::New();
1098 scrollView.SetAxisAutoLockGradient(0.5f);
1099 DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 0.5f, TEST_LOCATION);
1100 scrollView.SetAxisAutoLockGradient(1.0f);
1101 DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 1.0f, TEST_LOCATION);
1104 static void UtcDaliScrollViewConstraints()
1106 ToolkitTestApplication application;
1107 tet_infoline(" UtcDaliScrollViewConstraints");
1109 // Set up a scrollView...
1110 ScrollView scrollView = ScrollView::New();
1111 Stage::GetCurrent().Add( scrollView );
1112 Vector2 stageSize = Stage::GetCurrent().GetSize();
1113 scrollView.SetSize(stageSize);
1114 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
1115 scrollView.SetRefreshInterval(0);
1116 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1117 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1120 RulerPtr rulerX = new DefaultRuler();
1121 RulerPtr rulerY = new DefaultRuler();
1122 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1123 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1124 scrollView.SetRulerX(rulerX);
1125 scrollView.SetRulerY(rulerY);
1127 // Add an Actor to ScrollView,
1128 // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1129 gConstraintResult = Vector3::ZERO;
1130 Actor a = Actor::New();
1132 a.SetPosition( TEST_ACTOR_POSITION );
1135 Property::Index scrollPositionProperty = scrollView.GetPropertyIndex(ScrollView::SCROLL_POSITION_PROPERTY_NAME);
1136 Constraint constraint = Constraint::New<Vector3>( Actor::POSITION,
1137 Source(scrollView, scrollPositionProperty),
1138 TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1139 constraint.SetRemoveAction(Constraint::Discard);
1140 scrollView.ApplyConstraintToChildren(constraint);
1143 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1145 gConstraintResult = Vector3::ZERO;
1146 scrollView.RemoveConstraintsFromChildren();
1149 DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
1152 static void UtcDaliScrollViewBind()
1154 ToolkitTestApplication application;
1155 tet_infoline(" UtcDaliScrollViewBind");
1157 // Set up a scrollView...
1158 ScrollView scrollView = ScrollView::New();
1159 Stage::GetCurrent().Add( scrollView );
1160 Vector2 stageSize = Stage::GetCurrent().GetSize();
1161 scrollView.SetSize(stageSize);
1162 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
1163 scrollView.SetRefreshInterval(0);
1164 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1165 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1168 RulerPtr rulerX = new DefaultRuler();
1169 RulerPtr rulerY = new DefaultRuler();
1170 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1171 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1172 scrollView.SetRulerX(rulerX);
1173 scrollView.SetRulerY(rulerY);
1175 // Add an Actor to ScrollView,
1176 // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1178 gConstraintResult = Vector3::ZERO;
1179 Actor a = Actor::New();
1181 a.SetPosition( TEST_ACTOR_POSITION );
1184 Property::Index scrollPositionProperty = scrollView.GetPropertyIndex(ScrollView::SCROLL_POSITION_PROPERTY_NAME);
1185 // apply this constraint to scrollview
1186 Constraint constraint = Constraint::New<Vector3>( Actor::POSITION,
1187 Source(scrollView, scrollPositionProperty),
1188 TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
1190 constraint.SetRemoveAction(Constraint::Discard);
1191 scrollView.ApplyConstraintToChildren(constraint);
1195 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1198 gConstraintResult = Vector3::ZERO;
1199 scrollView.UnbindActor( a );
1201 DALI_TEST_EQUALS( gConstraintResult, Vector3::ZERO, TEST_LOCATION );
1204 gConstraintResult = Vector3::ZERO;
1205 scrollView.BindActor( a );
1207 DALI_TEST_EQUALS( gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION );
1210 static void UtcDaliRulerEnableDisable()
1212 ToolkitTestApplication application;
1213 tet_infoline(" UtcDaliRulerEnableDisable");
1215 RulerPtr ruler = new DefaultRuler();
1217 DALI_TEST_CHECK( ruler->IsEnabled() );
1219 DALI_TEST_CHECK( !ruler->IsEnabled() );
1221 DALI_TEST_CHECK( ruler->IsEnabled() );
1224 static void UtcDaliRulerDomainEnableDisable()
1226 ToolkitTestApplication application;
1227 tet_infoline(" UtcDaliRulerDomainEnableDisable");
1229 RulerPtr ruler = new DefaultRuler();
1230 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
1233 ruler->SetDomain( RulerDomain(0.0f, 100.0f, true) );
1234 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 100.0f, TEST_LOCATION );
1235 DALI_TEST_EQUALS( ruler->Clamp(-200.0f), 0.0f, TEST_LOCATION );
1236 DALI_TEST_EQUALS( ruler->Clamp(200.0f), 100.0f, TEST_LOCATION );
1238 ruler->DisableDomain();
1239 DALI_TEST_EQUALS( ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION );
1240 DALI_TEST_EQUALS( ruler->Clamp(-200.0f), -200.0f, TEST_LOCATION );
1241 DALI_TEST_EQUALS( ruler->Clamp(200.0f), 200.0f, TEST_LOCATION );
1244 static void UtcDaliRulerSnapAndClamp()
1246 ToolkitTestApplication application;
1247 tet_infoline(" UtcDaliRulerSnapAndClamp");
1249 RulerPtr ruler = new FixedRuler( 50.0f );
1250 ruler->SetDomain( RulerDomain(0.0f, 400.0f, true) );
1252 // default testing. (snap and clamp)
1253 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f), 50.0f, TEST_LOCATION);
1254 DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f), 50.0f, TEST_LOCATION);
1255 DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f), 0.0f, TEST_LOCATION);
1256 DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f), 0.0f, TEST_LOCATION);
1257 DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f), 400.0f, TEST_LOCATION);
1258 DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f), 400.0f, TEST_LOCATION);
1261 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
1262 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 0.5f), 50.0f, TEST_LOCATION); // No Flick
1263 DALI_TEST_EQUALS( ruler->SnapAndClamp(40.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
1265 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
1266 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 0.5f), 0.0f, TEST_LOCATION); // No Flick
1267 DALI_TEST_EQUALS( ruler->SnapAndClamp(20.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
1270 DALI_TEST_EQUALS( ruler->SnapAndClamp(-10.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (over left boundary)
1271 DALI_TEST_EQUALS( ruler->SnapAndClamp(-5.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (slightly ovr left boundary)
1272 DALI_TEST_EQUALS( ruler->SnapAndClamp(300.0f, 0.5f, 10.0f), 300.0f, TEST_LOCATION); // 10 units long (not over a boundary)
1273 DALI_TEST_EQUALS( ruler->SnapAndClamp(395.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (slightly over right boundary)
1274 DALI_TEST_EQUALS( ruler->SnapAndClamp(500.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (over right boundary)
1277 DALI_TEST_EQUALS( ruler->SnapAndClamp(-100.0f, 0.5f, 0.0f, 2.0f), 0.0f, TEST_LOCATION);
1278 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 2.0f), 50.0f, TEST_LOCATION);
1279 DALI_TEST_EQUALS( ruler->SnapAndClamp(700.0f, 0.5f, 0.0f, 2.0f), 700.0f, TEST_LOCATION);
1280 DALI_TEST_EQUALS( ruler->SnapAndClamp(850.0f, 0.5f, 0.0f, 2.0f), 800.0f, TEST_LOCATION);
1282 // clamp state testing.
1284 DALI_TEST_EQUALS( ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
1285 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
1286 DALI_TEST_EQUALS( ruler->SnapAndClamp(30.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
1287 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
1288 DALI_TEST_EQUALS( ruler->SnapAndClamp(10.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
1289 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
1290 DALI_TEST_EQUALS( ruler->SnapAndClamp(-40.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
1291 DALI_TEST_EQUALS( clamped, ClampedToMin, TEST_LOCATION );
1292 DALI_TEST_EQUALS( ruler->SnapAndClamp(390.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
1293 DALI_TEST_EQUALS( clamped, NotClamped, TEST_LOCATION );
1294 DALI_TEST_EQUALS( ruler->SnapAndClamp(430.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
1295 DALI_TEST_EQUALS( clamped, ClampedToMax, TEST_LOCATION );
1298 static void UtcDaliRulerFixedRulerSpacing()
1300 ToolkitTestApplication application;
1301 tet_infoline(" UtcDaliRulerFixedRulerSpacing");
1303 RulerPtr rulerZero = new FixedRuler( 0.0f );
1304 rulerZero->SetDomain( RulerDomain(10.0f, 90.0f, true) );
1306 RulerPtr rulerNormal = new FixedRuler( 25.0f );
1307 rulerNormal->SetDomain( RulerDomain(10.0f, 90.0f, true) );
1309 unsigned int volume;
1312 position = rulerZero->GetPositionFromPage(1, volume, true);
1313 DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
1314 DALI_TEST_EQUALS( volume, 1u, TEST_LOCATION );
1316 position = rulerNormal->GetPositionFromPage(1, volume, true);
1317 DALI_TEST_EQUALS( position, 35.0f, TEST_LOCATION );
1318 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
1320 position = rulerZero->GetPositionFromPage(2, volume, true);
1321 DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
1322 DALI_TEST_EQUALS( volume, 2u, TEST_LOCATION );
1324 position = rulerNormal->GetPositionFromPage(2, volume, true);
1325 DALI_TEST_EQUALS( position, 60.0f, TEST_LOCATION );
1326 DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
1329 static void UtcDaliScrollViewOvershoot()
1331 ToolkitTestApplication application;
1332 tet_infoline(" UtcDaliScrollViewOvershoot");
1334 // Set up a scrollView...
1335 ScrollView scrollView = ScrollView::New();
1336 Stage::GetCurrent().Add( scrollView );
1337 Vector2 stageSize = Stage::GetCurrent().GetSize();
1338 scrollView.SetSize(stageSize);
1339 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
1340 scrollView.SetRefreshInterval(0);
1341 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1342 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1345 RulerPtr rulerX = new DefaultRuler();
1346 RulerPtr rulerY = new DefaultRuler();
1347 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1348 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1349 scrollView.SetRulerX(rulerX);
1350 scrollView.SetRulerY(rulerY);
1351 scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
1352 scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1353 scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete );
1355 scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1358 // 1. Scroll page in NW (-500,-500 pixels), then inspect overshoot. (don't release touch)
1359 Vector2 currentPos = Vector2(100.0f, 100.0f);
1360 currentPos = PerformGestureDiagonalSwipe(application, currentPos, Vector2(5.0f, 5.0f), 100, false);
1361 Property::Index overshootXProperty = scrollView.GetPropertyIndex(ScrollView::SCROLL_OVERSHOOT_X_PROPERTY_NAME);
1362 Property::Index overshootYProperty = scrollView.GetPropertyIndex(ScrollView::SCROLL_OVERSHOOT_Y_PROPERTY_NAME);
1363 Property::Index scrollPositionProperty = scrollView.GetPropertyIndex(ScrollView::SCROLL_POSITION_PROPERTY_NAME);
1364 float overshootXValue = scrollView.GetProperty<float>(overshootXProperty);
1365 float overshootYValue = scrollView.GetProperty<float>(overshootYProperty);
1366 Vector3 positionValue = scrollView.GetProperty<Vector3>(scrollPositionProperty);
1367 DALI_TEST_EQUALS(overshootXValue, -1.0f, TEST_LOCATION);
1368 DALI_TEST_EQUALS(overshootYValue, -1.0f, TEST_LOCATION);
1369 DALI_TEST_EQUALS(positionValue, Vector3::ZERO, TEST_LOCATION);
1371 float timeToReachOrigin;
1373 // Now release touch. Overshoot should snap back to zero.
1374 SendPan(application, Gesture::Finished, currentPos);
1375 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1377 DALI_TEST_CHECK( (timeToReachOrigin > TEST_DEFAULT_SNAP_OVERSHOOT_DURATION - TIME_TOLERANCE) &&
1378 (timeToReachOrigin < TEST_DEFAULT_SNAP_OVERSHOOT_DURATION + TIME_TOLERANCE) );
1380 // 2. Repeat Scroll, but this time change overshoot snap duration to shorter time
1381 scrollView.SetSnapOvershootDuration(TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION);
1383 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1384 // Now release touch. Overshoot should snap back to zero.
1385 SendPan(application, Gesture::Finished, currentPos);
1386 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1388 DALI_TEST_CHECK( (timeToReachOrigin > TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION - TIME_TOLERANCE) &&
1389 (timeToReachOrigin < TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION + TIME_TOLERANCE) );
1391 // 3. Repeat Scroll, but this time change overshoot snap duration to longer time.
1392 scrollView.SetSnapOvershootDuration(TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION);
1394 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1395 // Now release touch. Overshoot should snap back to zero.
1396 SendPan(application, Gesture::Finished, currentPos);
1397 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1399 DALI_TEST_CHECK( (timeToReachOrigin > TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION - TIME_TOLERANCE) &&
1400 (timeToReachOrigin < TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION + TIME_TOLERANCE) );
1402 // 4. Repeat Scroll, but this time change overshoot function.
1403 scrollView.SetSnapOvershootAlphaFunction(TestAlphaFunction);
1405 currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false);
1406 // Now release touch. Overshoot should snap back to zero.
1407 SendPan(application, Gesture::Finished, currentPos);
1408 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1410 DALI_TEST_CHECK( (timeToReachOrigin > TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION - TIME_TOLERANCE) &&
1411 (timeToReachOrigin < TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION + TIME_TOLERANCE) );
1414 static void UtcDaliScrollViewSnapAlphaFunction()
1416 ToolkitTestApplication application;
1417 tet_infoline(" UtcDaliScrollViewSnapAlphaFunction");
1419 // Set up a scrollView...
1420 ScrollView scrollView = ScrollView::New();
1421 scrollView.SetScrollSnapAlphaFunction( AlphaFunctions::EaseIn );
1422 DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction() == AlphaFunctions::EaseIn );
1423 scrollView.SetScrollSnapAlphaFunction( AlphaFunctions::EaseOut );
1424 DALI_TEST_CHECK( scrollView.GetScrollSnapAlphaFunction() == AlphaFunctions::EaseOut );
1426 scrollView.SetScrollFlickAlphaFunction( AlphaFunctions::Bounce );
1427 DALI_TEST_CHECK( scrollView.GetScrollFlickAlphaFunction() == AlphaFunctions::Bounce );
1428 scrollView.SetScrollFlickAlphaFunction( AlphaFunctions::BounceBack );
1429 DALI_TEST_CHECK( scrollView.GetScrollFlickAlphaFunction() == AlphaFunctions::BounceBack );
1432 static void UtcDaliScrollViewSnapDuration()
1434 ToolkitTestApplication application;
1435 tet_infoline(" UtcDaliScrollViewSnapDuration");
1437 // Set up a scrollView...
1438 ScrollView scrollView = ScrollView::New();
1439 scrollView.SetScrollSnapDuration( 1.0f );
1440 DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 1.0f, TEST_LOCATION );
1441 scrollView.SetScrollSnapDuration( 0.5f );
1442 DALI_TEST_EQUALS( scrollView.GetScrollSnapDuration(), 0.5f, TEST_LOCATION );
1444 scrollView.SetScrollFlickDuration( 2.0f );
1445 DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 2.0f, TEST_LOCATION );
1446 scrollView.SetScrollFlickDuration( 1.5f );
1447 DALI_TEST_EQUALS( scrollView.GetScrollFlickDuration(), 1.5f, TEST_LOCATION );
1450 static void UtcDaliScrollViewSignalsSnapStart()
1452 ToolkitTestApplication application;
1453 tet_infoline(" UtcDaliScrollViewSignalsSnapStart");
1455 // Set up a scrollView...
1456 ScrollView scrollView = ScrollView::New();
1457 Stage::GetCurrent().Add( scrollView );
1458 Vector2 stageSize = Stage::GetCurrent().GetSize();
1459 scrollView.SetSize(stageSize);
1460 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
1461 scrollView.SetRefreshInterval(0);
1462 scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
1463 scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1466 RulerPtr rulerX = new DefaultRuler();
1467 RulerPtr rulerY = new DefaultRuler();
1468 rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
1469 rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
1470 scrollView.SetRulerX(rulerX);
1471 scrollView.SetRulerY(rulerY);
1472 scrollView.SnapStartedSignal().Connect( &OnSnapStart );
1474 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1477 DALI_TEST_CHECK( !gOnSnapStartCalled );
1479 // First try a snap.
1480 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(0.5f, 0.0f), 60, true);
1482 DALI_TEST_CHECK( gOnSnapStartCalled );
1483 DALI_TEST_CHECK( gLastSnapType == Toolkit::Snap );
1485 // Second try a swipe.
1486 PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(20.0f, 0.0f), 60, true);
1488 DALI_TEST_CHECK( gOnSnapStartCalled );
1489 DALI_TEST_CHECK( gLastSnapType == Toolkit::Flick );
1492 static void UtcDaliScrollViewUIComponent()
1494 ToolkitTestApplication application;
1495 tet_infoline(" UtcDaliScrollViewUIComponent");
1497 // Set up a scrollView...
1498 ScrollView scrollView = ScrollView::New();
1499 DALI_TEST_CHECK( !scrollView.IsScrollComponentEnabled(Scrollable::HorizontalScrollBar) );
1500 DALI_TEST_CHECK( !scrollView.IsScrollComponentEnabled(Scrollable::VerticalScrollBar) );
1501 DALI_TEST_CHECK( scrollView.IsScrollComponentEnabled(Scrollable::OvershootIndicator) );
1503 scrollView.EnableScrollComponent( Scrollable::VerticalScrollBar );
1504 DALI_TEST_CHECK( !scrollView.IsScrollComponentEnabled(Scrollable::HorizontalScrollBar) );
1505 DALI_TEST_CHECK( scrollView.IsScrollComponentEnabled(Scrollable::VerticalScrollBar) );
1506 DALI_TEST_CHECK( scrollView.IsScrollComponentEnabled(Scrollable::OvershootIndicator) );
1508 scrollView.EnableScrollComponent( Scrollable::HorizontalScrollBar );
1509 DALI_TEST_CHECK( scrollView.IsScrollComponentEnabled(Scrollable::HorizontalScrollBar) );
1510 DALI_TEST_CHECK( scrollView.IsScrollComponentEnabled(Scrollable::VerticalScrollBar) );
1511 DALI_TEST_CHECK( scrollView.IsScrollComponentEnabled(Scrollable::OvershootIndicator) );
1513 scrollView.EnableScrollComponent( Scrollable::OvershootIndicator );
1514 DALI_TEST_CHECK( scrollView.IsScrollComponentEnabled(Scrollable::HorizontalScrollBar) );
1515 DALI_TEST_CHECK( scrollView.IsScrollComponentEnabled(Scrollable::VerticalScrollBar) );
1516 DALI_TEST_CHECK( scrollView.IsScrollComponentEnabled(Scrollable::OvershootIndicator) );
1518 scrollView.DisableScrollComponent( Scrollable::VerticalScrollBar );
1519 DALI_TEST_CHECK( scrollView.IsScrollComponentEnabled(Scrollable::HorizontalScrollBar) );
1520 DALI_TEST_CHECK( !scrollView.IsScrollComponentEnabled(Scrollable::VerticalScrollBar) );
1521 DALI_TEST_CHECK( scrollView.IsScrollComponentEnabled(Scrollable::OvershootIndicator) );
1523 scrollView.DisableScrollComponent( Scrollable::HorizontalScrollBar );
1524 DALI_TEST_CHECK( !scrollView.IsScrollComponentEnabled(Scrollable::HorizontalScrollBar) );
1525 DALI_TEST_CHECK( !scrollView.IsScrollComponentEnabled(Scrollable::VerticalScrollBar) );
1526 DALI_TEST_CHECK( scrollView.IsScrollComponentEnabled(Scrollable::OvershootIndicator) );
1528 scrollView.DisableScrollComponent( Scrollable::OvershootIndicator );
1529 DALI_TEST_CHECK( !scrollView.IsScrollComponentEnabled(Scrollable::HorizontalScrollBar) );
1530 DALI_TEST_CHECK( !scrollView.IsScrollComponentEnabled(Scrollable::VerticalScrollBar) );
1531 DALI_TEST_CHECK( !scrollView.IsScrollComponentEnabled(Scrollable::OvershootIndicator) );
1533 // Create scroll bar
1534 ScrollBar scrollBar = ScrollBar::New(scrollView, true);
1539 const ScrollBar scrollBarVertical = ScrollBar(scrollBar);
1540 BaseHandle handle(scrollBarVertical);
1542 ScrollBar newScrollBar = ScrollBar::DownCast( handle );
1543 DALI_TEST_CHECK( scrollBarVertical );
1544 DALI_TEST_CHECK( newScrollBar == scrollBarVertical );
1546 ScrollComponent scrollComponent = ScrollComponent(scrollBarVertical);
1547 handle = scrollComponent;
1549 ScrollComponent newScrollComponent = ScrollComponent::DownCast( handle );
1550 DALI_TEST_CHECK( scrollComponent );
1551 DALI_TEST_CHECK( scrollComponent == scrollComponent );
1554 static void UtcDaliScrollViewSetMouseWheelScrollDistanceStep()
1556 ToolkitTestApplication application;
1557 tet_infoline(" UtcDaliScrollViewSetMouseWheelScrollDistanceStep");
1559 ScrollView scrollView = ScrollView::New();
1560 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
1561 scrollView.SetMouseWheelScrollDistanceStep(Vector2(30.0f, 15.0f));
1562 DALI_TEST_EQUALS( scrollView.GetMouseWheelScrollDistanceStep(), Vector2(30.0f, 15.0f), TEST_LOCATION );
1563 scrollView.SetMouseWheelScrollDistanceStep(Vector2(60.0f, 30.0f));
1564 DALI_TEST_EQUALS( scrollView.GetMouseWheelScrollDistanceStep(), Vector2(60.0f, 30.0f), TEST_LOCATION);
1567 static void UtcDaliScrollViewGetSet()
1569 ToolkitTestApplication application;
1570 tet_infoline(" UtcDaliScrollViewGetSet");
1571 ScrollView scrollView = ScrollView::New();
1572 scrollView.SetMaxOvershoot(50.0f, 50.0f);
1573 scrollView.SetMaxFlickSpeed(0.5f);
1574 DALI_TEST_EQUALS(scrollView.GetMaxFlickSpeed(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1575 scrollView.SetFrictionCoefficient(0.6f);
1576 DALI_TEST_EQUALS(scrollView.GetFrictionCoefficient(), 0.6f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1577 scrollView.SetFlickSpeedCoefficient(0.7f);
1578 DALI_TEST_EQUALS(scrollView.GetFlickSpeedCoefficient(), 0.7f, Math::MACHINE_EPSILON_0, TEST_LOCATION);