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