2 * Copyright (c) 2022 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.
22 #include <dali-toolkit-test-suite-utils.h>
23 #include "dali-toolkit-test-utils/toolkit-timer.h"
25 #include <dali-toolkit/dali-toolkit.h>
26 #include <dali-toolkit/devel-api/controls/scroll-bar/scroll-bar.h>
27 #include <dali/devel-api/actors/actor-devel.h>
30 using namespace Toolkit;
32 void dali_scrollbar_startup(void)
34 test_return_value = TET_UNDEF;
37 void dali_scrollbar_cleanup(void)
39 test_return_value = TET_PASS;
44 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
47 * Simulate time passed by.
49 * @note this will always process at least 1 frame (1/60 sec)
51 * @param application Test application instance
52 * @param duration Time to pass in milliseconds.
53 * @return The actual time passed in milliseconds
55 int Wait(ToolkitTestApplication& application, int duration = 0)
59 for(int i = 0; i <= (duration / RENDER_FRAME_INTERVAL); i++)
61 application.SendNotification();
62 application.Render(RENDER_FRAME_INTERVAL);
63 time += RENDER_FRAME_INTERVAL;
71 static bool gOnPanFinishedCalled; ///< Whether the PanFinished signal was invoked.
72 static bool gOnScrollPositionIntervalReachedSignalCalled; ///< Whether the ScrollPositionIntervalReached signal was invoked.
75 * Invoked when pan gesture is finished on the scroll indicator.
77 static void OnPanFinished()
79 gOnPanFinishedCalled = true;
82 struct CallbackFunctor
84 CallbackFunctor(bool* callbackFlag)
85 : mCallbackFlag(callbackFlag)
91 *mCallbackFlag = true;
97 * Invoked when the current scroll position of the scrollable content goes above or below the values
98 * specified by SCROLL_POSITION_INTERVALS property.
100 * @param[in] position The current scroll position.
102 static void OnScrollPositionIntervalReached(float position)
104 gOnScrollPositionIntervalReachedSignalCalled = true;
107 static Vector2 PerformGestureSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, uint32_t start_time)
109 gOnPanFinishedCalled = false;
111 // Now do a pan starting from (start) and heading (direction)
112 Vector2 pos(start + (direction * 15));
113 uint32_t time = start_time;
115 TestStartPan(application, start, pos, time);
119 for(int i = 0; i < frames; i++)
121 Test::EmitGlobalTimerSignal();
123 pos += direction; // Move in this direction
124 time += RENDER_FRAME_INTERVAL;
125 TestMovePan(application, pos, time);
129 pos += direction; // Move in this direction.
130 time += RENDER_FRAME_INTERVAL;
131 TestEndPan(application, pos, time);
139 int UtcDaliToolkitScrollBarConstructorP(void)
141 ToolkitTestApplication application;
144 DALI_TEST_CHECK(!scrollBar);
148 int UtcDaliToolkitScrollBarCopyConstructorP(void)
150 ToolkitTestApplication application;
152 ScrollBar scrollBar = ScrollBar::New();
153 scrollBar.SetProperty(ScrollBar::Property::INDICATOR_FIXED_HEIGHT, 38.2f);
155 ScrollBar copy(scrollBar);
156 DALI_TEST_CHECK(copy);
157 DALI_TEST_CHECK(copy.GetProperty<float>(ScrollBar::Property::INDICATOR_FIXED_HEIGHT) == scrollBar.GetProperty<float>(ScrollBar::Property::INDICATOR_FIXED_HEIGHT));
161 int UtcDaliToolkitScrollBarAssignmentOperatorP(void)
163 ToolkitTestApplication application;
165 ScrollBar scrollBar = ScrollBar::New();
166 scrollBar.SetProperty(ScrollBar::Property::INDICATOR_FIXED_HEIGHT, 38.2f);
168 ScrollBar copy = scrollBar;
169 DALI_TEST_CHECK(copy);
170 DALI_TEST_CHECK(copy.GetProperty<float>(ScrollBar::Property::INDICATOR_FIXED_HEIGHT) == scrollBar.GetProperty<float>(ScrollBar::Property::INDICATOR_FIXED_HEIGHT));
174 int UtcDaliScrollBarDestructorP(void)
176 ToolkitTestApplication application;
178 ScrollBar* scrollBar = new ScrollBar();
181 DALI_TEST_CHECK(true);
185 int UtcDaliToolkitScrollBarNewP(void)
187 ToolkitTestApplication application;
189 ScrollBar scrollBar = ScrollBar::New();
190 DALI_TEST_CHECK(scrollBar);
193 ScrollBar vertical = ScrollBar::New(ScrollBar::VERTICAL);
194 DALI_TEST_CHECK(vertical);
195 DALI_TEST_CHECK(vertical.GetScrollDirection() == ScrollBar::VERTICAL);
197 Property::Value value = vertical.GetProperty(ScrollBar::Property::SCROLL_DIRECTION);
198 std::string scrollDirection = value.Get<std::string>();
199 DALI_TEST_EQUALS(scrollDirection, "VERTICAL", TEST_LOCATION);
201 ScrollBar horizontal = ScrollBar::New(ScrollBar::HORIZONTAL);
202 DALI_TEST_CHECK(horizontal);
203 DALI_TEST_CHECK(horizontal.GetScrollDirection() == ScrollBar::HORIZONTAL);
204 value = vertical.GetProperty(ScrollBar::Property::SCROLL_DIRECTION);
205 scrollDirection = value.Get<std::string>();
206 DALI_TEST_EQUALS(scrollDirection, "HORIZONTAL", TEST_LOCATION);
211 int UtcDaliToolkitScrollBarCreateP(void)
213 ToolkitTestApplication application;
215 TypeRegistry typeRegistry = TypeRegistry::Get();
216 DALI_TEST_CHECK(typeRegistry);
218 TypeInfo typeInfo = typeRegistry.GetTypeInfo("ScrollBar");
219 DALI_TEST_CHECK(typeInfo);
221 BaseHandle handle = typeInfo.CreateInstance();
222 DALI_TEST_CHECK(handle);
224 ScrollBar scrollBar = ScrollBar::DownCast(handle);
225 DALI_TEST_CHECK(scrollBar);
227 scrollBar.SetProperty(ScrollBar::Property::SCROLL_DIRECTION, "VERTICAL");
228 scrollBar.SetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY, "FIXED");
230 DALI_TEST_EQUALS(scrollBar.GetScrollDirection(), Toolkit::ScrollBar::VERTICAL, TEST_LOCATION);
231 DALI_TEST_EQUALS(scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::FIXED, TEST_LOCATION);
233 scrollBar.SetProperty(ScrollBar::Property::SCROLL_DIRECTION, "HORIZONTAL");
234 scrollBar.SetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY, "VARIABLE");
236 DALI_TEST_EQUALS(scrollBar.GetScrollDirection(), Toolkit::ScrollBar::HORIZONTAL, TEST_LOCATION);
237 DALI_TEST_EQUALS(scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::VARIABLE, TEST_LOCATION);
242 int UtcDaliToolkitScrollBarDownCastP(void)
244 ToolkitTestApplication application;
246 ScrollBar scrollBar1 = ScrollBar::New();
247 BaseHandle object(scrollBar1);
249 ScrollBar scrollBar2 = ScrollBar::DownCast(object);
250 DALI_TEST_CHECK(scrollBar2);
252 ScrollBar scrollBar3 = DownCast<ScrollBar>(object);
253 DALI_TEST_CHECK(scrollBar3);
257 int UtcDaliToolkitScrollBarDownCastN(void)
259 ToolkitTestApplication application;
261 BaseHandle uninitializedObject;
262 ScrollBar scrollBar1 = ScrollBar::DownCast(uninitializedObject);
263 DALI_TEST_CHECK(!scrollBar1);
265 ScrollBar scrollBar2 = DownCast<ScrollBar>(uninitializedObject);
266 DALI_TEST_CHECK(!scrollBar2);
270 int UtcDaliToolkitScrollBarSetScrollPropertySourceP(void)
272 ToolkitTestApplication application;
274 // Create a vertical scroll bar
275 ScrollBar scrollBar = ScrollBar::New(ScrollBar::VERTICAL);
276 DALI_TEST_CHECK(scrollBar);
277 DALI_TEST_CHECK(scrollBar.GetScrollDirection() == ScrollBar::VERTICAL);
279 float scrollBarHeight = 100.0f;
280 scrollBar.SetProperty(Actor::Property::SIZE, Vector3(20.0f, scrollBarHeight, 0.0f));
281 application.GetScene().Add(scrollBar);
283 // Create a source actor that owns the scroll properties required by the scroll bar
284 Actor sourceActor = Actor::New();
285 application.GetScene().Add(sourceActor);
287 // Register the scroll properties
288 Property::Index propertyScrollPosition = sourceActor.RegisterProperty("sourcePosition", 0.0f);
289 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty("sourcePositionMin", 0.0f);
290 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty("sourcePositionMax", 100.0f);
291 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty("sourceContentSize", 500.0f);
293 DALI_TEST_EQUALS(sourceActor.GetPropertyIndex("sourcePosition"), propertyScrollPosition, TEST_LOCATION);
294 DALI_TEST_EQUALS(sourceActor.GetPropertyIndex("sourcePositionMin"), propertyMinScrollPosition, TEST_LOCATION);
295 DALI_TEST_EQUALS(sourceActor.GetPropertyIndex("sourcePositionMax"), propertyMaxScrollPosition, TEST_LOCATION);
296 DALI_TEST_EQUALS(sourceActor.GetPropertyIndex("sourceContentSize"), propertyScrollContentSize, TEST_LOCATION);
298 // Set the source of the scroll position properties.
299 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
302 application.SendNotification();
303 application.Render();
305 Actor indicator = scrollBar.GetScrollIndicator();
306 DALI_TEST_CHECK(indicator);
308 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
309 // i.e. The bigger the content size, the smaller the indicator size
310 float indicatorHeight = indicator.GetCurrentProperty<Vector3>(Actor::Property::SIZE).y;
311 DALI_TEST_EQUALS(indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION);
313 // Decrease the content length
314 sourceActor.SetProperty(propertyScrollContentSize, 250.0f);
317 application.SendNotification();
318 application.Render();
320 // Check that the indicator size is changed accordingly
321 indicatorHeight = indicator.GetCurrentProperty<Vector3>(Actor::Property::SIZE).y;
322 DALI_TEST_EQUALS(indicatorHeight, scrollBarHeight * scrollBarHeight / 250.0f, TEST_LOCATION);
324 // As scroll position is 0, check that the indicator position should be 0.0f.
325 float indicatorPosition = indicator.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y;
326 DALI_TEST_EQUALS(indicatorPosition, 0.0f, TEST_LOCATION);
328 // Set the scroll position to the middle
329 sourceActor.SetProperty(propertyScrollPosition, -50.0f);
332 application.SendNotification();
333 application.Render();
335 // Check that the indicator should be in the middle of the scroll bar
336 indicatorPosition = indicator.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y;
337 DALI_TEST_EQUALS(indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.5f, TEST_LOCATION);
339 // Set the scroll position to the maximum
340 sourceActor.SetProperty(propertyScrollPosition, -100.0f);
343 application.SendNotification();
344 application.Render();
346 // Check that the indicator should be in the end of the scroll bar
347 indicatorPosition = indicator.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y;
348 DALI_TEST_EQUALS(indicatorPosition, scrollBarHeight - indicatorHeight, TEST_LOCATION);
350 // Increase the maximum scroll position to double
351 sourceActor.SetProperty(propertyMaxScrollPosition, 200.0f);
354 application.SendNotification();
355 application.Render();
357 // Check that the indicator should be now in the middle of the scroll bar
358 indicatorPosition = indicator.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y;
359 DALI_TEST_EQUALS(indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.5f, TEST_LOCATION);
361 // Create another source actor
362 Actor newSourceActor = Actor::New();
363 application.GetScene().Add(newSourceActor);
365 // Register the scroll properties
366 Property::Index newPropertyScrollPosition = newSourceActor.RegisterProperty("sourcePosition", 0.0f);
367 Property::Index newPropertyMinScrollPosition = newSourceActor.RegisterProperty("sourcePositionMin", 0.0f);
368 Property::Index newPropertyMaxScrollPosition = newSourceActor.RegisterProperty("sourcePositionMax", 200.0f);
369 Property::Index newPropertyScrollContentSize = newSourceActor.RegisterProperty("sourceContentSize", 400.0f);
371 DALI_TEST_EQUALS(newSourceActor.GetPropertyIndex("sourcePosition"), newPropertyScrollPosition, TEST_LOCATION);
372 DALI_TEST_EQUALS(newSourceActor.GetPropertyIndex("sourcePositionMin"), newPropertyMinScrollPosition, TEST_LOCATION);
373 DALI_TEST_EQUALS(newSourceActor.GetPropertyIndex("sourcePositionMax"), newPropertyMaxScrollPosition, TEST_LOCATION);
374 DALI_TEST_EQUALS(newSourceActor.GetPropertyIndex("sourceContentSize"), newPropertyScrollContentSize, TEST_LOCATION);
376 // Change the source of the scroll position properties to be the new source actor.
377 scrollBar.SetScrollPropertySource(newSourceActor, newPropertyScrollPosition, newPropertyMinScrollPosition, newPropertyMaxScrollPosition, newPropertyScrollContentSize);
380 application.SendNotification();
381 application.Render();
383 // Check that the indicator size is changed accordingly
384 indicatorHeight = indicator.GetCurrentProperty<Vector3>(Actor::Property::SIZE).y;
385 DALI_TEST_EQUALS(indicatorHeight, scrollBarHeight * scrollBarHeight / 400.0f, TEST_LOCATION);
387 // Check that the indicator position goes back to the beginning of the scroll bar
388 indicatorPosition = indicator.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y;
389 DALI_TEST_EQUALS(indicatorPosition, 0.0f, TEST_LOCATION);
391 // Set the scroll position to one fifth of the maximum
392 newSourceActor.SetProperty(propertyScrollPosition, -40.0f);
395 application.SendNotification();
396 application.Render();
398 // Check that the indicator should be in one fifth from the beginning of the scroll bar
399 indicatorPosition = indicator.GetCurrentProperty<Vector3>(Actor::Property::POSITION).y;
400 DALI_TEST_EQUALS(indicatorPosition, (scrollBarHeight - indicatorHeight) * 0.2f, TEST_LOCATION);
405 int UtcDaliToolkitScrollBarSetScrollPropertySourceN(void)
407 ToolkitTestApplication application;
409 // Create a scroll bar
410 ScrollBar scrollBar = ScrollBar::New();
411 DALI_TEST_CHECK(scrollBar);
413 // Set empty handle of source object and invalid source property index.
415 scrollBar.SetScrollPropertySource(sourceActor, Property::INVALID_INDEX, Property::INVALID_INDEX, Property::INVALID_INDEX, Property::INVALID_INDEX);
417 DALI_TEST_CHECK(true);
421 int UtcDaliToolkitScrollBarSetScrollIndicatorP(void)
423 ToolkitTestApplication application;
425 // Create a scroll bar
426 ScrollBar scrollBar = ScrollBar::New();
427 DALI_TEST_CHECK(scrollBar);
429 Actor indicator = scrollBar.GetScrollIndicator();
430 DALI_TEST_CHECK(indicator);
432 // Set a new indicator
433 Actor newIndicator = Actor::New();
434 scrollBar.SetScrollIndicator(newIndicator);
436 // Check that the new indicator is successfully set
437 DALI_TEST_CHECK(indicator != scrollBar.GetScrollIndicator());
438 DALI_TEST_CHECK(newIndicator == scrollBar.GetScrollIndicator());
440 // Check that the new control indicator is successfully set
441 Control controlIndicator = Control::New();
442 scrollBar.SetScrollIndicator(controlIndicator);
444 DALI_TEST_CHECK(controlIndicator == Control::DownCast(scrollBar.GetScrollIndicator()));
448 int UtcDaliToolkitScrollBarSetScrollIndicatorN(void)
450 ToolkitTestApplication application;
452 // Create a scroll bar
453 ScrollBar scrollBar = ScrollBar::New();
454 DALI_TEST_CHECK(scrollBar);
456 Actor indicator = scrollBar.GetScrollIndicator();
457 DALI_TEST_CHECK(indicator);
459 // Try to set an uninitialized actor as the indicator
460 Actor uninitializedIndicator;
461 scrollBar.SetScrollIndicator(uninitializedIndicator);
463 // Check that the uninitialized actor can not be set as the indicator
464 DALI_TEST_CHECK(indicator == scrollBar.GetScrollIndicator());
465 DALI_TEST_CHECK(uninitializedIndicator != scrollBar.GetScrollIndicator());
470 int UtcDaliToolkitScrollBarGetScrollIndicatorP(void)
472 ToolkitTestApplication application;
474 // Create a scroll bar
475 ScrollBar scrollBar = ScrollBar::New();
476 DALI_TEST_CHECK(scrollBar);
478 Actor indicator = scrollBar.GetScrollIndicator();
479 DALI_TEST_CHECK(indicator);
481 // Set a new indicator
482 Actor newIndicator = Actor::New();
483 scrollBar.SetScrollIndicator(newIndicator);
485 // Check that the new indicator is successfully set
486 DALI_TEST_CHECK(scrollBar.GetScrollIndicator());
487 DALI_TEST_CHECK(indicator != scrollBar.GetScrollIndicator());
488 DALI_TEST_CHECK(newIndicator == scrollBar.GetScrollIndicator());
493 int UtcDaliToolkitScrollBarGetScrollIndicatorN(void)
495 ToolkitTestApplication application;
497 // Create a scroll bar
498 ScrollBar scrollBar = ScrollBar::New();
499 DALI_TEST_CHECK(scrollBar);
501 Actor indicator = scrollBar.GetScrollIndicator();
502 DALI_TEST_CHECK(indicator);
504 // Try to set an uninitialized actor as the indicator
505 Actor uninitializedIndicator;
506 scrollBar.SetScrollIndicator(uninitializedIndicator);
508 // Check that the indicator has not been changed
509 DALI_TEST_CHECK(indicator == scrollBar.GetScrollIndicator());
510 DALI_TEST_CHECK(uninitializedIndicator != scrollBar.GetScrollIndicator());
515 int UtcDaliToolkitScrollBarSetScrollPositionIntervalsP(void)
517 ToolkitTestApplication application;
519 // Create a vertical scroll bar
520 ScrollBar scrollBar = ScrollBar::New(ScrollBar::VERTICAL);
521 DALI_TEST_CHECK(scrollBar);
523 scrollBar.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
524 scrollBar.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
525 scrollBar.SetProperty(Actor::Property::SIZE, Vector3(20.0f, 800.0f, 0.0f));
527 application.GetScene().Add(scrollBar);
529 // Connect to the ScrollPositionIntervalReached signal
530 scrollBar.ScrollPositionIntervalReachedSignal().Connect(&OnScrollPositionIntervalReached);
533 application.SendNotification();
534 application.Render();
536 // Create a source actor that owns the scroll properties required by the scroll bar
537 Actor sourceActor = Actor::New();
538 application.GetScene().Add(sourceActor);
540 // Register the scroll properties
541 Property::Index propertyScrollPosition = sourceActor.RegisterProperty("sourcePosition", 0.0f);
542 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty("sourcePositionMin", 0.0f);
543 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty("sourcePositionMax", 800.0f);
544 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty("sourceContentSize", 2000.0f);
546 DALI_TEST_EQUALS(sourceActor.GetPropertyIndex("sourcePosition"), propertyScrollPosition, TEST_LOCATION);
547 DALI_TEST_EQUALS(sourceActor.GetPropertyIndex("sourcePositionMin"), propertyMinScrollPosition, TEST_LOCATION);
548 DALI_TEST_EQUALS(sourceActor.GetPropertyIndex("sourcePositionMax"), propertyMaxScrollPosition, TEST_LOCATION);
549 DALI_TEST_EQUALS(sourceActor.GetPropertyIndex("sourceContentSize"), propertyScrollContentSize, TEST_LOCATION);
551 // Set the source of the scroll position properties.
552 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
555 application.SendNotification();
556 application.Render();
558 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
559 Dali::Vector<float> positionIntervals;
560 for(size_t i = 0; i != 10; ++i)
562 positionIntervals.PushBack(-80.0f * i); // should get notified for each 80 pixels
564 scrollBar.SetScrollPositionIntervals(positionIntervals);
566 // Get the list of scroll position intervals for notification
567 Dali::Vector<float> results = scrollBar.GetScrollPositionIntervals();
569 // Check that the result is the same as the list previously set.
570 DALI_TEST_EQUALS(positionIntervals.Count(), results.Count(), TEST_LOCATION);
571 DALI_TEST_EQUALS(positionIntervals[0], results[0], TEST_LOCATION);
572 DALI_TEST_EQUALS(positionIntervals[1], results[1], TEST_LOCATION);
573 DALI_TEST_EQUALS(positionIntervals[2], results[2], TEST_LOCATION);
574 DALI_TEST_EQUALS(positionIntervals[3], results[3], TEST_LOCATION);
575 DALI_TEST_EQUALS(positionIntervals[4], results[4], TEST_LOCATION);
576 DALI_TEST_EQUALS(positionIntervals[5], results[5], TEST_LOCATION);
577 DALI_TEST_EQUALS(positionIntervals[6], results[6], TEST_LOCATION);
578 DALI_TEST_EQUALS(positionIntervals[7], results[7], TEST_LOCATION);
579 DALI_TEST_EQUALS(positionIntervals[8], results[8], TEST_LOCATION);
580 DALI_TEST_EQUALS(positionIntervals[9], results[9], TEST_LOCATION);
583 gOnScrollPositionIntervalReachedSignalCalled = false;
585 // Animate the scroll position to cross the specified value
586 Animation animation = Animation::New(0.1f);
587 animation.AnimateTo(Property(sourceActor, propertyScrollPosition), -85.0f);
590 // Wait for 0.1 second
591 Wait(application, 100);
593 // Check that the signal callback is called
594 DALI_TEST_EQUALS(gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION);
597 gOnScrollPositionIntervalReachedSignalCalled = false;
599 // Rest and clear the animation
603 // Animate the scroll position to cross another specified value
604 animation = Animation::New(0.1f);
605 animation.AnimateTo(Property(sourceActor, propertyScrollPosition), -170.0f);
608 // Wait for 0.1 second
609 Wait(application, 100);
611 // Check that the signal callback is called
612 DALI_TEST_EQUALS(gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION);
615 gOnScrollPositionIntervalReachedSignalCalled = false;
617 // Rest and clear the animation
621 // Animate the scroll position back to the previous value
622 animation = Animation::New(0.1f);
623 animation.AnimateTo(Property(sourceActor, propertyScrollPosition), -85.0f);
626 // Wait for 0.1 second
627 Wait(application, 100);
629 // Check that the signal callback is called
630 DALI_TEST_EQUALS(gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION);
635 int UtcDaliToolkitScrollBarGetScrollPositionIntervalsP(void)
637 ToolkitTestApplication application;
639 // Create a vertical scroll bar
640 ScrollBar scrollBar = ScrollBar::New(ScrollBar::VERTICAL);
641 DALI_TEST_CHECK(scrollBar);
643 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
644 Dali::Vector<float> positionIntervals;
645 for(size_t i = 0; i != 10; ++i)
647 positionIntervals.PushBack(-80.0f * i); // should get notified for each 80 pixels
649 scrollBar.SetScrollPositionIntervals(positionIntervals);
651 // Get the list of scroll position intervals for notification
652 Dali::Vector<float> results = scrollBar.GetScrollPositionIntervals();
654 // Check that the result is the same as the list previously set.
655 DALI_TEST_EQUALS(positionIntervals.Count(), results.Count(), TEST_LOCATION);
656 DALI_TEST_EQUALS(positionIntervals[0], results[0], TEST_LOCATION);
657 DALI_TEST_EQUALS(positionIntervals[1], results[1], TEST_LOCATION);
658 DALI_TEST_EQUALS(positionIntervals[2], results[2], TEST_LOCATION);
659 DALI_TEST_EQUALS(positionIntervals[3], results[3], TEST_LOCATION);
660 DALI_TEST_EQUALS(positionIntervals[4], results[4], TEST_LOCATION);
661 DALI_TEST_EQUALS(positionIntervals[5], results[5], TEST_LOCATION);
662 DALI_TEST_EQUALS(positionIntervals[6], results[6], TEST_LOCATION);
663 DALI_TEST_EQUALS(positionIntervals[7], results[7], TEST_LOCATION);
664 DALI_TEST_EQUALS(positionIntervals[8], results[8], TEST_LOCATION);
665 DALI_TEST_EQUALS(positionIntervals[9], results[9], TEST_LOCATION);
667 Property::Array resultArray = scrollBar.GetProperty<Property::Array>(Toolkit::ScrollBar::Property::SCROLL_POSITION_INTERVALS);
669 DALI_TEST_EQUALS(positionIntervals.Count(), resultArray.Count(), TEST_LOCATION);
670 DALI_TEST_EQUALS(positionIntervals[0], resultArray[0].Get<float>(), TEST_LOCATION);
671 DALI_TEST_EQUALS(positionIntervals[1], resultArray[1].Get<float>(), TEST_LOCATION);
672 DALI_TEST_EQUALS(positionIntervals[2], resultArray[2].Get<float>(), TEST_LOCATION);
673 DALI_TEST_EQUALS(positionIntervals[3], resultArray[3].Get<float>(), TEST_LOCATION);
674 DALI_TEST_EQUALS(positionIntervals[4], resultArray[4].Get<float>(), TEST_LOCATION);
675 DALI_TEST_EQUALS(positionIntervals[5], resultArray[5].Get<float>(), TEST_LOCATION);
676 DALI_TEST_EQUALS(positionIntervals[6], resultArray[6].Get<float>(), TEST_LOCATION);
677 DALI_TEST_EQUALS(positionIntervals[7], resultArray[7].Get<float>(), TEST_LOCATION);
678 DALI_TEST_EQUALS(positionIntervals[8], resultArray[8].Get<float>(), TEST_LOCATION);
679 DALI_TEST_EQUALS(positionIntervals[9], resultArray[9].Get<float>(), TEST_LOCATION);
684 int UtcDaliToolkitScrollBarGetScrollDirectionP(void)
686 ToolkitTestApplication application;
688 // Create a vertical scroll bar
689 ScrollBar scrollBar = ScrollBar::New(ScrollBar::VERTICAL);
690 DALI_TEST_CHECK(scrollBar);
691 DALI_TEST_CHECK(scrollBar.GetScrollDirection() == ScrollBar::VERTICAL);
693 // Change the direction of scroll bar to horizontal
694 scrollBar.SetScrollDirection(ScrollBar::HORIZONTAL);
695 DALI_TEST_CHECK(scrollBar.GetScrollDirection() == ScrollBar::HORIZONTAL);
700 int UtcDaliToolkitScrollBarSetIndicatorHeightPolicyP(void)
702 ToolkitTestApplication application;
704 // Create a scroll bar
705 ScrollBar scrollBar = ScrollBar::New();
706 DALI_TEST_CHECK(scrollBar);
708 float scrollBarHeight = 100.0f;
709 scrollBar.SetProperty(Actor::Property::SIZE, Vector3(20.0f, scrollBarHeight, 0.0f));
710 application.GetScene().Add(scrollBar);
712 // Create a source actor that owns the scroll properties required by the scroll bar
713 Actor sourceActor = Actor::New();
714 application.GetScene().Add(sourceActor);
716 // Register the scroll properties
717 Property::Index propertyScrollPosition = sourceActor.RegisterProperty("sourcePosition", 0.0f);
718 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty("sourcePositionMin", 0.0f);
719 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty("sourcePositionMax", 100.0f);
720 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty("sourceContentSize", 500.0f);
722 DALI_TEST_EQUALS(sourceActor.GetPropertyIndex("sourcePosition"), propertyScrollPosition, TEST_LOCATION);
723 DALI_TEST_EQUALS(sourceActor.GetPropertyIndex("sourcePositionMin"), propertyMinScrollPosition, TEST_LOCATION);
724 DALI_TEST_EQUALS(sourceActor.GetPropertyIndex("sourcePositionMax"), propertyMaxScrollPosition, TEST_LOCATION);
725 DALI_TEST_EQUALS(sourceActor.GetPropertyIndex("sourceContentSize"), propertyScrollContentSize, TEST_LOCATION);
727 // Set the source of the scroll position properties.
728 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
731 application.SendNotification();
732 application.Render();
734 Actor indicator = scrollBar.GetScrollIndicator();
735 DALI_TEST_CHECK(indicator);
737 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
738 // i.e. The bigger the content size, the smaller the indicator size
739 float indicatorHeight = indicator.GetCurrentProperty<Vector3>(Actor::Property::SIZE).y;
740 DALI_TEST_EQUALS(indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION);
742 // Set the indicator height to be fixed to 50.0f
743 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::FIXED);
744 scrollBar.SetIndicatorFixedHeight(50.0f);
746 Property::Value value = scrollBar.GetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY);
747 DALI_TEST_EQUALS(value.Get<std::string>(), "FIXED", TEST_LOCATION);
750 application.SendNotification();
751 application.Render();
753 // Check that the indicator size should be 50.0f
754 indicatorHeight = indicator.GetCurrentProperty<Vector3>(Actor::Property::SIZE).y;
755 DALI_TEST_EQUALS(indicatorHeight, 50.0f, TEST_LOCATION);
757 // Set the indicator height to be variable
758 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::VARIABLE);
759 value = scrollBar.GetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY);
760 DALI_TEST_EQUALS(value.Get<std::string>(), "VARIABLE", TEST_LOCATION);
763 application.SendNotification();
764 application.Render();
766 // Check that the indicator size should be: scroll bar size * (scroll bar size / content size).
767 indicatorHeight = indicator.GetCurrentProperty<Vector3>(Actor::Property::SIZE).y;
768 DALI_TEST_EQUALS(indicatorHeight, scrollBarHeight * scrollBarHeight / 500.0f, TEST_LOCATION);
773 int UtcDaliToolkitScrollBarGetIndicatorHeightPolicyP(void)
775 ToolkitTestApplication application;
777 // Create a scroll bar
778 ScrollBar scrollBar = ScrollBar::New();
779 DALI_TEST_CHECK(scrollBar);
781 // Set the indicator height to be fixed
782 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::FIXED);
783 DALI_TEST_EQUALS(scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::FIXED, TEST_LOCATION);
785 // Set the indicator height to be variable
786 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::VARIABLE);
787 DALI_TEST_EQUALS(scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::VARIABLE, TEST_LOCATION);
792 int UtcDaliToolkitScrollBarSetIndicatorFixedHeightP(void)
794 ToolkitTestApplication application;
796 // Create a scroll bar
797 ScrollBar scrollBar = ScrollBar::New();
798 DALI_TEST_CHECK(scrollBar);
800 float scrollBarHeight = 100.0f;
801 scrollBar.SetProperty(Actor::Property::SIZE, Vector3(20.0f, scrollBarHeight, 0.0f));
802 application.GetScene().Add(scrollBar);
804 Actor indicator = scrollBar.GetScrollIndicator();
805 DALI_TEST_CHECK(indicator);
807 // Set the indicator height to be fixed to 50.0f
808 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::FIXED);
809 scrollBar.SetIndicatorFixedHeight(50.0f);
812 application.SendNotification();
813 application.Render();
815 // Check that the indicator size should be 50.0f
816 DALI_TEST_EQUALS(indicator.GetCurrentProperty<Vector3>(Actor::Property::SIZE).y, 50.0f, TEST_LOCATION);
818 // Set the indicator height to be fixed to 25.0f
819 scrollBar.SetIndicatorFixedHeight(25.0f);
822 application.SendNotification();
823 application.Render();
825 // Check that the indicator size should be 25.0f
826 DALI_TEST_EQUALS(indicator.GetCurrentProperty<Vector3>(Actor::Property::SIZE).y, 25.0f, TEST_LOCATION);
831 int UtcDaliToolkitScrollBarGetIndicatorFixedHeightP(void)
833 ToolkitTestApplication application;
835 // Create a scroll bar
836 ScrollBar scrollBar = ScrollBar::New();
837 DALI_TEST_CHECK(scrollBar);
839 // Set the fixed indicator height to be 50.0f
840 scrollBar.SetIndicatorFixedHeight(50.0f);
842 // Check that the indicator size should be 50.0f
843 DALI_TEST_EQUALS(scrollBar.GetIndicatorFixedHeight(), 50.0f, TEST_LOCATION);
845 // Set the indicator height to be fixed to 25.0f
846 scrollBar.SetIndicatorFixedHeight(25.0f);
848 // Check that the indicator size should be 50.0f
849 DALI_TEST_EQUALS(scrollBar.GetIndicatorFixedHeight(), 25.0f, TEST_LOCATION);
854 int UtcDaliToolkitScrollBarSetIndicatorShowDurationP(void)
856 ToolkitTestApplication application;
858 // Create a scroll bar
859 ScrollBar scrollBar = ScrollBar::New();
860 DALI_TEST_CHECK(scrollBar);
862 application.GetScene().Add(scrollBar);
864 Actor indicator = scrollBar.GetScrollIndicator();
865 DALI_TEST_CHECK(indicator);
867 // Set the duration to show the indicator to be 0.35 second
868 scrollBar.SetIndicatorShowDuration(0.35);
869 DALI_TEST_EQUALS(scrollBar.GetIndicatorShowDuration(), 0.35f, TEST_LOCATION);
871 // Make the indicator invisible
872 indicator.SetProperty(Actor::Property::OPACITY, 0.0f);
875 application.SendNotification();
876 application.Render();
878 // Check that the indicator is invisible
879 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
881 // Show the indicator
882 scrollBar.ShowIndicator();
884 // Wait for 0.35 second
885 Wait(application, 350);
888 application.SendNotification();
889 application.Render();
891 // Check that the indicator is now visible
892 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
894 // Set the duration to show the indicator to be 0.75 second
895 scrollBar.SetIndicatorShowDuration(0.75);
896 DALI_TEST_EQUALS(scrollBar.GetIndicatorShowDuration(), 0.75f, TEST_LOCATION);
898 // Make the indicator invisible
899 indicator.SetProperty(Actor::Property::OPACITY, 0.0f);
902 application.SendNotification();
903 application.Render();
905 // Check that the indicator is invisible
906 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
908 // Show the indicator
909 scrollBar.ShowIndicator();
911 // Wait for 0.35 second first
912 Wait(application, 350);
915 application.SendNotification();
916 application.Render();
918 // Check that the indicator is not fully visible yet
919 DALI_TEST_CHECK(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY) != 1.0f);
921 // Wait for another 0.4 second
922 Wait(application, 400);
925 application.SendNotification();
926 application.Render();
928 // Check that the indicator is now fully visible
929 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
934 int UtcDaliToolkitScrollBarSetIndicatorShowDurationN(void)
936 ToolkitTestApplication application;
938 // Create a scroll bar
939 ScrollBar scrollBar = ScrollBar::New();
940 DALI_TEST_CHECK(scrollBar);
942 application.GetScene().Add(scrollBar);
944 Actor indicator = scrollBar.GetScrollIndicator();
945 DALI_TEST_CHECK(indicator);
947 // Get the default duration to show the indicator
948 float duration = scrollBar.GetIndicatorShowDuration();
950 // Check that the default duration is greater than 0
951 DALI_TEST_CHECK(duration > 0.0f);
953 // Make the indicator invisible
954 indicator.SetProperty(Actor::Property::OPACITY, 0.0f);
957 application.SendNotification();
958 application.Render();
960 // Check that the indicator is invisible
961 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
963 // Show the indicator
964 scrollBar.ShowIndicator();
966 // Wait for the specified duration
967 Wait(application, duration * 1000);
970 application.SendNotification();
971 application.Render();
973 // Check that the indicator is now visible
974 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
976 // Now set the duration to show the indicator to be a negative value (which should be ignored and therefore means instant)
977 scrollBar.SetIndicatorShowDuration(-0.25f);
978 DALI_TEST_EQUALS(scrollBar.GetIndicatorShowDuration(), -0.25f, TEST_LOCATION);
980 // Make the indicator invisible
981 indicator.SetProperty(Actor::Property::OPACITY, 0.0f);
984 application.SendNotification();
985 application.Render();
987 // Check that the indicator is invisible
988 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
990 // Show the indicator
991 scrollBar.ShowIndicator();
994 application.SendNotification();
995 application.Render();
997 // Check that the indicator becomes instantly visible in the next frame
998 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
1003 int UtcDaliToolkitScrollBarGetIndicatorShowDurationP(void)
1005 ToolkitTestApplication application;
1007 // Create a scroll bar
1008 ScrollBar scrollBar = ScrollBar::New();
1009 DALI_TEST_CHECK(scrollBar);
1011 // Set the duration to show the indicator to be 0.35 second
1012 scrollBar.SetIndicatorShowDuration(0.35f);
1014 // Check that the duration to show the indicator is 0.35 second
1015 DALI_TEST_EQUALS(scrollBar.GetIndicatorShowDuration(), 0.35f, TEST_LOCATION);
1017 // Set the duration to show the indicator to be 0.75 second
1018 scrollBar.SetIndicatorShowDuration(0.75f);
1020 // Check that the duration to show the indicator is 0.75 second
1021 DALI_TEST_EQUALS(scrollBar.GetIndicatorShowDuration(), 0.75f, TEST_LOCATION);
1026 int UtcDaliToolkitScrollBarSetIndicatorHideDurationP(void)
1028 ToolkitTestApplication application;
1030 // Create a scroll bar
1031 ScrollBar scrollBar = ScrollBar::New();
1032 DALI_TEST_CHECK(scrollBar);
1034 application.GetScene().Add(scrollBar);
1036 Actor indicator = scrollBar.GetScrollIndicator();
1037 DALI_TEST_CHECK(indicator);
1039 // Set the duration to hide the indicator to be 0.15 second
1040 scrollBar.SetIndicatorHideDuration(0.15f);
1041 DALI_TEST_EQUALS(scrollBar.GetIndicatorHideDuration(), 0.15f, TEST_LOCATION);
1043 // Make the indicator visible
1044 indicator.SetProperty(Actor::Property::OPACITY, 1.0f);
1046 // Render and notify
1047 application.SendNotification();
1048 application.Render();
1050 // Check that the indicator is visible
1051 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
1053 // Hide the indicator
1054 scrollBar.HideIndicator();
1056 // Wait for 0.15 second
1057 Wait(application, 150);
1059 // Render and notify
1060 application.SendNotification();
1061 application.Render();
1063 // Check that the indicator is now invisible
1064 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
1066 // Set the duration to hide the indicator to be 0.65 second
1067 scrollBar.SetIndicatorHideDuration(0.65f);
1068 DALI_TEST_EQUALS(scrollBar.GetIndicatorHideDuration(), 0.65f, TEST_LOCATION);
1070 // Make the indicator visible
1071 indicator.SetProperty(Actor::Property::OPACITY, 1.0f);
1073 // Render and notify
1074 application.SendNotification();
1075 application.Render();
1077 // Check that the indicator is visible
1078 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
1080 // Hide the indicator
1081 scrollBar.HideIndicator();
1083 // Wait for 0.15 second first
1084 Wait(application, 150);
1086 // Render and notify
1087 application.SendNotification();
1088 application.Render();
1090 // Check that the indicator is not fully invisible yet
1091 DALI_TEST_CHECK(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY) != 0.0f);
1093 // Wait for another 0.5 second
1094 Wait(application, 500);
1096 // Render and notify
1097 application.SendNotification();
1098 application.Render();
1100 // Check that the indicator is now fully invisible
1101 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
1106 int UtcDaliToolkitScrollBarSetIndicatorHideDurationN(void)
1108 ToolkitTestApplication application;
1110 // Create a scroll bar
1111 ScrollBar scrollBar = ScrollBar::New();
1112 DALI_TEST_CHECK(scrollBar);
1114 application.GetScene().Add(scrollBar);
1116 Actor indicator = scrollBar.GetScrollIndicator();
1117 DALI_TEST_CHECK(indicator);
1119 // Get the default duration to hide the indicator
1120 float duration = scrollBar.GetIndicatorHideDuration();
1122 // Check that the default duration is greater than 0
1123 DALI_TEST_CHECK(duration > 0.0f);
1125 // Make the indicator visible
1126 indicator.SetProperty(Actor::Property::OPACITY, 1.0f);
1128 // Render and notify
1129 application.SendNotification();
1130 application.Render();
1132 // Check that the indicator is visible
1133 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
1135 // Hide the indicator
1136 scrollBar.HideIndicator();
1138 // Wait for the specified duration
1139 Wait(application, duration * 1000);
1141 // Render and notify
1142 application.SendNotification();
1143 application.Render();
1145 // Check that the indicator is now invisible
1146 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
1148 // Now set the duration to hide the indicator to be a negative value (which should be ignored and therefore means instant)
1149 scrollBar.SetIndicatorHideDuration(-0.25f);
1150 DALI_TEST_EQUALS(scrollBar.GetIndicatorHideDuration(), -0.25f, TEST_LOCATION);
1152 // Make the indicator visible
1153 indicator.SetProperty(Actor::Property::OPACITY, 1.0f);
1155 // Render and notify
1156 application.SendNotification();
1157 application.Render();
1159 // Check that the indicator is visible
1160 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
1162 // Hide the indicator
1163 scrollBar.HideIndicator();
1165 // Render and notify
1166 application.SendNotification();
1167 application.Render();
1169 // Check that the indicator becomes instantly invisible in the next frame
1170 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
1175 int UtcDaliToolkitScrollBarGetIndicatorHideDurationP(void)
1177 ToolkitTestApplication application;
1179 // Create a scroll bar
1180 ScrollBar scrollBar = ScrollBar::New();
1181 DALI_TEST_CHECK(scrollBar);
1183 // Set the duration to hide the indicator to be 0.15 second
1184 scrollBar.SetIndicatorHideDuration(0.15f);
1186 // Check that the duration to hide the indicator is 0.15 second
1187 DALI_TEST_EQUALS(scrollBar.GetIndicatorHideDuration(), 0.15f, TEST_LOCATION);
1189 // Set the duration to hide the indicator to be 0.65 second
1190 scrollBar.SetIndicatorHideDuration(0.65f);
1192 // Check that the duration to hide the indicator is 0.65 second
1193 DALI_TEST_EQUALS(scrollBar.GetIndicatorHideDuration(), 0.65f, TEST_LOCATION);
1198 int UtcDaliToolkitScrollBarShowIndicatorP(void)
1200 ToolkitTestApplication application;
1202 // Create a scroll bar
1203 ScrollBar scrollBar = ScrollBar::New();
1204 DALI_TEST_CHECK(scrollBar);
1206 application.GetScene().Add(scrollBar);
1208 Actor indicator = scrollBar.GetScrollIndicator();
1209 DALI_TEST_CHECK(indicator);
1211 // Get the default duration to show the indicator
1212 float duration = scrollBar.GetIndicatorShowDuration();
1214 // Check that the default duration is greater than 0
1215 DALI_TEST_CHECK(duration > 0.0f);
1217 // Make the indicator invisible
1218 indicator.SetProperty(Actor::Property::OPACITY, 0.0f);
1220 // Render and notify
1221 application.SendNotification();
1222 application.Render();
1224 // Check that the indicator is invisible
1225 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
1227 // Show the indicator
1228 scrollBar.ShowIndicator();
1230 // Wait for the specified duration
1231 Wait(application, duration * 1000);
1233 // Render and notify
1234 application.SendNotification();
1235 application.Render();
1237 // Check that the indicator is now visible
1238 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
1243 int UtcDaliToolkitScrollBarShowIndicatorN(void)
1245 ToolkitTestApplication application;
1247 // Create a scroll bar
1248 ScrollBar scrollBar = ScrollBar::New();
1249 DALI_TEST_CHECK(scrollBar);
1251 application.GetScene().Add(scrollBar);
1253 Actor indicator = scrollBar.GetScrollIndicator();
1254 DALI_TEST_CHECK(indicator);
1256 // Make the indicator initially visible
1257 indicator.SetProperty(Actor::Property::OPACITY, 1.0f);
1259 // Render and notify
1260 application.SendNotification();
1261 application.Render();
1263 // Check that the indicator is initially visible
1264 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
1266 // Get the default duration to show the indicator
1267 float duration = scrollBar.GetIndicatorShowDuration();
1269 // Check that the default duration is greater than 0
1270 DALI_TEST_CHECK(duration > 0.0f);
1272 // Show the indicator
1273 scrollBar.ShowIndicator();
1275 // Render and notify
1276 application.SendNotification();
1277 application.Render();
1279 // Check that the indicator is still visible in the very next frame
1280 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
1285 int UtcDaliToolkitScrollBarHideIndicatorP(void)
1287 ToolkitTestApplication application;
1289 // Create a scroll bar
1290 ScrollBar scrollBar = ScrollBar::New();
1291 DALI_TEST_CHECK(scrollBar);
1293 application.GetScene().Add(scrollBar);
1295 Actor indicator = scrollBar.GetScrollIndicator();
1296 DALI_TEST_CHECK(indicator);
1298 // Get the default duration to hide the indicator
1299 float duration = scrollBar.GetIndicatorHideDuration();
1301 // Check that the default duration is greater than 0
1302 DALI_TEST_CHECK(duration > 0.0f);
1304 // Make the indicator visible
1305 indicator.SetProperty(Actor::Property::OPACITY, 1.0f);
1307 // Render and notify
1308 application.SendNotification();
1309 application.Render();
1311 // Check that the indicator is visible
1312 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
1314 // Hide the indicator
1315 scrollBar.HideIndicator();
1317 // Wait for the specified duration
1318 Wait(application, duration * 1000);
1320 // Render and notify
1321 application.SendNotification();
1322 application.Render();
1324 // Check that the indicator is now invisible
1325 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
1330 int UtcDaliToolkitScrollBarHideIndicatorN(void)
1332 ToolkitTestApplication application;
1334 // Create a scroll bar
1335 ScrollBar scrollBar = ScrollBar::New();
1336 DALI_TEST_CHECK(scrollBar);
1338 application.GetScene().Add(scrollBar);
1340 Actor indicator = scrollBar.GetScrollIndicator();
1341 DALI_TEST_CHECK(indicator);
1343 // Make the indicator initially invisible
1344 indicator.SetProperty(Actor::Property::OPACITY, 0.0f);
1346 // Render and notify
1347 application.SendNotification();
1348 application.Render();
1350 // Check that the indicator is initially invisible
1351 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
1353 // Get the default duration to hide the indicator
1354 float duration = scrollBar.GetIndicatorHideDuration();
1356 // Check that the default duration is greater than 0
1357 DALI_TEST_CHECK(duration > 0.0f);
1359 // Hide the indicator
1360 scrollBar.HideIndicator();
1362 // Render and notify
1363 application.SendNotification();
1364 application.Render();
1366 // Check that the indicator is still invisible in the very next frame
1367 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
1372 int UtcDaliToolkitScrollBarActionShowIndicator(void)
1374 ToolkitTestApplication application;
1376 // Create a scroll bar
1377 ScrollBar scrollBar = ScrollBar::New();
1378 DALI_TEST_CHECK(scrollBar);
1380 application.GetScene().Add(scrollBar);
1382 Actor indicator = scrollBar.GetScrollIndicator();
1383 DALI_TEST_CHECK(indicator);
1385 // Get the default duration to hide the indicator
1386 float duration = scrollBar.GetProperty<float>(ScrollBar::Property::INDICATOR_SHOW_DURATION);
1388 // Check that the default duration is greater than 0
1389 DALI_TEST_CHECK(duration > 0.0f);
1391 // Make the indicator invisible
1392 indicator.SetProperty(Actor::Property::OPACITY, 0.0f);
1394 // Render and notify
1395 application.SendNotification();
1396 application.Render();
1398 // Check that the indicator is invisible
1399 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
1401 // Do the "ShowIndicator" action
1402 Property::Map emptyMap;
1403 scrollBar.DoAction("ShowIndicator", emptyMap);
1405 // Wait for the specified duration
1406 Wait(application, duration * 1000);
1408 // Render and notify
1409 application.SendNotification();
1410 application.Render();
1412 // Check that the indicator is now visible
1413 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
1418 int UtcDaliToolkitScrollBarActionHideIndicator(void)
1420 ToolkitTestApplication application;
1422 // Create a scroll bar
1423 ScrollBar scrollBar = ScrollBar::New();
1424 DALI_TEST_CHECK(scrollBar);
1426 application.GetScene().Add(scrollBar);
1428 Actor indicator = scrollBar.GetScrollIndicator();
1429 DALI_TEST_CHECK(indicator);
1431 // Get the default duration to hide the indicator
1432 float duration = scrollBar.GetProperty<float>(ScrollBar::Property::INDICATOR_HIDE_DURATION);
1434 // Check that the default duration is greater than 0
1435 DALI_TEST_CHECK(duration > 0.0f);
1437 // Make the indicator visible
1438 indicator.SetProperty(Actor::Property::OPACITY, 1.0f);
1440 // Render and notify
1441 application.SendNotification();
1442 application.Render();
1444 // Check that the indicator is visible
1445 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
1447 // Do the "HideIndicator" action
1448 Property::Map emptyMap;
1449 scrollBar.DoAction("HideIndicator", emptyMap);
1451 // Wait for the specified duration
1452 Wait(application, duration * 1000);
1454 // Render and notify
1455 application.SendNotification();
1456 application.Render();
1458 // Check that the indicator is now invisible
1459 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
1464 int UtcDaliToolkitScrollBarActionShowTransientIndicator(void)
1466 ToolkitTestApplication application;
1468 // Create a scroll bar
1469 ScrollBar scrollBar = ScrollBar::New();
1470 DALI_TEST_CHECK(scrollBar);
1472 application.GetScene().Add(scrollBar);
1474 Actor indicator = scrollBar.GetScrollIndicator();
1475 DALI_TEST_CHECK(indicator);
1477 // Get the default duration to hide the indicator
1478 float duration = scrollBar.GetProperty<float>(ScrollBar::Property::INDICATOR_SHOW_DURATION);
1480 // Check that the default duration is greater than 0
1481 DALI_TEST_CHECK(duration > 0.0f);
1483 // Make the indicator invisible
1484 indicator.SetProperty(Actor::Property::OPACITY, 0.0f);
1486 // Render and notify
1487 application.SendNotification();
1488 application.Render();
1490 // Check that the indicator is invisible
1491 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
1493 // Do the "ShowIndicator" action
1494 Property::Map emptyMap;
1495 scrollBar.DoAction("ShowTransientIndicator", emptyMap);
1497 // Wait for the specified duration
1498 Wait(application, duration * 1000);
1500 // Render and notify
1501 application.SendNotification();
1502 application.Render();
1504 // Check that the indicator is now visible
1505 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
1507 // Get the default duration to hide the indicator
1508 float hideDuration = scrollBar.GetProperty<float>(ScrollBar::Property::INDICATOR_HIDE_DURATION);
1509 float transientDuration = scrollBar.GetProperty<float>(ScrollBar::Property::INDICATOR_TRANSIENT_DURATION);
1510 float totalVisibleDuration = hideDuration + transientDuration;
1512 // Check that the default duration is greater than 0
1513 DALI_TEST_CHECK(totalVisibleDuration > 0.0f);
1515 // Wait for the specified duration
1516 Wait(application, totalVisibleDuration * 1000);
1518 // Render and notify
1519 application.SendNotification();
1520 application.Render();
1522 // Check that the indicator is now invisible
1523 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
1528 int UtcDaliToolkitScrollBarActionShowTransientIndicatorImmediate(void)
1530 ToolkitTestApplication application;
1532 // Create a scroll bar
1533 ScrollBar scrollBar = ScrollBar::New();
1534 DALI_TEST_CHECK(scrollBar);
1536 application.GetScene().Add(scrollBar);
1538 Actor indicator = scrollBar.GetScrollIndicator();
1539 DALI_TEST_CHECK(indicator);
1541 // Make the indicator invisible
1542 indicator.SetProperty(Actor::Property::OPACITY, 0.0f);
1544 // Don't use a show animation; the indicator should appear immediately
1545 scrollBar.SetProperty(ScrollBar::Property::INDICATOR_SHOW_DURATION, 0.0f);
1546 float duration = scrollBar.GetProperty<float>(ScrollBar::Property::INDICATOR_SHOW_DURATION);
1547 DALI_TEST_EQUALS(duration, 0.0f, TEST_LOCATION);
1549 // Render and notify
1550 application.SendNotification();
1551 application.Render();
1553 // Do the "ShowIndicator" action
1554 Property::Map emptyMap;
1555 scrollBar.DoAction("ShowTransientIndicator", emptyMap);
1557 // Wait for the specified duration
1560 // Render and notify
1561 application.SendNotification();
1562 application.Render();
1564 // Check that the indicator is now visible
1565 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
1567 // Get the default duration to hide the indicator
1568 float hideDuration = scrollBar.GetProperty<float>(ScrollBar::Property::INDICATOR_HIDE_DURATION);
1569 float transientDuration = scrollBar.GetProperty<float>(ScrollBar::Property::INDICATOR_TRANSIENT_DURATION);
1570 float totalVisibleDuration = hideDuration + transientDuration;
1572 // Check that the default duration is greater than 0
1573 DALI_TEST_CHECK(totalVisibleDuration > 0.0f);
1575 // Wait for the specified duration
1576 Wait(application, totalVisibleDuration * 1000);
1578 // Render and notify
1579 application.SendNotification();
1580 application.Render();
1582 // Check that the indicator is now invisible
1583 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
1588 int UtcDaliToolkitScrollBarActionShowTransientIndicatorDuringHide(void)
1590 ToolkitTestApplication application;
1592 // Create a scroll bar
1593 ScrollBar scrollBar = ScrollBar::New();
1594 DALI_TEST_CHECK(scrollBar);
1596 application.GetScene().Add(scrollBar);
1598 Actor indicator = scrollBar.GetScrollIndicator();
1599 DALI_TEST_CHECK(indicator);
1601 // Get the default duration to hide the indicator
1602 float duration = scrollBar.GetIndicatorHideDuration();
1604 // Check that the default duration is greater than 0
1605 DALI_TEST_CHECK(duration > 0.0f);
1607 // Make the indicator visible
1608 indicator.SetProperty(Actor::Property::OPACITY, 1.0f);
1610 // Render and notify
1611 application.SendNotification();
1612 application.Render();
1614 // Check that the indicator is visible
1615 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
1617 // Hide the indicator
1618 scrollBar.HideIndicator();
1620 // Wait for half the specified duration
1621 Wait(application, duration * 0.5f * 1000);
1623 // Render and notify
1624 application.SendNotification();
1625 application.Render();
1627 // Check that the indicator is now partially hidden
1628 DALI_TEST_CHECK(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY) < 1.0f);
1630 // Now interrupt the Hide with a DoAction( "ShowTransientIndicator" )
1632 // Get the default duration to hide the indicator
1633 duration = scrollBar.GetProperty<float>(ScrollBar::Property::INDICATOR_SHOW_DURATION);
1635 // Check that the default duration is greater than 0
1636 DALI_TEST_CHECK(duration > 0.0f);
1638 // Do the "ShowIndicator" action
1639 Property::Map emptyMap;
1640 scrollBar.DoAction("ShowTransientIndicator", emptyMap);
1642 // Wait for the specified duration
1643 Wait(application, duration * 1000);
1645 // Render and notify
1646 application.SendNotification();
1647 application.Render();
1649 // Check that the indicator is now visible
1650 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
1652 // Get the default duration to hide the indicator
1653 float hideDuration = scrollBar.GetProperty<float>(ScrollBar::Property::INDICATOR_HIDE_DURATION);
1654 float transientDuration = scrollBar.GetProperty<float>(ScrollBar::Property::INDICATOR_TRANSIENT_DURATION);
1655 float totalVisibleDuration = hideDuration + transientDuration;
1657 // Check that the default duration is greater than 0
1658 DALI_TEST_CHECK(totalVisibleDuration > 0.0f);
1660 // Wait for the specified duration
1661 Wait(application, totalVisibleDuration * 1000);
1663 // Render and notify
1664 application.SendNotification();
1665 application.Render();
1667 // Check that the indicator is now invisible
1668 DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
1673 int UtcDaliToolkitScrollBarPanFinishedSignalP(void)
1675 ToolkitTestApplication application;
1677 // Create a vertical scroll bar
1678 ScrollBar scrollBar = ScrollBar::New(ScrollBar::VERTICAL);
1679 DALI_TEST_CHECK(scrollBar);
1681 scrollBar.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1682 scrollBar.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1683 scrollBar.SetProperty(Actor::Property::SIZE, Vector3(20.0f, 800.0f, 0.0f));
1685 // Set the indicator height to be fixed to 50.0f
1686 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::FIXED);
1687 scrollBar.SetIndicatorFixedHeight(50.0f);
1689 application.GetScene().Add(scrollBar);
1691 // Connect the pan finished signal
1692 ConnectionTracker connectionTracker;
1693 bool panFinished = false;
1694 scrollBar.PanFinishedSignal().Connect(&OnPanFinished);
1695 scrollBar.ConnectSignal(&connectionTracker, "panFinished", CallbackFunctor(&panFinished));
1697 // Render and notify
1698 application.SendNotification();
1699 application.Render();
1701 // Create a source actor that owns the scroll properties required by the scroll bar
1702 Actor sourceActor = Actor::New();
1703 application.GetScene().Add(sourceActor);
1705 // Register the scroll properties
1706 Property::Index propertyScrollPosition = sourceActor.RegisterProperty("sourcePosition", 0.0f);
1707 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty("sourcePositionMin", 0.0f);
1708 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty("sourcePositionMax", 100.0f);
1709 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty("sourceContentSize", 500.0f);
1711 DALI_TEST_EQUALS(sourceActor.GetPropertyIndex("sourcePosition"), propertyScrollPosition, TEST_LOCATION);
1712 DALI_TEST_EQUALS(sourceActor.GetPropertyIndex("sourcePositionMin"), propertyMinScrollPosition, TEST_LOCATION);
1713 DALI_TEST_EQUALS(sourceActor.GetPropertyIndex("sourcePositionMax"), propertyMaxScrollPosition, TEST_LOCATION);
1714 DALI_TEST_EQUALS(sourceActor.GetPropertyIndex("sourceContentSize"), propertyScrollContentSize, TEST_LOCATION);
1716 // Set the source of the scroll position properties.
1717 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1719 // Render and notify
1720 application.SendNotification();
1721 application.Render();
1723 // Perform a swipe gesture on the indicator
1724 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 1, 500);
1725 DALI_TEST_EQUALS(gOnPanFinishedCalled, true, TEST_LOCATION);
1726 DALI_TEST_EQUALS(panFinished, true, TEST_LOCATION);
1731 int UtcDaliToolkitScrollBarPanFinishedSignalN(void)
1733 ToolkitTestApplication application;
1735 // Create a vertical scroll bar
1736 ScrollBar scrollBar = ScrollBar::New(ScrollBar::VERTICAL);
1737 DALI_TEST_CHECK(scrollBar);
1739 scrollBar.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1740 scrollBar.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1741 scrollBar.SetProperty(Actor::Property::SIZE, Vector3(20.0f, 800.0f, 0.0f));
1743 // Set the indicator height to be fixed to 50.0f
1744 scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::FIXED);
1745 scrollBar.SetIndicatorFixedHeight(50.0f);
1747 application.GetScene().Add(scrollBar);
1749 // Connect the pan finished signal
1750 ConnectionTracker connectionTracker;
1751 bool panFinished = false;
1752 scrollBar.PanFinishedSignal().Connect(&OnPanFinished);
1753 scrollBar.ConnectSignal(&connectionTracker, "panFinished", CallbackFunctor(&panFinished));
1755 // Render and notify
1756 application.SendNotification();
1757 application.Render();
1759 // Perform a vertical swipe gesture on the indicator when there is no source object set on the scroll bar
1760 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20, 500);
1761 DALI_TEST_EQUALS(gOnPanFinishedCalled, false, TEST_LOCATION);
1763 // Create a source actor that owns the scroll properties required by the scroll bar
1764 Actor sourceActor = Actor::New();
1765 application.GetScene().Add(sourceActor);
1767 // Register the scroll properties
1768 Property::Index propertyScrollPosition = sourceActor.RegisterProperty("sourcePosition", 0.0f);
1769 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty("sourcePositionMin", 0.0f);
1770 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty("sourcePositionMax", 100.0f);
1771 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty("sourceContentSize", 500.0f);
1773 DALI_TEST_EQUALS(sourceActor.GetPropertyIndex("sourcePosition"), propertyScrollPosition, TEST_LOCATION);
1774 DALI_TEST_EQUALS(sourceActor.GetPropertyIndex("sourcePositionMin"), propertyMinScrollPosition, TEST_LOCATION);
1775 DALI_TEST_EQUALS(sourceActor.GetPropertyIndex("sourcePositionMax"), propertyMaxScrollPosition, TEST_LOCATION);
1776 DALI_TEST_EQUALS(sourceActor.GetPropertyIndex("sourceContentSize"), propertyScrollContentSize, TEST_LOCATION);
1778 // Set the source of the scroll position properties.
1779 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1781 // Render and notify
1782 application.SendNotification();
1783 application.Render();
1785 // Perform a swipe gesture on the scroll bar but not on the indicator
1786 PerformGestureSwipe(application, Vector2(1.0f, 780.0f), Vector2(Vector2::YAXIS * -1.0f), 20, 2000);
1787 DALI_TEST_EQUALS(gOnPanFinishedCalled, false, TEST_LOCATION);
1788 DALI_TEST_EQUALS(panFinished, false, TEST_LOCATION);
1790 // Perform a swipe gesture on the indicator
1791 PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20, 4000);
1792 DALI_TEST_EQUALS(gOnPanFinishedCalled, true, TEST_LOCATION);
1793 DALI_TEST_EQUALS(panFinished, true, TEST_LOCATION);
1798 int UtcDaliToolkitScrollBarScrollPositionIntervalReachedSignalP(void)
1800 ToolkitTestApplication application;
1802 // Create a vertical scroll bar
1803 ScrollBar scrollBar = ScrollBar::New(ScrollBar::VERTICAL);
1804 DALI_TEST_CHECK(scrollBar);
1806 scrollBar.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1807 scrollBar.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1808 scrollBar.SetProperty(Actor::Property::SIZE, Vector3(20.0f, 800.0f, 0.0f));
1810 application.GetScene().Add(scrollBar);
1811 ConnectionTracker connectionTracker;
1813 // Connect to the ScrollPositionIntervalReached signal
1814 bool intervalReached = false;
1815 scrollBar.ScrollPositionIntervalReachedSignal().Connect(&OnScrollPositionIntervalReached);
1816 scrollBar.ConnectSignal(&connectionTracker, "scrollPositionIntervalReached", CallbackFunctor(&intervalReached));
1818 // Render and notify
1819 application.SendNotification();
1820 application.Render();
1822 // Create a source actor that owns the scroll properties required by the scroll bar
1823 Actor sourceActor = Actor::New();
1824 application.GetScene().Add(sourceActor);
1826 // Register the scroll properties
1827 Property::Index propertyScrollPosition = sourceActor.RegisterProperty("sourcePosition", 0.0f);
1828 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty("sourcePositionMin", 0.0f);
1829 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty("sourcePositionMax", 800.0f);
1830 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty("sourceContentSize", 2000.0f);
1832 DALI_TEST_EQUALS(sourceActor.GetPropertyIndex("sourcePosition"), propertyScrollPosition, TEST_LOCATION);
1833 DALI_TEST_EQUALS(sourceActor.GetPropertyIndex("sourcePositionMin"), propertyMinScrollPosition, TEST_LOCATION);
1834 DALI_TEST_EQUALS(sourceActor.GetPropertyIndex("sourcePositionMax"), propertyMaxScrollPosition, TEST_LOCATION);
1835 DALI_TEST_EQUALS(sourceActor.GetPropertyIndex("sourceContentSize"), propertyScrollContentSize, TEST_LOCATION);
1837 // Set the source of the scroll position properties.
1838 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1840 // Render and notify
1841 application.SendNotification();
1842 application.Render();
1844 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
1845 Dali::Vector<float> positionIntervals;
1846 for(size_t i = 0; i != 10; ++i)
1848 positionIntervals.PushBack(-80.0f * i); // should get notified for each 80 pixels
1850 scrollBar.SetScrollPositionIntervals(positionIntervals);
1852 // Render and notify
1853 application.SendNotification();
1854 application.Render();
1857 gOnScrollPositionIntervalReachedSignalCalled = false;
1859 // Animate the scroll position to cross the specified value
1860 Animation animation = Animation::New(0.1f);
1861 animation.AnimateTo(Property(sourceActor, propertyScrollPosition), -85.0f);
1864 // Wait for 0.1 second
1865 Wait(application, 100);
1867 // Check that the signal callback is called
1868 DALI_TEST_EQUALS(gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION);
1869 DALI_TEST_EQUALS(intervalReached, true, TEST_LOCATION);
1872 gOnScrollPositionIntervalReachedSignalCalled = false;
1873 intervalReached = false;
1875 // Rest and clear the animation
1879 // Animate the scroll position to cross another specified value
1880 animation = Animation::New(0.1f);
1881 animation.AnimateTo(Property(sourceActor, propertyScrollPosition), -170.0f);
1884 // Wait for 0.1 second
1885 Wait(application, 100);
1887 // Check that the signal callback is called
1888 DALI_TEST_EQUALS(gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION);
1889 DALI_TEST_EQUALS(intervalReached, true, TEST_LOCATION);
1892 gOnScrollPositionIntervalReachedSignalCalled = false;
1893 intervalReached = false;
1895 // Rest and clear the animation
1899 // Animate the scroll position back to the previous value
1900 animation = Animation::New(0.1f);
1901 animation.AnimateTo(Property(sourceActor, propertyScrollPosition), -85.0f);
1904 // Wait for 0.1 second
1905 Wait(application, 100);
1907 // Check that the signal callback is called
1908 DALI_TEST_EQUALS(gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION);
1909 DALI_TEST_EQUALS(intervalReached, true, TEST_LOCATION);
1914 int UtcDaliToolkitScrollBarScrollPositionIntervalReachedSignalN(void)
1916 ToolkitTestApplication application;
1918 // Create a vertical scroll bar
1919 ScrollBar scrollBar = ScrollBar::New(ScrollBar::VERTICAL);
1920 DALI_TEST_CHECK(scrollBar);
1922 scrollBar.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1923 scrollBar.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1924 scrollBar.SetProperty(Actor::Property::SIZE, Vector3(20.0f, 800.0f, 0.0f));
1926 application.GetScene().Add(scrollBar);
1928 // Connect to the ScrollPositionIntervalReached signal
1929 scrollBar.ScrollPositionIntervalReachedSignal().Connect(&OnScrollPositionIntervalReached);
1931 // Render and notify
1932 application.SendNotification();
1933 application.Render();
1935 // Create a source actor that owns the scroll properties required by the scroll bar
1936 Actor sourceActor = Actor::New();
1937 application.GetScene().Add(sourceActor);
1939 // Register the scroll properties
1940 Property::Index propertyScrollPosition = sourceActor.RegisterProperty("sourcePosition", 0.0f);
1941 Property::Index propertyMinScrollPosition = sourceActor.RegisterProperty("sourcePositionMin", 0.0f);
1942 Property::Index propertyMaxScrollPosition = sourceActor.RegisterProperty("sourcePositionMax", 800.0f);
1943 Property::Index propertyScrollContentSize = sourceActor.RegisterProperty("sourceContentSize", 2000.0f);
1945 DALI_TEST_EQUALS(sourceActor.GetPropertyIndex("sourcePosition"), propertyScrollPosition, TEST_LOCATION);
1946 DALI_TEST_EQUALS(sourceActor.GetPropertyIndex("sourcePositionMin"), propertyMinScrollPosition, TEST_LOCATION);
1947 DALI_TEST_EQUALS(sourceActor.GetPropertyIndex("sourcePositionMax"), propertyMaxScrollPosition, TEST_LOCATION);
1948 DALI_TEST_EQUALS(sourceActor.GetPropertyIndex("sourceContentSize"), propertyScrollContentSize, TEST_LOCATION);
1950 // Set the source of the scroll position properties.
1951 scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1953 // Render and notify
1954 application.SendNotification();
1955 application.Render();
1957 // Set the values to get notified when the scroll positions of the source actor goes above or below these values
1958 Dali::Vector<float> positionIntervals;
1959 for(size_t i = 0; i != 10; ++i)
1961 positionIntervals.PushBack(-80.0f * i); // should get notified for each 80 pixels
1963 scrollBar.SetScrollPositionIntervals(positionIntervals);
1965 // Render and notify
1966 application.SendNotification();
1967 application.Render();
1970 gOnScrollPositionIntervalReachedSignalCalled = false;
1972 // Animate the scroll position not to cross the specified value
1973 Animation animation = Animation::New(0.1f);
1974 animation.AnimateTo(Property(sourceActor, propertyScrollPosition), -70.0f);
1977 // Wait for 0.1 second
1978 Wait(application, 100);
1980 // Check that the signal callback is not called
1981 DALI_TEST_EQUALS(gOnScrollPositionIntervalReachedSignalCalled, false, TEST_LOCATION);
1983 // Rest and clear the animation
1987 // Animate the scroll position to cross another specified value
1988 animation = Animation::New(0.1f);
1989 animation.AnimateTo(Property(sourceActor, propertyScrollPosition), -85.0f);
1992 // Wait for 0.1 second
1993 Wait(application, 100);
1995 // Check that the signal callback is called
1996 DALI_TEST_EQUALS(gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION);