Merge "fix issue in negative line spacing with key arrow down" into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-ScrollBar.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <stdlib.h>
19 #include <iostream>
20 #include <string>
21
22 #include <dali-toolkit-test-suite-utils.h>
23 #include "dali-toolkit-test-utils/toolkit-timer.h"
24
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>
28
29 using namespace Dali;
30 using namespace Toolkit;
31
32 void dali_scrollbar_startup(void)
33 {
34   test_return_value = TET_UNDEF;
35 }
36
37 void dali_scrollbar_cleanup(void)
38 {
39   test_return_value = TET_PASS;
40 }
41
42 namespace
43 {
44 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
45
46 /*
47  * Simulate time passed by.
48  *
49  * @note this will always process at least 1 frame (1/60 sec)
50  *
51  * @param application Test application instance
52  * @param duration Time to pass in milliseconds.
53  * @return The actual time passed in milliseconds
54  */
55 int Wait(ToolkitTestApplication& application, int duration = 0)
56 {
57   int time = 0;
58
59   for(int i = 0; i <= (duration / RENDER_FRAME_INTERVAL); i++)
60   {
61     application.SendNotification();
62     application.Render(RENDER_FRAME_INTERVAL);
63     time += RENDER_FRAME_INTERVAL;
64   }
65
66   return time;
67 }
68
69 // Callback probes.
70
71 static bool gOnPanFinishedCalled;                         ///< Whether the PanFinished signal was invoked.
72 static bool gOnScrollPositionIntervalReachedSignalCalled; ///< Whether the ScrollPositionIntervalReached signal was invoked.
73
74 /**
75  * Invoked when pan gesture is finished on the scroll indicator.
76  */
77 static void OnPanFinished()
78 {
79   gOnPanFinishedCalled = true;
80 }
81
82 struct CallbackFunctor
83 {
84   CallbackFunctor(bool* callbackFlag)
85   : mCallbackFlag(callbackFlag)
86   {
87   }
88
89   void operator()()
90   {
91     *mCallbackFlag = true;
92   }
93   bool* mCallbackFlag;
94 };
95
96 /**
97  * Invoked when the current scroll position of the scrollable content goes above or below the values
98  * specified by SCROLL_POSITION_INTERVALS property.
99  *
100  * @param[in] position The current scroll position.
101  */
102 static void OnScrollPositionIntervalReached(float position)
103 {
104   gOnScrollPositionIntervalReachedSignalCalled = true;
105 }
106
107 static Vector2 PerformGestureSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, uint32_t start_time)
108 {
109   gOnPanFinishedCalled = false;
110
111   // Now do a pan starting from (start) and heading (direction)
112   Vector2  pos(start + (direction * 15));
113   uint32_t time = start_time;
114
115   TestStartPan(application, start, pos, time);
116
117   Wait(application);
118
119   for(int i = 0; i < frames; i++)
120   {
121     Test::EmitGlobalTimerSignal();
122
123     pos += direction; // Move in this direction
124     time += RENDER_FRAME_INTERVAL;
125     TestMovePan(application, pos, time);
126     Wait(application);
127   }
128
129   pos += direction; // Move in this direction.
130   time += RENDER_FRAME_INTERVAL;
131   TestEndPan(application, pos, time);
132   Wait(application);
133
134   return pos;
135 }
136
137 } // namespace
138
139 int UtcDaliToolkitScrollBarConstructorP(void)
140 {
141   ToolkitTestApplication application;
142
143   ScrollBar scrollBar;
144   DALI_TEST_CHECK(!scrollBar);
145   END_TEST;
146 }
147
148 int UtcDaliToolkitScrollBarCopyConstructorP(void)
149 {
150   ToolkitTestApplication application;
151
152   ScrollBar scrollBar = ScrollBar::New();
153   scrollBar.SetProperty(ScrollBar::Property::INDICATOR_FIXED_HEIGHT, 38.2f);
154
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));
158   END_TEST;
159 }
160
161 int UtcDaliToolkitScrollBarAssignmentOperatorP(void)
162 {
163   ToolkitTestApplication application;
164
165   ScrollBar scrollBar = ScrollBar::New();
166   scrollBar.SetProperty(ScrollBar::Property::INDICATOR_FIXED_HEIGHT, 38.2f);
167
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));
171   END_TEST;
172 }
173
174 int UtcDaliScrollBarDestructorP(void)
175 {
176   ToolkitTestApplication application;
177
178   ScrollBar* scrollBar = new ScrollBar();
179   delete scrollBar;
180
181   DALI_TEST_CHECK(true);
182   END_TEST;
183 }
184
185 int UtcDaliToolkitScrollBarNewP(void)
186 {
187   ToolkitTestApplication application;
188
189   ScrollBar scrollBar = ScrollBar::New();
190   DALI_TEST_CHECK(scrollBar);
191   END_TEST;
192
193   ScrollBar vertical = ScrollBar::New(ScrollBar::VERTICAL);
194   DALI_TEST_CHECK(vertical);
195   DALI_TEST_CHECK(vertical.GetScrollDirection() == ScrollBar::VERTICAL);
196
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);
200
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);
207
208   END_TEST;
209 }
210
211 int UtcDaliToolkitScrollBarCreateP(void)
212 {
213   ToolkitTestApplication application;
214
215   TypeRegistry typeRegistry = TypeRegistry::Get();
216   DALI_TEST_CHECK(typeRegistry);
217
218   TypeInfo typeInfo = typeRegistry.GetTypeInfo("ScrollBar");
219   DALI_TEST_CHECK(typeInfo);
220
221   BaseHandle handle = typeInfo.CreateInstance();
222   DALI_TEST_CHECK(handle);
223
224   ScrollBar scrollBar = ScrollBar::DownCast(handle);
225   DALI_TEST_CHECK(scrollBar);
226
227   scrollBar.SetProperty(ScrollBar::Property::SCROLL_DIRECTION, "VERTICAL");
228   scrollBar.SetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY, "FIXED");
229
230   DALI_TEST_EQUALS(scrollBar.GetScrollDirection(), Toolkit::ScrollBar::VERTICAL, TEST_LOCATION);
231   DALI_TEST_EQUALS(scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::FIXED, TEST_LOCATION);
232
233   scrollBar.SetProperty(ScrollBar::Property::SCROLL_DIRECTION, "HORIZONTAL");
234   scrollBar.SetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY, "VARIABLE");
235
236   DALI_TEST_EQUALS(scrollBar.GetScrollDirection(), Toolkit::ScrollBar::HORIZONTAL, TEST_LOCATION);
237   DALI_TEST_EQUALS(scrollBar.GetIndicatorHeightPolicy(), Toolkit::ScrollBar::VARIABLE, TEST_LOCATION);
238
239   END_TEST;
240 }
241
242 int UtcDaliToolkitScrollBarDownCastP(void)
243 {
244   ToolkitTestApplication application;
245
246   ScrollBar  scrollBar1 = ScrollBar::New();
247   BaseHandle object(scrollBar1);
248
249   ScrollBar scrollBar2 = ScrollBar::DownCast(object);
250   DALI_TEST_CHECK(scrollBar2);
251
252   ScrollBar scrollBar3 = DownCast<ScrollBar>(object);
253   DALI_TEST_CHECK(scrollBar3);
254   END_TEST;
255 }
256
257 int UtcDaliToolkitScrollBarDownCastN(void)
258 {
259   ToolkitTestApplication application;
260
261   BaseHandle uninitializedObject;
262   ScrollBar  scrollBar1 = ScrollBar::DownCast(uninitializedObject);
263   DALI_TEST_CHECK(!scrollBar1);
264
265   ScrollBar scrollBar2 = DownCast<ScrollBar>(uninitializedObject);
266   DALI_TEST_CHECK(!scrollBar2);
267   END_TEST;
268 }
269
270 int UtcDaliToolkitScrollBarSetScrollPropertySourceP(void)
271 {
272   ToolkitTestApplication application;
273
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);
278
279   float scrollBarHeight = 100.0f;
280   scrollBar.SetProperty(Actor::Property::SIZE, Vector3(20.0f, scrollBarHeight, 0.0f));
281   application.GetScene().Add(scrollBar);
282
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);
286
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);
292
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);
297
298   // Set the source of the scroll position properties.
299   scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
300
301   // Render and notify
302   application.SendNotification();
303   application.Render();
304
305   Actor indicator = scrollBar.GetScrollIndicator();
306   DALI_TEST_CHECK(indicator);
307
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);
312
313   // Decrease the content length
314   sourceActor.SetProperty(propertyScrollContentSize, 250.0f);
315
316   // Render and notify
317   application.SendNotification();
318   application.Render();
319
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);
323
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);
327
328   // Set the scroll position to the middle
329   sourceActor.SetProperty(propertyScrollPosition, -50.0f);
330
331   // Render and notify
332   application.SendNotification();
333   application.Render();
334
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);
338
339   // Set the scroll position to the maximum
340   sourceActor.SetProperty(propertyScrollPosition, -100.0f);
341
342   // Render and notify
343   application.SendNotification();
344   application.Render();
345
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);
349
350   // Increase the maximum scroll position to double
351   sourceActor.SetProperty(propertyMaxScrollPosition, 200.0f);
352
353   // Render and notify
354   application.SendNotification();
355   application.Render();
356
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);
360
361   // Create another source actor
362   Actor newSourceActor = Actor::New();
363   application.GetScene().Add(newSourceActor);
364
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);
370
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);
375
376   // Change the source of the scroll position properties to be the new source actor.
377   scrollBar.SetScrollPropertySource(newSourceActor, newPropertyScrollPosition, newPropertyMinScrollPosition, newPropertyMaxScrollPosition, newPropertyScrollContentSize);
378
379   // Render and notify
380   application.SendNotification();
381   application.Render();
382
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);
386
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);
390
391   // Set the scroll position to one fifth of the maximum
392   newSourceActor.SetProperty(propertyScrollPosition, -40.0f);
393
394   // Render and notify
395   application.SendNotification();
396   application.Render();
397
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);
401
402   END_TEST;
403 }
404
405 int UtcDaliToolkitScrollBarSetScrollPropertySourceN(void)
406 {
407   ToolkitTestApplication application;
408
409   // Create a scroll bar
410   ScrollBar scrollBar = ScrollBar::New();
411   DALI_TEST_CHECK(scrollBar);
412
413   // Set empty handle of source object and invalid source property index.
414   Actor sourceActor;
415   scrollBar.SetScrollPropertySource(sourceActor, Property::INVALID_INDEX, Property::INVALID_INDEX, Property::INVALID_INDEX, Property::INVALID_INDEX);
416
417   DALI_TEST_CHECK(true);
418   END_TEST;
419 }
420
421 int UtcDaliToolkitScrollBarSetScrollIndicatorP(void)
422 {
423   ToolkitTestApplication application;
424
425   // Create a scroll bar
426   ScrollBar scrollBar = ScrollBar::New();
427   DALI_TEST_CHECK(scrollBar);
428
429   Actor indicator = scrollBar.GetScrollIndicator();
430   DALI_TEST_CHECK(indicator);
431
432   // Set a new indicator
433   Actor newIndicator = Actor::New();
434   scrollBar.SetScrollIndicator(newIndicator);
435
436   // Check that the new indicator is successfully set
437   DALI_TEST_CHECK(indicator != scrollBar.GetScrollIndicator());
438   DALI_TEST_CHECK(newIndicator == scrollBar.GetScrollIndicator());
439
440   // Check that the new control indicator is successfully set
441   Control controlIndicator = Control::New();
442   scrollBar.SetScrollIndicator(controlIndicator);
443
444   DALI_TEST_CHECK(controlIndicator == Control::DownCast(scrollBar.GetScrollIndicator()));
445   END_TEST;
446 }
447
448 int UtcDaliToolkitScrollBarSetScrollIndicatorN(void)
449 {
450   ToolkitTestApplication application;
451
452   // Create a scroll bar
453   ScrollBar scrollBar = ScrollBar::New();
454   DALI_TEST_CHECK(scrollBar);
455
456   Actor indicator = scrollBar.GetScrollIndicator();
457   DALI_TEST_CHECK(indicator);
458
459   // Try to set an uninitialized actor as the indicator
460   Actor uninitializedIndicator;
461   scrollBar.SetScrollIndicator(uninitializedIndicator);
462
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());
466
467   END_TEST;
468 }
469
470 int UtcDaliToolkitScrollBarGetScrollIndicatorP(void)
471 {
472   ToolkitTestApplication application;
473
474   // Create a scroll bar
475   ScrollBar scrollBar = ScrollBar::New();
476   DALI_TEST_CHECK(scrollBar);
477
478   Actor indicator = scrollBar.GetScrollIndicator();
479   DALI_TEST_CHECK(indicator);
480
481   // Set a new indicator
482   Actor newIndicator = Actor::New();
483   scrollBar.SetScrollIndicator(newIndicator);
484
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());
489
490   END_TEST;
491 }
492
493 int UtcDaliToolkitScrollBarGetScrollIndicatorN(void)
494 {
495   ToolkitTestApplication application;
496
497   // Create a scroll bar
498   ScrollBar scrollBar = ScrollBar::New();
499   DALI_TEST_CHECK(scrollBar);
500
501   Actor indicator = scrollBar.GetScrollIndicator();
502   DALI_TEST_CHECK(indicator);
503
504   // Try to set an uninitialized actor as the indicator
505   Actor uninitializedIndicator;
506   scrollBar.SetScrollIndicator(uninitializedIndicator);
507
508   // Check that the indicator has not been changed
509   DALI_TEST_CHECK(indicator == scrollBar.GetScrollIndicator());
510   DALI_TEST_CHECK(uninitializedIndicator != scrollBar.GetScrollIndicator());
511
512   END_TEST;
513 }
514
515 int UtcDaliToolkitScrollBarSetScrollPositionIntervalsP(void)
516 {
517   ToolkitTestApplication application;
518
519   // Create a vertical scroll bar
520   ScrollBar scrollBar = ScrollBar::New(ScrollBar::VERTICAL);
521   DALI_TEST_CHECK(scrollBar);
522
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));
526
527   application.GetScene().Add(scrollBar);
528
529   // Connect to the ScrollPositionIntervalReached signal
530   scrollBar.ScrollPositionIntervalReachedSignal().Connect(&OnScrollPositionIntervalReached);
531
532   // Render and notify
533   application.SendNotification();
534   application.Render();
535
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);
539
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);
545
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);
550
551   // Set the source of the scroll position properties.
552   scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
553
554   // Render and notify
555   application.SendNotification();
556   application.Render();
557
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)
561   {
562     positionIntervals.PushBack(-80.0f * i); // should get notified for each 80 pixels
563   }
564   scrollBar.SetScrollPositionIntervals(positionIntervals);
565
566   // Get the list of scroll position intervals for notification
567   Dali::Vector<float> results = scrollBar.GetScrollPositionIntervals();
568
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);
581
582   // Reset the flag
583   gOnScrollPositionIntervalReachedSignalCalled = false;
584
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);
588   animation.Play();
589
590   // Wait for 0.1 second
591   Wait(application, 100);
592
593   // Check that the signal callback is called
594   DALI_TEST_EQUALS(gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION);
595
596   // Reset the flag
597   gOnScrollPositionIntervalReachedSignalCalled = false;
598
599   // Rest and clear the animation
600   animation.Clear();
601   animation.Reset();
602
603   // Animate the scroll position to cross another specified value
604   animation = Animation::New(0.1f);
605   animation.AnimateTo(Property(sourceActor, propertyScrollPosition), -170.0f);
606   animation.Play();
607
608   // Wait for 0.1 second
609   Wait(application, 100);
610
611   // Check that the signal callback is called
612   DALI_TEST_EQUALS(gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION);
613
614   // Reset the flag
615   gOnScrollPositionIntervalReachedSignalCalled = false;
616
617   // Rest and clear the animation
618   animation.Clear();
619   animation.Reset();
620
621   // Animate the scroll position back to the previous value
622   animation = Animation::New(0.1f);
623   animation.AnimateTo(Property(sourceActor, propertyScrollPosition), -85.0f);
624   animation.Play();
625
626   // Wait for 0.1 second
627   Wait(application, 100);
628
629   // Check that the signal callback is called
630   DALI_TEST_EQUALS(gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION);
631
632   END_TEST;
633 }
634
635 int UtcDaliToolkitScrollBarGetScrollPositionIntervalsP(void)
636 {
637   ToolkitTestApplication application;
638
639   // Create a vertical scroll bar
640   ScrollBar scrollBar = ScrollBar::New(ScrollBar::VERTICAL);
641   DALI_TEST_CHECK(scrollBar);
642
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)
646   {
647     positionIntervals.PushBack(-80.0f * i); // should get notified for each 80 pixels
648   }
649   scrollBar.SetScrollPositionIntervals(positionIntervals);
650
651   // Get the list of scroll position intervals for notification
652   Dali::Vector<float> results = scrollBar.GetScrollPositionIntervals();
653
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);
666
667   Property::Array resultArray = scrollBar.GetProperty<Property::Array>(Toolkit::ScrollBar::Property::SCROLL_POSITION_INTERVALS);
668
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);
680
681   END_TEST;
682 }
683
684 int UtcDaliToolkitScrollBarGetScrollDirectionP(void)
685 {
686   ToolkitTestApplication application;
687
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);
692
693   // Change the direction of scroll bar to horizontal
694   scrollBar.SetScrollDirection(ScrollBar::HORIZONTAL);
695   DALI_TEST_CHECK(scrollBar.GetScrollDirection() == ScrollBar::HORIZONTAL);
696
697   END_TEST;
698 }
699
700 int UtcDaliToolkitScrollBarSetIndicatorHeightPolicyP(void)
701 {
702   ToolkitTestApplication application;
703
704   // Create a scroll bar
705   ScrollBar scrollBar = ScrollBar::New();
706   DALI_TEST_CHECK(scrollBar);
707
708   float scrollBarHeight = 100.0f;
709   scrollBar.SetProperty(Actor::Property::SIZE, Vector3(20.0f, scrollBarHeight, 0.0f));
710   application.GetScene().Add(scrollBar);
711
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);
715
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);
721
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);
726
727   // Set the source of the scroll position properties.
728   scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
729
730   // Render and notify
731   application.SendNotification();
732   application.Render();
733
734   Actor indicator = scrollBar.GetScrollIndicator();
735   DALI_TEST_CHECK(indicator);
736
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);
741
742   // Set the indicator height to be fixed to 50.0f
743   scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::FIXED);
744   scrollBar.SetIndicatorFixedHeight(50.0f);
745
746   Property::Value value = scrollBar.GetProperty(ScrollBar::Property::INDICATOR_HEIGHT_POLICY);
747   DALI_TEST_EQUALS(value.Get<std::string>(), "FIXED", TEST_LOCATION);
748
749   // Render and notify
750   application.SendNotification();
751   application.Render();
752
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);
756
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);
761
762   // Render and notify
763   application.SendNotification();
764   application.Render();
765
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);
769
770   END_TEST;
771 }
772
773 int UtcDaliToolkitScrollBarGetIndicatorHeightPolicyP(void)
774 {
775   ToolkitTestApplication application;
776
777   // Create a scroll bar
778   ScrollBar scrollBar = ScrollBar::New();
779   DALI_TEST_CHECK(scrollBar);
780
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);
784
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);
788
789   END_TEST;
790 }
791
792 int UtcDaliToolkitScrollBarSetIndicatorFixedHeightP(void)
793 {
794   ToolkitTestApplication application;
795
796   // Create a scroll bar
797   ScrollBar scrollBar = ScrollBar::New();
798   DALI_TEST_CHECK(scrollBar);
799
800   float scrollBarHeight = 100.0f;
801   scrollBar.SetProperty(Actor::Property::SIZE, Vector3(20.0f, scrollBarHeight, 0.0f));
802   application.GetScene().Add(scrollBar);
803
804   Actor indicator = scrollBar.GetScrollIndicator();
805   DALI_TEST_CHECK(indicator);
806
807   // Set the indicator height to be fixed to 50.0f
808   scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::FIXED);
809   scrollBar.SetIndicatorFixedHeight(50.0f);
810
811   // Render and notify
812   application.SendNotification();
813   application.Render();
814
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);
817
818   // Set the indicator height to be fixed to 25.0f
819   scrollBar.SetIndicatorFixedHeight(25.0f);
820
821   // Render and notify
822   application.SendNotification();
823   application.Render();
824
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);
827
828   END_TEST;
829 }
830
831 int UtcDaliToolkitScrollBarGetIndicatorFixedHeightP(void)
832 {
833   ToolkitTestApplication application;
834
835   // Create a scroll bar
836   ScrollBar scrollBar = ScrollBar::New();
837   DALI_TEST_CHECK(scrollBar);
838
839   // Set the fixed indicator height to be 50.0f
840   scrollBar.SetIndicatorFixedHeight(50.0f);
841
842   // Check that the indicator size should be 50.0f
843   DALI_TEST_EQUALS(scrollBar.GetIndicatorFixedHeight(), 50.0f, TEST_LOCATION);
844
845   // Set the indicator height to be fixed to 25.0f
846   scrollBar.SetIndicatorFixedHeight(25.0f);
847
848   // Check that the indicator size should be 50.0f
849   DALI_TEST_EQUALS(scrollBar.GetIndicatorFixedHeight(), 25.0f, TEST_LOCATION);
850
851   END_TEST;
852 }
853
854 int UtcDaliToolkitScrollBarSetIndicatorShowDurationP(void)
855 {
856   ToolkitTestApplication application;
857
858   // Create a scroll bar
859   ScrollBar scrollBar = ScrollBar::New();
860   DALI_TEST_CHECK(scrollBar);
861
862   application.GetScene().Add(scrollBar);
863
864   Actor indicator = scrollBar.GetScrollIndicator();
865   DALI_TEST_CHECK(indicator);
866
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);
870
871   // Make the indicator invisible
872   indicator.SetProperty(Actor::Property::OPACITY, 0.0f);
873
874   // Render and notify
875   application.SendNotification();
876   application.Render();
877
878   // Check that the indicator is invisible
879   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
880
881   // Show the indicator
882   scrollBar.ShowIndicator();
883
884   // Wait for 0.35 second
885   Wait(application, 350);
886
887   // Render and notify
888   application.SendNotification();
889   application.Render();
890
891   // Check that the indicator is now visible
892   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
893
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);
897
898   // Make the indicator invisible
899   indicator.SetProperty(Actor::Property::OPACITY, 0.0f);
900
901   // Render and notify
902   application.SendNotification();
903   application.Render();
904
905   // Check that the indicator is invisible
906   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
907
908   // Show the indicator
909   scrollBar.ShowIndicator();
910
911   // Wait for 0.35 second first
912   Wait(application, 350);
913
914   // Render and notify
915   application.SendNotification();
916   application.Render();
917
918   // Check that the indicator is not fully visible yet
919   DALI_TEST_CHECK(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY) != 1.0f);
920
921   // Wait for another 0.4 second
922   Wait(application, 400);
923
924   // Render and notify
925   application.SendNotification();
926   application.Render();
927
928   // Check that the indicator is now fully visible
929   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
930
931   END_TEST;
932 }
933
934 int UtcDaliToolkitScrollBarSetIndicatorShowDurationN(void)
935 {
936   ToolkitTestApplication application;
937
938   // Create a scroll bar
939   ScrollBar scrollBar = ScrollBar::New();
940   DALI_TEST_CHECK(scrollBar);
941
942   application.GetScene().Add(scrollBar);
943
944   Actor indicator = scrollBar.GetScrollIndicator();
945   DALI_TEST_CHECK(indicator);
946
947   // Get the default duration to show the indicator
948   float duration = scrollBar.GetIndicatorShowDuration();
949
950   // Check that the default duration is greater than 0
951   DALI_TEST_CHECK(duration > 0.0f);
952
953   // Make the indicator invisible
954   indicator.SetProperty(Actor::Property::OPACITY, 0.0f);
955
956   // Render and notify
957   application.SendNotification();
958   application.Render();
959
960   // Check that the indicator is invisible
961   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
962
963   // Show the indicator
964   scrollBar.ShowIndicator();
965
966   // Wait for the specified duration
967   Wait(application, duration * 1000);
968
969   // Render and notify
970   application.SendNotification();
971   application.Render();
972
973   // Check that the indicator is now visible
974   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
975
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);
979
980   // Make the indicator invisible
981   indicator.SetProperty(Actor::Property::OPACITY, 0.0f);
982
983   // Render and notify
984   application.SendNotification();
985   application.Render();
986
987   // Check that the indicator is invisible
988   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
989
990   // Show the indicator
991   scrollBar.ShowIndicator();
992
993   // Render and notify
994   application.SendNotification();
995   application.Render();
996
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);
999
1000   END_TEST;
1001 }
1002
1003 int UtcDaliToolkitScrollBarGetIndicatorShowDurationP(void)
1004 {
1005   ToolkitTestApplication application;
1006
1007   // Create a scroll bar
1008   ScrollBar scrollBar = ScrollBar::New();
1009   DALI_TEST_CHECK(scrollBar);
1010
1011   // Set the duration to show the indicator to be 0.35 second
1012   scrollBar.SetIndicatorShowDuration(0.35f);
1013
1014   // Check that the duration to show the indicator is 0.35 second
1015   DALI_TEST_EQUALS(scrollBar.GetIndicatorShowDuration(), 0.35f, TEST_LOCATION);
1016
1017   // Set the duration to show the indicator to be 0.75 second
1018   scrollBar.SetIndicatorShowDuration(0.75f);
1019
1020   // Check that the duration to show the indicator is 0.75 second
1021   DALI_TEST_EQUALS(scrollBar.GetIndicatorShowDuration(), 0.75f, TEST_LOCATION);
1022
1023   END_TEST;
1024 }
1025
1026 int UtcDaliToolkitScrollBarSetIndicatorHideDurationP(void)
1027 {
1028   ToolkitTestApplication application;
1029
1030   // Create a scroll bar
1031   ScrollBar scrollBar = ScrollBar::New();
1032   DALI_TEST_CHECK(scrollBar);
1033
1034   application.GetScene().Add(scrollBar);
1035
1036   Actor indicator = scrollBar.GetScrollIndicator();
1037   DALI_TEST_CHECK(indicator);
1038
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);
1042
1043   // Make the indicator visible
1044   indicator.SetProperty(Actor::Property::OPACITY, 1.0f);
1045
1046   // Render and notify
1047   application.SendNotification();
1048   application.Render();
1049
1050   // Check that the indicator is visible
1051   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
1052
1053   // Hide the indicator
1054   scrollBar.HideIndicator();
1055
1056   // Wait for 0.15 second
1057   Wait(application, 150);
1058
1059   // Render and notify
1060   application.SendNotification();
1061   application.Render();
1062
1063   // Check that the indicator is now invisible
1064   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
1065
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);
1069
1070   // Make the indicator visible
1071   indicator.SetProperty(Actor::Property::OPACITY, 1.0f);
1072
1073   // Render and notify
1074   application.SendNotification();
1075   application.Render();
1076
1077   // Check that the indicator is visible
1078   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
1079
1080   // Hide the indicator
1081   scrollBar.HideIndicator();
1082
1083   // Wait for 0.15 second first
1084   Wait(application, 150);
1085
1086   // Render and notify
1087   application.SendNotification();
1088   application.Render();
1089
1090   // Check that the indicator is not fully invisible yet
1091   DALI_TEST_CHECK(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY) != 0.0f);
1092
1093   // Wait for another 0.5 second
1094   Wait(application, 500);
1095
1096   // Render and notify
1097   application.SendNotification();
1098   application.Render();
1099
1100   // Check that the indicator is now fully invisible
1101   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
1102
1103   END_TEST;
1104 }
1105
1106 int UtcDaliToolkitScrollBarSetIndicatorHideDurationN(void)
1107 {
1108   ToolkitTestApplication application;
1109
1110   // Create a scroll bar
1111   ScrollBar scrollBar = ScrollBar::New();
1112   DALI_TEST_CHECK(scrollBar);
1113
1114   application.GetScene().Add(scrollBar);
1115
1116   Actor indicator = scrollBar.GetScrollIndicator();
1117   DALI_TEST_CHECK(indicator);
1118
1119   // Get the default duration to hide the indicator
1120   float duration = scrollBar.GetIndicatorHideDuration();
1121
1122   // Check that the default duration is greater than 0
1123   DALI_TEST_CHECK(duration > 0.0f);
1124
1125   // Make the indicator visible
1126   indicator.SetProperty(Actor::Property::OPACITY, 1.0f);
1127
1128   // Render and notify
1129   application.SendNotification();
1130   application.Render();
1131
1132   // Check that the indicator is visible
1133   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
1134
1135   // Hide the indicator
1136   scrollBar.HideIndicator();
1137
1138   // Wait for the specified duration
1139   Wait(application, duration * 1000);
1140
1141   // Render and notify
1142   application.SendNotification();
1143   application.Render();
1144
1145   // Check that the indicator is now invisible
1146   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
1147
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);
1151
1152   // Make the indicator visible
1153   indicator.SetProperty(Actor::Property::OPACITY, 1.0f);
1154
1155   // Render and notify
1156   application.SendNotification();
1157   application.Render();
1158
1159   // Check that the indicator is visible
1160   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
1161
1162   // Hide the indicator
1163   scrollBar.HideIndicator();
1164
1165   // Render and notify
1166   application.SendNotification();
1167   application.Render();
1168
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);
1171
1172   END_TEST;
1173 }
1174
1175 int UtcDaliToolkitScrollBarGetIndicatorHideDurationP(void)
1176 {
1177   ToolkitTestApplication application;
1178
1179   // Create a scroll bar
1180   ScrollBar scrollBar = ScrollBar::New();
1181   DALI_TEST_CHECK(scrollBar);
1182
1183   // Set the duration to hide the indicator to be 0.15 second
1184   scrollBar.SetIndicatorHideDuration(0.15f);
1185
1186   // Check that the duration to hide the indicator is 0.15 second
1187   DALI_TEST_EQUALS(scrollBar.GetIndicatorHideDuration(), 0.15f, TEST_LOCATION);
1188
1189   // Set the duration to hide the indicator to be 0.65 second
1190   scrollBar.SetIndicatorHideDuration(0.65f);
1191
1192   // Check that the duration to hide the indicator is 0.65 second
1193   DALI_TEST_EQUALS(scrollBar.GetIndicatorHideDuration(), 0.65f, TEST_LOCATION);
1194
1195   END_TEST;
1196 }
1197
1198 int UtcDaliToolkitScrollBarShowIndicatorP(void)
1199 {
1200   ToolkitTestApplication application;
1201
1202   // Create a scroll bar
1203   ScrollBar scrollBar = ScrollBar::New();
1204   DALI_TEST_CHECK(scrollBar);
1205
1206   application.GetScene().Add(scrollBar);
1207
1208   Actor indicator = scrollBar.GetScrollIndicator();
1209   DALI_TEST_CHECK(indicator);
1210
1211   // Get the default duration to show the indicator
1212   float duration = scrollBar.GetIndicatorShowDuration();
1213
1214   // Check that the default duration is greater than 0
1215   DALI_TEST_CHECK(duration > 0.0f);
1216
1217   // Make the indicator invisible
1218   indicator.SetProperty(Actor::Property::OPACITY, 0.0f);
1219
1220   // Render and notify
1221   application.SendNotification();
1222   application.Render();
1223
1224   // Check that the indicator is invisible
1225   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
1226
1227   // Show the indicator
1228   scrollBar.ShowIndicator();
1229
1230   // Wait for the specified duration
1231   Wait(application, duration * 1000);
1232
1233   // Render and notify
1234   application.SendNotification();
1235   application.Render();
1236
1237   // Check that the indicator is now visible
1238   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
1239
1240   END_TEST;
1241 }
1242
1243 int UtcDaliToolkitScrollBarShowIndicatorN(void)
1244 {
1245   ToolkitTestApplication application;
1246
1247   // Create a scroll bar
1248   ScrollBar scrollBar = ScrollBar::New();
1249   DALI_TEST_CHECK(scrollBar);
1250
1251   application.GetScene().Add(scrollBar);
1252
1253   Actor indicator = scrollBar.GetScrollIndicator();
1254   DALI_TEST_CHECK(indicator);
1255
1256   // Make the indicator initially visible
1257   indicator.SetProperty(Actor::Property::OPACITY, 1.0f);
1258
1259   // Render and notify
1260   application.SendNotification();
1261   application.Render();
1262
1263   // Check that the indicator is initially visible
1264   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
1265
1266   // Get the default duration to show the indicator
1267   float duration = scrollBar.GetIndicatorShowDuration();
1268
1269   // Check that the default duration is greater than 0
1270   DALI_TEST_CHECK(duration > 0.0f);
1271
1272   // Show the indicator
1273   scrollBar.ShowIndicator();
1274
1275   // Render and notify
1276   application.SendNotification();
1277   application.Render();
1278
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);
1281
1282   END_TEST;
1283 }
1284
1285 int UtcDaliToolkitScrollBarHideIndicatorP(void)
1286 {
1287   ToolkitTestApplication application;
1288
1289   // Create a scroll bar
1290   ScrollBar scrollBar = ScrollBar::New();
1291   DALI_TEST_CHECK(scrollBar);
1292
1293   application.GetScene().Add(scrollBar);
1294
1295   Actor indicator = scrollBar.GetScrollIndicator();
1296   DALI_TEST_CHECK(indicator);
1297
1298   // Get the default duration to hide the indicator
1299   float duration = scrollBar.GetIndicatorHideDuration();
1300
1301   // Check that the default duration is greater than 0
1302   DALI_TEST_CHECK(duration > 0.0f);
1303
1304   // Make the indicator visible
1305   indicator.SetProperty(Actor::Property::OPACITY, 1.0f);
1306
1307   // Render and notify
1308   application.SendNotification();
1309   application.Render();
1310
1311   // Check that the indicator is visible
1312   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
1313
1314   // Hide the indicator
1315   scrollBar.HideIndicator();
1316
1317   // Wait for the specified duration
1318   Wait(application, duration * 1000);
1319
1320   // Render and notify
1321   application.SendNotification();
1322   application.Render();
1323
1324   // Check that the indicator is now invisible
1325   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
1326
1327   END_TEST;
1328 }
1329
1330 int UtcDaliToolkitScrollBarHideIndicatorN(void)
1331 {
1332   ToolkitTestApplication application;
1333
1334   // Create a scroll bar
1335   ScrollBar scrollBar = ScrollBar::New();
1336   DALI_TEST_CHECK(scrollBar);
1337
1338   application.GetScene().Add(scrollBar);
1339
1340   Actor indicator = scrollBar.GetScrollIndicator();
1341   DALI_TEST_CHECK(indicator);
1342
1343   // Make the indicator initially invisible
1344   indicator.SetProperty(Actor::Property::OPACITY, 0.0f);
1345
1346   // Render and notify
1347   application.SendNotification();
1348   application.Render();
1349
1350   // Check that the indicator is initially invisible
1351   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
1352
1353   // Get the default duration to hide the indicator
1354   float duration = scrollBar.GetIndicatorHideDuration();
1355
1356   // Check that the default duration is greater than 0
1357   DALI_TEST_CHECK(duration > 0.0f);
1358
1359   // Hide the indicator
1360   scrollBar.HideIndicator();
1361
1362   // Render and notify
1363   application.SendNotification();
1364   application.Render();
1365
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);
1368
1369   END_TEST;
1370 }
1371
1372 int UtcDaliToolkitScrollBarActionShowIndicator(void)
1373 {
1374   ToolkitTestApplication application;
1375
1376   // Create a scroll bar
1377   ScrollBar scrollBar = ScrollBar::New();
1378   DALI_TEST_CHECK(scrollBar);
1379
1380   application.GetScene().Add(scrollBar);
1381
1382   Actor indicator = scrollBar.GetScrollIndicator();
1383   DALI_TEST_CHECK(indicator);
1384
1385   // Get the default duration to hide the indicator
1386   float duration = scrollBar.GetProperty<float>(ScrollBar::Property::INDICATOR_SHOW_DURATION);
1387
1388   // Check that the default duration is greater than 0
1389   DALI_TEST_CHECK(duration > 0.0f);
1390
1391   // Make the indicator invisible
1392   indicator.SetProperty(Actor::Property::OPACITY, 0.0f);
1393
1394   // Render and notify
1395   application.SendNotification();
1396   application.Render();
1397
1398   // Check that the indicator is invisible
1399   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
1400
1401   // Do the "ShowIndicator" action
1402   Property::Map emptyMap;
1403   scrollBar.DoAction("ShowIndicator", emptyMap);
1404
1405   // Wait for the specified duration
1406   Wait(application, duration * 1000);
1407
1408   // Render and notify
1409   application.SendNotification();
1410   application.Render();
1411
1412   // Check that the indicator is now visible
1413   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
1414
1415   END_TEST;
1416 }
1417
1418 int UtcDaliToolkitScrollBarActionHideIndicator(void)
1419 {
1420   ToolkitTestApplication application;
1421
1422   // Create a scroll bar
1423   ScrollBar scrollBar = ScrollBar::New();
1424   DALI_TEST_CHECK(scrollBar);
1425
1426   application.GetScene().Add(scrollBar);
1427
1428   Actor indicator = scrollBar.GetScrollIndicator();
1429   DALI_TEST_CHECK(indicator);
1430
1431   // Get the default duration to hide the indicator
1432   float duration = scrollBar.GetProperty<float>(ScrollBar::Property::INDICATOR_HIDE_DURATION);
1433
1434   // Check that the default duration is greater than 0
1435   DALI_TEST_CHECK(duration > 0.0f);
1436
1437   // Make the indicator visible
1438   indicator.SetProperty(Actor::Property::OPACITY, 1.0f);
1439
1440   // Render and notify
1441   application.SendNotification();
1442   application.Render();
1443
1444   // Check that the indicator is visible
1445   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
1446
1447   // Do the "HideIndicator" action
1448   Property::Map emptyMap;
1449   scrollBar.DoAction("HideIndicator", emptyMap);
1450
1451   // Wait for the specified duration
1452   Wait(application, duration * 1000);
1453
1454   // Render and notify
1455   application.SendNotification();
1456   application.Render();
1457
1458   // Check that the indicator is now invisible
1459   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
1460
1461   END_TEST;
1462 }
1463
1464 int UtcDaliToolkitScrollBarActionShowTransientIndicator(void)
1465 {
1466   ToolkitTestApplication application;
1467
1468   // Create a scroll bar
1469   ScrollBar scrollBar = ScrollBar::New();
1470   DALI_TEST_CHECK(scrollBar);
1471
1472   application.GetScene().Add(scrollBar);
1473
1474   Actor indicator = scrollBar.GetScrollIndicator();
1475   DALI_TEST_CHECK(indicator);
1476
1477   // Get the default duration to hide the indicator
1478   float duration = scrollBar.GetProperty<float>(ScrollBar::Property::INDICATOR_SHOW_DURATION);
1479
1480   // Check that the default duration is greater than 0
1481   DALI_TEST_CHECK(duration > 0.0f);
1482
1483   // Make the indicator invisible
1484   indicator.SetProperty(Actor::Property::OPACITY, 0.0f);
1485
1486   // Render and notify
1487   application.SendNotification();
1488   application.Render();
1489
1490   // Check that the indicator is invisible
1491   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
1492
1493   // Do the "ShowIndicator" action
1494   Property::Map emptyMap;
1495   scrollBar.DoAction("ShowTransientIndicator", emptyMap);
1496
1497   // Wait for the specified duration
1498   Wait(application, duration * 1000);
1499
1500   // Render and notify
1501   application.SendNotification();
1502   application.Render();
1503
1504   // Check that the indicator is now visible
1505   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
1506
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;
1511
1512   // Check that the default duration is greater than 0
1513   DALI_TEST_CHECK(totalVisibleDuration > 0.0f);
1514
1515   // Wait for the specified duration
1516   Wait(application, totalVisibleDuration * 1000);
1517
1518   // Render and notify
1519   application.SendNotification();
1520   application.Render();
1521
1522   // Check that the indicator is now invisible
1523   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
1524
1525   END_TEST;
1526 }
1527
1528 int UtcDaliToolkitScrollBarActionShowTransientIndicatorImmediate(void)
1529 {
1530   ToolkitTestApplication application;
1531
1532   // Create a scroll bar
1533   ScrollBar scrollBar = ScrollBar::New();
1534   DALI_TEST_CHECK(scrollBar);
1535
1536   application.GetScene().Add(scrollBar);
1537
1538   Actor indicator = scrollBar.GetScrollIndicator();
1539   DALI_TEST_CHECK(indicator);
1540
1541   // Make the indicator invisible
1542   indicator.SetProperty(Actor::Property::OPACITY, 0.0f);
1543
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);
1548
1549   // Render and notify
1550   application.SendNotification();
1551   application.Render();
1552
1553   // Do the "ShowIndicator" action
1554   Property::Map emptyMap;
1555   scrollBar.DoAction("ShowTransientIndicator", emptyMap);
1556
1557   // Wait for the specified duration
1558   Wait(application);
1559
1560   // Render and notify
1561   application.SendNotification();
1562   application.Render();
1563
1564   // Check that the indicator is now visible
1565   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
1566
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;
1571
1572   // Check that the default duration is greater than 0
1573   DALI_TEST_CHECK(totalVisibleDuration > 0.0f);
1574
1575   // Wait for the specified duration
1576   Wait(application, totalVisibleDuration * 1000);
1577
1578   // Render and notify
1579   application.SendNotification();
1580   application.Render();
1581
1582   // Check that the indicator is now invisible
1583   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
1584
1585   END_TEST;
1586 }
1587
1588 int UtcDaliToolkitScrollBarActionShowTransientIndicatorDuringHide(void)
1589 {
1590   ToolkitTestApplication application;
1591
1592   // Create a scroll bar
1593   ScrollBar scrollBar = ScrollBar::New();
1594   DALI_TEST_CHECK(scrollBar);
1595
1596   application.GetScene().Add(scrollBar);
1597
1598   Actor indicator = scrollBar.GetScrollIndicator();
1599   DALI_TEST_CHECK(indicator);
1600
1601   // Get the default duration to hide the indicator
1602   float duration = scrollBar.GetIndicatorHideDuration();
1603
1604   // Check that the default duration is greater than 0
1605   DALI_TEST_CHECK(duration > 0.0f);
1606
1607   // Make the indicator visible
1608   indicator.SetProperty(Actor::Property::OPACITY, 1.0f);
1609
1610   // Render and notify
1611   application.SendNotification();
1612   application.Render();
1613
1614   // Check that the indicator is visible
1615   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
1616
1617   // Hide the indicator
1618   scrollBar.HideIndicator();
1619
1620   // Wait for half the specified duration
1621   Wait(application, duration * 0.5f * 1000);
1622
1623   // Render and notify
1624   application.SendNotification();
1625   application.Render();
1626
1627   // Check that the indicator is now partially hidden
1628   DALI_TEST_CHECK(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY) < 1.0f);
1629
1630   // Now interrupt the Hide with a DoAction( "ShowTransientIndicator" )
1631
1632   // Get the default duration to hide the indicator
1633   duration = scrollBar.GetProperty<float>(ScrollBar::Property::INDICATOR_SHOW_DURATION);
1634
1635   // Check that the default duration is greater than 0
1636   DALI_TEST_CHECK(duration > 0.0f);
1637
1638   // Do the "ShowIndicator" action
1639   Property::Map emptyMap;
1640   scrollBar.DoAction("ShowTransientIndicator", emptyMap);
1641
1642   // Wait for the specified duration
1643   Wait(application, duration * 1000);
1644
1645   // Render and notify
1646   application.SendNotification();
1647   application.Render();
1648
1649   // Check that the indicator is now visible
1650   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, TEST_LOCATION);
1651
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;
1656
1657   // Check that the default duration is greater than 0
1658   DALI_TEST_CHECK(totalVisibleDuration > 0.0f);
1659
1660   // Wait for the specified duration
1661   Wait(application, totalVisibleDuration * 1000);
1662
1663   // Render and notify
1664   application.SendNotification();
1665   application.Render();
1666
1667   // Check that the indicator is now invisible
1668   DALI_TEST_EQUALS(indicator.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, TEST_LOCATION);
1669
1670   END_TEST;
1671 }
1672
1673 int UtcDaliToolkitScrollBarPanFinishedSignalP(void)
1674 {
1675   ToolkitTestApplication application;
1676
1677   // Create a vertical scroll bar
1678   ScrollBar scrollBar = ScrollBar::New(ScrollBar::VERTICAL);
1679   DALI_TEST_CHECK(scrollBar);
1680
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));
1684
1685   // Set the indicator height to be fixed to 50.0f
1686   scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::FIXED);
1687   scrollBar.SetIndicatorFixedHeight(50.0f);
1688
1689   application.GetScene().Add(scrollBar);
1690
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));
1696
1697   // Render and notify
1698   application.SendNotification();
1699   application.Render();
1700
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);
1704
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);
1710
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);
1715
1716   // Set the source of the scroll position properties.
1717   scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1718
1719   // Render and notify
1720   application.SendNotification();
1721   application.Render();
1722
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);
1727
1728   END_TEST;
1729 }
1730
1731 int UtcDaliToolkitScrollBarPanFinishedSignalN(void)
1732 {
1733   ToolkitTestApplication application;
1734
1735   // Create a vertical scroll bar
1736   ScrollBar scrollBar = ScrollBar::New(ScrollBar::VERTICAL);
1737   DALI_TEST_CHECK(scrollBar);
1738
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));
1742
1743   // Set the indicator height to be fixed to 50.0f
1744   scrollBar.SetIndicatorHeightPolicy(Toolkit::ScrollBar::FIXED);
1745   scrollBar.SetIndicatorFixedHeight(50.0f);
1746
1747   application.GetScene().Add(scrollBar);
1748
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));
1754
1755   // Render and notify
1756   application.SendNotification();
1757   application.Render();
1758
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);
1762
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);
1766
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);
1772
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);
1777
1778   // Set the source of the scroll position properties.
1779   scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1780
1781   // Render and notify
1782   application.SendNotification();
1783   application.Render();
1784
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);
1789
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);
1794
1795   END_TEST;
1796 }
1797
1798 int UtcDaliToolkitScrollBarScrollPositionIntervalReachedSignalP(void)
1799 {
1800   ToolkitTestApplication application;
1801
1802   // Create a vertical scroll bar
1803   ScrollBar scrollBar = ScrollBar::New(ScrollBar::VERTICAL);
1804   DALI_TEST_CHECK(scrollBar);
1805
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));
1809
1810   application.GetScene().Add(scrollBar);
1811   ConnectionTracker connectionTracker;
1812
1813   // Connect to the ScrollPositionIntervalReached signal
1814   bool intervalReached = false;
1815   scrollBar.ScrollPositionIntervalReachedSignal().Connect(&OnScrollPositionIntervalReached);
1816   scrollBar.ConnectSignal(&connectionTracker, "scrollPositionIntervalReached", CallbackFunctor(&intervalReached));
1817
1818   // Render and notify
1819   application.SendNotification();
1820   application.Render();
1821
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);
1825
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);
1831
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);
1836
1837   // Set the source of the scroll position properties.
1838   scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1839
1840   // Render and notify
1841   application.SendNotification();
1842   application.Render();
1843
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)
1847   {
1848     positionIntervals.PushBack(-80.0f * i); // should get notified for each 80 pixels
1849   }
1850   scrollBar.SetScrollPositionIntervals(positionIntervals);
1851
1852   // Render and notify
1853   application.SendNotification();
1854   application.Render();
1855
1856   // Reset the flag
1857   gOnScrollPositionIntervalReachedSignalCalled = false;
1858
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);
1862   animation.Play();
1863
1864   // Wait for 0.1 second
1865   Wait(application, 100);
1866
1867   // Check that the signal callback is called
1868   DALI_TEST_EQUALS(gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION);
1869   DALI_TEST_EQUALS(intervalReached, true, TEST_LOCATION);
1870
1871   // Reset the flag
1872   gOnScrollPositionIntervalReachedSignalCalled = false;
1873   intervalReached                              = false;
1874
1875   // Rest and clear the animation
1876   animation.Clear();
1877   animation.Reset();
1878
1879   // Animate the scroll position to cross another specified value
1880   animation = Animation::New(0.1f);
1881   animation.AnimateTo(Property(sourceActor, propertyScrollPosition), -170.0f);
1882   animation.Play();
1883
1884   // Wait for 0.1 second
1885   Wait(application, 100);
1886
1887   // Check that the signal callback is called
1888   DALI_TEST_EQUALS(gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION);
1889   DALI_TEST_EQUALS(intervalReached, true, TEST_LOCATION);
1890
1891   // Reset the flag
1892   gOnScrollPositionIntervalReachedSignalCalled = false;
1893   intervalReached                              = false;
1894
1895   // Rest and clear the animation
1896   animation.Clear();
1897   animation.Reset();
1898
1899   // Animate the scroll position back to the previous value
1900   animation = Animation::New(0.1f);
1901   animation.AnimateTo(Property(sourceActor, propertyScrollPosition), -85.0f);
1902   animation.Play();
1903
1904   // Wait for 0.1 second
1905   Wait(application, 100);
1906
1907   // Check that the signal callback is called
1908   DALI_TEST_EQUALS(gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION);
1909   DALI_TEST_EQUALS(intervalReached, true, TEST_LOCATION);
1910
1911   END_TEST;
1912 }
1913
1914 int UtcDaliToolkitScrollBarScrollPositionIntervalReachedSignalN(void)
1915 {
1916   ToolkitTestApplication application;
1917
1918   // Create a vertical scroll bar
1919   ScrollBar scrollBar = ScrollBar::New(ScrollBar::VERTICAL);
1920   DALI_TEST_CHECK(scrollBar);
1921
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));
1925
1926   application.GetScene().Add(scrollBar);
1927
1928   // Connect to the ScrollPositionIntervalReached signal
1929   scrollBar.ScrollPositionIntervalReachedSignal().Connect(&OnScrollPositionIntervalReached);
1930
1931   // Render and notify
1932   application.SendNotification();
1933   application.Render();
1934
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);
1938
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);
1944
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);
1949
1950   // Set the source of the scroll position properties.
1951   scrollBar.SetScrollPropertySource(sourceActor, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
1952
1953   // Render and notify
1954   application.SendNotification();
1955   application.Render();
1956
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)
1960   {
1961     positionIntervals.PushBack(-80.0f * i); // should get notified for each 80 pixels
1962   }
1963   scrollBar.SetScrollPositionIntervals(positionIntervals);
1964
1965   // Render and notify
1966   application.SendNotification();
1967   application.Render();
1968
1969   // Reset the flag
1970   gOnScrollPositionIntervalReachedSignalCalled = false;
1971
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);
1975   animation.Play();
1976
1977   // Wait for 0.1 second
1978   Wait(application, 100);
1979
1980   // Check that the signal callback is not called
1981   DALI_TEST_EQUALS(gOnScrollPositionIntervalReachedSignalCalled, false, TEST_LOCATION);
1982
1983   // Rest and clear the animation
1984   animation.Clear();
1985   animation.Reset();
1986
1987   // Animate the scroll position to cross another specified value
1988   animation = Animation::New(0.1f);
1989   animation.AnimateTo(Property(sourceActor, propertyScrollPosition), -85.0f);
1990   animation.Play();
1991
1992   // Wait for 0.1 second
1993   Wait(application, 100);
1994
1995   // Check that the signal callback is called
1996   DALI_TEST_EQUALS(gOnScrollPositionIntervalReachedSignalCalled, true, TEST_LOCATION);
1997
1998   END_TEST;
1999 }