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