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>
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 );
703 int UtcDaliToolkitScrollBarGetScrollDirectionP(void)
705 ToolkitTestApplication application;
707 // Create a vertical scroll bar
708 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
709 DALI_TEST_CHECK( scrollBar );
710 DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::Vertical );
712 // Change the direction of scroll bar to horizontal
713 scrollBar.SetScrollDirection(ScrollBar::Horizontal);
714 DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::Horizontal );
719 int UtcDaliToolkitScrollBarSetIndicatorHeightPolicyP(void)
721 ToolkitTestApplication application;
723 // Create a scroll bar
724 ScrollBar scrollBar = ScrollBar::New();
725 DALI_TEST_CHECK( scrollBar );
727 float scrollBarHeight = 100.0f;
728 scrollBar.SetSize(20.0f, scrollBarHeight, 0.0f);
729 Stage::GetCurrent().Add( scrollBar );
731 // Create a source actor that owns the scroll properties required by the scroll bar
732 Actor sourceActor = Actor::New();
733 Stage::GetCurrent().Add( sourceActor );
735 // Register the scroll properties
736 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
737 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
738 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
739 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
741 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
742 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
743 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
744 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
746 // Set the source of the scroll position properties.
747 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
750 application.SendNotification();
751 application.Render();
753 Actor indicator = scrollBar.GetScrollIndicator();
754 DALI_TEST_CHECK( indicator );
756 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
757 // i.e. The bigger the content size, the smaller the indicator size
758 float indicatorHeight = indicator.GetCurrentSize().y;
759 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
761 // Set the indicator height to be fixed to 50.0f
762 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
763 scrollBar.SetIndicatorFixedHeight(50.0f);
765 Property::Value value = scrollBar.GetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY);
766 DALI_TEST_EQUALS(value.Get<std::string>(), "Fixed", TEST_LOCATION );
769 application.SendNotification();
770 application.Render();
772 // Check that the indicator size should be 50.0f
773 indicatorHeight = indicator.GetCurrentSize().y;
774 DALI_TEST_EQUALS( indicatorHeight, 50.0f, TEST_LOCATION );
776 // Set the indicator height to be variable
777 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Variable);
778 value = scrollBar.GetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY);
779 DALI_TEST_EQUALS(value.Get<std::string>(), "Variable", TEST_LOCATION );
782 application.SendNotification();
783 application.Render();
785 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
786 indicatorHeight = indicator.GetCurrentSize().y;
787 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
792 int UtcDaliToolkitScrollBarGetIndicatorHeightPolicyP(void)
794 ToolkitTestApplication application;
796 // Create a scroll bar
797 ScrollBar scrollBar = ScrollBar::New();
798 DALI_TEST_CHECK( scrollBar );
800 // Set the indicator height to be fixed
801 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
802 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Fixed, TEST_LOCATION );
804 // Set the indicator height to be variable
805 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Variable);
806 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Variable, TEST_LOCATION );
811 int UtcDaliToolkitScrollBarSetIndicatorFixedHeightP(void)
813 ToolkitTestApplication application;
815 // Create a scroll bar
816 ScrollBar scrollBar = ScrollBar::New();
817 DALI_TEST_CHECK( scrollBar );
819 float scrollBarHeight = 100.0f;
820 scrollBar.SetSize(20.0f, scrollBarHeight, 0.0f);
821 Stage::GetCurrent().Add( scrollBar );
823 Actor indicator = scrollBar.GetScrollIndicator();
824 DALI_TEST_CHECK( indicator );
826 // Set the indicator height to be fixed to 50.0f
827 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
828 scrollBar.SetIndicatorFixedHeight(50.0f);
831 application.SendNotification();
832 application.Render();
834 // Check that the indicator size should be 50.0f
835 DALI_TEST_EQUALS( indicator.GetCurrentSize().y, 50.0f, TEST_LOCATION );
837 // Set the indicator height to be fixed to 25.0f
838 scrollBar.SetIndicatorFixedHeight(25.0f);
841 application.SendNotification();
842 application.Render();
844 // Check that the indicator size should be 25.0f
845 DALI_TEST_EQUALS( indicator.GetCurrentSize().y, 25.0f, TEST_LOCATION );
850 int UtcDaliToolkitScrollBarGetIndicatorFixedHeightP(void)
852 ToolkitTestApplication application;
854 // Create a scroll bar
855 ScrollBar scrollBar = ScrollBar::New();
856 DALI_TEST_CHECK( scrollBar );
858 // Set the fixed indicator height to be 50.0f
859 scrollBar.SetIndicatorFixedHeight(50.0f);
861 // Check that the indicator size should be 50.0f
862 DALI_TEST_EQUALS( scrollBar.GetIndicatorFixedHeight(), 50.0f, TEST_LOCATION );
864 // Set the indicator height to be fixed to 25.0f
865 scrollBar.SetIndicatorFixedHeight(25.0f);
867 // Check that the indicator size should be 50.0f
868 DALI_TEST_EQUALS( scrollBar.GetIndicatorFixedHeight(), 25.0f, TEST_LOCATION );
873 int UtcDaliToolkitScrollBarSetIndicatorShowDurationP(void)
875 ToolkitTestApplication application;
877 // Create a scroll bar
878 ScrollBar scrollBar = ScrollBar::New();
879 DALI_TEST_CHECK( scrollBar );
881 Stage::GetCurrent().Add( scrollBar );
883 Actor indicator = scrollBar.GetScrollIndicator();
884 DALI_TEST_CHECK( indicator );
886 // Set the duration to show the indicator to be 0.35 second
887 scrollBar.SetIndicatorShowDuration(0.35);
888 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.35f, TEST_LOCATION );
890 // Make the indicator invisible
891 indicator.SetOpacity(0.0f);
894 application.SendNotification();
895 application.Render();
897 // Check that the indicator is invisible
898 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
900 // Show the indicator
901 scrollBar.ShowIndicator();
903 // Wait for 0.35 second
904 Wait(application, 350);
907 application.SendNotification();
908 application.Render();
910 // Check that the indicator is now visible
911 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
913 // Set the duration to show the indicator to be 0.75 second
914 scrollBar.SetIndicatorShowDuration(0.75);
915 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.75f, TEST_LOCATION );
917 // Make the indicator invisible
918 indicator.SetOpacity(0.0f);
921 application.SendNotification();
922 application.Render();
924 // Check that the indicator is invisible
925 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
927 // Show the indicator
928 scrollBar.ShowIndicator();
930 // Wait for 0.35 second first
931 Wait(application, 350);
934 application.SendNotification();
935 application.Render();
937 // Check that the indicator is not fully visible yet
938 DALI_TEST_CHECK( indicator.GetCurrentOpacity() != 1.0f );
940 // Wait for another 0.4 second
941 Wait(application, 400);
944 application.SendNotification();
945 application.Render();
947 // Check that the indicator is now fully visible
948 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
953 int UtcDaliToolkitScrollBarSetIndicatorShowDurationN(void)
955 ToolkitTestApplication application;
957 // Create a scroll bar
958 ScrollBar scrollBar = ScrollBar::New();
959 DALI_TEST_CHECK( scrollBar );
961 Stage::GetCurrent().Add( scrollBar );
963 Actor indicator = scrollBar.GetScrollIndicator();
964 DALI_TEST_CHECK( indicator );
966 // Get the default duration to show the indicator
967 float duration = scrollBar.GetIndicatorShowDuration();
969 // Check that the default duration is greater than 0
970 DALI_TEST_CHECK( duration > 0.0f );
972 // Make the indicator invisible
973 indicator.SetOpacity(0.0f);
976 application.SendNotification();
977 application.Render();
979 // Check that the indicator is invisible
980 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
982 // Show the indicator
983 scrollBar.ShowIndicator();
985 // Wait for the specified duration
986 Wait(application, duration * 1000);
989 application.SendNotification();
990 application.Render();
992 // Check that the indicator is now visible
993 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
995 // Now set the duration to show the indicator to be a negative value (which should be ignored and therefore means instant)
996 scrollBar.SetIndicatorShowDuration(-0.25f);
997 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), -0.25f, TEST_LOCATION );
999 // Make the indicator invisible
1000 indicator.SetOpacity(0.0f);
1002 // Render and notify
1003 application.SendNotification();
1004 application.Render();
1006 // Check that the indicator is invisible
1007 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1009 // Show the indicator
1010 scrollBar.ShowIndicator();
1012 // Render and notify
1013 application.SendNotification();
1014 application.Render();
1016 // Check that the indicator becomes instantly visible in the next frame
1017 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1022 int UtcDaliToolkitScrollBarGetIndicatorShowDurationP(void)
1024 ToolkitTestApplication application;
1026 // Create a scroll bar
1027 ScrollBar scrollBar = ScrollBar::New();
1028 DALI_TEST_CHECK( scrollBar );
1030 // Set the duration to show the indicator to be 0.35 second
1031 scrollBar.SetIndicatorShowDuration(0.35f);
1033 // Check that the duration to show the indicator is 0.35 second
1034 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.35f, TEST_LOCATION );
1036 // Set the duration to show the indicator to be 0.75 second
1037 scrollBar.SetIndicatorShowDuration(0.75f);
1039 // Check that the duration to show the indicator is 0.75 second
1040 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.75f, TEST_LOCATION );
1045 int UtcDaliToolkitScrollBarSetIndicatorHideDurationP(void)
1047 ToolkitTestApplication application;
1049 // Create a scroll bar
1050 ScrollBar scrollBar = ScrollBar::New();
1051 DALI_TEST_CHECK( scrollBar );
1053 Stage::GetCurrent().Add( scrollBar );
1055 Actor indicator = scrollBar.GetScrollIndicator();
1056 DALI_TEST_CHECK( indicator );
1058 // Set the duration to hide the indicator to be 0.15 second
1059 scrollBar.SetIndicatorHideDuration(0.15f);
1060 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.15f, TEST_LOCATION );
1062 // Make the indicator visible
1063 indicator.SetOpacity(1.0f);
1065 // Render and notify
1066 application.SendNotification();
1067 application.Render();
1069 // Check that the indicator is visible
1070 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1072 // Hide the indicator
1073 scrollBar.HideIndicator();
1075 // Wait for 0.15 second
1076 Wait(application, 150);
1078 // Render and notify
1079 application.SendNotification();
1080 application.Render();
1082 // Check that the indicator is now invisible
1083 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1085 // Set the duration to hide the indicator to be 0.65 second
1086 scrollBar.SetIndicatorHideDuration(0.65f);
1087 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.65f, TEST_LOCATION );
1089 // Make the indicator visible
1090 indicator.SetOpacity(1.0f);
1092 // Render and notify
1093 application.SendNotification();
1094 application.Render();
1096 // Check that the indicator is visible
1097 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1099 // Hide the indicator
1100 scrollBar.HideIndicator();
1102 // Wait for 0.15 second first
1103 Wait(application, 150);
1105 // Render and notify
1106 application.SendNotification();
1107 application.Render();
1109 // Check that the indicator is not fully invisible yet
1110 DALI_TEST_CHECK( indicator.GetCurrentOpacity() != 0.0f );
1112 // Wait for another 0.5 second
1113 Wait(application, 500);
1115 // Render and notify
1116 application.SendNotification();
1117 application.Render();
1119 // Check that the indicator is now fully invisible
1120 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1125 int UtcDaliToolkitScrollBarSetIndicatorHideDurationN(void)
1127 ToolkitTestApplication application;
1129 // Create a scroll bar
1130 ScrollBar scrollBar = ScrollBar::New();
1131 DALI_TEST_CHECK( scrollBar );
1133 Stage::GetCurrent().Add( scrollBar );
1135 Actor indicator = scrollBar.GetScrollIndicator();
1136 DALI_TEST_CHECK( indicator );
1138 // Get the default duration to hide the indicator
1139 float duration = scrollBar.GetIndicatorHideDuration();
1141 // Check that the default duration is greater than 0
1142 DALI_TEST_CHECK( duration > 0.0f );
1144 // Make the indicator visible
1145 indicator.SetOpacity(1.0f);
1147 // Render and notify
1148 application.SendNotification();
1149 application.Render();
1151 // Check that the indicator is visible
1152 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1154 // Hide the indicator
1155 scrollBar.HideIndicator();
1157 // Wait for the specified duration
1158 Wait(application, duration * 1000);
1160 // Render and notify
1161 application.SendNotification();
1162 application.Render();
1164 // Check that the indicator is now invisible
1165 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1167 // Now set the duration to hide the indicator to be a negative value (which should be ignored and therefore means instant)
1168 scrollBar.SetIndicatorHideDuration(-0.25f);
1169 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), -0.25f, TEST_LOCATION );
1171 // Make the indicator visible
1172 indicator.SetOpacity(1.0f);
1174 // Render and notify
1175 application.SendNotification();
1176 application.Render();
1178 // Check that the indicator is visible
1179 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1181 // Hide the indicator
1182 scrollBar.HideIndicator();
1184 // Render and notify
1185 application.SendNotification();
1186 application.Render();
1188 // Check that the indicator becomes instantly invisible in the next frame
1189 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1194 int UtcDaliToolkitScrollBarGetIndicatorHideDurationP(void)
1196 ToolkitTestApplication application;
1198 // Create a scroll bar
1199 ScrollBar scrollBar = ScrollBar::New();
1200 DALI_TEST_CHECK( scrollBar );
1202 // Set the duration to hide the indicator to be 0.15 second
1203 scrollBar.SetIndicatorHideDuration(0.15f);
1205 // Check that the duration to hide the indicator is 0.15 second
1206 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.15f, TEST_LOCATION );
1208 // Set the duration to hide the indicator to be 0.65 second
1209 scrollBar.SetIndicatorHideDuration(0.65f);
1211 // Check that the duration to hide the indicator is 0.65 second
1212 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.65f, TEST_LOCATION );
1217 int UtcDaliToolkitScrollBarShowIndicatorP(void)
1219 ToolkitTestApplication application;
1221 // Create a scroll bar
1222 ScrollBar scrollBar = ScrollBar::New();
1223 DALI_TEST_CHECK( scrollBar );
1225 Stage::GetCurrent().Add( scrollBar );
1227 Actor indicator = scrollBar.GetScrollIndicator();
1228 DALI_TEST_CHECK( indicator );
1230 // Get the default duration to show the indicator
1231 float duration = scrollBar.GetIndicatorShowDuration();
1233 // Check that the default duration is greater than 0
1234 DALI_TEST_CHECK( duration > 0.0f );
1236 // Make the indicator invisible
1237 indicator.SetOpacity(0.0f);
1239 // Render and notify
1240 application.SendNotification();
1241 application.Render();
1243 // Check that the indicator is invisible
1244 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1246 // Show the indicator
1247 scrollBar.ShowIndicator();
1249 // Wait for the specified duration
1250 Wait(application, duration * 1000);
1252 // Render and notify
1253 application.SendNotification();
1254 application.Render();
1256 // Check that the indicator is now visible
1257 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1262 int UtcDaliToolkitScrollBarShowIndicatorN(void)
1264 ToolkitTestApplication application;
1266 // Create a scroll bar
1267 ScrollBar scrollBar = ScrollBar::New();
1268 DALI_TEST_CHECK( scrollBar );
1270 Stage::GetCurrent().Add( scrollBar );
1272 Actor indicator = scrollBar.GetScrollIndicator();
1273 DALI_TEST_CHECK( indicator );
1275 // Make the indicator initially visible
1276 indicator.SetOpacity(1.0f);
1278 // Render and notify
1279 application.SendNotification();
1280 application.Render();
1282 // Check that the indicator is initially visible
1283 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1285 // Get the default duration to show the indicator
1286 float duration = scrollBar.GetIndicatorShowDuration();
1288 // Check that the default duration is greater than 0
1289 DALI_TEST_CHECK( duration > 0.0f );
1291 // Show the indicator
1292 scrollBar.ShowIndicator();
1294 // Render and notify
1295 application.SendNotification();
1296 application.Render();
1298 // Check that the indicator is still visible in the very next frame
1299 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1304 int UtcDaliToolkitScrollBarHideIndicatorP(void)
1306 ToolkitTestApplication application;
1308 // Create a scroll bar
1309 ScrollBar scrollBar = ScrollBar::New();
1310 DALI_TEST_CHECK( scrollBar );
1312 Stage::GetCurrent().Add( scrollBar );
1314 Actor indicator = scrollBar.GetScrollIndicator();
1315 DALI_TEST_CHECK( indicator );
1317 // Get the default duration to hide the indicator
1318 float duration = scrollBar.GetIndicatorHideDuration();
1320 // Check that the default duration is greater than 0
1321 DALI_TEST_CHECK( duration > 0.0f );
1323 // Make the indicator visible
1324 indicator.SetOpacity(1.0f);
1326 // Render and notify
1327 application.SendNotification();
1328 application.Render();
1330 // Check that the indicator is visible
1331 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1333 // Hide the indicator
1334 scrollBar.HideIndicator();
1336 // Wait for the specified duration
1337 Wait(application, duration * 1000);
1339 // Render and notify
1340 application.SendNotification();
1341 application.Render();
1343 // Check that the indicator is now invisible
1344 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1349 int UtcDaliToolkitScrollBarHideIndicatorN(void)
1351 ToolkitTestApplication application;
1353 // Create a scroll bar
1354 ScrollBar scrollBar = ScrollBar::New();
1355 DALI_TEST_CHECK( scrollBar );
1357 Stage::GetCurrent().Add( scrollBar );
1359 Actor indicator = scrollBar.GetScrollIndicator();
1360 DALI_TEST_CHECK( indicator );
1362 // Make the indicator initially invisible
1363 indicator.SetOpacity(0.0f);
1365 // Render and notify
1366 application.SendNotification();
1367 application.Render();
1369 // Check that the indicator is initially invisible
1370 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1372 // Get the default duration to hide the indicator
1373 float duration = scrollBar.GetIndicatorHideDuration();
1375 // Check that the default duration is greater than 0
1376 DALI_TEST_CHECK( duration > 0.0f );
1378 // Hide the indicator
1379 scrollBar.HideIndicator();
1381 // Render and notify
1382 application.SendNotification();
1383 application.Render();
1385 // Check that the indicator is still invisible in the very next frame
1386 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1391 int UtcDaliToolkitScrollBarPanFinishedSignalP(void)
1393 ToolkitTestApplication application;
1395 // Create a vertical scroll bar
1396 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1397 DALI_TEST_CHECK( scrollBar );
1399 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
1400 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1401 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
1403 // Set the indicator height to be fixed to 50.0f
1404 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
1405 scrollBar.SetIndicatorFixedHeight(50.0f);
1407 Stage::GetCurrent().Add( scrollBar );
1409 // Connect the pan finished signal
1410 ConnectionTracker connectionTracker;
1411 bool panFinished = false;
1412 scrollBar.PanFinishedSignal().Connect( &OnPanFinished );
1413 scrollBar.ConnectSignal( &connectionTracker, "panFinished", CallbackFunctor(&panFinished));
1415 // Render and notify
1416 application.SendNotification();
1417 application.Render();
1419 // Create a source actor that owns the scroll properties required by the scroll bar
1420 Actor sourceActor = Actor::New();
1421 Stage::GetCurrent().Add( sourceActor );
1423 // Register the scroll properties
1424 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1425 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1426 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
1427 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
1429 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1430 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1431 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1432 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1434 // Set the source of the scroll position properties.
1435 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1437 // Render and notify
1438 application.SendNotification();
1439 application.Render();
1441 // Perform a swipe gesture on the indicator
1442 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20);
1443 DALI_TEST_EQUALS( gOnPanFinishedCalled, true, TEST_LOCATION );
1444 DALI_TEST_EQUALS( panFinished, true, TEST_LOCATION );
1449 int UtcDaliToolkitScrollBarPanFinishedSignalN(void)
1451 ToolkitTestApplication application;
1453 // Create a vertical scroll bar
1454 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1455 DALI_TEST_CHECK( scrollBar );
1457 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
1458 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1459 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
1461 // Set the indicator height to be fixed to 50.0f
1462 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
1463 scrollBar.SetIndicatorFixedHeight(50.0f);
1465 Stage::GetCurrent().Add( scrollBar );
1467 // Connect the pan finished signal
1468 ConnectionTracker connectionTracker;
1469 bool panFinished = false;
1470 scrollBar.PanFinishedSignal().Connect( &OnPanFinished );
1471 scrollBar.ConnectSignal( &connectionTracker, "panFinished", CallbackFunctor(&panFinished));
1473 // Render and notify
1474 application.SendNotification();
1475 application.Render();
1477 // Perform a vertical swipe gesture on the indicator when there is no source object set on the scroll bar
1478 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20);
1479 DALI_TEST_EQUALS( gOnPanFinishedCalled, false, TEST_LOCATION );
1481 // Create a source actor that owns the scroll properties required by the scroll bar
1482 Actor sourceActor = Actor::New();
1483 Stage::GetCurrent().Add( sourceActor );
1485 // Register the scroll properties
1486 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1487 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1488 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
1489 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
1491 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1492 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1493 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1494 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1496 // Set the source of the scroll position properties.
1497 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1499 // Render and notify
1500 application.SendNotification();
1501 application.Render();
1503 // Perform a swipe gesture on the scroll bar but not on the indicator
1504 PerformGestureSwipe(application, Vector2(1.0f, 780.0f), Vector2(Vector2::YAXIS * -1.0f), 20);
1505 DALI_TEST_EQUALS( gOnPanFinishedCalled, false, TEST_LOCATION );
1506 DALI_TEST_EQUALS( panFinished, false, TEST_LOCATION );
1508 // Perform a swipe gesture on the indicator
1509 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20);
1510 DALI_TEST_EQUALS( gOnPanFinishedCalled, true, TEST_LOCATION );
1511 DALI_TEST_EQUALS( panFinished, true, TEST_LOCATION );
1516 int UtcDaliToolkitScrollBarScrollPositionIntervalReachedSignalP(void)
1518 ToolkitTestApplication application;
1520 // Create a vertical scroll bar
1521 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1522 DALI_TEST_CHECK( scrollBar );
1524 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
1525 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1526 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
1528 Stage::GetCurrent().Add( scrollBar );
1529 ConnectionTracker connectionTracker;
1531 // Connect to the ScrollPositionIntervalReached signal
1532 bool intervalReached = false;
1533 scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
1534 scrollBar.ConnectSignal( &connectionTracker, "scrollPositionIntervalReached", CallbackFunctor(&intervalReached));
1536 // Render and notify
1537 application.SendNotification();
1538 application.Render();
1540 // Create a source actor that owns the scroll properties required by the scroll bar
1541 Actor sourceActor = Actor::New();
1542 Stage::GetCurrent().Add( sourceActor );
1544 // Register the scroll properties
1545 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1546 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1547 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 800.0f );
1548 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 2000.0f );
1550 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1551 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1552 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1553 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1555 // Set the source of the scroll position properties.
1556 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1558 // Render and notify
1559 application.SendNotification();
1560 application.Render();
1562 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
1563 Dali::Vector<float> positionIntervals;
1564 for( size_t i = 0; i != 10; ++i )
1566 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
1568 scrollBar.SetScrollPositionIntervals(positionIntervals);
1570 // Render and notify
1571 application.SendNotification();
1572 application.Render();
1575 gOnScrollPositionIntervalReachedSignalCalled = false;
1577 // Animate the scroll position to cross the specified value
1578 Animation animation = Animation::New(0.1f);
1579 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
1582 // Wait for 0.1 second
1583 Wait(application, 100);
1585 // Check that the signal callback is called
1586 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1587 DALI_TEST_EQUALS( intervalReached, true, TEST_LOCATION );
1590 gOnScrollPositionIntervalReachedSignalCalled = false;
1591 intervalReached = false;
1593 // Rest and clear the animation
1597 // Animate the scroll position to cross another specified value
1598 animation = Animation::New(0.1f);
1599 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -170.0f );
1602 // Wait for 0.1 second
1603 Wait(application, 100);
1605 // Check that the signal callback is called
1606 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1607 DALI_TEST_EQUALS( intervalReached, true, TEST_LOCATION );
1610 gOnScrollPositionIntervalReachedSignalCalled = false;
1611 intervalReached = false;
1613 // Rest and clear the animation
1617 // Animate the scroll position back to the previous value
1618 animation = Animation::New(0.1f);
1619 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
1622 // Wait for 0.1 second
1623 Wait(application, 100);
1625 // Check that the signal callback is called
1626 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1627 DALI_TEST_EQUALS( intervalReached, true, TEST_LOCATION );
1632 int UtcDaliToolkitScrollBarScrollPositionIntervalReachedSignalN(void)
1634 ToolkitTestApplication application;
1636 // Create a vertical scroll bar
1637 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1638 DALI_TEST_CHECK( scrollBar );
1640 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
1641 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1642 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
1644 Stage::GetCurrent().Add( scrollBar );
1646 // Connect to the ScrollPositionIntervalReached signal
1647 scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
1649 // Render and notify
1650 application.SendNotification();
1651 application.Render();
1653 // Create a source actor that owns the scroll properties required by the scroll bar
1654 Actor sourceActor = Actor::New();
1655 Stage::GetCurrent().Add( sourceActor );
1657 // Register the scroll properties
1658 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1659 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1660 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 800.0f );
1661 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 2000.0f );
1663 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1664 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1665 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1666 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1668 // Set the source of the scroll position properties.
1669 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1671 // Render and notify
1672 application.SendNotification();
1673 application.Render();
1675 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
1676 Dali::Vector<float> positionIntervals;
1677 for( size_t i = 0; i != 10; ++i )
1679 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
1681 scrollBar.SetScrollPositionIntervals(positionIntervals);
1683 // Render and notify
1684 application.SendNotification();
1685 application.Render();
1688 gOnScrollPositionIntervalReachedSignalCalled = false;
1690 // Animate the scroll position not to cross the specified value
1691 Animation animation = Animation::New(0.1f);
1692 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -70.0f );
1695 // Wait for 0.1 second
1696 Wait(application, 100);
1698 // Check that the signal callback is not called
1699 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, false, TEST_LOCATION );
1701 // Rest and clear the animation
1705 // Animate the scroll position to cross another specified value
1706 animation = Animation::New(0.1f);
1707 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
1710 // Wait for 0.1 second
1711 Wait(application, 100);
1713 // Check that the signal callback is called
1714 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );