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