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