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>
24 #include <dali-toolkit/devel-api/controls/scroll-bar/scroll-bar.h>
27 using namespace Toolkit;
29 void dali_scrollbar_startup(void)
31 test_return_value = TET_UNDEF;
34 void dali_scrollbar_cleanup(void)
36 test_return_value = TET_PASS;
42 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
45 * Simulate time passed by.
47 * @note this will always process at least 1 frame (1/60 sec)
49 * @param application Test application instance
50 * @param duration Time to pass in milliseconds.
51 * @return The actual time passed in milliseconds
53 int Wait(ToolkitTestApplication& application, int duration = 0)
57 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
59 application.SendNotification();
60 application.Render(RENDER_FRAME_INTERVAL);
61 time += RENDER_FRAME_INTERVAL;
69 static bool gOnPanFinishedCalled; ///< Whether the PanFinished signal was invoked.
70 static bool gOnScrollPositionIntervalReachedSignalCalled; ///< Whether the ScrollPositionIntervalReached signal was invoked.
73 * Invoked when pan gesture is finished on the scroll indicator.
75 static void OnPanFinished()
77 gOnPanFinishedCalled = true;
80 struct CallbackFunctor
82 CallbackFunctor(bool* callbackFlag)
83 : mCallbackFlag( callbackFlag )
89 *mCallbackFlag = true;
95 * Invoked when the current scroll position of the scrollable content goes above or below the values
96 * specified by SCROLL_POSITION_INTERVALS property.
98 * @param[in] position The current scroll position.
100 static void OnScrollPositionIntervalReached( float position )
102 gOnScrollPositionIntervalReachedSignalCalled = true;
105 static Vector2 PerformGestureSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, uint32_t start_time)
107 gOnPanFinishedCalled = false;
109 // Now do a pan starting from (start) and heading (direction)
110 Vector2 pos( start + ( direction * 15 ) );
111 uint32_t time = start_time;
113 TestStartPan( application, start, pos, time );
117 for(int i = 0; i < frames; i++)
119 pos += direction; // Move in this direction
120 time += RENDER_FRAME_INTERVAL;
121 TestMovePan( application, pos, time);
125 pos += direction; // Move in this direction.
126 time += RENDER_FRAME_INTERVAL;
127 TestEndPan(application, pos, time );
135 int UtcDaliToolkitScrollBarConstructorP(void)
137 ToolkitTestApplication application;
140 DALI_TEST_CHECK( !scrollBar );
144 int UtcDaliToolkitScrollBarCopyConstructorP(void)
146 ToolkitTestApplication application;
148 ScrollBar scrollBar = ScrollBar::New();
149 scrollBar.SetProperty( ScrollBar::Property::INDICATOR_FIXED_HEIGHT, 38.2f );
151 ScrollBar copy( scrollBar );
152 DALI_TEST_CHECK( copy );
153 DALI_TEST_CHECK( copy.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) == scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) );
157 int UtcDaliToolkitScrollBarAssignmentOperatorP(void)
159 ToolkitTestApplication application;
161 ScrollBar scrollBar = ScrollBar::New();
162 scrollBar.SetProperty( ScrollBar::Property::INDICATOR_FIXED_HEIGHT, 38.2f );
164 ScrollBar copy = scrollBar;
165 DALI_TEST_CHECK( copy );
166 DALI_TEST_CHECK( copy.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) == scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) );
170 int UtcDaliScrollBarDestructorP(void)
172 ToolkitTestApplication application;
174 ScrollBar* scrollBar = new ScrollBar();
177 DALI_TEST_CHECK( true );
181 int UtcDaliToolkitScrollBarNewP(void)
183 ToolkitTestApplication application;
185 ScrollBar scrollBar = ScrollBar::New();
186 DALI_TEST_CHECK( scrollBar );
189 ScrollBar vertical = ScrollBar::New(ScrollBar::Vertical);
190 DALI_TEST_CHECK( vertical );
191 DALI_TEST_CHECK( vertical.GetScrollDirection() == ScrollBar::Vertical );
193 Property::Value value = vertical.GetProperty(ScrollBar::Property::SCROLL_DIRECTION);
194 std::string scrollDirection = value.Get<std::string>();
195 DALI_TEST_EQUALS( scrollDirection, "Vertical", TEST_LOCATION );
197 ScrollBar horizontal = ScrollBar::New(ScrollBar::Horizontal);
198 DALI_TEST_CHECK( horizontal );
199 DALI_TEST_CHECK( horizontal.GetScrollDirection() == ScrollBar::Horizontal );
200 value = vertical.GetProperty(ScrollBar::Property::SCROLL_DIRECTION);
201 scrollDirection = value.Get<std::string>();
202 DALI_TEST_EQUALS( scrollDirection, "Horizontal", TEST_LOCATION );
207 int UtcDaliToolkitScrollBarCreateP(void)
209 ToolkitTestApplication application;
211 TypeRegistry typeRegistry = TypeRegistry::Get();
212 DALI_TEST_CHECK( typeRegistry );
214 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "ScrollBar" );
215 DALI_TEST_CHECK( typeInfo );
217 BaseHandle handle = typeInfo.CreateInstance();
218 DALI_TEST_CHECK( handle );
220 ScrollBar scrollBar = ScrollBar::DownCast( handle );
221 DALI_TEST_CHECK( scrollBar );
223 scrollBar.SetProperty(ScrollBar::Property::SCROLL_DIRECTION, "Vertical");
224 scrollBar.SetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY, "Fixed");
226 DALI_TEST_EQUALS( scrollBar.GetScrollDirection(), Toolkit::ScrollBar::Vertical, TEST_LOCATION );
227 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Fixed, TEST_LOCATION );
229 scrollBar.SetProperty(ScrollBar::Property::SCROLL_DIRECTION, "Horizontal");
230 scrollBar.SetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY, "Variable");
232 DALI_TEST_EQUALS( scrollBar.GetScrollDirection(), Toolkit::ScrollBar::Horizontal, TEST_LOCATION );
233 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Variable, TEST_LOCATION );
238 int UtcDaliToolkitScrollBarDownCastP(void)
240 ToolkitTestApplication application;
242 ScrollBar scrollBar1 = ScrollBar::New();
243 BaseHandle object( scrollBar1 );
245 ScrollBar scrollBar2 = ScrollBar::DownCast( object );
246 DALI_TEST_CHECK( scrollBar2 );
248 ScrollBar scrollBar3 = DownCast< ScrollBar >( object );
249 DALI_TEST_CHECK( scrollBar3 );
253 int UtcDaliToolkitScrollBarDownCastN(void)
255 ToolkitTestApplication application;
257 BaseHandle uninitializedObject;
258 ScrollBar scrollBar1 = ScrollBar::DownCast( uninitializedObject );
259 DALI_TEST_CHECK( !scrollBar1 );
261 ScrollBar scrollBar2 = DownCast< ScrollBar >( uninitializedObject );
262 DALI_TEST_CHECK( !scrollBar2 );
266 int UtcDaliToolkitScrollBarSetScrollPropertySourceP(void)
268 ToolkitTestApplication application;
270 // Create a vertical scroll bar
271 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
272 DALI_TEST_CHECK( scrollBar );
273 DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::Vertical );
275 float scrollBarHeight = 100.0f;
276 scrollBar.SetProperty( Actor::Property::SIZE, Vector3(20.0f, scrollBarHeight, 0.0f) );
277 Stage::GetCurrent().Add( scrollBar );
279 // Create a source actor that owns the scroll properties required by the scroll bar
280 Actor sourceActor = Actor::New();
281 Stage::GetCurrent().Add( sourceActor );
283 // Register the scroll properties
284 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
285 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
286 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
287 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
289 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
290 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
291 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
292 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
294 // Set the source of the scroll position properties.
295 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
298 application.SendNotification();
299 application.Render();
301 Actor indicator = scrollBar.GetScrollIndicator();
302 DALI_TEST_CHECK( indicator );
304 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
305 // i.e. The bigger the content size, the smaller the indicator size
306 float indicatorHeight = indicator.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).y;
307 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
309 // Decrease the content length
310 sourceActor.SetProperty( propertyScrollContentSize, 250.0f );
313 application.SendNotification();
314 application.Render();
316 // Check that the indicator size is changed accordingly
317 indicatorHeight = indicator.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).y;
318 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 250.0f, TEST_LOCATION );
320 // As scroll position is 0, check that the indicator position should be 0.0f.
321 float indicatorPosition = indicator.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y;
322 DALI_TEST_EQUALS( indicatorPosition, 0.0f, TEST_LOCATION );
324 // Set the scroll position to the middle
325 sourceActor.SetProperty( propertyScrollPosition, -50.0f );
328 application.SendNotification();
329 application.Render();
331 // Check that the indicator should be in the middle of the scroll bar
332 indicatorPosition = indicator.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y;
333 DALI_TEST_EQUALS( indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.5f, TEST_LOCATION );
335 // Set the scroll position to the maximum
336 sourceActor.SetProperty( propertyScrollPosition, -100.0f );
339 application.SendNotification();
340 application.Render();
342 // Check that the indicator should be in the end of the scroll bar
343 indicatorPosition = indicator.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y;
344 DALI_TEST_EQUALS( indicatorPosition, scrollBarHeight - indicatorHeight, TEST_LOCATION );
346 // Increase the maximum scroll position to double
347 sourceActor.SetProperty( propertyMaxScrollPosition, 200.0f );
350 application.SendNotification();
351 application.Render();
353 // Check that the indicator should be now in the middle of the scroll bar
354 indicatorPosition = indicator.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y;
355 DALI_TEST_EQUALS( indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.5f, TEST_LOCATION );
357 // Create another source actor
358 Actor newSourceActor = Actor::New();
359 Stage::GetCurrent().Add( newSourceActor );
361 // Register the scroll properties
362 Property::Index newPropertyScrollPosition = newSourceActor.RegisterProperty( "sourcePosition", 0.0f );
363 Property::Index newPropertyMinScrollPosition = newSourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
364 Property::Index newPropertyMaxScrollPosition = newSourceActor.RegisterProperty( "sourcePositionMax", 200.0f );
365 Property::Index newPropertyScrollContentSize = newSourceActor.RegisterProperty( "sourceContentSize", 400.0f );
367 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourcePosition" ), newPropertyScrollPosition, TEST_LOCATION );
368 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourcePositionMin" ), newPropertyMinScrollPosition, TEST_LOCATION );
369 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourcePositionMax" ), newPropertyMaxScrollPosition, TEST_LOCATION );
370 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourceContentSize" ), newPropertyScrollContentSize, TEST_LOCATION );
372 // Change the source of the scroll position properties to be the new source actor.
373 scrollBar.SetScrollPropertySource(newSourceActor, newPropertyScrollPosition, newPropertyMinScrollPosition, newPropertyMaxScrollPosition, newPropertyScrollContentSize);
376 application.SendNotification();
377 application.Render();
379 // Check that the indicator size is changed accordingly
380 indicatorHeight = indicator.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).y;
381 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 400.0f, TEST_LOCATION );
383 // Check that the indicator position goes back to the beginning of the scroll bar
384 indicatorPosition = indicator.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y;
385 DALI_TEST_EQUALS( indicatorPosition, 0.0f, TEST_LOCATION );
387 // Set the scroll position to one fifth of the maximum
388 newSourceActor.SetProperty( propertyScrollPosition, -40.0f );
391 application.SendNotification();
392 application.Render();
394 // Check that the indicator should be in one fifth from the beginning of the scroll bar
395 indicatorPosition = indicator.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ).y;
396 DALI_TEST_EQUALS( indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.2f, TEST_LOCATION );
401 int UtcDaliToolkitScrollBarSetScrollPropertySourceN(void)
403 ToolkitTestApplication application;
405 // Create a scroll bar
406 ScrollBar scrollBar = ScrollBar::New();
407 DALI_TEST_CHECK( scrollBar );
409 // Set empty handle of source object and invalid source property index.
411 scrollBar.SetScrollPropertySource(sourceActor, Property::INVALID_INDEX, Property::INVALID_INDEX, Property::INVALID_INDEX, Property::INVALID_INDEX);
413 DALI_TEST_CHECK( true );
417 int UtcDaliToolkitScrollBarSetScrollIndicatorP(void)
419 ToolkitTestApplication application;
421 // Create a scroll bar
422 ScrollBar scrollBar = ScrollBar::New();
423 DALI_TEST_CHECK( scrollBar );
425 Actor indicator = scrollBar.GetScrollIndicator();
426 DALI_TEST_CHECK( indicator );
428 // Set a new indicator
429 Actor newIndicator = Actor::New();
430 scrollBar.SetScrollIndicator(newIndicator);
432 // Check that the new indicator is successfully set
433 DALI_TEST_CHECK( indicator != scrollBar.GetScrollIndicator() );
434 DALI_TEST_CHECK( newIndicator == scrollBar.GetScrollIndicator() );
436 // Check that the new control indicator is successfully set
437 Control controlIndicator = Control::New();
438 scrollBar.SetScrollIndicator(controlIndicator);
440 DALI_TEST_CHECK( controlIndicator == Control::DownCast( scrollBar.GetScrollIndicator() ) );
444 int UtcDaliToolkitScrollBarSetScrollIndicatorN(void)
446 ToolkitTestApplication application;
448 // Create a scroll bar
449 ScrollBar scrollBar = ScrollBar::New();
450 DALI_TEST_CHECK( scrollBar );
452 Actor indicator = scrollBar.GetScrollIndicator();
453 DALI_TEST_CHECK( indicator );
455 // Try to set an uninitialized actor as the indicator
456 Actor uninitializedIndicator;
457 scrollBar.SetScrollIndicator(uninitializedIndicator);
459 // Check that the uninitialized actor can not be set as the indicator
460 DALI_TEST_CHECK( indicator == scrollBar.GetScrollIndicator() );
461 DALI_TEST_CHECK( uninitializedIndicator != scrollBar.GetScrollIndicator() );
466 int UtcDaliToolkitScrollBarGetScrollIndicatorP(void)
468 ToolkitTestApplication application;
470 // Create a scroll bar
471 ScrollBar scrollBar = ScrollBar::New();
472 DALI_TEST_CHECK( scrollBar );
474 Actor indicator = scrollBar.GetScrollIndicator();
475 DALI_TEST_CHECK( indicator );
477 // Set a new indicator
478 Actor newIndicator = Actor::New();
479 scrollBar.SetScrollIndicator(newIndicator);
481 // Check that the new indicator is successfully set
482 DALI_TEST_CHECK( scrollBar.GetScrollIndicator() );
483 DALI_TEST_CHECK( indicator != scrollBar.GetScrollIndicator() );
484 DALI_TEST_CHECK( newIndicator == scrollBar.GetScrollIndicator() );
489 int UtcDaliToolkitScrollBarGetScrollIndicatorN(void)
491 ToolkitTestApplication application;
493 // Create a scroll bar
494 ScrollBar scrollBar = ScrollBar::New();
495 DALI_TEST_CHECK( scrollBar );
497 Actor indicator = scrollBar.GetScrollIndicator();
498 DALI_TEST_CHECK( indicator );
500 // Try to set an uninitialized actor as the indicator
501 Actor uninitializedIndicator;
502 scrollBar.SetScrollIndicator(uninitializedIndicator);
504 // Check that the indicator has not been changed
505 DALI_TEST_CHECK( indicator == scrollBar.GetScrollIndicator() );
506 DALI_TEST_CHECK( uninitializedIndicator != scrollBar.GetScrollIndicator() );
511 int UtcDaliToolkitScrollBarSetScrollPositionIntervalsP(void)
513 ToolkitTestApplication application;
515 // Create a vertical scroll bar
516 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
517 DALI_TEST_CHECK( scrollBar );
519 scrollBar.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
520 scrollBar.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
521 scrollBar.SetProperty( Actor::Property::SIZE, Vector3(20.0f, 800.0f, 0.0f) );
523 Stage::GetCurrent().Add( scrollBar );
525 // Connect to the ScrollPositionIntervalReached signal
526 scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
529 application.SendNotification();
530 application.Render();
532 // Create a source actor that owns the scroll properties required by the scroll bar
533 Actor sourceActor = Actor::New();
534 Stage::GetCurrent().Add( sourceActor );
536 // Register the scroll properties
537 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
538 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
539 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 800.0f );
540 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 2000.0f );
542 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
543 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
544 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
545 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
547 // Set the source of the scroll position properties.
548 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
551 application.SendNotification();
552 application.Render();
554 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
555 Dali::Vector<float> positionIntervals;
556 for( size_t i = 0; i != 10; ++i )
558 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
560 scrollBar.SetScrollPositionIntervals(positionIntervals);
562 // Get the list of scroll position intervals for notification
563 Dali::Vector<float> results = scrollBar.GetScrollPositionIntervals();
565 // Check that the result is the same as the list previously set.
566 DALI_TEST_EQUALS( positionIntervals.Count(), results.Count(), TEST_LOCATION );
567 DALI_TEST_EQUALS( positionIntervals[0], results[0], TEST_LOCATION );
568 DALI_TEST_EQUALS( positionIntervals[1], results[1], TEST_LOCATION );
569 DALI_TEST_EQUALS( positionIntervals[2], results[2], TEST_LOCATION );
570 DALI_TEST_EQUALS( positionIntervals[3], results[3], TEST_LOCATION );
571 DALI_TEST_EQUALS( positionIntervals[4], results[4], TEST_LOCATION );
572 DALI_TEST_EQUALS( positionIntervals[5], results[5], TEST_LOCATION );
573 DALI_TEST_EQUALS( positionIntervals[6], results[6], TEST_LOCATION );
574 DALI_TEST_EQUALS( positionIntervals[7], results[7], TEST_LOCATION );
575 DALI_TEST_EQUALS( positionIntervals[8], results[8], TEST_LOCATION );
576 DALI_TEST_EQUALS( positionIntervals[9], results[9], TEST_LOCATION );
579 gOnScrollPositionIntervalReachedSignalCalled = false;
581 // Animate the scroll position to cross the specified value
582 Animation animation = Animation::New(0.1f);
583 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
586 // Wait for 0.1 second
587 Wait(application, 100);
589 // Check that the signal callback is called
590 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
593 gOnScrollPositionIntervalReachedSignalCalled = false;
595 // Rest and clear the animation
599 // Animate the scroll position to cross another specified value
600 animation = Animation::New(0.1f);
601 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -170.0f );
604 // Wait for 0.1 second
605 Wait(application, 100);
607 // Check that the signal callback is called
608 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
611 gOnScrollPositionIntervalReachedSignalCalled = false;
613 // Rest and clear the animation
617 // Animate the scroll position back to the previous value
618 animation = Animation::New(0.1f);
619 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
622 // Wait for 0.1 second
623 Wait(application, 100);
625 // Check that the signal callback is called
626 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
631 int UtcDaliToolkitScrollBarGetScrollPositionIntervalsP(void)
633 ToolkitTestApplication application;
635 // Create a vertical scroll bar
636 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
637 DALI_TEST_CHECK( scrollBar );
639 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
640 Dali::Vector<float> positionIntervals;
641 for( size_t i = 0; i != 10; ++i )
643 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
645 scrollBar.SetScrollPositionIntervals(positionIntervals);
647 // Get the list of scroll position intervals for notification
648 Dali::Vector<float> results = scrollBar.GetScrollPositionIntervals();
650 // Check that the result is the same as the list previously set.
651 DALI_TEST_EQUALS( positionIntervals.Count(), results.Count(), TEST_LOCATION );
652 DALI_TEST_EQUALS( positionIntervals[0], results[0], TEST_LOCATION );
653 DALI_TEST_EQUALS( positionIntervals[1], results[1], TEST_LOCATION );
654 DALI_TEST_EQUALS( positionIntervals[2], results[2], TEST_LOCATION );
655 DALI_TEST_EQUALS( positionIntervals[3], results[3], TEST_LOCATION );
656 DALI_TEST_EQUALS( positionIntervals[4], results[4], TEST_LOCATION );
657 DALI_TEST_EQUALS( positionIntervals[5], results[5], TEST_LOCATION );
658 DALI_TEST_EQUALS( positionIntervals[6], results[6], TEST_LOCATION );
659 DALI_TEST_EQUALS( positionIntervals[7], results[7], TEST_LOCATION );
660 DALI_TEST_EQUALS( positionIntervals[8], results[8], TEST_LOCATION );
661 DALI_TEST_EQUALS( positionIntervals[9], results[9], TEST_LOCATION );
663 Property::Array resultArray = scrollBar.GetProperty<Property::Array>(Toolkit::ScrollBar::Property::SCROLL_POSITION_INTERVALS);
665 DALI_TEST_EQUALS( positionIntervals.Count(), resultArray.Count(), TEST_LOCATION );
666 DALI_TEST_EQUALS( positionIntervals[0], resultArray[0].Get<float>(), TEST_LOCATION );
667 DALI_TEST_EQUALS( positionIntervals[1], resultArray[1].Get<float>(), TEST_LOCATION );
668 DALI_TEST_EQUALS( positionIntervals[2], resultArray[2].Get<float>(), TEST_LOCATION );
669 DALI_TEST_EQUALS( positionIntervals[3], resultArray[3].Get<float>(), TEST_LOCATION );
670 DALI_TEST_EQUALS( positionIntervals[4], resultArray[4].Get<float>(), TEST_LOCATION );
671 DALI_TEST_EQUALS( positionIntervals[5], resultArray[5].Get<float>(), TEST_LOCATION );
672 DALI_TEST_EQUALS( positionIntervals[6], resultArray[6].Get<float>(), TEST_LOCATION );
673 DALI_TEST_EQUALS( positionIntervals[7], resultArray[7].Get<float>(), TEST_LOCATION );
674 DALI_TEST_EQUALS( positionIntervals[8], resultArray[8].Get<float>(), TEST_LOCATION );
675 DALI_TEST_EQUALS( positionIntervals[9], resultArray[9].Get<float>(), TEST_LOCATION );
680 int UtcDaliToolkitScrollBarGetScrollDirectionP(void)
682 ToolkitTestApplication application;
684 // Create a vertical scroll bar
685 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
686 DALI_TEST_CHECK( scrollBar );
687 DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::Vertical );
689 // Change the direction of scroll bar to horizontal
690 scrollBar.SetScrollDirection(ScrollBar::Horizontal);
691 DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::Horizontal );
696 int UtcDaliToolkitScrollBarSetIndicatorHeightPolicyP(void)
698 ToolkitTestApplication application;
700 // Create a scroll bar
701 ScrollBar scrollBar = ScrollBar::New();
702 DALI_TEST_CHECK( scrollBar );
704 float scrollBarHeight = 100.0f;
705 scrollBar.SetProperty( Actor::Property::SIZE, Vector3(20.0f, scrollBarHeight, 0.0f) );
706 Stage::GetCurrent().Add( scrollBar );
708 // Create a source actor that owns the scroll properties required by the scroll bar
709 Actor sourceActor = Actor::New();
710 Stage::GetCurrent().Add( sourceActor );
712 // Register the scroll properties
713 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
714 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
715 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
716 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
718 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
719 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
720 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
721 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
723 // Set the source of the scroll position properties.
724 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
727 application.SendNotification();
728 application.Render();
730 Actor indicator = scrollBar.GetScrollIndicator();
731 DALI_TEST_CHECK( indicator );
733 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
734 // i.e. The bigger the content size, the smaller the indicator size
735 float indicatorHeight = indicator.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).y;
736 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
738 // Set the indicator height to be fixed to 50.0f
739 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
740 scrollBar.SetIndicatorFixedHeight(50.0f);
742 Property::Value value = scrollBar.GetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY);
743 DALI_TEST_EQUALS(value.Get<std::string>(), "Fixed", TEST_LOCATION );
746 application.SendNotification();
747 application.Render();
749 // Check that the indicator size should be 50.0f
750 indicatorHeight = indicator.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).y;
751 DALI_TEST_EQUALS( indicatorHeight, 50.0f, TEST_LOCATION );
753 // Set the indicator height to be variable
754 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Variable);
755 value = scrollBar.GetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY);
756 DALI_TEST_EQUALS(value.Get<std::string>(), "Variable", TEST_LOCATION );
759 application.SendNotification();
760 application.Render();
762 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
763 indicatorHeight = indicator.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).y;
764 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
769 int UtcDaliToolkitScrollBarGetIndicatorHeightPolicyP(void)
771 ToolkitTestApplication application;
773 // Create a scroll bar
774 ScrollBar scrollBar = ScrollBar::New();
775 DALI_TEST_CHECK( scrollBar );
777 // Set the indicator height to be fixed
778 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
779 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Fixed, TEST_LOCATION );
781 // Set the indicator height to be variable
782 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Variable);
783 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Variable, TEST_LOCATION );
788 int UtcDaliToolkitScrollBarSetIndicatorFixedHeightP(void)
790 ToolkitTestApplication application;
792 // Create a scroll bar
793 ScrollBar scrollBar = ScrollBar::New();
794 DALI_TEST_CHECK( scrollBar );
796 float scrollBarHeight = 100.0f;
797 scrollBar.SetProperty( Actor::Property::SIZE, Vector3(20.0f, scrollBarHeight, 0.0f) );
798 Stage::GetCurrent().Add( scrollBar );
800 Actor indicator = scrollBar.GetScrollIndicator();
801 DALI_TEST_CHECK( indicator );
803 // Set the indicator height to be fixed to 50.0f
804 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
805 scrollBar.SetIndicatorFixedHeight(50.0f);
808 application.SendNotification();
809 application.Render();
811 // Check that the indicator size should be 50.0f
812 DALI_TEST_EQUALS( indicator.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).y, 50.0f, TEST_LOCATION );
814 // Set the indicator height to be fixed to 25.0f
815 scrollBar.SetIndicatorFixedHeight(25.0f);
818 application.SendNotification();
819 application.Render();
821 // Check that the indicator size should be 25.0f
822 DALI_TEST_EQUALS( indicator.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).y, 25.0f, TEST_LOCATION );
827 int UtcDaliToolkitScrollBarGetIndicatorFixedHeightP(void)
829 ToolkitTestApplication application;
831 // Create a scroll bar
832 ScrollBar scrollBar = ScrollBar::New();
833 DALI_TEST_CHECK( scrollBar );
835 // Set the fixed indicator height to be 50.0f
836 scrollBar.SetIndicatorFixedHeight(50.0f);
838 // Check that the indicator size should be 50.0f
839 DALI_TEST_EQUALS( scrollBar.GetIndicatorFixedHeight(), 50.0f, TEST_LOCATION );
841 // Set the indicator height to be fixed to 25.0f
842 scrollBar.SetIndicatorFixedHeight(25.0f);
844 // Check that the indicator size should be 50.0f
845 DALI_TEST_EQUALS( scrollBar.GetIndicatorFixedHeight(), 25.0f, TEST_LOCATION );
850 int UtcDaliToolkitScrollBarSetIndicatorShowDurationP(void)
852 ToolkitTestApplication application;
854 // Create a scroll bar
855 ScrollBar scrollBar = ScrollBar::New();
856 DALI_TEST_CHECK( scrollBar );
858 Stage::GetCurrent().Add( scrollBar );
860 Actor indicator = scrollBar.GetScrollIndicator();
861 DALI_TEST_CHECK( indicator );
863 // Set the duration to show the indicator to be 0.35 second
864 scrollBar.SetIndicatorShowDuration(0.35);
865 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.35f, TEST_LOCATION );
867 // Make the indicator invisible
868 indicator.SetProperty( Actor::Property::OPACITY,0.0f);
871 application.SendNotification();
872 application.Render();
874 // Check that the indicator is invisible
875 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
877 // Show the indicator
878 scrollBar.ShowIndicator();
880 // Wait for 0.35 second
881 Wait(application, 350);
884 application.SendNotification();
885 application.Render();
887 // Check that the indicator is now visible
888 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
890 // Set the duration to show the indicator to be 0.75 second
891 scrollBar.SetIndicatorShowDuration(0.75);
892 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.75f, TEST_LOCATION );
894 // Make the indicator invisible
895 indicator.SetProperty( Actor::Property::OPACITY,0.0f);
898 application.SendNotification();
899 application.Render();
901 // Check that the indicator is invisible
902 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
904 // Show the indicator
905 scrollBar.ShowIndicator();
907 // Wait for 0.35 second first
908 Wait(application, 350);
911 application.SendNotification();
912 application.Render();
914 // Check that the indicator is not fully visible yet
915 DALI_TEST_CHECK( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ) != 1.0f );
917 // Wait for another 0.4 second
918 Wait(application, 400);
921 application.SendNotification();
922 application.Render();
924 // Check that the indicator is now fully visible
925 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
930 int UtcDaliToolkitScrollBarSetIndicatorShowDurationN(void)
932 ToolkitTestApplication application;
934 // Create a scroll bar
935 ScrollBar scrollBar = ScrollBar::New();
936 DALI_TEST_CHECK( scrollBar );
938 Stage::GetCurrent().Add( scrollBar );
940 Actor indicator = scrollBar.GetScrollIndicator();
941 DALI_TEST_CHECK( indicator );
943 // Get the default duration to show the indicator
944 float duration = scrollBar.GetIndicatorShowDuration();
946 // Check that the default duration is greater than 0
947 DALI_TEST_CHECK( duration > 0.0f );
949 // Make the indicator invisible
950 indicator.SetProperty( Actor::Property::OPACITY,0.0f);
953 application.SendNotification();
954 application.Render();
956 // Check that the indicator is invisible
957 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
959 // Show the indicator
960 scrollBar.ShowIndicator();
962 // Wait for the specified duration
963 Wait(application, duration * 1000);
966 application.SendNotification();
967 application.Render();
969 // Check that the indicator is now visible
970 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
972 // Now set the duration to show the indicator to be a negative value (which should be ignored and therefore means instant)
973 scrollBar.SetIndicatorShowDuration(-0.25f);
974 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), -0.25f, TEST_LOCATION );
976 // Make the indicator invisible
977 indicator.SetProperty( Actor::Property::OPACITY,0.0f);
980 application.SendNotification();
981 application.Render();
983 // Check that the indicator is invisible
984 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
986 // Show the indicator
987 scrollBar.ShowIndicator();
990 application.SendNotification();
991 application.Render();
993 // Check that the indicator becomes instantly visible in the next frame
994 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
999 int UtcDaliToolkitScrollBarGetIndicatorShowDurationP(void)
1001 ToolkitTestApplication application;
1003 // Create a scroll bar
1004 ScrollBar scrollBar = ScrollBar::New();
1005 DALI_TEST_CHECK( scrollBar );
1007 // Set the duration to show the indicator to be 0.35 second
1008 scrollBar.SetIndicatorShowDuration(0.35f);
1010 // Check that the duration to show the indicator is 0.35 second
1011 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.35f, TEST_LOCATION );
1013 // Set the duration to show the indicator to be 0.75 second
1014 scrollBar.SetIndicatorShowDuration(0.75f);
1016 // Check that the duration to show the indicator is 0.75 second
1017 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.75f, TEST_LOCATION );
1022 int UtcDaliToolkitScrollBarSetIndicatorHideDurationP(void)
1024 ToolkitTestApplication application;
1026 // Create a scroll bar
1027 ScrollBar scrollBar = ScrollBar::New();
1028 DALI_TEST_CHECK( scrollBar );
1030 Stage::GetCurrent().Add( scrollBar );
1032 Actor indicator = scrollBar.GetScrollIndicator();
1033 DALI_TEST_CHECK( indicator );
1035 // Set the duration to hide the indicator to be 0.15 second
1036 scrollBar.SetIndicatorHideDuration(0.15f);
1037 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.15f, TEST_LOCATION );
1039 // Make the indicator visible
1040 indicator.SetProperty( Actor::Property::OPACITY,1.0f);
1042 // Render and notify
1043 application.SendNotification();
1044 application.Render();
1046 // Check that the indicator is visible
1047 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1049 // Hide the indicator
1050 scrollBar.HideIndicator();
1052 // Wait for 0.15 second
1053 Wait(application, 150);
1055 // Render and notify
1056 application.SendNotification();
1057 application.Render();
1059 // Check that the indicator is now invisible
1060 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1062 // Set the duration to hide the indicator to be 0.65 second
1063 scrollBar.SetIndicatorHideDuration(0.65f);
1064 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.65f, TEST_LOCATION );
1066 // Make the indicator visible
1067 indicator.SetProperty( Actor::Property::OPACITY,1.0f);
1069 // Render and notify
1070 application.SendNotification();
1071 application.Render();
1073 // Check that the indicator is visible
1074 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1076 // Hide the indicator
1077 scrollBar.HideIndicator();
1079 // Wait for 0.15 second first
1080 Wait(application, 150);
1082 // Render and notify
1083 application.SendNotification();
1084 application.Render();
1086 // Check that the indicator is not fully invisible yet
1087 DALI_TEST_CHECK( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ) != 0.0f );
1089 // Wait for another 0.5 second
1090 Wait(application, 500);
1092 // Render and notify
1093 application.SendNotification();
1094 application.Render();
1096 // Check that the indicator is now fully invisible
1097 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1102 int UtcDaliToolkitScrollBarSetIndicatorHideDurationN(void)
1104 ToolkitTestApplication application;
1106 // Create a scroll bar
1107 ScrollBar scrollBar = ScrollBar::New();
1108 DALI_TEST_CHECK( scrollBar );
1110 Stage::GetCurrent().Add( scrollBar );
1112 Actor indicator = scrollBar.GetScrollIndicator();
1113 DALI_TEST_CHECK( indicator );
1115 // Get the default duration to hide the indicator
1116 float duration = scrollBar.GetIndicatorHideDuration();
1118 // Check that the default duration is greater than 0
1119 DALI_TEST_CHECK( duration > 0.0f );
1121 // Make the indicator visible
1122 indicator.SetProperty( Actor::Property::OPACITY,1.0f);
1124 // Render and notify
1125 application.SendNotification();
1126 application.Render();
1128 // Check that the indicator is visible
1129 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1131 // Hide the indicator
1132 scrollBar.HideIndicator();
1134 // Wait for the specified duration
1135 Wait(application, duration * 1000);
1137 // Render and notify
1138 application.SendNotification();
1139 application.Render();
1141 // Check that the indicator is now invisible
1142 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1144 // Now set the duration to hide the indicator to be a negative value (which should be ignored and therefore means instant)
1145 scrollBar.SetIndicatorHideDuration(-0.25f);
1146 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), -0.25f, TEST_LOCATION );
1148 // Make the indicator visible
1149 indicator.SetProperty( Actor::Property::OPACITY,1.0f);
1151 // Render and notify
1152 application.SendNotification();
1153 application.Render();
1155 // Check that the indicator is visible
1156 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1158 // Hide the indicator
1159 scrollBar.HideIndicator();
1161 // Render and notify
1162 application.SendNotification();
1163 application.Render();
1165 // Check that the indicator becomes instantly invisible in the next frame
1166 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1171 int UtcDaliToolkitScrollBarGetIndicatorHideDurationP(void)
1173 ToolkitTestApplication application;
1175 // Create a scroll bar
1176 ScrollBar scrollBar = ScrollBar::New();
1177 DALI_TEST_CHECK( scrollBar );
1179 // Set the duration to hide the indicator to be 0.15 second
1180 scrollBar.SetIndicatorHideDuration(0.15f);
1182 // Check that the duration to hide the indicator is 0.15 second
1183 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.15f, TEST_LOCATION );
1185 // Set the duration to hide the indicator to be 0.65 second
1186 scrollBar.SetIndicatorHideDuration(0.65f);
1188 // Check that the duration to hide the indicator is 0.65 second
1189 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.65f, TEST_LOCATION );
1194 int UtcDaliToolkitScrollBarShowIndicatorP(void)
1196 ToolkitTestApplication application;
1198 // Create a scroll bar
1199 ScrollBar scrollBar = ScrollBar::New();
1200 DALI_TEST_CHECK( scrollBar );
1202 Stage::GetCurrent().Add( scrollBar );
1204 Actor indicator = scrollBar.GetScrollIndicator();
1205 DALI_TEST_CHECK( indicator );
1207 // Get the default duration to show the indicator
1208 float duration = scrollBar.GetIndicatorShowDuration();
1210 // Check that the default duration is greater than 0
1211 DALI_TEST_CHECK( duration > 0.0f );
1213 // Make the indicator invisible
1214 indicator.SetProperty( Actor::Property::OPACITY,0.0f);
1216 // Render and notify
1217 application.SendNotification();
1218 application.Render();
1220 // Check that the indicator is invisible
1221 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1223 // Show the indicator
1224 scrollBar.ShowIndicator();
1226 // Wait for the specified duration
1227 Wait(application, duration * 1000);
1229 // Render and notify
1230 application.SendNotification();
1231 application.Render();
1233 // Check that the indicator is now visible
1234 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1239 int UtcDaliToolkitScrollBarShowIndicatorN(void)
1241 ToolkitTestApplication application;
1243 // Create a scroll bar
1244 ScrollBar scrollBar = ScrollBar::New();
1245 DALI_TEST_CHECK( scrollBar );
1247 Stage::GetCurrent().Add( scrollBar );
1249 Actor indicator = scrollBar.GetScrollIndicator();
1250 DALI_TEST_CHECK( indicator );
1252 // Make the indicator initially visible
1253 indicator.SetProperty( Actor::Property::OPACITY,1.0f);
1255 // Render and notify
1256 application.SendNotification();
1257 application.Render();
1259 // Check that the indicator is initially visible
1260 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1262 // Get the default duration to show the indicator
1263 float duration = scrollBar.GetIndicatorShowDuration();
1265 // Check that the default duration is greater than 0
1266 DALI_TEST_CHECK( duration > 0.0f );
1268 // Show the indicator
1269 scrollBar.ShowIndicator();
1271 // Render and notify
1272 application.SendNotification();
1273 application.Render();
1275 // Check that the indicator is still visible in the very next frame
1276 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1281 int UtcDaliToolkitScrollBarHideIndicatorP(void)
1283 ToolkitTestApplication application;
1285 // Create a scroll bar
1286 ScrollBar scrollBar = ScrollBar::New();
1287 DALI_TEST_CHECK( scrollBar );
1289 Stage::GetCurrent().Add( scrollBar );
1291 Actor indicator = scrollBar.GetScrollIndicator();
1292 DALI_TEST_CHECK( indicator );
1294 // Get the default duration to hide the indicator
1295 float duration = scrollBar.GetIndicatorHideDuration();
1297 // Check that the default duration is greater than 0
1298 DALI_TEST_CHECK( duration > 0.0f );
1300 // Make the indicator visible
1301 indicator.SetProperty( Actor::Property::OPACITY,1.0f);
1303 // Render and notify
1304 application.SendNotification();
1305 application.Render();
1307 // Check that the indicator is visible
1308 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1310 // Hide the indicator
1311 scrollBar.HideIndicator();
1313 // Wait for the specified duration
1314 Wait(application, duration * 1000);
1316 // Render and notify
1317 application.SendNotification();
1318 application.Render();
1320 // Check that the indicator is now invisible
1321 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1326 int UtcDaliToolkitScrollBarHideIndicatorN(void)
1328 ToolkitTestApplication application;
1330 // Create a scroll bar
1331 ScrollBar scrollBar = ScrollBar::New();
1332 DALI_TEST_CHECK( scrollBar );
1334 Stage::GetCurrent().Add( scrollBar );
1336 Actor indicator = scrollBar.GetScrollIndicator();
1337 DALI_TEST_CHECK( indicator );
1339 // Make the indicator initially invisible
1340 indicator.SetProperty( Actor::Property::OPACITY,0.0f);
1342 // Render and notify
1343 application.SendNotification();
1344 application.Render();
1346 // Check that the indicator is initially invisible
1347 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1349 // Get the default duration to hide the indicator
1350 float duration = scrollBar.GetIndicatorHideDuration();
1352 // Check that the default duration is greater than 0
1353 DALI_TEST_CHECK( duration > 0.0f );
1355 // Hide the indicator
1356 scrollBar.HideIndicator();
1358 // Render and notify
1359 application.SendNotification();
1360 application.Render();
1362 // Check that the indicator is still invisible in the very next frame
1363 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1368 int UtcDaliToolkitScrollBarActionShowIndicator(void)
1370 ToolkitTestApplication application;
1372 // Create a scroll bar
1373 ScrollBar scrollBar = ScrollBar::New();
1374 DALI_TEST_CHECK( scrollBar );
1376 Stage::GetCurrent().Add( scrollBar );
1378 Actor indicator = scrollBar.GetScrollIndicator();
1379 DALI_TEST_CHECK( indicator );
1381 // Get the default duration to hide the indicator
1382 float duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_SHOW_DURATION );
1384 // Check that the default duration is greater than 0
1385 DALI_TEST_CHECK( duration > 0.0f );
1387 // Make the indicator invisible
1388 indicator.SetProperty( Actor::Property::OPACITY,0.0f);
1390 // Render and notify
1391 application.SendNotification();
1392 application.Render();
1394 // Check that the indicator is invisible
1395 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1397 // Do the "ShowIndicator" action
1398 Property::Map emptyMap;
1399 scrollBar.DoAction( "ShowIndicator", emptyMap );
1401 // Wait for the specified duration
1402 Wait(application, duration * 1000);
1404 // Render and notify
1405 application.SendNotification();
1406 application.Render();
1408 // Check that the indicator is now visible
1409 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1414 int UtcDaliToolkitScrollBarActionHideIndicator(void)
1416 ToolkitTestApplication application;
1418 // Create a scroll bar
1419 ScrollBar scrollBar = ScrollBar::New();
1420 DALI_TEST_CHECK( scrollBar );
1422 Stage::GetCurrent().Add( scrollBar );
1424 Actor indicator = scrollBar.GetScrollIndicator();
1425 DALI_TEST_CHECK( indicator );
1427 // Get the default duration to hide the indicator
1428 float duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_HIDE_DURATION );
1430 // Check that the default duration is greater than 0
1431 DALI_TEST_CHECK( duration > 0.0f );
1433 // Make the indicator visible
1434 indicator.SetProperty( Actor::Property::OPACITY,1.0f);
1436 // Render and notify
1437 application.SendNotification();
1438 application.Render();
1440 // Check that the indicator is visible
1441 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1443 // Do the "HideIndicator" action
1444 Property::Map emptyMap;
1445 scrollBar.DoAction( "HideIndicator", emptyMap );
1447 // Wait for the specified duration
1448 Wait(application, duration * 1000);
1450 // Render and notify
1451 application.SendNotification();
1452 application.Render();
1454 // Check that the indicator is now invisible
1455 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1460 int UtcDaliToolkitScrollBarActionShowTransientIndicator(void)
1462 ToolkitTestApplication application;
1464 // Create a scroll bar
1465 ScrollBar scrollBar = ScrollBar::New();
1466 DALI_TEST_CHECK( scrollBar );
1468 Stage::GetCurrent().Add( scrollBar );
1470 Actor indicator = scrollBar.GetScrollIndicator();
1471 DALI_TEST_CHECK( indicator );
1473 // Get the default duration to hide the indicator
1474 float duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_SHOW_DURATION );
1476 // Check that the default duration is greater than 0
1477 DALI_TEST_CHECK( duration > 0.0f );
1479 // Make the indicator invisible
1480 indicator.SetProperty( Actor::Property::OPACITY,0.0f);
1482 // Render and notify
1483 application.SendNotification();
1484 application.Render();
1486 // Check that the indicator is invisible
1487 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1489 // Do the "ShowIndicator" action
1490 Property::Map emptyMap;
1491 scrollBar.DoAction( "ShowTransientIndicator", emptyMap );
1493 // Wait for the specified duration
1494 Wait(application, duration * 1000);
1496 // Render and notify
1497 application.SendNotification();
1498 application.Render();
1500 // Check that the indicator is now visible
1501 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1503 // Get the default duration to hide the indicator
1504 float hideDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_HIDE_DURATION );
1505 float transientDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_TRANSIENT_DURATION );
1506 float totalVisibleDuration = hideDuration + transientDuration;
1508 // Check that the default duration is greater than 0
1509 DALI_TEST_CHECK( totalVisibleDuration > 0.0f );
1511 // Wait for the specified duration
1512 Wait(application, totalVisibleDuration * 1000);
1514 // Render and notify
1515 application.SendNotification();
1516 application.Render();
1518 // Check that the indicator is now invisible
1519 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1524 int UtcDaliToolkitScrollBarActionShowTransientIndicatorImmediate(void)
1526 ToolkitTestApplication application;
1528 // Create a scroll bar
1529 ScrollBar scrollBar = ScrollBar::New();
1530 DALI_TEST_CHECK( scrollBar );
1532 Stage::GetCurrent().Add( scrollBar );
1534 Actor indicator = scrollBar.GetScrollIndicator();
1535 DALI_TEST_CHECK( indicator );
1537 // Make the indicator invisible
1538 indicator.SetProperty( Actor::Property::OPACITY,0.0f);
1540 // Don't use a show animation; the indicator should appear immediately
1541 scrollBar.SetProperty( ScrollBar::Property::INDICATOR_SHOW_DURATION, 0.0f );
1542 float duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_SHOW_DURATION );
1543 DALI_TEST_EQUALS( duration, 0.0f, TEST_LOCATION );
1545 // Render and notify
1546 application.SendNotification();
1547 application.Render();
1549 // Do the "ShowIndicator" action
1550 Property::Map emptyMap;
1551 scrollBar.DoAction( "ShowTransientIndicator", emptyMap );
1553 // Wait for the specified duration
1556 // Render and notify
1557 application.SendNotification();
1558 application.Render();
1560 // Check that the indicator is now visible
1561 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1563 // Get the default duration to hide the indicator
1564 float hideDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_HIDE_DURATION );
1565 float transientDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_TRANSIENT_DURATION );
1566 float totalVisibleDuration = hideDuration + transientDuration;
1568 // Check that the default duration is greater than 0
1569 DALI_TEST_CHECK( totalVisibleDuration > 0.0f );
1571 // Wait for the specified duration
1572 Wait(application, totalVisibleDuration * 1000);
1574 // Render and notify
1575 application.SendNotification();
1576 application.Render();
1578 // Check that the indicator is now invisible
1579 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1584 int UtcDaliToolkitScrollBarActionShowTransientIndicatorDuringHide(void)
1586 ToolkitTestApplication application;
1588 // Create a scroll bar
1589 ScrollBar scrollBar = ScrollBar::New();
1590 DALI_TEST_CHECK( scrollBar );
1592 Stage::GetCurrent().Add( scrollBar );
1594 Actor indicator = scrollBar.GetScrollIndicator();
1595 DALI_TEST_CHECK( indicator );
1597 // Get the default duration to hide the indicator
1598 float duration = scrollBar.GetIndicatorHideDuration();
1600 // Check that the default duration is greater than 0
1601 DALI_TEST_CHECK( duration > 0.0f );
1603 // Make the indicator visible
1604 indicator.SetProperty( Actor::Property::OPACITY,1.0f);
1606 // Render and notify
1607 application.SendNotification();
1608 application.Render();
1610 // Check that the indicator is visible
1611 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1613 // Hide the indicator
1614 scrollBar.HideIndicator();
1616 // Wait for half the specified duration
1617 Wait(application, duration * 0.5f * 1000);
1619 // Render and notify
1620 application.SendNotification();
1621 application.Render();
1623 // Check that the indicator is now partially hidden
1624 DALI_TEST_CHECK( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ) < 1.0f );
1626 // Now interrupt the Hide with a DoAction( "ShowTransientIndicator" )
1628 // Get the default duration to hide the indicator
1629 duration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_SHOW_DURATION );
1631 // Check that the default duration is greater than 0
1632 DALI_TEST_CHECK( duration > 0.0f );
1634 // Do the "ShowIndicator" action
1635 Property::Map emptyMap;
1636 scrollBar.DoAction( "ShowTransientIndicator", emptyMap );
1638 // Wait for the specified duration
1639 Wait(application, duration * 1000);
1641 // Render and notify
1642 application.SendNotification();
1643 application.Render();
1645 // Check that the indicator is now visible
1646 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, TEST_LOCATION );
1648 // Get the default duration to hide the indicator
1649 float hideDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_HIDE_DURATION );
1650 float transientDuration = scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_TRANSIENT_DURATION );
1651 float totalVisibleDuration = hideDuration + transientDuration;
1653 // Check that the default duration is greater than 0
1654 DALI_TEST_CHECK( totalVisibleDuration > 0.0f );
1656 // Wait for the specified duration
1657 Wait(application, totalVisibleDuration * 1000);
1659 // Render and notify
1660 application.SendNotification();
1661 application.Render();
1663 // Check that the indicator is now invisible
1664 DALI_TEST_EQUALS( indicator.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, TEST_LOCATION );
1669 int UtcDaliToolkitScrollBarPanFinishedSignalP(void)
1671 ToolkitTestApplication application;
1673 // Create a vertical scroll bar
1674 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1675 DALI_TEST_CHECK( scrollBar );
1677 scrollBar.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1678 scrollBar.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1679 scrollBar.SetProperty( Actor::Property::SIZE, Vector3(20.0f, 800.0f, 0.0f) );
1681 // Set the indicator height to be fixed to 50.0f
1682 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
1683 scrollBar.SetIndicatorFixedHeight(50.0f);
1685 Stage::GetCurrent().Add( scrollBar );
1687 // Connect the pan finished signal
1688 ConnectionTracker connectionTracker;
1689 bool panFinished = false;
1690 scrollBar.PanFinishedSignal().Connect( &OnPanFinished );
1691 scrollBar.ConnectSignal( &connectionTracker, "panFinished", CallbackFunctor(&panFinished));
1693 // Render and notify
1694 application.SendNotification();
1695 application.Render();
1697 // Create a source actor that owns the scroll properties required by the scroll bar
1698 Actor sourceActor = Actor::New();
1699 Stage::GetCurrent().Add( sourceActor );
1701 // Register the scroll properties
1702 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1703 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1704 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
1705 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
1707 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1708 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1709 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1710 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1712 // Set the source of the scroll position properties.
1713 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1715 // Render and notify
1716 application.SendNotification();
1717 application.Render();
1719 // Perform a swipe gesture on the indicator
1720 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 1, 500);
1721 DALI_TEST_EQUALS( gOnPanFinishedCalled, true, TEST_LOCATION );
1722 DALI_TEST_EQUALS( panFinished, true, TEST_LOCATION );
1727 int UtcDaliToolkitScrollBarPanFinishedSignalN(void)
1729 ToolkitTestApplication application;
1731 // Create a vertical scroll bar
1732 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1733 DALI_TEST_CHECK( scrollBar );
1735 scrollBar.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1736 scrollBar.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1737 scrollBar.SetProperty( Actor::Property::SIZE, Vector3(20.0f, 800.0f, 0.0f) );
1739 // Set the indicator height to be fixed to 50.0f
1740 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
1741 scrollBar.SetIndicatorFixedHeight(50.0f);
1743 Stage::GetCurrent().Add( scrollBar );
1745 // Connect the pan finished signal
1746 ConnectionTracker connectionTracker;
1747 bool panFinished = false;
1748 scrollBar.PanFinishedSignal().Connect( &OnPanFinished );
1749 scrollBar.ConnectSignal( &connectionTracker, "panFinished", CallbackFunctor(&panFinished));
1751 // Render and notify
1752 application.SendNotification();
1753 application.Render();
1755 // Perform a vertical swipe gesture on the indicator when there is no source object set on the scroll bar
1756 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20, 500);
1757 DALI_TEST_EQUALS( gOnPanFinishedCalled, false, TEST_LOCATION );
1759 // Create a source actor that owns the scroll properties required by the scroll bar
1760 Actor sourceActor = Actor::New();
1761 Stage::GetCurrent().Add( sourceActor );
1763 // Register the scroll properties
1764 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1765 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1766 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
1767 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
1769 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1770 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1771 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1772 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1774 // Set the source of the scroll position properties.
1775 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1777 // Render and notify
1778 application.SendNotification();
1779 application.Render();
1781 // Perform a swipe gesture on the scroll bar but not on the indicator
1782 PerformGestureSwipe(application, Vector2(1.0f, 780.0f), Vector2(Vector2::YAXIS * -1.0f), 20, 2000);
1783 DALI_TEST_EQUALS( gOnPanFinishedCalled, false, TEST_LOCATION );
1784 DALI_TEST_EQUALS( panFinished, false, TEST_LOCATION );
1786 // Perform a swipe gesture on the indicator
1787 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20, 4000);
1788 DALI_TEST_EQUALS( gOnPanFinishedCalled, true, TEST_LOCATION );
1789 DALI_TEST_EQUALS( panFinished, true, TEST_LOCATION );
1794 int UtcDaliToolkitScrollBarScrollPositionIntervalReachedSignalP(void)
1796 ToolkitTestApplication application;
1798 // Create a vertical scroll bar
1799 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1800 DALI_TEST_CHECK( scrollBar );
1802 scrollBar.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1803 scrollBar.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1804 scrollBar.SetProperty( Actor::Property::SIZE, Vector3(20.0f, 800.0f, 0.0f) );
1806 Stage::GetCurrent().Add( scrollBar );
1807 ConnectionTracker connectionTracker;
1809 // Connect to the ScrollPositionIntervalReached signal
1810 bool intervalReached = false;
1811 scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
1812 scrollBar.ConnectSignal( &connectionTracker, "scrollPositionIntervalReached", CallbackFunctor(&intervalReached));
1814 // Render and notify
1815 application.SendNotification();
1816 application.Render();
1818 // Create a source actor that owns the scroll properties required by the scroll bar
1819 Actor sourceActor = Actor::New();
1820 Stage::GetCurrent().Add( sourceActor );
1822 // Register the scroll properties
1823 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1824 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1825 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 800.0f );
1826 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 2000.0f );
1828 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1829 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1830 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1831 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1833 // Set the source of the scroll position properties.
1834 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1836 // Render and notify
1837 application.SendNotification();
1838 application.Render();
1840 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
1841 Dali::Vector<float> positionIntervals;
1842 for( size_t i = 0; i != 10; ++i )
1844 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
1846 scrollBar.SetScrollPositionIntervals(positionIntervals);
1848 // Render and notify
1849 application.SendNotification();
1850 application.Render();
1853 gOnScrollPositionIntervalReachedSignalCalled = false;
1855 // Animate the scroll position to cross the specified value
1856 Animation animation = Animation::New(0.1f);
1857 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
1860 // Wait for 0.1 second
1861 Wait(application, 100);
1863 // Check that the signal callback is called
1864 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1865 DALI_TEST_EQUALS( intervalReached, true, TEST_LOCATION );
1868 gOnScrollPositionIntervalReachedSignalCalled = false;
1869 intervalReached = false;
1871 // Rest and clear the animation
1875 // Animate the scroll position to cross another specified value
1876 animation = Animation::New(0.1f);
1877 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -170.0f );
1880 // Wait for 0.1 second
1881 Wait(application, 100);
1883 // Check that the signal callback is called
1884 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1885 DALI_TEST_EQUALS( intervalReached, true, TEST_LOCATION );
1888 gOnScrollPositionIntervalReachedSignalCalled = false;
1889 intervalReached = false;
1891 // Rest and clear the animation
1895 // Animate the scroll position back to the previous value
1896 animation = Animation::New(0.1f);
1897 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
1900 // Wait for 0.1 second
1901 Wait(application, 100);
1903 // Check that the signal callback is called
1904 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1905 DALI_TEST_EQUALS( intervalReached, true, TEST_LOCATION );
1910 int UtcDaliToolkitScrollBarScrollPositionIntervalReachedSignalN(void)
1912 ToolkitTestApplication application;
1914 // Create a vertical scroll bar
1915 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1916 DALI_TEST_CHECK( scrollBar );
1918 scrollBar.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
1919 scrollBar.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1920 scrollBar.SetProperty( Actor::Property::SIZE, Vector3(20.0f, 800.0f, 0.0f) );
1922 Stage::GetCurrent().Add( scrollBar );
1924 // Connect to the ScrollPositionIntervalReached signal
1925 scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
1927 // Render and notify
1928 application.SendNotification();
1929 application.Render();
1931 // Create a source actor that owns the scroll properties required by the scroll bar
1932 Actor sourceActor = Actor::New();
1933 Stage::GetCurrent().Add( sourceActor );
1935 // Register the scroll properties
1936 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1937 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1938 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 800.0f );
1939 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 2000.0f );
1941 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1942 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1943 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1944 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1946 // Set the source of the scroll position properties.
1947 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1949 // Render and notify
1950 application.SendNotification();
1951 application.Render();
1953 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
1954 Dali::Vector<float> positionIntervals;
1955 for( size_t i = 0; i != 10; ++i )
1957 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
1959 scrollBar.SetScrollPositionIntervals(positionIntervals);
1961 // Render and notify
1962 application.SendNotification();
1963 application.Render();
1966 gOnScrollPositionIntervalReachedSignalCalled = false;
1968 // Animate the scroll position not to cross the specified value
1969 Animation animation = Animation::New(0.1f);
1970 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -70.0f );
1973 // Wait for 0.1 second
1974 Wait(application, 100);
1976 // Check that the signal callback is not called
1977 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, false, TEST_LOCATION );
1979 // Rest and clear the animation
1983 // Animate the scroll position to cross another specified value
1984 animation = Animation::New(0.1f);
1985 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
1988 // Wait for 0.1 second
1989 Wait(application, 100);
1991 // Check that the signal callback is called
1992 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );