2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali-toolkit-test-suite-utils.h>
22 #include <dali-toolkit/dali-toolkit.h>
23 #include <dali/integration-api/events/pan-gesture-event.h>
26 using namespace Toolkit;
28 void dali_scrollbar_startup(void)
30 test_return_value = TET_UNDEF;
33 void dali_scrollbar_cleanup(void)
35 test_return_value = TET_PASS;
41 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
43 // Generate a PanGestureEvent to send to Core
44 Integration::PanGestureEvent GeneratePan(
46 const Vector2& previousPosition,
47 const Vector2& currentPosition,
48 unsigned long timeDelta,
49 unsigned int numberOfTouches = 1)
51 Integration::PanGestureEvent pan(state);
53 pan.previousPosition = previousPosition;
54 pan.currentPosition = currentPosition;
55 pan.timeDelta = timeDelta;
56 pan.numberOfTouches = numberOfTouches;
62 * Helper to generate PanGestureEvent
64 * @param[in] application Application instance
65 * @param[in] state The Gesture State
66 * @param[in] pos The current position of touch.
68 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
72 if( (state == Gesture::Started) ||
73 (state == Gesture::Possible) )
79 application.ProcessEvent(GeneratePan(state, last, pos, RENDER_FRAME_INTERVAL));
86 * Simulate time passed by.
88 * @note this will always process at least 1 frame (1/60 sec)
90 * @param application Test application instance
91 * @param duration Time to pass in milliseconds.
92 * @return The actual time passed in milliseconds
94 int Wait(ToolkitTestApplication& application, int duration = 0)
98 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
100 application.SendNotification();
101 application.Render(RENDER_FRAME_INTERVAL);
102 time += RENDER_FRAME_INTERVAL;
110 static bool gOnPanFinishedCalled; ///< Whether the PanFinished signal was invoked.
111 static bool gOnScrollPositionIntervalReachedSignalCalled; ///< Whether the ScrollPositionIntervalReached signal was invoked.
114 * Invoked when pan gesture is finished on the scroll indicator.
116 static void OnPanFinished()
118 gOnPanFinishedCalled = true;
121 struct CallbackFunctor
123 CallbackFunctor(bool* callbackFlag)
124 : mCallbackFlag( callbackFlag )
130 *mCallbackFlag = true;
136 * Invoked when the current scroll position of the scrollable content goes above or below the values
137 * specified by SCROLL_POSITION_INTERVALS property.
139 * @param[in] position The current scroll position.
141 static void OnScrollPositionIntervalReached( float position )
143 gOnScrollPositionIntervalReachedSignalCalled = true;
146 static Vector2 PerformGestureSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames)
148 gOnPanFinishedCalled = false;
150 // Now do a pan starting from (start) and heading (direction)
152 SendPan(application, Gesture::Possible, pos);
153 SendPan(application, Gesture::Started, pos);
156 for(int i = 0; i < frames; i++)
158 pos += direction; // Move in this direction
159 SendPan(application, Gesture::Continuing, pos);
163 pos += direction; // Move in this direction.
164 SendPan(application, Gesture::Finished, pos);
172 int UtcDaliToolkitScrollBarConstructorP(void)
174 ToolkitTestApplication application;
177 DALI_TEST_CHECK( !scrollBar );
181 int UtcDaliToolkitScrollBarCopyConstructorP(void)
183 ToolkitTestApplication application;
185 ScrollBar scrollBar = ScrollBar::New();
186 scrollBar.SetProperty( ScrollBar::Property::INDICATOR_FIXED_HEIGHT, 38.2f );
188 ScrollBar copy( scrollBar );
189 DALI_TEST_CHECK( copy );
190 DALI_TEST_CHECK( copy.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) == scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) );
194 int UtcDaliToolkitScrollBarAssignmentOperatorP(void)
196 ToolkitTestApplication application;
198 ScrollBar scrollBar = ScrollBar::New();
199 scrollBar.SetProperty( ScrollBar::Property::INDICATOR_FIXED_HEIGHT, 38.2f );
201 ScrollBar copy = scrollBar;
202 DALI_TEST_CHECK( copy );
203 DALI_TEST_CHECK( copy.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) == scrollBar.GetProperty<float>( ScrollBar::Property::INDICATOR_FIXED_HEIGHT ) );
207 int UtcDaliScrollBarDestructorP(void)
209 ToolkitTestApplication application;
211 ScrollBar* scrollBar = new ScrollBar();
214 DALI_TEST_CHECK( true );
218 int UtcDaliToolkitScrollBarNewP(void)
220 ToolkitTestApplication application;
222 ScrollBar scrollBar = ScrollBar::New();
223 DALI_TEST_CHECK( scrollBar );
226 ScrollBar vertical = ScrollBar::New(ScrollBar::Vertical);
227 DALI_TEST_CHECK( vertical );
228 DALI_TEST_CHECK( vertical.GetScrollDirection() == ScrollBar::Vertical );
230 Property::Value value = vertical.GetProperty(ScrollBar::Property::SCROLL_DIRECTION);
231 std::string scrollDirection = value.Get<std::string>();
232 DALI_TEST_EQUALS( scrollDirection, "Vertical", TEST_LOCATION );
234 ScrollBar horizontal = ScrollBar::New(ScrollBar::Horizontal);
235 DALI_TEST_CHECK( horizontal );
236 DALI_TEST_CHECK( horizontal.GetScrollDirection() == ScrollBar::Horizontal );
237 value = vertical.GetProperty(ScrollBar::Property::SCROLL_DIRECTION);
238 scrollDirection = value.Get<std::string>();
239 DALI_TEST_EQUALS( scrollDirection, "Horizontal", TEST_LOCATION );
244 int UtcDaliToolkitScrollBarCreateP(void)
246 ToolkitTestApplication application;
248 TypeRegistry typeRegistry = TypeRegistry::Get();
249 DALI_TEST_CHECK( typeRegistry );
251 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "ScrollBar" );
252 DALI_TEST_CHECK( typeInfo );
254 BaseHandle handle = typeInfo.CreateInstance();
255 DALI_TEST_CHECK( handle );
257 ScrollBar scrollBar = ScrollBar::DownCast( handle );
258 DALI_TEST_CHECK( scrollBar );
260 scrollBar.SetProperty(ScrollBar::Property::SCROLL_DIRECTION, "Vertical");
261 scrollBar.SetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY, "Fixed");
263 DALI_TEST_EQUALS( scrollBar.GetScrollDirection(), Toolkit::ScrollBar::Vertical, TEST_LOCATION );
264 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Fixed, TEST_LOCATION );
266 scrollBar.SetProperty(ScrollBar::Property::SCROLL_DIRECTION, "Horizontal");
267 scrollBar.SetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY, "Variable");
269 DALI_TEST_EQUALS( scrollBar.GetScrollDirection(), Toolkit::ScrollBar::Horizontal, TEST_LOCATION );
270 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Variable, TEST_LOCATION );
275 int UtcDaliToolkitScrollBarDownCastP(void)
277 ToolkitTestApplication application;
279 ScrollBar scrollBar1 = ScrollBar::New();
280 BaseHandle object( scrollBar1 );
282 ScrollBar scrollBar2 = ScrollBar::DownCast( object );
283 DALI_TEST_CHECK( scrollBar2 );
285 ScrollBar scrollBar3 = DownCast< ScrollBar >( object );
286 DALI_TEST_CHECK( scrollBar3 );
290 int UtcDaliToolkitScrollBarDownCastN(void)
292 ToolkitTestApplication application;
294 BaseHandle uninitializedObject;
295 ScrollBar scrollBar1 = ScrollBar::DownCast( uninitializedObject );
296 DALI_TEST_CHECK( !scrollBar1 );
298 ScrollBar scrollBar2 = DownCast< ScrollBar >( uninitializedObject );
299 DALI_TEST_CHECK( !scrollBar2 );
303 int UtcDaliToolkitScrollBarSetScrollPropertySourceP(void)
305 ToolkitTestApplication application;
307 // Create a vertical scroll bar
308 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
309 DALI_TEST_CHECK( scrollBar );
310 DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::Vertical );
312 float scrollBarHeight = 100.0f;
313 scrollBar.SetSize(20.0f, scrollBarHeight, 0.0f);
314 Stage::GetCurrent().Add( scrollBar );
316 // Create a source actor that owns the scroll properties required by the scroll bar
317 Actor sourceActor = Actor::New();
318 Stage::GetCurrent().Add( sourceActor );
320 // Register the scroll properties
321 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
322 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
323 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
324 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
326 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
327 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
328 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
329 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
331 // Set the source of the scroll position properties.
332 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
335 application.SendNotification();
336 application.Render();
338 Actor indicator = scrollBar.GetScrollIndicator();
339 DALI_TEST_CHECK( indicator );
341 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
342 // i.e. The bigger the content size, the smaller the indicator size
343 float indicatorHeight = indicator.GetCurrentSize().y;
344 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
346 // Decrease the content length
347 sourceActor.SetProperty( propertyScrollContentSize, 250.0f );
350 application.SendNotification();
351 application.Render();
353 // Check that the indicator size is changed accordingly
354 indicatorHeight = indicator.GetCurrentSize().y;
355 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 250.0f, TEST_LOCATION );
357 // As scroll position is 0, check that the indicator position should be 0.0f.
358 float indicatorPosition = indicator.GetCurrentPosition().y;
359 DALI_TEST_EQUALS( indicatorPosition, 0.0f, TEST_LOCATION );
361 // Set the scroll position to the middle
362 sourceActor.SetProperty( propertyScrollPosition, -50.0f );
365 application.SendNotification();
366 application.Render();
368 // Check that the indicator should be in the middle of the scroll bar
369 indicatorPosition = indicator.GetCurrentPosition().y;
370 DALI_TEST_EQUALS( indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.5f, TEST_LOCATION );
372 // Set the scroll position to the maximum
373 sourceActor.SetProperty( propertyScrollPosition, -100.0f );
376 application.SendNotification();
377 application.Render();
379 // Check that the indicator should be in the end of the scroll bar
380 indicatorPosition = indicator.GetCurrentPosition().y;
381 DALI_TEST_EQUALS( indicatorPosition, scrollBarHeight - indicatorHeight, TEST_LOCATION );
383 // Increase the maximum scroll position to double
384 sourceActor.SetProperty( propertyMaxScrollPosition, 200.0f );
387 application.SendNotification();
388 application.Render();
390 // Check that the indicator should be now in the middle of the scroll bar
391 indicatorPosition = indicator.GetCurrentPosition().y;
392 DALI_TEST_EQUALS( indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.5f, TEST_LOCATION );
394 // Create another source actor
395 Actor newSourceActor = Actor::New();
396 Stage::GetCurrent().Add( newSourceActor );
398 // Register the scroll properties
399 Property::Index newPropertyScrollPosition = newSourceActor.RegisterProperty( "sourcePosition", 0.0f );
400 Property::Index newPropertyMinScrollPosition = newSourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
401 Property::Index newPropertyMaxScrollPosition = newSourceActor.RegisterProperty( "sourcePositionMax", 200.0f );
402 Property::Index newPropertyScrollContentSize = newSourceActor.RegisterProperty( "sourceContentSize", 400.0f );
404 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourcePosition" ), newPropertyScrollPosition, TEST_LOCATION );
405 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourcePositionMin" ), newPropertyMinScrollPosition, TEST_LOCATION );
406 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourcePositionMax" ), newPropertyMaxScrollPosition, TEST_LOCATION );
407 DALI_TEST_EQUALS( newSourceActor.GetPropertyIndex( "sourceContentSize" ), newPropertyScrollContentSize, TEST_LOCATION );
409 // Change the source of the scroll position properties to be the new source actor.
410 scrollBar.SetScrollPropertySource(newSourceActor, newPropertyScrollPosition, newPropertyMinScrollPosition, newPropertyMaxScrollPosition, newPropertyScrollContentSize);
413 application.SendNotification();
414 application.Render();
416 // Check that the indicator size is changed accordingly
417 indicatorHeight = indicator.GetCurrentSize().y;
418 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 400.0f, TEST_LOCATION );
420 // Check that the indicator position goes back to the beginning of the scroll bar
421 indicatorPosition = indicator.GetCurrentPosition().y;
422 DALI_TEST_EQUALS( indicatorPosition, 0.0f, TEST_LOCATION );
424 // Set the scroll position to one fifth of the maximum
425 newSourceActor.SetProperty( propertyScrollPosition, -40.0f );
428 application.SendNotification();
429 application.Render();
431 // Check that the indicator should be in one fifth from the beginning of the scroll bar
432 indicatorPosition = indicator.GetCurrentPosition().y;
433 DALI_TEST_EQUALS( indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.2f, TEST_LOCATION );
438 int UtcDaliToolkitScrollBarSetScrollPropertySourceN(void)
440 ToolkitTestApplication application;
442 // Create a scroll bar
443 ScrollBar scrollBar = ScrollBar::New();
444 DALI_TEST_CHECK( scrollBar );
446 // Set empty handle of source object and invalid source property index.
448 scrollBar.SetScrollPropertySource(sourceActor, Property::INVALID_INDEX, Property::INVALID_INDEX, Property::INVALID_INDEX, Property::INVALID_INDEX);
450 DALI_TEST_CHECK( true );
454 int UtcDaliToolkitScrollBarSetScrollIndicatorP(void)
456 ToolkitTestApplication application;
458 // Create a scroll bar
459 ScrollBar scrollBar = ScrollBar::New();
460 DALI_TEST_CHECK( scrollBar );
462 Actor indicator = scrollBar.GetScrollIndicator();
463 DALI_TEST_CHECK( indicator );
465 // Set a new indicator
466 Actor newIndicator = Actor::New();
467 scrollBar.SetScrollIndicator(newIndicator);
469 // Check that the new indicator is successfully set
470 DALI_TEST_CHECK( indicator != scrollBar.GetScrollIndicator() );
471 DALI_TEST_CHECK( newIndicator == scrollBar.GetScrollIndicator() );
476 int UtcDaliToolkitScrollBarSetScrollIndicatorN(void)
478 ToolkitTestApplication application;
480 // Create a scroll bar
481 ScrollBar scrollBar = ScrollBar::New();
482 DALI_TEST_CHECK( scrollBar );
484 Actor indicator = scrollBar.GetScrollIndicator();
485 DALI_TEST_CHECK( indicator );
487 // Try to set an uninitialized actor as the indicator
488 Actor uninitializedIndicator;
489 scrollBar.SetScrollIndicator(uninitializedIndicator);
491 // Check that the uninitialized actor can not be set as the indicator
492 DALI_TEST_CHECK( indicator == scrollBar.GetScrollIndicator() );
493 DALI_TEST_CHECK( uninitializedIndicator != scrollBar.GetScrollIndicator() );
498 int UtcDaliToolkitScrollBarGetScrollIndicatorP(void)
500 ToolkitTestApplication application;
502 // Create a scroll bar
503 ScrollBar scrollBar = ScrollBar::New();
504 DALI_TEST_CHECK( scrollBar );
506 Actor indicator = scrollBar.GetScrollIndicator();
507 DALI_TEST_CHECK( indicator );
509 // Set a new indicator
510 Actor newIndicator = Actor::New();
511 scrollBar.SetScrollIndicator(newIndicator);
513 // Check that the new indicator is successfully set
514 DALI_TEST_CHECK( scrollBar.GetScrollIndicator() );
515 DALI_TEST_CHECK( indicator != scrollBar.GetScrollIndicator() );
516 DALI_TEST_CHECK( newIndicator == scrollBar.GetScrollIndicator() );
521 int UtcDaliToolkitScrollBarGetScrollIndicatorN(void)
523 ToolkitTestApplication application;
525 // Create a scroll bar
526 ScrollBar scrollBar = ScrollBar::New();
527 DALI_TEST_CHECK( scrollBar );
529 Actor indicator = scrollBar.GetScrollIndicator();
530 DALI_TEST_CHECK( indicator );
532 // Try to set an uninitialized actor as the indicator
533 Actor uninitializedIndicator;
534 scrollBar.SetScrollIndicator(uninitializedIndicator);
536 // Check that the indicator has not been changed
537 DALI_TEST_CHECK( indicator == scrollBar.GetScrollIndicator() );
538 DALI_TEST_CHECK( uninitializedIndicator != scrollBar.GetScrollIndicator() );
543 int UtcDaliToolkitScrollBarSetScrollPositionIntervalsP(void)
545 ToolkitTestApplication application;
547 // Create a vertical scroll bar
548 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
549 DALI_TEST_CHECK( scrollBar );
551 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
552 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
553 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
555 Stage::GetCurrent().Add( scrollBar );
557 // Connect to the ScrollPositionIntervalReached signal
558 scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
561 application.SendNotification();
562 application.Render();
564 // Create a source actor that owns the scroll properties required by the scroll bar
565 Actor sourceActor = Actor::New();
566 Stage::GetCurrent().Add( sourceActor );
568 // Register the scroll properties
569 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
570 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
571 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 800.0f );
572 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 2000.0f );
574 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
575 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
576 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
577 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
579 // Set the source of the scroll position properties.
580 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
583 application.SendNotification();
584 application.Render();
586 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
587 Dali::Vector<float> positionIntervals;
588 for( size_t i = 0; i != 10; ++i )
590 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
592 scrollBar.SetScrollPositionIntervals(positionIntervals);
594 // Get the list of scroll position intervals for notification
595 Dali::Vector<float> results = scrollBar.GetScrollPositionIntervals();
597 // Check that the result is the same as the list previously set.
598 DALI_TEST_EQUALS( positionIntervals.Count(), results.Count(), TEST_LOCATION );
599 DALI_TEST_EQUALS( positionIntervals[0], results[0], TEST_LOCATION );
600 DALI_TEST_EQUALS( positionIntervals[1], results[1], TEST_LOCATION );
601 DALI_TEST_EQUALS( positionIntervals[2], results[2], TEST_LOCATION );
602 DALI_TEST_EQUALS( positionIntervals[3], results[3], TEST_LOCATION );
603 DALI_TEST_EQUALS( positionIntervals[4], results[4], TEST_LOCATION );
604 DALI_TEST_EQUALS( positionIntervals[5], results[5], TEST_LOCATION );
605 DALI_TEST_EQUALS( positionIntervals[6], results[6], TEST_LOCATION );
606 DALI_TEST_EQUALS( positionIntervals[7], results[7], TEST_LOCATION );
607 DALI_TEST_EQUALS( positionIntervals[8], results[8], TEST_LOCATION );
608 DALI_TEST_EQUALS( positionIntervals[9], results[9], TEST_LOCATION );
611 gOnScrollPositionIntervalReachedSignalCalled = false;
613 // Animate the scroll position to cross the specified value
614 Animation animation = Animation::New(0.1f);
615 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
618 // Wait for 0.1 second
619 Wait(application, 100);
621 // Check that the signal callback is called
622 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
625 gOnScrollPositionIntervalReachedSignalCalled = false;
627 // Rest and clear the animation
631 // Animate the scroll position to cross another specified value
632 animation = Animation::New(0.1f);
633 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -170.0f );
636 // Wait for 0.1 second
637 Wait(application, 100);
639 // Check that the signal callback is called
640 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
643 gOnScrollPositionIntervalReachedSignalCalled = false;
645 // Rest and clear the animation
649 // Animate the scroll position back to the previous value
650 animation = Animation::New(0.1f);
651 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
654 // Wait for 0.1 second
655 Wait(application, 100);
657 // Check that the signal callback is called
658 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
663 int UtcDaliToolkitScrollBarGetScrollPositionIntervalsP(void)
665 ToolkitTestApplication application;
667 // Create a vertical scroll bar
668 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
669 DALI_TEST_CHECK( scrollBar );
671 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
672 Dali::Vector<float> positionIntervals;
673 for( size_t i = 0; i != 10; ++i )
675 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
677 scrollBar.SetScrollPositionIntervals(positionIntervals);
679 // Get the list of scroll position intervals for notification
680 Dali::Vector<float> results = scrollBar.GetScrollPositionIntervals();
682 // Check that the result is the same as the list previously set.
683 DALI_TEST_EQUALS( positionIntervals.Count(), results.Count(), TEST_LOCATION );
684 DALI_TEST_EQUALS( positionIntervals[0], results[0], TEST_LOCATION );
685 DALI_TEST_EQUALS( positionIntervals[1], results[1], TEST_LOCATION );
686 DALI_TEST_EQUALS( positionIntervals[2], results[2], TEST_LOCATION );
687 DALI_TEST_EQUALS( positionIntervals[3], results[3], TEST_LOCATION );
688 DALI_TEST_EQUALS( positionIntervals[4], results[4], TEST_LOCATION );
689 DALI_TEST_EQUALS( positionIntervals[5], results[5], TEST_LOCATION );
690 DALI_TEST_EQUALS( positionIntervals[6], results[6], TEST_LOCATION );
691 DALI_TEST_EQUALS( positionIntervals[7], results[7], TEST_LOCATION );
692 DALI_TEST_EQUALS( positionIntervals[8], results[8], TEST_LOCATION );
693 DALI_TEST_EQUALS( positionIntervals[9], results[9], TEST_LOCATION );
698 int UtcDaliToolkitScrollBarGetScrollDirectionP(void)
700 ToolkitTestApplication application;
702 // Create a vertical scroll bar
703 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
704 DALI_TEST_CHECK( scrollBar );
705 DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::Vertical );
707 // Change the direction of scroll bar to horizontal
708 scrollBar.SetScrollDirection(ScrollBar::Horizontal);
709 DALI_TEST_CHECK( scrollBar.GetScrollDirection() == ScrollBar::Horizontal );
714 int UtcDaliToolkitScrollBarSetIndicatorHeightPolicyP(void)
716 ToolkitTestApplication application;
718 // Create a scroll bar
719 ScrollBar scrollBar = ScrollBar::New();
720 DALI_TEST_CHECK( scrollBar );
722 float scrollBarHeight = 100.0f;
723 scrollBar.SetSize(20.0f, scrollBarHeight, 0.0f);
724 Stage::GetCurrent().Add( scrollBar );
726 // Create a source actor that owns the scroll properties required by the scroll bar
727 Actor sourceActor = Actor::New();
728 Stage::GetCurrent().Add( sourceActor );
730 // Register the scroll properties
731 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
732 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
733 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
734 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
736 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
737 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
738 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
739 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
741 // Set the source of the scroll position properties.
742 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
745 application.SendNotification();
746 application.Render();
748 Actor indicator = scrollBar.GetScrollIndicator();
749 DALI_TEST_CHECK( indicator );
751 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
752 // i.e. The bigger the content size, the smaller the indicator size
753 float indicatorHeight = indicator.GetCurrentSize().y;
754 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
756 // Set the indicator height to be fixed to 50.0f
757 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
758 scrollBar.SetIndicatorFixedHeight(50.0f);
760 Property::Value value = scrollBar.GetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY);
761 DALI_TEST_EQUALS(value.Get<std::string>(), "Fixed", TEST_LOCATION );
764 application.SendNotification();
765 application.Render();
767 // Check that the indicator size should be 50.0f
768 indicatorHeight = indicator.GetCurrentSize().y;
769 DALI_TEST_EQUALS( indicatorHeight, 50.0f, TEST_LOCATION );
771 // Set the indicator height to be variable
772 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Variable);
773 value = scrollBar.GetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY);
774 DALI_TEST_EQUALS(value.Get<std::string>(), "Variable", TEST_LOCATION );
777 application.SendNotification();
778 application.Render();
780 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
781 indicatorHeight = indicator.GetCurrentSize().y;
782 DALI_TEST_EQUALS( indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION );
787 int UtcDaliToolkitScrollBarGetIndicatorHeightPolicyP(void)
789 ToolkitTestApplication application;
791 // Create a scroll bar
792 ScrollBar scrollBar = ScrollBar::New();
793 DALI_TEST_CHECK( scrollBar );
795 // Set the indicator height to be fixed
796 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
797 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Fixed, TEST_LOCATION );
799 // Set the indicator height to be variable
800 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Variable);
801 DALI_TEST_EQUALS( scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::Variable, TEST_LOCATION );
806 int UtcDaliToolkitScrollBarSetIndicatorFixedHeightP(void)
808 ToolkitTestApplication application;
810 // Create a scroll bar
811 ScrollBar scrollBar = ScrollBar::New();
812 DALI_TEST_CHECK( scrollBar );
814 float scrollBarHeight = 100.0f;
815 scrollBar.SetSize(20.0f, scrollBarHeight, 0.0f);
816 Stage::GetCurrent().Add( scrollBar );
818 Actor indicator = scrollBar.GetScrollIndicator();
819 DALI_TEST_CHECK( indicator );
821 // Set the indicator height to be fixed to 50.0f
822 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
823 scrollBar.SetIndicatorFixedHeight(50.0f);
826 application.SendNotification();
827 application.Render();
829 // Check that the indicator size should be 50.0f
830 DALI_TEST_EQUALS( indicator.GetCurrentSize().y, 50.0f, TEST_LOCATION );
832 // Set the indicator height to be fixed to 25.0f
833 scrollBar.SetIndicatorFixedHeight(25.0f);
836 application.SendNotification();
837 application.Render();
839 // Check that the indicator size should be 25.0f
840 DALI_TEST_EQUALS( indicator.GetCurrentSize().y, 25.0f, TEST_LOCATION );
845 int UtcDaliToolkitScrollBarGetIndicatorFixedHeightP(void)
847 ToolkitTestApplication application;
849 // Create a scroll bar
850 ScrollBar scrollBar = ScrollBar::New();
851 DALI_TEST_CHECK( scrollBar );
853 // Set the fixed indicator height to be 50.0f
854 scrollBar.SetIndicatorFixedHeight(50.0f);
856 // Check that the indicator size should be 50.0f
857 DALI_TEST_EQUALS( scrollBar.GetIndicatorFixedHeight(), 50.0f, TEST_LOCATION );
859 // Set the indicator height to be fixed to 25.0f
860 scrollBar.SetIndicatorFixedHeight(25.0f);
862 // Check that the indicator size should be 50.0f
863 DALI_TEST_EQUALS( scrollBar.GetIndicatorFixedHeight(), 25.0f, TEST_LOCATION );
868 int UtcDaliToolkitScrollBarSetIndicatorShowDurationP(void)
870 ToolkitTestApplication application;
872 // Create a scroll bar
873 ScrollBar scrollBar = ScrollBar::New();
874 DALI_TEST_CHECK( scrollBar );
876 Stage::GetCurrent().Add( scrollBar );
878 Actor indicator = scrollBar.GetScrollIndicator();
879 DALI_TEST_CHECK( indicator );
881 // Set the duration to show the indicator to be 0.35 second
882 scrollBar.SetIndicatorShowDuration(0.35);
883 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.35f, TEST_LOCATION );
885 // Make the indicator invisible
886 indicator.SetOpacity(0.0f);
889 application.SendNotification();
890 application.Render();
892 // Check that the indicator is invisible
893 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
895 // Show the indicator
896 scrollBar.ShowIndicator();
898 // Wait for 0.35 second
899 Wait(application, 350);
902 application.SendNotification();
903 application.Render();
905 // Check that the indicator is now visible
906 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
908 // Set the duration to show the indicator to be 0.75 second
909 scrollBar.SetIndicatorShowDuration(0.75);
910 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.75f, TEST_LOCATION );
912 // Make the indicator invisible
913 indicator.SetOpacity(0.0f);
916 application.SendNotification();
917 application.Render();
919 // Check that the indicator is invisible
920 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
922 // Show the indicator
923 scrollBar.ShowIndicator();
925 // Wait for 0.35 second first
926 Wait(application, 350);
929 application.SendNotification();
930 application.Render();
932 // Check that the indicator is not fully visible yet
933 DALI_TEST_CHECK( indicator.GetCurrentOpacity() != 1.0f );
935 // Wait for another 0.4 second
936 Wait(application, 400);
939 application.SendNotification();
940 application.Render();
942 // Check that the indicator is now fully visible
943 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
948 int UtcDaliToolkitScrollBarSetIndicatorShowDurationN(void)
950 ToolkitTestApplication application;
952 // Create a scroll bar
953 ScrollBar scrollBar = ScrollBar::New();
954 DALI_TEST_CHECK( scrollBar );
956 Stage::GetCurrent().Add( scrollBar );
958 Actor indicator = scrollBar.GetScrollIndicator();
959 DALI_TEST_CHECK( indicator );
961 // Get the default duration to show the indicator
962 float duration = scrollBar.GetIndicatorShowDuration();
964 // Check that the default duration is greater than 0
965 DALI_TEST_CHECK( duration > 0.0f );
967 // Make the indicator invisible
968 indicator.SetOpacity(0.0f);
971 application.SendNotification();
972 application.Render();
974 // Check that the indicator is invisible
975 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
977 // Show the indicator
978 scrollBar.ShowIndicator();
980 // Wait for the specified duration
981 Wait(application, duration * 1000);
984 application.SendNotification();
985 application.Render();
987 // Check that the indicator is now visible
988 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
990 // Now set the duration to show the indicator to be a negative value (which should be ignored and therefore means instant)
991 scrollBar.SetIndicatorShowDuration(-0.25f);
992 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), -0.25f, TEST_LOCATION );
994 // Make the indicator invisible
995 indicator.SetOpacity(0.0f);
998 application.SendNotification();
999 application.Render();
1001 // Check that the indicator is invisible
1002 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1004 // Show the indicator
1005 scrollBar.ShowIndicator();
1007 // Render and notify
1008 application.SendNotification();
1009 application.Render();
1011 // Check that the indicator becomes instantly visible in the next frame
1012 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1017 int UtcDaliToolkitScrollBarGetIndicatorShowDurationP(void)
1019 ToolkitTestApplication application;
1021 // Create a scroll bar
1022 ScrollBar scrollBar = ScrollBar::New();
1023 DALI_TEST_CHECK( scrollBar );
1025 // Set the duration to show the indicator to be 0.35 second
1026 scrollBar.SetIndicatorShowDuration(0.35f);
1028 // Check that the duration to show the indicator is 0.35 second
1029 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.35f, TEST_LOCATION );
1031 // Set the duration to show the indicator to be 0.75 second
1032 scrollBar.SetIndicatorShowDuration(0.75f);
1034 // Check that the duration to show the indicator is 0.75 second
1035 DALI_TEST_EQUALS( scrollBar.GetIndicatorShowDuration(), 0.75f, TEST_LOCATION );
1040 int UtcDaliToolkitScrollBarSetIndicatorHideDurationP(void)
1042 ToolkitTestApplication application;
1044 // Create a scroll bar
1045 ScrollBar scrollBar = ScrollBar::New();
1046 DALI_TEST_CHECK( scrollBar );
1048 Stage::GetCurrent().Add( scrollBar );
1050 Actor indicator = scrollBar.GetScrollIndicator();
1051 DALI_TEST_CHECK( indicator );
1053 // Set the duration to hide the indicator to be 0.15 second
1054 scrollBar.SetIndicatorHideDuration(0.15f);
1055 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.15f, TEST_LOCATION );
1057 // Make the indicator visible
1058 indicator.SetOpacity(1.0f);
1060 // Render and notify
1061 application.SendNotification();
1062 application.Render();
1064 // Check that the indicator is visible
1065 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1067 // Hide the indicator
1068 scrollBar.HideIndicator();
1070 // Wait for 0.15 second
1071 Wait(application, 150);
1073 // Render and notify
1074 application.SendNotification();
1075 application.Render();
1077 // Check that the indicator is now invisible
1078 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1080 // Set the duration to hide the indicator to be 0.65 second
1081 scrollBar.SetIndicatorHideDuration(0.65f);
1082 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.65f, TEST_LOCATION );
1084 // Make the indicator visible
1085 indicator.SetOpacity(1.0f);
1087 // Render and notify
1088 application.SendNotification();
1089 application.Render();
1091 // Check that the indicator is visible
1092 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1094 // Hide the indicator
1095 scrollBar.HideIndicator();
1097 // Wait for 0.15 second first
1098 Wait(application, 150);
1100 // Render and notify
1101 application.SendNotification();
1102 application.Render();
1104 // Check that the indicator is not fully invisible yet
1105 DALI_TEST_CHECK( indicator.GetCurrentOpacity() != 0.0f );
1107 // Wait for another 0.5 second
1108 Wait(application, 500);
1110 // Render and notify
1111 application.SendNotification();
1112 application.Render();
1114 // Check that the indicator is now fully invisible
1115 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1120 int UtcDaliToolkitScrollBarSetIndicatorHideDurationN(void)
1122 ToolkitTestApplication application;
1124 // Create a scroll bar
1125 ScrollBar scrollBar = ScrollBar::New();
1126 DALI_TEST_CHECK( scrollBar );
1128 Stage::GetCurrent().Add( scrollBar );
1130 Actor indicator = scrollBar.GetScrollIndicator();
1131 DALI_TEST_CHECK( indicator );
1133 // Get the default duration to hide the indicator
1134 float duration = scrollBar.GetIndicatorHideDuration();
1136 // Check that the default duration is greater than 0
1137 DALI_TEST_CHECK( duration > 0.0f );
1139 // Make the indicator visible
1140 indicator.SetOpacity(1.0f);
1142 // Render and notify
1143 application.SendNotification();
1144 application.Render();
1146 // Check that the indicator is visible
1147 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1149 // Hide the indicator
1150 scrollBar.HideIndicator();
1152 // Wait for the specified duration
1153 Wait(application, duration * 1000);
1155 // Render and notify
1156 application.SendNotification();
1157 application.Render();
1159 // Check that the indicator is now invisible
1160 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1162 // Now set the duration to hide the indicator to be a negative value (which should be ignored and therefore means instant)
1163 scrollBar.SetIndicatorHideDuration(-0.25f);
1164 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), -0.25f, TEST_LOCATION );
1166 // Make the indicator visible
1167 indicator.SetOpacity(1.0f);
1169 // Render and notify
1170 application.SendNotification();
1171 application.Render();
1173 // Check that the indicator is visible
1174 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1176 // Hide the indicator
1177 scrollBar.HideIndicator();
1179 // Render and notify
1180 application.SendNotification();
1181 application.Render();
1183 // Check that the indicator becomes instantly invisible in the next frame
1184 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1189 int UtcDaliToolkitScrollBarGetIndicatorHideDurationP(void)
1191 ToolkitTestApplication application;
1193 // Create a scroll bar
1194 ScrollBar scrollBar = ScrollBar::New();
1195 DALI_TEST_CHECK( scrollBar );
1197 // Set the duration to hide the indicator to be 0.15 second
1198 scrollBar.SetIndicatorHideDuration(0.15f);
1200 // Check that the duration to hide the indicator is 0.15 second
1201 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.15f, TEST_LOCATION );
1203 // Set the duration to hide the indicator to be 0.65 second
1204 scrollBar.SetIndicatorHideDuration(0.65f);
1206 // Check that the duration to hide the indicator is 0.65 second
1207 DALI_TEST_EQUALS( scrollBar.GetIndicatorHideDuration(), 0.65f, TEST_LOCATION );
1212 int UtcDaliToolkitScrollBarShowIndicatorP(void)
1214 ToolkitTestApplication application;
1216 // Create a scroll bar
1217 ScrollBar scrollBar = ScrollBar::New();
1218 DALI_TEST_CHECK( scrollBar );
1220 Stage::GetCurrent().Add( scrollBar );
1222 Actor indicator = scrollBar.GetScrollIndicator();
1223 DALI_TEST_CHECK( indicator );
1225 // Get the default duration to show the indicator
1226 float duration = scrollBar.GetIndicatorShowDuration();
1228 // Check that the default duration is greater than 0
1229 DALI_TEST_CHECK( duration > 0.0f );
1231 // Make the indicator invisible
1232 indicator.SetOpacity(0.0f);
1234 // Render and notify
1235 application.SendNotification();
1236 application.Render();
1238 // Check that the indicator is invisible
1239 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1241 // Show the indicator
1242 scrollBar.ShowIndicator();
1244 // Wait for the specified duration
1245 Wait(application, duration * 1000);
1247 // Render and notify
1248 application.SendNotification();
1249 application.Render();
1251 // Check that the indicator is now visible
1252 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1257 int UtcDaliToolkitScrollBarShowIndicatorN(void)
1259 ToolkitTestApplication application;
1261 // Create a scroll bar
1262 ScrollBar scrollBar = ScrollBar::New();
1263 DALI_TEST_CHECK( scrollBar );
1265 Stage::GetCurrent().Add( scrollBar );
1267 Actor indicator = scrollBar.GetScrollIndicator();
1268 DALI_TEST_CHECK( indicator );
1270 // Make the indicator initially visible
1271 indicator.SetOpacity(1.0f);
1273 // Render and notify
1274 application.SendNotification();
1275 application.Render();
1277 // Check that the indicator is initially visible
1278 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1280 // Get the default duration to show the indicator
1281 float duration = scrollBar.GetIndicatorShowDuration();
1283 // Check that the default duration is greater than 0
1284 DALI_TEST_CHECK( duration > 0.0f );
1286 // Show the indicator
1287 scrollBar.ShowIndicator();
1289 // Render and notify
1290 application.SendNotification();
1291 application.Render();
1293 // Check that the indicator is still visible in the very next frame
1294 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1299 int UtcDaliToolkitScrollBarHideIndicatorP(void)
1301 ToolkitTestApplication application;
1303 // Create a scroll bar
1304 ScrollBar scrollBar = ScrollBar::New();
1305 DALI_TEST_CHECK( scrollBar );
1307 Stage::GetCurrent().Add( scrollBar );
1309 Actor indicator = scrollBar.GetScrollIndicator();
1310 DALI_TEST_CHECK( indicator );
1312 // Get the default duration to hide the indicator
1313 float duration = scrollBar.GetIndicatorHideDuration();
1315 // Check that the default duration is greater than 0
1316 DALI_TEST_CHECK( duration > 0.0f );
1318 // Make the indicator visible
1319 indicator.SetOpacity(1.0f);
1321 // Render and notify
1322 application.SendNotification();
1323 application.Render();
1325 // Check that the indicator is visible
1326 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION );
1328 // Hide the indicator
1329 scrollBar.HideIndicator();
1331 // Wait for the specified duration
1332 Wait(application, duration * 1000);
1334 // Render and notify
1335 application.SendNotification();
1336 application.Render();
1338 // Check that the indicator is now invisible
1339 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1344 int UtcDaliToolkitScrollBarHideIndicatorN(void)
1346 ToolkitTestApplication application;
1348 // Create a scroll bar
1349 ScrollBar scrollBar = ScrollBar::New();
1350 DALI_TEST_CHECK( scrollBar );
1352 Stage::GetCurrent().Add( scrollBar );
1354 Actor indicator = scrollBar.GetScrollIndicator();
1355 DALI_TEST_CHECK( indicator );
1357 // Make the indicator initially invisible
1358 indicator.SetOpacity(0.0f);
1360 // Render and notify
1361 application.SendNotification();
1362 application.Render();
1364 // Check that the indicator is initially invisible
1365 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1367 // Get the default duration to hide the indicator
1368 float duration = scrollBar.GetIndicatorHideDuration();
1370 // Check that the default duration is greater than 0
1371 DALI_TEST_CHECK( duration > 0.0f );
1373 // Hide the indicator
1374 scrollBar.HideIndicator();
1376 // Render and notify
1377 application.SendNotification();
1378 application.Render();
1380 // Check that the indicator is still invisible in the very next frame
1381 DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION );
1386 int UtcDaliToolkitScrollBarPanFinishedSignalP(void)
1388 ToolkitTestApplication application;
1390 // Create a vertical scroll bar
1391 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1392 DALI_TEST_CHECK( scrollBar );
1394 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
1395 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1396 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
1398 // Set the indicator height to be fixed to 50.0f
1399 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
1400 scrollBar.SetIndicatorFixedHeight(50.0f);
1402 Stage::GetCurrent().Add( scrollBar );
1404 // Connect the pan finished signal
1405 ConnectionTracker connectionTracker;
1406 bool panFinished = false;
1407 scrollBar.PanFinishedSignal().Connect( &OnPanFinished );
1408 scrollBar.ConnectSignal( &connectionTracker, "panFinished", CallbackFunctor(&panFinished));
1410 // Render and notify
1411 application.SendNotification();
1412 application.Render();
1414 // Create a source actor that owns the scroll properties required by the scroll bar
1415 Actor sourceActor = Actor::New();
1416 Stage::GetCurrent().Add( sourceActor );
1418 // Register the scroll properties
1419 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1420 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1421 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
1422 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
1424 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1425 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1426 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1427 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1429 // Set the source of the scroll position properties.
1430 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1432 // Render and notify
1433 application.SendNotification();
1434 application.Render();
1436 // Perform a swipe gesture on the indicator
1437 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20);
1438 DALI_TEST_EQUALS( gOnPanFinishedCalled, true, TEST_LOCATION );
1439 DALI_TEST_EQUALS( panFinished, true, TEST_LOCATION );
1444 int UtcDaliToolkitScrollBarPanFinishedSignalN(void)
1446 ToolkitTestApplication application;
1448 // Create a vertical scroll bar
1449 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1450 DALI_TEST_CHECK( scrollBar );
1452 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
1453 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1454 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
1456 // Set the indicator height to be fixed to 50.0f
1457 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::Fixed);
1458 scrollBar.SetIndicatorFixedHeight(50.0f);
1460 Stage::GetCurrent().Add( scrollBar );
1462 // Connect the pan finished signal
1463 ConnectionTracker connectionTracker;
1464 bool panFinished = false;
1465 scrollBar.PanFinishedSignal().Connect( &OnPanFinished );
1466 scrollBar.ConnectSignal( &connectionTracker, "panFinished", CallbackFunctor(&panFinished));
1468 // Render and notify
1469 application.SendNotification();
1470 application.Render();
1472 // Perform a vertical swipe gesture on the indicator when there is no source object set on the scroll bar
1473 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20);
1474 DALI_TEST_EQUALS( gOnPanFinishedCalled, false, TEST_LOCATION );
1476 // Create a source actor that owns the scroll properties required by the scroll bar
1477 Actor sourceActor = Actor::New();
1478 Stage::GetCurrent().Add( sourceActor );
1480 // Register the scroll properties
1481 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1482 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1483 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 100.0f );
1484 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 500.0f );
1486 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1487 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1488 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1489 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1491 // Set the source of the scroll position properties.
1492 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1494 // Render and notify
1495 application.SendNotification();
1496 application.Render();
1498 // Perform a swipe gesture on the scroll bar but not on the indicator
1499 PerformGestureSwipe(application, Vector2(1.0f, 780.0f), Vector2(Vector2::YAXIS * -1.0f), 20);
1500 DALI_TEST_EQUALS( gOnPanFinishedCalled, false, TEST_LOCATION );
1501 DALI_TEST_EQUALS( panFinished, false, TEST_LOCATION );
1503 // Perform a swipe gesture on the indicator
1504 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20);
1505 DALI_TEST_EQUALS( gOnPanFinishedCalled, true, TEST_LOCATION );
1506 DALI_TEST_EQUALS( panFinished, true, TEST_LOCATION );
1511 int UtcDaliToolkitScrollBarScrollPositionIntervalReachedSignalP(void)
1513 ToolkitTestApplication application;
1515 // Create a vertical scroll bar
1516 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1517 DALI_TEST_CHECK( scrollBar );
1519 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
1520 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1521 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
1523 Stage::GetCurrent().Add( scrollBar );
1524 ConnectionTracker connectionTracker;
1526 // Connect to the ScrollPositionIntervalReached signal
1527 bool intervalReached = false;
1528 scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
1529 scrollBar.ConnectSignal( &connectionTracker, "scrollPositionIntervalReached", CallbackFunctor(&intervalReached));
1531 // Render and notify
1532 application.SendNotification();
1533 application.Render();
1535 // Create a source actor that owns the scroll properties required by the scroll bar
1536 Actor sourceActor = Actor::New();
1537 Stage::GetCurrent().Add( sourceActor );
1539 // Register the scroll properties
1540 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1541 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1542 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 800.0f );
1543 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 2000.0f );
1545 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1546 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1547 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1548 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1550 // Set the source of the scroll position properties.
1551 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1553 // Render and notify
1554 application.SendNotification();
1555 application.Render();
1557 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
1558 Dali::Vector<float> positionIntervals;
1559 for( size_t i = 0; i != 10; ++i )
1561 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
1563 scrollBar.SetScrollPositionIntervals(positionIntervals);
1565 // Render and notify
1566 application.SendNotification();
1567 application.Render();
1570 gOnScrollPositionIntervalReachedSignalCalled = false;
1572 // Animate the scroll position to cross the specified value
1573 Animation animation = Animation::New(0.1f);
1574 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
1577 // Wait for 0.1 second
1578 Wait(application, 100);
1580 // Check that the signal callback is called
1581 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1582 DALI_TEST_EQUALS( intervalReached, true, TEST_LOCATION );
1585 gOnScrollPositionIntervalReachedSignalCalled = false;
1586 intervalReached = false;
1588 // Rest and clear the animation
1592 // Animate the scroll position to cross another specified value
1593 animation = Animation::New(0.1f);
1594 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -170.0f );
1597 // Wait for 0.1 second
1598 Wait(application, 100);
1600 // Check that the signal callback is called
1601 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1602 DALI_TEST_EQUALS( intervalReached, true, TEST_LOCATION );
1605 gOnScrollPositionIntervalReachedSignalCalled = false;
1606 intervalReached = false;
1608 // Rest and clear the animation
1612 // Animate the scroll position back to the previous value
1613 animation = Animation::New(0.1f);
1614 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
1617 // Wait for 0.1 second
1618 Wait(application, 100);
1620 // Check that the signal callback is called
1621 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );
1622 DALI_TEST_EQUALS( intervalReached, true, TEST_LOCATION );
1627 int UtcDaliToolkitScrollBarScrollPositionIntervalReachedSignalN(void)
1629 ToolkitTestApplication application;
1631 // Create a vertical scroll bar
1632 ScrollBar scrollBar = ScrollBar::New(ScrollBar::Vertical);
1633 DALI_TEST_CHECK( scrollBar );
1635 scrollBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
1636 scrollBar.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1637 scrollBar.SetSize(20.0f, 800.0f, 0.0f);
1639 Stage::GetCurrent().Add( scrollBar );
1641 // Connect to the ScrollPositionIntervalReached signal
1642 scrollBar.ScrollPositionIntervalReachedSignal().Connect( &OnScrollPositionIntervalReached );
1644 // Render and notify
1645 application.SendNotification();
1646 application.Render();
1648 // Create a source actor that owns the scroll properties required by the scroll bar
1649 Actor sourceActor = Actor::New();
1650 Stage::GetCurrent().Add( sourceActor );
1652 // Register the scroll properties
1653 Property::Index propertyScrollPosition = sourceActor.RegisterProperty( "sourcePosition", 0.0f );
1654 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty( "sourcePositionMin", 0.0f );
1655 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty( "sourcePositionMax", 800.0f );
1656 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty( "sourceContentSize", 2000.0f );
1658 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePosition" ), propertyScrollPosition, TEST_LOCATION );
1659 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMin" ), propertyMinScrollPosition, TEST_LOCATION );
1660 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourcePositionMax" ), propertyMaxScrollPosition, TEST_LOCATION );
1661 DALI_TEST_EQUALS( sourceActor.GetPropertyIndex( "sourceContentSize" ), propertyScrollContentSize, TEST_LOCATION );
1663 // Set the source of the scroll position properties.
1664 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1666 // Render and notify
1667 application.SendNotification();
1668 application.Render();
1670 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
1671 Dali::Vector<float> positionIntervals;
1672 for( size_t i = 0; i != 10; ++i )
1674 positionIntervals.PushBack( -80.0f * i ); // should get notified for each 80 pixels
1676 scrollBar.SetScrollPositionIntervals(positionIntervals);
1678 // Render and notify
1679 application.SendNotification();
1680 application.Render();
1683 gOnScrollPositionIntervalReachedSignalCalled = false;
1685 // Animate the scroll position not to cross the specified value
1686 Animation animation = Animation::New(0.1f);
1687 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -70.0f );
1690 // Wait for 0.1 second
1691 Wait(application, 100);
1693 // Check that the signal callback is not called
1694 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, false, TEST_LOCATION );
1696 // Rest and clear the animation
1700 // Animate the scroll position to cross another specified value
1701 animation = Animation::New(0.1f);
1702 animation.AnimateTo( Property( sourceActor, propertyScrollPosition ), -85.0f );
1705 // Wait for 0.1 second
1706 Wait(application, 100);
1708 // Check that the signal callback is called
1709 DALI_TEST_EQUALS( gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION );