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