2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali-toolkit-test-suite-utils.h>
22 #include <dali-toolkit/dali-toolkit.h>
23 #include <dali/integration-api/events/pan-gesture-event.h>
24 #include <dali-toolkit/devel-api/controls/scroll-bar/scroll-bar-devel.h>
27 using namespace Toolkit;
29 void dali_scrollbar_startup(void)
31 test_return_value = TET_UNDEF;
34 void dali_scrollbar_cleanup(void)
36 test_return_value = TET_PASS;
42 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
44 // Generate a PanGestureEvent to send to Core
45 Integration::PanGestureEvent GeneratePan(
47 const Vector2& previousPosition,
48 const Vector2& currentPosition,
49 unsigned long timeDelta,
50 unsigned int numberOfTouches = 1)
52 Integration::PanGestureEvent pan(state);
54 pan.previousPosition = previousPosition;
55 pan.currentPosition = currentPosition;
56 pan.timeDelta = timeDelta;
57 pan.numberOfTouches = numberOfTouches;
63 * Helper to generate PanGestureEvent
65 * @param[in] application Application instance
66 * @param[in] state The Gesture State
67 * @param[in] pos The current position of touch.
69 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
73 if( (state == Gesture::Started) ||
74 (state == Gesture::Possible) )
80 application.ProcessEvent(GeneratePan(state, last, pos, RENDER_FRAME_INTERVAL));
87 * Simulate time passed by.
89 * @note this will always process at least 1 frame (1/60 sec)
91 * @param application Test application instance
92 * @param duration Time to pass in milliseconds.
93 * @return The actual time passed in milliseconds
95 int Wait(ToolkitTestApplication& application, int duration = 0)
99 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
101 application.SendNotification();
102 application.Render(RENDER_FRAME_INTERVAL);
103 time += RENDER_FRAME_INTERVAL;
111 static bool gOnPanFinishedCalled; ///< Whether the PanFinished signal was invoked.
112 static bool gOnScrollPositionIntervalReachedSignalCalled; ///< Whether the ScrollPositionIntervalReached signal was invoked.
115 * Invoked when pan gesture is finished on the scroll indicator.
117 static void OnPanFinished()
119 gOnPanFinishedCalled = true;
122 struct CallbackFunctor
124 CallbackFunctor(bool* callbackFlag)
125 : mCallbackFlag( callbackFlag )
131 *mCallbackFlag = true;
137 * Invoked when the current scroll position of the scrollable content goes above or below the values
138 * specified by SCROLL_POSITION_INTERVALS property.
140 * @param[in] position The current scroll position.
142 static void OnScrollPositionIntervalReached( float position )
144 gOnScrollPositionIntervalReachedSignalCalled = true;
147 static Vector2 PerformGestureSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames)
149 gOnPanFinishedCalled = false;
151 // Now do a pan starting from (start) and heading (direction)
153 SendPan(application, Gesture::Possible, pos);
154 SendPan(application, Gesture::Started, pos);
157 for(int i = 0; i < frames; i++)
159 pos += direction; // Move in this direction
160 SendPan(application, Gesture::Continuing, pos);
164 pos += direction; // Move in this direction.
165 SendPan(application, Gesture::Finished, pos);
173 int UtcDaliToolkitScrollBarConstructorP(void)
175 ToolkitTestApplication application;
178 DALI_TEST_CHECK( !scrollBar );
182 int UtcDaliToolkitScrollBarCopyConstructorP(void)
184 ToolkitTestApplication application;
186 ScrollBar scrollBar = ScrollBar::New();
187 scrollBar.SetProperty( ScrollBar::Property::INDICATOR_FIXED_HEIGHT, 38.2f );
189 ScrollBar copy( scrollBar );
190 DALI_TEST_CHECK( copy );
191 DALI_TEST_CHECK( copy.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) == scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) );
195 int UtcDaliToolkitScrollBarAssignmentOperatorP(void)
197 ToolkitTestApplication application;
199 ScrollBar scrollBar = ScrollBar::New();
200 scrollBar.SetProperty( ScrollBar::Property::INDICATOR_FIXED_HEIGHT, 38.2f );
202 ScrollBar copy = scrollBar;
203 DALI_TEST_CHECK( copy );
204 DALI_TEST_CHECK( copy.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) == scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) );
208 int UtcDaliScrollBarDestructorP(void)
210 ToolkitTestApplication application;
212 ScrollBar* scrollBar = new ScrollBar();
215 DALI_TEST_CHECK( true );
219 int UtcDaliToolkitScrollBarNewP(void)
221 ToolkitTestApplication application;
223 ScrollBar scrollBar = ScrollBar::New();
224 DALI_TEST_CHECK( scrollBar );
227 ScrollBar vertical = ScrollBar::New(ScrollBar::Vertical);
228 DALI_TEST_CHECK( vertical );
229 DALI_TEST_CHECK( vertical.GetScrollDirection() == ScrollBar::Vertical );
231 Property::Value value = vertical.GetProperty(ScrollBar::Property::SCROLL_DIRECTION);
232 std::string scrollDirection = value.Get<std::string>();
233 DALI_TEST_EQUALS( scrollDirection, "Vertical", TEST_LOCATION );
235 ScrollBar horizontal = ScrollBar::New(ScrollBar::Horizontal);
236 DALI_TEST_CHECK( horizontal );
237 DALI_TEST_CHECK( horizontal.GetScrollDirection() == ScrollBar::Horizontal );
238 value = vertical.GetProperty(ScrollBar::Property::SCROLL_DIRECTION);
239 scrollDirection = value.Get<std::string>();
240 DALI_TEST_EQUALS( scrollDirection, "Horizontal", TEST_LOCATION );
245 int UtcDaliToolkitScrollBarCreateP(void)
247 ToolkitTestApplication application;
249 TypeRegistry typeRegistry = TypeRegistry::Get();
250 DALI_TEST_CHECK( typeRegistry );
252 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "ScrollBar" );
253 DALI_TEST_CHECK( typeInfo );
255 BaseHandle handle = typeInfo.CreateInstance();
256 DALI_TEST_CHECK( handle );
258 ScrollBar scrollBar = ScrollBar::DownCast( handle );
259 DALI_TEST_CHECK( scrollBar );
261 scrollBar.SetProperty(ScrollBar::Property::SCROLL_DIRECTION, "Vertical");
262 scrollBar.SetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY, "Fixed");
264 DALI_TEST_EQUALS( scrollBar.GetScrollDirection(), Toolkit::ScrollBar::Vertical, TEST_LOCATION );
265 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Fixed, TEST_LOCATION );
267 scrollBar.SetProperty(ScrollBar::Property::SCROLL_DIRECTION, "Horizontal");
268 scrollBar.SetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY, "Variable");
270 DALI_TEST_EQUALS( scrollBar.GetScrollDirection(), Toolkit::ScrollBar::Horizontal, TEST_LOCATION );
271 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Variable, TEST_LOCATION );
276 int UtcDaliToolkitScrollBarDownCastP(void)
278 ToolkitTestApplication application;
280 ScrollBar scrollBar1 = ScrollBar::New();
281 BaseHandle object( scrollBar1 );
283 ScrollBar scrollBar2 = ScrollBar::DownCast( object );
284 DALI_TEST_CHECK( scrollBar2 );
286 ScrollBar scrollBar3 = DownCast< ScrollBar >( object );
287 DALI_TEST_CHECK( scrollBar3 );
291 int UtcDaliToolkitScrollBarDownCastN(void)
293 ToolkitTestApplication application;
295 BaseHandle uninitializedObject;
296 ScrollBar scrollBar1 = ScrollBar::DownCast( uninitializedObject );
297 DALI_TEST_CHECK( !scrollBar1 );
299 ScrollBar scrollBar2 = DownCast< ScrollBar >( uninitializedObject );
300 DALI_TEST_CHECK( !scrollBar2 );
304 int UtcDaliToolkitScrollBarSetScrollPropertySourceP(void)
306 ToolkitTestApplication application;
308 // Create a vertical scroll bar
309 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
310 DALI_TEST_CHECK( scrollBar );
311 DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::Vertical );
313 float scrollBarHeight = 100.0f;
314 scrollBar.SetSize(20.0f, scrollBarHeight, 0.0f);
315 Stage::GetCurrent().Add( scrollBar );
317 // Create a source actor that owns the scroll properties required by the scroll bar
318 Actor sourceActor = Actor::New();
319 Stage::GetCurrent().Add( sourceActor );
321 // Register the scroll properties
322 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
323 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
324 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
325 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
327 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
328 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
329 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
330 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
332 // Set the source of the scroll position properties.
333 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
336 application.SendNotification();
337 application.Render();
339 Actor indicator = scrollBar.GetScrollIndicator();
340 DALI_TEST_CHECK( indicator );
342 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
343 // i.e. The bigger the content size, the smaller the indicator size
344 float indicatorHeight = indicator.GetCurrentSize().y;
345 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
347 // Decrease the content length
348 sourceActor.SetProperty( propertyScrollContentSize, 250.0f );
351 application.SendNotification();
352 application.Render();
354 // Check that the indicator size is changed accordingly
355 indicatorHeight = indicator.GetCurrentSize().y;
356 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 250.0f, TEST_LOCATION );
358 // As scroll position is 0, check that the indicator position should be 0.0f.
359 float indicatorPosition = indicator.GetCurrentPosition().y;
360 DALI_TEST_EQUALS( indicatorPosition, 0.0f, TEST_LOCATION );
362 // Set the scroll position to the middle
363 sourceActor.SetProperty( propertyScrollPosition, -50.0f );
366 application.SendNotification();
367 application.Render();
369 // Check that the indicator should be in the middle of the scroll bar
370 indicatorPosition = indicator.GetCurrentPosition().y;
371 DALI_TEST_EQUALS( indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.5f, TEST_LOCATION );
373 // Set the scroll position to the maximum
374 sourceActor.SetProperty( propertyScrollPosition, -100.0f );
377 application.SendNotification();
378 application.Render();
380 // Check that the indicator should be in the end of the scroll bar
381 indicatorPosition = indicator.GetCurrentPosition().y;
382 DALI_TEST_EQUALS( indicatorPosition, scrollBarHeight - indicatorHeight, TEST_LOCATION );
384 // Increase the maximum scroll position to double
385 sourceActor.SetProperty( propertyMaxScrollPosition, 200.0f );
388 application.SendNotification();
389 application.Render();
391 // Check that the indicator should be now in the middle of the scroll bar
392 indicatorPosition = indicator.GetCurrentPosition().y;
393 DALI_TEST_EQUALS( indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.5f, TEST_LOCATION );
395 // Create another source actor
396 Actor newSourceActor = Actor::New();
397 Stage::GetCurrent().Add( newSourceActor );
399 // Register the scroll properties
400 Property::Index newPropertyScrollPosition = newSourceActor.RegisterProperty( "sourcePosition", 0.0f );
401 Property::Index newPropertyMinScrollPosition = newSourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
402 Property::Index newPropertyMaxScrollPosition = newSourceActor.RegisterProperty( "sourcePositionMax", 200.0f );
403 Property::Index newPropertyScrollContentSize = newSourceActor.RegisterProperty( "sourceContentSize", 400.0f );
405 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourcePosition" ), newPropertyScrollPosition, TEST_LOCATION );
406 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourcePositionMin" ), newPropertyMinScrollPosition, TEST_LOCATION );
407 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourcePositionMax" ), newPropertyMaxScrollPosition, TEST_LOCATION );
408 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourceContentSize" ), newPropertyScrollContentSize, TEST_LOCATION );
410 // Change the source of the scroll position properties to be the new source actor.
411 scrollBar.SetScrollPropertySource(newSourceActor, newPropertyScrollPosition, newPropertyMinScrollPosition, newPropertyMaxScrollPosition, newPropertyScrollContentSize);
414 application.SendNotification();
415 application.Render();
417 // Check that the indicator size is changed accordingly
418 indicatorHeight = indicator.GetCurrentSize().y;
419 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 400.0f, TEST_LOCATION );
421 // Check that the indicator position goes back to the beginning of the scroll bar
422 indicatorPosition = indicator.GetCurrentPosition().y;
423 DALI_TEST_EQUALS( indicatorPosition, 0.0f, TEST_LOCATION );
425 // Set the scroll position to one fifth of the maximum
426 newSourceActor.SetProperty( propertyScrollPosition, -40.0f );
429 application.SendNotification();
430 application.Render();
432 // Check that the indicator should be in one fifth from the beginning of the scroll bar
433 indicatorPosition = indicator.GetCurrentPosition().y;
434 DALI_TEST_EQUALS( indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.2f, TEST_LOCATION );
439 int UtcDaliToolkitScrollBarSetScrollPropertySourceN(void)
441 ToolkitTestApplication application;
443 // Create a scroll bar
444 ScrollBar scrollBar = ScrollBar::New();
445 DALI_TEST_CHECK( scrollBar );
447 // Set empty handle of source object and invalid source property index.
449 scrollBar.SetScrollPropertySource(sourceActor, Property::INVALID_INDEX, Property::INVALID_INDEX, Property::INVALID_INDEX, Property::INVALID_INDEX);
451 DALI_TEST_CHECK( true );
455 int UtcDaliToolkitScrollBarSetScrollIndicatorP(void)
457 ToolkitTestApplication application;
459 // Create a scroll bar
460 ScrollBar scrollBar = ScrollBar::New();
461 DALI_TEST_CHECK( scrollBar );
463 Actor indicator = scrollBar.GetScrollIndicator();
464 DALI_TEST_CHECK( indicator );
466 // Set a new indicator
467 Actor newIndicator = Actor::New();
468 scrollBar.SetScrollIndicator(newIndicator);
470 // Check that the new indicator is successfully set
471 DALI_TEST_CHECK( indicator != scrollBar.GetScrollIndicator() );
472 DALI_TEST_CHECK( newIndicator == scrollBar.GetScrollIndicator() );
474 // Check that the new control indicator is successfully set
475 Control controlIndicator = Control::New();
476 scrollBar.SetScrollIndicator(controlIndicator);
478 DALI_TEST_CHECK( controlIndicator == Control::DownCast( scrollBar.GetScrollIndicator() ) );
482 int UtcDaliToolkitScrollBarSetScrollIndicatorN(void)
484 ToolkitTestApplication application;
486 // Create a scroll bar
487 ScrollBar scrollBar = ScrollBar::New();
488 DALI_TEST_CHECK( scrollBar );
490 Actor indicator = scrollBar.GetScrollIndicator();
491 DALI_TEST_CHECK( indicator );
493 // Try to set an uninitialized actor as the indicator
494 Actor uninitializedIndicator;
495 scrollBar.SetScrollIndicator(uninitializedIndicator);
497 // Check that the uninitialized actor can not be set as the indicator
498 DALI_TEST_CHECK( indicator == scrollBar.GetScrollIndicator() );
499 DALI_TEST_CHECK( uninitializedIndicator != scrollBar.GetScrollIndicator() );
504 int UtcDaliToolkitScrollBarGetScrollIndicatorP(void)
506 ToolkitTestApplication application;
508 // Create a scroll bar
509 ScrollBar scrollBar = ScrollBar::New();
510 DALI_TEST_CHECK( scrollBar );
512 Actor indicator = scrollBar.GetScrollIndicator();
513 DALI_TEST_CHECK( indicator );
515 // Set a new indicator
516 Actor newIndicator = Actor::New();
517 scrollBar.SetScrollIndicator(newIndicator);
519 // Check that the new indicator is successfully set
520 DALI_TEST_CHECK( scrollBar.GetScrollIndicator() );
521 DALI_TEST_CHECK( indicator != scrollBar.GetScrollIndicator() );
522 DALI_TEST_CHECK( newIndicator == scrollBar.GetScrollIndicator() );
527 int UtcDaliToolkitScrollBarGetScrollIndicatorN(void)
529 ToolkitTestApplication application;
531 // Create a scroll bar
532 ScrollBar scrollBar = ScrollBar::New();
533 DALI_TEST_CHECK( scrollBar );
535 Actor indicator = scrollBar.GetScrollIndicator();
536 DALI_TEST_CHECK( indicator );
538 // Try to set an uninitialized actor as the indicator
539 Actor uninitializedIndicator;
540 scrollBar.SetScrollIndicator(uninitializedIndicator);
542 // Check that the indicator has not been changed
543 DALI_TEST_CHECK( indicator == scrollBar.GetScrollIndicator() );
544 DALI_TEST_CHECK( uninitializedIndicator != scrollBar.GetScrollIndicator() );
549 int UtcDaliToolkitScrollBarSetScrollPositionIntervalsP(void)
551 ToolkitTestApplication application;
553 // Create a vertical scroll bar
554 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
555 DALI_TEST_CHECK( scrollBar );
557 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
558 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
559 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
561 Stage::GetCurrent().Add( scrollBar );
563 // Connect to the ScrollPositionIntervalReached signal
564 scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
567 application.SendNotification();
568 application.Render();
570 // Create a source actor that owns the scroll properties required by the scroll bar
571 Actor sourceActor = Actor::New();
572 Stage::GetCurrent().Add( sourceActor );
574 // Register the scroll properties
575 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
576 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
577 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 800.0f );
578 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 2000.0f );
580 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
581 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
582 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
583 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
585 // Set the source of the scroll position properties.
586 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
589 application.SendNotification();
590 application.Render();
592 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
593 Dali::Vector<float> positionIntervals;
594 for( size_t i = 0; i != 10; ++i )
596 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
598 scrollBar.SetScrollPositionIntervals(positionIntervals);
600 // Get the list of scroll position intervals for notification
601 Dali::Vector<float> results = scrollBar.GetScrollPositionIntervals();
603 // Check that the result is the same as the list previously set.
604 DALI_TEST_EQUALS( positionIntervals.Count(), results.Count(), TEST_LOCATION );
605 DALI_TEST_EQUALS( positionIntervals[0], results[0], TEST_LOCATION );
606 DALI_TEST_EQUALS( positionIntervals[1], results[1], TEST_LOCATION );
607 DALI_TEST_EQUALS( positionIntervals[2], results[2], TEST_LOCATION );
608 DALI_TEST_EQUALS( positionIntervals[3], results[3], TEST_LOCATION );
609 DALI_TEST_EQUALS( positionIntervals[4], results[4], TEST_LOCATION );
610 DALI_TEST_EQUALS( positionIntervals[5], results[5], TEST_LOCATION );
611 DALI_TEST_EQUALS( positionIntervals[6], results[6], TEST_LOCATION );
612 DALI_TEST_EQUALS( positionIntervals[7], results[7], TEST_LOCATION );
613 DALI_TEST_EQUALS( positionIntervals[8], results[8], TEST_LOCATION );
614 DALI_TEST_EQUALS( positionIntervals[9], results[9], TEST_LOCATION );
617 gOnScrollPositionIntervalReachedSignalCalled = false;
619 // Animate the scroll position to cross the specified value
620 Animation animation = Animation::New(0.1f);
621 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
624 // Wait for 0.1 second
625 Wait(application, 100);
627 // Check that the signal callback is called
628 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
631 gOnScrollPositionIntervalReachedSignalCalled = false;
633 // Rest and clear the animation
637 // Animate the scroll position to cross another specified value
638 animation = Animation::New(0.1f);
639 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -170.0f );
642 // Wait for 0.1 second
643 Wait(application, 100);
645 // Check that the signal callback is called
646 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
649 gOnScrollPositionIntervalReachedSignalCalled = false;
651 // Rest and clear the animation
655 // Animate the scroll position back to the previous value
656 animation = Animation::New(0.1f);
657 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
660 // Wait for 0.1 second
661 Wait(application, 100);
663 // Check that the signal callback is called
664 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
669 int UtcDaliToolkitScrollBarGetScrollPositionIntervalsP(void)
671 ToolkitTestApplication application;
673 // Create a vertical scroll bar
674 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
675 DALI_TEST_CHECK( scrollBar );
677 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
678 Dali::Vector<float> positionIntervals;
679 for( size_t i = 0; i != 10; ++i )
681 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
683 scrollBar.SetScrollPositionIntervals(positionIntervals);
685 // Get the list of scroll position intervals for notification
686 Dali::Vector<float> results = scrollBar.GetScrollPositionIntervals();
688 // Check that the result is the same as the list previously set.
689 DALI_TEST_EQUALS( positionIntervals.Count(), results.Count(), TEST_LOCATION );
690 DALI_TEST_EQUALS( positionIntervals[0], results[0], TEST_LOCATION );
691 DALI_TEST_EQUALS( positionIntervals[1], results[1], TEST_LOCATION );
692 DALI_TEST_EQUALS( positionIntervals[2], results[2], TEST_LOCATION );
693 DALI_TEST_EQUALS( positionIntervals[3], results[3], TEST_LOCATION );
694 DALI_TEST_EQUALS( positionIntervals[4], results[4], TEST_LOCATION );
695 DALI_TEST_EQUALS( positionIntervals[5], results[5], TEST_LOCATION );
696 DALI_TEST_EQUALS( positionIntervals[6], results[6], TEST_LOCATION );
697 DALI_TEST_EQUALS( positionIntervals[7], results[7], TEST_LOCATION );
698 DALI_TEST_EQUALS( positionIntervals[8], results[8], TEST_LOCATION );
699 DALI_TEST_EQUALS( positionIntervals[9], results[9], TEST_LOCATION );
701 Property::Array resultArray = scrollBar.GetProperty<Property::Array>(Toolkit::ScrollBar::Property::SCROLL_POSITION_INTERVALS);
703 DALI_TEST_EQUALS( positionIntervals.Count(), resultArray.Count(), TEST_LOCATION );
704 DALI_TEST_EQUALS( positionIntervals[0], resultArray[0].Get<float>(), TEST_LOCATION );
705 DALI_TEST_EQUALS( positionIntervals[1], resultArray[1].Get<float>(), TEST_LOCATION );
706 DALI_TEST_EQUALS( positionIntervals[2], resultArray[2].Get<float>(), TEST_LOCATION );
707 DALI_TEST_EQUALS( positionIntervals[3], resultArray[3].Get<float>(), TEST_LOCATION );
708 DALI_TEST_EQUALS( positionIntervals[4], resultArray[4].Get<float>(), TEST_LOCATION );
709 DALI_TEST_EQUALS( positionIntervals[5], resultArray[5].Get<float>(), TEST_LOCATION );
710 DALI_TEST_EQUALS( positionIntervals[6], resultArray[6].Get<float>(), TEST_LOCATION );
711 DALI_TEST_EQUALS( positionIntervals[7], resultArray[7].Get<float>(), TEST_LOCATION );
712 DALI_TEST_EQUALS( positionIntervals[8], resultArray[8].Get<float>(), TEST_LOCATION );
713 DALI_TEST_EQUALS( positionIntervals[9], resultArray[9].Get<float>(), TEST_LOCATION );
718 int UtcDaliToolkitScrollBarGetScrollDirectionP(void)
720 ToolkitTestApplication application;
722 // Create a vertical scroll bar
723 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
724 DALI_TEST_CHECK( scrollBar );
725 DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::Vertical );
727 // Change the direction of scroll bar to horizontal
728 scrollBar.SetScrollDirection(ScrollBar::Horizontal);
729 DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::Horizontal );
734 int UtcDaliToolkitScrollBarSetIndicatorHeightPolicyP(void)
736 ToolkitTestApplication application;
738 // Create a scroll bar
739 ScrollBar scrollBar = ScrollBar::New();
740 DALI_TEST_CHECK( scrollBar );
742 float scrollBarHeight = 100.0f;
743 scrollBar.SetSize(20.0f, scrollBarHeight, 0.0f);
744 Stage::GetCurrent().Add( scrollBar );
746 // Create a source actor that owns the scroll properties required by the scroll bar
747 Actor sourceActor = Actor::New();
748 Stage::GetCurrent().Add( sourceActor );
750 // Register the scroll properties
751 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
752 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
753 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
754 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
756 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
757 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
758 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
759 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
761 // Set the source of the scroll position properties.
762 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
765 application.SendNotification();
766 application.Render();
768 Actor indicator = scrollBar.GetScrollIndicator();
769 DALI_TEST_CHECK( indicator );
771 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
772 // i.e. The bigger the content size, the smaller the indicator size
773 float indicatorHeight = indicator.GetCurrentSize().y;
774 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
776 // Set the indicator height to be fixed to 50.0f
777 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
778 scrollBar.SetIndicatorFixedHeight(50.0f);
780 Property::Value value = scrollBar.GetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY);
781 DALI_TEST_EQUALS(value.Get<std::string>(), "Fixed", TEST_LOCATION );
784 application.SendNotification();
785 application.Render();
787 // Check that the indicator size should be 50.0f
788 indicatorHeight = indicator.GetCurrentSize().y;
789 DALI_TEST_EQUALS( indicatorHeight, 50.0f, TEST_LOCATION );
791 // Set the indicator height to be variable
792 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Variable);
793 value = scrollBar.GetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY);
794 DALI_TEST_EQUALS(value.Get<std::string>(), "Variable", TEST_LOCATION );
797 application.SendNotification();
798 application.Render();
800 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
801 indicatorHeight = indicator.GetCurrentSize().y;
802 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
807 int UtcDaliToolkitScrollBarGetIndicatorHeightPolicyP(void)
809 ToolkitTestApplication application;
811 // Create a scroll bar
812 ScrollBar scrollBar = ScrollBar::New();
813 DALI_TEST_CHECK( scrollBar );
815 // Set the indicator height to be fixed
816 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
817 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Fixed, TEST_LOCATION );
819 // Set the indicator height to be variable
820 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Variable);
821 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Variable, TEST_LOCATION );
826 int UtcDaliToolkitScrollBarSetIndicatorFixedHeightP(void)
828 ToolkitTestApplication application;
830 // Create a scroll bar
831 ScrollBar scrollBar = ScrollBar::New();
832 DALI_TEST_CHECK( scrollBar );
834 float scrollBarHeight = 100.0f;
835 scrollBar.SetSize(20.0f, scrollBarHeight, 0.0f);
836 Stage::GetCurrent().Add( scrollBar );
838 Actor indicator = scrollBar.GetScrollIndicator();
839 DALI_TEST_CHECK( indicator );
841 // Set the indicator height to be fixed to 50.0f
842 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
843 scrollBar.SetIndicatorFixedHeight(50.0f);
846 application.SendNotification();
847 application.Render();
849 // Check that the indicator size should be 50.0f
850 DALI_TEST_EQUALS( indicator.GetCurrentSize().y, 50.0f, TEST_LOCATION );
852 // Set the indicator height to be fixed to 25.0f
853 scrollBar.SetIndicatorFixedHeight(25.0f);
856 application.SendNotification();
857 application.Render();
859 // Check that the indicator size should be 25.0f
860 DALI_TEST_EQUALS( indicator.GetCurrentSize().y, 25.0f, TEST_LOCATION );
865 int UtcDaliToolkitScrollBarGetIndicatorFixedHeightP(void)
867 ToolkitTestApplication application;
869 // Create a scroll bar
870 ScrollBar scrollBar = ScrollBar::New();
871 DALI_TEST_CHECK( scrollBar );
873 // Set the fixed indicator height to be 50.0f
874 scrollBar.SetIndicatorFixedHeight(50.0f);
876 // Check that the indicator size should be 50.0f
877 DALI_TEST_EQUALS( scrollBar.GetIndicatorFixedHeight(), 50.0f, TEST_LOCATION );
879 // Set the indicator height to be fixed to 25.0f
880 scrollBar.SetIndicatorFixedHeight(25.0f);
882 // Check that the indicator size should be 50.0f
883 DALI_TEST_EQUALS( scrollBar.GetIndicatorFixedHeight(), 25.0f, TEST_LOCATION );
888 int UtcDaliToolkitScrollBarSetIndicatorShowDurationP(void)
890 ToolkitTestApplication application;
892 // Create a scroll bar
893 ScrollBar scrollBar = ScrollBar::New();
894 DALI_TEST_CHECK( scrollBar );
896 Stage::GetCurrent().Add( scrollBar );
898 Actor indicator = scrollBar.GetScrollIndicator();
899 DALI_TEST_CHECK( indicator );
901 // Set the duration to show the indicator to be 0.35 second
902 scrollBar.SetIndicatorShowDuration(0.35);
903 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.35f, TEST_LOCATION );
905 // Make the indicator invisible
906 indicator.SetOpacity(0.0f);
909 application.SendNotification();
910 application.Render();
912 // Check that the indicator is invisible
913 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
915 // Show the indicator
916 scrollBar.ShowIndicator();
918 // Wait for 0.35 second
919 Wait(application, 350);
922 application.SendNotification();
923 application.Render();
925 // Check that the indicator is now visible
926 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
928 // Set the duration to show the indicator to be 0.75 second
929 scrollBar.SetIndicatorShowDuration(0.75);
930 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.75f, TEST_LOCATION );
932 // Make the indicator invisible
933 indicator.SetOpacity(0.0f);
936 application.SendNotification();
937 application.Render();
939 // Check that the indicator is invisible
940 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
942 // Show the indicator
943 scrollBar.ShowIndicator();
945 // Wait for 0.35 second first
946 Wait(application, 350);
949 application.SendNotification();
950 application.Render();
952 // Check that the indicator is not fully visible yet
953 DALI_TEST_CHECK( indicator.GetCurrentOpacity() != 1.0f );
955 // Wait for another 0.4 second
956 Wait(application, 400);
959 application.SendNotification();
960 application.Render();
962 // Check that the indicator is now fully visible
963 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
968 int UtcDaliToolkitScrollBarSetIndicatorShowDurationN(void)
970 ToolkitTestApplication application;
972 // Create a scroll bar
973 ScrollBar scrollBar = ScrollBar::New();
974 DALI_TEST_CHECK( scrollBar );
976 Stage::GetCurrent().Add( scrollBar );
978 Actor indicator = scrollBar.GetScrollIndicator();
979 DALI_TEST_CHECK( indicator );
981 // Get the default duration to show the indicator
982 float duration = scrollBar.GetIndicatorShowDuration();
984 // Check that the default duration is greater than 0
985 DALI_TEST_CHECK( duration > 0.0f );
987 // Make the indicator invisible
988 indicator.SetOpacity(0.0f);
991 application.SendNotification();
992 application.Render();
994 // Check that the indicator is invisible
995 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
997 // Show the indicator
998 scrollBar.ShowIndicator();
1000 // Wait for the specified duration
1001 Wait(application, duration * 1000);
1003 // Render and notify
1004 application.SendNotification();
1005 application.Render();
1007 // Check that the indicator is now visible
1008 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1010 // Now set the duration to show the indicator to be a negative value (which should be ignored and therefore means instant)
1011 scrollBar.SetIndicatorShowDuration(-0.25f);
1012 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), -0.25f, TEST_LOCATION );
1014 // Make the indicator invisible
1015 indicator.SetOpacity(0.0f);
1017 // Render and notify
1018 application.SendNotification();
1019 application.Render();
1021 // Check that the indicator is invisible
1022 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1024 // Show the indicator
1025 scrollBar.ShowIndicator();
1027 // Render and notify
1028 application.SendNotification();
1029 application.Render();
1031 // Check that the indicator becomes instantly visible in the next frame
1032 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1037 int UtcDaliToolkitScrollBarGetIndicatorShowDurationP(void)
1039 ToolkitTestApplication application;
1041 // Create a scroll bar
1042 ScrollBar scrollBar = ScrollBar::New();
1043 DALI_TEST_CHECK( scrollBar );
1045 // Set the duration to show the indicator to be 0.35 second
1046 scrollBar.SetIndicatorShowDuration(0.35f);
1048 // Check that the duration to show the indicator is 0.35 second
1049 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.35f, TEST_LOCATION );
1051 // Set the duration to show the indicator to be 0.75 second
1052 scrollBar.SetIndicatorShowDuration(0.75f);
1054 // Check that the duration to show the indicator is 0.75 second
1055 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.75f, TEST_LOCATION );
1060 int UtcDaliToolkitScrollBarSetIndicatorHideDurationP(void)
1062 ToolkitTestApplication application;
1064 // Create a scroll bar
1065 ScrollBar scrollBar = ScrollBar::New();
1066 DALI_TEST_CHECK( scrollBar );
1068 Stage::GetCurrent().Add( scrollBar );
1070 Actor indicator = scrollBar.GetScrollIndicator();
1071 DALI_TEST_CHECK( indicator );
1073 // Set the duration to hide the indicator to be 0.15 second
1074 scrollBar.SetIndicatorHideDuration(0.15f);
1075 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.15f, TEST_LOCATION );
1077 // Make the indicator visible
1078 indicator.SetOpacity(1.0f);
1080 // Render and notify
1081 application.SendNotification();
1082 application.Render();
1084 // Check that the indicator is visible
1085 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1087 // Hide the indicator
1088 scrollBar.HideIndicator();
1090 // Wait for 0.15 second
1091 Wait(application, 150);
1093 // Render and notify
1094 application.SendNotification();
1095 application.Render();
1097 // Check that the indicator is now invisible
1098 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1100 // Set the duration to hide the indicator to be 0.65 second
1101 scrollBar.SetIndicatorHideDuration(0.65f);
1102 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.65f, TEST_LOCATION );
1104 // Make the indicator visible
1105 indicator.SetOpacity(1.0f);
1107 // Render and notify
1108 application.SendNotification();
1109 application.Render();
1111 // Check that the indicator is visible
1112 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1114 // Hide the indicator
1115 scrollBar.HideIndicator();
1117 // Wait for 0.15 second first
1118 Wait(application, 150);
1120 // Render and notify
1121 application.SendNotification();
1122 application.Render();
1124 // Check that the indicator is not fully invisible yet
1125 DALI_TEST_CHECK( indicator.GetCurrentOpacity() != 0.0f );
1127 // Wait for another 0.5 second
1128 Wait(application, 500);
1130 // Render and notify
1131 application.SendNotification();
1132 application.Render();
1134 // Check that the indicator is now fully invisible
1135 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1140 int UtcDaliToolkitScrollBarSetIndicatorHideDurationN(void)
1142 ToolkitTestApplication application;
1144 // Create a scroll bar
1145 ScrollBar scrollBar = ScrollBar::New();
1146 DALI_TEST_CHECK( scrollBar );
1148 Stage::GetCurrent().Add( scrollBar );
1150 Actor indicator = scrollBar.GetScrollIndicator();
1151 DALI_TEST_CHECK( indicator );
1153 // Get the default duration to hide the indicator
1154 float duration = scrollBar.GetIndicatorHideDuration();
1156 // Check that the default duration is greater than 0
1157 DALI_TEST_CHECK( duration > 0.0f );
1159 // Make the indicator visible
1160 indicator.SetOpacity(1.0f);
1162 // Render and notify
1163 application.SendNotification();
1164 application.Render();
1166 // Check that the indicator is visible
1167 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1169 // Hide the indicator
1170 scrollBar.HideIndicator();
1172 // Wait for the specified duration
1173 Wait(application, duration * 1000);
1175 // Render and notify
1176 application.SendNotification();
1177 application.Render();
1179 // Check that the indicator is now invisible
1180 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1182 // Now set the duration to hide the indicator to be a negative value (which should be ignored and therefore means instant)
1183 scrollBar.SetIndicatorHideDuration(-0.25f);
1184 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), -0.25f, TEST_LOCATION );
1186 // Make the indicator visible
1187 indicator.SetOpacity(1.0f);
1189 // Render and notify
1190 application.SendNotification();
1191 application.Render();
1193 // Check that the indicator is visible
1194 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1196 // Hide the indicator
1197 scrollBar.HideIndicator();
1199 // Render and notify
1200 application.SendNotification();
1201 application.Render();
1203 // Check that the indicator becomes instantly invisible in the next frame
1204 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1209 int UtcDaliToolkitScrollBarGetIndicatorHideDurationP(void)
1211 ToolkitTestApplication application;
1213 // Create a scroll bar
1214 ScrollBar scrollBar = ScrollBar::New();
1215 DALI_TEST_CHECK( scrollBar );
1217 // Set the duration to hide the indicator to be 0.15 second
1218 scrollBar.SetIndicatorHideDuration(0.15f);
1220 // Check that the duration to hide the indicator is 0.15 second
1221 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.15f, TEST_LOCATION );
1223 // Set the duration to hide the indicator to be 0.65 second
1224 scrollBar.SetIndicatorHideDuration(0.65f);
1226 // Check that the duration to hide the indicator is 0.65 second
1227 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.65f, TEST_LOCATION );
1232 int UtcDaliToolkitScrollBarShowIndicatorP(void)
1234 ToolkitTestApplication application;
1236 // Create a scroll bar
1237 ScrollBar scrollBar = ScrollBar::New();
1238 DALI_TEST_CHECK( scrollBar );
1240 Stage::GetCurrent().Add( scrollBar );
1242 Actor indicator = scrollBar.GetScrollIndicator();
1243 DALI_TEST_CHECK( indicator );
1245 // Get the default duration to show the indicator
1246 float duration = scrollBar.GetIndicatorShowDuration();
1248 // Check that the default duration is greater than 0
1249 DALI_TEST_CHECK( duration > 0.0f );
1251 // Make the indicator invisible
1252 indicator.SetOpacity(0.0f);
1254 // Render and notify
1255 application.SendNotification();
1256 application.Render();
1258 // Check that the indicator is invisible
1259 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1261 // Show the indicator
1262 scrollBar.ShowIndicator();
1264 // Wait for the specified duration
1265 Wait(application, duration * 1000);
1267 // Render and notify
1268 application.SendNotification();
1269 application.Render();
1271 // Check that the indicator is now visible
1272 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1277 int UtcDaliToolkitScrollBarShowIndicatorN(void)
1279 ToolkitTestApplication application;
1281 // Create a scroll bar
1282 ScrollBar scrollBar = ScrollBar::New();
1283 DALI_TEST_CHECK( scrollBar );
1285 Stage::GetCurrent().Add( scrollBar );
1287 Actor indicator = scrollBar.GetScrollIndicator();
1288 DALI_TEST_CHECK( indicator );
1290 // Make the indicator initially visible
1291 indicator.SetOpacity(1.0f);
1293 // Render and notify
1294 application.SendNotification();
1295 application.Render();
1297 // Check that the indicator is initially visible
1298 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1300 // Get the default duration to show the indicator
1301 float duration = scrollBar.GetIndicatorShowDuration();
1303 // Check that the default duration is greater than 0
1304 DALI_TEST_CHECK( duration > 0.0f );
1306 // Show the indicator
1307 scrollBar.ShowIndicator();
1309 // Render and notify
1310 application.SendNotification();
1311 application.Render();
1313 // Check that the indicator is still visible in the very next frame
1314 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1319 int UtcDaliToolkitScrollBarHideIndicatorP(void)
1321 ToolkitTestApplication application;
1323 // Create a scroll bar
1324 ScrollBar scrollBar = ScrollBar::New();
1325 DALI_TEST_CHECK( scrollBar );
1327 Stage::GetCurrent().Add( scrollBar );
1329 Actor indicator = scrollBar.GetScrollIndicator();
1330 DALI_TEST_CHECK( indicator );
1332 // Get the default duration to hide the indicator
1333 float duration = scrollBar.GetIndicatorHideDuration();
1335 // Check that the default duration is greater than 0
1336 DALI_TEST_CHECK( duration > 0.0f );
1338 // Make the indicator visible
1339 indicator.SetOpacity(1.0f);
1341 // Render and notify
1342 application.SendNotification();
1343 application.Render();
1345 // Check that the indicator is visible
1346 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1348 // Hide the indicator
1349 scrollBar.HideIndicator();
1351 // Wait for the specified duration
1352 Wait(application, duration * 1000);
1354 // Render and notify
1355 application.SendNotification();
1356 application.Render();
1358 // Check that the indicator is now invisible
1359 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1364 int UtcDaliToolkitScrollBarHideIndicatorN(void)
1366 ToolkitTestApplication application;
1368 // Create a scroll bar
1369 ScrollBar scrollBar = ScrollBar::New();
1370 DALI_TEST_CHECK( scrollBar );
1372 Stage::GetCurrent().Add( scrollBar );
1374 Actor indicator = scrollBar.GetScrollIndicator();
1375 DALI_TEST_CHECK( indicator );
1377 // Make the indicator initially invisible
1378 indicator.SetOpacity(0.0f);
1380 // Render and notify
1381 application.SendNotification();
1382 application.Render();
1384 // Check that the indicator is initially invisible
1385 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1387 // Get the default duration to hide the indicator
1388 float duration = scrollBar.GetIndicatorHideDuration();
1390 // Check that the default duration is greater than 0
1391 DALI_TEST_CHECK( duration > 0.0f );
1393 // Hide the indicator
1394 scrollBar.HideIndicator();
1396 // Render and notify
1397 application.SendNotification();
1398 application.Render();
1400 // Check that the indicator is still invisible in the very next frame
1401 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1406 int UtcDaliToolkitScrollBarActionShowIndicator(void)
1408 ToolkitTestApplication application;
1410 // Create a scroll bar
1411 ScrollBar scrollBar = ScrollBar::New();
1412 DALI_TEST_CHECK( scrollBar );
1414 Stage::GetCurrent().Add( scrollBar );
1416 Actor indicator = scrollBar.GetScrollIndicator();
1417 DALI_TEST_CHECK( indicator );
1419 // Get the default duration to hide the indicator
1420 float duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_SHOW_DURATION );
1422 // Check that the default duration is greater than 0
1423 DALI_TEST_CHECK( duration > 0.0f );
1425 // Make the indicator invisible
1426 indicator.SetOpacity(0.0f);
1428 // Render and notify
1429 application.SendNotification();
1430 application.Render();
1432 // Check that the indicator is invisible
1433 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1435 // Do the "ShowIndicator" action
1436 Property::Map emptyMap;
1437 scrollBar.DoAction( "ShowIndicator", emptyMap );
1439 // Wait for the specified duration
1440 Wait(application, duration * 1000);
1442 // Render and notify
1443 application.SendNotification();
1444 application.Render();
1446 // Check that the indicator is now visible
1447 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1452 int UtcDaliToolkitScrollBarActionHideIndicator(void)
1454 ToolkitTestApplication application;
1456 // Create a scroll bar
1457 ScrollBar scrollBar = ScrollBar::New();
1458 DALI_TEST_CHECK( scrollBar );
1460 Stage::GetCurrent().Add( scrollBar );
1462 Actor indicator = scrollBar.GetScrollIndicator();
1463 DALI_TEST_CHECK( indicator );
1465 // Get the default duration to hide the indicator
1466 float duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_HIDE_DURATION );
1468 // Check that the default duration is greater than 0
1469 DALI_TEST_CHECK( duration > 0.0f );
1471 // Make the indicator visible
1472 indicator.SetOpacity(1.0f);
1474 // Render and notify
1475 application.SendNotification();
1476 application.Render();
1478 // Check that the indicator is visible
1479 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1481 // Do the "HideIndicator" action
1482 Property::Map emptyMap;
1483 scrollBar.DoAction( "HideIndicator", emptyMap );
1485 // Wait for the specified duration
1486 Wait(application, duration * 1000);
1488 // Render and notify
1489 application.SendNotification();
1490 application.Render();
1492 // Check that the indicator is now invisible
1493 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1498 int UtcDaliToolkitScrollBarActionShowTransientIndicator(void)
1500 ToolkitTestApplication application;
1502 // Create a scroll bar
1503 ScrollBar scrollBar = ScrollBar::New();
1504 DALI_TEST_CHECK( scrollBar );
1506 Stage::GetCurrent().Add( scrollBar );
1508 Actor indicator = scrollBar.GetScrollIndicator();
1509 DALI_TEST_CHECK( indicator );
1511 // Get the default duration to hide the indicator
1512 float duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_SHOW_DURATION );
1514 // Check that the default duration is greater than 0
1515 DALI_TEST_CHECK( duration > 0.0f );
1517 // Make the indicator invisible
1518 indicator.SetOpacity(0.0f);
1520 // Render and notify
1521 application.SendNotification();
1522 application.Render();
1524 // Check that the indicator is invisible
1525 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1527 // Do the "ShowIndicator" action
1528 Property::Map emptyMap;
1529 scrollBar.DoAction( "ShowTransientIndicator", emptyMap );
1531 // Wait for the specified duration
1532 Wait(application, duration * 1000);
1534 // Render and notify
1535 application.SendNotification();
1536 application.Render();
1538 // Check that the indicator is now visible
1539 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1541 // Get the default duration to hide the indicator
1542 float hideDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_HIDE_DURATION );
1543 float transientDuration = scrollBar.GetProperty<float>( DevelScrollBar::Property::INDICATOR_TRANSIENT_DURATION );
1544 float totalVisibleDuration = hideDuration + transientDuration;
1546 // Check that the default duration is greater than 0
1547 DALI_TEST_CHECK( totalVisibleDuration > 0.0f );
1549 // Wait for the specified duration
1550 Wait(application, totalVisibleDuration * 1000);
1552 // Render and notify
1553 application.SendNotification();
1554 application.Render();
1556 // Check that the indicator is now invisible
1557 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1562 int UtcDaliToolkitScrollBarActionShowTransientIndicatorImmediate(void)
1564 ToolkitTestApplication application;
1566 // Create a scroll bar
1567 ScrollBar scrollBar = ScrollBar::New();
1568 DALI_TEST_CHECK( scrollBar );
1570 Stage::GetCurrent().Add( scrollBar );
1572 Actor indicator = scrollBar.GetScrollIndicator();
1573 DALI_TEST_CHECK( indicator );
1575 // Make the indicator invisible
1576 indicator.SetOpacity(0.0f);
1578 // Don't use a show animation; the indicator should appear immediately
1579 scrollBar.SetProperty( ScrollBar::Property::INDICATOR_SHOW_DURATION, 0.0f );
1580 float duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_SHOW_DURATION );
1581 DALI_TEST_EQUALS( duration, 0.0f, TEST_LOCATION );
1583 // Render and notify
1584 application.SendNotification();
1585 application.Render();
1587 // Do the "ShowIndicator" action
1588 Property::Map emptyMap;
1589 scrollBar.DoAction( "ShowTransientIndicator", emptyMap );
1591 // Wait for the specified duration
1594 // Render and notify
1595 application.SendNotification();
1596 application.Render();
1598 // Check that the indicator is now visible
1599 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1601 // Get the default duration to hide the indicator
1602 float hideDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_HIDE_DURATION );
1603 float transientDuration = scrollBar.GetProperty<float>( DevelScrollBar::Property::INDICATOR_TRANSIENT_DURATION );
1604 float totalVisibleDuration = hideDuration + transientDuration;
1606 // Check that the default duration is greater than 0
1607 DALI_TEST_CHECK( totalVisibleDuration > 0.0f );
1609 // Wait for the specified duration
1610 Wait(application, totalVisibleDuration * 1000);
1612 // Render and notify
1613 application.SendNotification();
1614 application.Render();
1616 // Check that the indicator is now invisible
1617 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1622 int UtcDaliToolkitScrollBarActionShowTransientIndicatorDuringHide(void)
1624 ToolkitTestApplication application;
1626 // Create a scroll bar
1627 ScrollBar scrollBar = ScrollBar::New();
1628 DALI_TEST_CHECK( scrollBar );
1630 Stage::GetCurrent().Add( scrollBar );
1632 Actor indicator = scrollBar.GetScrollIndicator();
1633 DALI_TEST_CHECK( indicator );
1635 // Get the default duration to hide the indicator
1636 float duration = scrollBar.GetIndicatorHideDuration();
1638 // Check that the default duration is greater than 0
1639 DALI_TEST_CHECK( duration > 0.0f );
1641 // Make the indicator visible
1642 indicator.SetOpacity(1.0f);
1644 // Render and notify
1645 application.SendNotification();
1646 application.Render();
1648 // Check that the indicator is visible
1649 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1651 // Hide the indicator
1652 scrollBar.HideIndicator();
1654 // Wait for half the specified duration
1655 Wait(application, duration * 0.5f * 1000);
1657 // Render and notify
1658 application.SendNotification();
1659 application.Render();
1661 // Check that the indicator is now partially hidden
1662 DALI_TEST_CHECK( indicator.GetCurrentOpacity() < 1.0f );
1664 // Now interrupt the Hide with a DoAction( "ShowTransientIndicator" )
1666 // Get the default duration to hide the indicator
1667 duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_SHOW_DURATION );
1669 // Check that the default duration is greater than 0
1670 DALI_TEST_CHECK( duration > 0.0f );
1672 // Do the "ShowIndicator" action
1673 Property::Map emptyMap;
1674 scrollBar.DoAction( "ShowTransientIndicator", emptyMap );
1676 // Wait for the specified duration
1677 Wait(application, duration * 1000);
1679 // Render and notify
1680 application.SendNotification();
1681 application.Render();
1683 // Check that the indicator is now visible
1684 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1686 // Get the default duration to hide the indicator
1687 float hideDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_HIDE_DURATION );
1688 float transientDuration = scrollBar.GetProperty<float>( DevelScrollBar::Property::INDICATOR_TRANSIENT_DURATION );
1689 float totalVisibleDuration = hideDuration + transientDuration;
1691 // Check that the default duration is greater than 0
1692 DALI_TEST_CHECK( totalVisibleDuration > 0.0f );
1694 // Wait for the specified duration
1695 Wait(application, totalVisibleDuration * 1000);
1697 // Render and notify
1698 application.SendNotification();
1699 application.Render();
1701 // Check that the indicator is now invisible
1702 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1707 int UtcDaliToolkitScrollBarPanFinishedSignalP(void)
1709 ToolkitTestApplication application;
1711 // Create a vertical scroll bar
1712 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1713 DALI_TEST_CHECK( scrollBar );
1715 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
1716 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1717 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
1719 // Set the indicator height to be fixed to 50.0f
1720 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
1721 scrollBar.SetIndicatorFixedHeight(50.0f);
1723 Stage::GetCurrent().Add( scrollBar );
1725 // Connect the pan finished signal
1726 ConnectionTracker connectionTracker;
1727 bool panFinished = false;
1728 scrollBar.PanFinishedSignal().Connect( &OnPanFinished );
1729 scrollBar.ConnectSignal( &connectionTracker, "panFinished", CallbackFunctor(&panFinished));
1731 // Render and notify
1732 application.SendNotification();
1733 application.Render();
1735 // Create a source actor that owns the scroll properties required by the scroll bar
1736 Actor sourceActor = Actor::New();
1737 Stage::GetCurrent().Add( sourceActor );
1739 // Register the scroll properties
1740 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1741 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1742 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
1743 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
1745 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1746 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1747 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1748 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1750 // Set the source of the scroll position properties.
1751 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1753 // Render and notify
1754 application.SendNotification();
1755 application.Render();
1757 // Perform a swipe gesture on the indicator
1758 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20);
1759 DALI_TEST_EQUALS( gOnPanFinishedCalled, true, TEST_LOCATION );
1760 DALI_TEST_EQUALS( panFinished, true, TEST_LOCATION );
1765 int UtcDaliToolkitScrollBarPanFinishedSignalN(void)
1767 ToolkitTestApplication application;
1769 // Create a vertical scroll bar
1770 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1771 DALI_TEST_CHECK( scrollBar );
1773 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
1774 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1775 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
1777 // Set the indicator height to be fixed to 50.0f
1778 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
1779 scrollBar.SetIndicatorFixedHeight(50.0f);
1781 Stage::GetCurrent().Add( scrollBar );
1783 // Connect the pan finished signal
1784 ConnectionTracker connectionTracker;
1785 bool panFinished = false;
1786 scrollBar.PanFinishedSignal().Connect( &OnPanFinished );
1787 scrollBar.ConnectSignal( &connectionTracker, "panFinished", CallbackFunctor(&panFinished));
1789 // Render and notify
1790 application.SendNotification();
1791 application.Render();
1793 // Perform a vertical swipe gesture on the indicator when there is no source object set on the scroll bar
1794 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20);
1795 DALI_TEST_EQUALS( gOnPanFinishedCalled, false, TEST_LOCATION );
1797 // Create a source actor that owns the scroll properties required by the scroll bar
1798 Actor sourceActor = Actor::New();
1799 Stage::GetCurrent().Add( sourceActor );
1801 // Register the scroll properties
1802 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1803 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1804 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
1805 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
1807 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1808 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1809 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1810 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1812 // Set the source of the scroll position properties.
1813 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1815 // Render and notify
1816 application.SendNotification();
1817 application.Render();
1819 // Perform a swipe gesture on the scroll bar but not on the indicator
1820 PerformGestureSwipe(application, Vector2(1.0f, 780.0f), Vector2(Vector2::YAXIS * -1.0f), 20);
1821 DALI_TEST_EQUALS( gOnPanFinishedCalled, false, TEST_LOCATION );
1822 DALI_TEST_EQUALS( panFinished, false, TEST_LOCATION );
1824 // Perform a swipe gesture on the indicator
1825 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20);
1826 DALI_TEST_EQUALS( gOnPanFinishedCalled, true, TEST_LOCATION );
1827 DALI_TEST_EQUALS( panFinished, true, TEST_LOCATION );
1832 int UtcDaliToolkitScrollBarScrollPositionIntervalReachedSignalP(void)
1834 ToolkitTestApplication application;
1836 // Create a vertical scroll bar
1837 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1838 DALI_TEST_CHECK( scrollBar );
1840 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
1841 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1842 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
1844 Stage::GetCurrent().Add( scrollBar );
1845 ConnectionTracker connectionTracker;
1847 // Connect to the ScrollPositionIntervalReached signal
1848 bool intervalReached = false;
1849 scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
1850 scrollBar.ConnectSignal( &connectionTracker, "scrollPositionIntervalReached", CallbackFunctor(&intervalReached));
1852 // Render and notify
1853 application.SendNotification();
1854 application.Render();
1856 // Create a source actor that owns the scroll properties required by the scroll bar
1857 Actor sourceActor = Actor::New();
1858 Stage::GetCurrent().Add( sourceActor );
1860 // Register the scroll properties
1861 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1862 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1863 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 800.0f );
1864 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 2000.0f );
1866 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1867 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1868 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1869 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1871 // Set the source of the scroll position properties.
1872 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1874 // Render and notify
1875 application.SendNotification();
1876 application.Render();
1878 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
1879 Dali::Vector<float> positionIntervals;
1880 for( size_t i = 0; i != 10; ++i )
1882 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
1884 scrollBar.SetScrollPositionIntervals(positionIntervals);
1886 // Render and notify
1887 application.SendNotification();
1888 application.Render();
1891 gOnScrollPositionIntervalReachedSignalCalled = false;
1893 // Animate the scroll position to cross the specified value
1894 Animation animation = Animation::New(0.1f);
1895 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
1898 // Wait for 0.1 second
1899 Wait(application, 100);
1901 // Check that the signal callback is called
1902 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1903 DALI_TEST_EQUALS( intervalReached, true, TEST_LOCATION );
1906 gOnScrollPositionIntervalReachedSignalCalled = false;
1907 intervalReached = false;
1909 // Rest and clear the animation
1913 // Animate the scroll position to cross another specified value
1914 animation = Animation::New(0.1f);
1915 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -170.0f );
1918 // Wait for 0.1 second
1919 Wait(application, 100);
1921 // Check that the signal callback is called
1922 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1923 DALI_TEST_EQUALS( intervalReached, true, TEST_LOCATION );
1926 gOnScrollPositionIntervalReachedSignalCalled = false;
1927 intervalReached = false;
1929 // Rest and clear the animation
1933 // Animate the scroll position back to the previous value
1934 animation = Animation::New(0.1f);
1935 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
1938 // Wait for 0.1 second
1939 Wait(application, 100);
1941 // Check that the signal callback is called
1942 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1943 DALI_TEST_EQUALS( intervalReached, true, TEST_LOCATION );
1948 int UtcDaliToolkitScrollBarScrollPositionIntervalReachedSignalN(void)
1950 ToolkitTestApplication application;
1952 // Create a vertical scroll bar
1953 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1954 DALI_TEST_CHECK( scrollBar );
1956 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
1957 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1958 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
1960 Stage::GetCurrent().Add( scrollBar );
1962 // Connect to the ScrollPositionIntervalReached signal
1963 scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
1965 // Render and notify
1966 application.SendNotification();
1967 application.Render();
1969 // Create a source actor that owns the scroll properties required by the scroll bar
1970 Actor sourceActor = Actor::New();
1971 Stage::GetCurrent().Add( sourceActor );
1973 // Register the scroll properties
1974 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1975 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1976 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 800.0f );
1977 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 2000.0f );
1979 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1980 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1981 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1982 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1984 // Set the source of the scroll position properties.
1985 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1987 // Render and notify
1988 application.SendNotification();
1989 application.Render();
1991 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
1992 Dali::Vector<float> positionIntervals;
1993 for( size_t i = 0; i != 10; ++i )
1995 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
1997 scrollBar.SetScrollPositionIntervals(positionIntervals);
1999 // Render and notify
2000 application.SendNotification();
2001 application.Render();
2004 gOnScrollPositionIntervalReachedSignalCalled = false;
2006 // Animate the scroll position not to cross the specified value
2007 Animation animation = Animation::New(0.1f);
2008 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -70.0f );
2011 // Wait for 0.1 second
2012 Wait(application, 100);
2014 // Check that the signal callback is not called
2015 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, false, TEST_LOCATION );
2017 // Rest and clear the animation
2021 // Animate the scroll position to cross another specified value
2022 animation = Animation::New(0.1f);
2023 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
2026 // Wait for 0.1 second
2027 Wait(application, 100);
2029 // Check that the signal callback is called
2030 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );