(Automated Tests) Use Scene instead of Stage
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-ItemView.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 <float.h>       // for FLT_MAX
21
22 // Need to override adaptor classes for toolkit test harness, so include
23 // test harness headers before dali headers.
24 #include <dali-toolkit-test-suite-utils.h>
25 #include <dali-toolkit/dali-toolkit.h>
26 #include <dali/integration-api/events/touch-event-integ.h>
27
28
29 using namespace Dali;
30 using namespace Toolkit;
31
32 void utc_dali_toolkit_item_view_startup(void)
33 {
34   test_return_value = TET_UNDEF;
35 }
36
37 void utc_dali_toolkit_item_view_cleanup(void)
38 {
39   test_return_value = TET_PASS;
40 }
41
42 namespace
43 {
44
45 const unsigned int TOTAL_ITEM_NUMBER = 400;
46 const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
47
48 const int RENDER_FRAME_INTERVAL = 16;                     ///< Duration of each frame in ms. (at approx 60FPS)
49
50 static bool gObjectCreatedCallBackCalled;
51 static bool gOnLayoutActivatedCalled;                     ///< Whether the LayoutActivated signal was invoked.
52 static bool gOnScrollUpdateCalled;
53
54 static void TestCallback(BaseHandle handle)
55 {
56   gObjectCreatedCallBackCalled = true;
57 }
58
59 static void OnLayoutActivated()
60 {
61   gOnLayoutActivatedCalled = true;
62 }
63
64 static void OnScrollUpdate( const Vector2& position )
65 {
66   gOnScrollUpdateCalled = true;
67 }
68
69 Integration::TouchEvent GenerateSingleTouch( PointState::Type state, const Vector2& screenPosition, uint32_t time )
70 {
71   Integration::TouchEvent touchEvent;
72   Integration::Point point;
73   point.SetState( state );
74   point.SetDeviceId(4);
75   point.SetScreenPosition( screenPosition );
76   point.SetDeviceClass( Device::Class::TOUCH );
77   point.SetDeviceSubclass( Device::Subclass::NONE );
78   touchEvent.points.push_back( point );
79   touchEvent.time = time;
80   return touchEvent;
81 }
82
83 /*
84  * Simulate time passed by.
85  *
86  * @note this will always process at least 1 frame (1/60 sec)
87  *
88  * @param application Test application instance
89  * @param duration Time to pass in milliseconds.
90  * @return The actual time passed in milliseconds
91  */
92 int Wait(ToolkitTestApplication& application, int duration = 0)
93 {
94   int time = 0;
95
96   for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
97   {
98     application.SendNotification();
99     application.Render(RENDER_FRAME_INTERVAL);
100     time += RENDER_FRAME_INTERVAL;
101   }
102
103   return time;
104 }
105
106 // Implementation of ItemFactory for providing actors to ItemView
107 class TestItemFactory : public ItemFactory
108 {
109 public:
110
111   /**
112    * Constructor
113    * @param application class, stored as reference
114    */
115   TestItemFactory()
116   {
117   }
118
119 public: // From ItemFactory
120
121   /**
122    * Query the number of items available from the factory.
123    * The maximum available item has an ID of GetNumberOfItems() - 1.
124    */
125   virtual unsigned int GetNumberOfItems()
126   {
127     return TOTAL_ITEM_NUMBER;
128   }
129
130   /**
131    * Create an Actor to represent a visible item.
132    * @param itemId
133    * @return the created actor.
134    */
135   virtual Actor NewItem(unsigned int itemId)
136   {
137     // Create a renderable actor for this item
138     return ImageView::New( TEST_IMAGE_FILE_NAME );
139   }
140 };
141
142 } // namespace
143
144
145 int UtcDaliItemViewNew(void)
146 {
147   ToolkitTestApplication application;
148
149   // Create the ItemView actor
150   TestItemFactory factory;
151   ItemView view = ItemView::New(factory);
152
153   DALI_TEST_CHECK(view);
154
155   //Additional check to ensure object is created by checking if it's registered
156   ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
157   DALI_TEST_CHECK( registry );
158
159   gObjectCreatedCallBackCalled = false;
160   registry.ObjectCreatedSignal().Connect(&TestCallback);
161   {
162     TestItemFactory factory;
163     ItemView view = ItemView::New(factory);
164   }
165   DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
166   END_TEST;
167 }
168
169 int UtcDaliItemViewDownCast(void)
170 {
171   ToolkitTestApplication application;
172
173   // Create the ItemView actor
174   TestItemFactory factory;
175   const ItemView itemViewConst = ItemView::New(factory);
176   ItemView itemView(itemViewConst);
177
178   BaseHandle handle(itemView);
179
180   ItemView newItemView = ItemView::DownCast( handle );
181   DALI_TEST_CHECK( itemView );
182   DALI_TEST_CHECK( newItemView == itemView );
183   END_TEST;
184 }
185
186 int UtcDaliItemViewAddAndGetLayout(void)
187 {
188   ToolkitTestApplication application;
189
190   // Create the ItemView actor
191   TestItemFactory factory;
192   ItemView view = ItemView::New(factory);
193
194   // Create a grid layout and add it to ItemView
195   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
196   view.AddLayout(*gridLayout);
197
198   // As we have added one layout, check the number of layout is now 1
199   DALI_TEST_CHECK(view.GetLayoutCount() == 1);
200
201   // Create a depth layout and add it to ItemView
202   ItemLayoutPtr depthLayout = DefaultItemLayout::New( DefaultItemLayout::DEPTH );
203   view.AddLayout(*depthLayout);
204
205   // As we have added another layout, check the number of layout is now 2
206   DALI_TEST_CHECK(view.GetLayoutCount() == 2);
207
208   // Create a spiral layout and add it to ItemView
209   ItemLayoutPtr spiralLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL );
210   view.AddLayout(*spiralLayout);
211
212   // As we have added another layout, check the number of layout is now 3
213   DALI_TEST_CHECK(view.GetLayoutCount() == 3);
214
215   // Check we are getting the correct layout from ItemView
216   DALI_TEST_CHECK(view.GetLayout(0) == gridLayout);
217   DALI_TEST_CHECK(view.GetLayout(1) == depthLayout);
218   DALI_TEST_CHECK(view.GetLayout(2) == spiralLayout);
219   END_TEST;
220 }
221
222 int UtcDaliItemViewAddAndRemoveLayout(void)
223 {
224   ToolkitTestApplication application;
225
226   // Create the ItemView actor
227   TestItemFactory factory;
228   ItemView view = ItemView::New(factory);
229
230   // Create a grid layout and add it to ItemView
231   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
232   view.AddLayout(*gridLayout);
233
234   // As we have added one layout, check the number of layout is now 1
235   DALI_TEST_CHECK(view.GetLayoutCount() == 1);
236
237   // Create a depth layout and add it to ItemView
238   ItemLayoutPtr depthLayout = DefaultItemLayout::New( DefaultItemLayout::DEPTH );
239   view.AddLayout(*depthLayout);
240
241   // As we have added another layout, check the number of layout is now 2
242   DALI_TEST_CHECK(view.GetLayoutCount() == 2);
243
244   // Check we are getting the correct layout from ItemView
245   DALI_TEST_CHECK(view.GetLayout(0) == gridLayout);
246   DALI_TEST_CHECK(view.GetLayout(1) == depthLayout);
247
248   // Remove the grid layout
249   view.RemoveLayout(0);
250
251   // As we have removed the grid layout, check the number of layout is now 1
252   DALI_TEST_CHECK(view.GetLayoutCount() == 1);
253
254   // Check we are getting the correct layout from ItemView
255   DALI_TEST_CHECK(view.GetLayout(0) == depthLayout);
256
257   // Remove the depth layout
258   view.RemoveLayout(0);
259
260   // As we also removed the depth layout, check the number of layout is now 0
261   DALI_TEST_CHECK(view.GetLayoutCount() == 0);
262   END_TEST;
263 }
264
265 int UtcDaliItemViewActivateLayoutAndGetActiveLayout(void)
266 {
267   ToolkitTestApplication application;
268
269   // Create the ItemView actor
270   TestItemFactory factory;
271   ItemView view = ItemView::New(factory);
272
273   // Create a grid layout and add it to ItemView
274   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
275   view.AddLayout(*gridLayout);
276
277   // Create a depth layout and add it to ItemView
278   ItemLayoutPtr depthLayout = DefaultItemLayout::New( DefaultItemLayout::DEPTH );
279   view.AddLayout(*depthLayout);
280
281   // Create a spiral layout and add it to ItemView
282   ItemLayoutPtr spiralLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL );
283   view.AddLayout(*spiralLayout);
284
285   // As we have added three layouts, check the number of layout is now 3
286   DALI_TEST_CHECK(view.GetLayoutCount() == 3);
287
288   // Check there is no active layout at the moment
289   DALI_TEST_CHECK(view.GetActiveLayout() == NULL);
290
291   // Activate the depth layout
292   Vector3 stageSize(application.GetScene().GetSize());
293   view.ActivateLayout(1, stageSize, 0.5f);
294
295   // Check the current active layout is the depth layout
296   DALI_TEST_CHECK(view.GetActiveLayout() == depthLayout);
297
298   // Activate the grid layout
299   view.ActivateLayout(0, stageSize, 0.5f);
300
301   // Check the current active layout is the grid layout
302   DALI_TEST_CHECK(view.GetActiveLayout() == gridLayout);
303
304   // Activate the spiral layout
305   view.ActivateLayout(2, stageSize, 0.5f);
306
307   // Check the current active layout is the spiral layout
308   DALI_TEST_CHECK(view.GetActiveLayout() == spiralLayout);
309   END_TEST;
310 }
311
312 int UtcDaliItemViewDeactivateCurrentLayout(void)
313 {
314   ToolkitTestApplication application;
315
316   // Create the ItemView actor
317   TestItemFactory factory;
318   ItemView view = ItemView::New(factory);
319
320   // Create a grid layout and add it to ItemView
321   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
322   gridLayout->SetOrientation(ControlOrientation::Down);
323   view.AddLayout(*gridLayout);
324
325   // Check there is no active layout at the moment
326   DALI_TEST_CHECK(view.GetActiveLayout() == NULL);
327
328   // Activate the grid layout
329   Vector3 stageSize(application.GetScene().GetSize());
330   view.ActivateLayout(0, stageSize, 0.5f);
331
332   // Check the current active layout is the grid layout
333   DALI_TEST_CHECK(view.GetActiveLayout() == gridLayout);
334
335   // Deactivate the current layout
336   view.DeactivateCurrentLayout();
337
338   // Check there is no active layout at the moment
339   DALI_TEST_CHECK(view.GetActiveLayout() == NULL);
340   END_TEST;
341 }
342
343 int UtcDaliItemViewGetItemAndGetItemId(void)
344 {
345   ToolkitTestApplication application;
346
347   // Create the ItemView actor
348   TestItemFactory factory;
349   ItemView view = ItemView::New(factory);
350
351   // Create a grid layout and add it to ItemView
352   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
353   gridLayout->SetOrientation(ControlOrientation::Left);
354   view.AddLayout(*gridLayout);
355
356   // Activate the grid layout so that the items will be created and added to ItemView
357   Vector3 stageSize(application.GetScene().GetSize());
358   view.ActivateLayout(0, stageSize, 0.5f);
359
360   // Get the item given the item ID
361   Actor itemActor = view.GetItem(2);
362
363   // Check we are getting the correct Item ID given the specified actor
364   DALI_TEST_CHECK(view.GetItemId(itemActor) == 2);
365   END_TEST;
366 }
367
368 int UtcDaliItemViewRemoveItem(void)
369 {
370   ToolkitTestApplication application;
371
372   // Create the ItemView actor
373   TestItemFactory factory;
374   ItemView view = ItemView::New(factory);
375
376   // Create a grid layout and add it to ItemView
377   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
378   gridLayout->SetOrientation(ControlOrientation::Right);
379   view.AddLayout(*gridLayout);
380
381   // Activate the grid layout so that the items will be created and added to ItemView
382   Vector3 stageSize(application.GetScene().GetSize());
383   view.ActivateLayout(0, stageSize, 0.5f);
384
385   // Get the item given the item ID 2 and 3
386   Actor oldItemActorID2 = view.GetItem(2);
387   Actor oldItemActorID3 = view.GetItem(3);
388
389   // Remove the item with ID 2
390   view.RemoveItem(2, 0.0f);
391
392   // Get the new item given the item ID 2 and 3
393   Actor newItemActorID2 = view.GetItem(2);
394   Actor newItemActorID3 = view.GetItem(3);
395
396   // Check the original item with item ID 2 was deleted and now item ID 2 represents the original item with ID 3
397   DALI_TEST_CHECK(view.GetItemId(newItemActorID2) == 2);
398   DALI_TEST_CHECK(oldItemActorID2 != newItemActorID2);
399   DALI_TEST_CHECK(newItemActorID2 == oldItemActorID3);
400
401   // scroll to the end of item view
402   view.ScrollToItem(TOTAL_ITEM_NUMBER - 1, 0.00f);
403
404   application.SendNotification();
405   application.Render(0);
406
407   // Refresh the item view
408   view.Refresh();
409
410   Actor itemActorID390 = view.GetItem(390);
411   DALI_TEST_CHECK(view.GetItemId(itemActorID390) == 390);
412
413   // Remove the item with ID 2 (which is now before the current item range)
414   view.RemoveItem(2, 0.0f);
415
416   // Check the original item with item ID 2 was deleted and now item ID 389 represents the original item with ID 390
417   DALI_TEST_CHECK(view.GetItemId(itemActorID390) == 389);
418   DALI_TEST_CHECK(view.GetItem(389) == itemActorID390);
419
420   END_TEST;
421 }
422
423 int UtcDaliItemViewGetCurrentLayoutPosition(void)
424 {
425   ToolkitTestApplication application;
426
427   // Create the ItemView actor
428   TestItemFactory factory;
429   ItemView view = ItemView::New(factory);
430
431   // Create a depth layout and add it to ItemView
432   ItemLayoutPtr depthLayout = DefaultItemLayout::New( DefaultItemLayout::DEPTH );
433   depthLayout->SetOrientation(ControlOrientation::Up);
434   view.AddLayout(*depthLayout);
435
436   // Activate the grid layout so that the items will be created and added to ItemView
437   Vector3 stageSize(application.GetScene().GetSize());
438   view.ActivateLayout(0, stageSize, 0.0f);
439
440   // Check the current layout position for the 10th items is 9.0f
441   DALI_TEST_EQUALS(view.GetCurrentLayoutPosition(9), 9.0f, TEST_LOCATION );
442   END_TEST;
443 }
444
445 int UtcDaliItemViewSetAndGetMinimumSwipeSpeed(void)
446 {
447   ToolkitTestApplication application;
448
449   // Create the ItemView actor
450   TestItemFactory factory;
451   ItemView view = ItemView::New(factory);
452
453   // Set the minimum swipe speed to be 1.5f
454   view.SetMinimumSwipeSpeed(1.5f);
455
456   // Check the minimum swipe speed is 1.5f
457   DALI_TEST_EQUALS(view.GetMinimumSwipeSpeed(), 1.5f, TEST_LOCATION );
458   END_TEST;
459 }
460
461 int UtcDaliItemViewSetAndGetMinimumSwipeDistance(void)
462 {
463   ToolkitTestApplication application;
464
465   // Create the ItemView actor
466   TestItemFactory factory;
467   ItemView view = ItemView::New(factory);
468
469   // Set the minimum swipe distance to be 2.5f
470   view.SetMinimumSwipeDistance(2.5f);
471
472   // Check the minimum swipe distance is 2.5f
473   DALI_TEST_EQUALS(view.GetMinimumSwipeDistance(), 2.5f, TEST_LOCATION );
474   END_TEST;
475 }
476
477 int UtcDaliItemViewSetAndGetAnchoring(void)
478 {
479   ToolkitTestApplication application;
480
481   // Create the ItemView actor
482   TestItemFactory factory;
483   ItemView view = ItemView::New(factory);
484
485   // Disable the anchor animation
486   view.SetAnchoring(false);
487
488   // Check the anchor animation is disabled
489   DALI_TEST_CHECK(view.GetAnchoring() == false);
490   END_TEST;
491 }
492
493 int UtcDaliItemViewSetAndGetAnchoringDuration(void)
494 {
495   ToolkitTestApplication application;
496
497   // Create the ItemView actor
498   TestItemFactory factory;
499   ItemView view = ItemView::New(factory);
500
501   // Set the duration of anchor animation to be 1.5f
502   view.SetAnchoringDuration(1.5f);
503
504   // Check the duration of anchor animation is 1.5f
505   DALI_TEST_EQUALS(view.GetAnchoringDuration(), 1.5f, TEST_LOCATION );
506   END_TEST;
507 }
508
509 int UtcDaliItemViewSetAndGetRefreshInterval(void)
510 {
511   ToolkitTestApplication application;
512
513   // Create the ItemView actor
514   TestItemFactory factory;
515   ItemView view = ItemView::New(factory);
516
517   // Set the interval between refreshes to be 20
518   view.SetRefreshInterval(20);
519
520   view.Refresh();
521
522   // Check the interval between refreshes is 20
523   DALI_TEST_CHECK(view.GetRefreshInterval() == 20);
524   END_TEST;
525 }
526
527 int UtcDaliItemViewScrollToItem(void)
528 {
529   ToolkitTestApplication application;
530
531   // Create the ItemView actor
532   TestItemFactory factory;
533   ItemView view = ItemView::New(factory);
534   Vector3 vec(480.0f, 800.0f, 0.0f);
535   ItemLayoutPtr layout = DefaultItemLayout::New( DefaultItemLayout::DEPTH );
536
537   view.SetProperty( Dali::Actor::Property::NAME,"view actor");
538   view.AddLayout(*layout);
539   view.SetProperty( Actor::Property::SIZE, vec );
540
541   application.GetScene().Add(view);
542   layout->SetOrientation(ControlOrientation::Down);
543   view.ActivateLayout(0, vec, 0.0f);
544
545   application.SendNotification();
546   application.Render(0);
547
548   // render 10 frames
549   for(int i = 0; i < 10; ++i)
550   {
551     application.Render(16); // 60hz frames
552   }
553
554   // Confirm: we have actors in the view.
555   std::vector<unsigned int> indices;
556   for(unsigned int i = 0; i < 10; i++)
557   {
558     Actor testActor = view.GetItem(i);
559     if (testActor)
560     {
561       indices.push_back(i);
562     }
563   }
564
565   try
566   {
567     if (!indices.empty())
568     {
569       const unsigned int firstTargetIndex = indices[indices.size()-1];
570       // scroll to last item
571       view.ScrollToItem(firstTargetIndex, 0.00f);
572       for(int i = 0; i < 10; ++i)
573       {
574         application.Render(16); // 60hz frames
575       }
576
577       std::size_t moveCount = 0;
578       for(std::size_t i = 0; i < indices.size(); i++)
579       {
580         float layoutPosBefore = view.GetCurrentLayoutPosition(i);
581         view.ScrollToItem(indices[i], 0.0f);
582         float layoutPosAfter = view.GetCurrentLayoutPosition(i);
583
584         if (fabs(layoutPosBefore-layoutPosAfter) <= FLT_EPSILON)
585         {
586           ++moveCount;
587         }
588       }
589
590       DALI_TEST_CHECK((moveCount == indices.size()));
591     }
592   }
593   catch(...)
594   {
595     tet_result(TET_FAIL);
596   }
597
598   application.GetScene().Remove(view);
599   END_TEST;
600 }
601
602 int UtcDaliItemViewSetAndGetWheelScrollDistanceStep(void)
603 {
604   ToolkitTestApplication application;
605
606   // Create the ItemView actor
607   TestItemFactory factory;
608   ItemView view = ItemView::New(factory);
609
610   // Set the scroll distance step for the wheel event to be 100.0f
611   view.SetWheelScrollDistanceStep(100.0f);
612
613   // Check the scroll distance step is 100.0f
614   DALI_TEST_EQUALS(view.GetWheelScrollDistanceStep(), 100.0f, TEST_LOCATION );
615   END_TEST;
616 }
617
618 int UtcDaliItemViewInsertItemP(void)
619 {
620   ToolkitTestApplication application;
621
622   // Create the ItemView actor
623   TestItemFactory factory;
624   ItemView view = ItemView::New(factory);
625
626   // Create a grid layout and add it to ItemView
627   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID);
628   gridLayout->SetOrientation(ControlOrientation::Left);
629   view.AddLayout(*gridLayout);
630
631   // Activate the grid layout so that the items will be created and added to ItemView
632   Vector3 stageSize(application.GetScene().GetSize());
633   view.ActivateLayout(0, stageSize, 0.0f);
634
635   // Get the specified item where new item to be inserted before that
636   Actor itemActor = view.GetItem(2);
637
638   ItemId id = view.GetItemId( itemActor );
639
640   // Check we are getting the correct Item ID given the specified actor
641   DALI_TEST_CHECK(view.GetItemId(itemActor) == 2);
642
643   Actor newActor = Actor::New();
644
645   view.InsertItem(Item(id, newActor), 0.0f);
646
647   DALI_TEST_CHECK(view.GetItem(2) == newActor);
648
649   DALI_TEST_CHECK(view.GetItemId(itemActor) == 3);
650   DALI_TEST_CHECK(view.GetItem(3) == itemActor);
651
652   // scroll to the end of item view
653   view.ScrollToItem(TOTAL_ITEM_NUMBER - 1, 0.00f);
654
655   application.SendNotification();
656   application.Render(0);
657
658   // Refresh the item view
659   view.Refresh();
660
661   Actor itemActorID390 = view.GetItem(390);
662   DALI_TEST_CHECK(view.GetItemId(itemActorID390) == 390);
663
664   // Insert the item with ID 2 (which is now before the current item range)
665   Actor anotherNewActor = Actor::New();
666   view.InsertItem(Item(id, anotherNewActor), 0.0f);
667
668   // Check that item ID 391 now represents the original item with ID 390
669   DALI_TEST_CHECK(view.GetItemId(itemActorID390) == 391);
670   DALI_TEST_CHECK(view.GetItem(391) == itemActorID390);
671
672   END_TEST;
673 }
674
675 int UtcDaliItemViewInsertItemsP(void)
676 {
677   ToolkitTestApplication application;
678
679   // Create the ItemView actor
680   TestItemFactory factory;
681   ItemView view = ItemView::New(factory);
682
683   // Create a depth layout and add it to ItemView
684   ItemLayoutPtr depthLayout = DefaultItemLayout::New( DefaultItemLayout::DEPTH);
685   depthLayout->SetOrientation(ControlOrientation::Right);
686   view.AddLayout(*depthLayout);
687
688   // Activate the grid layout so that the items will be created and added to ItemView
689   Vector3 stageSize(application.GetScene().GetSize());
690   view.ActivateLayout(0, stageSize, 0.5f);
691
692   unsigned int itemCount = view.GetChildCount();
693
694   // Get the specified item where new items to be inserted before that
695   Actor itemActor = view.GetItem(1);
696
697   // Check we are getting the correct Item ID given the specified item
698   DALI_TEST_CHECK(view.GetItemId(itemActor) == 1);
699
700   ItemContainer insertList;
701
702   for( unsigned int i = 1u; i < 11; ++i )
703   {
704     Actor child = view.GetChildAt( i );
705     Actor newActor = Actor::New();
706     newActor.SetProperty( Dali::Actor::Property::NAME,"Inserted");
707     insertList.push_back( Item( view.GetItemId(child), newActor ) );
708   }
709
710   if( !insertList.empty() )
711   {
712     view.InsertItems( insertList, 0.5f );
713   }
714
715   DALI_TEST_CHECK(view.GetChildCount() == itemCount + 10);
716
717   // Check that new items are inserted in the correct positions
718   DALI_TEST_CHECK(view.GetItemId(itemActor) == 11);
719   DALI_TEST_CHECK(view.GetItem(11) == itemActor);
720
721   ItemIdContainer removeList;
722
723   for( unsigned int i = 0u; i < view.GetChildCount(); ++i )
724   {
725     Actor child = view.GetChildAt( i );
726
727     if( child.GetProperty< std::string >( Dali::Actor::Property::NAME ) == "Inserted" )
728     {
729       removeList.push_back( view.GetItemId(child) );
730     }
731   }
732
733   if( ! removeList.empty() )
734   {
735     view.RemoveItems( removeList, 0.5f );
736   }
737
738   DALI_TEST_CHECK(view.GetChildCount() == itemCount);
739
740   // Check that new items are removed correctly so that we are getting the correct Item ID given the specified item
741   DALI_TEST_CHECK(view.GetItemId(itemActor) == 1);
742   DALI_TEST_CHECK(view.GetItem(1) == itemActor);
743
744   END_TEST;
745 }
746
747 int UtcDaliItemViewReplaceItemP(void)
748 {
749   ToolkitTestApplication application;
750
751   // Create the ItemView actor
752   TestItemFactory factory;
753   ItemView view = ItemView::New(factory);
754
755   // Create a spiral layout and add it to ItemView
756   ItemLayoutPtr spiralLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL );
757   view.AddLayout(*spiralLayout);
758
759   // Activate the grid layout so that the items will be created and added to ItemView
760   Vector3 stageSize(application.GetScene().GetSize());
761   view.ActivateLayout(0, stageSize, 0.5f);
762
763   Actor newActor = Actor::New();
764
765   view.ReplaceItem( Item( 5, newActor ), 0.5f );
766
767   DALI_TEST_CHECK(view.GetItem(5) == newActor);
768
769   END_TEST;
770 }
771
772 int UtcDaliItemViewReplaceItemsP(void)
773 {
774   ToolkitTestApplication application;
775
776   // Create the ItemView actor
777   TestItemFactory factory;
778   ItemView view = ItemView::New(factory);
779
780   // Create a spiral layout and add it to ItemView
781   ItemLayoutPtr spiralLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL );
782   spiralLayout->SetOrientation( ControlOrientation::Down );
783   view.AddLayout(*spiralLayout);
784
785   // Activate the grid layout so that the items will be created and added to ItemView
786   Vector3 stageSize(application.GetScene().GetSize());
787   view.ActivateLayout(0, stageSize, 0.5f);
788
789   ItemContainer replaceList;
790
791   for( unsigned int i = 0u; i < 10; ++i )
792   {
793     Actor child = view.GetItem( i );
794     Actor newActor = Actor::New();
795     newActor.SetProperty( Dali::Actor::Property::NAME,"Replaced");
796
797     replaceList.push_back( Item( i, newActor ) );
798   }
799
800   if( !replaceList.empty() )
801   {
802     view.ReplaceItems( replaceList, 0.5f );
803   }
804
805   DALI_TEST_CHECK(view.GetItem(0).GetProperty< std::string >( Dali::Actor::Property::NAME ) == "Replaced");
806   DALI_TEST_CHECK(view.GetItem(8).GetProperty< std::string >( Dali::Actor::Property::NAME ) == "Replaced");
807   END_TEST;
808 }
809
810 int UtcDaliItemViewGetItemsRangeP(void)
811 {
812   ToolkitTestApplication application;
813
814   // Create the ItemView actor
815   TestItemFactory factory;
816   ItemView view = ItemView::New(factory);
817
818   // Create a spiral layout and add it to ItemView
819   ItemLayoutPtr spiralLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL );
820   spiralLayout->SetOrientation( ControlOrientation::Left );
821   view.AddLayout(*spiralLayout);
822
823   // Activate the grid layout so that the items will be created and added to ItemView
824   Vector3 stageSize(application.GetScene().GetSize());
825   view.ActivateLayout(0, stageSize, 0.5f);
826
827   ItemRange itemRange(0, 0);
828
829   view.GetItemsRange(itemRange);
830
831   DALI_TEST_CHECK(itemRange.Within(0));
832   END_TEST;
833 }
834
835 int UtcDaliItemViewSetItemsAnchorPointP(void)
836 {
837   ToolkitTestApplication application;
838
839   // Create the ItemView actor
840   TestItemFactory factory;
841   ItemView view = ItemView::New(factory);
842
843   // Create a spiral layout and add it to ItemView
844   ItemLayoutPtr spiralLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL );
845   spiralLayout->SetOrientation( ControlOrientation::Right );
846   view.AddLayout(*spiralLayout);
847
848   // Activate the grid layout so that the items will be created and added to ItemView
849   Vector3 stageSize(application.GetScene().GetSize());
850   view.ActivateLayout(0, stageSize, 0.5f);
851
852   Vector3 anchorPoint(10.0f, 10.0f, 0.0f);
853
854   view.SetItemsAnchorPoint(anchorPoint);
855
856   DALI_TEST_CHECK(view.GetItemsAnchorPoint() == anchorPoint);
857   DALI_TEST_CHECK(view.GetItem(0).GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ) == anchorPoint);
858   END_TEST;
859 }
860
861 int UtcDaliItemViewSetItemsParentOriginP(void)
862 {
863   ToolkitTestApplication application;
864
865   // Create the ItemView actor
866   TestItemFactory factory;
867   ItemView view = ItemView::New(factory);
868
869   // Create a grid layout and add it to ItemView
870   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
871   view.AddLayout(*gridLayout);
872
873   // Activate the grid layout so that the items will be created and added to ItemView
874   Vector3 stageSize(application.GetScene().GetSize());
875   view.ActivateLayout(0, stageSize, 0.5f);
876
877   Vector3 parentOrigin(10.0f, 10.0f, 0.0f);
878
879   view.SetItemsParentOrigin(parentOrigin);
880
881   DALI_TEST_CHECK(view.GetItemsParentOrigin() == parentOrigin);
882   DALI_TEST_CHECK(view.GetItem(0).GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ) == parentOrigin);
883   END_TEST;
884 }
885
886 int UtcDaliItemFactoryGetExtention(void)
887 {
888   ToolkitTestApplication application;
889   TestItemFactory factory;
890   DALI_TEST_CHECK( factory.GetExtension() == NULL );
891   END_TEST;
892 }
893
894 int UtcDaliItemViewLayoutActivatedSignalP(void)
895 {
896   ToolkitTestApplication application;
897
898   // Create the ItemView actor
899   TestItemFactory factory;
900   ItemView view = ItemView::New(factory);
901
902   // Create a grid layout and add it to ItemView
903   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
904   view.AddLayout(*gridLayout);
905
906   application.GetScene().Add( view );
907
908   // Connect the layout activated signal
909   view.LayoutActivatedSignal().Connect( &OnLayoutActivated );
910
911   gOnLayoutActivatedCalled = false;
912
913   // Render and notify
914   application.SendNotification();
915   application.Render();
916
917   // Activate the grid layout so that the items will be created and added to ItemView
918   Vector3 stageSize(application.GetScene().GetSize());
919   view.ActivateLayout(0, stageSize, 0.1f);
920
921   // Wait for 0.1 second
922   Wait(application, 100);
923
924   DALI_TEST_EQUALS( gOnLayoutActivatedCalled, true, TEST_LOCATION );
925
926   END_TEST;
927 }
928
929 int UtcDaliItemViewSetGetProperty(void)
930 {
931   ToolkitTestApplication application;
932
933   // Create the ItemView actor
934   TestItemFactory factory;
935   ItemView view = ItemView::New(factory);
936   DALI_TEST_CHECK(view);
937
938   // Event side properties
939
940   // Test "minimumSwipeSpeed" property
941   DALI_TEST_CHECK( view.GetPropertyIndex("minimumSwipeSpeed") == ItemView::Property::MINIMUM_SWIPE_SPEED  );
942   DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::MINIMUM_SWIPE_SPEED).Get<float>(), view.GetMinimumSwipeSpeed(), TEST_LOCATION );
943   view.SetProperty( ItemView::Property::MINIMUM_SWIPE_SPEED, 2.5f );
944   DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::MINIMUM_SWIPE_SPEED).Get<float>(), 2.5f, TEST_LOCATION );
945
946   // Test "minimumSwipeDistance" property
947   DALI_TEST_CHECK( view.GetPropertyIndex("minimumSwipeDistance") == ItemView::Property::MINIMUM_SWIPE_DISTANCE  );
948   DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::MINIMUM_SWIPE_DISTANCE).Get<float>(), view.GetMinimumSwipeDistance(), TEST_LOCATION );
949   view.SetProperty( ItemView::Property::MINIMUM_SWIPE_DISTANCE, 8.725f );
950   DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::MINIMUM_SWIPE_DISTANCE).Get<float>(), 8.725f, TEST_LOCATION );
951
952   // Test "wheelScrollDistanceStep" property
953   DALI_TEST_CHECK( view.GetPropertyIndex("wheelScrollDistanceStep") == ItemView::Property::WHEEL_SCROLL_DISTANCE_STEP  );
954   DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::WHEEL_SCROLL_DISTANCE_STEP).Get<float>(), view.GetWheelScrollDistanceStep(), TEST_LOCATION );
955   view.SetProperty( ItemView::Property::WHEEL_SCROLL_DISTANCE_STEP, 5.0f );
956   DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::WHEEL_SCROLL_DISTANCE_STEP).Get<float>(), 5.0f, TEST_LOCATION );
957
958   // Test "snapToItemEnabled" property
959   DALI_TEST_CHECK( view.GetPropertyIndex("snapToItemEnabled") == ItemView::Property::SNAP_TO_ITEM_ENABLED  );
960   DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::SNAP_TO_ITEM_ENABLED).Get<bool>(), view.GetAnchoring(), TEST_LOCATION );
961   view.SetProperty( ItemView::Property::SNAP_TO_ITEM_ENABLED, true );
962   DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::SNAP_TO_ITEM_ENABLED).Get<bool>(), true, TEST_LOCATION );
963
964   // Test "refreshInterval" property
965   DALI_TEST_CHECK( view.GetPropertyIndex("refreshInterval") == ItemView::Property::REFRESH_INTERVAL  );
966   DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::REFRESH_INTERVAL).Get<float>(), view.GetRefreshInterval(), TEST_LOCATION );
967   view.SetProperty( ItemView::Property::REFRESH_INTERVAL, 11.0f );
968   DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::REFRESH_INTERVAL).Get<float>(), 11.0f, TEST_LOCATION );
969
970   // Test "layout" property
971   DALI_TEST_CHECK( view.GetPropertyIndex("layout") == ItemView::Property::LAYOUT  );
972   Property::Map gridLayoutProperty;
973   gridLayoutProperty.Insert( DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::GRID) );
974   gridLayoutProperty.Insert( DefaultItemLayoutProperty::ITEM_SIZE, Dali::Property::Value(Vector3(200, 200,50)) );
975   gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_ROW_SPACING, Dali::Property::Value(50.0f) );
976   gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_COLUMN_NUMBER, Dali::Property::Value(4) );
977
978   Property::Map depthLayoutProperty;
979   depthLayoutProperty.Insert( DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::DEPTH) );
980   depthLayoutProperty.Insert( DefaultItemLayoutProperty::DEPTH_COLUMN_NUMBER, Dali::Property::Value(3) );
981   depthLayoutProperty.Insert( DefaultItemLayoutProperty::DEPTH_ROW_NUMBER, Dali::Property::Value(26.0f) );
982
983   Property::Map spiralLayoutPrperty;
984   spiralLayoutPrperty.Insert( DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::SPIRAL) );
985   spiralLayoutPrperty.Insert( DefaultItemLayoutProperty::SPIRAL_ITEM_SPACING, Dali::Property::Value((Math::PI*2.0f)/9.5f) );
986   spiralLayoutPrperty.Insert( DefaultItemLayoutProperty::SPIRAL_TOP_ITEM_ALIGNMENT, Dali::Property::Value(-0.125f) );
987
988   Property::Map listLayoutPrperty;
989   listLayoutPrperty.Insert( DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::LIST) );
990   listLayoutPrperty.Insert( DefaultItemLayoutProperty::ITEM_SIZE, Dali::Property::Value(Vector3(100, 100,50)) );
991
992
993   Property::Array layoutArray;
994   layoutArray.PushBack(gridLayoutProperty);
995   layoutArray.PushBack(depthLayoutProperty);
996   layoutArray.PushBack(spiralLayoutPrperty);
997   layoutArray.PushBack(listLayoutPrperty);
998
999   view.SetProperty( ItemView::Property::LAYOUT, layoutArray);
1000
1001   Property::Array getLayoutArray;
1002   DALI_TEST_CHECK( view.GetProperty( ItemView::Property::LAYOUT ).Get( getLayoutArray ) );
1003
1004   //Check that the result is the same as
1005   DALI_TEST_EQUALS( layoutArray.Count(), getLayoutArray.Count(), TEST_LOCATION );
1006   Property::Map firstLayout = *((getLayoutArray.GetElementAt( 0 )).GetMap());
1007
1008   for( unsigned int mapIdx = 0, mapCount = firstLayout.Count(); mapIdx < mapCount; ++mapIdx )
1009   {
1010     KeyValuePair propertyPair( firstLayout.GetKeyValue( mapIdx ) );
1011     if(propertyPair.first == DefaultItemLayoutProperty::TYPE)
1012     {
1013       int layoutType = propertyPair.second.Get<int>();
1014       DALI_TEST_EQUALS( layoutType, (int)DefaultItemLayout::GRID, TEST_LOCATION );
1015     }
1016     else if(propertyPair.first == DefaultItemLayoutProperty::ITEM_SIZE)
1017     {
1018       Vector3 size = propertyPair.second.Get<Vector3>();
1019       DALI_TEST_EQUALS( size, Vector3(200, 200,50), TEST_LOCATION );
1020     }
1021     else if(propertyPair.first == DefaultItemLayoutProperty::GRID_ROW_SPACING)
1022     {
1023       float spacing = propertyPair.second.Get<float>();
1024       DALI_TEST_EQUALS( spacing, 50.0f, TEST_LOCATION );
1025     }
1026     else if(propertyPair.first == DefaultItemLayoutProperty::GRID_COLUMN_NUMBER)
1027     {
1028       int number = propertyPair.second.Get<int>();
1029       DALI_TEST_EQUALS(number, 4, TEST_LOCATION );
1030     }
1031   }
1032   view.SetProperty( ItemView::Property::LAYOUT, layoutArray);
1033
1034
1035   // Test "overshootEnabled" property
1036   DALI_TEST_CHECK( view.GetPropertyIndex("overshootEnabled") == Scrollable::Property::OVERSHOOT_ENABLED  );
1037   DALI_TEST_EQUALS( view.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), view.IsOvershootEnabled(), TEST_LOCATION );
1038   view.SetProperty( Scrollable::Property::OVERSHOOT_ENABLED, false );
1039   DALI_TEST_EQUALS( view.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), false, TEST_LOCATION );
1040
1041   // Test "overshootSize" property
1042   DALI_TEST_CHECK( view.GetPropertyIndex("overshootSize") == Scrollable::Property::OVERSHOOT_SIZE  );
1043   Vector2 overshootSize = Vector2(100.0f,100.0f);
1044   view.SetProperty( Scrollable::Property::OVERSHOOT_SIZE, overshootSize );
1045   DALI_TEST_EQUALS( view.GetProperty(Scrollable::Property::OVERSHOOT_SIZE).Get<Vector2>(), overshootSize, TEST_LOCATION );
1046
1047   // Animatable properties
1048
1049   // Test "layoutPosition" property
1050   DALI_TEST_CHECK( view.GetPropertyIndex("layoutPosition") == ItemView::Property::LAYOUT_POSITION  );
1051   view.SetProperty( ItemView::Property::LAYOUT_POSITION, 20.5f );
1052   Wait(application);
1053   DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::LAYOUT_POSITION).Get<float>(), 20.5f, TEST_LOCATION );
1054
1055   // Test "scrollSpeed" property
1056   DALI_TEST_CHECK( view.GetPropertyIndex("scrollSpeed") == ItemView::Property::SCROLL_SPEED  );
1057   view.SetProperty( ItemView::Property::SCROLL_SPEED, 3.35f );
1058   Wait(application);
1059   DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::SCROLL_SPEED).Get<float>(), 3.35f, TEST_LOCATION );
1060
1061   // Test "overshoot" property
1062   DALI_TEST_CHECK( view.GetPropertyIndex("overshoot") == ItemView::Property::OVERSHOOT  );
1063   view.SetProperty( ItemView::Property::OVERSHOOT, 0.15f );
1064   Wait(application);
1065   DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::OVERSHOOT).Get<float>(), 0.15f, TEST_LOCATION );
1066
1067   // Test "scrollDirection" property
1068   DALI_TEST_CHECK( view.GetPropertyIndex("scrollDirection") == ItemView::Property::SCROLL_DIRECTION  );
1069   view.SetProperty( ItemView::Property::SCROLL_DIRECTION, Vector2(0.85f, 0.5f) );
1070   Wait(application);
1071   DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::SCROLL_DIRECTION).Get<Vector2>(), Vector2(0.85f, 0.5f), TEST_LOCATION );
1072
1073   // Test "layoutOrientation" property
1074   DALI_TEST_CHECK( view.GetPropertyIndex("layoutOrientation") == ItemView::Property::LAYOUT_ORIENTATION  );
1075   view.SetProperty( ItemView::Property::LAYOUT_ORIENTATION, 2 );
1076   Wait(application);
1077   DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::LAYOUT_ORIENTATION).Get<int>(), 2, TEST_LOCATION );
1078
1079   // Test "scrollContentSize" property
1080   DALI_TEST_CHECK( view.GetPropertyIndex("scrollContentSize") == ItemView::Property::SCROLL_CONTENT_SIZE  );
1081   view.SetProperty( ItemView::Property::SCROLL_CONTENT_SIZE, 250.0f );
1082   Wait(application);
1083   DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::SCROLL_CONTENT_SIZE).Get<float>(), 250.0f, TEST_LOCATION );
1084
1085   END_TEST;
1086 }
1087
1088
1089 int UtcDaliItemViewOvershootVertical(void)
1090 {
1091   ToolkitTestApplication application;
1092   Dali::Integration::Scene stage = application.GetScene();
1093
1094   // Create the ItemView actor
1095   TestItemFactory factory;
1096   ItemView view = ItemView::New(factory);
1097
1098   // Create a grid layout and add it to ItemView
1099   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
1100   view.AddLayout(*gridLayout);
1101   stage.Add(view);
1102
1103   // Activate the grid layout so that the items will be created and added to ItemView
1104   Vector3 stageSize(stage.GetSize());
1105   view.ActivateLayout(0, stageSize, 0.5f);
1106
1107   view.SetProperty( Scrollable::Property::OVERSHOOT_ENABLED, true );
1108   DALI_TEST_EQUALS( view.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), true, TEST_LOCATION );
1109
1110   view.SetProperty( Scrollable::Property::OVERSHOOT_SIZE, Vector2(30, 30) );
1111
1112   Wait(application);
1113
1114   // Do a pan starting from 100,100 and moving down
1115   Vector2 pos(100.0f, 100.0f);
1116
1117   application.ProcessEvent( GenerateSingleTouch(PointState::DOWN, pos, 100 ) );
1118   application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ) );
1119
1120   pos.y += 5.0f;
1121   Wait(application, 100);
1122
1123   for(int i = 0;i<200;i++)
1124   {
1125     application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ) );
1126     pos.y += 5.0f;
1127     Wait(application);
1128   }
1129
1130   application.ProcessEvent( GenerateSingleTouch(PointState::UP, pos, 100 ) );
1131
1132   Wait(application, 100);
1133
1134   // Do a pan starting from 100,100 and moving up
1135   pos = Vector2(100.0f, 300.0f);
1136
1137   application.ProcessEvent( GenerateSingleTouch(PointState::DOWN, pos, 100 ) );
1138   application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ) );
1139
1140   pos.y -= 5.0f;
1141   Wait(application, 100);
1142
1143   for(int i = 0;i<200;i++)
1144   {
1145     application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ) );
1146     pos.y -= 5.0f;
1147     Wait(application);
1148   }
1149
1150   application.ProcessEvent( GenerateSingleTouch(PointState::UP, pos, 100 ) );
1151   Wait(application, 100);
1152   END_TEST;
1153 }
1154
1155 int UtcDaliItemViewOvershootHorizontal(void)
1156 {
1157   ToolkitTestApplication application;
1158   Dali::Integration::Scene stage = application.GetScene();
1159
1160   // Create the ItemView actor
1161   TestItemFactory factory;
1162   ItemView view = ItemView::New(factory);
1163
1164   // Create a grid layout and add it to ItemView
1165   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL );
1166   view.AddLayout(*gridLayout);
1167   stage.Add(view);
1168
1169   // Activate the grid layout so that the items will be created and added to ItemView
1170   Vector3 stageSize(stage.GetSize());
1171   view.ActivateLayout(0, stageSize, 0.5f);
1172
1173   view.SetProperty( Scrollable::Property::OVERSHOOT_ENABLED, true );
1174   DALI_TEST_EQUALS( view.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), true, TEST_LOCATION );
1175
1176   view.SetProperty( Scrollable::Property::OVERSHOOT_SIZE, Vector2(30, 30) );
1177
1178   Wait(application);
1179
1180   // Do a pan starting from 100,100 and moving left
1181   Vector2 pos(100.0f, 100.0f);
1182   application.ProcessEvent( GenerateSingleTouch(PointState::DOWN, pos, 100 ));
1183   application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ));
1184   pos.x -= 5.0f;
1185   Wait(application, 100);
1186
1187   for(int i = 0;i<200;i++)
1188   {
1189     application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ) );
1190     pos.x -= 5.0f;
1191     Wait(application);
1192   }
1193
1194   application.ProcessEvent( GenerateSingleTouch(PointState::UP, pos, 100 ) );
1195   Wait(application, 100);
1196
1197   // Do a pan starting from 100,100 and moving right
1198   pos = Vector2(100.0f, 100.0f);
1199   application.ProcessEvent( GenerateSingleTouch(PointState::DOWN, pos, 100 ) );
1200   application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ) );
1201   pos.x += 5.0f;
1202   Wait(application, 100);
1203
1204   for(int i = 0;i<200;i++)
1205   {
1206     application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ) );
1207     pos.x += 5.0f;
1208     Wait(application);
1209   }
1210
1211   application.ProcessEvent( GenerateSingleTouch(PointState::UP, pos, 100 ) );
1212   Wait(application, 100);
1213
1214   END_TEST;
1215 }
1216
1217 int UtcDaliItemEnableDisableRefresh(void)
1218 {
1219   ToolkitTestApplication application;
1220   Dali::Integration::Scene stage = application.GetScene();
1221
1222   // Create the ItemView actor
1223   TestItemFactory factory;
1224   ItemView view = ItemView::New(factory);
1225
1226   // Create a grid layout and add it to ItemView
1227   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
1228   view.AddLayout(*gridLayout);
1229   stage.Add(view);
1230
1231   // Activate the grid layout so that the items will be created and added to ItemView
1232   Vector3 stageSize(stage.GetSize());
1233   view.ActivateLayout(0, stageSize, 0.5f);
1234
1235   //Connect to signal scroll updated
1236   view.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1237
1238   Property::Map attributes;
1239   view.DoAction("enableRefresh", attributes );
1240   gOnScrollUpdateCalled = true;
1241   view.SetProperty( ItemView::Property::LAYOUT_POSITION, 100.0f );
1242   application.SendNotification();
1243   application.Render(1000);
1244   DALI_TEST_EQUALS( gOnScrollUpdateCalled, true, TEST_LOCATION );
1245
1246
1247   view.DoAction("disableRefresh", attributes );
1248   gOnScrollUpdateCalled = false;
1249   view.SetProperty( ItemView::Property::LAYOUT_POSITION, 100.0f );
1250   application.SendNotification();
1251   application.Render(1000);
1252
1253   DALI_TEST_EQUALS( gOnScrollUpdateCalled, false, TEST_LOCATION );
1254
1255   END_TEST;
1256 }