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