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