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.
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <dali-toolkit/dali-toolkit.h>
22 #include <dali/integration-api/events/pan-gesture-event.h>
25 using namespace Toolkit;
27 void dali_scrollbar_startup(void)
29 test_return_value = TET_UNDEF;
32 void dali_scrollbar_cleanup(void)
34 test_return_value = TET_PASS;
40 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
42 // Generate a PanGestureEvent to send to Core
43 Integration::PanGestureEvent GeneratePan(
45 const Vector2& previousPosition,
46 const Vector2& currentPosition,
47 unsigned long timeDelta,
48 unsigned int numberOfTouches = 1)
50 Integration::PanGestureEvent pan(state);
52 pan.previousPosition = previousPosition;
53 pan.currentPosition = currentPosition;
54 pan.timeDelta = timeDelta;
55 pan.numberOfTouches = numberOfTouches;
61 * Helper to generate PanGestureEvent
63 * @param[in] application Application instance
64 * @param[in] state The Gesture State
65 * @param[in] pos The current position of touch.
67 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
71 if( (state == Gesture::Started) ||
72 (state == Gesture::Possible) )
78 application.ProcessEvent(GeneratePan(state, last, pos, RENDER_FRAME_INTERVAL));
85 * Simulate time passed by.
87 * @note this will always process at least 1 frame (1/60 sec)
89 * @param application Test application instance
90 * @param duration Time to pass in milliseconds.
91 * @return The actual time passed in milliseconds
93 int Wait(ToolkitTestApplication& application, int duration = 0)
97 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
99 application.SendNotification();
100 application.Render(RENDER_FRAME_INTERVAL);
101 time += RENDER_FRAME_INTERVAL;
109 static bool gOnPanFinishedCalled; ///< Whether the PanFinished signal was invoked.
110 static bool gOnScrollPositionIntervalReachedSignalCalled; ///< Whether the ScrollPositionIntervalReached signal was invoked.
113 * Invoked when pan gesture is finished on the scroll indicator.
115 static void OnPanFinished()
117 gOnPanFinishedCalled = true;
121 * Invoked when the current scroll position of the scrollable content goes above or below the values
122 * specified by SCROLL_POSITION_INTERVALS property.
124 * @param[in] position The current scroll position.
126 static void OnScrollPositionIntervalReached( float position )
128 gOnScrollPositionIntervalReachedSignalCalled = true;
131 static Vector2 PerformGestureSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames)
133 gOnPanFinishedCalled = false;
135 // Now do a pan starting from (start) and heading (direction)
137 SendPan(application, Gesture::Possible, pos);
138 SendPan(application, Gesture::Started, pos);
141 for(int i = 0; i < frames; i++)
143 pos += direction; // Move in this direction
144 SendPan(application, Gesture::Continuing, pos);
148 pos += direction; // Move in this direction.
149 SendPan(application, Gesture::Finished, pos);
157 int UtcDaliToolkitScrollBarConstructorP(void)
159 ToolkitTestApplication application;
162 DALI_TEST_CHECK( !scrollBar );
166 int UtcDaliToolkitScrollBarCopyConstructorP(void)
168 ToolkitTestApplication application;
170 ScrollBar scrollBar = ScrollBar::New();
171 scrollBar.SetProperty( ScrollBar::Property::INDICATOR_FIXED_HEIGHT, 38.2f );
173 ScrollBar copy( scrollBar );
174 DALI_TEST_CHECK( copy );
175 DALI_TEST_CHECK( copy.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) == scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) );
179 int UtcDaliToolkitScrollBarAssignmentOperatorP(void)
181 ToolkitTestApplication application;
183 ScrollBar scrollBar = ScrollBar::New();
184 scrollBar.SetProperty( ScrollBar::Property::INDICATOR_FIXED_HEIGHT, 38.2f );
186 ScrollBar copy = scrollBar;
187 DALI_TEST_CHECK( copy );
188 DALI_TEST_CHECK( copy.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) == scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) );
192 int UtcDaliScrollBarDestructorP(void)
194 ToolkitTestApplication application;
196 ScrollBar* scrollBar = new ScrollBar();
199 DALI_TEST_CHECK( true );
203 int UtcDaliToolkitScrollBarNewP(void)
205 ToolkitTestApplication application;
207 ScrollBar scrollBar = ScrollBar::New();
208 DALI_TEST_CHECK( scrollBar );
211 ScrollBar vertical = ScrollBar::New(ScrollBar::Vertical);
212 DALI_TEST_CHECK( vertical );
213 DALI_TEST_CHECK( vertical.GetScrollDirection() == ScrollBar::Vertical );
215 ScrollBar horizontal = ScrollBar::New(ScrollBar::Horizontal);
216 DALI_TEST_CHECK( horizontal );
217 DALI_TEST_CHECK( horizontal.GetScrollDirection() == ScrollBar::Horizontal );
222 int UtcDaliToolkitScrollBarDownCastP(void)
224 ToolkitTestApplication application;
226 ScrollBar scrollBar1 = ScrollBar::New();
227 BaseHandle object( scrollBar1 );
229 ScrollBar scrollBar2 = ScrollBar::DownCast( object );
230 DALI_TEST_CHECK( scrollBar2 );
232 ScrollBar scrollBar3 = DownCast< ScrollBar >( object );
233 DALI_TEST_CHECK( scrollBar3 );
237 int UtcDaliToolkitScrollBarDownCastN(void)
239 ToolkitTestApplication application;
241 BaseHandle uninitializedObject;
242 ScrollBar scrollBar1 = ScrollBar::DownCast( uninitializedObject );
243 DALI_TEST_CHECK( !scrollBar1 );
245 ScrollBar scrollBar2 = DownCast< ScrollBar >( uninitializedObject );
246 DALI_TEST_CHECK( !scrollBar2 );
250 int UtcDaliToolkitScrollBarSetScrollPropertySourceP(void)
252 ToolkitTestApplication application;
254 // Create a vertical scroll bar
255 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
256 DALI_TEST_CHECK( scrollBar );
257 DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::Vertical );
259 float scrollBarHeight = 100.0f;
260 scrollBar.SetSize(20.0f, scrollBarHeight, 0.0f);
261 Stage::GetCurrent().Add( scrollBar );
263 // Create a source actor that owns the scroll properties required by the scroll bar
264 Actor sourceActor = Actor::New();
265 Stage::GetCurrent().Add( sourceActor );
267 // Register the scroll properties
268 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
269 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
270 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
271 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
273 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
274 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
275 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
276 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
278 // Set the source of the scroll position properties.
279 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
282 application.SendNotification();
283 application.Render();
285 Actor indicator = scrollBar.GetScrollIndicator();
286 DALI_TEST_CHECK( indicator );
288 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
289 // i.e. The bigger the content size, the smaller the indicator size
290 float indicatorHeight = indicator.GetCurrentSize().y;
291 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
293 // Decrease the content length
294 sourceActor.SetProperty( propertyScrollContentSize, 250.0f );
297 application.SendNotification();
298 application.Render();
300 // Check that the indicator size is changed accordingly
301 indicatorHeight = indicator.GetCurrentSize().y;
302 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 250.0f, TEST_LOCATION );
304 // As scroll position is 0, check that the indicator position should be 0.0f.
305 float indicatorPosition = indicator.GetCurrentPosition().y;
306 DALI_TEST_EQUALS( indicatorPosition, 0.0f, TEST_LOCATION );
308 // Set the scroll position to the middle
309 sourceActor.SetProperty( propertyScrollPosition, -50.0f );
312 application.SendNotification();
313 application.Render();
315 // Check that the indicator should be in the middle of the scroll bar
316 indicatorPosition = indicator.GetCurrentPosition().y;
317 DALI_TEST_EQUALS( indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.5f, TEST_LOCATION );
319 // Set the scroll position to the maximum
320 sourceActor.SetProperty( propertyScrollPosition, -100.0f );
323 application.SendNotification();
324 application.Render();
326 // Check that the indicator should be in the end of the scroll bar
327 indicatorPosition = indicator.GetCurrentPosition().y;
328 DALI_TEST_EQUALS( indicatorPosition, scrollBarHeight - indicatorHeight, TEST_LOCATION );
330 // Increase the maximum scroll position to double
331 sourceActor.SetProperty( propertyMaxScrollPosition, 200.0f );
334 application.SendNotification();
335 application.Render();
337 // Check that the indicator should be now in the middle of the scroll bar
338 indicatorPosition = indicator.GetCurrentPosition().y;
339 DALI_TEST_EQUALS( indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.5f, TEST_LOCATION );
341 // Create another source actor
342 Actor newSourceActor = Actor::New();
343 Stage::GetCurrent().Add( newSourceActor );
345 // Register the scroll properties
346 Property::Index newPropertyScrollPosition = newSourceActor.RegisterProperty( "sourcePosition", 0.0f );
347 Property::Index newPropertyMinScrollPosition = newSourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
348 Property::Index newPropertyMaxScrollPosition = newSourceActor.RegisterProperty( "sourcePositionMax", 200.0f );
349 Property::Index newPropertyScrollContentSize = newSourceActor.RegisterProperty( "sourceContentSize", 400.0f );
351 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourcePosition" ), newPropertyScrollPosition, TEST_LOCATION );
352 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourcePositionMin" ), newPropertyMinScrollPosition, TEST_LOCATION );
353 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourcePositionMax" ), newPropertyMaxScrollPosition, TEST_LOCATION );
354 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourceContentSize" ), newPropertyScrollContentSize, TEST_LOCATION );
356 // Change the source of the scroll position properties to be the new source actor.
357 scrollBar.SetScrollPropertySource(newSourceActor, newPropertyScrollPosition, newPropertyMinScrollPosition, newPropertyMaxScrollPosition, newPropertyScrollContentSize);
360 application.SendNotification();
361 application.Render();
363 // Check that the indicator size is changed accordingly
364 indicatorHeight = indicator.GetCurrentSize().y;
365 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 400.0f, TEST_LOCATION );
367 // Check that the indicator position goes back to the beginning of the scroll bar
368 indicatorPosition = indicator.GetCurrentPosition().y;
369 DALI_TEST_EQUALS( indicatorPosition, 0.0f, TEST_LOCATION );
371 // Set the scroll position to one fifth of the maximum
372 newSourceActor.SetProperty( propertyScrollPosition, -40.0f );
375 application.SendNotification();
376 application.Render();
378 // Check that the indicator should be in one fifth from the beginning of the scroll bar
379 indicatorPosition = indicator.GetCurrentPosition().y;
380 DALI_TEST_EQUALS( indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.2f, TEST_LOCATION );
385 int UtcDaliToolkitScrollBarSetScrollPropertySourceN(void)
387 ToolkitTestApplication application;
389 // Create a scroll bar
390 ScrollBar scrollBar = ScrollBar::New();
391 DALI_TEST_CHECK( scrollBar );
393 // Set empty handle of source object and invalid source property index.
395 scrollBar.SetScrollPropertySource(sourceActor, Property::INVALID_INDEX, Property::INVALID_INDEX, Property::INVALID_INDEX, Property::INVALID_INDEX);
397 DALI_TEST_CHECK( true );
401 int UtcDaliToolkitScrollBarSetScrollIndicatorP(void)
403 ToolkitTestApplication application;
405 // Create a scroll bar
406 ScrollBar scrollBar = ScrollBar::New();
407 DALI_TEST_CHECK( scrollBar );
409 Actor indicator = scrollBar.GetScrollIndicator();
410 DALI_TEST_CHECK( indicator );
412 // Set a new indicator
413 Actor newIndicator = Actor::New();
414 scrollBar.SetScrollIndicator(newIndicator);
416 // Check that the new indicator is successfully set
417 DALI_TEST_CHECK( indicator != scrollBar.GetScrollIndicator() );
418 DALI_TEST_CHECK( newIndicator == scrollBar.GetScrollIndicator() );
423 int UtcDaliToolkitScrollBarSetScrollIndicatorN(void)
425 ToolkitTestApplication application;
427 // Create a scroll bar
428 ScrollBar scrollBar = ScrollBar::New();
429 DALI_TEST_CHECK( scrollBar );
431 Actor indicator = scrollBar.GetScrollIndicator();
432 DALI_TEST_CHECK( indicator );
434 // Try to set an uninitialized actor as the indicator
435 Actor uninitializedIndicator;
436 scrollBar.SetScrollIndicator(uninitializedIndicator);
438 // Check that the uninitialized actor can not be set as the indicator
439 DALI_TEST_CHECK( indicator == scrollBar.GetScrollIndicator() );
440 DALI_TEST_CHECK( uninitializedIndicator != scrollBar.GetScrollIndicator() );
445 int UtcDaliToolkitScrollBarGetScrollIndicatorP(void)
447 ToolkitTestApplication application;
449 // Create a scroll bar
450 ScrollBar scrollBar = ScrollBar::New();
451 DALI_TEST_CHECK( scrollBar );
453 Actor indicator = scrollBar.GetScrollIndicator();
454 DALI_TEST_CHECK( indicator );
456 // Set a new indicator
457 Actor newIndicator = Actor::New();
458 scrollBar.SetScrollIndicator(newIndicator);
460 // Check that the new indicator is successfully set
461 DALI_TEST_CHECK( scrollBar.GetScrollIndicator() );
462 DALI_TEST_CHECK( indicator != scrollBar.GetScrollIndicator() );
463 DALI_TEST_CHECK( newIndicator == scrollBar.GetScrollIndicator() );
468 int UtcDaliToolkitScrollBarGetScrollIndicatorN(void)
470 ToolkitTestApplication application;
472 // Create a scroll bar
473 ScrollBar scrollBar = ScrollBar::New();
474 DALI_TEST_CHECK( scrollBar );
476 Actor indicator = scrollBar.GetScrollIndicator();
477 DALI_TEST_CHECK( indicator );
479 // Try to set an uninitialized actor as the indicator
480 Actor uninitializedIndicator;
481 scrollBar.SetScrollIndicator(uninitializedIndicator);
483 // Check that the indicator has not been changed
484 DALI_TEST_CHECK( indicator == scrollBar.GetScrollIndicator() );
485 DALI_TEST_CHECK( uninitializedIndicator != scrollBar.GetScrollIndicator() );
490 int UtcDaliToolkitScrollBarSetScrollPositionIntervalsP(void)
492 ToolkitTestApplication application;
494 // Create a vertical scroll bar
495 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
496 DALI_TEST_CHECK( scrollBar );
498 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
499 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
500 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
502 Stage::GetCurrent().Add( scrollBar );
504 // Connect to the ScrollPositionIntervalReached signal
505 scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
508 application.SendNotification();
509 application.Render();
511 // Create a source actor that owns the scroll properties required by the scroll bar
512 Actor sourceActor = Actor::New();
513 Stage::GetCurrent().Add( sourceActor );
515 // Register the scroll properties
516 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
517 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
518 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 800.0f );
519 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 2000.0f );
521 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
522 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
523 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
524 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
526 // Set the source of the scroll position properties.
527 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
530 application.SendNotification();
531 application.Render();
533 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
534 Dali::Vector<float> positionIntervals;
535 for( size_t i = 0; i != 10; ++i )
537 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
539 scrollBar.SetScrollPositionIntervals(positionIntervals);
541 // Get the list of scroll position intervals for notification
542 Dali::Vector<float> results = scrollBar.GetScrollPositionIntervals();
544 // Check that the result is the same as the list previously set.
545 DALI_TEST_EQUALS( positionIntervals.Count(), results.Count(), TEST_LOCATION );
546 DALI_TEST_EQUALS( positionIntervals[0], results[0], TEST_LOCATION );
547 DALI_TEST_EQUALS( positionIntervals[1], results[1], TEST_LOCATION );
548 DALI_TEST_EQUALS( positionIntervals[2], results[2], TEST_LOCATION );
549 DALI_TEST_EQUALS( positionIntervals[3], results[3], TEST_LOCATION );
550 DALI_TEST_EQUALS( positionIntervals[4], results[4], TEST_LOCATION );
551 DALI_TEST_EQUALS( positionIntervals[5], results[5], TEST_LOCATION );
552 DALI_TEST_EQUALS( positionIntervals[6], results[6], TEST_LOCATION );
553 DALI_TEST_EQUALS( positionIntervals[7], results[7], TEST_LOCATION );
554 DALI_TEST_EQUALS( positionIntervals[8], results[8], TEST_LOCATION );
555 DALI_TEST_EQUALS( positionIntervals[9], results[9], TEST_LOCATION );
558 gOnScrollPositionIntervalReachedSignalCalled = false;
560 // Animate the scroll position to cross the specified value
561 Animation animation = Animation::New(0.1f);
562 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
565 // Wait for 0.1 second
566 Wait(application, 100);
568 // Check that the signal callback is called
569 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
572 gOnScrollPositionIntervalReachedSignalCalled = false;
574 // Rest and clear the animation
578 // Animate the scroll position to cross another specified value
579 animation = Animation::New(0.1f);
580 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -170.0f );
583 // Wait for 0.1 second
584 Wait(application, 100);
586 // Check that the signal callback is called
587 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
590 gOnScrollPositionIntervalReachedSignalCalled = false;
592 // Rest and clear the animation
596 // Animate the scroll position back to the previous value
597 animation = Animation::New(0.1f);
598 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
601 // Wait for 0.1 second
602 Wait(application, 100);
604 // Check that the signal callback is called
605 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
610 int UtcDaliToolkitScrollBarGetScrollPositionIntervalsP(void)
612 ToolkitTestApplication application;
614 // Create a vertical scroll bar
615 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
616 DALI_TEST_CHECK( scrollBar );
618 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
619 Dali::Vector<float> positionIntervals;
620 for( size_t i = 0; i != 10; ++i )
622 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
624 scrollBar.SetScrollPositionIntervals(positionIntervals);
626 // Get the list of scroll position intervals for notification
627 Dali::Vector<float> results = scrollBar.GetScrollPositionIntervals();
629 // Check that the result is the same as the list previously set.
630 DALI_TEST_EQUALS( positionIntervals.Count(), results.Count(), TEST_LOCATION );
631 DALI_TEST_EQUALS( positionIntervals[0], results[0], TEST_LOCATION );
632 DALI_TEST_EQUALS( positionIntervals[1], results[1], TEST_LOCATION );
633 DALI_TEST_EQUALS( positionIntervals[2], results[2], TEST_LOCATION );
634 DALI_TEST_EQUALS( positionIntervals[3], results[3], TEST_LOCATION );
635 DALI_TEST_EQUALS( positionIntervals[4], results[4], TEST_LOCATION );
636 DALI_TEST_EQUALS( positionIntervals[5], results[5], TEST_LOCATION );
637 DALI_TEST_EQUALS( positionIntervals[6], results[6], TEST_LOCATION );
638 DALI_TEST_EQUALS( positionIntervals[7], results[7], TEST_LOCATION );
639 DALI_TEST_EQUALS( positionIntervals[8], results[8], TEST_LOCATION );
640 DALI_TEST_EQUALS( positionIntervals[9], results[9], TEST_LOCATION );
645 int UtcDaliToolkitScrollBarGetScrollDirectionP(void)
647 ToolkitTestApplication application;
649 // Create a vertical scroll bar
650 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
651 DALI_TEST_CHECK( scrollBar );
652 DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::Vertical );
654 // Change the direction of scroll bar to horizontal
655 scrollBar.SetScrollDirection(ScrollBar::Horizontal);
656 DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::Horizontal );
661 int UtcDaliToolkitScrollBarSetIndicatorHeightPolicyP(void)
663 ToolkitTestApplication application;
665 // Create a scroll bar
666 ScrollBar scrollBar = ScrollBar::New();
667 DALI_TEST_CHECK( scrollBar );
669 float scrollBarHeight = 100.0f;
670 scrollBar.SetSize(20.0f, scrollBarHeight, 0.0f);
671 Stage::GetCurrent().Add( scrollBar );
673 // Create a source actor that owns the scroll properties required by the scroll bar
674 Actor sourceActor = Actor::New();
675 Stage::GetCurrent().Add( sourceActor );
677 // Register the scroll properties
678 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
679 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
680 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
681 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
683 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
684 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
685 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
686 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
688 // Set the source of the scroll position properties.
689 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
692 application.SendNotification();
693 application.Render();
695 Actor indicator = scrollBar.GetScrollIndicator();
696 DALI_TEST_CHECK( indicator );
698 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
699 // i.e. The bigger the content size, the smaller the indicator size
700 float indicatorHeight = indicator.GetCurrentSize().y;
701 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
703 // Set the indicator height to be fixed to 50.0f
704 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
705 scrollBar.SetIndicatorFixedHeight(50.0f);
708 application.SendNotification();
709 application.Render();
711 // Check that the indicator size should be 50.0f
712 indicatorHeight = indicator.GetCurrentSize().y;
713 DALI_TEST_EQUALS( indicatorHeight, 50.0f, TEST_LOCATION );
715 // Set the indicator height to be variable
716 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Variable);
719 application.SendNotification();
720 application.Render();
722 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
723 indicatorHeight = indicator.GetCurrentSize().y;
724 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
729 int UtcDaliToolkitScrollBarGetIndicatorHeightPolicyP(void)
731 ToolkitTestApplication application;
733 // Create a scroll bar
734 ScrollBar scrollBar = ScrollBar::New();
735 DALI_TEST_CHECK( scrollBar );
737 // Set the indicator height to be fixed
738 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
739 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Fixed, TEST_LOCATION );
741 // Set the indicator height to be variable
742 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Variable);
743 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Variable, TEST_LOCATION );
748 int UtcDaliToolkitScrollBarSetIndicatorFixedHeightP(void)
750 ToolkitTestApplication application;
752 // Create a scroll bar
753 ScrollBar scrollBar = ScrollBar::New();
754 DALI_TEST_CHECK( scrollBar );
756 float scrollBarHeight = 100.0f;
757 scrollBar.SetSize(20.0f, scrollBarHeight, 0.0f);
758 Stage::GetCurrent().Add( scrollBar );
760 Actor indicator = scrollBar.GetScrollIndicator();
761 DALI_TEST_CHECK( indicator );
763 // Set the indicator height to be fixed to 50.0f
764 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
765 scrollBar.SetIndicatorFixedHeight(50.0f);
768 application.SendNotification();
769 application.Render();
771 // Check that the indicator size should be 50.0f
772 DALI_TEST_EQUALS( indicator.GetCurrentSize().y, 50.0f, TEST_LOCATION );
774 // Set the indicator height to be fixed to 25.0f
775 scrollBar.SetIndicatorFixedHeight(25.0f);
778 application.SendNotification();
779 application.Render();
781 // Check that the indicator size should be 25.0f
782 DALI_TEST_EQUALS( indicator.GetCurrentSize().y, 25.0f, TEST_LOCATION );
787 int UtcDaliToolkitScrollBarGetIndicatorFixedHeightP(void)
789 ToolkitTestApplication application;
791 // Create a scroll bar
792 ScrollBar scrollBar = ScrollBar::New();
793 DALI_TEST_CHECK( scrollBar );
795 // Set the fixed indicator height to be 50.0f
796 scrollBar.SetIndicatorFixedHeight(50.0f);
798 // Check that the indicator size should be 50.0f
799 DALI_TEST_EQUALS( scrollBar.GetIndicatorFixedHeight(), 50.0f, TEST_LOCATION );
801 // Set the indicator height to be fixed to 25.0f
802 scrollBar.SetIndicatorFixedHeight(25.0f);
804 // Check that the indicator size should be 50.0f
805 DALI_TEST_EQUALS( scrollBar.GetIndicatorFixedHeight(), 25.0f, TEST_LOCATION );
810 int UtcDaliToolkitScrollBarSetIndicatorShowDurationP(void)
812 ToolkitTestApplication application;
814 // Create a scroll bar
815 ScrollBar scrollBar = ScrollBar::New();
816 DALI_TEST_CHECK( scrollBar );
818 Stage::GetCurrent().Add( scrollBar );
820 Actor indicator = scrollBar.GetScrollIndicator();
821 DALI_TEST_CHECK( indicator );
823 // Set the duration to show the indicator to be 0.35 second
824 scrollBar.SetIndicatorShowDuration(0.35);
825 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.35f, TEST_LOCATION );
827 // Make the indicator invisible
828 indicator.SetOpacity(0.0f);
831 application.SendNotification();
832 application.Render();
834 // Check that the indicator is invisible
835 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
837 // Show the indicator
838 scrollBar.ShowIndicator();
840 // Wait for 0.35 second
841 Wait(application, 350);
844 application.SendNotification();
845 application.Render();
847 // Check that the indicator is now visible
848 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
850 // Set the duration to show the indicator to be 0.75 second
851 scrollBar.SetIndicatorShowDuration(0.75);
852 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.75f, TEST_LOCATION );
854 // Make the indicator invisible
855 indicator.SetOpacity(0.0f);
858 application.SendNotification();
859 application.Render();
861 // Check that the indicator is invisible
862 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
864 // Show the indicator
865 scrollBar.ShowIndicator();
867 // Wait for 0.35 second first
868 Wait(application, 350);
871 application.SendNotification();
872 application.Render();
874 // Check that the indicator is not fully visible yet
875 DALI_TEST_CHECK( indicator.GetCurrentOpacity() != 1.0f );
877 // Wait for another 0.4 second
878 Wait(application, 400);
881 application.SendNotification();
882 application.Render();
884 // Check that the indicator is now fully visible
885 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
890 int UtcDaliToolkitScrollBarSetIndicatorShowDurationN(void)
892 ToolkitTestApplication application;
894 // Create a scroll bar
895 ScrollBar scrollBar = ScrollBar::New();
896 DALI_TEST_CHECK( scrollBar );
898 Stage::GetCurrent().Add( scrollBar );
900 Actor indicator = scrollBar.GetScrollIndicator();
901 DALI_TEST_CHECK( indicator );
903 // Get the default duration to show the indicator
904 float duration = scrollBar.GetIndicatorShowDuration();
906 // Check that the default duration is greater than 0
907 DALI_TEST_CHECK( duration > 0.0f );
909 // Make the indicator invisible
910 indicator.SetOpacity(0.0f);
913 application.SendNotification();
914 application.Render();
916 // Check that the indicator is invisible
917 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
919 // Show the indicator
920 scrollBar.ShowIndicator();
922 // Wait for the specified duration
923 Wait(application, duration * 1000);
926 application.SendNotification();
927 application.Render();
929 // Check that the indicator is now visible
930 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
932 // Now set the duration to show the indicator to be a negative value (which should be ignored and therefore means instant)
933 scrollBar.SetIndicatorShowDuration(-0.25f);
934 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), -0.25f, TEST_LOCATION );
936 // Make the indicator invisible
937 indicator.SetOpacity(0.0f);
940 application.SendNotification();
941 application.Render();
943 // Check that the indicator is invisible
944 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
946 // Show the indicator
947 scrollBar.ShowIndicator();
950 application.SendNotification();
951 application.Render();
953 // Check that the indicator becomes instantly visible in the next frame
954 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
959 int UtcDaliToolkitScrollBarGetIndicatorShowDurationP(void)
961 ToolkitTestApplication application;
963 // Create a scroll bar
964 ScrollBar scrollBar = ScrollBar::New();
965 DALI_TEST_CHECK( scrollBar );
967 // Set the duration to show the indicator to be 0.35 second
968 scrollBar.SetIndicatorShowDuration(0.35f);
970 // Check that the duration to show the indicator is 0.35 second
971 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.35f, TEST_LOCATION );
973 // Set the duration to show the indicator to be 0.75 second
974 scrollBar.SetIndicatorShowDuration(0.75f);
976 // Check that the duration to show the indicator is 0.75 second
977 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.75f, TEST_LOCATION );
982 int UtcDaliToolkitScrollBarSetIndicatorHideDurationP(void)
984 ToolkitTestApplication application;
986 // Create a scroll bar
987 ScrollBar scrollBar = ScrollBar::New();
988 DALI_TEST_CHECK( scrollBar );
990 Stage::GetCurrent().Add( scrollBar );
992 Actor indicator = scrollBar.GetScrollIndicator();
993 DALI_TEST_CHECK( indicator );
995 // Set the duration to hide the indicator to be 0.15 second
996 scrollBar.SetIndicatorHideDuration(0.15f);
997 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.15f, TEST_LOCATION );
999 // Make the indicator visible
1000 indicator.SetOpacity(1.0f);
1002 // Render and notify
1003 application.SendNotification();
1004 application.Render();
1006 // Check that the indicator is visible
1007 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1009 // Hide the indicator
1010 scrollBar.HideIndicator();
1012 // Wait for 0.15 second
1013 Wait(application, 150);
1015 // Render and notify
1016 application.SendNotification();
1017 application.Render();
1019 // Check that the indicator is now invisible
1020 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1022 // Set the duration to hide the indicator to be 0.65 second
1023 scrollBar.SetIndicatorHideDuration(0.65f);
1024 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.65f, TEST_LOCATION );
1026 // Make the indicator visible
1027 indicator.SetOpacity(1.0f);
1029 // Render and notify
1030 application.SendNotification();
1031 application.Render();
1033 // Check that the indicator is visible
1034 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1036 // Hide the indicator
1037 scrollBar.HideIndicator();
1039 // Wait for 0.15 second first
1040 Wait(application, 150);
1042 // Render and notify
1043 application.SendNotification();
1044 application.Render();
1046 // Check that the indicator is not fully invisible yet
1047 DALI_TEST_CHECK( indicator.GetCurrentOpacity() != 0.0f );
1049 // Wait for another 0.5 second
1050 Wait(application, 500);
1052 // Render and notify
1053 application.SendNotification();
1054 application.Render();
1056 // Check that the indicator is now fully invisible
1057 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1062 int UtcDaliToolkitScrollBarSetIndicatorHideDurationN(void)
1064 ToolkitTestApplication application;
1066 // Create a scroll bar
1067 ScrollBar scrollBar = ScrollBar::New();
1068 DALI_TEST_CHECK( scrollBar );
1070 Stage::GetCurrent().Add( scrollBar );
1072 Actor indicator = scrollBar.GetScrollIndicator();
1073 DALI_TEST_CHECK( indicator );
1075 // Get the default duration to hide the indicator
1076 float duration = scrollBar.GetIndicatorHideDuration();
1078 // Check that the default duration is greater than 0
1079 DALI_TEST_CHECK( duration > 0.0f );
1081 // Make the indicator visible
1082 indicator.SetOpacity(1.0f);
1084 // Render and notify
1085 application.SendNotification();
1086 application.Render();
1088 // Check that the indicator is visible
1089 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1091 // Hide the indicator
1092 scrollBar.HideIndicator();
1094 // Wait for the specified duration
1095 Wait(application, duration * 1000);
1097 // Render and notify
1098 application.SendNotification();
1099 application.Render();
1101 // Check that the indicator is now invisible
1102 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1104 // Now set the duration to hide the indicator to be a negative value (which should be ignored and therefore means instant)
1105 scrollBar.SetIndicatorHideDuration(-0.25f);
1106 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), -0.25f, TEST_LOCATION );
1108 // Make the indicator visible
1109 indicator.SetOpacity(1.0f);
1111 // Render and notify
1112 application.SendNotification();
1113 application.Render();
1115 // Check that the indicator is visible
1116 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1118 // Hide the indicator
1119 scrollBar.HideIndicator();
1121 // Render and notify
1122 application.SendNotification();
1123 application.Render();
1125 // Check that the indicator becomes instantly invisible in the next frame
1126 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1131 int UtcDaliToolkitScrollBarGetIndicatorHideDurationP(void)
1133 ToolkitTestApplication application;
1135 // Create a scroll bar
1136 ScrollBar scrollBar = ScrollBar::New();
1137 DALI_TEST_CHECK( scrollBar );
1139 // Set the duration to hide the indicator to be 0.15 second
1140 scrollBar.SetIndicatorHideDuration(0.15f);
1142 // Check that the duration to hide the indicator is 0.15 second
1143 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.15f, TEST_LOCATION );
1145 // Set the duration to hide the indicator to be 0.65 second
1146 scrollBar.SetIndicatorHideDuration(0.65f);
1148 // Check that the duration to hide the indicator is 0.65 second
1149 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.65f, TEST_LOCATION );
1154 int UtcDaliToolkitScrollBarShowIndicatorP(void)
1156 ToolkitTestApplication application;
1158 // Create a scroll bar
1159 ScrollBar scrollBar = ScrollBar::New();
1160 DALI_TEST_CHECK( scrollBar );
1162 Stage::GetCurrent().Add( scrollBar );
1164 Actor indicator = scrollBar.GetScrollIndicator();
1165 DALI_TEST_CHECK( indicator );
1167 // Get the default duration to show the indicator
1168 float duration = scrollBar.GetIndicatorShowDuration();
1170 // Check that the default duration is greater than 0
1171 DALI_TEST_CHECK( duration > 0.0f );
1173 // Make the indicator invisible
1174 indicator.SetOpacity(0.0f);
1176 // Render and notify
1177 application.SendNotification();
1178 application.Render();
1180 // Check that the indicator is invisible
1181 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1183 // Show the indicator
1184 scrollBar.ShowIndicator();
1186 // Wait for the specified duration
1187 Wait(application, duration * 1000);
1189 // Render and notify
1190 application.SendNotification();
1191 application.Render();
1193 // Check that the indicator is now visible
1194 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1199 int UtcDaliToolkitScrollBarShowIndicatorN(void)
1201 ToolkitTestApplication application;
1203 // Create a scroll bar
1204 ScrollBar scrollBar = ScrollBar::New();
1205 DALI_TEST_CHECK( scrollBar );
1207 Stage::GetCurrent().Add( scrollBar );
1209 Actor indicator = scrollBar.GetScrollIndicator();
1210 DALI_TEST_CHECK( indicator );
1212 // Make the indicator initially visible
1213 indicator.SetOpacity(1.0f);
1215 // Render and notify
1216 application.SendNotification();
1217 application.Render();
1219 // Check that the indicator is initially visible
1220 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1222 // Get the default duration to show the indicator
1223 float duration = scrollBar.GetIndicatorShowDuration();
1225 // Check that the default duration is greater than 0
1226 DALI_TEST_CHECK( duration > 0.0f );
1228 // Show the indicator
1229 scrollBar.ShowIndicator();
1231 // Render and notify
1232 application.SendNotification();
1233 application.Render();
1235 // Check that the indicator is still visible in the very next frame
1236 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1241 int UtcDaliToolkitScrollBarHideIndicatorP(void)
1243 ToolkitTestApplication application;
1245 // Create a scroll bar
1246 ScrollBar scrollBar = ScrollBar::New();
1247 DALI_TEST_CHECK( scrollBar );
1249 Stage::GetCurrent().Add( scrollBar );
1251 Actor indicator = scrollBar.GetScrollIndicator();
1252 DALI_TEST_CHECK( indicator );
1254 // Get the default duration to hide the indicator
1255 float duration = scrollBar.GetIndicatorHideDuration();
1257 // Check that the default duration is greater than 0
1258 DALI_TEST_CHECK( duration > 0.0f );
1260 // Make the indicator visible
1261 indicator.SetOpacity(1.0f);
1263 // Render and notify
1264 application.SendNotification();
1265 application.Render();
1267 // Check that the indicator is visible
1268 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1270 // Hide the indicator
1271 scrollBar.HideIndicator();
1273 // Wait for the specified duration
1274 Wait(application, duration * 1000);
1276 // Render and notify
1277 application.SendNotification();
1278 application.Render();
1280 // Check that the indicator is now invisible
1281 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1286 int UtcDaliToolkitScrollBarHideIndicatorN(void)
1288 ToolkitTestApplication application;
1290 // Create a scroll bar
1291 ScrollBar scrollBar = ScrollBar::New();
1292 DALI_TEST_CHECK( scrollBar );
1294 Stage::GetCurrent().Add( scrollBar );
1296 Actor indicator = scrollBar.GetScrollIndicator();
1297 DALI_TEST_CHECK( indicator );
1299 // Make the indicator initially invisible
1300 indicator.SetOpacity(0.0f);
1302 // Render and notify
1303 application.SendNotification();
1304 application.Render();
1306 // Check that the indicator is initially invisible
1307 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1309 // Get the default duration to hide the indicator
1310 float duration = scrollBar.GetIndicatorHideDuration();
1312 // Check that the default duration is greater than 0
1313 DALI_TEST_CHECK( duration > 0.0f );
1315 // Hide the indicator
1316 scrollBar.HideIndicator();
1318 // Render and notify
1319 application.SendNotification();
1320 application.Render();
1322 // Check that the indicator is still invisible in the very next frame
1323 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1328 int UtcDaliToolkitScrollBarPanFinishedSignalP(void)
1330 ToolkitTestApplication application;
1332 // Create a vertical scroll bar
1333 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1334 DALI_TEST_CHECK( scrollBar );
1336 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
1337 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1338 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
1340 // Set the indicator height to be fixed to 50.0f
1341 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
1342 scrollBar.SetIndicatorFixedHeight(50.0f);
1344 Stage::GetCurrent().Add( scrollBar );
1346 // Connect the pan finished signal
1347 scrollBar.PanFinishedSignal().Connect( &OnPanFinished );
1349 // Render and notify
1350 application.SendNotification();
1351 application.Render();
1353 // Create a source actor that owns the scroll properties required by the scroll bar
1354 Actor sourceActor = Actor::New();
1355 Stage::GetCurrent().Add( sourceActor );
1357 // Register the scroll properties
1358 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1359 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1360 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
1361 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
1363 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1364 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1365 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1366 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1368 // Set the source of the scroll position properties.
1369 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1371 // Render and notify
1372 application.SendNotification();
1373 application.Render();
1375 // Perform a swipe gesture on the indicator
1376 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20);
1377 DALI_TEST_EQUALS( gOnPanFinishedCalled, true, TEST_LOCATION );
1382 int UtcDaliToolkitScrollBarPanFinishedSignalN(void)
1384 ToolkitTestApplication application;
1386 // Create a vertical scroll bar
1387 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1388 DALI_TEST_CHECK( scrollBar );
1390 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
1391 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1392 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
1394 // Set the indicator height to be fixed to 50.0f
1395 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
1396 scrollBar.SetIndicatorFixedHeight(50.0f);
1398 Stage::GetCurrent().Add( scrollBar );
1400 // Connect the pan finished signal
1401 scrollBar.PanFinishedSignal().Connect( &OnPanFinished );
1403 // Render and notify
1404 application.SendNotification();
1405 application.Render();
1407 // Perform a vertical swipe gesture on the indicator when there is no source object set on the scroll bar
1408 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20);
1409 DALI_TEST_EQUALS( gOnPanFinishedCalled, false, TEST_LOCATION );
1411 // Create a source actor that owns the scroll properties required by the scroll bar
1412 Actor sourceActor = Actor::New();
1413 Stage::GetCurrent().Add( sourceActor );
1415 // Register the scroll properties
1416 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1417 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1418 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
1419 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
1421 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1422 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1423 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1424 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1426 // Set the source of the scroll position properties.
1427 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1429 // Render and notify
1430 application.SendNotification();
1431 application.Render();
1433 // Perform a swipe gesture on the scroll bar but not on the indicator
1434 PerformGestureSwipe(application, Vector2(1.0f, 780.0f), Vector2(Vector2::YAXIS * -1.0f), 20);
1435 DALI_TEST_EQUALS( gOnPanFinishedCalled, false, TEST_LOCATION );
1437 // Perform a swipe gesture on the indicator
1438 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20);
1439 DALI_TEST_EQUALS( gOnPanFinishedCalled, true, TEST_LOCATION );
1444 int UtcDaliToolkitScrollBarScrollPositionIntervalReachedSignalP(void)
1446 ToolkitTestApplication application;
1448 // Create a vertical scroll bar
1449 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1450 DALI_TEST_CHECK( scrollBar );
1452 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
1453 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1454 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
1456 Stage::GetCurrent().Add( scrollBar );
1458 // Connect to the ScrollPositionIntervalReached signal
1459 scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
1461 // Render and notify
1462 application.SendNotification();
1463 application.Render();
1465 // Create a source actor that owns the scroll properties required by the scroll bar
1466 Actor sourceActor = Actor::New();
1467 Stage::GetCurrent().Add( sourceActor );
1469 // Register the scroll properties
1470 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1471 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1472 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 800.0f );
1473 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 2000.0f );
1475 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1476 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1477 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1478 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1480 // Set the source of the scroll position properties.
1481 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1483 // Render and notify
1484 application.SendNotification();
1485 application.Render();
1487 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
1488 Dali::Vector<float> positionIntervals;
1489 for( size_t i = 0; i != 10; ++i )
1491 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
1493 scrollBar.SetScrollPositionIntervals(positionIntervals);
1495 // Render and notify
1496 application.SendNotification();
1497 application.Render();
1500 gOnScrollPositionIntervalReachedSignalCalled = false;
1502 // Animate the scroll position to cross the specified value
1503 Animation animation = Animation::New(0.1f);
1504 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
1507 // Wait for 0.1 second
1508 Wait(application, 100);
1510 // Check that the signal callback is called
1511 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1514 gOnScrollPositionIntervalReachedSignalCalled = false;
1516 // Rest and clear the animation
1520 // Animate the scroll position to cross another specified value
1521 animation = Animation::New(0.1f);
1522 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -170.0f );
1525 // Wait for 0.1 second
1526 Wait(application, 100);
1528 // Check that the signal callback is called
1529 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1532 gOnScrollPositionIntervalReachedSignalCalled = false;
1534 // Rest and clear the animation
1538 // Animate the scroll position back to the previous value
1539 animation = Animation::New(0.1f);
1540 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
1543 // Wait for 0.1 second
1544 Wait(application, 100);
1546 // Check that the signal callback is called
1547 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1552 int UtcDaliToolkitScrollBarScrollPositionIntervalReachedSignalN(void)
1554 ToolkitTestApplication application;
1556 // Create a vertical scroll bar
1557 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1558 DALI_TEST_CHECK( scrollBar );
1560 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
1561 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1562 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
1564 Stage::GetCurrent().Add( scrollBar );
1566 // Connect to the ScrollPositionIntervalReached signal
1567 scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
1569 // Render and notify
1570 application.SendNotification();
1571 application.Render();
1573 // Create a source actor that owns the scroll properties required by the scroll bar
1574 Actor sourceActor = Actor::New();
1575 Stage::GetCurrent().Add( sourceActor );
1577 // Register the scroll properties
1578 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1579 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1580 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 800.0f );
1581 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 2000.0f );
1583 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1584 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1585 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1586 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1588 // Set the source of the scroll position properties.
1589 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1591 // Render and notify
1592 application.SendNotification();
1593 application.Render();
1595 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
1596 Dali::Vector<float> positionIntervals;
1597 for( size_t i = 0; i != 10; ++i )
1599 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
1601 scrollBar.SetScrollPositionIntervals(positionIntervals);
1603 // Render and notify
1604 application.SendNotification();
1605 application.Render();
1608 gOnScrollPositionIntervalReachedSignalCalled = false;
1610 // Animate the scroll position not to cross the specified value
1611 Animation animation = Animation::New(0.1f);
1612 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -70.0f );
1615 // Wait for 0.1 second
1616 Wait(application, 100);
1618 // Check that the signal callback is not called
1619 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, false, TEST_LOCATION );
1621 // Rest and clear the animation
1625 // Animate the scroll position to cross another specified value
1626 animation = Animation::New(0.1f);
1627 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
1630 // Wait for 0.1 second
1631 Wait(application, 100);
1633 // Check that the signal callback is called
1634 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );