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>
25 using namespace Toolkit;
27 void dali_scrollbar_startup(void)
29 test_return_value = TET_UNDEF;
32 void dali_scrollbar_cleanup(void)
34 test_return_value = TET_PASS;
40 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
43 * Simulate time passed by.
45 * @note this will always process at least 1 frame (1/60 sec)
47 * @param application Test application instance
48 * @param duration Time to pass in milliseconds.
49 * @return The actual time passed in milliseconds
51 int Wait(ToolkitTestApplication& application, int duration = 0)
55 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
57 application.SendNotification();
58 application.Render(RENDER_FRAME_INTERVAL);
59 time += RENDER_FRAME_INTERVAL;
67 static bool gOnPanFinishedCalled; ///< Whether the PanFinished signal was invoked.
68 static bool gOnScrollPositionIntervalReachedSignalCalled; ///< Whether the ScrollPositionIntervalReached signal was invoked.
71 * Invoked when pan gesture is finished on the scroll indicator.
73 static void OnPanFinished()
75 gOnPanFinishedCalled = true;
78 struct CallbackFunctor
80 CallbackFunctor(bool* callbackFlag)
81 : mCallbackFlag( callbackFlag )
87 *mCallbackFlag = true;
93 * Invoked when the current scroll position of the scrollable content goes above or below the values
94 * specified by SCROLL_POSITION_INTERVALS property.
96 * @param[in] position The current scroll position.
98 static void OnScrollPositionIntervalReached( float position )
100 gOnScrollPositionIntervalReachedSignalCalled = true;
103 static Vector2 PerformGestureSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, uint32_t start_time)
105 gOnPanFinishedCalled = false;
107 // Now do a pan starting from (start) and heading (direction)
108 Vector2 pos( start + ( direction * 15 ) );
109 uint32_t time = start_time;
111 TestStartPan( application, start, pos, time );
115 for(int i = 0; i < frames; i++)
117 pos += direction; // Move in this direction
118 time += RENDER_FRAME_INTERVAL;
119 TestMovePan( application, pos, time);
123 pos += direction; // Move in this direction.
124 time += RENDER_FRAME_INTERVAL;
125 TestEndPan(application, pos, time );
133 int UtcDaliToolkitScrollBarConstructorP(void)
135 ToolkitTestApplication application;
138 DALI_TEST_CHECK( !scrollBar );
142 int UtcDaliToolkitScrollBarCopyConstructorP(void)
144 ToolkitTestApplication application;
146 ScrollBar scrollBar = ScrollBar::New();
147 scrollBar.SetProperty( ScrollBar::Property::INDICATOR_FIXED_HEIGHT, 38.2f );
149 ScrollBar copy( scrollBar );
150 DALI_TEST_CHECK( copy );
151 DALI_TEST_CHECK( copy.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) == scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) );
155 int UtcDaliToolkitScrollBarAssignmentOperatorP(void)
157 ToolkitTestApplication application;
159 ScrollBar scrollBar = ScrollBar::New();
160 scrollBar.SetProperty( ScrollBar::Property::INDICATOR_FIXED_HEIGHT, 38.2f );
162 ScrollBar copy = scrollBar;
163 DALI_TEST_CHECK( copy );
164 DALI_TEST_CHECK( copy.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) == scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) );
168 int UtcDaliScrollBarDestructorP(void)
170 ToolkitTestApplication application;
172 ScrollBar* scrollBar = new ScrollBar();
175 DALI_TEST_CHECK( true );
179 int UtcDaliToolkitScrollBarNewP(void)
181 ToolkitTestApplication application;
183 ScrollBar scrollBar = ScrollBar::New();
184 DALI_TEST_CHECK( scrollBar );
187 ScrollBar vertical = ScrollBar::New(ScrollBar::Vertical);
188 DALI_TEST_CHECK( vertical );
189 DALI_TEST_CHECK( vertical.GetScrollDirection() == ScrollBar::Vertical );
191 Property::Value value = vertical.GetProperty(ScrollBar::Property::SCROLL_DIRECTION);
192 std::string scrollDirection = value.Get<std::string>();
193 DALI_TEST_EQUALS( scrollDirection, "Vertical", TEST_LOCATION );
195 ScrollBar horizontal = ScrollBar::New(ScrollBar::Horizontal);
196 DALI_TEST_CHECK( horizontal );
197 DALI_TEST_CHECK( horizontal.GetScrollDirection() == ScrollBar::Horizontal );
198 value = vertical.GetProperty(ScrollBar::Property::SCROLL_DIRECTION);
199 scrollDirection = value.Get<std::string>();
200 DALI_TEST_EQUALS( scrollDirection, "Horizontal", TEST_LOCATION );
205 int UtcDaliToolkitScrollBarCreateP(void)
207 ToolkitTestApplication application;
209 TypeRegistry typeRegistry = TypeRegistry::Get();
210 DALI_TEST_CHECK( typeRegistry );
212 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "ScrollBar" );
213 DALI_TEST_CHECK( typeInfo );
215 BaseHandle handle = typeInfo.CreateInstance();
216 DALI_TEST_CHECK( handle );
218 ScrollBar scrollBar = ScrollBar::DownCast( handle );
219 DALI_TEST_CHECK( scrollBar );
221 scrollBar.SetProperty(ScrollBar::Property::SCROLL_DIRECTION, "Vertical");
222 scrollBar.SetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY, "Fixed");
224 DALI_TEST_EQUALS( scrollBar.GetScrollDirection(), Toolkit::ScrollBar::Vertical, TEST_LOCATION );
225 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Fixed, TEST_LOCATION );
227 scrollBar.SetProperty(ScrollBar::Property::SCROLL_DIRECTION, "Horizontal");
228 scrollBar.SetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY, "Variable");
230 DALI_TEST_EQUALS( scrollBar.GetScrollDirection(), Toolkit::ScrollBar::Horizontal, TEST_LOCATION );
231 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Variable, TEST_LOCATION );
236 int UtcDaliToolkitScrollBarDownCastP(void)
238 ToolkitTestApplication application;
240 ScrollBar scrollBar1 = ScrollBar::New();
241 BaseHandle object( scrollBar1 );
243 ScrollBar scrollBar2 = ScrollBar::DownCast( object );
244 DALI_TEST_CHECK( scrollBar2 );
246 ScrollBar scrollBar3 = DownCast< ScrollBar >( object );
247 DALI_TEST_CHECK( scrollBar3 );
251 int UtcDaliToolkitScrollBarDownCastN(void)
253 ToolkitTestApplication application;
255 BaseHandle uninitializedObject;
256 ScrollBar scrollBar1 = ScrollBar::DownCast( uninitializedObject );
257 DALI_TEST_CHECK( !scrollBar1 );
259 ScrollBar scrollBar2 = DownCast< ScrollBar >( uninitializedObject );
260 DALI_TEST_CHECK( !scrollBar2 );
264 int UtcDaliToolkitScrollBarSetScrollPropertySourceP(void)
266 ToolkitTestApplication application;
268 // Create a vertical scroll bar
269 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
270 DALI_TEST_CHECK( scrollBar );
271 DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::Vertical );
273 float scrollBarHeight = 100.0f;
274 scrollBar.SetSize(20.0f, scrollBarHeight, 0.0f);
275 Stage::GetCurrent().Add( scrollBar );
277 // Create a source actor that owns the scroll properties required by the scroll bar
278 Actor sourceActor = Actor::New();
279 Stage::GetCurrent().Add( sourceActor );
281 // Register the scroll properties
282 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
283 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
284 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
285 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
287 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
288 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
289 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
290 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
292 // Set the source of the scroll position properties.
293 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
296 application.SendNotification();
297 application.Render();
299 Actor indicator = scrollBar.GetScrollIndicator();
300 DALI_TEST_CHECK( indicator );
302 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
303 // i.e. The bigger the content size, the smaller the indicator size
304 float indicatorHeight = indicator.GetCurrentSize().y;
305 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
307 // Decrease the content length
308 sourceActor.SetProperty( propertyScrollContentSize, 250.0f );
311 application.SendNotification();
312 application.Render();
314 // Check that the indicator size is changed accordingly
315 indicatorHeight = indicator.GetCurrentSize().y;
316 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 250.0f, TEST_LOCATION );
318 // As scroll position is 0, check that the indicator position should be 0.0f.
319 float indicatorPosition = indicator.GetCurrentPosition().y;
320 DALI_TEST_EQUALS( indicatorPosition, 0.0f, TEST_LOCATION );
322 // Set the scroll position to the middle
323 sourceActor.SetProperty( propertyScrollPosition, -50.0f );
326 application.SendNotification();
327 application.Render();
329 // Check that the indicator should be in the middle of the scroll bar
330 indicatorPosition = indicator.GetCurrentPosition().y;
331 DALI_TEST_EQUALS( indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.5f, TEST_LOCATION );
333 // Set the scroll position to the maximum
334 sourceActor.SetProperty( propertyScrollPosition, -100.0f );
337 application.SendNotification();
338 application.Render();
340 // Check that the indicator should be in the end of the scroll bar
341 indicatorPosition = indicator.GetCurrentPosition().y;
342 DALI_TEST_EQUALS( indicatorPosition, scrollBarHeight - indicatorHeight, TEST_LOCATION );
344 // Increase the maximum scroll position to double
345 sourceActor.SetProperty( propertyMaxScrollPosition, 200.0f );
348 application.SendNotification();
349 application.Render();
351 // Check that the indicator should be now in the middle of the scroll bar
352 indicatorPosition = indicator.GetCurrentPosition().y;
353 DALI_TEST_EQUALS( indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.5f, TEST_LOCATION );
355 // Create another source actor
356 Actor newSourceActor = Actor::New();
357 Stage::GetCurrent().Add( newSourceActor );
359 // Register the scroll properties
360 Property::Index newPropertyScrollPosition = newSourceActor.RegisterProperty( "sourcePosition", 0.0f );
361 Property::Index newPropertyMinScrollPosition = newSourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
362 Property::Index newPropertyMaxScrollPosition = newSourceActor.RegisterProperty( "sourcePositionMax", 200.0f );
363 Property::Index newPropertyScrollContentSize = newSourceActor.RegisterProperty( "sourceContentSize", 400.0f );
365 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourcePosition" ), newPropertyScrollPosition, TEST_LOCATION );
366 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourcePositionMin" ), newPropertyMinScrollPosition, TEST_LOCATION );
367 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourcePositionMax" ), newPropertyMaxScrollPosition, TEST_LOCATION );
368 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourceContentSize" ), newPropertyScrollContentSize, TEST_LOCATION );
370 // Change the source of the scroll position properties to be the new source actor.
371 scrollBar.SetScrollPropertySource(newSourceActor, newPropertyScrollPosition, newPropertyMinScrollPosition, newPropertyMaxScrollPosition, newPropertyScrollContentSize);
374 application.SendNotification();
375 application.Render();
377 // Check that the indicator size is changed accordingly
378 indicatorHeight = indicator.GetCurrentSize().y;
379 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 400.0f, TEST_LOCATION );
381 // Check that the indicator position goes back to the beginning of the scroll bar
382 indicatorPosition = indicator.GetCurrentPosition().y;
383 DALI_TEST_EQUALS( indicatorPosition, 0.0f, TEST_LOCATION );
385 // Set the scroll position to one fifth of the maximum
386 newSourceActor.SetProperty( propertyScrollPosition, -40.0f );
389 application.SendNotification();
390 application.Render();
392 // Check that the indicator should be in one fifth from the beginning of the scroll bar
393 indicatorPosition = indicator.GetCurrentPosition().y;
394 DALI_TEST_EQUALS( indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.2f, TEST_LOCATION );
399 int UtcDaliToolkitScrollBarSetScrollPropertySourceN(void)
401 ToolkitTestApplication application;
403 // Create a scroll bar
404 ScrollBar scrollBar = ScrollBar::New();
405 DALI_TEST_CHECK( scrollBar );
407 // Set empty handle of source object and invalid source property index.
409 scrollBar.SetScrollPropertySource(sourceActor, Property::INVALID_INDEX, Property::INVALID_INDEX, Property::INVALID_INDEX, Property::INVALID_INDEX);
411 DALI_TEST_CHECK( true );
415 int UtcDaliToolkitScrollBarSetScrollIndicatorP(void)
417 ToolkitTestApplication application;
419 // Create a scroll bar
420 ScrollBar scrollBar = ScrollBar::New();
421 DALI_TEST_CHECK( scrollBar );
423 Actor indicator = scrollBar.GetScrollIndicator();
424 DALI_TEST_CHECK( indicator );
426 // Set a new indicator
427 Actor newIndicator = Actor::New();
428 scrollBar.SetScrollIndicator(newIndicator);
430 // Check that the new indicator is successfully set
431 DALI_TEST_CHECK( indicator != scrollBar.GetScrollIndicator() );
432 DALI_TEST_CHECK( newIndicator == scrollBar.GetScrollIndicator() );
434 // Check that the new control indicator is successfully set
435 Control controlIndicator = Control::New();
436 scrollBar.SetScrollIndicator(controlIndicator);
438 DALI_TEST_CHECK( controlIndicator == Control::DownCast( scrollBar.GetScrollIndicator() ) );
442 int UtcDaliToolkitScrollBarSetScrollIndicatorN(void)
444 ToolkitTestApplication application;
446 // Create a scroll bar
447 ScrollBar scrollBar = ScrollBar::New();
448 DALI_TEST_CHECK( scrollBar );
450 Actor indicator = scrollBar.GetScrollIndicator();
451 DALI_TEST_CHECK( indicator );
453 // Try to set an uninitialized actor as the indicator
454 Actor uninitializedIndicator;
455 scrollBar.SetScrollIndicator(uninitializedIndicator);
457 // Check that the uninitialized actor can not be set as the indicator
458 DALI_TEST_CHECK( indicator == scrollBar.GetScrollIndicator() );
459 DALI_TEST_CHECK( uninitializedIndicator != scrollBar.GetScrollIndicator() );
464 int UtcDaliToolkitScrollBarGetScrollIndicatorP(void)
466 ToolkitTestApplication application;
468 // Create a scroll bar
469 ScrollBar scrollBar = ScrollBar::New();
470 DALI_TEST_CHECK( scrollBar );
472 Actor indicator = scrollBar.GetScrollIndicator();
473 DALI_TEST_CHECK( indicator );
475 // Set a new indicator
476 Actor newIndicator = Actor::New();
477 scrollBar.SetScrollIndicator(newIndicator);
479 // Check that the new indicator is successfully set
480 DALI_TEST_CHECK( scrollBar.GetScrollIndicator() );
481 DALI_TEST_CHECK( indicator != scrollBar.GetScrollIndicator() );
482 DALI_TEST_CHECK( newIndicator == scrollBar.GetScrollIndicator() );
487 int UtcDaliToolkitScrollBarGetScrollIndicatorN(void)
489 ToolkitTestApplication application;
491 // Create a scroll bar
492 ScrollBar scrollBar = ScrollBar::New();
493 DALI_TEST_CHECK( scrollBar );
495 Actor indicator = scrollBar.GetScrollIndicator();
496 DALI_TEST_CHECK( indicator );
498 // Try to set an uninitialized actor as the indicator
499 Actor uninitializedIndicator;
500 scrollBar.SetScrollIndicator(uninitializedIndicator);
502 // Check that the indicator has not been changed
503 DALI_TEST_CHECK( indicator == scrollBar.GetScrollIndicator() );
504 DALI_TEST_CHECK( uninitializedIndicator != scrollBar.GetScrollIndicator() );
509 int UtcDaliToolkitScrollBarSetScrollPositionIntervalsP(void)
511 ToolkitTestApplication application;
513 // Create a vertical scroll bar
514 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
515 DALI_TEST_CHECK( scrollBar );
517 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
518 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
519 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
521 Stage::GetCurrent().Add( scrollBar );
523 // Connect to the ScrollPositionIntervalReached signal
524 scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
527 application.SendNotification();
528 application.Render();
530 // Create a source actor that owns the scroll properties required by the scroll bar
531 Actor sourceActor = Actor::New();
532 Stage::GetCurrent().Add( sourceActor );
534 // Register the scroll properties
535 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
536 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
537 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 800.0f );
538 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 2000.0f );
540 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
541 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
542 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
543 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
545 // Set the source of the scroll position properties.
546 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
549 application.SendNotification();
550 application.Render();
552 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
553 Dali::Vector<float> positionIntervals;
554 for( size_t i = 0; i != 10; ++i )
556 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
558 scrollBar.SetScrollPositionIntervals(positionIntervals);
560 // Get the list of scroll position intervals for notification
561 Dali::Vector<float> results = scrollBar.GetScrollPositionIntervals();
563 // Check that the result is the same as the list previously set.
564 DALI_TEST_EQUALS( positionIntervals.Count(), results.Count(), TEST_LOCATION );
565 DALI_TEST_EQUALS( positionIntervals[0], results[0], TEST_LOCATION );
566 DALI_TEST_EQUALS( positionIntervals[1], results[1], TEST_LOCATION );
567 DALI_TEST_EQUALS( positionIntervals[2], results[2], TEST_LOCATION );
568 DALI_TEST_EQUALS( positionIntervals[3], results[3], TEST_LOCATION );
569 DALI_TEST_EQUALS( positionIntervals[4], results[4], TEST_LOCATION );
570 DALI_TEST_EQUALS( positionIntervals[5], results[5], TEST_LOCATION );
571 DALI_TEST_EQUALS( positionIntervals[6], results[6], TEST_LOCATION );
572 DALI_TEST_EQUALS( positionIntervals[7], results[7], TEST_LOCATION );
573 DALI_TEST_EQUALS( positionIntervals[8], results[8], TEST_LOCATION );
574 DALI_TEST_EQUALS( positionIntervals[9], results[9], TEST_LOCATION );
577 gOnScrollPositionIntervalReachedSignalCalled = false;
579 // Animate the scroll position to cross the specified value
580 Animation animation = Animation::New(0.1f);
581 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
584 // Wait for 0.1 second
585 Wait(application, 100);
587 // Check that the signal callback is called
588 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
591 gOnScrollPositionIntervalReachedSignalCalled = false;
593 // Rest and clear the animation
597 // Animate the scroll position to cross another specified value
598 animation = Animation::New(0.1f);
599 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -170.0f );
602 // Wait for 0.1 second
603 Wait(application, 100);
605 // Check that the signal callback is called
606 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
609 gOnScrollPositionIntervalReachedSignalCalled = false;
611 // Rest and clear the animation
615 // Animate the scroll position back to the previous value
616 animation = Animation::New(0.1f);
617 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
620 // Wait for 0.1 second
621 Wait(application, 100);
623 // Check that the signal callback is called
624 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
629 int UtcDaliToolkitScrollBarGetScrollPositionIntervalsP(void)
631 ToolkitTestApplication application;
633 // Create a vertical scroll bar
634 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
635 DALI_TEST_CHECK( scrollBar );
637 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
638 Dali::Vector<float> positionIntervals;
639 for( size_t i = 0; i != 10; ++i )
641 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
643 scrollBar.SetScrollPositionIntervals(positionIntervals);
645 // Get the list of scroll position intervals for notification
646 Dali::Vector<float> results = scrollBar.GetScrollPositionIntervals();
648 // Check that the result is the same as the list previously set.
649 DALI_TEST_EQUALS( positionIntervals.Count(), results.Count(), TEST_LOCATION );
650 DALI_TEST_EQUALS( positionIntervals[0], results[0], TEST_LOCATION );
651 DALI_TEST_EQUALS( positionIntervals[1], results[1], TEST_LOCATION );
652 DALI_TEST_EQUALS( positionIntervals[2], results[2], TEST_LOCATION );
653 DALI_TEST_EQUALS( positionIntervals[3], results[3], TEST_LOCATION );
654 DALI_TEST_EQUALS( positionIntervals[4], results[4], TEST_LOCATION );
655 DALI_TEST_EQUALS( positionIntervals[5], results[5], TEST_LOCATION );
656 DALI_TEST_EQUALS( positionIntervals[6], results[6], TEST_LOCATION );
657 DALI_TEST_EQUALS( positionIntervals[7], results[7], TEST_LOCATION );
658 DALI_TEST_EQUALS( positionIntervals[8], results[8], TEST_LOCATION );
659 DALI_TEST_EQUALS( positionIntervals[9], results[9], TEST_LOCATION );
661 Property::Array resultArray = scrollBar.GetProperty<Property::Array>(Toolkit::ScrollBar::Property::SCROLL_POSITION_INTERVALS);
663 DALI_TEST_EQUALS( positionIntervals.Count(), resultArray.Count(), TEST_LOCATION );
664 DALI_TEST_EQUALS( positionIntervals[0], resultArray[0].Get<float>(), TEST_LOCATION );
665 DALI_TEST_EQUALS( positionIntervals[1], resultArray[1].Get<float>(), TEST_LOCATION );
666 DALI_TEST_EQUALS( positionIntervals[2], resultArray[2].Get<float>(), TEST_LOCATION );
667 DALI_TEST_EQUALS( positionIntervals[3], resultArray[3].Get<float>(), TEST_LOCATION );
668 DALI_TEST_EQUALS( positionIntervals[4], resultArray[4].Get<float>(), TEST_LOCATION );
669 DALI_TEST_EQUALS( positionIntervals[5], resultArray[5].Get<float>(), TEST_LOCATION );
670 DALI_TEST_EQUALS( positionIntervals[6], resultArray[6].Get<float>(), TEST_LOCATION );
671 DALI_TEST_EQUALS( positionIntervals[7], resultArray[7].Get<float>(), TEST_LOCATION );
672 DALI_TEST_EQUALS( positionIntervals[8], resultArray[8].Get<float>(), TEST_LOCATION );
673 DALI_TEST_EQUALS( positionIntervals[9], resultArray[9].Get<float>(), TEST_LOCATION );
678 int UtcDaliToolkitScrollBarGetScrollDirectionP(void)
680 ToolkitTestApplication application;
682 // Create a vertical scroll bar
683 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
684 DALI_TEST_CHECK( scrollBar );
685 DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::Vertical );
687 // Change the direction of scroll bar to horizontal
688 scrollBar.SetScrollDirection(ScrollBar::Horizontal);
689 DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::Horizontal );
694 int UtcDaliToolkitScrollBarSetIndicatorHeightPolicyP(void)
696 ToolkitTestApplication application;
698 // Create a scroll bar
699 ScrollBar scrollBar = ScrollBar::New();
700 DALI_TEST_CHECK( scrollBar );
702 float scrollBarHeight = 100.0f;
703 scrollBar.SetSize(20.0f, scrollBarHeight, 0.0f);
704 Stage::GetCurrent().Add( scrollBar );
706 // Create a source actor that owns the scroll properties required by the scroll bar
707 Actor sourceActor = Actor::New();
708 Stage::GetCurrent().Add( sourceActor );
710 // Register the scroll properties
711 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
712 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
713 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
714 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
716 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
717 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
718 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
719 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
721 // Set the source of the scroll position properties.
722 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
725 application.SendNotification();
726 application.Render();
728 Actor indicator = scrollBar.GetScrollIndicator();
729 DALI_TEST_CHECK( indicator );
731 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
732 // i.e. The bigger the content size, the smaller the indicator size
733 float indicatorHeight = indicator.GetCurrentSize().y;
734 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
736 // Set the indicator height to be fixed to 50.0f
737 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
738 scrollBar.SetIndicatorFixedHeight(50.0f);
740 Property::Value value = scrollBar.GetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY);
741 DALI_TEST_EQUALS(value.Get<std::string>(), "Fixed", TEST_LOCATION );
744 application.SendNotification();
745 application.Render();
747 // Check that the indicator size should be 50.0f
748 indicatorHeight = indicator.GetCurrentSize().y;
749 DALI_TEST_EQUALS( indicatorHeight, 50.0f, TEST_LOCATION );
751 // Set the indicator height to be variable
752 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Variable);
753 value = scrollBar.GetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY);
754 DALI_TEST_EQUALS(value.Get<std::string>(), "Variable", TEST_LOCATION );
757 application.SendNotification();
758 application.Render();
760 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
761 indicatorHeight = indicator.GetCurrentSize().y;
762 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
767 int UtcDaliToolkitScrollBarGetIndicatorHeightPolicyP(void)
769 ToolkitTestApplication application;
771 // Create a scroll bar
772 ScrollBar scrollBar = ScrollBar::New();
773 DALI_TEST_CHECK( scrollBar );
775 // Set the indicator height to be fixed
776 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
777 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Fixed, TEST_LOCATION );
779 // Set the indicator height to be variable
780 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Variable);
781 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Variable, TEST_LOCATION );
786 int UtcDaliToolkitScrollBarSetIndicatorFixedHeightP(void)
788 ToolkitTestApplication application;
790 // Create a scroll bar
791 ScrollBar scrollBar = ScrollBar::New();
792 DALI_TEST_CHECK( scrollBar );
794 float scrollBarHeight = 100.0f;
795 scrollBar.SetSize(20.0f, scrollBarHeight, 0.0f);
796 Stage::GetCurrent().Add( scrollBar );
798 Actor indicator = scrollBar.GetScrollIndicator();
799 DALI_TEST_CHECK( indicator );
801 // Set the indicator height to be fixed to 50.0f
802 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
803 scrollBar.SetIndicatorFixedHeight(50.0f);
806 application.SendNotification();
807 application.Render();
809 // Check that the indicator size should be 50.0f
810 DALI_TEST_EQUALS( indicator.GetCurrentSize().y, 50.0f, TEST_LOCATION );
812 // Set the indicator height to be fixed to 25.0f
813 scrollBar.SetIndicatorFixedHeight(25.0f);
816 application.SendNotification();
817 application.Render();
819 // Check that the indicator size should be 25.0f
820 DALI_TEST_EQUALS( indicator.GetCurrentSize().y, 25.0f, TEST_LOCATION );
825 int UtcDaliToolkitScrollBarGetIndicatorFixedHeightP(void)
827 ToolkitTestApplication application;
829 // Create a scroll bar
830 ScrollBar scrollBar = ScrollBar::New();
831 DALI_TEST_CHECK( scrollBar );
833 // Set the fixed indicator height to be 50.0f
834 scrollBar.SetIndicatorFixedHeight(50.0f);
836 // Check that the indicator size should be 50.0f
837 DALI_TEST_EQUALS( scrollBar.GetIndicatorFixedHeight(), 50.0f, TEST_LOCATION );
839 // Set the indicator height to be fixed to 25.0f
840 scrollBar.SetIndicatorFixedHeight(25.0f);
842 // Check that the indicator size should be 50.0f
843 DALI_TEST_EQUALS( scrollBar.GetIndicatorFixedHeight(), 25.0f, TEST_LOCATION );
848 int UtcDaliToolkitScrollBarSetIndicatorShowDurationP(void)
850 ToolkitTestApplication application;
852 // Create a scroll bar
853 ScrollBar scrollBar = ScrollBar::New();
854 DALI_TEST_CHECK( scrollBar );
856 Stage::GetCurrent().Add( scrollBar );
858 Actor indicator = scrollBar.GetScrollIndicator();
859 DALI_TEST_CHECK( indicator );
861 // Set the duration to show the indicator to be 0.35 second
862 scrollBar.SetIndicatorShowDuration(0.35);
863 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.35f, TEST_LOCATION );
865 // Make the indicator invisible
866 indicator.SetOpacity(0.0f);
869 application.SendNotification();
870 application.Render();
872 // Check that the indicator is invisible
873 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
875 // Show the indicator
876 scrollBar.ShowIndicator();
878 // Wait for 0.35 second
879 Wait(application, 350);
882 application.SendNotification();
883 application.Render();
885 // Check that the indicator is now visible
886 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
888 // Set the duration to show the indicator to be 0.75 second
889 scrollBar.SetIndicatorShowDuration(0.75);
890 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.75f, TEST_LOCATION );
892 // Make the indicator invisible
893 indicator.SetOpacity(0.0f);
896 application.SendNotification();
897 application.Render();
899 // Check that the indicator is invisible
900 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
902 // Show the indicator
903 scrollBar.ShowIndicator();
905 // Wait for 0.35 second first
906 Wait(application, 350);
909 application.SendNotification();
910 application.Render();
912 // Check that the indicator is not fully visible yet
913 DALI_TEST_CHECK( indicator.GetCurrentOpacity() != 1.0f );
915 // Wait for another 0.4 second
916 Wait(application, 400);
919 application.SendNotification();
920 application.Render();
922 // Check that the indicator is now fully visible
923 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
928 int UtcDaliToolkitScrollBarSetIndicatorShowDurationN(void)
930 ToolkitTestApplication application;
932 // Create a scroll bar
933 ScrollBar scrollBar = ScrollBar::New();
934 DALI_TEST_CHECK( scrollBar );
936 Stage::GetCurrent().Add( scrollBar );
938 Actor indicator = scrollBar.GetScrollIndicator();
939 DALI_TEST_CHECK( indicator );
941 // Get the default duration to show the indicator
942 float duration = scrollBar.GetIndicatorShowDuration();
944 // Check that the default duration is greater than 0
945 DALI_TEST_CHECK( duration > 0.0f );
947 // Make the indicator invisible
948 indicator.SetOpacity(0.0f);
951 application.SendNotification();
952 application.Render();
954 // Check that the indicator is invisible
955 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
957 // Show the indicator
958 scrollBar.ShowIndicator();
960 // Wait for the specified duration
961 Wait(application, duration * 1000);
964 application.SendNotification();
965 application.Render();
967 // Check that the indicator is now visible
968 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
970 // Now set the duration to show the indicator to be a negative value (which should be ignored and therefore means instant)
971 scrollBar.SetIndicatorShowDuration(-0.25f);
972 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), -0.25f, TEST_LOCATION );
974 // Make the indicator invisible
975 indicator.SetOpacity(0.0f);
978 application.SendNotification();
979 application.Render();
981 // Check that the indicator is invisible
982 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
984 // Show the indicator
985 scrollBar.ShowIndicator();
988 application.SendNotification();
989 application.Render();
991 // Check that the indicator becomes instantly visible in the next frame
992 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
997 int UtcDaliToolkitScrollBarGetIndicatorShowDurationP(void)
999 ToolkitTestApplication application;
1001 // Create a scroll bar
1002 ScrollBar scrollBar = ScrollBar::New();
1003 DALI_TEST_CHECK( scrollBar );
1005 // Set the duration to show the indicator to be 0.35 second
1006 scrollBar.SetIndicatorShowDuration(0.35f);
1008 // Check that the duration to show the indicator is 0.35 second
1009 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.35f, TEST_LOCATION );
1011 // Set the duration to show the indicator to be 0.75 second
1012 scrollBar.SetIndicatorShowDuration(0.75f);
1014 // Check that the duration to show the indicator is 0.75 second
1015 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.75f, TEST_LOCATION );
1020 int UtcDaliToolkitScrollBarSetIndicatorHideDurationP(void)
1022 ToolkitTestApplication application;
1024 // Create a scroll bar
1025 ScrollBar scrollBar = ScrollBar::New();
1026 DALI_TEST_CHECK( scrollBar );
1028 Stage::GetCurrent().Add( scrollBar );
1030 Actor indicator = scrollBar.GetScrollIndicator();
1031 DALI_TEST_CHECK( indicator );
1033 // Set the duration to hide the indicator to be 0.15 second
1034 scrollBar.SetIndicatorHideDuration(0.15f);
1035 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.15f, TEST_LOCATION );
1037 // Make the indicator visible
1038 indicator.SetOpacity(1.0f);
1040 // Render and notify
1041 application.SendNotification();
1042 application.Render();
1044 // Check that the indicator is visible
1045 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1047 // Hide the indicator
1048 scrollBar.HideIndicator();
1050 // Wait for 0.15 second
1051 Wait(application, 150);
1053 // Render and notify
1054 application.SendNotification();
1055 application.Render();
1057 // Check that the indicator is now invisible
1058 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1060 // Set the duration to hide the indicator to be 0.65 second
1061 scrollBar.SetIndicatorHideDuration(0.65f);
1062 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.65f, TEST_LOCATION );
1064 // Make the indicator visible
1065 indicator.SetOpacity(1.0f);
1067 // Render and notify
1068 application.SendNotification();
1069 application.Render();
1071 // Check that the indicator is visible
1072 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1074 // Hide the indicator
1075 scrollBar.HideIndicator();
1077 // Wait for 0.15 second first
1078 Wait(application, 150);
1080 // Render and notify
1081 application.SendNotification();
1082 application.Render();
1084 // Check that the indicator is not fully invisible yet
1085 DALI_TEST_CHECK( indicator.GetCurrentOpacity() != 0.0f );
1087 // Wait for another 0.5 second
1088 Wait(application, 500);
1090 // Render and notify
1091 application.SendNotification();
1092 application.Render();
1094 // Check that the indicator is now fully invisible
1095 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1100 int UtcDaliToolkitScrollBarSetIndicatorHideDurationN(void)
1102 ToolkitTestApplication application;
1104 // Create a scroll bar
1105 ScrollBar scrollBar = ScrollBar::New();
1106 DALI_TEST_CHECK( scrollBar );
1108 Stage::GetCurrent().Add( scrollBar );
1110 Actor indicator = scrollBar.GetScrollIndicator();
1111 DALI_TEST_CHECK( indicator );
1113 // Get the default duration to hide the indicator
1114 float duration = scrollBar.GetIndicatorHideDuration();
1116 // Check that the default duration is greater than 0
1117 DALI_TEST_CHECK( duration > 0.0f );
1119 // Make the indicator visible
1120 indicator.SetOpacity(1.0f);
1122 // Render and notify
1123 application.SendNotification();
1124 application.Render();
1126 // Check that the indicator is visible
1127 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1129 // Hide the indicator
1130 scrollBar.HideIndicator();
1132 // Wait for the specified duration
1133 Wait(application, duration * 1000);
1135 // Render and notify
1136 application.SendNotification();
1137 application.Render();
1139 // Check that the indicator is now invisible
1140 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1142 // Now set the duration to hide the indicator to be a negative value (which should be ignored and therefore means instant)
1143 scrollBar.SetIndicatorHideDuration(-0.25f);
1144 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), -0.25f, TEST_LOCATION );
1146 // Make the indicator visible
1147 indicator.SetOpacity(1.0f);
1149 // Render and notify
1150 application.SendNotification();
1151 application.Render();
1153 // Check that the indicator is visible
1154 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1156 // Hide the indicator
1157 scrollBar.HideIndicator();
1159 // Render and notify
1160 application.SendNotification();
1161 application.Render();
1163 // Check that the indicator becomes instantly invisible in the next frame
1164 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1169 int UtcDaliToolkitScrollBarGetIndicatorHideDurationP(void)
1171 ToolkitTestApplication application;
1173 // Create a scroll bar
1174 ScrollBar scrollBar = ScrollBar::New();
1175 DALI_TEST_CHECK( scrollBar );
1177 // Set the duration to hide the indicator to be 0.15 second
1178 scrollBar.SetIndicatorHideDuration(0.15f);
1180 // Check that the duration to hide the indicator is 0.15 second
1181 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.15f, TEST_LOCATION );
1183 // Set the duration to hide the indicator to be 0.65 second
1184 scrollBar.SetIndicatorHideDuration(0.65f);
1186 // Check that the duration to hide the indicator is 0.65 second
1187 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.65f, TEST_LOCATION );
1192 int UtcDaliToolkitScrollBarShowIndicatorP(void)
1194 ToolkitTestApplication application;
1196 // Create a scroll bar
1197 ScrollBar scrollBar = ScrollBar::New();
1198 DALI_TEST_CHECK( scrollBar );
1200 Stage::GetCurrent().Add( scrollBar );
1202 Actor indicator = scrollBar.GetScrollIndicator();
1203 DALI_TEST_CHECK( indicator );
1205 // Get the default duration to show the indicator
1206 float duration = scrollBar.GetIndicatorShowDuration();
1208 // Check that the default duration is greater than 0
1209 DALI_TEST_CHECK( duration > 0.0f );
1211 // Make the indicator invisible
1212 indicator.SetOpacity(0.0f);
1214 // Render and notify
1215 application.SendNotification();
1216 application.Render();
1218 // Check that the indicator is invisible
1219 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1221 // Show the indicator
1222 scrollBar.ShowIndicator();
1224 // Wait for the specified duration
1225 Wait(application, duration * 1000);
1227 // Render and notify
1228 application.SendNotification();
1229 application.Render();
1231 // Check that the indicator is now visible
1232 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1237 int UtcDaliToolkitScrollBarShowIndicatorN(void)
1239 ToolkitTestApplication application;
1241 // Create a scroll bar
1242 ScrollBar scrollBar = ScrollBar::New();
1243 DALI_TEST_CHECK( scrollBar );
1245 Stage::GetCurrent().Add( scrollBar );
1247 Actor indicator = scrollBar.GetScrollIndicator();
1248 DALI_TEST_CHECK( indicator );
1250 // Make the indicator initially visible
1251 indicator.SetOpacity(1.0f);
1253 // Render and notify
1254 application.SendNotification();
1255 application.Render();
1257 // Check that the indicator is initially visible
1258 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1260 // Get the default duration to show the indicator
1261 float duration = scrollBar.GetIndicatorShowDuration();
1263 // Check that the default duration is greater than 0
1264 DALI_TEST_CHECK( duration > 0.0f );
1266 // Show the indicator
1267 scrollBar.ShowIndicator();
1269 // Render and notify
1270 application.SendNotification();
1271 application.Render();
1273 // Check that the indicator is still visible in the very next frame
1274 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1279 int UtcDaliToolkitScrollBarHideIndicatorP(void)
1281 ToolkitTestApplication application;
1283 // Create a scroll bar
1284 ScrollBar scrollBar = ScrollBar::New();
1285 DALI_TEST_CHECK( scrollBar );
1287 Stage::GetCurrent().Add( scrollBar );
1289 Actor indicator = scrollBar.GetScrollIndicator();
1290 DALI_TEST_CHECK( indicator );
1292 // Get the default duration to hide the indicator
1293 float duration = scrollBar.GetIndicatorHideDuration();
1295 // Check that the default duration is greater than 0
1296 DALI_TEST_CHECK( duration > 0.0f );
1298 // Make the indicator visible
1299 indicator.SetOpacity(1.0f);
1301 // Render and notify
1302 application.SendNotification();
1303 application.Render();
1305 // Check that the indicator is visible
1306 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1308 // Hide the indicator
1309 scrollBar.HideIndicator();
1311 // Wait for the specified duration
1312 Wait(application, duration * 1000);
1314 // Render and notify
1315 application.SendNotification();
1316 application.Render();
1318 // Check that the indicator is now invisible
1319 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1324 int UtcDaliToolkitScrollBarHideIndicatorN(void)
1326 ToolkitTestApplication application;
1328 // Create a scroll bar
1329 ScrollBar scrollBar = ScrollBar::New();
1330 DALI_TEST_CHECK( scrollBar );
1332 Stage::GetCurrent().Add( scrollBar );
1334 Actor indicator = scrollBar.GetScrollIndicator();
1335 DALI_TEST_CHECK( indicator );
1337 // Make the indicator initially invisible
1338 indicator.SetOpacity(0.0f);
1340 // Render and notify
1341 application.SendNotification();
1342 application.Render();
1344 // Check that the indicator is initially invisible
1345 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1347 // Get the default duration to hide the indicator
1348 float duration = scrollBar.GetIndicatorHideDuration();
1350 // Check that the default duration is greater than 0
1351 DALI_TEST_CHECK( duration > 0.0f );
1353 // Hide the indicator
1354 scrollBar.HideIndicator();
1356 // Render and notify
1357 application.SendNotification();
1358 application.Render();
1360 // Check that the indicator is still invisible in the very next frame
1361 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1366 int UtcDaliToolkitScrollBarActionShowIndicator(void)
1368 ToolkitTestApplication application;
1370 // Create a scroll bar
1371 ScrollBar scrollBar = ScrollBar::New();
1372 DALI_TEST_CHECK( scrollBar );
1374 Stage::GetCurrent().Add( scrollBar );
1376 Actor indicator = scrollBar.GetScrollIndicator();
1377 DALI_TEST_CHECK( indicator );
1379 // Get the default duration to hide the indicator
1380 float duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_SHOW_DURATION );
1382 // Check that the default duration is greater than 0
1383 DALI_TEST_CHECK( duration > 0.0f );
1385 // Make the indicator invisible
1386 indicator.SetOpacity(0.0f);
1388 // Render and notify
1389 application.SendNotification();
1390 application.Render();
1392 // Check that the indicator is invisible
1393 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1395 // Do the "ShowIndicator" action
1396 Property::Map emptyMap;
1397 scrollBar.DoAction( "ShowIndicator", emptyMap );
1399 // Wait for the specified duration
1400 Wait(application, duration * 1000);
1402 // Render and notify
1403 application.SendNotification();
1404 application.Render();
1406 // Check that the indicator is now visible
1407 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1412 int UtcDaliToolkitScrollBarActionHideIndicator(void)
1414 ToolkitTestApplication application;
1416 // Create a scroll bar
1417 ScrollBar scrollBar = ScrollBar::New();
1418 DALI_TEST_CHECK( scrollBar );
1420 Stage::GetCurrent().Add( scrollBar );
1422 Actor indicator = scrollBar.GetScrollIndicator();
1423 DALI_TEST_CHECK( indicator );
1425 // Get the default duration to hide the indicator
1426 float duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_HIDE_DURATION );
1428 // Check that the default duration is greater than 0
1429 DALI_TEST_CHECK( duration > 0.0f );
1431 // Make the indicator visible
1432 indicator.SetOpacity(1.0f);
1434 // Render and notify
1435 application.SendNotification();
1436 application.Render();
1438 // Check that the indicator is visible
1439 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1441 // Do the "HideIndicator" action
1442 Property::Map emptyMap;
1443 scrollBar.DoAction( "HideIndicator", emptyMap );
1445 // Wait for the specified duration
1446 Wait(application, duration * 1000);
1448 // Render and notify
1449 application.SendNotification();
1450 application.Render();
1452 // Check that the indicator is now invisible
1453 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1458 int UtcDaliToolkitScrollBarActionShowTransientIndicator(void)
1460 ToolkitTestApplication application;
1462 // Create a scroll bar
1463 ScrollBar scrollBar = ScrollBar::New();
1464 DALI_TEST_CHECK( scrollBar );
1466 Stage::GetCurrent().Add( scrollBar );
1468 Actor indicator = scrollBar.GetScrollIndicator();
1469 DALI_TEST_CHECK( indicator );
1471 // Get the default duration to hide the indicator
1472 float duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_SHOW_DURATION );
1474 // Check that the default duration is greater than 0
1475 DALI_TEST_CHECK( duration > 0.0f );
1477 // Make the indicator invisible
1478 indicator.SetOpacity(0.0f);
1480 // Render and notify
1481 application.SendNotification();
1482 application.Render();
1484 // Check that the indicator is invisible
1485 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1487 // Do the "ShowIndicator" action
1488 Property::Map emptyMap;
1489 scrollBar.DoAction( "ShowTransientIndicator", emptyMap );
1491 // Wait for the specified duration
1492 Wait(application, duration * 1000);
1494 // Render and notify
1495 application.SendNotification();
1496 application.Render();
1498 // Check that the indicator is now visible
1499 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1501 // Get the default duration to hide the indicator
1502 float hideDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_HIDE_DURATION );
1503 float transientDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_TRANSIENT_DURATION );
1504 float totalVisibleDuration = hideDuration + transientDuration;
1506 // Check that the default duration is greater than 0
1507 DALI_TEST_CHECK( totalVisibleDuration > 0.0f );
1509 // Wait for the specified duration
1510 Wait(application, totalVisibleDuration * 1000);
1512 // Render and notify
1513 application.SendNotification();
1514 application.Render();
1516 // Check that the indicator is now invisible
1517 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1522 int UtcDaliToolkitScrollBarActionShowTransientIndicatorImmediate(void)
1524 ToolkitTestApplication application;
1526 // Create a scroll bar
1527 ScrollBar scrollBar = ScrollBar::New();
1528 DALI_TEST_CHECK( scrollBar );
1530 Stage::GetCurrent().Add( scrollBar );
1532 Actor indicator = scrollBar.GetScrollIndicator();
1533 DALI_TEST_CHECK( indicator );
1535 // Make the indicator invisible
1536 indicator.SetOpacity(0.0f);
1538 // Don't use a show animation; the indicator should appear immediately
1539 scrollBar.SetProperty( ScrollBar::Property::INDICATOR_SHOW_DURATION, 0.0f );
1540 float duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_SHOW_DURATION );
1541 DALI_TEST_EQUALS( duration, 0.0f, TEST_LOCATION );
1543 // Render and notify
1544 application.SendNotification();
1545 application.Render();
1547 // Do the "ShowIndicator" action
1548 Property::Map emptyMap;
1549 scrollBar.DoAction( "ShowTransientIndicator", emptyMap );
1551 // Wait for the specified duration
1554 // Render and notify
1555 application.SendNotification();
1556 application.Render();
1558 // Check that the indicator is now visible
1559 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1561 // Get the default duration to hide the indicator
1562 float hideDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_HIDE_DURATION );
1563 float transientDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_TRANSIENT_DURATION );
1564 float totalVisibleDuration = hideDuration + transientDuration;
1566 // Check that the default duration is greater than 0
1567 DALI_TEST_CHECK( totalVisibleDuration > 0.0f );
1569 // Wait for the specified duration
1570 Wait(application, totalVisibleDuration * 1000);
1572 // Render and notify
1573 application.SendNotification();
1574 application.Render();
1576 // Check that the indicator is now invisible
1577 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1582 int UtcDaliToolkitScrollBarActionShowTransientIndicatorDuringHide(void)
1584 ToolkitTestApplication application;
1586 // Create a scroll bar
1587 ScrollBar scrollBar = ScrollBar::New();
1588 DALI_TEST_CHECK( scrollBar );
1590 Stage::GetCurrent().Add( scrollBar );
1592 Actor indicator = scrollBar.GetScrollIndicator();
1593 DALI_TEST_CHECK( indicator );
1595 // Get the default duration to hide the indicator
1596 float duration = scrollBar.GetIndicatorHideDuration();
1598 // Check that the default duration is greater than 0
1599 DALI_TEST_CHECK( duration > 0.0f );
1601 // Make the indicator visible
1602 indicator.SetOpacity(1.0f);
1604 // Render and notify
1605 application.SendNotification();
1606 application.Render();
1608 // Check that the indicator is visible
1609 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1611 // Hide the indicator
1612 scrollBar.HideIndicator();
1614 // Wait for half the specified duration
1615 Wait(application, duration * 0.5f * 1000);
1617 // Render and notify
1618 application.SendNotification();
1619 application.Render();
1621 // Check that the indicator is now partially hidden
1622 DALI_TEST_CHECK( indicator.GetCurrentOpacity() < 1.0f );
1624 // Now interrupt the Hide with a DoAction( "ShowTransientIndicator" )
1626 // Get the default duration to hide the indicator
1627 duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_SHOW_DURATION );
1629 // Check that the default duration is greater than 0
1630 DALI_TEST_CHECK( duration > 0.0f );
1632 // Do the "ShowIndicator" action
1633 Property::Map emptyMap;
1634 scrollBar.DoAction( "ShowTransientIndicator", emptyMap );
1636 // Wait for the specified duration
1637 Wait(application, duration * 1000);
1639 // Render and notify
1640 application.SendNotification();
1641 application.Render();
1643 // Check that the indicator is now visible
1644 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1646 // Get the default duration to hide the indicator
1647 float hideDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_HIDE_DURATION );
1648 float transientDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_TRANSIENT_DURATION );
1649 float totalVisibleDuration = hideDuration + transientDuration;
1651 // Check that the default duration is greater than 0
1652 DALI_TEST_CHECK( totalVisibleDuration > 0.0f );
1654 // Wait for the specified duration
1655 Wait(application, totalVisibleDuration * 1000);
1657 // Render and notify
1658 application.SendNotification();
1659 application.Render();
1661 // Check that the indicator is now invisible
1662 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1667 int UtcDaliToolkitScrollBarPanFinishedSignalP(void)
1669 ToolkitTestApplication application;
1671 // Create a vertical scroll bar
1672 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1673 DALI_TEST_CHECK( scrollBar );
1675 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
1676 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1677 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
1679 // Set the indicator height to be fixed to 50.0f
1680 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
1681 scrollBar.SetIndicatorFixedHeight(50.0f);
1683 Stage::GetCurrent().Add( scrollBar );
1685 // Connect the pan finished signal
1686 ConnectionTracker connectionTracker;
1687 bool panFinished = false;
1688 scrollBar.PanFinishedSignal().Connect( &OnPanFinished );
1689 scrollBar.ConnectSignal( &connectionTracker, "panFinished", CallbackFunctor(&panFinished));
1691 // Render and notify
1692 application.SendNotification();
1693 application.Render();
1695 // Create a source actor that owns the scroll properties required by the scroll bar
1696 Actor sourceActor = Actor::New();
1697 Stage::GetCurrent().Add( sourceActor );
1699 // Register the scroll properties
1700 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1701 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1702 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
1703 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
1705 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1706 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1707 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1708 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1710 // Set the source of the scroll position properties.
1711 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1713 // Render and notify
1714 application.SendNotification();
1715 application.Render();
1717 // Perform a swipe gesture on the indicator
1718 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 1, 500);
1719 DALI_TEST_EQUALS( gOnPanFinishedCalled, true, TEST_LOCATION );
1720 DALI_TEST_EQUALS( panFinished, true, TEST_LOCATION );
1725 int UtcDaliToolkitScrollBarPanFinishedSignalN(void)
1727 ToolkitTestApplication application;
1729 // Create a vertical scroll bar
1730 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1731 DALI_TEST_CHECK( scrollBar );
1733 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
1734 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1735 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
1737 // Set the indicator height to be fixed to 50.0f
1738 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
1739 scrollBar.SetIndicatorFixedHeight(50.0f);
1741 Stage::GetCurrent().Add( scrollBar );
1743 // Connect the pan finished signal
1744 ConnectionTracker connectionTracker;
1745 bool panFinished = false;
1746 scrollBar.PanFinishedSignal().Connect( &OnPanFinished );
1747 scrollBar.ConnectSignal( &connectionTracker, "panFinished", CallbackFunctor(&panFinished));
1749 // Render and notify
1750 application.SendNotification();
1751 application.Render();
1753 // Perform a vertical swipe gesture on the indicator when there is no source object set on the scroll bar
1754 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20, 500);
1755 DALI_TEST_EQUALS( gOnPanFinishedCalled, false, TEST_LOCATION );
1757 // Create a source actor that owns the scroll properties required by the scroll bar
1758 Actor sourceActor = Actor::New();
1759 Stage::GetCurrent().Add( sourceActor );
1761 // Register the scroll properties
1762 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1763 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1764 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
1765 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
1767 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1768 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1769 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1770 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1772 // Set the source of the scroll position properties.
1773 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1775 // Render and notify
1776 application.SendNotification();
1777 application.Render();
1779 // Perform a swipe gesture on the scroll bar but not on the indicator
1780 PerformGestureSwipe(application, Vector2(1.0f, 780.0f), Vector2(Vector2::YAXIS * -1.0f), 20, 2000);
1781 DALI_TEST_EQUALS( gOnPanFinishedCalled, false, TEST_LOCATION );
1782 DALI_TEST_EQUALS( panFinished, false, TEST_LOCATION );
1784 // Perform a swipe gesture on the indicator
1785 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20, 4000);
1786 DALI_TEST_EQUALS( gOnPanFinishedCalled, true, TEST_LOCATION );
1787 DALI_TEST_EQUALS( panFinished, true, TEST_LOCATION );
1792 int UtcDaliToolkitScrollBarScrollPositionIntervalReachedSignalP(void)
1794 ToolkitTestApplication application;
1796 // Create a vertical scroll bar
1797 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1798 DALI_TEST_CHECK( scrollBar );
1800 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
1801 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1802 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
1804 Stage::GetCurrent().Add( scrollBar );
1805 ConnectionTracker connectionTracker;
1807 // Connect to the ScrollPositionIntervalReached signal
1808 bool intervalReached = false;
1809 scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
1810 scrollBar.ConnectSignal( &connectionTracker, "scrollPositionIntervalReached", CallbackFunctor(&intervalReached));
1812 // Render and notify
1813 application.SendNotification();
1814 application.Render();
1816 // Create a source actor that owns the scroll properties required by the scroll bar
1817 Actor sourceActor = Actor::New();
1818 Stage::GetCurrent().Add( sourceActor );
1820 // Register the scroll properties
1821 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1822 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1823 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 800.0f );
1824 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 2000.0f );
1826 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1827 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1828 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1829 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1831 // Set the source of the scroll position properties.
1832 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1834 // Render and notify
1835 application.SendNotification();
1836 application.Render();
1838 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
1839 Dali::Vector<float> positionIntervals;
1840 for( size_t i = 0; i != 10; ++i )
1842 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
1844 scrollBar.SetScrollPositionIntervals(positionIntervals);
1846 // Render and notify
1847 application.SendNotification();
1848 application.Render();
1851 gOnScrollPositionIntervalReachedSignalCalled = false;
1853 // Animate the scroll position to cross the specified value
1854 Animation animation = Animation::New(0.1f);
1855 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
1858 // Wait for 0.1 second
1859 Wait(application, 100);
1861 // Check that the signal callback is called
1862 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1863 DALI_TEST_EQUALS( intervalReached, true, TEST_LOCATION );
1866 gOnScrollPositionIntervalReachedSignalCalled = false;
1867 intervalReached = false;
1869 // Rest and clear the animation
1873 // Animate the scroll position to cross another specified value
1874 animation = Animation::New(0.1f);
1875 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -170.0f );
1878 // Wait for 0.1 second
1879 Wait(application, 100);
1881 // Check that the signal callback is called
1882 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1883 DALI_TEST_EQUALS( intervalReached, true, TEST_LOCATION );
1886 gOnScrollPositionIntervalReachedSignalCalled = false;
1887 intervalReached = false;
1889 // Rest and clear the animation
1893 // Animate the scroll position back to the previous value
1894 animation = Animation::New(0.1f);
1895 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
1898 // Wait for 0.1 second
1899 Wait(application, 100);
1901 // Check that the signal callback is called
1902 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1903 DALI_TEST_EQUALS( intervalReached, true, TEST_LOCATION );
1908 int UtcDaliToolkitScrollBarScrollPositionIntervalReachedSignalN(void)
1910 ToolkitTestApplication application;
1912 // Create a vertical scroll bar
1913 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1914 DALI_TEST_CHECK( scrollBar );
1916 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
1917 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1918 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
1920 Stage::GetCurrent().Add( scrollBar );
1922 // Connect to the ScrollPositionIntervalReached signal
1923 scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
1925 // Render and notify
1926 application.SendNotification();
1927 application.Render();
1929 // Create a source actor that owns the scroll properties required by the scroll bar
1930 Actor sourceActor = Actor::New();
1931 Stage::GetCurrent().Add( sourceActor );
1933 // Register the scroll properties
1934 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1935 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1936 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 800.0f );
1937 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 2000.0f );
1939 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1940 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1941 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1942 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1944 // Set the source of the scroll position properties.
1945 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1947 // Render and notify
1948 application.SendNotification();
1949 application.Render();
1951 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
1952 Dali::Vector<float> positionIntervals;
1953 for( size_t i = 0; i != 10; ++i )
1955 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
1957 scrollBar.SetScrollPositionIntervals(positionIntervals);
1959 // Render and notify
1960 application.SendNotification();
1961 application.Render();
1964 gOnScrollPositionIntervalReachedSignalCalled = false;
1966 // Animate the scroll position not to cross the specified value
1967 Animation animation = Animation::New(0.1f);
1968 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -70.0f );
1971 // Wait for 0.1 second
1972 Wait(application, 100);
1974 // Check that the signal callback is not called
1975 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, false, TEST_LOCATION );
1977 // Rest and clear the animation
1981 // Animate the scroll position to cross another specified value
1982 animation = Animation::New(0.1f);
1983 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
1986 // Wait for 0.1 second
1987 Wait(application, 100);
1989 // Check that the signal callback is called
1990 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );