2 * Copyright (c) 2020 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-test-utils/toolkit-timer.h"
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali/devel-api/actors/actor-devel.h>
25 #include <dali-toolkit/devel-api/controls/scroll-bar/scroll-bar.h>
28 using namespace Toolkit;
30 void dali_scrollbar_startup(void)
32 test_return_value = TET_UNDEF;
35 void dali_scrollbar_cleanup(void)
37 test_return_value = TET_PASS;
43 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
46 * Simulate time passed by.
48 * @note this will always process at least 1 frame (1/60 sec)
50 * @param application Test application instance
51 * @param duration Time to pass in milliseconds.
52 * @return The actual time passed in milliseconds
54 int Wait(ToolkitTestApplication& application, int duration = 0)
58 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
60 application.SendNotification();
61 application.Render(RENDER_FRAME_INTERVAL);
62 time += RENDER_FRAME_INTERVAL;
70 static bool gOnPanFinishedCalled; ///< Whether the PanFinished signal was invoked.
71 static bool gOnScrollPositionIntervalReachedSignalCalled; ///< Whether the ScrollPositionIntervalReached signal was invoked.
74 * Invoked when pan gesture is finished on the scroll indicator.
76 static void OnPanFinished()
78 gOnPanFinishedCalled = true;
81 struct CallbackFunctor
83 CallbackFunctor(bool* callbackFlag)
84 : mCallbackFlag( callbackFlag )
90 *mCallbackFlag = true;
96 * Invoked when the current scroll position of the scrollable content goes above or below the values
97 * specified by SCROLL_POSITION_INTERVALS property.
99 * @param[in] position The current scroll position.
101 static void OnScrollPositionIntervalReached( float position )
103 gOnScrollPositionIntervalReachedSignalCalled = true;
106 static Vector2 PerformGestureSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, uint32_t start_time)
108 gOnPanFinishedCalled = false;
110 // Now do a pan starting from (start) and heading (direction)
111 Vector2 pos( start + ( direction * 15 ) );
112 uint32_t time = start_time;
114 TestStartPan( application, start, pos, time );
118 for(int i = 0; i < frames; i++)
120 Test::EmitGlobalTimerSignal();
122 pos += direction; // Move in this direction
123 time += RENDER_FRAME_INTERVAL;
124 TestMovePan( application, pos, time);
128 pos += direction; // Move in this direction.
129 time += RENDER_FRAME_INTERVAL;
130 TestEndPan(application, pos, time );
138 int UtcDaliToolkitScrollBarConstructorP(void)
140 ToolkitTestApplication application;
143 DALI_TEST_CHECK( !scrollBar );
147 int UtcDaliToolkitScrollBarCopyConstructorP(void)
149 ToolkitTestApplication application;
151 ScrollBar scrollBar = ScrollBar::New();
152 scrollBar.SetProperty( ScrollBar::Property::INDICATOR_FIXED_HEIGHT, 38.2f );
154 ScrollBar copy( scrollBar );
155 DALI_TEST_CHECK( copy );
156 DALI_TEST_CHECK( copy.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) == scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) );
160 int UtcDaliToolkitScrollBarAssignmentOperatorP(void)
162 ToolkitTestApplication application;
164 ScrollBar scrollBar = ScrollBar::New();
165 scrollBar.SetProperty( ScrollBar::Property::INDICATOR_FIXED_HEIGHT, 38.2f );
167 ScrollBar copy = scrollBar;
168 DALI_TEST_CHECK( copy );
169 DALI_TEST_CHECK( copy.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) == scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) );
173 int UtcDaliScrollBarDestructorP(void)
175 ToolkitTestApplication application;
177 ScrollBar* scrollBar = new ScrollBar();
180 DALI_TEST_CHECK( true );
184 int UtcDaliToolkitScrollBarNewP(void)
186 ToolkitTestApplication application;
188 ScrollBar scrollBar = ScrollBar::New();
189 DALI_TEST_CHECK( scrollBar );
192 ScrollBar vertical = ScrollBar::New(ScrollBar::VERTICAL);
193 DALI_TEST_CHECK( vertical );
194 DALI_TEST_CHECK( vertical.GetScrollDirection() == ScrollBar::VERTICAL );
196 Property::Value value = vertical.GetProperty(ScrollBar::Property::SCROLL_DIRECTION);
197 std::string scrollDirection = value.Get<std::string>();
198 DALI_TEST_EQUALS( scrollDirection, "VERTICAL", TEST_LOCATION );
200 ScrollBar horizontal = ScrollBar::New(ScrollBar::HORIZONTAL);
201 DALI_TEST_CHECK( horizontal );
202 DALI_TEST_CHECK( horizontal.GetScrollDirection() == ScrollBar::HORIZONTAL );
203 value = vertical.GetProperty(ScrollBar::Property::SCROLL_DIRECTION);
204 scrollDirection = value.Get<std::string>();
205 DALI_TEST_EQUALS( scrollDirection, "HORIZONTAL", TEST_LOCATION );
210 int UtcDaliToolkitScrollBarCreateP(void)
212 ToolkitTestApplication application;
214 TypeRegistry typeRegistry = TypeRegistry::Get();
215 DALI_TEST_CHECK( typeRegistry );
217 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "ScrollBar" );
218 DALI_TEST_CHECK( typeInfo );
220 BaseHandle handle = typeInfo.CreateInstance();
221 DALI_TEST_CHECK( handle );
223 ScrollBar scrollBar = ScrollBar::DownCast( handle );
224 DALI_TEST_CHECK( scrollBar );
226 scrollBar.SetProperty(ScrollBar::Property::SCROLL_DIRECTION, "VERTICAL");
227 scrollBar.SetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY, "FIXED");
229 DALI_TEST_EQUALS( scrollBar.GetScrollDirection(), Toolkit::ScrollBar::VERTICAL, TEST_LOCATION );
230 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::FIXED, TEST_LOCATION );
232 scrollBar.SetProperty(ScrollBar::Property::SCROLL_DIRECTION, "HORIZONTAL");
233 scrollBar.SetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY, "VARIABLE");
235 DALI_TEST_EQUALS( scrollBar.GetScrollDirection(), Toolkit::ScrollBar::HORIZONTAL, TEST_LOCATION );
236 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::VARIABLE, TEST_LOCATION );
241 int UtcDaliToolkitScrollBarDownCastP(void)
243 ToolkitTestApplication application;
245 ScrollBar scrollBar1 = ScrollBar::New();
246 BaseHandle object( scrollBar1 );
248 ScrollBar scrollBar2 = ScrollBar::DownCast( object );
249 DALI_TEST_CHECK( scrollBar2 );
251 ScrollBar scrollBar3 = DownCast< ScrollBar >( object );
252 DALI_TEST_CHECK( scrollBar3 );
256 int UtcDaliToolkitScrollBarDownCastN(void)
258 ToolkitTestApplication application;
260 BaseHandle uninitializedObject;
261 ScrollBar scrollBar1 = ScrollBar::DownCast( uninitializedObject );
262 DALI_TEST_CHECK( !scrollBar1 );
264 ScrollBar scrollBar2 = DownCast< ScrollBar >( uninitializedObject );
265 DALI_TEST_CHECK( !scrollBar2 );
269 int UtcDaliToolkitScrollBarSetScrollPropertySourceP(void)
271 ToolkitTestApplication application;
273 // Create a vertical scroll bar
274 ScrollBar scrollBar = ScrollBar::New(ScrollBar::VERTICAL);
275 DALI_TEST_CHECK( scrollBar );
276 DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::VERTICAL );
278 float scrollBarHeight = 100.0f;
279 scrollBar.SetProperty( Actor::Property::SIZE, Vector3(20.0f, scrollBarHeight, 0.0f) );
280 application.GetScene().Add( scrollBar );
282 // Create a source actor that owns the scroll properties required by the scroll bar
283 Actor sourceActor = Actor::New();
284 application.GetScene().Add( sourceActor );
286 // Register the scroll properties
287 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
288 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
289 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
290 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
292 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
293 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
294 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
295 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
297 // Set the source of the scroll position properties.
298 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
301 application.SendNotification();
302 application.Render();
304 Actor indicator = scrollBar.GetScrollIndicator();
305 DALI_TEST_CHECK( indicator );
307 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
308 // i.e. The bigger the content size, the smaller the indicator size
309 float indicatorHeight = indicator.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).y;
310 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
312 // Decrease the content length
313 sourceActor.SetProperty( propertyScrollContentSize, 250.0f );
316 application.SendNotification();
317 application.Render();
319 // Check that the indicator size is changed accordingly
320 indicatorHeight = indicator.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).y;
321 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 250.0f, TEST_LOCATION );
323 // As scroll position is 0, check that the indicator position should be 0.0f.
324 float indicatorPosition = indicator.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y;
325 DALI_TEST_EQUALS( indicatorPosition, 0.0f, TEST_LOCATION );
327 // Set the scroll position to the middle
328 sourceActor.SetProperty( propertyScrollPosition, -50.0f );
331 application.SendNotification();
332 application.Render();
334 // Check that the indicator should be in the middle of the scroll bar
335 indicatorPosition = indicator.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y;
336 DALI_TEST_EQUALS( indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.5f, TEST_LOCATION );
338 // Set the scroll position to the maximum
339 sourceActor.SetProperty( propertyScrollPosition, -100.0f );
342 application.SendNotification();
343 application.Render();
345 // Check that the indicator should be in the end of the scroll bar
346 indicatorPosition = indicator.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y;
347 DALI_TEST_EQUALS( indicatorPosition, scrollBarHeight - indicatorHeight, TEST_LOCATION );
349 // Increase the maximum scroll position to double
350 sourceActor.SetProperty( propertyMaxScrollPosition, 200.0f );
353 application.SendNotification();
354 application.Render();
356 // Check that the indicator should be now in the middle of the scroll bar
357 indicatorPosition = indicator.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y;
358 DALI_TEST_EQUALS( indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.5f, TEST_LOCATION );
360 // Create another source actor
361 Actor newSourceActor = Actor::New();
362 application.GetScene().Add( newSourceActor );
364 // Register the scroll properties
365 Property::Index newPropertyScrollPosition = newSourceActor.RegisterProperty( "sourcePosition", 0.0f );
366 Property::Index newPropertyMinScrollPosition = newSourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
367 Property::Index newPropertyMaxScrollPosition = newSourceActor.RegisterProperty( "sourcePositionMax", 200.0f );
368 Property::Index newPropertyScrollContentSize = newSourceActor.RegisterProperty( "sourceContentSize", 400.0f );
370 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourcePosition" ), newPropertyScrollPosition, TEST_LOCATION );
371 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourcePositionMin" ), newPropertyMinScrollPosition, TEST_LOCATION );
372 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourcePositionMax" ), newPropertyMaxScrollPosition, TEST_LOCATION );
373 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourceContentSize" ), newPropertyScrollContentSize, TEST_LOCATION );
375 // Change the source of the scroll position properties to be the new source actor.
376 scrollBar.SetScrollPropertySource(newSourceActor, newPropertyScrollPosition, newPropertyMinScrollPosition, newPropertyMaxScrollPosition, newPropertyScrollContentSize);
379 application.SendNotification();
380 application.Render();
382 // Check that the indicator size is changed accordingly
383 indicatorHeight = indicator.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).y;
384 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 400.0f, TEST_LOCATION );
386 // Check that the indicator position goes back to the beginning of the scroll bar
387 indicatorPosition = indicator.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y;
388 DALI_TEST_EQUALS( indicatorPosition, 0.0f, TEST_LOCATION );
390 // Set the scroll position to one fifth of the maximum
391 newSourceActor.SetProperty( propertyScrollPosition, -40.0f );
394 application.SendNotification();
395 application.Render();
397 // Check that the indicator should be in one fifth from the beginning of the scroll bar
398 indicatorPosition = indicator.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y;
399 DALI_TEST_EQUALS( indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.2f, TEST_LOCATION );
404 int UtcDaliToolkitScrollBarSetScrollPropertySourceN(void)
406 ToolkitTestApplication application;
408 // Create a scroll bar
409 ScrollBar scrollBar = ScrollBar::New();
410 DALI_TEST_CHECK( scrollBar );
412 // Set empty handle of source object and invalid source property index.
414 scrollBar.SetScrollPropertySource(sourceActor, Property::INVALID_INDEX, Property::INVALID_INDEX, Property::INVALID_INDEX, Property::INVALID_INDEX);
416 DALI_TEST_CHECK( true );
420 int UtcDaliToolkitScrollBarSetScrollIndicatorP(void)
422 ToolkitTestApplication application;
424 // Create a scroll bar
425 ScrollBar scrollBar = ScrollBar::New();
426 DALI_TEST_CHECK( scrollBar );
428 Actor indicator = scrollBar.GetScrollIndicator();
429 DALI_TEST_CHECK( indicator );
431 // Set a new indicator
432 Actor newIndicator = Actor::New();
433 scrollBar.SetScrollIndicator(newIndicator);
435 // Check that the new indicator is successfully set
436 DALI_TEST_CHECK( indicator != scrollBar.GetScrollIndicator() );
437 DALI_TEST_CHECK( newIndicator == scrollBar.GetScrollIndicator() );
439 // Check that the new control indicator is successfully set
440 Control controlIndicator = Control::New();
441 scrollBar.SetScrollIndicator(controlIndicator);
443 DALI_TEST_CHECK( controlIndicator == Control::DownCast( scrollBar.GetScrollIndicator() ) );
447 int UtcDaliToolkitScrollBarSetScrollIndicatorN(void)
449 ToolkitTestApplication application;
451 // Create a scroll bar
452 ScrollBar scrollBar = ScrollBar::New();
453 DALI_TEST_CHECK( scrollBar );
455 Actor indicator = scrollBar.GetScrollIndicator();
456 DALI_TEST_CHECK( indicator );
458 // Try to set an uninitialized actor as the indicator
459 Actor uninitializedIndicator;
460 scrollBar.SetScrollIndicator(uninitializedIndicator);
462 // Check that the uninitialized actor can not be set as the indicator
463 DALI_TEST_CHECK( indicator == scrollBar.GetScrollIndicator() );
464 DALI_TEST_CHECK( uninitializedIndicator != scrollBar.GetScrollIndicator() );
469 int UtcDaliToolkitScrollBarGetScrollIndicatorP(void)
471 ToolkitTestApplication application;
473 // Create a scroll bar
474 ScrollBar scrollBar = ScrollBar::New();
475 DALI_TEST_CHECK( scrollBar );
477 Actor indicator = scrollBar.GetScrollIndicator();
478 DALI_TEST_CHECK( indicator );
480 // Set a new indicator
481 Actor newIndicator = Actor::New();
482 scrollBar.SetScrollIndicator(newIndicator);
484 // Check that the new indicator is successfully set
485 DALI_TEST_CHECK( scrollBar.GetScrollIndicator() );
486 DALI_TEST_CHECK( indicator != scrollBar.GetScrollIndicator() );
487 DALI_TEST_CHECK( newIndicator == scrollBar.GetScrollIndicator() );
492 int UtcDaliToolkitScrollBarGetScrollIndicatorN(void)
494 ToolkitTestApplication application;
496 // Create a scroll bar
497 ScrollBar scrollBar = ScrollBar::New();
498 DALI_TEST_CHECK( scrollBar );
500 Actor indicator = scrollBar.GetScrollIndicator();
501 DALI_TEST_CHECK( indicator );
503 // Try to set an uninitialized actor as the indicator
504 Actor uninitializedIndicator;
505 scrollBar.SetScrollIndicator(uninitializedIndicator);
507 // Check that the indicator has not been changed
508 DALI_TEST_CHECK( indicator == scrollBar.GetScrollIndicator() );
509 DALI_TEST_CHECK( uninitializedIndicator != scrollBar.GetScrollIndicator() );
514 int UtcDaliToolkitScrollBarSetScrollPositionIntervalsP(void)
516 ToolkitTestApplication application;
518 // Create a vertical scroll bar
519 ScrollBar scrollBar = ScrollBar::New(ScrollBar::VERTICAL);
520 DALI_TEST_CHECK( scrollBar );
522 scrollBar.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
523 scrollBar.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
524 scrollBar.SetProperty( Actor::Property::SIZE, Vector3(20.0f, 800.0f, 0.0f) );
526 application.GetScene().Add( scrollBar );
528 // Connect to the ScrollPositionIntervalReached signal
529 scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
532 application.SendNotification();
533 application.Render();
535 // Create a source actor that owns the scroll properties required by the scroll bar
536 Actor sourceActor = Actor::New();
537 application.GetScene().Add( sourceActor );
539 // Register the scroll properties
540 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
541 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
542 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 800.0f );
543 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 2000.0f );
545 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
546 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
547 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
548 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
550 // Set the source of the scroll position properties.
551 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
554 application.SendNotification();
555 application.Render();
557 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
558 Dali::Vector<float> positionIntervals;
559 for( size_t i = 0; i != 10; ++i )
561 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
563 scrollBar.SetScrollPositionIntervals(positionIntervals);
565 // Get the list of scroll position intervals for notification
566 Dali::Vector<float> results = scrollBar.GetScrollPositionIntervals();
568 // Check that the result is the same as the list previously set.
569 DALI_TEST_EQUALS( positionIntervals.Count(), results.Count(), TEST_LOCATION );
570 DALI_TEST_EQUALS( positionIntervals[0], results[0], TEST_LOCATION );
571 DALI_TEST_EQUALS( positionIntervals[1], results[1], TEST_LOCATION );
572 DALI_TEST_EQUALS( positionIntervals[2], results[2], TEST_LOCATION );
573 DALI_TEST_EQUALS( positionIntervals[3], results[3], TEST_LOCATION );
574 DALI_TEST_EQUALS( positionIntervals[4], results[4], TEST_LOCATION );
575 DALI_TEST_EQUALS( positionIntervals[5], results[5], TEST_LOCATION );
576 DALI_TEST_EQUALS( positionIntervals[6], results[6], TEST_LOCATION );
577 DALI_TEST_EQUALS( positionIntervals[7], results[7], TEST_LOCATION );
578 DALI_TEST_EQUALS( positionIntervals[8], results[8], TEST_LOCATION );
579 DALI_TEST_EQUALS( positionIntervals[9], results[9], TEST_LOCATION );
582 gOnScrollPositionIntervalReachedSignalCalled = false;
584 // Animate the scroll position to cross the specified value
585 Animation animation = Animation::New(0.1f);
586 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
589 // Wait for 0.1 second
590 Wait(application, 100);
592 // Check that the signal callback is called
593 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
596 gOnScrollPositionIntervalReachedSignalCalled = false;
598 // Rest and clear the animation
602 // Animate the scroll position to cross another specified value
603 animation = Animation::New(0.1f);
604 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -170.0f );
607 // Wait for 0.1 second
608 Wait(application, 100);
610 // Check that the signal callback is called
611 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
614 gOnScrollPositionIntervalReachedSignalCalled = false;
616 // Rest and clear the animation
620 // Animate the scroll position back to the previous value
621 animation = Animation::New(0.1f);
622 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
625 // Wait for 0.1 second
626 Wait(application, 100);
628 // Check that the signal callback is called
629 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
634 int UtcDaliToolkitScrollBarGetScrollPositionIntervalsP(void)
636 ToolkitTestApplication application;
638 // Create a vertical scroll bar
639 ScrollBar scrollBar = ScrollBar::New(ScrollBar::VERTICAL);
640 DALI_TEST_CHECK( scrollBar );
642 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
643 Dali::Vector<float> positionIntervals;
644 for( size_t i = 0; i != 10; ++i )
646 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
648 scrollBar.SetScrollPositionIntervals(positionIntervals);
650 // Get the list of scroll position intervals for notification
651 Dali::Vector<float> results = scrollBar.GetScrollPositionIntervals();
653 // Check that the result is the same as the list previously set.
654 DALI_TEST_EQUALS( positionIntervals.Count(), results.Count(), TEST_LOCATION );
655 DALI_TEST_EQUALS( positionIntervals[0], results[0], TEST_LOCATION );
656 DALI_TEST_EQUALS( positionIntervals[1], results[1], TEST_LOCATION );
657 DALI_TEST_EQUALS( positionIntervals[2], results[2], TEST_LOCATION );
658 DALI_TEST_EQUALS( positionIntervals[3], results[3], TEST_LOCATION );
659 DALI_TEST_EQUALS( positionIntervals[4], results[4], TEST_LOCATION );
660 DALI_TEST_EQUALS( positionIntervals[5], results[5], TEST_LOCATION );
661 DALI_TEST_EQUALS( positionIntervals[6], results[6], TEST_LOCATION );
662 DALI_TEST_EQUALS( positionIntervals[7], results[7], TEST_LOCATION );
663 DALI_TEST_EQUALS( positionIntervals[8], results[8], TEST_LOCATION );
664 DALI_TEST_EQUALS( positionIntervals[9], results[9], TEST_LOCATION );
666 Property::Array resultArray = scrollBar.GetProperty<Property::Array>(Toolkit::ScrollBar::Property::SCROLL_POSITION_INTERVALS);
668 DALI_TEST_EQUALS( positionIntervals.Count(), resultArray.Count(), TEST_LOCATION );
669 DALI_TEST_EQUALS( positionIntervals[0], resultArray[0].Get<float>(), TEST_LOCATION );
670 DALI_TEST_EQUALS( positionIntervals[1], resultArray[1].Get<float>(), TEST_LOCATION );
671 DALI_TEST_EQUALS( positionIntervals[2], resultArray[2].Get<float>(), TEST_LOCATION );
672 DALI_TEST_EQUALS( positionIntervals[3], resultArray[3].Get<float>(), TEST_LOCATION );
673 DALI_TEST_EQUALS( positionIntervals[4], resultArray[4].Get<float>(), TEST_LOCATION );
674 DALI_TEST_EQUALS( positionIntervals[5], resultArray[5].Get<float>(), TEST_LOCATION );
675 DALI_TEST_EQUALS( positionIntervals[6], resultArray[6].Get<float>(), TEST_LOCATION );
676 DALI_TEST_EQUALS( positionIntervals[7], resultArray[7].Get<float>(), TEST_LOCATION );
677 DALI_TEST_EQUALS( positionIntervals[8], resultArray[8].Get<float>(), TEST_LOCATION );
678 DALI_TEST_EQUALS( positionIntervals[9], resultArray[9].Get<float>(), TEST_LOCATION );
683 int UtcDaliToolkitScrollBarGetScrollDirectionP(void)
685 ToolkitTestApplication application;
687 // Create a vertical scroll bar
688 ScrollBar scrollBar = ScrollBar::New(ScrollBar::VERTICAL);
689 DALI_TEST_CHECK( scrollBar );
690 DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::VERTICAL );
692 // Change the direction of scroll bar to horizontal
693 scrollBar.SetScrollDirection(ScrollBar::HORIZONTAL);
694 DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::HORIZONTAL );
699 int UtcDaliToolkitScrollBarSetIndicatorHeightPolicyP(void)
701 ToolkitTestApplication application;
703 // Create a scroll bar
704 ScrollBar scrollBar = ScrollBar::New();
705 DALI_TEST_CHECK( scrollBar );
707 float scrollBarHeight = 100.0f;
708 scrollBar.SetProperty( Actor::Property::SIZE, Vector3(20.0f, scrollBarHeight, 0.0f) );
709 application.GetScene().Add( scrollBar );
711 // Create a source actor that owns the scroll properties required by the scroll bar
712 Actor sourceActor = Actor::New();
713 application.GetScene().Add( sourceActor );
715 // Register the scroll properties
716 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
717 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
718 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
719 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
721 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
722 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
723 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
724 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
726 // Set the source of the scroll position properties.
727 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
730 application.SendNotification();
731 application.Render();
733 Actor indicator = scrollBar.GetScrollIndicator();
734 DALI_TEST_CHECK( indicator );
736 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
737 // i.e. The bigger the content size, the smaller the indicator size
738 float indicatorHeight = indicator.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).y;
739 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
741 // Set the indicator height to be fixed to 50.0f
742 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::FIXED);
743 scrollBar.SetIndicatorFixedHeight(50.0f);
745 Property::Value value = scrollBar.GetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY);
746 DALI_TEST_EQUALS(value.Get<std::string>(), "FIXED", TEST_LOCATION );
749 application.SendNotification();
750 application.Render();
752 // Check that the indicator size should be 50.0f
753 indicatorHeight = indicator.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).y;
754 DALI_TEST_EQUALS( indicatorHeight, 50.0f, TEST_LOCATION );
756 // Set the indicator height to be variable
757 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::VARIABLE);
758 value = scrollBar.GetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY);
759 DALI_TEST_EQUALS(value.Get<std::string>(), "VARIABLE", TEST_LOCATION );
762 application.SendNotification();
763 application.Render();
765 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
766 indicatorHeight = indicator.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).y;
767 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
772 int UtcDaliToolkitScrollBarGetIndicatorHeightPolicyP(void)
774 ToolkitTestApplication application;
776 // Create a scroll bar
777 ScrollBar scrollBar = ScrollBar::New();
778 DALI_TEST_CHECK( scrollBar );
780 // Set the indicator height to be fixed
781 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::FIXED);
782 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::FIXED, TEST_LOCATION );
784 // Set the indicator height to be variable
785 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::VARIABLE);
786 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::VARIABLE, TEST_LOCATION );
791 int UtcDaliToolkitScrollBarSetIndicatorFixedHeightP(void)
793 ToolkitTestApplication application;
795 // Create a scroll bar
796 ScrollBar scrollBar = ScrollBar::New();
797 DALI_TEST_CHECK( scrollBar );
799 float scrollBarHeight = 100.0f;
800 scrollBar.SetProperty( Actor::Property::SIZE, Vector3(20.0f, scrollBarHeight, 0.0f) );
801 application.GetScene().Add( scrollBar );
803 Actor indicator = scrollBar.GetScrollIndicator();
804 DALI_TEST_CHECK( indicator );
806 // Set the indicator height to be fixed to 50.0f
807 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::FIXED);
808 scrollBar.SetIndicatorFixedHeight(50.0f);
811 application.SendNotification();
812 application.Render();
814 // Check that the indicator size should be 50.0f
815 DALI_TEST_EQUALS( indicator.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).y, 50.0f, TEST_LOCATION );
817 // Set the indicator height to be fixed to 25.0f
818 scrollBar.SetIndicatorFixedHeight(25.0f);
821 application.SendNotification();
822 application.Render();
824 // Check that the indicator size should be 25.0f
825 DALI_TEST_EQUALS( indicator.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).y, 25.0f, TEST_LOCATION );
830 int UtcDaliToolkitScrollBarGetIndicatorFixedHeightP(void)
832 ToolkitTestApplication application;
834 // Create a scroll bar
835 ScrollBar scrollBar = ScrollBar::New();
836 DALI_TEST_CHECK( scrollBar );
838 // Set the fixed indicator height to be 50.0f
839 scrollBar.SetIndicatorFixedHeight(50.0f);
841 // Check that the indicator size should be 50.0f
842 DALI_TEST_EQUALS( scrollBar.GetIndicatorFixedHeight(), 50.0f, TEST_LOCATION );
844 // Set the indicator height to be fixed to 25.0f
845 scrollBar.SetIndicatorFixedHeight(25.0f);
847 // Check that the indicator size should be 50.0f
848 DALI_TEST_EQUALS( scrollBar.GetIndicatorFixedHeight(), 25.0f, TEST_LOCATION );
853 int UtcDaliToolkitScrollBarSetIndicatorShowDurationP(void)
855 ToolkitTestApplication application;
857 // Create a scroll bar
858 ScrollBar scrollBar = ScrollBar::New();
859 DALI_TEST_CHECK( scrollBar );
861 application.GetScene().Add( scrollBar );
863 Actor indicator = scrollBar.GetScrollIndicator();
864 DALI_TEST_CHECK( indicator );
866 // Set the duration to show the indicator to be 0.35 second
867 scrollBar.SetIndicatorShowDuration(0.35);
868 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.35f, TEST_LOCATION );
870 // Make the indicator invisible
871 indicator.SetProperty( Actor::Property::OPACITY,0.0f);
874 application.SendNotification();
875 application.Render();
877 // Check that the indicator is invisible
878 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
880 // Show the indicator
881 scrollBar.ShowIndicator();
883 // Wait for 0.35 second
884 Wait(application, 350);
887 application.SendNotification();
888 application.Render();
890 // Check that the indicator is now visible
891 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
893 // Set the duration to show the indicator to be 0.75 second
894 scrollBar.SetIndicatorShowDuration(0.75);
895 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.75f, TEST_LOCATION );
897 // Make the indicator invisible
898 indicator.SetProperty( Actor::Property::OPACITY,0.0f);
901 application.SendNotification();
902 application.Render();
904 // Check that the indicator is invisible
905 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
907 // Show the indicator
908 scrollBar.ShowIndicator();
910 // Wait for 0.35 second first
911 Wait(application, 350);
914 application.SendNotification();
915 application.Render();
917 // Check that the indicator is not fully visible yet
918 DALI_TEST_CHECK( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ) != 1.0f );
920 // Wait for another 0.4 second
921 Wait(application, 400);
924 application.SendNotification();
925 application.Render();
927 // Check that the indicator is now fully visible
928 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
933 int UtcDaliToolkitScrollBarSetIndicatorShowDurationN(void)
935 ToolkitTestApplication application;
937 // Create a scroll bar
938 ScrollBar scrollBar = ScrollBar::New();
939 DALI_TEST_CHECK( scrollBar );
941 application.GetScene().Add( scrollBar );
943 Actor indicator = scrollBar.GetScrollIndicator();
944 DALI_TEST_CHECK( indicator );
946 // Get the default duration to show the indicator
947 float duration = scrollBar.GetIndicatorShowDuration();
949 // Check that the default duration is greater than 0
950 DALI_TEST_CHECK( duration > 0.0f );
952 // Make the indicator invisible
953 indicator.SetProperty( Actor::Property::OPACITY,0.0f);
956 application.SendNotification();
957 application.Render();
959 // Check that the indicator is invisible
960 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
962 // Show the indicator
963 scrollBar.ShowIndicator();
965 // Wait for the specified duration
966 Wait(application, duration * 1000);
969 application.SendNotification();
970 application.Render();
972 // Check that the indicator is now visible
973 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
975 // Now set the duration to show the indicator to be a negative value (which should be ignored and therefore means instant)
976 scrollBar.SetIndicatorShowDuration(-0.25f);
977 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), -0.25f, TEST_LOCATION );
979 // Make the indicator invisible
980 indicator.SetProperty( Actor::Property::OPACITY,0.0f);
983 application.SendNotification();
984 application.Render();
986 // Check that the indicator is invisible
987 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
989 // Show the indicator
990 scrollBar.ShowIndicator();
993 application.SendNotification();
994 application.Render();
996 // Check that the indicator becomes instantly visible in the next frame
997 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1002 int UtcDaliToolkitScrollBarGetIndicatorShowDurationP(void)
1004 ToolkitTestApplication application;
1006 // Create a scroll bar
1007 ScrollBar scrollBar = ScrollBar::New();
1008 DALI_TEST_CHECK( scrollBar );
1010 // Set the duration to show the indicator to be 0.35 second
1011 scrollBar.SetIndicatorShowDuration(0.35f);
1013 // Check that the duration to show the indicator is 0.35 second
1014 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.35f, TEST_LOCATION );
1016 // Set the duration to show the indicator to be 0.75 second
1017 scrollBar.SetIndicatorShowDuration(0.75f);
1019 // Check that the duration to show the indicator is 0.75 second
1020 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.75f, TEST_LOCATION );
1025 int UtcDaliToolkitScrollBarSetIndicatorHideDurationP(void)
1027 ToolkitTestApplication application;
1029 // Create a scroll bar
1030 ScrollBar scrollBar = ScrollBar::New();
1031 DALI_TEST_CHECK( scrollBar );
1033 application.GetScene().Add( scrollBar );
1035 Actor indicator = scrollBar.GetScrollIndicator();
1036 DALI_TEST_CHECK( indicator );
1038 // Set the duration to hide the indicator to be 0.15 second
1039 scrollBar.SetIndicatorHideDuration(0.15f);
1040 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.15f, TEST_LOCATION );
1042 // Make the indicator visible
1043 indicator.SetProperty( Actor::Property::OPACITY,1.0f);
1045 // Render and notify
1046 application.SendNotification();
1047 application.Render();
1049 // Check that the indicator is visible
1050 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1052 // Hide the indicator
1053 scrollBar.HideIndicator();
1055 // Wait for 0.15 second
1056 Wait(application, 150);
1058 // Render and notify
1059 application.SendNotification();
1060 application.Render();
1062 // Check that the indicator is now invisible
1063 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1065 // Set the duration to hide the indicator to be 0.65 second
1066 scrollBar.SetIndicatorHideDuration(0.65f);
1067 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.65f, TEST_LOCATION );
1069 // Make the indicator visible
1070 indicator.SetProperty( Actor::Property::OPACITY,1.0f);
1072 // Render and notify
1073 application.SendNotification();
1074 application.Render();
1076 // Check that the indicator is visible
1077 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1079 // Hide the indicator
1080 scrollBar.HideIndicator();
1082 // Wait for 0.15 second first
1083 Wait(application, 150);
1085 // Render and notify
1086 application.SendNotification();
1087 application.Render();
1089 // Check that the indicator is not fully invisible yet
1090 DALI_TEST_CHECK( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ) != 0.0f );
1092 // Wait for another 0.5 second
1093 Wait(application, 500);
1095 // Render and notify
1096 application.SendNotification();
1097 application.Render();
1099 // Check that the indicator is now fully invisible
1100 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1105 int UtcDaliToolkitScrollBarSetIndicatorHideDurationN(void)
1107 ToolkitTestApplication application;
1109 // Create a scroll bar
1110 ScrollBar scrollBar = ScrollBar::New();
1111 DALI_TEST_CHECK( scrollBar );
1113 application.GetScene().Add( scrollBar );
1115 Actor indicator = scrollBar.GetScrollIndicator();
1116 DALI_TEST_CHECK( indicator );
1118 // Get the default duration to hide the indicator
1119 float duration = scrollBar.GetIndicatorHideDuration();
1121 // Check that the default duration is greater than 0
1122 DALI_TEST_CHECK( duration > 0.0f );
1124 // Make the indicator visible
1125 indicator.SetProperty( Actor::Property::OPACITY,1.0f);
1127 // Render and notify
1128 application.SendNotification();
1129 application.Render();
1131 // Check that the indicator is visible
1132 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1134 // Hide the indicator
1135 scrollBar.HideIndicator();
1137 // Wait for the specified duration
1138 Wait(application, duration * 1000);
1140 // Render and notify
1141 application.SendNotification();
1142 application.Render();
1144 // Check that the indicator is now invisible
1145 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1147 // Now set the duration to hide the indicator to be a negative value (which should be ignored and therefore means instant)
1148 scrollBar.SetIndicatorHideDuration(-0.25f);
1149 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), -0.25f, TEST_LOCATION );
1151 // Make the indicator visible
1152 indicator.SetProperty( Actor::Property::OPACITY,1.0f);
1154 // Render and notify
1155 application.SendNotification();
1156 application.Render();
1158 // Check that the indicator is visible
1159 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1161 // Hide the indicator
1162 scrollBar.HideIndicator();
1164 // Render and notify
1165 application.SendNotification();
1166 application.Render();
1168 // Check that the indicator becomes instantly invisible in the next frame
1169 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1174 int UtcDaliToolkitScrollBarGetIndicatorHideDurationP(void)
1176 ToolkitTestApplication application;
1178 // Create a scroll bar
1179 ScrollBar scrollBar = ScrollBar::New();
1180 DALI_TEST_CHECK( scrollBar );
1182 // Set the duration to hide the indicator to be 0.15 second
1183 scrollBar.SetIndicatorHideDuration(0.15f);
1185 // Check that the duration to hide the indicator is 0.15 second
1186 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.15f, TEST_LOCATION );
1188 // Set the duration to hide the indicator to be 0.65 second
1189 scrollBar.SetIndicatorHideDuration(0.65f);
1191 // Check that the duration to hide the indicator is 0.65 second
1192 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.65f, TEST_LOCATION );
1197 int UtcDaliToolkitScrollBarShowIndicatorP(void)
1199 ToolkitTestApplication application;
1201 // Create a scroll bar
1202 ScrollBar scrollBar = ScrollBar::New();
1203 DALI_TEST_CHECK( scrollBar );
1205 application.GetScene().Add( scrollBar );
1207 Actor indicator = scrollBar.GetScrollIndicator();
1208 DALI_TEST_CHECK( indicator );
1210 // Get the default duration to show the indicator
1211 float duration = scrollBar.GetIndicatorShowDuration();
1213 // Check that the default duration is greater than 0
1214 DALI_TEST_CHECK( duration > 0.0f );
1216 // Make the indicator invisible
1217 indicator.SetProperty( Actor::Property::OPACITY,0.0f);
1219 // Render and notify
1220 application.SendNotification();
1221 application.Render();
1223 // Check that the indicator is invisible
1224 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1226 // Show the indicator
1227 scrollBar.ShowIndicator();
1229 // Wait for the specified duration
1230 Wait(application, duration * 1000);
1232 // Render and notify
1233 application.SendNotification();
1234 application.Render();
1236 // Check that the indicator is now visible
1237 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1242 int UtcDaliToolkitScrollBarShowIndicatorN(void)
1244 ToolkitTestApplication application;
1246 // Create a scroll bar
1247 ScrollBar scrollBar = ScrollBar::New();
1248 DALI_TEST_CHECK( scrollBar );
1250 application.GetScene().Add( scrollBar );
1252 Actor indicator = scrollBar.GetScrollIndicator();
1253 DALI_TEST_CHECK( indicator );
1255 // Make the indicator initially visible
1256 indicator.SetProperty( Actor::Property::OPACITY,1.0f);
1258 // Render and notify
1259 application.SendNotification();
1260 application.Render();
1262 // Check that the indicator is initially visible
1263 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1265 // Get the default duration to show the indicator
1266 float duration = scrollBar.GetIndicatorShowDuration();
1268 // Check that the default duration is greater than 0
1269 DALI_TEST_CHECK( duration > 0.0f );
1271 // Show the indicator
1272 scrollBar.ShowIndicator();
1274 // Render and notify
1275 application.SendNotification();
1276 application.Render();
1278 // Check that the indicator is still visible in the very next frame
1279 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1284 int UtcDaliToolkitScrollBarHideIndicatorP(void)
1286 ToolkitTestApplication application;
1288 // Create a scroll bar
1289 ScrollBar scrollBar = ScrollBar::New();
1290 DALI_TEST_CHECK( scrollBar );
1292 application.GetScene().Add( scrollBar );
1294 Actor indicator = scrollBar.GetScrollIndicator();
1295 DALI_TEST_CHECK( indicator );
1297 // Get the default duration to hide the indicator
1298 float duration = scrollBar.GetIndicatorHideDuration();
1300 // Check that the default duration is greater than 0
1301 DALI_TEST_CHECK( duration > 0.0f );
1303 // Make the indicator visible
1304 indicator.SetProperty( Actor::Property::OPACITY,1.0f);
1306 // Render and notify
1307 application.SendNotification();
1308 application.Render();
1310 // Check that the indicator is visible
1311 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1313 // Hide the indicator
1314 scrollBar.HideIndicator();
1316 // Wait for the specified duration
1317 Wait(application, duration * 1000);
1319 // Render and notify
1320 application.SendNotification();
1321 application.Render();
1323 // Check that the indicator is now invisible
1324 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1329 int UtcDaliToolkitScrollBarHideIndicatorN(void)
1331 ToolkitTestApplication application;
1333 // Create a scroll bar
1334 ScrollBar scrollBar = ScrollBar::New();
1335 DALI_TEST_CHECK( scrollBar );
1337 application.GetScene().Add( scrollBar );
1339 Actor indicator = scrollBar.GetScrollIndicator();
1340 DALI_TEST_CHECK( indicator );
1342 // Make the indicator initially invisible
1343 indicator.SetProperty( Actor::Property::OPACITY,0.0f);
1345 // Render and notify
1346 application.SendNotification();
1347 application.Render();
1349 // Check that the indicator is initially invisible
1350 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1352 // Get the default duration to hide the indicator
1353 float duration = scrollBar.GetIndicatorHideDuration();
1355 // Check that the default duration is greater than 0
1356 DALI_TEST_CHECK( duration > 0.0f );
1358 // Hide the indicator
1359 scrollBar.HideIndicator();
1361 // Render and notify
1362 application.SendNotification();
1363 application.Render();
1365 // Check that the indicator is still invisible in the very next frame
1366 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1371 int UtcDaliToolkitScrollBarActionShowIndicator(void)
1373 ToolkitTestApplication application;
1375 // Create a scroll bar
1376 ScrollBar scrollBar = ScrollBar::New();
1377 DALI_TEST_CHECK( scrollBar );
1379 application.GetScene().Add( scrollBar );
1381 Actor indicator = scrollBar.GetScrollIndicator();
1382 DALI_TEST_CHECK( indicator );
1384 // Get the default duration to hide the indicator
1385 float duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_SHOW_DURATION );
1387 // Check that the default duration is greater than 0
1388 DALI_TEST_CHECK( duration > 0.0f );
1390 // Make the indicator invisible
1391 indicator.SetProperty( Actor::Property::OPACITY,0.0f);
1393 // Render and notify
1394 application.SendNotification();
1395 application.Render();
1397 // Check that the indicator is invisible
1398 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1400 // Do the "ShowIndicator" action
1401 Property::Map emptyMap;
1402 scrollBar.DoAction( "ShowIndicator", emptyMap );
1404 // Wait for the specified duration
1405 Wait(application, duration * 1000);
1407 // Render and notify
1408 application.SendNotification();
1409 application.Render();
1411 // Check that the indicator is now visible
1412 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1417 int UtcDaliToolkitScrollBarActionHideIndicator(void)
1419 ToolkitTestApplication application;
1421 // Create a scroll bar
1422 ScrollBar scrollBar = ScrollBar::New();
1423 DALI_TEST_CHECK( scrollBar );
1425 application.GetScene().Add( scrollBar );
1427 Actor indicator = scrollBar.GetScrollIndicator();
1428 DALI_TEST_CHECK( indicator );
1430 // Get the default duration to hide the indicator
1431 float duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_HIDE_DURATION );
1433 // Check that the default duration is greater than 0
1434 DALI_TEST_CHECK( duration > 0.0f );
1436 // Make the indicator visible
1437 indicator.SetProperty( Actor::Property::OPACITY,1.0f);
1439 // Render and notify
1440 application.SendNotification();
1441 application.Render();
1443 // Check that the indicator is visible
1444 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1446 // Do the "HideIndicator" action
1447 Property::Map emptyMap;
1448 scrollBar.DoAction( "HideIndicator", emptyMap );
1450 // Wait for the specified duration
1451 Wait(application, duration * 1000);
1453 // Render and notify
1454 application.SendNotification();
1455 application.Render();
1457 // Check that the indicator is now invisible
1458 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1463 int UtcDaliToolkitScrollBarActionShowTransientIndicator(void)
1465 ToolkitTestApplication application;
1467 // Create a scroll bar
1468 ScrollBar scrollBar = ScrollBar::New();
1469 DALI_TEST_CHECK( scrollBar );
1471 application.GetScene().Add( scrollBar );
1473 Actor indicator = scrollBar.GetScrollIndicator();
1474 DALI_TEST_CHECK( indicator );
1476 // Get the default duration to hide the indicator
1477 float duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_SHOW_DURATION );
1479 // Check that the default duration is greater than 0
1480 DALI_TEST_CHECK( duration > 0.0f );
1482 // Make the indicator invisible
1483 indicator.SetProperty( Actor::Property::OPACITY,0.0f);
1485 // Render and notify
1486 application.SendNotification();
1487 application.Render();
1489 // Check that the indicator is invisible
1490 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1492 // Do the "ShowIndicator" action
1493 Property::Map emptyMap;
1494 scrollBar.DoAction( "ShowTransientIndicator", emptyMap );
1496 // Wait for the specified duration
1497 Wait(application, duration * 1000);
1499 // Render and notify
1500 application.SendNotification();
1501 application.Render();
1503 // Check that the indicator is now visible
1504 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1506 // Get the default duration to hide the indicator
1507 float hideDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_HIDE_DURATION );
1508 float transientDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_TRANSIENT_DURATION );
1509 float totalVisibleDuration = hideDuration + transientDuration;
1511 // Check that the default duration is greater than 0
1512 DALI_TEST_CHECK( totalVisibleDuration > 0.0f );
1514 // Wait for the specified duration
1515 Wait(application, totalVisibleDuration * 1000);
1517 // Render and notify
1518 application.SendNotification();
1519 application.Render();
1521 // Check that the indicator is now invisible
1522 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1527 int UtcDaliToolkitScrollBarActionShowTransientIndicatorImmediate(void)
1529 ToolkitTestApplication application;
1531 // Create a scroll bar
1532 ScrollBar scrollBar = ScrollBar::New();
1533 DALI_TEST_CHECK( scrollBar );
1535 application.GetScene().Add( scrollBar );
1537 Actor indicator = scrollBar.GetScrollIndicator();
1538 DALI_TEST_CHECK( indicator );
1540 // Make the indicator invisible
1541 indicator.SetProperty( Actor::Property::OPACITY,0.0f);
1543 // Don't use a show animation; the indicator should appear immediately
1544 scrollBar.SetProperty( ScrollBar::Property::INDICATOR_SHOW_DURATION, 0.0f );
1545 float duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_SHOW_DURATION );
1546 DALI_TEST_EQUALS( duration, 0.0f, TEST_LOCATION );
1548 // Render and notify
1549 application.SendNotification();
1550 application.Render();
1552 // Do the "ShowIndicator" action
1553 Property::Map emptyMap;
1554 scrollBar.DoAction( "ShowTransientIndicator", emptyMap );
1556 // Wait for the specified duration
1559 // Render and notify
1560 application.SendNotification();
1561 application.Render();
1563 // Check that the indicator is now visible
1564 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1566 // Get the default duration to hide the indicator
1567 float hideDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_HIDE_DURATION );
1568 float transientDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_TRANSIENT_DURATION );
1569 float totalVisibleDuration = hideDuration + transientDuration;
1571 // Check that the default duration is greater than 0
1572 DALI_TEST_CHECK( totalVisibleDuration > 0.0f );
1574 // Wait for the specified duration
1575 Wait(application, totalVisibleDuration * 1000);
1577 // Render and notify
1578 application.SendNotification();
1579 application.Render();
1581 // Check that the indicator is now invisible
1582 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1587 int UtcDaliToolkitScrollBarActionShowTransientIndicatorDuringHide(void)
1589 ToolkitTestApplication application;
1591 // Create a scroll bar
1592 ScrollBar scrollBar = ScrollBar::New();
1593 DALI_TEST_CHECK( scrollBar );
1595 application.GetScene().Add( scrollBar );
1597 Actor indicator = scrollBar.GetScrollIndicator();
1598 DALI_TEST_CHECK( indicator );
1600 // Get the default duration to hide the indicator
1601 float duration = scrollBar.GetIndicatorHideDuration();
1603 // Check that the default duration is greater than 0
1604 DALI_TEST_CHECK( duration > 0.0f );
1606 // Make the indicator visible
1607 indicator.SetProperty( Actor::Property::OPACITY,1.0f);
1609 // Render and notify
1610 application.SendNotification();
1611 application.Render();
1613 // Check that the indicator is visible
1614 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1616 // Hide the indicator
1617 scrollBar.HideIndicator();
1619 // Wait for half the specified duration
1620 Wait(application, duration * 0.5f * 1000);
1622 // Render and notify
1623 application.SendNotification();
1624 application.Render();
1626 // Check that the indicator is now partially hidden
1627 DALI_TEST_CHECK( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ) < 1.0f );
1629 // Now interrupt the Hide with a DoAction( "ShowTransientIndicator" )
1631 // Get the default duration to hide the indicator
1632 duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_SHOW_DURATION );
1634 // Check that the default duration is greater than 0
1635 DALI_TEST_CHECK( duration > 0.0f );
1637 // Do the "ShowIndicator" action
1638 Property::Map emptyMap;
1639 scrollBar.DoAction( "ShowTransientIndicator", emptyMap );
1641 // Wait for the specified duration
1642 Wait(application, duration * 1000);
1644 // Render and notify
1645 application.SendNotification();
1646 application.Render();
1648 // Check that the indicator is now visible
1649 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1651 // Get the default duration to hide the indicator
1652 float hideDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_HIDE_DURATION );
1653 float transientDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_TRANSIENT_DURATION );
1654 float totalVisibleDuration = hideDuration + transientDuration;
1656 // Check that the default duration is greater than 0
1657 DALI_TEST_CHECK( totalVisibleDuration > 0.0f );
1659 // Wait for the specified duration
1660 Wait(application, totalVisibleDuration * 1000);
1662 // Render and notify
1663 application.SendNotification();
1664 application.Render();
1666 // Check that the indicator is now invisible
1667 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1672 int UtcDaliToolkitScrollBarPanFinishedSignalP(void)
1674 ToolkitTestApplication application;
1676 // Create a vertical scroll bar
1677 ScrollBar scrollBar = ScrollBar::New(ScrollBar::VERTICAL);
1678 DALI_TEST_CHECK( scrollBar );
1680 scrollBar.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1681 scrollBar.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1682 scrollBar.SetProperty( Actor::Property::SIZE, Vector3(20.0f, 800.0f, 0.0f) );
1684 // Set the indicator height to be fixed to 50.0f
1685 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::FIXED);
1686 scrollBar.SetIndicatorFixedHeight(50.0f);
1688 application.GetScene().Add( scrollBar );
1690 // Connect the pan finished signal
1691 ConnectionTracker connectionTracker;
1692 bool panFinished = false;
1693 scrollBar.PanFinishedSignal().Connect( &OnPanFinished );
1694 scrollBar.ConnectSignal( &connectionTracker, "panFinished", CallbackFunctor(&panFinished));
1696 // Render and notify
1697 application.SendNotification();
1698 application.Render();
1700 // Create a source actor that owns the scroll properties required by the scroll bar
1701 Actor sourceActor = Actor::New();
1702 application.GetScene().Add( sourceActor );
1704 // Register the scroll properties
1705 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1706 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1707 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
1708 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
1710 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1711 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1712 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1713 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1715 // Set the source of the scroll position properties.
1716 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1718 // Render and notify
1719 application.SendNotification();
1720 application.Render();
1722 // Perform a swipe gesture on the indicator
1723 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 1, 500);
1724 DALI_TEST_EQUALS( gOnPanFinishedCalled, true, TEST_LOCATION );
1725 DALI_TEST_EQUALS( panFinished, true, TEST_LOCATION );
1730 int UtcDaliToolkitScrollBarPanFinishedSignalN(void)
1732 ToolkitTestApplication application;
1734 // Create a vertical scroll bar
1735 ScrollBar scrollBar = ScrollBar::New(ScrollBar::VERTICAL);
1736 DALI_TEST_CHECK( scrollBar );
1738 scrollBar.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1739 scrollBar.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1740 scrollBar.SetProperty( Actor::Property::SIZE, Vector3(20.0f, 800.0f, 0.0f) );
1742 // Set the indicator height to be fixed to 50.0f
1743 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::FIXED);
1744 scrollBar.SetIndicatorFixedHeight(50.0f);
1746 application.GetScene().Add( scrollBar );
1748 // Connect the pan finished signal
1749 ConnectionTracker connectionTracker;
1750 bool panFinished = false;
1751 scrollBar.PanFinishedSignal().Connect( &OnPanFinished );
1752 scrollBar.ConnectSignal( &connectionTracker, "panFinished", CallbackFunctor(&panFinished));
1754 // Render and notify
1755 application.SendNotification();
1756 application.Render();
1758 // Perform a vertical swipe gesture on the indicator when there is no source object set on the scroll bar
1759 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20, 500);
1760 DALI_TEST_EQUALS( gOnPanFinishedCalled, false, TEST_LOCATION );
1762 // Create a source actor that owns the scroll properties required by the scroll bar
1763 Actor sourceActor = Actor::New();
1764 application.GetScene().Add( sourceActor );
1766 // Register the scroll properties
1767 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1768 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1769 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
1770 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
1772 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1773 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1774 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1775 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1777 // Set the source of the scroll position properties.
1778 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1780 // Render and notify
1781 application.SendNotification();
1782 application.Render();
1784 // Perform a swipe gesture on the scroll bar but not on the indicator
1785 PerformGestureSwipe(application, Vector2(1.0f, 780.0f), Vector2(Vector2::YAXIS * -1.0f), 20, 2000);
1786 DALI_TEST_EQUALS( gOnPanFinishedCalled, false, TEST_LOCATION );
1787 DALI_TEST_EQUALS( panFinished, false, TEST_LOCATION );
1789 // Perform a swipe gesture on the indicator
1790 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20, 4000);
1791 DALI_TEST_EQUALS( gOnPanFinishedCalled, true, TEST_LOCATION );
1792 DALI_TEST_EQUALS( panFinished, true, TEST_LOCATION );
1797 int UtcDaliToolkitScrollBarScrollPositionIntervalReachedSignalP(void)
1799 ToolkitTestApplication application;
1801 // Create a vertical scroll bar
1802 ScrollBar scrollBar = ScrollBar::New(ScrollBar::VERTICAL);
1803 DALI_TEST_CHECK( scrollBar );
1805 scrollBar.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1806 scrollBar.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1807 scrollBar.SetProperty( Actor::Property::SIZE, Vector3(20.0f, 800.0f, 0.0f) );
1809 application.GetScene().Add( scrollBar );
1810 ConnectionTracker connectionTracker;
1812 // Connect to the ScrollPositionIntervalReached signal
1813 bool intervalReached = false;
1814 scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
1815 scrollBar.ConnectSignal( &connectionTracker, "scrollPositionIntervalReached", CallbackFunctor(&intervalReached));
1817 // Render and notify
1818 application.SendNotification();
1819 application.Render();
1821 // Create a source actor that owns the scroll properties required by the scroll bar
1822 Actor sourceActor = Actor::New();
1823 application.GetScene().Add( sourceActor );
1825 // Register the scroll properties
1826 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1827 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1828 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 800.0f );
1829 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 2000.0f );
1831 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1832 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1833 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1834 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1836 // Set the source of the scroll position properties.
1837 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1839 // Render and notify
1840 application.SendNotification();
1841 application.Render();
1843 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
1844 Dali::Vector<float> positionIntervals;
1845 for( size_t i = 0; i != 10; ++i )
1847 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
1849 scrollBar.SetScrollPositionIntervals(positionIntervals);
1851 // Render and notify
1852 application.SendNotification();
1853 application.Render();
1856 gOnScrollPositionIntervalReachedSignalCalled = false;
1858 // Animate the scroll position to cross the specified value
1859 Animation animation = Animation::New(0.1f);
1860 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
1863 // Wait for 0.1 second
1864 Wait(application, 100);
1866 // Check that the signal callback is called
1867 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1868 DALI_TEST_EQUALS( intervalReached, true, TEST_LOCATION );
1871 gOnScrollPositionIntervalReachedSignalCalled = false;
1872 intervalReached = false;
1874 // Rest and clear the animation
1878 // Animate the scroll position to cross another specified value
1879 animation = Animation::New(0.1f);
1880 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -170.0f );
1883 // Wait for 0.1 second
1884 Wait(application, 100);
1886 // Check that the signal callback is called
1887 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1888 DALI_TEST_EQUALS( intervalReached, true, TEST_LOCATION );
1891 gOnScrollPositionIntervalReachedSignalCalled = false;
1892 intervalReached = false;
1894 // Rest and clear the animation
1898 // Animate the scroll position back to the previous value
1899 animation = Animation::New(0.1f);
1900 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
1903 // Wait for 0.1 second
1904 Wait(application, 100);
1906 // Check that the signal callback is called
1907 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1908 DALI_TEST_EQUALS( intervalReached, true, TEST_LOCATION );
1913 int UtcDaliToolkitScrollBarScrollPositionIntervalReachedSignalN(void)
1915 ToolkitTestApplication application;
1917 // Create a vertical scroll bar
1918 ScrollBar scrollBar = ScrollBar::New(ScrollBar::VERTICAL);
1919 DALI_TEST_CHECK( scrollBar );
1921 scrollBar.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1922 scrollBar.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1923 scrollBar.SetProperty( Actor::Property::SIZE, Vector3(20.0f, 800.0f, 0.0f) );
1925 application.GetScene().Add( scrollBar );
1927 // Connect to the ScrollPositionIntervalReached signal
1928 scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
1930 // Render and notify
1931 application.SendNotification();
1932 application.Render();
1934 // Create a source actor that owns the scroll properties required by the scroll bar
1935 Actor sourceActor = Actor::New();
1936 application.GetScene().Add( sourceActor );
1938 // Register the scroll properties
1939 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1940 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1941 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 800.0f );
1942 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 2000.0f );
1944 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1945 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1946 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1947 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1949 // Set the source of the scroll position properties.
1950 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1952 // Render and notify
1953 application.SendNotification();
1954 application.Render();
1956 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
1957 Dali::Vector<float> positionIntervals;
1958 for( size_t i = 0; i != 10; ++i )
1960 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
1962 scrollBar.SetScrollPositionIntervals(positionIntervals);
1964 // Render and notify
1965 application.SendNotification();
1966 application.Render();
1969 gOnScrollPositionIntervalReachedSignalCalled = false;
1971 // Animate the scroll position not to cross the specified value
1972 Animation animation = Animation::New(0.1f);
1973 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -70.0f );
1976 // Wait for 0.1 second
1977 Wait(application, 100);
1979 // Check that the signal callback is not called
1980 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, false, TEST_LOCATION );
1982 // Rest and clear the animation
1986 // Animate the scroll position to cross another specified value
1987 animation = Animation::New(0.1f);
1988 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
1991 // Wait for 0.1 second
1992 Wait(application, 100);
1994 // Check that the signal callback is called
1995 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );