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