2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali-toolkit-test-suite-utils.h>
22 #include <dali-toolkit/dali-toolkit.h>
23 #include <dali/devel-api/actors/actor-devel.h>
26 using namespace Toolkit;
28 void dali_scrollbar_startup(void)
30 test_return_value = TET_UNDEF;
33 void dali_scrollbar_cleanup(void)
35 test_return_value = TET_PASS;
41 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
44 * Simulate time passed by.
46 * @note this will always process at least 1 frame (1/60 sec)
48 * @param application Test application instance
49 * @param duration Time to pass in milliseconds.
50 * @return The actual time passed in milliseconds
52 int Wait(ToolkitTestApplication& application, int duration = 0)
56 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
58 application.SendNotification();
59 application.Render(RENDER_FRAME_INTERVAL);
60 time += RENDER_FRAME_INTERVAL;
68 static bool gOnPanFinishedCalled; ///< Whether the PanFinished signal was invoked.
69 static bool gOnScrollPositionIntervalReachedSignalCalled; ///< Whether the ScrollPositionIntervalReached signal was invoked.
72 * Invoked when pan gesture is finished on the scroll indicator.
74 static void OnPanFinished()
76 gOnPanFinishedCalled = true;
79 struct CallbackFunctor
81 CallbackFunctor(bool* callbackFlag)
82 : mCallbackFlag( callbackFlag )
88 *mCallbackFlag = true;
94 * Invoked when the current scroll position of the scrollable content goes above or below the values
95 * specified by SCROLL_POSITION_INTERVALS property.
97 * @param[in] position The current scroll position.
99 static void OnScrollPositionIntervalReached( float position )
101 gOnScrollPositionIntervalReachedSignalCalled = true;
104 static Vector2 PerformGestureSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, uint32_t start_time)
106 gOnPanFinishedCalled = false;
108 // Now do a pan starting from (start) and heading (direction)
109 Vector2 pos( start + ( direction * 15 ) );
110 uint32_t time = start_time;
112 TestStartPan( application, start, pos, time );
116 for(int i = 0; i < frames; i++)
118 pos += direction; // Move in this direction
119 time += RENDER_FRAME_INTERVAL;
120 TestMovePan( application, pos, time);
124 pos += direction; // Move in this direction.
125 time += RENDER_FRAME_INTERVAL;
126 TestEndPan(application, pos, time );
134 int UtcDaliToolkitScrollBarConstructorP(void)
136 ToolkitTestApplication application;
139 DALI_TEST_CHECK( !scrollBar );
143 int UtcDaliToolkitScrollBarCopyConstructorP(void)
145 ToolkitTestApplication application;
147 ScrollBar scrollBar = ScrollBar::New();
148 scrollBar.SetProperty( ScrollBar::Property::INDICATOR_FIXED_HEIGHT, 38.2f );
150 ScrollBar copy( scrollBar );
151 DALI_TEST_CHECK( copy );
152 DALI_TEST_CHECK( copy.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) == scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) );
156 int UtcDaliToolkitScrollBarAssignmentOperatorP(void)
158 ToolkitTestApplication application;
160 ScrollBar scrollBar = ScrollBar::New();
161 scrollBar.SetProperty( ScrollBar::Property::INDICATOR_FIXED_HEIGHT, 38.2f );
163 ScrollBar copy = scrollBar;
164 DALI_TEST_CHECK( copy );
165 DALI_TEST_CHECK( copy.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) == scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) );
169 int UtcDaliScrollBarDestructorP(void)
171 ToolkitTestApplication application;
173 ScrollBar* scrollBar = new ScrollBar();
176 DALI_TEST_CHECK( true );
180 int UtcDaliToolkitScrollBarNewP(void)
182 ToolkitTestApplication application;
184 ScrollBar scrollBar = ScrollBar::New();
185 DALI_TEST_CHECK( scrollBar );
188 ScrollBar vertical = ScrollBar::New(ScrollBar::Vertical);
189 DALI_TEST_CHECK( vertical );
190 DALI_TEST_CHECK( vertical.GetScrollDirection() == ScrollBar::Vertical );
192 Property::Value value = vertical.GetProperty(ScrollBar::Property::SCROLL_DIRECTION);
193 std::string scrollDirection = value.Get<std::string>();
194 DALI_TEST_EQUALS( scrollDirection, "Vertical", TEST_LOCATION );
196 ScrollBar horizontal = ScrollBar::New(ScrollBar::Horizontal);
197 DALI_TEST_CHECK( horizontal );
198 DALI_TEST_CHECK( horizontal.GetScrollDirection() == ScrollBar::Horizontal );
199 value = vertical.GetProperty(ScrollBar::Property::SCROLL_DIRECTION);
200 scrollDirection = value.Get<std::string>();
201 DALI_TEST_EQUALS( scrollDirection, "Horizontal", TEST_LOCATION );
206 int UtcDaliToolkitScrollBarCreateP(void)
208 ToolkitTestApplication application;
210 TypeRegistry typeRegistry = TypeRegistry::Get();
211 DALI_TEST_CHECK( typeRegistry );
213 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "ScrollBar" );
214 DALI_TEST_CHECK( typeInfo );
216 BaseHandle handle = typeInfo.CreateInstance();
217 DALI_TEST_CHECK( handle );
219 ScrollBar scrollBar = ScrollBar::DownCast( handle );
220 DALI_TEST_CHECK( scrollBar );
222 scrollBar.SetProperty(ScrollBar::Property::SCROLL_DIRECTION, "Vertical");
223 scrollBar.SetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY, "Fixed");
225 DALI_TEST_EQUALS( scrollBar.GetScrollDirection(), Toolkit::ScrollBar::Vertical, TEST_LOCATION );
226 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Fixed, TEST_LOCATION );
228 scrollBar.SetProperty(ScrollBar::Property::SCROLL_DIRECTION, "Horizontal");
229 scrollBar.SetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY, "Variable");
231 DALI_TEST_EQUALS( scrollBar.GetScrollDirection(), Toolkit::ScrollBar::Horizontal, TEST_LOCATION );
232 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Variable, TEST_LOCATION );
237 int UtcDaliToolkitScrollBarDownCastP(void)
239 ToolkitTestApplication application;
241 ScrollBar scrollBar1 = ScrollBar::New();
242 BaseHandle object( scrollBar1 );
244 ScrollBar scrollBar2 = ScrollBar::DownCast( object );
245 DALI_TEST_CHECK( scrollBar2 );
247 ScrollBar scrollBar3 = DownCast< ScrollBar >( object );
248 DALI_TEST_CHECK( scrollBar3 );
252 int UtcDaliToolkitScrollBarDownCastN(void)
254 ToolkitTestApplication application;
256 BaseHandle uninitializedObject;
257 ScrollBar scrollBar1 = ScrollBar::DownCast( uninitializedObject );
258 DALI_TEST_CHECK( !scrollBar1 );
260 ScrollBar scrollBar2 = DownCast< ScrollBar >( uninitializedObject );
261 DALI_TEST_CHECK( !scrollBar2 );
265 int UtcDaliToolkitScrollBarSetScrollPropertySourceP(void)
267 ToolkitTestApplication application;
269 // Create a vertical scroll bar
270 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
271 DALI_TEST_CHECK( scrollBar );
272 DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::Vertical );
274 float scrollBarHeight = 100.0f;
275 scrollBar.SetProperty( Actor::Property::SIZE, Vector3(20.0f, scrollBarHeight, 0.0f) );
276 Stage::GetCurrent().Add( scrollBar );
278 // Create a source actor that owns the scroll properties required by the scroll bar
279 Actor sourceActor = Actor::New();
280 Stage::GetCurrent().Add( sourceActor );
282 // Register the scroll properties
283 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
284 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
285 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
286 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
288 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
289 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
290 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
291 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
293 // Set the source of the scroll position properties.
294 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
297 application.SendNotification();
298 application.Render();
300 Actor indicator = scrollBar.GetScrollIndicator();
301 DALI_TEST_CHECK( indicator );
303 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
304 // i.e. The bigger the content size, the smaller the indicator size
305 float indicatorHeight = indicator.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).y;
306 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
308 // Decrease the content length
309 sourceActor.SetProperty( propertyScrollContentSize, 250.0f );
312 application.SendNotification();
313 application.Render();
315 // Check that the indicator size is changed accordingly
316 indicatorHeight = indicator.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).y;
317 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 250.0f, TEST_LOCATION );
319 // As scroll position is 0, check that the indicator position should be 0.0f.
320 float indicatorPosition = indicator.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y;
321 DALI_TEST_EQUALS( indicatorPosition, 0.0f, TEST_LOCATION );
323 // Set the scroll position to the middle
324 sourceActor.SetProperty( propertyScrollPosition, -50.0f );
327 application.SendNotification();
328 application.Render();
330 // Check that the indicator should be in the middle of the scroll bar
331 indicatorPosition = indicator.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y;
332 DALI_TEST_EQUALS( indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.5f, TEST_LOCATION );
334 // Set the scroll position to the maximum
335 sourceActor.SetProperty( propertyScrollPosition, -100.0f );
338 application.SendNotification();
339 application.Render();
341 // Check that the indicator should be in the end of the scroll bar
342 indicatorPosition = indicator.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y;
343 DALI_TEST_EQUALS( indicatorPosition, scrollBarHeight - indicatorHeight, TEST_LOCATION );
345 // Increase the maximum scroll position to double
346 sourceActor.SetProperty( propertyMaxScrollPosition, 200.0f );
349 application.SendNotification();
350 application.Render();
352 // Check that the indicator should be now in the middle of the scroll bar
353 indicatorPosition = indicator.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y;
354 DALI_TEST_EQUALS( indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.5f, TEST_LOCATION );
356 // Create another source actor
357 Actor newSourceActor = Actor::New();
358 Stage::GetCurrent().Add( newSourceActor );
360 // Register the scroll properties
361 Property::Index newPropertyScrollPosition = newSourceActor.RegisterProperty( "sourcePosition", 0.0f );
362 Property::Index newPropertyMinScrollPosition = newSourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
363 Property::Index newPropertyMaxScrollPosition = newSourceActor.RegisterProperty( "sourcePositionMax", 200.0f );
364 Property::Index newPropertyScrollContentSize = newSourceActor.RegisterProperty( "sourceContentSize", 400.0f );
366 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourcePosition" ), newPropertyScrollPosition, TEST_LOCATION );
367 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourcePositionMin" ), newPropertyMinScrollPosition, TEST_LOCATION );
368 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourcePositionMax" ), newPropertyMaxScrollPosition, TEST_LOCATION );
369 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourceContentSize" ), newPropertyScrollContentSize, TEST_LOCATION );
371 // Change the source of the scroll position properties to be the new source actor.
372 scrollBar.SetScrollPropertySource(newSourceActor, newPropertyScrollPosition, newPropertyMinScrollPosition, newPropertyMaxScrollPosition, newPropertyScrollContentSize);
375 application.SendNotification();
376 application.Render();
378 // Check that the indicator size is changed accordingly
379 indicatorHeight = indicator.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).y;
380 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 400.0f, TEST_LOCATION );
382 // Check that the indicator position goes back to the beginning of the scroll bar
383 indicatorPosition = indicator.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y;
384 DALI_TEST_EQUALS( indicatorPosition, 0.0f, TEST_LOCATION );
386 // Set the scroll position to one fifth of the maximum
387 newSourceActor.SetProperty( propertyScrollPosition, -40.0f );
390 application.SendNotification();
391 application.Render();
393 // Check that the indicator should be in one fifth from the beginning of the scroll bar
394 indicatorPosition = indicator.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y;
395 DALI_TEST_EQUALS( indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.2f, TEST_LOCATION );
400 int UtcDaliToolkitScrollBarSetScrollPropertySourceN(void)
402 ToolkitTestApplication application;
404 // Create a scroll bar
405 ScrollBar scrollBar = ScrollBar::New();
406 DALI_TEST_CHECK( scrollBar );
408 // Set empty handle of source object and invalid source property index.
410 scrollBar.SetScrollPropertySource(sourceActor, Property::INVALID_INDEX, Property::INVALID_INDEX, Property::INVALID_INDEX, Property::INVALID_INDEX);
412 DALI_TEST_CHECK( true );
416 int UtcDaliToolkitScrollBarSetScrollIndicatorP(void)
418 ToolkitTestApplication application;
420 // Create a scroll bar
421 ScrollBar scrollBar = ScrollBar::New();
422 DALI_TEST_CHECK( scrollBar );
424 Actor indicator = scrollBar.GetScrollIndicator();
425 DALI_TEST_CHECK( indicator );
427 // Set a new indicator
428 Actor newIndicator = Actor::New();
429 scrollBar.SetScrollIndicator(newIndicator);
431 // Check that the new indicator is successfully set
432 DALI_TEST_CHECK( indicator != scrollBar.GetScrollIndicator() );
433 DALI_TEST_CHECK( newIndicator == scrollBar.GetScrollIndicator() );
435 // Check that the new control indicator is successfully set
436 Control controlIndicator = Control::New();
437 scrollBar.SetScrollIndicator(controlIndicator);
439 DALI_TEST_CHECK( controlIndicator == Control::DownCast( scrollBar.GetScrollIndicator() ) );
443 int UtcDaliToolkitScrollBarSetScrollIndicatorN(void)
445 ToolkitTestApplication application;
447 // Create a scroll bar
448 ScrollBar scrollBar = ScrollBar::New();
449 DALI_TEST_CHECK( scrollBar );
451 Actor indicator = scrollBar.GetScrollIndicator();
452 DALI_TEST_CHECK( indicator );
454 // Try to set an uninitialized actor as the indicator
455 Actor uninitializedIndicator;
456 scrollBar.SetScrollIndicator(uninitializedIndicator);
458 // Check that the uninitialized actor can not be set as the indicator
459 DALI_TEST_CHECK( indicator == scrollBar.GetScrollIndicator() );
460 DALI_TEST_CHECK( uninitializedIndicator != scrollBar.GetScrollIndicator() );
465 int UtcDaliToolkitScrollBarGetScrollIndicatorP(void)
467 ToolkitTestApplication application;
469 // Create a scroll bar
470 ScrollBar scrollBar = ScrollBar::New();
471 DALI_TEST_CHECK( scrollBar );
473 Actor indicator = scrollBar.GetScrollIndicator();
474 DALI_TEST_CHECK( indicator );
476 // Set a new indicator
477 Actor newIndicator = Actor::New();
478 scrollBar.SetScrollIndicator(newIndicator);
480 // Check that the new indicator is successfully set
481 DALI_TEST_CHECK( scrollBar.GetScrollIndicator() );
482 DALI_TEST_CHECK( indicator != scrollBar.GetScrollIndicator() );
483 DALI_TEST_CHECK( newIndicator == scrollBar.GetScrollIndicator() );
488 int UtcDaliToolkitScrollBarGetScrollIndicatorN(void)
490 ToolkitTestApplication application;
492 // Create a scroll bar
493 ScrollBar scrollBar = ScrollBar::New();
494 DALI_TEST_CHECK( scrollBar );
496 Actor indicator = scrollBar.GetScrollIndicator();
497 DALI_TEST_CHECK( indicator );
499 // Try to set an uninitialized actor as the indicator
500 Actor uninitializedIndicator;
501 scrollBar.SetScrollIndicator(uninitializedIndicator);
503 // Check that the indicator has not been changed
504 DALI_TEST_CHECK( indicator == scrollBar.GetScrollIndicator() );
505 DALI_TEST_CHECK( uninitializedIndicator != scrollBar.GetScrollIndicator() );
510 int UtcDaliToolkitScrollBarSetScrollPositionIntervalsP(void)
512 ToolkitTestApplication application;
514 // Create a vertical scroll bar
515 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
516 DALI_TEST_CHECK( scrollBar );
518 scrollBar.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
519 scrollBar.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
520 scrollBar.SetProperty( Actor::Property::SIZE, Vector3(20.0f, 800.0f, 0.0f) );
522 Stage::GetCurrent().Add( scrollBar );
524 // Connect to the ScrollPositionIntervalReached signal
525 scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
528 application.SendNotification();
529 application.Render();
531 // Create a source actor that owns the scroll properties required by the scroll bar
532 Actor sourceActor = Actor::New();
533 Stage::GetCurrent().Add( sourceActor );
535 // Register the scroll properties
536 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
537 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
538 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 800.0f );
539 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 2000.0f );
541 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
542 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
543 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
544 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
546 // Set the source of the scroll position properties.
547 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
550 application.SendNotification();
551 application.Render();
553 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
554 Dali::Vector<float> positionIntervals;
555 for( size_t i = 0; i != 10; ++i )
557 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
559 scrollBar.SetScrollPositionIntervals(positionIntervals);
561 // Get the list of scroll position intervals for notification
562 Dali::Vector<float> results = scrollBar.GetScrollPositionIntervals();
564 // Check that the result is the same as the list previously set.
565 DALI_TEST_EQUALS( positionIntervals.Count(), results.Count(), TEST_LOCATION );
566 DALI_TEST_EQUALS( positionIntervals[0], results[0], TEST_LOCATION );
567 DALI_TEST_EQUALS( positionIntervals[1], results[1], TEST_LOCATION );
568 DALI_TEST_EQUALS( positionIntervals[2], results[2], TEST_LOCATION );
569 DALI_TEST_EQUALS( positionIntervals[3], results[3], TEST_LOCATION );
570 DALI_TEST_EQUALS( positionIntervals[4], results[4], TEST_LOCATION );
571 DALI_TEST_EQUALS( positionIntervals[5], results[5], TEST_LOCATION );
572 DALI_TEST_EQUALS( positionIntervals[6], results[6], TEST_LOCATION );
573 DALI_TEST_EQUALS( positionIntervals[7], results[7], TEST_LOCATION );
574 DALI_TEST_EQUALS( positionIntervals[8], results[8], TEST_LOCATION );
575 DALI_TEST_EQUALS( positionIntervals[9], results[9], TEST_LOCATION );
578 gOnScrollPositionIntervalReachedSignalCalled = false;
580 // Animate the scroll position to cross the specified value
581 Animation animation = Animation::New(0.1f);
582 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
585 // Wait for 0.1 second
586 Wait(application, 100);
588 // Check that the signal callback is called
589 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
592 gOnScrollPositionIntervalReachedSignalCalled = false;
594 // Rest and clear the animation
598 // Animate the scroll position to cross another specified value
599 animation = Animation::New(0.1f);
600 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -170.0f );
603 // Wait for 0.1 second
604 Wait(application, 100);
606 // Check that the signal callback is called
607 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
610 gOnScrollPositionIntervalReachedSignalCalled = false;
612 // Rest and clear the animation
616 // Animate the scroll position back to the previous value
617 animation = Animation::New(0.1f);
618 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
621 // Wait for 0.1 second
622 Wait(application, 100);
624 // Check that the signal callback is called
625 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
630 int UtcDaliToolkitScrollBarGetScrollPositionIntervalsP(void)
632 ToolkitTestApplication application;
634 // Create a vertical scroll bar
635 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
636 DALI_TEST_CHECK( scrollBar );
638 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
639 Dali::Vector<float> positionIntervals;
640 for( size_t i = 0; i != 10; ++i )
642 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
644 scrollBar.SetScrollPositionIntervals(positionIntervals);
646 // Get the list of scroll position intervals for notification
647 Dali::Vector<float> results = scrollBar.GetScrollPositionIntervals();
649 // Check that the result is the same as the list previously set.
650 DALI_TEST_EQUALS( positionIntervals.Count(), results.Count(), TEST_LOCATION );
651 DALI_TEST_EQUALS( positionIntervals[0], results[0], TEST_LOCATION );
652 DALI_TEST_EQUALS( positionIntervals[1], results[1], TEST_LOCATION );
653 DALI_TEST_EQUALS( positionIntervals[2], results[2], TEST_LOCATION );
654 DALI_TEST_EQUALS( positionIntervals[3], results[3], TEST_LOCATION );
655 DALI_TEST_EQUALS( positionIntervals[4], results[4], TEST_LOCATION );
656 DALI_TEST_EQUALS( positionIntervals[5], results[5], TEST_LOCATION );
657 DALI_TEST_EQUALS( positionIntervals[6], results[6], TEST_LOCATION );
658 DALI_TEST_EQUALS( positionIntervals[7], results[7], TEST_LOCATION );
659 DALI_TEST_EQUALS( positionIntervals[8], results[8], TEST_LOCATION );
660 DALI_TEST_EQUALS( positionIntervals[9], results[9], TEST_LOCATION );
662 Property::Array resultArray = scrollBar.GetProperty<Property::Array>(Toolkit::ScrollBar::Property::SCROLL_POSITION_INTERVALS);
664 DALI_TEST_EQUALS( positionIntervals.Count(), resultArray.Count(), TEST_LOCATION );
665 DALI_TEST_EQUALS( positionIntervals[0], resultArray[0].Get<float>(), TEST_LOCATION );
666 DALI_TEST_EQUALS( positionIntervals[1], resultArray[1].Get<float>(), TEST_LOCATION );
667 DALI_TEST_EQUALS( positionIntervals[2], resultArray[2].Get<float>(), TEST_LOCATION );
668 DALI_TEST_EQUALS( positionIntervals[3], resultArray[3].Get<float>(), TEST_LOCATION );
669 DALI_TEST_EQUALS( positionIntervals[4], resultArray[4].Get<float>(), TEST_LOCATION );
670 DALI_TEST_EQUALS( positionIntervals[5], resultArray[5].Get<float>(), TEST_LOCATION );
671 DALI_TEST_EQUALS( positionIntervals[6], resultArray[6].Get<float>(), TEST_LOCATION );
672 DALI_TEST_EQUALS( positionIntervals[7], resultArray[7].Get<float>(), TEST_LOCATION );
673 DALI_TEST_EQUALS( positionIntervals[8], resultArray[8].Get<float>(), TEST_LOCATION );
674 DALI_TEST_EQUALS( positionIntervals[9], resultArray[9].Get<float>(), TEST_LOCATION );
679 int UtcDaliToolkitScrollBarGetScrollDirectionP(void)
681 ToolkitTestApplication application;
683 // Create a vertical scroll bar
684 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
685 DALI_TEST_CHECK( scrollBar );
686 DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::Vertical );
688 // Change the direction of scroll bar to horizontal
689 scrollBar.SetScrollDirection(ScrollBar::Horizontal);
690 DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::Horizontal );
695 int UtcDaliToolkitScrollBarSetIndicatorHeightPolicyP(void)
697 ToolkitTestApplication application;
699 // Create a scroll bar
700 ScrollBar scrollBar = ScrollBar::New();
701 DALI_TEST_CHECK( scrollBar );
703 float scrollBarHeight = 100.0f;
704 scrollBar.SetProperty( Actor::Property::SIZE, Vector3(20.0f, scrollBarHeight, 0.0f) );
705 Stage::GetCurrent().Add( scrollBar );
707 // Create a source actor that owns the scroll properties required by the scroll bar
708 Actor sourceActor = Actor::New();
709 Stage::GetCurrent().Add( sourceActor );
711 // Register the scroll properties
712 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
713 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
714 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
715 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
717 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
718 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
719 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
720 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
722 // Set the source of the scroll position properties.
723 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
726 application.SendNotification();
727 application.Render();
729 Actor indicator = scrollBar.GetScrollIndicator();
730 DALI_TEST_CHECK( indicator );
732 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
733 // i.e. The bigger the content size, the smaller the indicator size
734 float indicatorHeight = indicator.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).y;
735 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
737 // Set the indicator height to be fixed to 50.0f
738 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
739 scrollBar.SetIndicatorFixedHeight(50.0f);
741 Property::Value value = scrollBar.GetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY);
742 DALI_TEST_EQUALS(value.Get<std::string>(), "Fixed", TEST_LOCATION );
745 application.SendNotification();
746 application.Render();
748 // Check that the indicator size should be 50.0f
749 indicatorHeight = indicator.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).y;
750 DALI_TEST_EQUALS( indicatorHeight, 50.0f, TEST_LOCATION );
752 // Set the indicator height to be variable
753 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Variable);
754 value = scrollBar.GetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY);
755 DALI_TEST_EQUALS(value.Get<std::string>(), "Variable", TEST_LOCATION );
758 application.SendNotification();
759 application.Render();
761 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
762 indicatorHeight = indicator.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).y;
763 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
768 int UtcDaliToolkitScrollBarGetIndicatorHeightPolicyP(void)
770 ToolkitTestApplication application;
772 // Create a scroll bar
773 ScrollBar scrollBar = ScrollBar::New();
774 DALI_TEST_CHECK( scrollBar );
776 // Set the indicator height to be fixed
777 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
778 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Fixed, TEST_LOCATION );
780 // Set the indicator height to be variable
781 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Variable);
782 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Variable, TEST_LOCATION );
787 int UtcDaliToolkitScrollBarSetIndicatorFixedHeightP(void)
789 ToolkitTestApplication application;
791 // Create a scroll bar
792 ScrollBar scrollBar = ScrollBar::New();
793 DALI_TEST_CHECK( scrollBar );
795 float scrollBarHeight = 100.0f;
796 scrollBar.SetProperty( Actor::Property::SIZE, Vector3(20.0f, scrollBarHeight, 0.0f) );
797 Stage::GetCurrent().Add( scrollBar );
799 Actor indicator = scrollBar.GetScrollIndicator();
800 DALI_TEST_CHECK( indicator );
802 // Set the indicator height to be fixed to 50.0f
803 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
804 scrollBar.SetIndicatorFixedHeight(50.0f);
807 application.SendNotification();
808 application.Render();
810 // Check that the indicator size should be 50.0f
811 DALI_TEST_EQUALS( indicator.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).y, 50.0f, TEST_LOCATION );
813 // Set the indicator height to be fixed to 25.0f
814 scrollBar.SetIndicatorFixedHeight(25.0f);
817 application.SendNotification();
818 application.Render();
820 // Check that the indicator size should be 25.0f
821 DALI_TEST_EQUALS( indicator.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).y, 25.0f, TEST_LOCATION );
826 int UtcDaliToolkitScrollBarGetIndicatorFixedHeightP(void)
828 ToolkitTestApplication application;
830 // Create a scroll bar
831 ScrollBar scrollBar = ScrollBar::New();
832 DALI_TEST_CHECK( scrollBar );
834 // Set the fixed indicator height to be 50.0f
835 scrollBar.SetIndicatorFixedHeight(50.0f);
837 // Check that the indicator size should be 50.0f
838 DALI_TEST_EQUALS( scrollBar.GetIndicatorFixedHeight(), 50.0f, TEST_LOCATION );
840 // Set the indicator height to be fixed to 25.0f
841 scrollBar.SetIndicatorFixedHeight(25.0f);
843 // Check that the indicator size should be 50.0f
844 DALI_TEST_EQUALS( scrollBar.GetIndicatorFixedHeight(), 25.0f, TEST_LOCATION );
849 int UtcDaliToolkitScrollBarSetIndicatorShowDurationP(void)
851 ToolkitTestApplication application;
853 // Create a scroll bar
854 ScrollBar scrollBar = ScrollBar::New();
855 DALI_TEST_CHECK( scrollBar );
857 Stage::GetCurrent().Add( scrollBar );
859 Actor indicator = scrollBar.GetScrollIndicator();
860 DALI_TEST_CHECK( indicator );
862 // Set the duration to show the indicator to be 0.35 second
863 scrollBar.SetIndicatorShowDuration(0.35);
864 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.35f, TEST_LOCATION );
866 // Make the indicator invisible
867 indicator.SetProperty( DevelActor::Property::OPACITY,0.0f);
870 application.SendNotification();
871 application.Render();
873 // Check that the indicator is invisible
874 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, TEST_LOCATION );
876 // Show the indicator
877 scrollBar.ShowIndicator();
879 // Wait for 0.35 second
880 Wait(application, 350);
883 application.SendNotification();
884 application.Render();
886 // Check that the indicator is now visible
887 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 1.0f, TEST_LOCATION );
889 // Set the duration to show the indicator to be 0.75 second
890 scrollBar.SetIndicatorShowDuration(0.75);
891 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.75f, TEST_LOCATION );
893 // Make the indicator invisible
894 indicator.SetProperty( DevelActor::Property::OPACITY,0.0f);
897 application.SendNotification();
898 application.Render();
900 // Check that the indicator is invisible
901 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, TEST_LOCATION );
903 // Show the indicator
904 scrollBar.ShowIndicator();
906 // Wait for 0.35 second first
907 Wait(application, 350);
910 application.SendNotification();
911 application.Render();
913 // Check that the indicator is not fully visible yet
914 DALI_TEST_CHECK( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ) != 1.0f );
916 // Wait for another 0.4 second
917 Wait(application, 400);
920 application.SendNotification();
921 application.Render();
923 // Check that the indicator is now fully visible
924 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 1.0f, TEST_LOCATION );
929 int UtcDaliToolkitScrollBarSetIndicatorShowDurationN(void)
931 ToolkitTestApplication application;
933 // Create a scroll bar
934 ScrollBar scrollBar = ScrollBar::New();
935 DALI_TEST_CHECK( scrollBar );
937 Stage::GetCurrent().Add( scrollBar );
939 Actor indicator = scrollBar.GetScrollIndicator();
940 DALI_TEST_CHECK( indicator );
942 // Get the default duration to show the indicator
943 float duration = scrollBar.GetIndicatorShowDuration();
945 // Check that the default duration is greater than 0
946 DALI_TEST_CHECK( duration > 0.0f );
948 // Make the indicator invisible
949 indicator.SetProperty( DevelActor::Property::OPACITY,0.0f);
952 application.SendNotification();
953 application.Render();
955 // Check that the indicator is invisible
956 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, TEST_LOCATION );
958 // Show the indicator
959 scrollBar.ShowIndicator();
961 // Wait for the specified duration
962 Wait(application, duration * 1000);
965 application.SendNotification();
966 application.Render();
968 // Check that the indicator is now visible
969 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 1.0f, TEST_LOCATION );
971 // Now set the duration to show the indicator to be a negative value (which should be ignored and therefore means instant)
972 scrollBar.SetIndicatorShowDuration(-0.25f);
973 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), -0.25f, TEST_LOCATION );
975 // Make the indicator invisible
976 indicator.SetProperty( DevelActor::Property::OPACITY,0.0f);
979 application.SendNotification();
980 application.Render();
982 // Check that the indicator is invisible
983 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, TEST_LOCATION );
985 // Show the indicator
986 scrollBar.ShowIndicator();
989 application.SendNotification();
990 application.Render();
992 // Check that the indicator becomes instantly visible in the next frame
993 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 1.0f, TEST_LOCATION );
998 int UtcDaliToolkitScrollBarGetIndicatorShowDurationP(void)
1000 ToolkitTestApplication application;
1002 // Create a scroll bar
1003 ScrollBar scrollBar = ScrollBar::New();
1004 DALI_TEST_CHECK( scrollBar );
1006 // Set the duration to show the indicator to be 0.35 second
1007 scrollBar.SetIndicatorShowDuration(0.35f);
1009 // Check that the duration to show the indicator is 0.35 second
1010 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.35f, TEST_LOCATION );
1012 // Set the duration to show the indicator to be 0.75 second
1013 scrollBar.SetIndicatorShowDuration(0.75f);
1015 // Check that the duration to show the indicator is 0.75 second
1016 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.75f, TEST_LOCATION );
1021 int UtcDaliToolkitScrollBarSetIndicatorHideDurationP(void)
1023 ToolkitTestApplication application;
1025 // Create a scroll bar
1026 ScrollBar scrollBar = ScrollBar::New();
1027 DALI_TEST_CHECK( scrollBar );
1029 Stage::GetCurrent().Add( scrollBar );
1031 Actor indicator = scrollBar.GetScrollIndicator();
1032 DALI_TEST_CHECK( indicator );
1034 // Set the duration to hide the indicator to be 0.15 second
1035 scrollBar.SetIndicatorHideDuration(0.15f);
1036 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.15f, TEST_LOCATION );
1038 // Make the indicator visible
1039 indicator.SetProperty( DevelActor::Property::OPACITY,1.0f);
1041 // Render and notify
1042 application.SendNotification();
1043 application.Render();
1045 // Check that the indicator is visible
1046 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1048 // Hide the indicator
1049 scrollBar.HideIndicator();
1051 // Wait for 0.15 second
1052 Wait(application, 150);
1054 // Render and notify
1055 application.SendNotification();
1056 application.Render();
1058 // Check that the indicator is now invisible
1059 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1061 // Set the duration to hide the indicator to be 0.65 second
1062 scrollBar.SetIndicatorHideDuration(0.65f);
1063 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.65f, TEST_LOCATION );
1065 // Make the indicator visible
1066 indicator.SetProperty( DevelActor::Property::OPACITY,1.0f);
1068 // Render and notify
1069 application.SendNotification();
1070 application.Render();
1072 // Check that the indicator is visible
1073 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1075 // Hide the indicator
1076 scrollBar.HideIndicator();
1078 // Wait for 0.15 second first
1079 Wait(application, 150);
1081 // Render and notify
1082 application.SendNotification();
1083 application.Render();
1085 // Check that the indicator is not fully invisible yet
1086 DALI_TEST_CHECK( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ) != 0.0f );
1088 // Wait for another 0.5 second
1089 Wait(application, 500);
1091 // Render and notify
1092 application.SendNotification();
1093 application.Render();
1095 // Check that the indicator is now fully invisible
1096 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1101 int UtcDaliToolkitScrollBarSetIndicatorHideDurationN(void)
1103 ToolkitTestApplication application;
1105 // Create a scroll bar
1106 ScrollBar scrollBar = ScrollBar::New();
1107 DALI_TEST_CHECK( scrollBar );
1109 Stage::GetCurrent().Add( scrollBar );
1111 Actor indicator = scrollBar.GetScrollIndicator();
1112 DALI_TEST_CHECK( indicator );
1114 // Get the default duration to hide the indicator
1115 float duration = scrollBar.GetIndicatorHideDuration();
1117 // Check that the default duration is greater than 0
1118 DALI_TEST_CHECK( duration > 0.0f );
1120 // Make the indicator visible
1121 indicator.SetProperty( DevelActor::Property::OPACITY,1.0f);
1123 // Render and notify
1124 application.SendNotification();
1125 application.Render();
1127 // Check that the indicator is visible
1128 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1130 // Hide the indicator
1131 scrollBar.HideIndicator();
1133 // Wait for the specified duration
1134 Wait(application, duration * 1000);
1136 // Render and notify
1137 application.SendNotification();
1138 application.Render();
1140 // Check that the indicator is now invisible
1141 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1143 // Now set the duration to hide the indicator to be a negative value (which should be ignored and therefore means instant)
1144 scrollBar.SetIndicatorHideDuration(-0.25f);
1145 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), -0.25f, TEST_LOCATION );
1147 // Make the indicator visible
1148 indicator.SetProperty( DevelActor::Property::OPACITY,1.0f);
1150 // Render and notify
1151 application.SendNotification();
1152 application.Render();
1154 // Check that the indicator is visible
1155 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1157 // Hide the indicator
1158 scrollBar.HideIndicator();
1160 // Render and notify
1161 application.SendNotification();
1162 application.Render();
1164 // Check that the indicator becomes instantly invisible in the next frame
1165 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1170 int UtcDaliToolkitScrollBarGetIndicatorHideDurationP(void)
1172 ToolkitTestApplication application;
1174 // Create a scroll bar
1175 ScrollBar scrollBar = ScrollBar::New();
1176 DALI_TEST_CHECK( scrollBar );
1178 // Set the duration to hide the indicator to be 0.15 second
1179 scrollBar.SetIndicatorHideDuration(0.15f);
1181 // Check that the duration to hide the indicator is 0.15 second
1182 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.15f, TEST_LOCATION );
1184 // Set the duration to hide the indicator to be 0.65 second
1185 scrollBar.SetIndicatorHideDuration(0.65f);
1187 // Check that the duration to hide the indicator is 0.65 second
1188 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.65f, TEST_LOCATION );
1193 int UtcDaliToolkitScrollBarShowIndicatorP(void)
1195 ToolkitTestApplication application;
1197 // Create a scroll bar
1198 ScrollBar scrollBar = ScrollBar::New();
1199 DALI_TEST_CHECK( scrollBar );
1201 Stage::GetCurrent().Add( scrollBar );
1203 Actor indicator = scrollBar.GetScrollIndicator();
1204 DALI_TEST_CHECK( indicator );
1206 // Get the default duration to show the indicator
1207 float duration = scrollBar.GetIndicatorShowDuration();
1209 // Check that the default duration is greater than 0
1210 DALI_TEST_CHECK( duration > 0.0f );
1212 // Make the indicator invisible
1213 indicator.SetProperty( DevelActor::Property::OPACITY,0.0f);
1215 // Render and notify
1216 application.SendNotification();
1217 application.Render();
1219 // Check that the indicator is invisible
1220 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1222 // Show the indicator
1223 scrollBar.ShowIndicator();
1225 // Wait for the specified duration
1226 Wait(application, duration * 1000);
1228 // Render and notify
1229 application.SendNotification();
1230 application.Render();
1232 // Check that the indicator is now visible
1233 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1238 int UtcDaliToolkitScrollBarShowIndicatorN(void)
1240 ToolkitTestApplication application;
1242 // Create a scroll bar
1243 ScrollBar scrollBar = ScrollBar::New();
1244 DALI_TEST_CHECK( scrollBar );
1246 Stage::GetCurrent().Add( scrollBar );
1248 Actor indicator = scrollBar.GetScrollIndicator();
1249 DALI_TEST_CHECK( indicator );
1251 // Make the indicator initially visible
1252 indicator.SetProperty( DevelActor::Property::OPACITY,1.0f);
1254 // Render and notify
1255 application.SendNotification();
1256 application.Render();
1258 // Check that the indicator is initially visible
1259 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1261 // Get the default duration to show the indicator
1262 float duration = scrollBar.GetIndicatorShowDuration();
1264 // Check that the default duration is greater than 0
1265 DALI_TEST_CHECK( duration > 0.0f );
1267 // Show the indicator
1268 scrollBar.ShowIndicator();
1270 // Render and notify
1271 application.SendNotification();
1272 application.Render();
1274 // Check that the indicator is still visible in the very next frame
1275 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1280 int UtcDaliToolkitScrollBarHideIndicatorP(void)
1282 ToolkitTestApplication application;
1284 // Create a scroll bar
1285 ScrollBar scrollBar = ScrollBar::New();
1286 DALI_TEST_CHECK( scrollBar );
1288 Stage::GetCurrent().Add( scrollBar );
1290 Actor indicator = scrollBar.GetScrollIndicator();
1291 DALI_TEST_CHECK( indicator );
1293 // Get the default duration to hide the indicator
1294 float duration = scrollBar.GetIndicatorHideDuration();
1296 // Check that the default duration is greater than 0
1297 DALI_TEST_CHECK( duration > 0.0f );
1299 // Make the indicator visible
1300 indicator.SetProperty( DevelActor::Property::OPACITY,1.0f);
1302 // Render and notify
1303 application.SendNotification();
1304 application.Render();
1306 // Check that the indicator is visible
1307 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1309 // Hide the indicator
1310 scrollBar.HideIndicator();
1312 // Wait for the specified duration
1313 Wait(application, duration * 1000);
1315 // Render and notify
1316 application.SendNotification();
1317 application.Render();
1319 // Check that the indicator is now invisible
1320 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1325 int UtcDaliToolkitScrollBarHideIndicatorN(void)
1327 ToolkitTestApplication application;
1329 // Create a scroll bar
1330 ScrollBar scrollBar = ScrollBar::New();
1331 DALI_TEST_CHECK( scrollBar );
1333 Stage::GetCurrent().Add( scrollBar );
1335 Actor indicator = scrollBar.GetScrollIndicator();
1336 DALI_TEST_CHECK( indicator );
1338 // Make the indicator initially invisible
1339 indicator.SetProperty( DevelActor::Property::OPACITY,0.0f);
1341 // Render and notify
1342 application.SendNotification();
1343 application.Render();
1345 // Check that the indicator is initially invisible
1346 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1348 // Get the default duration to hide the indicator
1349 float duration = scrollBar.GetIndicatorHideDuration();
1351 // Check that the default duration is greater than 0
1352 DALI_TEST_CHECK( duration > 0.0f );
1354 // Hide the indicator
1355 scrollBar.HideIndicator();
1357 // Render and notify
1358 application.SendNotification();
1359 application.Render();
1361 // Check that the indicator is still invisible in the very next frame
1362 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1367 int UtcDaliToolkitScrollBarActionShowIndicator(void)
1369 ToolkitTestApplication application;
1371 // Create a scroll bar
1372 ScrollBar scrollBar = ScrollBar::New();
1373 DALI_TEST_CHECK( scrollBar );
1375 Stage::GetCurrent().Add( scrollBar );
1377 Actor indicator = scrollBar.GetScrollIndicator();
1378 DALI_TEST_CHECK( indicator );
1380 // Get the default duration to hide the indicator
1381 float duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_SHOW_DURATION );
1383 // Check that the default duration is greater than 0
1384 DALI_TEST_CHECK( duration > 0.0f );
1386 // Make the indicator invisible
1387 indicator.SetProperty( DevelActor::Property::OPACITY,0.0f);
1389 // Render and notify
1390 application.SendNotification();
1391 application.Render();
1393 // Check that the indicator is invisible
1394 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1396 // Do the "ShowIndicator" action
1397 Property::Map emptyMap;
1398 scrollBar.DoAction( "ShowIndicator", emptyMap );
1400 // Wait for the specified duration
1401 Wait(application, duration * 1000);
1403 // Render and notify
1404 application.SendNotification();
1405 application.Render();
1407 // Check that the indicator is now visible
1408 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1413 int UtcDaliToolkitScrollBarActionHideIndicator(void)
1415 ToolkitTestApplication application;
1417 // Create a scroll bar
1418 ScrollBar scrollBar = ScrollBar::New();
1419 DALI_TEST_CHECK( scrollBar );
1421 Stage::GetCurrent().Add( scrollBar );
1423 Actor indicator = scrollBar.GetScrollIndicator();
1424 DALI_TEST_CHECK( indicator );
1426 // Get the default duration to hide the indicator
1427 float duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_HIDE_DURATION );
1429 // Check that the default duration is greater than 0
1430 DALI_TEST_CHECK( duration > 0.0f );
1432 // Make the indicator visible
1433 indicator.SetProperty( DevelActor::Property::OPACITY,1.0f);
1435 // Render and notify
1436 application.SendNotification();
1437 application.Render();
1439 // Check that the indicator is visible
1440 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1442 // Do the "HideIndicator" action
1443 Property::Map emptyMap;
1444 scrollBar.DoAction( "HideIndicator", emptyMap );
1446 // Wait for the specified duration
1447 Wait(application, duration * 1000);
1449 // Render and notify
1450 application.SendNotification();
1451 application.Render();
1453 // Check that the indicator is now invisible
1454 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1459 int UtcDaliToolkitScrollBarActionShowTransientIndicator(void)
1461 ToolkitTestApplication application;
1463 // Create a scroll bar
1464 ScrollBar scrollBar = ScrollBar::New();
1465 DALI_TEST_CHECK( scrollBar );
1467 Stage::GetCurrent().Add( scrollBar );
1469 Actor indicator = scrollBar.GetScrollIndicator();
1470 DALI_TEST_CHECK( indicator );
1472 // Get the default duration to hide the indicator
1473 float duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_SHOW_DURATION );
1475 // Check that the default duration is greater than 0
1476 DALI_TEST_CHECK( duration > 0.0f );
1478 // Make the indicator invisible
1479 indicator.SetProperty( DevelActor::Property::OPACITY,0.0f);
1481 // Render and notify
1482 application.SendNotification();
1483 application.Render();
1485 // Check that the indicator is invisible
1486 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1488 // Do the "ShowIndicator" action
1489 Property::Map emptyMap;
1490 scrollBar.DoAction( "ShowTransientIndicator", emptyMap );
1492 // Wait for the specified duration
1493 Wait(application, duration * 1000);
1495 // Render and notify
1496 application.SendNotification();
1497 application.Render();
1499 // Check that the indicator is now visible
1500 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1502 // Get the default duration to hide the indicator
1503 float hideDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_HIDE_DURATION );
1504 float transientDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_TRANSIENT_DURATION );
1505 float totalVisibleDuration = hideDuration + transientDuration;
1507 // Check that the default duration is greater than 0
1508 DALI_TEST_CHECK( totalVisibleDuration > 0.0f );
1510 // Wait for the specified duration
1511 Wait(application, totalVisibleDuration * 1000);
1513 // Render and notify
1514 application.SendNotification();
1515 application.Render();
1517 // Check that the indicator is now invisible
1518 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1523 int UtcDaliToolkitScrollBarActionShowTransientIndicatorImmediate(void)
1525 ToolkitTestApplication application;
1527 // Create a scroll bar
1528 ScrollBar scrollBar = ScrollBar::New();
1529 DALI_TEST_CHECK( scrollBar );
1531 Stage::GetCurrent().Add( scrollBar );
1533 Actor indicator = scrollBar.GetScrollIndicator();
1534 DALI_TEST_CHECK( indicator );
1536 // Make the indicator invisible
1537 indicator.SetProperty( DevelActor::Property::OPACITY,0.0f);
1539 // Don't use a show animation; the indicator should appear immediately
1540 scrollBar.SetProperty( ScrollBar::Property::INDICATOR_SHOW_DURATION, 0.0f );
1541 float duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_SHOW_DURATION );
1542 DALI_TEST_EQUALS( duration, 0.0f, TEST_LOCATION );
1544 // Render and notify
1545 application.SendNotification();
1546 application.Render();
1548 // Do the "ShowIndicator" action
1549 Property::Map emptyMap;
1550 scrollBar.DoAction( "ShowTransientIndicator", emptyMap );
1552 // Wait for the specified duration
1555 // Render and notify
1556 application.SendNotification();
1557 application.Render();
1559 // Check that the indicator is now visible
1560 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1562 // Get the default duration to hide the indicator
1563 float hideDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_HIDE_DURATION );
1564 float transientDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_TRANSIENT_DURATION );
1565 float totalVisibleDuration = hideDuration + transientDuration;
1567 // Check that the default duration is greater than 0
1568 DALI_TEST_CHECK( totalVisibleDuration > 0.0f );
1570 // Wait for the specified duration
1571 Wait(application, totalVisibleDuration * 1000);
1573 // Render and notify
1574 application.SendNotification();
1575 application.Render();
1577 // Check that the indicator is now invisible
1578 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1583 int UtcDaliToolkitScrollBarActionShowTransientIndicatorDuringHide(void)
1585 ToolkitTestApplication application;
1587 // Create a scroll bar
1588 ScrollBar scrollBar = ScrollBar::New();
1589 DALI_TEST_CHECK( scrollBar );
1591 Stage::GetCurrent().Add( scrollBar );
1593 Actor indicator = scrollBar.GetScrollIndicator();
1594 DALI_TEST_CHECK( indicator );
1596 // Get the default duration to hide the indicator
1597 float duration = scrollBar.GetIndicatorHideDuration();
1599 // Check that the default duration is greater than 0
1600 DALI_TEST_CHECK( duration > 0.0f );
1602 // Make the indicator visible
1603 indicator.SetProperty( DevelActor::Property::OPACITY,1.0f);
1605 // Render and notify
1606 application.SendNotification();
1607 application.Render();
1609 // Check that the indicator is visible
1610 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1612 // Hide the indicator
1613 scrollBar.HideIndicator();
1615 // Wait for half the specified duration
1616 Wait(application, duration * 0.5f * 1000);
1618 // Render and notify
1619 application.SendNotification();
1620 application.Render();
1622 // Check that the indicator is now partially hidden
1623 DALI_TEST_CHECK( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ) < 1.0f );
1625 // Now interrupt the Hide with a DoAction( "ShowTransientIndicator" )
1627 // Get the default duration to hide the indicator
1628 duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_SHOW_DURATION );
1630 // Check that the default duration is greater than 0
1631 DALI_TEST_CHECK( duration > 0.0f );
1633 // Do the "ShowIndicator" action
1634 Property::Map emptyMap;
1635 scrollBar.DoAction( "ShowTransientIndicator", emptyMap );
1637 // Wait for the specified duration
1638 Wait(application, duration * 1000);
1640 // Render and notify
1641 application.SendNotification();
1642 application.Render();
1644 // Check that the indicator is now visible
1645 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1647 // Get the default duration to hide the indicator
1648 float hideDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_HIDE_DURATION );
1649 float transientDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_TRANSIENT_DURATION );
1650 float totalVisibleDuration = hideDuration + transientDuration;
1652 // Check that the default duration is greater than 0
1653 DALI_TEST_CHECK( totalVisibleDuration > 0.0f );
1655 // Wait for the specified duration
1656 Wait(application, totalVisibleDuration * 1000);
1658 // Render and notify
1659 application.SendNotification();
1660 application.Render();
1662 // Check that the indicator is now invisible
1663 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1668 int UtcDaliToolkitScrollBarPanFinishedSignalP(void)
1670 ToolkitTestApplication application;
1672 // Create a vertical scroll bar
1673 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1674 DALI_TEST_CHECK( scrollBar );
1676 scrollBar.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1677 scrollBar.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1678 scrollBar.SetProperty( Actor::Property::SIZE, Vector3(20.0f, 800.0f, 0.0f) );
1680 // Set the indicator height to be fixed to 50.0f
1681 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
1682 scrollBar.SetIndicatorFixedHeight(50.0f);
1684 Stage::GetCurrent().Add( scrollBar );
1686 // Connect the pan finished signal
1687 ConnectionTracker connectionTracker;
1688 bool panFinished = false;
1689 scrollBar.PanFinishedSignal().Connect( &OnPanFinished );
1690 scrollBar.ConnectSignal( &connectionTracker, "panFinished", CallbackFunctor(&panFinished));
1692 // Render and notify
1693 application.SendNotification();
1694 application.Render();
1696 // Create a source actor that owns the scroll properties required by the scroll bar
1697 Actor sourceActor = Actor::New();
1698 Stage::GetCurrent().Add( sourceActor );
1700 // Register the scroll properties
1701 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1702 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1703 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
1704 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
1706 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1707 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1708 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1709 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1711 // Set the source of the scroll position properties.
1712 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1714 // Render and notify
1715 application.SendNotification();
1716 application.Render();
1718 // Perform a swipe gesture on the indicator
1719 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 1, 500);
1720 DALI_TEST_EQUALS( gOnPanFinishedCalled, true, TEST_LOCATION );
1721 DALI_TEST_EQUALS( panFinished, true, TEST_LOCATION );
1726 int UtcDaliToolkitScrollBarPanFinishedSignalN(void)
1728 ToolkitTestApplication application;
1730 // Create a vertical scroll bar
1731 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1732 DALI_TEST_CHECK( scrollBar );
1734 scrollBar.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1735 scrollBar.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1736 scrollBar.SetProperty( Actor::Property::SIZE, Vector3(20.0f, 800.0f, 0.0f) );
1738 // Set the indicator height to be fixed to 50.0f
1739 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
1740 scrollBar.SetIndicatorFixedHeight(50.0f);
1742 Stage::GetCurrent().Add( scrollBar );
1744 // Connect the pan finished signal
1745 ConnectionTracker connectionTracker;
1746 bool panFinished = false;
1747 scrollBar.PanFinishedSignal().Connect( &OnPanFinished );
1748 scrollBar.ConnectSignal( &connectionTracker, "panFinished", CallbackFunctor(&panFinished));
1750 // Render and notify
1751 application.SendNotification();
1752 application.Render();
1754 // Perform a vertical swipe gesture on the indicator when there is no source object set on the scroll bar
1755 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20, 500);
1756 DALI_TEST_EQUALS( gOnPanFinishedCalled, false, TEST_LOCATION );
1758 // Create a source actor that owns the scroll properties required by the scroll bar
1759 Actor sourceActor = Actor::New();
1760 Stage::GetCurrent().Add( sourceActor );
1762 // Register the scroll properties
1763 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1764 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1765 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
1766 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
1768 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1769 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1770 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1771 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1773 // Set the source of the scroll position properties.
1774 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1776 // Render and notify
1777 application.SendNotification();
1778 application.Render();
1780 // Perform a swipe gesture on the scroll bar but not on the indicator
1781 PerformGestureSwipe(application, Vector2(1.0f, 780.0f), Vector2(Vector2::YAXIS * -1.0f), 20, 2000);
1782 DALI_TEST_EQUALS( gOnPanFinishedCalled, false, TEST_LOCATION );
1783 DALI_TEST_EQUALS( panFinished, false, TEST_LOCATION );
1785 // Perform a swipe gesture on the indicator
1786 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20, 4000);
1787 DALI_TEST_EQUALS( gOnPanFinishedCalled, true, TEST_LOCATION );
1788 DALI_TEST_EQUALS( panFinished, true, TEST_LOCATION );
1793 int UtcDaliToolkitScrollBarScrollPositionIntervalReachedSignalP(void)
1795 ToolkitTestApplication application;
1797 // Create a vertical scroll bar
1798 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1799 DALI_TEST_CHECK( scrollBar );
1801 scrollBar.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1802 scrollBar.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1803 scrollBar.SetProperty( Actor::Property::SIZE, Vector3(20.0f, 800.0f, 0.0f) );
1805 Stage::GetCurrent().Add( scrollBar );
1806 ConnectionTracker connectionTracker;
1808 // Connect to the ScrollPositionIntervalReached signal
1809 bool intervalReached = false;
1810 scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
1811 scrollBar.ConnectSignal( &connectionTracker, "scrollPositionIntervalReached", CallbackFunctor(&intervalReached));
1813 // Render and notify
1814 application.SendNotification();
1815 application.Render();
1817 // Create a source actor that owns the scroll properties required by the scroll bar
1818 Actor sourceActor = Actor::New();
1819 Stage::GetCurrent().Add( sourceActor );
1821 // Register the scroll properties
1822 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1823 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1824 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 800.0f );
1825 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 2000.0f );
1827 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1828 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1829 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1830 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1832 // Set the source of the scroll position properties.
1833 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1835 // Render and notify
1836 application.SendNotification();
1837 application.Render();
1839 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
1840 Dali::Vector<float> positionIntervals;
1841 for( size_t i = 0; i != 10; ++i )
1843 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
1845 scrollBar.SetScrollPositionIntervals(positionIntervals);
1847 // Render and notify
1848 application.SendNotification();
1849 application.Render();
1852 gOnScrollPositionIntervalReachedSignalCalled = false;
1854 // Animate the scroll position to cross the specified value
1855 Animation animation = Animation::New(0.1f);
1856 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
1859 // Wait for 0.1 second
1860 Wait(application, 100);
1862 // Check that the signal callback is called
1863 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1864 DALI_TEST_EQUALS( intervalReached, true, TEST_LOCATION );
1867 gOnScrollPositionIntervalReachedSignalCalled = false;
1868 intervalReached = false;
1870 // Rest and clear the animation
1874 // Animate the scroll position to cross another specified value
1875 animation = Animation::New(0.1f);
1876 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -170.0f );
1879 // Wait for 0.1 second
1880 Wait(application, 100);
1882 // Check that the signal callback is called
1883 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1884 DALI_TEST_EQUALS( intervalReached, true, TEST_LOCATION );
1887 gOnScrollPositionIntervalReachedSignalCalled = false;
1888 intervalReached = false;
1890 // Rest and clear the animation
1894 // Animate the scroll position back to the previous value
1895 animation = Animation::New(0.1f);
1896 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
1899 // Wait for 0.1 second
1900 Wait(application, 100);
1902 // Check that the signal callback is called
1903 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1904 DALI_TEST_EQUALS( intervalReached, true, TEST_LOCATION );
1909 int UtcDaliToolkitScrollBarScrollPositionIntervalReachedSignalN(void)
1911 ToolkitTestApplication application;
1913 // Create a vertical scroll bar
1914 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1915 DALI_TEST_CHECK( scrollBar );
1917 scrollBar.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1918 scrollBar.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1919 scrollBar.SetProperty( Actor::Property::SIZE, Vector3(20.0f, 800.0f, 0.0f) );
1921 Stage::GetCurrent().Add( scrollBar );
1923 // Connect to the ScrollPositionIntervalReached signal
1924 scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
1926 // Render and notify
1927 application.SendNotification();
1928 application.Render();
1930 // Create a source actor that owns the scroll properties required by the scroll bar
1931 Actor sourceActor = Actor::New();
1932 Stage::GetCurrent().Add( sourceActor );
1934 // Register the scroll properties
1935 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1936 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1937 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 800.0f );
1938 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 2000.0f );
1940 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1941 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1942 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1943 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1945 // Set the source of the scroll position properties.
1946 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1948 // Render and notify
1949 application.SendNotification();
1950 application.Render();
1952 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
1953 Dali::Vector<float> positionIntervals;
1954 for( size_t i = 0; i != 10; ++i )
1956 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
1958 scrollBar.SetScrollPositionIntervals(positionIntervals);
1960 // Render and notify
1961 application.SendNotification();
1962 application.Render();
1965 gOnScrollPositionIntervalReachedSignalCalled = false;
1967 // Animate the scroll position not to cross the specified value
1968 Animation animation = Animation::New(0.1f);
1969 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -70.0f );
1972 // Wait for 0.1 second
1973 Wait(application, 100);
1975 // Check that the signal callback is not called
1976 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, false, TEST_LOCATION );
1978 // Rest and clear the animation
1982 // Animate the scroll position to cross another specified value
1983 animation = Animation::New(0.1f);
1984 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
1987 // Wait for 0.1 second
1988 Wait(application, 100);
1990 // Check that the signal callback is called
1991 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );