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