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 );
704 int UtcDaliToolkitScrollBarGetScrollDirectionP(void)
706 ToolkitTestApplication application;
708 // Create a vertical scroll bar
709 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
710 DALI_TEST_CHECK( scrollBar );
711 DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::Vertical );
713 // Change the direction of scroll bar to horizontal
714 scrollBar.SetScrollDirection(ScrollBar::Horizontal);
715 DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::Horizontal );
720 int UtcDaliToolkitScrollBarSetIndicatorHeightPolicyP(void)
722 ToolkitTestApplication application;
724 // Create a scroll bar
725 ScrollBar scrollBar = ScrollBar::New();
726 DALI_TEST_CHECK( scrollBar );
728 float scrollBarHeight = 100.0f;
729 scrollBar.SetSize(20.0f, scrollBarHeight, 0.0f);
730 Stage::GetCurrent().Add( scrollBar );
732 // Create a source actor that owns the scroll properties required by the scroll bar
733 Actor sourceActor = Actor::New();
734 Stage::GetCurrent().Add( sourceActor );
736 // Register the scroll properties
737 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
738 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
739 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
740 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
742 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
743 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
744 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
745 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
747 // Set the source of the scroll position properties.
748 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
751 application.SendNotification();
752 application.Render();
754 Actor indicator = scrollBar.GetScrollIndicator();
755 DALI_TEST_CHECK( indicator );
757 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
758 // i.e. The bigger the content size, the smaller the indicator size
759 float indicatorHeight = indicator.GetCurrentSize().y;
760 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
762 // Set the indicator height to be fixed to 50.0f
763 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
764 scrollBar.SetIndicatorFixedHeight(50.0f);
766 Property::Value value = scrollBar.GetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY);
767 DALI_TEST_EQUALS(value.Get<std::string>(), "Fixed", TEST_LOCATION );
770 application.SendNotification();
771 application.Render();
773 // Check that the indicator size should be 50.0f
774 indicatorHeight = indicator.GetCurrentSize().y;
775 DALI_TEST_EQUALS( indicatorHeight, 50.0f, TEST_LOCATION );
777 // Set the indicator height to be variable
778 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Variable);
779 value = scrollBar.GetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY);
780 DALI_TEST_EQUALS(value.Get<std::string>(), "Variable", TEST_LOCATION );
783 application.SendNotification();
784 application.Render();
786 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
787 indicatorHeight = indicator.GetCurrentSize().y;
788 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
793 int UtcDaliToolkitScrollBarGetIndicatorHeightPolicyP(void)
795 ToolkitTestApplication application;
797 // Create a scroll bar
798 ScrollBar scrollBar = ScrollBar::New();
799 DALI_TEST_CHECK( scrollBar );
801 // Set the indicator height to be fixed
802 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
803 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Fixed, TEST_LOCATION );
805 // Set the indicator height to be variable
806 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Variable);
807 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Variable, TEST_LOCATION );
812 int UtcDaliToolkitScrollBarSetIndicatorFixedHeightP(void)
814 ToolkitTestApplication application;
816 // Create a scroll bar
817 ScrollBar scrollBar = ScrollBar::New();
818 DALI_TEST_CHECK( scrollBar );
820 float scrollBarHeight = 100.0f;
821 scrollBar.SetSize(20.0f, scrollBarHeight, 0.0f);
822 Stage::GetCurrent().Add( scrollBar );
824 Actor indicator = scrollBar.GetScrollIndicator();
825 DALI_TEST_CHECK( indicator );
827 // Set the indicator height to be fixed to 50.0f
828 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
829 scrollBar.SetIndicatorFixedHeight(50.0f);
832 application.SendNotification();
833 application.Render();
835 // Check that the indicator size should be 50.0f
836 DALI_TEST_EQUALS( indicator.GetCurrentSize().y, 50.0f, TEST_LOCATION );
838 // Set the indicator height to be fixed to 25.0f
839 scrollBar.SetIndicatorFixedHeight(25.0f);
842 application.SendNotification();
843 application.Render();
845 // Check that the indicator size should be 25.0f
846 DALI_TEST_EQUALS( indicator.GetCurrentSize().y, 25.0f, TEST_LOCATION );
851 int UtcDaliToolkitScrollBarGetIndicatorFixedHeightP(void)
853 ToolkitTestApplication application;
855 // Create a scroll bar
856 ScrollBar scrollBar = ScrollBar::New();
857 DALI_TEST_CHECK( scrollBar );
859 // Set the fixed indicator height to be 50.0f
860 scrollBar.SetIndicatorFixedHeight(50.0f);
862 // Check that the indicator size should be 50.0f
863 DALI_TEST_EQUALS( scrollBar.GetIndicatorFixedHeight(), 50.0f, TEST_LOCATION );
865 // Set the indicator height to be fixed to 25.0f
866 scrollBar.SetIndicatorFixedHeight(25.0f);
868 // Check that the indicator size should be 50.0f
869 DALI_TEST_EQUALS( scrollBar.GetIndicatorFixedHeight(), 25.0f, TEST_LOCATION );
874 int UtcDaliToolkitScrollBarSetIndicatorShowDurationP(void)
876 ToolkitTestApplication application;
878 // Create a scroll bar
879 ScrollBar scrollBar = ScrollBar::New();
880 DALI_TEST_CHECK( scrollBar );
882 Stage::GetCurrent().Add( scrollBar );
884 Actor indicator = scrollBar.GetScrollIndicator();
885 DALI_TEST_CHECK( indicator );
887 // Set the duration to show the indicator to be 0.35 second
888 scrollBar.SetIndicatorShowDuration(0.35);
889 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.35f, TEST_LOCATION );
891 // Make the indicator invisible
892 indicator.SetOpacity(0.0f);
895 application.SendNotification();
896 application.Render();
898 // Check that the indicator is invisible
899 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
901 // Show the indicator
902 scrollBar.ShowIndicator();
904 // Wait for 0.35 second
905 Wait(application, 350);
908 application.SendNotification();
909 application.Render();
911 // Check that the indicator is now visible
912 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
914 // Set the duration to show the indicator to be 0.75 second
915 scrollBar.SetIndicatorShowDuration(0.75);
916 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.75f, TEST_LOCATION );
918 // Make the indicator invisible
919 indicator.SetOpacity(0.0f);
922 application.SendNotification();
923 application.Render();
925 // Check that the indicator is invisible
926 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
928 // Show the indicator
929 scrollBar.ShowIndicator();
931 // Wait for 0.35 second first
932 Wait(application, 350);
935 application.SendNotification();
936 application.Render();
938 // Check that the indicator is not fully visible yet
939 DALI_TEST_CHECK( indicator.GetCurrentOpacity() != 1.0f );
941 // Wait for another 0.4 second
942 Wait(application, 400);
945 application.SendNotification();
946 application.Render();
948 // Check that the indicator is now fully visible
949 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
954 int UtcDaliToolkitScrollBarSetIndicatorShowDurationN(void)
956 ToolkitTestApplication application;
958 // Create a scroll bar
959 ScrollBar scrollBar = ScrollBar::New();
960 DALI_TEST_CHECK( scrollBar );
962 Stage::GetCurrent().Add( scrollBar );
964 Actor indicator = scrollBar.GetScrollIndicator();
965 DALI_TEST_CHECK( indicator );
967 // Get the default duration to show the indicator
968 float duration = scrollBar.GetIndicatorShowDuration();
970 // Check that the default duration is greater than 0
971 DALI_TEST_CHECK( duration > 0.0f );
973 // Make the indicator invisible
974 indicator.SetOpacity(0.0f);
977 application.SendNotification();
978 application.Render();
980 // Check that the indicator is invisible
981 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
983 // Show the indicator
984 scrollBar.ShowIndicator();
986 // Wait for the specified duration
987 Wait(application, duration * 1000);
990 application.SendNotification();
991 application.Render();
993 // Check that the indicator is now visible
994 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
996 // Now set the duration to show the indicator to be a negative value (which should be ignored and therefore means instant)
997 scrollBar.SetIndicatorShowDuration(-0.25f);
998 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), -0.25f, TEST_LOCATION );
1000 // Make the indicator invisible
1001 indicator.SetOpacity(0.0f);
1003 // Render and notify
1004 application.SendNotification();
1005 application.Render();
1007 // Check that the indicator is invisible
1008 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1010 // Show the indicator
1011 scrollBar.ShowIndicator();
1013 // Render and notify
1014 application.SendNotification();
1015 application.Render();
1017 // Check that the indicator becomes instantly visible in the next frame
1018 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1023 int UtcDaliToolkitScrollBarGetIndicatorShowDurationP(void)
1025 ToolkitTestApplication application;
1027 // Create a scroll bar
1028 ScrollBar scrollBar = ScrollBar::New();
1029 DALI_TEST_CHECK( scrollBar );
1031 // Set the duration to show the indicator to be 0.35 second
1032 scrollBar.SetIndicatorShowDuration(0.35f);
1034 // Check that the duration to show the indicator is 0.35 second
1035 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.35f, TEST_LOCATION );
1037 // Set the duration to show the indicator to be 0.75 second
1038 scrollBar.SetIndicatorShowDuration(0.75f);
1040 // Check that the duration to show the indicator is 0.75 second
1041 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.75f, TEST_LOCATION );
1046 int UtcDaliToolkitScrollBarSetIndicatorHideDurationP(void)
1048 ToolkitTestApplication application;
1050 // Create a scroll bar
1051 ScrollBar scrollBar = ScrollBar::New();
1052 DALI_TEST_CHECK( scrollBar );
1054 Stage::GetCurrent().Add( scrollBar );
1056 Actor indicator = scrollBar.GetScrollIndicator();
1057 DALI_TEST_CHECK( indicator );
1059 // Set the duration to hide the indicator to be 0.15 second
1060 scrollBar.SetIndicatorHideDuration(0.15f);
1061 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.15f, TEST_LOCATION );
1063 // Make the indicator visible
1064 indicator.SetOpacity(1.0f);
1066 // Render and notify
1067 application.SendNotification();
1068 application.Render();
1070 // Check that the indicator is visible
1071 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1073 // Hide the indicator
1074 scrollBar.HideIndicator();
1076 // Wait for 0.15 second
1077 Wait(application, 150);
1079 // Render and notify
1080 application.SendNotification();
1081 application.Render();
1083 // Check that the indicator is now invisible
1084 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1086 // Set the duration to hide the indicator to be 0.65 second
1087 scrollBar.SetIndicatorHideDuration(0.65f);
1088 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.65f, TEST_LOCATION );
1090 // Make the indicator visible
1091 indicator.SetOpacity(1.0f);
1093 // Render and notify
1094 application.SendNotification();
1095 application.Render();
1097 // Check that the indicator is visible
1098 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1100 // Hide the indicator
1101 scrollBar.HideIndicator();
1103 // Wait for 0.15 second first
1104 Wait(application, 150);
1106 // Render and notify
1107 application.SendNotification();
1108 application.Render();
1110 // Check that the indicator is not fully invisible yet
1111 DALI_TEST_CHECK( indicator.GetCurrentOpacity() != 0.0f );
1113 // Wait for another 0.5 second
1114 Wait(application, 500);
1116 // Render and notify
1117 application.SendNotification();
1118 application.Render();
1120 // Check that the indicator is now fully invisible
1121 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1126 int UtcDaliToolkitScrollBarSetIndicatorHideDurationN(void)
1128 ToolkitTestApplication application;
1130 // Create a scroll bar
1131 ScrollBar scrollBar = ScrollBar::New();
1132 DALI_TEST_CHECK( scrollBar );
1134 Stage::GetCurrent().Add( scrollBar );
1136 Actor indicator = scrollBar.GetScrollIndicator();
1137 DALI_TEST_CHECK( indicator );
1139 // Get the default duration to hide the indicator
1140 float duration = scrollBar.GetIndicatorHideDuration();
1142 // Check that the default duration is greater than 0
1143 DALI_TEST_CHECK( duration > 0.0f );
1145 // Make the indicator visible
1146 indicator.SetOpacity(1.0f);
1148 // Render and notify
1149 application.SendNotification();
1150 application.Render();
1152 // Check that the indicator is visible
1153 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1155 // Hide the indicator
1156 scrollBar.HideIndicator();
1158 // Wait for the specified duration
1159 Wait(application, duration * 1000);
1161 // Render and notify
1162 application.SendNotification();
1163 application.Render();
1165 // Check that the indicator is now invisible
1166 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1168 // Now set the duration to hide the indicator to be a negative value (which should be ignored and therefore means instant)
1169 scrollBar.SetIndicatorHideDuration(-0.25f);
1170 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), -0.25f, TEST_LOCATION );
1172 // Make the indicator visible
1173 indicator.SetOpacity(1.0f);
1175 // Render and notify
1176 application.SendNotification();
1177 application.Render();
1179 // Check that the indicator is visible
1180 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1182 // Hide the indicator
1183 scrollBar.HideIndicator();
1185 // Render and notify
1186 application.SendNotification();
1187 application.Render();
1189 // Check that the indicator becomes instantly invisible in the next frame
1190 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1195 int UtcDaliToolkitScrollBarGetIndicatorHideDurationP(void)
1197 ToolkitTestApplication application;
1199 // Create a scroll bar
1200 ScrollBar scrollBar = ScrollBar::New();
1201 DALI_TEST_CHECK( scrollBar );
1203 // Set the duration to hide the indicator to be 0.15 second
1204 scrollBar.SetIndicatorHideDuration(0.15f);
1206 // Check that the duration to hide the indicator is 0.15 second
1207 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.15f, TEST_LOCATION );
1209 // Set the duration to hide the indicator to be 0.65 second
1210 scrollBar.SetIndicatorHideDuration(0.65f);
1212 // Check that the duration to hide the indicator is 0.65 second
1213 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.65f, TEST_LOCATION );
1218 int UtcDaliToolkitScrollBarShowIndicatorP(void)
1220 ToolkitTestApplication application;
1222 // Create a scroll bar
1223 ScrollBar scrollBar = ScrollBar::New();
1224 DALI_TEST_CHECK( scrollBar );
1226 Stage::GetCurrent().Add( scrollBar );
1228 Actor indicator = scrollBar.GetScrollIndicator();
1229 DALI_TEST_CHECK( indicator );
1231 // Get the default duration to show the indicator
1232 float duration = scrollBar.GetIndicatorShowDuration();
1234 // Check that the default duration is greater than 0
1235 DALI_TEST_CHECK( duration > 0.0f );
1237 // Make the indicator invisible
1238 indicator.SetOpacity(0.0f);
1240 // Render and notify
1241 application.SendNotification();
1242 application.Render();
1244 // Check that the indicator is invisible
1245 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1247 // Show the indicator
1248 scrollBar.ShowIndicator();
1250 // Wait for the specified duration
1251 Wait(application, duration * 1000);
1253 // Render and notify
1254 application.SendNotification();
1255 application.Render();
1257 // Check that the indicator is now visible
1258 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1263 int UtcDaliToolkitScrollBarShowIndicatorN(void)
1265 ToolkitTestApplication application;
1267 // Create a scroll bar
1268 ScrollBar scrollBar = ScrollBar::New();
1269 DALI_TEST_CHECK( scrollBar );
1271 Stage::GetCurrent().Add( scrollBar );
1273 Actor indicator = scrollBar.GetScrollIndicator();
1274 DALI_TEST_CHECK( indicator );
1276 // Make the indicator initially visible
1277 indicator.SetOpacity(1.0f);
1279 // Render and notify
1280 application.SendNotification();
1281 application.Render();
1283 // Check that the indicator is initially visible
1284 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1286 // Get the default duration to show the indicator
1287 float duration = scrollBar.GetIndicatorShowDuration();
1289 // Check that the default duration is greater than 0
1290 DALI_TEST_CHECK( duration > 0.0f );
1292 // Show the indicator
1293 scrollBar.ShowIndicator();
1295 // Render and notify
1296 application.SendNotification();
1297 application.Render();
1299 // Check that the indicator is still visible in the very next frame
1300 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1305 int UtcDaliToolkitScrollBarHideIndicatorP(void)
1307 ToolkitTestApplication application;
1309 // Create a scroll bar
1310 ScrollBar scrollBar = ScrollBar::New();
1311 DALI_TEST_CHECK( scrollBar );
1313 Stage::GetCurrent().Add( scrollBar );
1315 Actor indicator = scrollBar.GetScrollIndicator();
1316 DALI_TEST_CHECK( indicator );
1318 // Get the default duration to hide the indicator
1319 float duration = scrollBar.GetIndicatorHideDuration();
1321 // Check that the default duration is greater than 0
1322 DALI_TEST_CHECK( duration > 0.0f );
1324 // Make the indicator visible
1325 indicator.SetOpacity(1.0f);
1327 // Render and notify
1328 application.SendNotification();
1329 application.Render();
1331 // Check that the indicator is visible
1332 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1334 // Hide the indicator
1335 scrollBar.HideIndicator();
1337 // Wait for the specified duration
1338 Wait(application, duration * 1000);
1340 // Render and notify
1341 application.SendNotification();
1342 application.Render();
1344 // Check that the indicator is now invisible
1345 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1350 int UtcDaliToolkitScrollBarHideIndicatorN(void)
1352 ToolkitTestApplication application;
1354 // Create a scroll bar
1355 ScrollBar scrollBar = ScrollBar::New();
1356 DALI_TEST_CHECK( scrollBar );
1358 Stage::GetCurrent().Add( scrollBar );
1360 Actor indicator = scrollBar.GetScrollIndicator();
1361 DALI_TEST_CHECK( indicator );
1363 // Make the indicator initially invisible
1364 indicator.SetOpacity(0.0f);
1366 // Render and notify
1367 application.SendNotification();
1368 application.Render();
1370 // Check that the indicator is initially invisible
1371 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1373 // Get the default duration to hide the indicator
1374 float duration = scrollBar.GetIndicatorHideDuration();
1376 // Check that the default duration is greater than 0
1377 DALI_TEST_CHECK( duration > 0.0f );
1379 // Hide the indicator
1380 scrollBar.HideIndicator();
1382 // Render and notify
1383 application.SendNotification();
1384 application.Render();
1386 // Check that the indicator is still invisible in the very next frame
1387 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1392 int UtcDaliToolkitScrollBarActionShowIndicator(void)
1394 ToolkitTestApplication application;
1396 // Create a scroll bar
1397 ScrollBar scrollBar = ScrollBar::New();
1398 DALI_TEST_CHECK( scrollBar );
1400 Stage::GetCurrent().Add( scrollBar );
1402 Actor indicator = scrollBar.GetScrollIndicator();
1403 DALI_TEST_CHECK( indicator );
1405 // Get the default duration to hide the indicator
1406 float duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_SHOW_DURATION );
1408 // Check that the default duration is greater than 0
1409 DALI_TEST_CHECK( duration > 0.0f );
1411 // Make the indicator invisible
1412 indicator.SetOpacity(0.0f);
1414 // Render and notify
1415 application.SendNotification();
1416 application.Render();
1418 // Check that the indicator is invisible
1419 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1421 // Do the "ShowIndicator" action
1422 Property::Map emptyMap;
1423 scrollBar.DoAction( "ShowIndicator", emptyMap );
1425 // Wait for the specified duration
1426 Wait(application, duration * 1000);
1428 // Render and notify
1429 application.SendNotification();
1430 application.Render();
1432 // Check that the indicator is now visible
1433 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1438 int UtcDaliToolkitScrollBarActionHideIndicator(void)
1440 ToolkitTestApplication application;
1442 // Create a scroll bar
1443 ScrollBar scrollBar = ScrollBar::New();
1444 DALI_TEST_CHECK( scrollBar );
1446 Stage::GetCurrent().Add( scrollBar );
1448 Actor indicator = scrollBar.GetScrollIndicator();
1449 DALI_TEST_CHECK( indicator );
1451 // Get the default duration to hide the indicator
1452 float duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_HIDE_DURATION );
1454 // Check that the default duration is greater than 0
1455 DALI_TEST_CHECK( duration > 0.0f );
1457 // Make the indicator visible
1458 indicator.SetOpacity(1.0f);
1460 // Render and notify
1461 application.SendNotification();
1462 application.Render();
1464 // Check that the indicator is visible
1465 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1467 // Do the "HideIndicator" action
1468 Property::Map emptyMap;
1469 scrollBar.DoAction( "HideIndicator", emptyMap );
1471 // Wait for the specified duration
1472 Wait(application, duration * 1000);
1474 // Render and notify
1475 application.SendNotification();
1476 application.Render();
1478 // Check that the indicator is now invisible
1479 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1484 int UtcDaliToolkitScrollBarActionShowTransientIndicator(void)
1486 ToolkitTestApplication application;
1488 // Create a scroll bar
1489 ScrollBar scrollBar = ScrollBar::New();
1490 DALI_TEST_CHECK( scrollBar );
1492 Stage::GetCurrent().Add( scrollBar );
1494 Actor indicator = scrollBar.GetScrollIndicator();
1495 DALI_TEST_CHECK( indicator );
1497 // Get the default duration to hide the indicator
1498 float duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_SHOW_DURATION );
1500 // Check that the default duration is greater than 0
1501 DALI_TEST_CHECK( duration > 0.0f );
1503 // Make the indicator invisible
1504 indicator.SetOpacity(0.0f);
1506 // Render and notify
1507 application.SendNotification();
1508 application.Render();
1510 // Check that the indicator is invisible
1511 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1513 // Do the "ShowIndicator" action
1514 Property::Map emptyMap;
1515 scrollBar.DoAction( "ShowTransientIndicator", emptyMap );
1517 // Wait for the specified duration
1518 Wait(application, duration * 1000);
1520 // Render and notify
1521 application.SendNotification();
1522 application.Render();
1524 // Check that the indicator is now visible
1525 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1527 // Get the default duration to hide the indicator
1528 float hideDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_HIDE_DURATION );
1529 float transientDuration = scrollBar.GetProperty<float>( DevelScrollBar::Property::INDICATOR_TRANSIENT_DURATION );
1530 float totalVisibleDuration = hideDuration + transientDuration;
1532 // Check that the default duration is greater than 0
1533 DALI_TEST_CHECK( totalVisibleDuration > 0.0f );
1535 // Wait for the specified duration
1536 Wait(application, totalVisibleDuration * 1000);
1538 // Render and notify
1539 application.SendNotification();
1540 application.Render();
1542 // Check that the indicator is now invisible
1543 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1548 int UtcDaliToolkitScrollBarActionShowTransientIndicatorImmediate(void)
1550 ToolkitTestApplication application;
1552 // Create a scroll bar
1553 ScrollBar scrollBar = ScrollBar::New();
1554 DALI_TEST_CHECK( scrollBar );
1556 Stage::GetCurrent().Add( scrollBar );
1558 Actor indicator = scrollBar.GetScrollIndicator();
1559 DALI_TEST_CHECK( indicator );
1561 // Make the indicator invisible
1562 indicator.SetOpacity(0.0f);
1564 // Don't use a show animation; the indicator should appear immediately
1565 scrollBar.SetProperty( ScrollBar::Property::INDICATOR_SHOW_DURATION, 0.0f );
1566 float duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_SHOW_DURATION );
1567 DALI_TEST_EQUALS( duration, 0.0f, TEST_LOCATION );
1569 // Render and notify
1570 application.SendNotification();
1571 application.Render();
1573 // Do the "ShowIndicator" action
1574 Property::Map emptyMap;
1575 scrollBar.DoAction( "ShowTransientIndicator", emptyMap );
1577 // Wait for the specified duration
1580 // Render and notify
1581 application.SendNotification();
1582 application.Render();
1584 // Check that the indicator is now visible
1585 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1587 // Get the default duration to hide the indicator
1588 float hideDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_HIDE_DURATION );
1589 float transientDuration = scrollBar.GetProperty<float>( DevelScrollBar::Property::INDICATOR_TRANSIENT_DURATION );
1590 float totalVisibleDuration = hideDuration + transientDuration;
1592 // Check that the default duration is greater than 0
1593 DALI_TEST_CHECK( totalVisibleDuration > 0.0f );
1595 // Wait for the specified duration
1596 Wait(application, totalVisibleDuration * 1000);
1598 // Render and notify
1599 application.SendNotification();
1600 application.Render();
1602 // Check that the indicator is now invisible
1603 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1608 int UtcDaliToolkitScrollBarActionShowTransientIndicatorDuringHide(void)
1610 ToolkitTestApplication application;
1612 // Create a scroll bar
1613 ScrollBar scrollBar = ScrollBar::New();
1614 DALI_TEST_CHECK( scrollBar );
1616 Stage::GetCurrent().Add( scrollBar );
1618 Actor indicator = scrollBar.GetScrollIndicator();
1619 DALI_TEST_CHECK( indicator );
1621 // Get the default duration to hide the indicator
1622 float duration = scrollBar.GetIndicatorHideDuration();
1624 // Check that the default duration is greater than 0
1625 DALI_TEST_CHECK( duration > 0.0f );
1627 // Make the indicator visible
1628 indicator.SetOpacity(1.0f);
1630 // Render and notify
1631 application.SendNotification();
1632 application.Render();
1634 // Check that the indicator is visible
1635 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1637 // Hide the indicator
1638 scrollBar.HideIndicator();
1640 // Wait for half the specified duration
1641 Wait(application, duration * 0.5f * 1000);
1643 // Render and notify
1644 application.SendNotification();
1645 application.Render();
1647 // Check that the indicator is now partially hidden
1648 DALI_TEST_CHECK( indicator.GetCurrentOpacity() < 1.0f );
1650 // Now interrupt the Hide with a DoAction( "ShowTransientIndicator" )
1652 // Get the default duration to hide the indicator
1653 duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_SHOW_DURATION );
1655 // Check that the default duration is greater than 0
1656 DALI_TEST_CHECK( duration > 0.0f );
1658 // Do the "ShowIndicator" action
1659 Property::Map emptyMap;
1660 scrollBar.DoAction( "ShowTransientIndicator", emptyMap );
1662 // Wait for the specified duration
1663 Wait(application, duration * 1000);
1665 // Render and notify
1666 application.SendNotification();
1667 application.Render();
1669 // Check that the indicator is now visible
1670 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1672 // Get the default duration to hide the indicator
1673 float hideDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_HIDE_DURATION );
1674 float transientDuration = scrollBar.GetProperty<float>( DevelScrollBar::Property::INDICATOR_TRANSIENT_DURATION );
1675 float totalVisibleDuration = hideDuration + transientDuration;
1677 // Check that the default duration is greater than 0
1678 DALI_TEST_CHECK( totalVisibleDuration > 0.0f );
1680 // Wait for the specified duration
1681 Wait(application, totalVisibleDuration * 1000);
1683 // Render and notify
1684 application.SendNotification();
1685 application.Render();
1687 // Check that the indicator is now invisible
1688 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1693 int UtcDaliToolkitScrollBarPanFinishedSignalP(void)
1695 ToolkitTestApplication application;
1697 // Create a vertical scroll bar
1698 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1699 DALI_TEST_CHECK( scrollBar );
1701 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
1702 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1703 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
1705 // Set the indicator height to be fixed to 50.0f
1706 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
1707 scrollBar.SetIndicatorFixedHeight(50.0f);
1709 Stage::GetCurrent().Add( scrollBar );
1711 // Connect the pan finished signal
1712 ConnectionTracker connectionTracker;
1713 bool panFinished = false;
1714 scrollBar.PanFinishedSignal().Connect( &OnPanFinished );
1715 scrollBar.ConnectSignal( &connectionTracker, "panFinished", CallbackFunctor(&panFinished));
1717 // Render and notify
1718 application.SendNotification();
1719 application.Render();
1721 // Create a source actor that owns the scroll properties required by the scroll bar
1722 Actor sourceActor = Actor::New();
1723 Stage::GetCurrent().Add( sourceActor );
1725 // Register the scroll properties
1726 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1727 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1728 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
1729 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
1731 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1732 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1733 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1734 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1736 // Set the source of the scroll position properties.
1737 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1739 // Render and notify
1740 application.SendNotification();
1741 application.Render();
1743 // Perform a swipe gesture on the indicator
1744 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20);
1745 DALI_TEST_EQUALS( gOnPanFinishedCalled, true, TEST_LOCATION );
1746 DALI_TEST_EQUALS( panFinished, true, TEST_LOCATION );
1751 int UtcDaliToolkitScrollBarPanFinishedSignalN(void)
1753 ToolkitTestApplication application;
1755 // Create a vertical scroll bar
1756 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1757 DALI_TEST_CHECK( scrollBar );
1759 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
1760 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1761 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
1763 // Set the indicator height to be fixed to 50.0f
1764 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
1765 scrollBar.SetIndicatorFixedHeight(50.0f);
1767 Stage::GetCurrent().Add( scrollBar );
1769 // Connect the pan finished signal
1770 ConnectionTracker connectionTracker;
1771 bool panFinished = false;
1772 scrollBar.PanFinishedSignal().Connect( &OnPanFinished );
1773 scrollBar.ConnectSignal( &connectionTracker, "panFinished", CallbackFunctor(&panFinished));
1775 // Render and notify
1776 application.SendNotification();
1777 application.Render();
1779 // Perform a vertical swipe gesture on the indicator when there is no source object set on the scroll bar
1780 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20);
1781 DALI_TEST_EQUALS( gOnPanFinishedCalled, false, TEST_LOCATION );
1783 // Create a source actor that owns the scroll properties required by the scroll bar
1784 Actor sourceActor = Actor::New();
1785 Stage::GetCurrent().Add( sourceActor );
1787 // Register the scroll properties
1788 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1789 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1790 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
1791 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
1793 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1794 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1795 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1796 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1798 // Set the source of the scroll position properties.
1799 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1801 // Render and notify
1802 application.SendNotification();
1803 application.Render();
1805 // Perform a swipe gesture on the scroll bar but not on the indicator
1806 PerformGestureSwipe(application, Vector2(1.0f, 780.0f), Vector2(Vector2::YAXIS * -1.0f), 20);
1807 DALI_TEST_EQUALS( gOnPanFinishedCalled, false, TEST_LOCATION );
1808 DALI_TEST_EQUALS( panFinished, false, TEST_LOCATION );
1810 // Perform a swipe gesture on the indicator
1811 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20);
1812 DALI_TEST_EQUALS( gOnPanFinishedCalled, true, TEST_LOCATION );
1813 DALI_TEST_EQUALS( panFinished, true, TEST_LOCATION );
1818 int UtcDaliToolkitScrollBarScrollPositionIntervalReachedSignalP(void)
1820 ToolkitTestApplication application;
1822 // Create a vertical scroll bar
1823 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1824 DALI_TEST_CHECK( scrollBar );
1826 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
1827 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1828 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
1830 Stage::GetCurrent().Add( scrollBar );
1831 ConnectionTracker connectionTracker;
1833 // Connect to the ScrollPositionIntervalReached signal
1834 bool intervalReached = false;
1835 scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
1836 scrollBar.ConnectSignal( &connectionTracker, "scrollPositionIntervalReached", CallbackFunctor(&intervalReached));
1838 // Render and notify
1839 application.SendNotification();
1840 application.Render();
1842 // Create a source actor that owns the scroll properties required by the scroll bar
1843 Actor sourceActor = Actor::New();
1844 Stage::GetCurrent().Add( sourceActor );
1846 // Register the scroll properties
1847 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1848 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1849 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 800.0f );
1850 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 2000.0f );
1852 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1853 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1854 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1855 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1857 // Set the source of the scroll position properties.
1858 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1860 // Render and notify
1861 application.SendNotification();
1862 application.Render();
1864 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
1865 Dali::Vector<float> positionIntervals;
1866 for( size_t i = 0; i != 10; ++i )
1868 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
1870 scrollBar.SetScrollPositionIntervals(positionIntervals);
1872 // Render and notify
1873 application.SendNotification();
1874 application.Render();
1877 gOnScrollPositionIntervalReachedSignalCalled = false;
1879 // Animate the scroll position to cross the specified value
1880 Animation animation = Animation::New(0.1f);
1881 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
1884 // Wait for 0.1 second
1885 Wait(application, 100);
1887 // Check that the signal callback is called
1888 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1889 DALI_TEST_EQUALS( intervalReached, true, TEST_LOCATION );
1892 gOnScrollPositionIntervalReachedSignalCalled = false;
1893 intervalReached = false;
1895 // Rest and clear the animation
1899 // Animate the scroll position to cross another specified value
1900 animation = Animation::New(0.1f);
1901 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -170.0f );
1904 // Wait for 0.1 second
1905 Wait(application, 100);
1907 // Check that the signal callback is called
1908 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1909 DALI_TEST_EQUALS( intervalReached, true, TEST_LOCATION );
1912 gOnScrollPositionIntervalReachedSignalCalled = false;
1913 intervalReached = false;
1915 // Rest and clear the animation
1919 // Animate the scroll position back to the previous value
1920 animation = Animation::New(0.1f);
1921 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
1924 // Wait for 0.1 second
1925 Wait(application, 100);
1927 // Check that the signal callback is called
1928 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1929 DALI_TEST_EQUALS( intervalReached, true, TEST_LOCATION );
1934 int UtcDaliToolkitScrollBarScrollPositionIntervalReachedSignalN(void)
1936 ToolkitTestApplication application;
1938 // Create a vertical scroll bar
1939 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1940 DALI_TEST_CHECK( scrollBar );
1942 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
1943 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1944 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
1946 Stage::GetCurrent().Add( scrollBar );
1948 // Connect to the ScrollPositionIntervalReached signal
1949 scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
1951 // Render and notify
1952 application.SendNotification();
1953 application.Render();
1955 // Create a source actor that owns the scroll properties required by the scroll bar
1956 Actor sourceActor = Actor::New();
1957 Stage::GetCurrent().Add( sourceActor );
1959 // Register the scroll properties
1960 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1961 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1962 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 800.0f );
1963 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 2000.0f );
1965 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1966 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1967 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1968 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1970 // Set the source of the scroll position properties.
1971 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1973 // Render and notify
1974 application.SendNotification();
1975 application.Render();
1977 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
1978 Dali::Vector<float> positionIntervals;
1979 for( size_t i = 0; i != 10; ++i )
1981 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
1983 scrollBar.SetScrollPositionIntervals(positionIntervals);
1985 // Render and notify
1986 application.SendNotification();
1987 application.Render();
1990 gOnScrollPositionIntervalReachedSignalCalled = false;
1992 // Animate the scroll position not to cross the specified value
1993 Animation animation = Animation::New(0.1f);
1994 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -70.0f );
1997 // Wait for 0.1 second
1998 Wait(application, 100);
2000 // Check that the signal callback is not called
2001 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, false, TEST_LOCATION );
2003 // Rest and clear the animation
2007 // Animate the scroll position to cross another specified value
2008 animation = Animation::New(0.1f);
2009 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
2012 // Wait for 0.1 second
2013 Wait(application, 100);
2015 // Check that the signal callback is called
2016 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );