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