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