2 * Copyright (c) 2017 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>
26 using namespace Toolkit;
28 void dali_scrollbar_startup(void)
30 test_return_value = TET_UNDEF;
33 void dali_scrollbar_cleanup(void)
35 test_return_value = TET_PASS;
41 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
43 // Generate a PanGestureEvent to send to Core
44 Integration::PanGestureEvent GeneratePan(
46 const Vector2& previousPosition,
47 const Vector2& currentPosition,
48 unsigned long timeDelta,
49 unsigned int numberOfTouches = 1)
51 Integration::PanGestureEvent pan(state);
53 pan.previousPosition = previousPosition;
54 pan.currentPosition = currentPosition;
55 pan.timeDelta = timeDelta;
56 pan.numberOfTouches = numberOfTouches;
62 * Helper to generate PanGestureEvent
64 * @param[in] application Application instance
65 * @param[in] state The Gesture State
66 * @param[in] pos The current position of touch.
68 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
72 if( (state == Gesture::Started) ||
73 (state == Gesture::Possible) )
79 application.ProcessEvent(GeneratePan(state, last, pos, RENDER_FRAME_INTERVAL));
86 * Simulate time passed by.
88 * @note this will always process at least 1 frame (1/60 sec)
90 * @param application Test application instance
91 * @param duration Time to pass in milliseconds.
92 * @return The actual time passed in milliseconds
94 int Wait(ToolkitTestApplication& application, int duration = 0)
98 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
100 application.SendNotification();
101 application.Render(RENDER_FRAME_INTERVAL);
102 time += RENDER_FRAME_INTERVAL;
110 static bool gOnPanFinishedCalled; ///< Whether the PanFinished signal was invoked.
111 static bool gOnScrollPositionIntervalReachedSignalCalled; ///< Whether the ScrollPositionIntervalReached signal was invoked.
114 * Invoked when pan gesture is finished on the scroll indicator.
116 static void OnPanFinished()
118 gOnPanFinishedCalled = true;
121 struct CallbackFunctor
123 CallbackFunctor(bool* callbackFlag)
124 : mCallbackFlag( callbackFlag )
130 *mCallbackFlag = true;
136 * Invoked when the current scroll position of the scrollable content goes above or below the values
137 * specified by SCROLL_POSITION_INTERVALS property.
139 * @param[in] position The current scroll position.
141 static void OnScrollPositionIntervalReached( float position )
143 gOnScrollPositionIntervalReachedSignalCalled = true;
146 static Vector2 PerformGestureSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames)
148 gOnPanFinishedCalled = false;
150 // Now do a pan starting from (start) and heading (direction)
152 SendPan(application, Gesture::Possible, pos);
153 SendPan(application, Gesture::Started, pos);
156 for(int i = 0; i < frames; i++)
158 pos += direction; // Move in this direction
159 SendPan(application, Gesture::Continuing, pos);
163 pos += direction; // Move in this direction.
164 SendPan(application, Gesture::Finished, pos);
172 int UtcDaliToolkitScrollBarConstructorP(void)
174 ToolkitTestApplication application;
177 DALI_TEST_CHECK( !scrollBar );
181 int UtcDaliToolkitScrollBarCopyConstructorP(void)
183 ToolkitTestApplication application;
185 ScrollBar scrollBar = ScrollBar::New();
186 scrollBar.SetProperty( ScrollBar::Property::INDICATOR_FIXED_HEIGHT, 38.2f );
188 ScrollBar copy( scrollBar );
189 DALI_TEST_CHECK( copy );
190 DALI_TEST_CHECK( copy.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) == scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) );
194 int UtcDaliToolkitScrollBarAssignmentOperatorP(void)
196 ToolkitTestApplication application;
198 ScrollBar scrollBar = ScrollBar::New();
199 scrollBar.SetProperty( ScrollBar::Property::INDICATOR_FIXED_HEIGHT, 38.2f );
201 ScrollBar copy = scrollBar;
202 DALI_TEST_CHECK( copy );
203 DALI_TEST_CHECK( copy.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) == scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) );
207 int UtcDaliScrollBarDestructorP(void)
209 ToolkitTestApplication application;
211 ScrollBar* scrollBar = new ScrollBar();
214 DALI_TEST_CHECK( true );
218 int UtcDaliToolkitScrollBarNewP(void)
220 ToolkitTestApplication application;
222 ScrollBar scrollBar = ScrollBar::New();
223 DALI_TEST_CHECK( scrollBar );
226 ScrollBar vertical = ScrollBar::New(ScrollBar::Vertical);
227 DALI_TEST_CHECK( vertical );
228 DALI_TEST_CHECK( vertical.GetScrollDirection() == ScrollBar::Vertical );
230 Property::Value value = vertical.GetProperty(ScrollBar::Property::SCROLL_DIRECTION);
231 std::string scrollDirection = value.Get<std::string>();
232 DALI_TEST_EQUALS( scrollDirection, "Vertical", TEST_LOCATION );
234 ScrollBar horizontal = ScrollBar::New(ScrollBar::Horizontal);
235 DALI_TEST_CHECK( horizontal );
236 DALI_TEST_CHECK( horizontal.GetScrollDirection() == ScrollBar::Horizontal );
237 value = vertical.GetProperty(ScrollBar::Property::SCROLL_DIRECTION);
238 scrollDirection = value.Get<std::string>();
239 DALI_TEST_EQUALS( scrollDirection, "Horizontal", TEST_LOCATION );
244 int UtcDaliToolkitScrollBarCreateP(void)
246 ToolkitTestApplication application;
248 TypeRegistry typeRegistry = TypeRegistry::Get();
249 DALI_TEST_CHECK( typeRegistry );
251 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "ScrollBar" );
252 DALI_TEST_CHECK( typeInfo );
254 BaseHandle handle = typeInfo.CreateInstance();
255 DALI_TEST_CHECK( handle );
257 ScrollBar scrollBar = ScrollBar::DownCast( handle );
258 DALI_TEST_CHECK( scrollBar );
260 scrollBar.SetProperty(ScrollBar::Property::SCROLL_DIRECTION, "Vertical");
261 scrollBar.SetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY, "Fixed");
263 DALI_TEST_EQUALS( scrollBar.GetScrollDirection(), Toolkit::ScrollBar::Vertical, TEST_LOCATION );
264 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Fixed, TEST_LOCATION );
266 scrollBar.SetProperty(ScrollBar::Property::SCROLL_DIRECTION, "Horizontal");
267 scrollBar.SetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY, "Variable");
269 DALI_TEST_EQUALS( scrollBar.GetScrollDirection(), Toolkit::ScrollBar::Horizontal, TEST_LOCATION );
270 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Variable, TEST_LOCATION );
275 int UtcDaliToolkitScrollBarDownCastP(void)
277 ToolkitTestApplication application;
279 ScrollBar scrollBar1 = ScrollBar::New();
280 BaseHandle object( scrollBar1 );
282 ScrollBar scrollBar2 = ScrollBar::DownCast( object );
283 DALI_TEST_CHECK( scrollBar2 );
285 ScrollBar scrollBar3 = DownCast< ScrollBar >( object );
286 DALI_TEST_CHECK( scrollBar3 );
290 int UtcDaliToolkitScrollBarDownCastN(void)
292 ToolkitTestApplication application;
294 BaseHandle uninitializedObject;
295 ScrollBar scrollBar1 = ScrollBar::DownCast( uninitializedObject );
296 DALI_TEST_CHECK( !scrollBar1 );
298 ScrollBar scrollBar2 = DownCast< ScrollBar >( uninitializedObject );
299 DALI_TEST_CHECK( !scrollBar2 );
303 int UtcDaliToolkitScrollBarSetScrollPropertySourceP(void)
305 ToolkitTestApplication application;
307 // Create a vertical scroll bar
308 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
309 DALI_TEST_CHECK( scrollBar );
310 DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::Vertical );
312 float scrollBarHeight = 100.0f;
313 scrollBar.SetSize(20.0f, scrollBarHeight, 0.0f);
314 Stage::GetCurrent().Add( scrollBar );
316 // Create a source actor that owns the scroll properties required by the scroll bar
317 Actor sourceActor = Actor::New();
318 Stage::GetCurrent().Add( sourceActor );
320 // Register the scroll properties
321 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
322 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
323 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
324 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
326 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
327 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
328 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
329 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
331 // Set the source of the scroll position properties.
332 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
335 application.SendNotification();
336 application.Render();
338 Actor indicator = scrollBar.GetScrollIndicator();
339 DALI_TEST_CHECK( indicator );
341 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
342 // i.e. The bigger the content size, the smaller the indicator size
343 float indicatorHeight = indicator.GetCurrentSize().y;
344 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
346 // Decrease the content length
347 sourceActor.SetProperty( propertyScrollContentSize, 250.0f );
350 application.SendNotification();
351 application.Render();
353 // Check that the indicator size is changed accordingly
354 indicatorHeight = indicator.GetCurrentSize().y;
355 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 250.0f, TEST_LOCATION );
357 // As scroll position is 0, check that the indicator position should be 0.0f.
358 float indicatorPosition = indicator.GetCurrentPosition().y;
359 DALI_TEST_EQUALS( indicatorPosition, 0.0f, TEST_LOCATION );
361 // Set the scroll position to the middle
362 sourceActor.SetProperty( propertyScrollPosition, -50.0f );
365 application.SendNotification();
366 application.Render();
368 // Check that the indicator should be in the middle of the scroll bar
369 indicatorPosition = indicator.GetCurrentPosition().y;
370 DALI_TEST_EQUALS( indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.5f, TEST_LOCATION );
372 // Set the scroll position to the maximum
373 sourceActor.SetProperty( propertyScrollPosition, -100.0f );
376 application.SendNotification();
377 application.Render();
379 // Check that the indicator should be in the end of the scroll bar
380 indicatorPosition = indicator.GetCurrentPosition().y;
381 DALI_TEST_EQUALS( indicatorPosition, scrollBarHeight - indicatorHeight, TEST_LOCATION );
383 // Increase the maximum scroll position to double
384 sourceActor.SetProperty( propertyMaxScrollPosition, 200.0f );
387 application.SendNotification();
388 application.Render();
390 // Check that the indicator should be now in the middle of the scroll bar
391 indicatorPosition = indicator.GetCurrentPosition().y;
392 DALI_TEST_EQUALS( indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.5f, TEST_LOCATION );
394 // Create another source actor
395 Actor newSourceActor = Actor::New();
396 Stage::GetCurrent().Add( newSourceActor );
398 // Register the scroll properties
399 Property::Index newPropertyScrollPosition = newSourceActor.RegisterProperty( "sourcePosition", 0.0f );
400 Property::Index newPropertyMinScrollPosition = newSourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
401 Property::Index newPropertyMaxScrollPosition = newSourceActor.RegisterProperty( "sourcePositionMax", 200.0f );
402 Property::Index newPropertyScrollContentSize = newSourceActor.RegisterProperty( "sourceContentSize", 400.0f );
404 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourcePosition" ), newPropertyScrollPosition, TEST_LOCATION );
405 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourcePositionMin" ), newPropertyMinScrollPosition, TEST_LOCATION );
406 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourcePositionMax" ), newPropertyMaxScrollPosition, TEST_LOCATION );
407 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourceContentSize" ), newPropertyScrollContentSize, TEST_LOCATION );
409 // Change the source of the scroll position properties to be the new source actor.
410 scrollBar.SetScrollPropertySource(newSourceActor, newPropertyScrollPosition, newPropertyMinScrollPosition, newPropertyMaxScrollPosition, newPropertyScrollContentSize);
413 application.SendNotification();
414 application.Render();
416 // Check that the indicator size is changed accordingly
417 indicatorHeight = indicator.GetCurrentSize().y;
418 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 400.0f, TEST_LOCATION );
420 // Check that the indicator position goes back to the beginning of the scroll bar
421 indicatorPosition = indicator.GetCurrentPosition().y;
422 DALI_TEST_EQUALS( indicatorPosition, 0.0f, TEST_LOCATION );
424 // Set the scroll position to one fifth of the maximum
425 newSourceActor.SetProperty( propertyScrollPosition, -40.0f );
428 application.SendNotification();
429 application.Render();
431 // Check that the indicator should be in one fifth from the beginning of the scroll bar
432 indicatorPosition = indicator.GetCurrentPosition().y;
433 DALI_TEST_EQUALS( indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.2f, TEST_LOCATION );
438 int UtcDaliToolkitScrollBarSetScrollPropertySourceN(void)
440 ToolkitTestApplication application;
442 // Create a scroll bar
443 ScrollBar scrollBar = ScrollBar::New();
444 DALI_TEST_CHECK( scrollBar );
446 // Set empty handle of source object and invalid source property index.
448 scrollBar.SetScrollPropertySource(sourceActor, Property::INVALID_INDEX, Property::INVALID_INDEX, Property::INVALID_INDEX, Property::INVALID_INDEX);
450 DALI_TEST_CHECK( true );
454 int UtcDaliToolkitScrollBarSetScrollIndicatorP(void)
456 ToolkitTestApplication application;
458 // Create a scroll bar
459 ScrollBar scrollBar = ScrollBar::New();
460 DALI_TEST_CHECK( scrollBar );
462 Actor indicator = scrollBar.GetScrollIndicator();
463 DALI_TEST_CHECK( indicator );
465 // Set a new indicator
466 Actor newIndicator = Actor::New();
467 scrollBar.SetScrollIndicator(newIndicator);
469 // Check that the new indicator is successfully set
470 DALI_TEST_CHECK( indicator != scrollBar.GetScrollIndicator() );
471 DALI_TEST_CHECK( newIndicator == scrollBar.GetScrollIndicator() );
473 // Check that the new control indicator is successfully set
474 Control controlIndicator = Control::New();
475 scrollBar.SetScrollIndicator(controlIndicator);
477 DALI_TEST_CHECK( controlIndicator == Control::DownCast( scrollBar.GetScrollIndicator() ) );
481 int UtcDaliToolkitScrollBarSetScrollIndicatorN(void)
483 ToolkitTestApplication application;
485 // Create a scroll bar
486 ScrollBar scrollBar = ScrollBar::New();
487 DALI_TEST_CHECK( scrollBar );
489 Actor indicator = scrollBar.GetScrollIndicator();
490 DALI_TEST_CHECK( indicator );
492 // Try to set an uninitialized actor as the indicator
493 Actor uninitializedIndicator;
494 scrollBar.SetScrollIndicator(uninitializedIndicator);
496 // Check that the uninitialized actor can not be set as the indicator
497 DALI_TEST_CHECK( indicator == scrollBar.GetScrollIndicator() );
498 DALI_TEST_CHECK( uninitializedIndicator != scrollBar.GetScrollIndicator() );
503 int UtcDaliToolkitScrollBarGetScrollIndicatorP(void)
505 ToolkitTestApplication application;
507 // Create a scroll bar
508 ScrollBar scrollBar = ScrollBar::New();
509 DALI_TEST_CHECK( scrollBar );
511 Actor indicator = scrollBar.GetScrollIndicator();
512 DALI_TEST_CHECK( indicator );
514 // Set a new indicator
515 Actor newIndicator = Actor::New();
516 scrollBar.SetScrollIndicator(newIndicator);
518 // Check that the new indicator is successfully set
519 DALI_TEST_CHECK( scrollBar.GetScrollIndicator() );
520 DALI_TEST_CHECK( indicator != scrollBar.GetScrollIndicator() );
521 DALI_TEST_CHECK( newIndicator == scrollBar.GetScrollIndicator() );
526 int UtcDaliToolkitScrollBarGetScrollIndicatorN(void)
528 ToolkitTestApplication application;
530 // Create a scroll bar
531 ScrollBar scrollBar = ScrollBar::New();
532 DALI_TEST_CHECK( scrollBar );
534 Actor indicator = scrollBar.GetScrollIndicator();
535 DALI_TEST_CHECK( indicator );
537 // Try to set an uninitialized actor as the indicator
538 Actor uninitializedIndicator;
539 scrollBar.SetScrollIndicator(uninitializedIndicator);
541 // Check that the indicator has not been changed
542 DALI_TEST_CHECK( indicator == scrollBar.GetScrollIndicator() );
543 DALI_TEST_CHECK( uninitializedIndicator != scrollBar.GetScrollIndicator() );
548 int UtcDaliToolkitScrollBarSetScrollPositionIntervalsP(void)
550 ToolkitTestApplication application;
552 // Create a vertical scroll bar
553 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
554 DALI_TEST_CHECK( scrollBar );
556 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
557 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
558 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
560 Stage::GetCurrent().Add( scrollBar );
562 // Connect to the ScrollPositionIntervalReached signal
563 scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
566 application.SendNotification();
567 application.Render();
569 // Create a source actor that owns the scroll properties required by the scroll bar
570 Actor sourceActor = Actor::New();
571 Stage::GetCurrent().Add( sourceActor );
573 // Register the scroll properties
574 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
575 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
576 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 800.0f );
577 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 2000.0f );
579 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
580 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
581 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
582 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
584 // Set the source of the scroll position properties.
585 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
588 application.SendNotification();
589 application.Render();
591 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
592 Dali::Vector<float> positionIntervals;
593 for( size_t i = 0; i != 10; ++i )
595 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
597 scrollBar.SetScrollPositionIntervals(positionIntervals);
599 // Get the list of scroll position intervals for notification
600 Dali::Vector<float> results = scrollBar.GetScrollPositionIntervals();
602 // Check that the result is the same as the list previously set.
603 DALI_TEST_EQUALS( positionIntervals.Count(), results.Count(), TEST_LOCATION );
604 DALI_TEST_EQUALS( positionIntervals[0], results[0], TEST_LOCATION );
605 DALI_TEST_EQUALS( positionIntervals[1], results[1], TEST_LOCATION );
606 DALI_TEST_EQUALS( positionIntervals[2], results[2], TEST_LOCATION );
607 DALI_TEST_EQUALS( positionIntervals[3], results[3], TEST_LOCATION );
608 DALI_TEST_EQUALS( positionIntervals[4], results[4], TEST_LOCATION );
609 DALI_TEST_EQUALS( positionIntervals[5], results[5], TEST_LOCATION );
610 DALI_TEST_EQUALS( positionIntervals[6], results[6], TEST_LOCATION );
611 DALI_TEST_EQUALS( positionIntervals[7], results[7], TEST_LOCATION );
612 DALI_TEST_EQUALS( positionIntervals[8], results[8], TEST_LOCATION );
613 DALI_TEST_EQUALS( positionIntervals[9], results[9], TEST_LOCATION );
616 gOnScrollPositionIntervalReachedSignalCalled = false;
618 // Animate the scroll position to cross the specified value
619 Animation animation = Animation::New(0.1f);
620 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
623 // Wait for 0.1 second
624 Wait(application, 100);
626 // Check that the signal callback is called
627 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
630 gOnScrollPositionIntervalReachedSignalCalled = false;
632 // Rest and clear the animation
636 // Animate the scroll position to cross another specified value
637 animation = Animation::New(0.1f);
638 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -170.0f );
641 // Wait for 0.1 second
642 Wait(application, 100);
644 // Check that the signal callback is called
645 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
648 gOnScrollPositionIntervalReachedSignalCalled = false;
650 // Rest and clear the animation
654 // Animate the scroll position back to the previous value
655 animation = Animation::New(0.1f);
656 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
659 // Wait for 0.1 second
660 Wait(application, 100);
662 // Check that the signal callback is called
663 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
668 int UtcDaliToolkitScrollBarGetScrollPositionIntervalsP(void)
670 ToolkitTestApplication application;
672 // Create a vertical scroll bar
673 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
674 DALI_TEST_CHECK( scrollBar );
676 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
677 Dali::Vector<float> positionIntervals;
678 for( size_t i = 0; i != 10; ++i )
680 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
682 scrollBar.SetScrollPositionIntervals(positionIntervals);
684 // Get the list of scroll position intervals for notification
685 Dali::Vector<float> results = scrollBar.GetScrollPositionIntervals();
687 // Check that the result is the same as the list previously set.
688 DALI_TEST_EQUALS( positionIntervals.Count(), results.Count(), TEST_LOCATION );
689 DALI_TEST_EQUALS( positionIntervals[0], results[0], TEST_LOCATION );
690 DALI_TEST_EQUALS( positionIntervals[1], results[1], TEST_LOCATION );
691 DALI_TEST_EQUALS( positionIntervals[2], results[2], TEST_LOCATION );
692 DALI_TEST_EQUALS( positionIntervals[3], results[3], TEST_LOCATION );
693 DALI_TEST_EQUALS( positionIntervals[4], results[4], TEST_LOCATION );
694 DALI_TEST_EQUALS( positionIntervals[5], results[5], TEST_LOCATION );
695 DALI_TEST_EQUALS( positionIntervals[6], results[6], TEST_LOCATION );
696 DALI_TEST_EQUALS( positionIntervals[7], results[7], TEST_LOCATION );
697 DALI_TEST_EQUALS( positionIntervals[8], results[8], TEST_LOCATION );
698 DALI_TEST_EQUALS( positionIntervals[9], results[9], TEST_LOCATION );
700 Property::Array resultArray = scrollBar.GetProperty<Property::Array>(Toolkit::ScrollBar::Property::SCROLL_POSITION_INTERVALS);
702 DALI_TEST_EQUALS( positionIntervals.Count(), resultArray.Count(), TEST_LOCATION );
703 DALI_TEST_EQUALS( positionIntervals[0], resultArray[0].Get<float>(), TEST_LOCATION );
704 DALI_TEST_EQUALS( positionIntervals[1], resultArray[1].Get<float>(), TEST_LOCATION );
705 DALI_TEST_EQUALS( positionIntervals[2], resultArray[2].Get<float>(), TEST_LOCATION );
706 DALI_TEST_EQUALS( positionIntervals[3], resultArray[3].Get<float>(), TEST_LOCATION );
707 DALI_TEST_EQUALS( positionIntervals[4], resultArray[4].Get<float>(), TEST_LOCATION );
708 DALI_TEST_EQUALS( positionIntervals[5], resultArray[5].Get<float>(), TEST_LOCATION );
709 DALI_TEST_EQUALS( positionIntervals[6], resultArray[6].Get<float>(), TEST_LOCATION );
710 DALI_TEST_EQUALS( positionIntervals[7], resultArray[7].Get<float>(), TEST_LOCATION );
711 DALI_TEST_EQUALS( positionIntervals[8], resultArray[8].Get<float>(), TEST_LOCATION );
712 DALI_TEST_EQUALS( positionIntervals[9], resultArray[9].Get<float>(), TEST_LOCATION );
717 int UtcDaliToolkitScrollBarGetScrollDirectionP(void)
719 ToolkitTestApplication application;
721 // Create a vertical scroll bar
722 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
723 DALI_TEST_CHECK( scrollBar );
724 DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::Vertical );
726 // Change the direction of scroll bar to horizontal
727 scrollBar.SetScrollDirection(ScrollBar::Horizontal);
728 DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::Horizontal );
733 int UtcDaliToolkitScrollBarSetIndicatorHeightPolicyP(void)
735 ToolkitTestApplication application;
737 // Create a scroll bar
738 ScrollBar scrollBar = ScrollBar::New();
739 DALI_TEST_CHECK( scrollBar );
741 float scrollBarHeight = 100.0f;
742 scrollBar.SetSize(20.0f, scrollBarHeight, 0.0f);
743 Stage::GetCurrent().Add( scrollBar );
745 // Create a source actor that owns the scroll properties required by the scroll bar
746 Actor sourceActor = Actor::New();
747 Stage::GetCurrent().Add( sourceActor );
749 // Register the scroll properties
750 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
751 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
752 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
753 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
755 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
756 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
757 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
758 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
760 // Set the source of the scroll position properties.
761 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
764 application.SendNotification();
765 application.Render();
767 Actor indicator = scrollBar.GetScrollIndicator();
768 DALI_TEST_CHECK( indicator );
770 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
771 // i.e. The bigger the content size, the smaller the indicator size
772 float indicatorHeight = indicator.GetCurrentSize().y;
773 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
775 // Set the indicator height to be fixed to 50.0f
776 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
777 scrollBar.SetIndicatorFixedHeight(50.0f);
779 Property::Value value = scrollBar.GetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY);
780 DALI_TEST_EQUALS(value.Get<std::string>(), "Fixed", TEST_LOCATION );
783 application.SendNotification();
784 application.Render();
786 // Check that the indicator size should be 50.0f
787 indicatorHeight = indicator.GetCurrentSize().y;
788 DALI_TEST_EQUALS( indicatorHeight, 50.0f, TEST_LOCATION );
790 // Set the indicator height to be variable
791 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Variable);
792 value = scrollBar.GetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY);
793 DALI_TEST_EQUALS(value.Get<std::string>(), "Variable", TEST_LOCATION );
796 application.SendNotification();
797 application.Render();
799 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
800 indicatorHeight = indicator.GetCurrentSize().y;
801 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
806 int UtcDaliToolkitScrollBarGetIndicatorHeightPolicyP(void)
808 ToolkitTestApplication application;
810 // Create a scroll bar
811 ScrollBar scrollBar = ScrollBar::New();
812 DALI_TEST_CHECK( scrollBar );
814 // Set the indicator height to be fixed
815 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
816 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Fixed, TEST_LOCATION );
818 // Set the indicator height to be variable
819 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Variable);
820 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Variable, TEST_LOCATION );
825 int UtcDaliToolkitScrollBarSetIndicatorFixedHeightP(void)
827 ToolkitTestApplication application;
829 // Create a scroll bar
830 ScrollBar scrollBar = ScrollBar::New();
831 DALI_TEST_CHECK( scrollBar );
833 float scrollBarHeight = 100.0f;
834 scrollBar.SetSize(20.0f, scrollBarHeight, 0.0f);
835 Stage::GetCurrent().Add( scrollBar );
837 Actor indicator = scrollBar.GetScrollIndicator();
838 DALI_TEST_CHECK( indicator );
840 // Set the indicator height to be fixed to 50.0f
841 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
842 scrollBar.SetIndicatorFixedHeight(50.0f);
845 application.SendNotification();
846 application.Render();
848 // Check that the indicator size should be 50.0f
849 DALI_TEST_EQUALS( indicator.GetCurrentSize().y, 50.0f, TEST_LOCATION );
851 // Set the indicator height to be fixed to 25.0f
852 scrollBar.SetIndicatorFixedHeight(25.0f);
855 application.SendNotification();
856 application.Render();
858 // Check that the indicator size should be 25.0f
859 DALI_TEST_EQUALS( indicator.GetCurrentSize().y, 25.0f, TEST_LOCATION );
864 int UtcDaliToolkitScrollBarGetIndicatorFixedHeightP(void)
866 ToolkitTestApplication application;
868 // Create a scroll bar
869 ScrollBar scrollBar = ScrollBar::New();
870 DALI_TEST_CHECK( scrollBar );
872 // Set the fixed indicator height to be 50.0f
873 scrollBar.SetIndicatorFixedHeight(50.0f);
875 // Check that the indicator size should be 50.0f
876 DALI_TEST_EQUALS( scrollBar.GetIndicatorFixedHeight(), 50.0f, TEST_LOCATION );
878 // Set the indicator height to be fixed to 25.0f
879 scrollBar.SetIndicatorFixedHeight(25.0f);
881 // Check that the indicator size should be 50.0f
882 DALI_TEST_EQUALS( scrollBar.GetIndicatorFixedHeight(), 25.0f, TEST_LOCATION );
887 int UtcDaliToolkitScrollBarSetIndicatorShowDurationP(void)
889 ToolkitTestApplication application;
891 // Create a scroll bar
892 ScrollBar scrollBar = ScrollBar::New();
893 DALI_TEST_CHECK( scrollBar );
895 Stage::GetCurrent().Add( scrollBar );
897 Actor indicator = scrollBar.GetScrollIndicator();
898 DALI_TEST_CHECK( indicator );
900 // Set the duration to show the indicator to be 0.35 second
901 scrollBar.SetIndicatorShowDuration(0.35);
902 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.35f, TEST_LOCATION );
904 // Make the indicator invisible
905 indicator.SetOpacity(0.0f);
908 application.SendNotification();
909 application.Render();
911 // Check that the indicator is invisible
912 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
914 // Show the indicator
915 scrollBar.ShowIndicator();
917 // Wait for 0.35 second
918 Wait(application, 350);
921 application.SendNotification();
922 application.Render();
924 // Check that the indicator is now visible
925 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
927 // Set the duration to show the indicator to be 0.75 second
928 scrollBar.SetIndicatorShowDuration(0.75);
929 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.75f, TEST_LOCATION );
931 // Make the indicator invisible
932 indicator.SetOpacity(0.0f);
935 application.SendNotification();
936 application.Render();
938 // Check that the indicator is invisible
939 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
941 // Show the indicator
942 scrollBar.ShowIndicator();
944 // Wait for 0.35 second first
945 Wait(application, 350);
948 application.SendNotification();
949 application.Render();
951 // Check that the indicator is not fully visible yet
952 DALI_TEST_CHECK( indicator.GetCurrentOpacity() != 1.0f );
954 // Wait for another 0.4 second
955 Wait(application, 400);
958 application.SendNotification();
959 application.Render();
961 // Check that the indicator is now fully visible
962 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
967 int UtcDaliToolkitScrollBarSetIndicatorShowDurationN(void)
969 ToolkitTestApplication application;
971 // Create a scroll bar
972 ScrollBar scrollBar = ScrollBar::New();
973 DALI_TEST_CHECK( scrollBar );
975 Stage::GetCurrent().Add( scrollBar );
977 Actor indicator = scrollBar.GetScrollIndicator();
978 DALI_TEST_CHECK( indicator );
980 // Get the default duration to show the indicator
981 float duration = scrollBar.GetIndicatorShowDuration();
983 // Check that the default duration is greater than 0
984 DALI_TEST_CHECK( duration > 0.0f );
986 // Make the indicator invisible
987 indicator.SetOpacity(0.0f);
990 application.SendNotification();
991 application.Render();
993 // Check that the indicator is invisible
994 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
996 // Show the indicator
997 scrollBar.ShowIndicator();
999 // Wait for the specified duration
1000 Wait(application, duration * 1000);
1002 // Render and notify
1003 application.SendNotification();
1004 application.Render();
1006 // Check that the indicator is now visible
1007 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1009 // Now set the duration to show the indicator to be a negative value (which should be ignored and therefore means instant)
1010 scrollBar.SetIndicatorShowDuration(-0.25f);
1011 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), -0.25f, TEST_LOCATION );
1013 // Make the indicator invisible
1014 indicator.SetOpacity(0.0f);
1016 // Render and notify
1017 application.SendNotification();
1018 application.Render();
1020 // Check that the indicator is invisible
1021 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1023 // Show the indicator
1024 scrollBar.ShowIndicator();
1026 // Render and notify
1027 application.SendNotification();
1028 application.Render();
1030 // Check that the indicator becomes instantly visible in the next frame
1031 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1036 int UtcDaliToolkitScrollBarGetIndicatorShowDurationP(void)
1038 ToolkitTestApplication application;
1040 // Create a scroll bar
1041 ScrollBar scrollBar = ScrollBar::New();
1042 DALI_TEST_CHECK( scrollBar );
1044 // Set the duration to show the indicator to be 0.35 second
1045 scrollBar.SetIndicatorShowDuration(0.35f);
1047 // Check that the duration to show the indicator is 0.35 second
1048 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.35f, TEST_LOCATION );
1050 // Set the duration to show the indicator to be 0.75 second
1051 scrollBar.SetIndicatorShowDuration(0.75f);
1053 // Check that the duration to show the indicator is 0.75 second
1054 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.75f, TEST_LOCATION );
1059 int UtcDaliToolkitScrollBarSetIndicatorHideDurationP(void)
1061 ToolkitTestApplication application;
1063 // Create a scroll bar
1064 ScrollBar scrollBar = ScrollBar::New();
1065 DALI_TEST_CHECK( scrollBar );
1067 Stage::GetCurrent().Add( scrollBar );
1069 Actor indicator = scrollBar.GetScrollIndicator();
1070 DALI_TEST_CHECK( indicator );
1072 // Set the duration to hide the indicator to be 0.15 second
1073 scrollBar.SetIndicatorHideDuration(0.15f);
1074 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.15f, TEST_LOCATION );
1076 // Make the indicator visible
1077 indicator.SetOpacity(1.0f);
1079 // Render and notify
1080 application.SendNotification();
1081 application.Render();
1083 // Check that the indicator is visible
1084 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1086 // Hide the indicator
1087 scrollBar.HideIndicator();
1089 // Wait for 0.15 second
1090 Wait(application, 150);
1092 // Render and notify
1093 application.SendNotification();
1094 application.Render();
1096 // Check that the indicator is now invisible
1097 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1099 // Set the duration to hide the indicator to be 0.65 second
1100 scrollBar.SetIndicatorHideDuration(0.65f);
1101 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.65f, TEST_LOCATION );
1103 // Make the indicator visible
1104 indicator.SetOpacity(1.0f);
1106 // Render and notify
1107 application.SendNotification();
1108 application.Render();
1110 // Check that the indicator is visible
1111 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1113 // Hide the indicator
1114 scrollBar.HideIndicator();
1116 // Wait for 0.15 second first
1117 Wait(application, 150);
1119 // Render and notify
1120 application.SendNotification();
1121 application.Render();
1123 // Check that the indicator is not fully invisible yet
1124 DALI_TEST_CHECK( indicator.GetCurrentOpacity() != 0.0f );
1126 // Wait for another 0.5 second
1127 Wait(application, 500);
1129 // Render and notify
1130 application.SendNotification();
1131 application.Render();
1133 // Check that the indicator is now fully invisible
1134 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1139 int UtcDaliToolkitScrollBarSetIndicatorHideDurationN(void)
1141 ToolkitTestApplication application;
1143 // Create a scroll bar
1144 ScrollBar scrollBar = ScrollBar::New();
1145 DALI_TEST_CHECK( scrollBar );
1147 Stage::GetCurrent().Add( scrollBar );
1149 Actor indicator = scrollBar.GetScrollIndicator();
1150 DALI_TEST_CHECK( indicator );
1152 // Get the default duration to hide the indicator
1153 float duration = scrollBar.GetIndicatorHideDuration();
1155 // Check that the default duration is greater than 0
1156 DALI_TEST_CHECK( duration > 0.0f );
1158 // Make the indicator visible
1159 indicator.SetOpacity(1.0f);
1161 // Render and notify
1162 application.SendNotification();
1163 application.Render();
1165 // Check that the indicator is visible
1166 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1168 // Hide the indicator
1169 scrollBar.HideIndicator();
1171 // Wait for the specified duration
1172 Wait(application, duration * 1000);
1174 // Render and notify
1175 application.SendNotification();
1176 application.Render();
1178 // Check that the indicator is now invisible
1179 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1181 // Now set the duration to hide the indicator to be a negative value (which should be ignored and therefore means instant)
1182 scrollBar.SetIndicatorHideDuration(-0.25f);
1183 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), -0.25f, TEST_LOCATION );
1185 // Make the indicator visible
1186 indicator.SetOpacity(1.0f);
1188 // Render and notify
1189 application.SendNotification();
1190 application.Render();
1192 // Check that the indicator is visible
1193 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1195 // Hide the indicator
1196 scrollBar.HideIndicator();
1198 // Render and notify
1199 application.SendNotification();
1200 application.Render();
1202 // Check that the indicator becomes instantly invisible in the next frame
1203 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1208 int UtcDaliToolkitScrollBarGetIndicatorHideDurationP(void)
1210 ToolkitTestApplication application;
1212 // Create a scroll bar
1213 ScrollBar scrollBar = ScrollBar::New();
1214 DALI_TEST_CHECK( scrollBar );
1216 // Set the duration to hide the indicator to be 0.15 second
1217 scrollBar.SetIndicatorHideDuration(0.15f);
1219 // Check that the duration to hide the indicator is 0.15 second
1220 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.15f, TEST_LOCATION );
1222 // Set the duration to hide the indicator to be 0.65 second
1223 scrollBar.SetIndicatorHideDuration(0.65f);
1225 // Check that the duration to hide the indicator is 0.65 second
1226 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.65f, TEST_LOCATION );
1231 int UtcDaliToolkitScrollBarShowIndicatorP(void)
1233 ToolkitTestApplication application;
1235 // Create a scroll bar
1236 ScrollBar scrollBar = ScrollBar::New();
1237 DALI_TEST_CHECK( scrollBar );
1239 Stage::GetCurrent().Add( scrollBar );
1241 Actor indicator = scrollBar.GetScrollIndicator();
1242 DALI_TEST_CHECK( indicator );
1244 // Get the default duration to show the indicator
1245 float duration = scrollBar.GetIndicatorShowDuration();
1247 // Check that the default duration is greater than 0
1248 DALI_TEST_CHECK( duration > 0.0f );
1250 // Make the indicator invisible
1251 indicator.SetOpacity(0.0f);
1253 // Render and notify
1254 application.SendNotification();
1255 application.Render();
1257 // Check that the indicator is invisible
1258 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1260 // Show the indicator
1261 scrollBar.ShowIndicator();
1263 // Wait for the specified duration
1264 Wait(application, duration * 1000);
1266 // Render and notify
1267 application.SendNotification();
1268 application.Render();
1270 // Check that the indicator is now visible
1271 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1276 int UtcDaliToolkitScrollBarShowIndicatorN(void)
1278 ToolkitTestApplication application;
1280 // Create a scroll bar
1281 ScrollBar scrollBar = ScrollBar::New();
1282 DALI_TEST_CHECK( scrollBar );
1284 Stage::GetCurrent().Add( scrollBar );
1286 Actor indicator = scrollBar.GetScrollIndicator();
1287 DALI_TEST_CHECK( indicator );
1289 // Make the indicator initially visible
1290 indicator.SetOpacity(1.0f);
1292 // Render and notify
1293 application.SendNotification();
1294 application.Render();
1296 // Check that the indicator is initially visible
1297 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1299 // Get the default duration to show the indicator
1300 float duration = scrollBar.GetIndicatorShowDuration();
1302 // Check that the default duration is greater than 0
1303 DALI_TEST_CHECK( duration > 0.0f );
1305 // Show the indicator
1306 scrollBar.ShowIndicator();
1308 // Render and notify
1309 application.SendNotification();
1310 application.Render();
1312 // Check that the indicator is still visible in the very next frame
1313 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1318 int UtcDaliToolkitScrollBarHideIndicatorP(void)
1320 ToolkitTestApplication application;
1322 // Create a scroll bar
1323 ScrollBar scrollBar = ScrollBar::New();
1324 DALI_TEST_CHECK( scrollBar );
1326 Stage::GetCurrent().Add( scrollBar );
1328 Actor indicator = scrollBar.GetScrollIndicator();
1329 DALI_TEST_CHECK( indicator );
1331 // Get the default duration to hide the indicator
1332 float duration = scrollBar.GetIndicatorHideDuration();
1334 // Check that the default duration is greater than 0
1335 DALI_TEST_CHECK( duration > 0.0f );
1337 // Make the indicator visible
1338 indicator.SetOpacity(1.0f);
1340 // Render and notify
1341 application.SendNotification();
1342 application.Render();
1344 // Check that the indicator is visible
1345 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1347 // Hide the indicator
1348 scrollBar.HideIndicator();
1350 // Wait for the specified duration
1351 Wait(application, duration * 1000);
1353 // Render and notify
1354 application.SendNotification();
1355 application.Render();
1357 // Check that the indicator is now invisible
1358 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1363 int UtcDaliToolkitScrollBarHideIndicatorN(void)
1365 ToolkitTestApplication application;
1367 // Create a scroll bar
1368 ScrollBar scrollBar = ScrollBar::New();
1369 DALI_TEST_CHECK( scrollBar );
1371 Stage::GetCurrent().Add( scrollBar );
1373 Actor indicator = scrollBar.GetScrollIndicator();
1374 DALI_TEST_CHECK( indicator );
1376 // Make the indicator initially invisible
1377 indicator.SetOpacity(0.0f);
1379 // Render and notify
1380 application.SendNotification();
1381 application.Render();
1383 // Check that the indicator is initially invisible
1384 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1386 // Get the default duration to hide the indicator
1387 float duration = scrollBar.GetIndicatorHideDuration();
1389 // Check that the default duration is greater than 0
1390 DALI_TEST_CHECK( duration > 0.0f );
1392 // Hide the indicator
1393 scrollBar.HideIndicator();
1395 // Render and notify
1396 application.SendNotification();
1397 application.Render();
1399 // Check that the indicator is still invisible in the very next frame
1400 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1405 int UtcDaliToolkitScrollBarActionShowIndicator(void)
1407 ToolkitTestApplication application;
1409 // Create a scroll bar
1410 ScrollBar scrollBar = ScrollBar::New();
1411 DALI_TEST_CHECK( scrollBar );
1413 Stage::GetCurrent().Add( scrollBar );
1415 Actor indicator = scrollBar.GetScrollIndicator();
1416 DALI_TEST_CHECK( indicator );
1418 // Get the default duration to hide the indicator
1419 float duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_SHOW_DURATION );
1421 // Check that the default duration is greater than 0
1422 DALI_TEST_CHECK( duration > 0.0f );
1424 // Make the indicator invisible
1425 indicator.SetOpacity(0.0f);
1427 // Render and notify
1428 application.SendNotification();
1429 application.Render();
1431 // Check that the indicator is invisible
1432 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1434 // Do the "ShowIndicator" action
1435 Property::Map emptyMap;
1436 scrollBar.DoAction( "ShowIndicator", emptyMap );
1438 // Wait for the specified duration
1439 Wait(application, duration * 1000);
1441 // Render and notify
1442 application.SendNotification();
1443 application.Render();
1445 // Check that the indicator is now visible
1446 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1451 int UtcDaliToolkitScrollBarActionHideIndicator(void)
1453 ToolkitTestApplication application;
1455 // Create a scroll bar
1456 ScrollBar scrollBar = ScrollBar::New();
1457 DALI_TEST_CHECK( scrollBar );
1459 Stage::GetCurrent().Add( scrollBar );
1461 Actor indicator = scrollBar.GetScrollIndicator();
1462 DALI_TEST_CHECK( indicator );
1464 // Get the default duration to hide the indicator
1465 float duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_HIDE_DURATION );
1467 // Check that the default duration is greater than 0
1468 DALI_TEST_CHECK( duration > 0.0f );
1470 // Make the indicator visible
1471 indicator.SetOpacity(1.0f);
1473 // Render and notify
1474 application.SendNotification();
1475 application.Render();
1477 // Check that the indicator is visible
1478 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1480 // Do the "HideIndicator" action
1481 Property::Map emptyMap;
1482 scrollBar.DoAction( "HideIndicator", emptyMap );
1484 // Wait for the specified duration
1485 Wait(application, duration * 1000);
1487 // Render and notify
1488 application.SendNotification();
1489 application.Render();
1491 // Check that the indicator is now invisible
1492 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1497 int UtcDaliToolkitScrollBarActionShowTransientIndicator(void)
1499 ToolkitTestApplication application;
1501 // Create a scroll bar
1502 ScrollBar scrollBar = ScrollBar::New();
1503 DALI_TEST_CHECK( scrollBar );
1505 Stage::GetCurrent().Add( scrollBar );
1507 Actor indicator = scrollBar.GetScrollIndicator();
1508 DALI_TEST_CHECK( indicator );
1510 // Get the default duration to hide the indicator
1511 float duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_SHOW_DURATION );
1513 // Check that the default duration is greater than 0
1514 DALI_TEST_CHECK( duration > 0.0f );
1516 // Make the indicator invisible
1517 indicator.SetOpacity(0.0f);
1519 // Render and notify
1520 application.SendNotification();
1521 application.Render();
1523 // Check that the indicator is invisible
1524 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1526 // Do the "ShowIndicator" action
1527 Property::Map emptyMap;
1528 scrollBar.DoAction( "ShowTransientIndicator", emptyMap );
1530 // Wait for the specified duration
1531 Wait(application, duration * 1000);
1533 // Render and notify
1534 application.SendNotification();
1535 application.Render();
1537 // Check that the indicator is now visible
1538 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1540 // Get the default duration to hide the indicator
1541 float hideDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_HIDE_DURATION );
1542 float transientDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_TRANSIENT_DURATION );
1543 float totalVisibleDuration = hideDuration + transientDuration;
1545 // Check that the default duration is greater than 0
1546 DALI_TEST_CHECK( totalVisibleDuration > 0.0f );
1548 // Wait for the specified duration
1549 Wait(application, totalVisibleDuration * 1000);
1551 // Render and notify
1552 application.SendNotification();
1553 application.Render();
1555 // Check that the indicator is now invisible
1556 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1561 int UtcDaliToolkitScrollBarActionShowTransientIndicatorImmediate(void)
1563 ToolkitTestApplication application;
1565 // Create a scroll bar
1566 ScrollBar scrollBar = ScrollBar::New();
1567 DALI_TEST_CHECK( scrollBar );
1569 Stage::GetCurrent().Add( scrollBar );
1571 Actor indicator = scrollBar.GetScrollIndicator();
1572 DALI_TEST_CHECK( indicator );
1574 // Make the indicator invisible
1575 indicator.SetOpacity(0.0f);
1577 // Don't use a show animation; the indicator should appear immediately
1578 scrollBar.SetProperty( ScrollBar::Property::INDICATOR_SHOW_DURATION, 0.0f );
1579 float duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_SHOW_DURATION );
1580 DALI_TEST_EQUALS( duration, 0.0f, TEST_LOCATION );
1582 // Render and notify
1583 application.SendNotification();
1584 application.Render();
1586 // Do the "ShowIndicator" action
1587 Property::Map emptyMap;
1588 scrollBar.DoAction( "ShowTransientIndicator", emptyMap );
1590 // Wait for the specified duration
1593 // Render and notify
1594 application.SendNotification();
1595 application.Render();
1597 // Check that the indicator is now visible
1598 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1600 // Get the default duration to hide the indicator
1601 float hideDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_HIDE_DURATION );
1602 float transientDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_TRANSIENT_DURATION );
1603 float totalVisibleDuration = hideDuration + transientDuration;
1605 // Check that the default duration is greater than 0
1606 DALI_TEST_CHECK( totalVisibleDuration > 0.0f );
1608 // Wait for the specified duration
1609 Wait(application, totalVisibleDuration * 1000);
1611 // Render and notify
1612 application.SendNotification();
1613 application.Render();
1615 // Check that the indicator is now invisible
1616 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1621 int UtcDaliToolkitScrollBarActionShowTransientIndicatorDuringHide(void)
1623 ToolkitTestApplication application;
1625 // Create a scroll bar
1626 ScrollBar scrollBar = ScrollBar::New();
1627 DALI_TEST_CHECK( scrollBar );
1629 Stage::GetCurrent().Add( scrollBar );
1631 Actor indicator = scrollBar.GetScrollIndicator();
1632 DALI_TEST_CHECK( indicator );
1634 // Get the default duration to hide the indicator
1635 float duration = scrollBar.GetIndicatorHideDuration();
1637 // Check that the default duration is greater than 0
1638 DALI_TEST_CHECK( duration > 0.0f );
1640 // Make the indicator visible
1641 indicator.SetOpacity(1.0f);
1643 // Render and notify
1644 application.SendNotification();
1645 application.Render();
1647 // Check that the indicator is visible
1648 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1650 // Hide the indicator
1651 scrollBar.HideIndicator();
1653 // Wait for half the specified duration
1654 Wait(application, duration * 0.5f * 1000);
1656 // Render and notify
1657 application.SendNotification();
1658 application.Render();
1660 // Check that the indicator is now partially hidden
1661 DALI_TEST_CHECK( indicator.GetCurrentOpacity() < 1.0f );
1663 // Now interrupt the Hide with a DoAction( "ShowTransientIndicator" )
1665 // Get the default duration to hide the indicator
1666 duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_SHOW_DURATION );
1668 // Check that the default duration is greater than 0
1669 DALI_TEST_CHECK( duration > 0.0f );
1671 // Do the "ShowIndicator" action
1672 Property::Map emptyMap;
1673 scrollBar.DoAction( "ShowTransientIndicator", emptyMap );
1675 // Wait for the specified duration
1676 Wait(application, duration * 1000);
1678 // Render and notify
1679 application.SendNotification();
1680 application.Render();
1682 // Check that the indicator is now visible
1683 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1685 // Get the default duration to hide the indicator
1686 float hideDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_HIDE_DURATION );
1687 float transientDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_TRANSIENT_DURATION );
1688 float totalVisibleDuration = hideDuration + transientDuration;
1690 // Check that the default duration is greater than 0
1691 DALI_TEST_CHECK( totalVisibleDuration > 0.0f );
1693 // Wait for the specified duration
1694 Wait(application, totalVisibleDuration * 1000);
1696 // Render and notify
1697 application.SendNotification();
1698 application.Render();
1700 // Check that the indicator is now invisible
1701 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1706 int UtcDaliToolkitScrollBarPanFinishedSignalP(void)
1708 ToolkitTestApplication application;
1710 // Create a vertical scroll bar
1711 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1712 DALI_TEST_CHECK( scrollBar );
1714 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
1715 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1716 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
1718 // Set the indicator height to be fixed to 50.0f
1719 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
1720 scrollBar.SetIndicatorFixedHeight(50.0f);
1722 Stage::GetCurrent().Add( scrollBar );
1724 // Connect the pan finished signal
1725 ConnectionTracker connectionTracker;
1726 bool panFinished = false;
1727 scrollBar.PanFinishedSignal().Connect( &OnPanFinished );
1728 scrollBar.ConnectSignal( &connectionTracker, "panFinished", CallbackFunctor(&panFinished));
1730 // Render and notify
1731 application.SendNotification();
1732 application.Render();
1734 // Create a source actor that owns the scroll properties required by the scroll bar
1735 Actor sourceActor = Actor::New();
1736 Stage::GetCurrent().Add( sourceActor );
1738 // Register the scroll properties
1739 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1740 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1741 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
1742 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
1744 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1745 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1746 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1747 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1749 // Set the source of the scroll position properties.
1750 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1752 // Render and notify
1753 application.SendNotification();
1754 application.Render();
1756 // Perform a swipe gesture on the indicator
1757 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20);
1758 DALI_TEST_EQUALS( gOnPanFinishedCalled, true, TEST_LOCATION );
1759 DALI_TEST_EQUALS( panFinished, true, TEST_LOCATION );
1764 int UtcDaliToolkitScrollBarPanFinishedSignalN(void)
1766 ToolkitTestApplication application;
1768 // Create a vertical scroll bar
1769 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1770 DALI_TEST_CHECK( scrollBar );
1772 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
1773 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1774 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
1776 // Set the indicator height to be fixed to 50.0f
1777 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
1778 scrollBar.SetIndicatorFixedHeight(50.0f);
1780 Stage::GetCurrent().Add( scrollBar );
1782 // Connect the pan finished signal
1783 ConnectionTracker connectionTracker;
1784 bool panFinished = false;
1785 scrollBar.PanFinishedSignal().Connect( &OnPanFinished );
1786 scrollBar.ConnectSignal( &connectionTracker, "panFinished", CallbackFunctor(&panFinished));
1788 // Render and notify
1789 application.SendNotification();
1790 application.Render();
1792 // Perform a vertical swipe gesture on the indicator when there is no source object set on the scroll bar
1793 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20);
1794 DALI_TEST_EQUALS( gOnPanFinishedCalled, false, TEST_LOCATION );
1796 // Create a source actor that owns the scroll properties required by the scroll bar
1797 Actor sourceActor = Actor::New();
1798 Stage::GetCurrent().Add( sourceActor );
1800 // Register the scroll properties
1801 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1802 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1803 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
1804 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
1806 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1807 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1808 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1809 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1811 // Set the source of the scroll position properties.
1812 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1814 // Render and notify
1815 application.SendNotification();
1816 application.Render();
1818 // Perform a swipe gesture on the scroll bar but not on the indicator
1819 PerformGestureSwipe(application, Vector2(1.0f, 780.0f), Vector2(Vector2::YAXIS * -1.0f), 20);
1820 DALI_TEST_EQUALS( gOnPanFinishedCalled, false, TEST_LOCATION );
1821 DALI_TEST_EQUALS( panFinished, false, TEST_LOCATION );
1823 // Perform a swipe gesture on the indicator
1824 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20);
1825 DALI_TEST_EQUALS( gOnPanFinishedCalled, true, TEST_LOCATION );
1826 DALI_TEST_EQUALS( panFinished, true, TEST_LOCATION );
1831 int UtcDaliToolkitScrollBarScrollPositionIntervalReachedSignalP(void)
1833 ToolkitTestApplication application;
1835 // Create a vertical scroll bar
1836 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1837 DALI_TEST_CHECK( scrollBar );
1839 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
1840 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1841 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
1843 Stage::GetCurrent().Add( scrollBar );
1844 ConnectionTracker connectionTracker;
1846 // Connect to the ScrollPositionIntervalReached signal
1847 bool intervalReached = false;
1848 scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
1849 scrollBar.ConnectSignal( &connectionTracker, "scrollPositionIntervalReached", CallbackFunctor(&intervalReached));
1851 // Render and notify
1852 application.SendNotification();
1853 application.Render();
1855 // Create a source actor that owns the scroll properties required by the scroll bar
1856 Actor sourceActor = Actor::New();
1857 Stage::GetCurrent().Add( sourceActor );
1859 // Register the scroll properties
1860 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1861 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1862 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 800.0f );
1863 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 2000.0f );
1865 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1866 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1867 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1868 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1870 // Set the source of the scroll position properties.
1871 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1873 // Render and notify
1874 application.SendNotification();
1875 application.Render();
1877 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
1878 Dali::Vector<float> positionIntervals;
1879 for( size_t i = 0; i != 10; ++i )
1881 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
1883 scrollBar.SetScrollPositionIntervals(positionIntervals);
1885 // Render and notify
1886 application.SendNotification();
1887 application.Render();
1890 gOnScrollPositionIntervalReachedSignalCalled = false;
1892 // Animate the scroll position to cross the specified value
1893 Animation animation = Animation::New(0.1f);
1894 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
1897 // Wait for 0.1 second
1898 Wait(application, 100);
1900 // Check that the signal callback is called
1901 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1902 DALI_TEST_EQUALS( intervalReached, true, TEST_LOCATION );
1905 gOnScrollPositionIntervalReachedSignalCalled = false;
1906 intervalReached = false;
1908 // Rest and clear the animation
1912 // Animate the scroll position to cross another specified value
1913 animation = Animation::New(0.1f);
1914 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -170.0f );
1917 // Wait for 0.1 second
1918 Wait(application, 100);
1920 // Check that the signal callback is called
1921 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1922 DALI_TEST_EQUALS( intervalReached, true, TEST_LOCATION );
1925 gOnScrollPositionIntervalReachedSignalCalled = false;
1926 intervalReached = false;
1928 // Rest and clear the animation
1932 // Animate the scroll position back to the previous value
1933 animation = Animation::New(0.1f);
1934 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
1937 // Wait for 0.1 second
1938 Wait(application, 100);
1940 // Check that the signal callback is called
1941 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1942 DALI_TEST_EQUALS( intervalReached, true, TEST_LOCATION );
1947 int UtcDaliToolkitScrollBarScrollPositionIntervalReachedSignalN(void)
1949 ToolkitTestApplication application;
1951 // Create a vertical scroll bar
1952 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1953 DALI_TEST_CHECK( scrollBar );
1955 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
1956 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1957 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
1959 Stage::GetCurrent().Add( scrollBar );
1961 // Connect to the ScrollPositionIntervalReached signal
1962 scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
1964 // Render and notify
1965 application.SendNotification();
1966 application.Render();
1968 // Create a source actor that owns the scroll properties required by the scroll bar
1969 Actor sourceActor = Actor::New();
1970 Stage::GetCurrent().Add( sourceActor );
1972 // Register the scroll properties
1973 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1974 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1975 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 800.0f );
1976 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 2000.0f );
1978 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1979 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1980 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1981 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1983 // Set the source of the scroll position properties.
1984 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1986 // Render and notify
1987 application.SendNotification();
1988 application.Render();
1990 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
1991 Dali::Vector<float> positionIntervals;
1992 for( size_t i = 0; i != 10; ++i )
1994 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
1996 scrollBar.SetScrollPositionIntervals(positionIntervals);
1998 // Render and notify
1999 application.SendNotification();
2000 application.Render();
2003 gOnScrollPositionIntervalReachedSignalCalled = false;
2005 // Animate the scroll position not to cross the specified value
2006 Animation animation = Animation::New(0.1f);
2007 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -70.0f );
2010 // Wait for 0.1 second
2011 Wait(application, 100);
2013 // Check that the signal callback is not called
2014 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, false, TEST_LOCATION );
2016 // Rest and clear the animation
2020 // Animate the scroll position to cross another specified value
2021 animation = Animation::New(0.1f);
2022 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
2025 // Wait for 0.1 second
2026 Wait(application, 100);
2028 // Check that the signal callback is called
2029 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );