Added new property API to Button. Added Icon and color features. Deprecated old API
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-ItemView.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <iostream>
19 #include <stdlib.h>
20 #include <float.h>       // for FLT_MAX
21
22 // Need to override adaptor classes for toolkit test harness, so include
23 // test harness headers before dali headers.
24 #include <dali-toolkit-test-suite-utils.h>
25
26 #include <dali-toolkit/dali-toolkit.h>
27
28 using namespace Dali;
29 using namespace Toolkit;
30
31 void utc_dali_toolkit_item_view_startup(void)
32 {
33   test_return_value = TET_UNDEF;
34 }
35
36 void utc_dali_toolkit_item_view_cleanup(void)
37 {
38   test_return_value = TET_PASS;
39 }
40
41 namespace
42 {
43
44 const unsigned int TOTAL_ITEM_NUMBER = 100;
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
52 static void TestCallback(BaseHandle handle)
53 {
54   gObjectCreatedCallBackCalled = true;
55 }
56
57 static void OnLayoutActivated()
58 {
59   gOnLayoutActivatedCalled = true;
60 }
61
62 /*
63  * Simulate time passed by.
64  *
65  * @note this will always process at least 1 frame (1/60 sec)
66  *
67  * @param application Test application instance
68  * @param duration Time to pass in milliseconds.
69  * @return The actual time passed in milliseconds
70  */
71 int Wait(ToolkitTestApplication& application, int duration = 0)
72 {
73   int time = 0;
74
75   for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
76   {
77     application.SendNotification();
78     application.Render(RENDER_FRAME_INTERVAL);
79     time += RENDER_FRAME_INTERVAL;
80   }
81
82   return time;
83 }
84
85 // Implementation of ItemFactory for providing actors to ItemView
86 class TestItemFactory : public ItemFactory
87 {
88 public:
89
90   /**
91    * Constructor
92    * @param application class, stored as reference
93    */
94   TestItemFactory()
95   {
96   }
97
98 public: // From ItemFactory
99
100   /**
101    * Query the number of items available from the factory.
102    * The maximum available item has an ID of GetNumberOfItems() - 1.
103    */
104   virtual unsigned int GetNumberOfItems()
105   {
106     return TOTAL_ITEM_NUMBER;
107   }
108
109   /**
110    * Create an Actor to represent a visible item.
111    * @param itemId
112    * @return the created actor.
113    */
114   virtual Actor NewItem(unsigned int itemId)
115   {
116     // Create an image actor for this item
117     Image image = ResourceImage::New( TEST_IMAGE_FILE_NAME );
118     Actor actor = ImageActor::New(image);
119
120     return actor;
121   }
122 };
123
124 } // namespace
125
126
127 int UtcDaliItemViewNew(void)
128 {
129   ToolkitTestApplication application;
130
131   // Create the ItemView actor
132   TestItemFactory factory;
133   ItemView view = ItemView::New(factory);
134
135   DALI_TEST_CHECK(view);
136
137   //Additional check to ensure object is created by checking if it's registered
138   ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
139   DALI_TEST_CHECK( registry );
140
141   gObjectCreatedCallBackCalled = false;
142   registry.ObjectCreatedSignal().Connect(&TestCallback);
143   {
144     TestItemFactory factory;
145     ItemView view = ItemView::New(factory);
146   }
147   DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
148   END_TEST;
149 }
150
151 int UtcDaliItemViewDownCast(void)
152 {
153   ToolkitTestApplication application;
154
155   // Create the ItemView actor
156   TestItemFactory factory;
157   const ItemView itemViewConst = ItemView::New(factory);
158   ItemView itemView(itemViewConst);
159
160   BaseHandle handle(itemView);
161
162   ItemView newItemView = ItemView::DownCast( handle );
163   DALI_TEST_CHECK( itemView );
164   DALI_TEST_CHECK( newItemView == itemView );
165   END_TEST;
166 }
167
168 int UtcDaliItemViewAddAndGetLayout(void)
169 {
170   ToolkitTestApplication application;
171
172   // Create the ItemView actor
173   TestItemFactory factory;
174   ItemView view = ItemView::New(factory);
175
176   // Create a grid layout and add it to ItemView
177   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
178   view.AddLayout(*gridLayout);
179
180   // As we have added one layout, check the number of layout is now 1
181   DALI_TEST_CHECK(view.GetLayoutCount() == 1);
182
183   // Create a depth layout and add it to ItemView
184   ItemLayoutPtr depthLayout = DefaultItemLayout::New( DefaultItemLayout::DEPTH );
185   view.AddLayout(*depthLayout);
186
187   // As we have added another layout, check the number of layout is now 2
188   DALI_TEST_CHECK(view.GetLayoutCount() == 2);
189
190   // Create a spiral layout and add it to ItemView
191   ItemLayoutPtr spiralLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL );
192   view.AddLayout(*spiralLayout);
193
194   // As we have added another layout, check the number of layout is now 3
195   DALI_TEST_CHECK(view.GetLayoutCount() == 3);
196
197   // Check we are getting the correct layout from ItemView
198   DALI_TEST_CHECK(view.GetLayout(0) == gridLayout);
199   DALI_TEST_CHECK(view.GetLayout(1) == depthLayout);
200   DALI_TEST_CHECK(view.GetLayout(2) == spiralLayout);
201   END_TEST;
202 }
203
204 int UtcDaliItemViewAddAndRemoveLayout(void)
205 {
206   ToolkitTestApplication application;
207
208   // Create the ItemView actor
209   TestItemFactory factory;
210   ItemView view = ItemView::New(factory);
211
212   // Create a grid layout and add it to ItemView
213   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
214   view.AddLayout(*gridLayout);
215
216   // As we have added one layout, check the number of layout is now 1
217   DALI_TEST_CHECK(view.GetLayoutCount() == 1);
218
219   // Create a depth layout and add it to ItemView
220   ItemLayoutPtr depthLayout = DefaultItemLayout::New( DefaultItemLayout::DEPTH );
221   view.AddLayout(*depthLayout);
222
223   // As we have added another layout, check the number of layout is now 2
224   DALI_TEST_CHECK(view.GetLayoutCount() == 2);
225
226   // Check we are getting the correct layout from ItemView
227   DALI_TEST_CHECK(view.GetLayout(0) == gridLayout);
228   DALI_TEST_CHECK(view.GetLayout(1) == depthLayout);
229
230   // Remove the grid layout
231   view.RemoveLayout(0);
232
233   // As we have removed the grid layout, check the number of layout is now 1
234   DALI_TEST_CHECK(view.GetLayoutCount() == 1);
235
236   // Check we are getting the correct layout from ItemView
237   DALI_TEST_CHECK(view.GetLayout(0) == depthLayout);
238
239   // Remove the depth layout
240   view.RemoveLayout(0);
241
242   // As we also removed the depth layout, check the number of layout is now 0
243   DALI_TEST_CHECK(view.GetLayoutCount() == 0);
244   END_TEST;
245 }
246
247 int UtcDaliItemViewActivateLayoutAndGetActiveLayout(void)
248 {
249   ToolkitTestApplication application;
250
251   // Create the ItemView actor
252   TestItemFactory factory;
253   ItemView view = ItemView::New(factory);
254
255   // Create a grid layout and add it to ItemView
256   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
257   view.AddLayout(*gridLayout);
258
259   // Create a depth layout and add it to ItemView
260   ItemLayoutPtr depthLayout = DefaultItemLayout::New( DefaultItemLayout::DEPTH );
261   view.AddLayout(*depthLayout);
262
263   // Create a spiral layout and add it to ItemView
264   ItemLayoutPtr spiralLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL );
265   view.AddLayout(*spiralLayout);
266
267   // As we have added three layouts, check the number of layout is now 3
268   DALI_TEST_CHECK(view.GetLayoutCount() == 3);
269
270   // Check there is no active layout at the moment
271   DALI_TEST_CHECK(view.GetActiveLayout() == NULL);
272
273   // Activate the depth layout
274   Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
275   view.ActivateLayout(1, stageSize, 0.5f);
276
277   // Check the current active layout is the depth layout
278   DALI_TEST_CHECK(view.GetActiveLayout() == depthLayout);
279
280   // Activate the grid layout
281   view.ActivateLayout(0, stageSize, 0.5f);
282
283   // Check the current active layout is the grid layout
284   DALI_TEST_CHECK(view.GetActiveLayout() == gridLayout);
285
286   // Activate the spiral layout
287   view.ActivateLayout(2, stageSize, 0.5f);
288
289   // Check the current active layout is the spiral layout
290   DALI_TEST_CHECK(view.GetActiveLayout() == spiralLayout);
291   END_TEST;
292 }
293
294 int UtcDaliItemViewDeactivateCurrentLayout(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   // Check there is no active layout at the moment
307   DALI_TEST_CHECK(view.GetActiveLayout() == NULL);
308
309   // Activate the grid layout
310   Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
311   view.ActivateLayout(0, stageSize, 0.5f);
312
313   // Check the current active layout is the grid layout
314   DALI_TEST_CHECK(view.GetActiveLayout() == gridLayout);
315
316   // Deactivate the current layout
317   view.DeactivateCurrentLayout();
318
319   // Check there is no active layout at the moment
320   DALI_TEST_CHECK(view.GetActiveLayout() == NULL);
321   END_TEST;
322 }
323
324 int UtcDaliItemViewGetItemAndGetItemId(void)
325 {
326   ToolkitTestApplication application;
327
328   // Create the ItemView actor
329   TestItemFactory factory;
330   ItemView view = ItemView::New(factory);
331
332   // Create a grid layout and add it to ItemView
333   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
334   view.AddLayout(*gridLayout);
335
336   // Activate the grid layout so that the items will be created and added to ItemView
337   Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
338   view.ActivateLayout(0, stageSize, 0.5f);
339
340   // Get the item given the item ID
341   Actor itemActor = view.GetItem(2);
342
343   // Check we are getting the correct Item ID given the specified actor
344   DALI_TEST_CHECK(view.GetItemId(itemActor) == 2);
345   END_TEST;
346 }
347
348 int UtcDaliItemViewRemoveItem(void)
349 {
350   ToolkitTestApplication application;
351
352   // Create the ItemView actor
353   TestItemFactory factory;
354   ItemView view = ItemView::New(factory);
355
356   // Create a grid layout and add it to ItemView
357   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
358   view.AddLayout(*gridLayout);
359
360   // Activate the grid layout so that the items will be created and added to ItemView
361   Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
362   view.ActivateLayout(0, stageSize, 0.5f);
363
364   // Get the item given the item ID 2 and 3
365   Actor oldItemActorID2 = view.GetItem(2);
366   Actor oldItemActorID3 = view.GetItem(3);
367
368   // Remove the item with ID 2
369   view.RemoveItem(2, 0.0f);
370
371   // Get the new item given the item ID 2
372   Actor newItemActorID2 = view.GetItem(2);
373
374   // Check the original item with item ID 2 was deleted and now item ID 2 represents the original item with ID 3
375   DALI_TEST_CHECK(view.GetItemId(newItemActorID2) == 2);
376   DALI_TEST_CHECK(oldItemActorID2 != newItemActorID2);
377   DALI_TEST_CHECK(newItemActorID2 = oldItemActorID3);
378   END_TEST;
379 }
380
381 int UtcDaliItemViewGetCurrentLayoutPosition(void)
382 {
383   ToolkitTestApplication application;
384
385   // Create the ItemView actor
386   TestItemFactory factory;
387   ItemView view = ItemView::New(factory);
388
389   // Create a grid layout and add it to ItemView
390   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
391   view.AddLayout(*gridLayout);
392
393   // Activate the grid layout so that the items will be created and added to ItemView
394   Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
395   view.ActivateLayout(0, stageSize, 0.0f);
396
397   // Check the current layout position for the 10th items is 9.0f
398   DALI_TEST_EQUALS(view.GetCurrentLayoutPosition(9), 9.0f, TEST_LOCATION );
399   END_TEST;
400 }
401
402 int UtcDaliItemViewSetAndGetMinimumSwipeSpeed(void)
403 {
404   ToolkitTestApplication application;
405
406   // Create the ItemView actor
407   TestItemFactory factory;
408   ItemView view = ItemView::New(factory);
409
410   // Set the minimum swipe speed to be 1.5f
411   view.SetMinimumSwipeSpeed(1.5f);
412
413   // Check the minimum swipe speed is 1.5f
414   DALI_TEST_EQUALS(view.GetMinimumSwipeSpeed(), 1.5f, TEST_LOCATION );
415   END_TEST;
416 }
417
418 int UtcDaliItemViewSetAndGetMinimumSwipeDistance(void)
419 {
420   ToolkitTestApplication application;
421
422   // Create the ItemView actor
423   TestItemFactory factory;
424   ItemView view = ItemView::New(factory);
425
426   // Set the minimum swipe distance to be 2.5f
427   view.SetMinimumSwipeDistance(2.5f);
428
429   // Check the minimum swipe distance is 2.5f
430   DALI_TEST_EQUALS(view.GetMinimumSwipeDistance(), 2.5f, TEST_LOCATION );
431   END_TEST;
432 }
433
434 int UtcDaliItemViewSetAndGetAnchoring(void)
435 {
436   ToolkitTestApplication application;
437
438   // Create the ItemView actor
439   TestItemFactory factory;
440   ItemView view = ItemView::New(factory);
441
442   // Disable the anchor animation
443   view.SetAnchoring(false);
444
445   // Check the anchor animation is disabled
446   DALI_TEST_CHECK(view.GetAnchoring() == false);
447   END_TEST;
448 }
449
450 int UtcDaliItemViewSetAndGetAnchoringDuration(void)
451 {
452   ToolkitTestApplication application;
453
454   // Create the ItemView actor
455   TestItemFactory factory;
456   ItemView view = ItemView::New(factory);
457
458   // Set the duration of anchor animation to be 1.5f
459   view.SetAnchoringDuration(1.5f);
460
461   // Check the duration of anchor animation is 1.5f
462   DALI_TEST_EQUALS(view.GetAnchoringDuration(), 1.5f, TEST_LOCATION );
463   END_TEST;
464 }
465
466 int UtcDaliItemViewSetAndGetRefreshInterval(void)
467 {
468   ToolkitTestApplication application;
469
470   // Create the ItemView actor
471   TestItemFactory factory;
472   ItemView view = ItemView::New(factory);
473
474   // Set the interval between refreshes to be 20
475   view.SetRefreshInterval(20);
476
477   view.Refresh();
478
479   // Check the interval between refreshes is 20
480   DALI_TEST_CHECK(view.GetRefreshInterval() == 20);
481   END_TEST;
482 }
483
484 int UtcDaliItemViewScrollToItem(void)
485 {
486   ToolkitTestApplication application;
487
488   // Create the ItemView actor
489   TestItemFactory factory;
490   ItemView view = ItemView::New(factory);
491   Vector3 vec(480.0f, 800.0f, 0.0f);
492   ItemLayoutPtr layout = DefaultItemLayout::New( DefaultItemLayout::GRID );
493
494   view.SetName("view actor");
495   view.AddLayout(*layout);
496   view.SetSize(vec);
497
498   Stage::GetCurrent().Add(view);
499   layout->SetOrientation(ControlOrientation::Up);
500   view.ActivateLayout(0, vec, 0.0f);
501
502   application.SendNotification();
503   application.Render(0);
504
505   // render 10 frames
506   for(int i = 0; i < 10; ++i)
507   {
508     application.Render(16); // 60hz frames
509   }
510
511   // Confirm: we have actors in the view.
512   std::vector<unsigned int> indices;
513   for(unsigned int i = 0; i < 10; i++)
514   {
515     Actor testActor = view.GetItem(i);
516     if (testActor)
517     {
518       indices.push_back(i);
519     }
520   }
521
522   try
523   {
524     if (!indices.empty())
525     {
526       const unsigned int firstTargetIndex = indices[indices.size()-1];
527       // scroll to last item
528       view.ScrollToItem(firstTargetIndex, 0.00f);
529       for(int i = 0; i < 10; ++i)
530       {
531         application.Render(16); // 60hz frames
532       }
533
534       std::size_t moveCount = 0;
535       for(std::size_t i = 0; i < indices.size(); i++)
536       {
537         float layoutPosBefore = view.GetCurrentLayoutPosition(i);
538         view.ScrollToItem(indices[i], 0.0f);
539         float layoutPosAfter = view.GetCurrentLayoutPosition(i);
540
541         if (fabs(layoutPosBefore-layoutPosAfter) <= FLT_EPSILON)
542         {
543           ++moveCount;
544         }
545       }
546
547       DALI_TEST_CHECK((moveCount == indices.size()));
548     }
549   }
550   catch(...)
551   {
552     tet_result(TET_FAIL);
553   }
554
555   Stage::GetCurrent().Remove(view);
556   END_TEST;
557 }
558
559 int UtcDaliItemViewSetAndGetWheelScrollDistanceStep(void)
560 {
561   ToolkitTestApplication application;
562
563   // Create the ItemView actor
564   TestItemFactory factory;
565   ItemView view = ItemView::New(factory);
566
567   // Set the scroll distance step for the wheel event to be 100.0f
568   view.SetWheelScrollDistanceStep(100.0f);
569
570   // Check the scroll distance step is 100.0f
571   DALI_TEST_EQUALS(view.GetWheelScrollDistanceStep(), 100.0f, TEST_LOCATION );
572   END_TEST;
573 }
574
575 int UtcDaliItemViewInsertItemP(void)
576 {
577   ToolkitTestApplication application;
578
579   // Create the ItemView actor
580   TestItemFactory factory;
581   ItemView view = ItemView::New(factory);
582
583   // Create a grid layout and add it to ItemView
584   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
585   view.AddLayout(*gridLayout);
586
587   // Activate the grid layout so that the items will be created and added to ItemView
588   Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
589   view.ActivateLayout(0, stageSize, 0.5f);
590
591   // Get the item given the item ID
592   Actor itemActor = view.GetItem(2);
593
594   ItemId id = view.GetItemId( itemActor );
595
596   // Check we are getting the correct Item ID given the specified actor
597   DALI_TEST_CHECK(view.GetItemId(itemActor) == 2);
598
599   Actor newActor = Actor::New();
600
601   view.InsertItem(Item(id, newActor), 0.5f);
602
603   DALI_TEST_CHECK(view.GetItem(2) == newActor);
604   END_TEST;
605 }
606
607 int UtcDaliItemViewInsertItemsP(void)
608 {
609   ToolkitTestApplication application;
610
611   // Create the ItemView actor
612   TestItemFactory factory;
613   ItemView view = ItemView::New(factory);
614
615   // Create a grid layout and add it to ItemView
616   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
617   view.AddLayout(*gridLayout);
618
619   // Activate the grid layout so that the items will be created and added to ItemView
620   Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
621   view.ActivateLayout(0, stageSize, 0.5f);
622
623   unsigned int itemCount = view.GetChildCount();
624
625   ItemContainer insertList;
626
627   for( unsigned int i = 0u; i < 10; ++i )
628   {
629     Actor child = view.GetChildAt( i );
630     Actor newActor = Actor::New();
631     newActor.SetName("Inserted");
632     insertList.push_back( Item( view.GetItemId(child), newActor ) );
633   }
634
635   if( !insertList.empty() )
636   {
637     view.InsertItems( insertList, 0.5f );
638   }
639
640   DALI_TEST_CHECK(view.GetChildCount() == itemCount + 10);
641
642   ItemIdContainer removeList;
643
644   for( unsigned int i = 0u; i < view.GetChildCount(); ++i )
645   {
646     Actor child = view.GetChildAt( i );
647
648     if( child.GetName() == "Inserted" )
649     {
650       removeList.push_back( view.GetItemId(child) );
651     }
652   }
653
654   if( ! removeList.empty() )
655   {
656     view.RemoveItems( removeList, 0.5f );
657   }
658
659   DALI_TEST_CHECK(view.GetChildCount() == itemCount);
660   END_TEST;
661 }
662
663 int UtcDaliItemViewReplaceItemP(void)
664 {
665   ToolkitTestApplication application;
666
667   // Create the ItemView actor
668   TestItemFactory factory;
669   ItemView view = ItemView::New(factory);
670
671   // Create a grid layout and add it to ItemView
672   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
673   view.AddLayout(*gridLayout);
674
675   // Activate the grid layout so that the items will be created and added to ItemView
676   Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
677   view.ActivateLayout(0, stageSize, 0.5f);
678
679   Actor newActor = Actor::New();
680
681   view.ReplaceItem( Item( 0, newActor ), 0.5f );
682
683   DALI_TEST_CHECK(view.GetItem(0) == newActor);
684   END_TEST;
685 }
686
687 int UtcDaliItemViewReplaceItemsP(void)
688 {
689   ToolkitTestApplication application;
690
691   // Create the ItemView actor
692   TestItemFactory factory;
693   ItemView view = ItemView::New(factory);
694
695   // Create a grid layout and add it to ItemView
696   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
697   view.AddLayout(*gridLayout);
698
699   // Activate the grid layout so that the items will be created and added to ItemView
700   Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
701   view.ActivateLayout(0, stageSize, 0.5f);
702
703   ItemContainer replaceList;
704
705   for( unsigned int i = 0u; i < 10; ++i )
706   {
707     Actor child = view.GetChildAt( i );
708     Actor newActor = Actor::New();
709     newActor.SetName("Replaced");
710
711     replaceList.push_back( Item( view.GetItemId(child), newActor ) );
712   }
713
714   if( !replaceList.empty() )
715   {
716     view.ReplaceItems( replaceList, 0.5f );
717   }
718
719   DALI_TEST_CHECK(view.GetItem(0).GetName() == "Replaced");
720   DALI_TEST_CHECK(view.GetItem(8).GetName() == "Replaced");
721   END_TEST;
722 }
723
724 int UtcDaliItemViewGetItemsRangeP(void)
725 {
726   ToolkitTestApplication application;
727
728   // Create the ItemView actor
729   TestItemFactory factory;
730   ItemView view = ItemView::New(factory);
731
732   // Create a grid layout and add it to ItemView
733   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
734   view.AddLayout(*gridLayout);
735
736   // Activate the grid layout so that the items will be created and added to ItemView
737   Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
738   view.ActivateLayout(0, stageSize, 0.5f);
739
740   ItemRange itemRange(0, 0);
741
742   view.GetItemsRange(itemRange);
743
744   DALI_TEST_CHECK(itemRange.Within(0));
745   END_TEST;
746 }
747
748 int UtcDaliItemViewSetItemsAnchorPointP(void)
749 {
750   ToolkitTestApplication application;
751
752   // Create the ItemView actor
753   TestItemFactory factory;
754   ItemView view = ItemView::New(factory);
755
756   // Create a grid layout and add it to ItemView
757   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
758   view.AddLayout(*gridLayout);
759
760   // Activate the grid layout so that the items will be created and added to ItemView
761   Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
762   view.ActivateLayout(0, stageSize, 0.5f);
763
764   Vector3 anchorPoint(10.0f, 10.0f, 0.0f);
765
766   view.SetItemsAnchorPoint(anchorPoint);
767
768   DALI_TEST_CHECK(view.GetItemsAnchorPoint() == anchorPoint);
769   DALI_TEST_CHECK(view.GetItem(0).GetCurrentAnchorPoint() == anchorPoint);
770   END_TEST;
771 }
772
773 int UtcDaliItemViewSetItemsParentOriginP(void)
774 {
775   ToolkitTestApplication application;
776
777   // Create the ItemView actor
778   TestItemFactory factory;
779   ItemView view = ItemView::New(factory);
780
781   // Create a grid layout and add it to ItemView
782   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
783   view.AddLayout(*gridLayout);
784
785   // Activate the grid layout so that the items will be created and added to ItemView
786   Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
787   view.ActivateLayout(0, stageSize, 0.5f);
788
789   Vector3 parentOrigin(10.0f, 10.0f, 0.0f);
790
791   view.SetItemsParentOrigin(parentOrigin);
792
793   DALI_TEST_CHECK(view.GetItemsParentOrigin() == parentOrigin);
794   DALI_TEST_CHECK(view.GetItem(0).GetCurrentParentOrigin() == parentOrigin);
795   END_TEST;
796 }
797
798 int UtcDaliItemFactoryGetExtention(void)
799 {
800   ToolkitTestApplication application;
801   TestItemFactory factory;
802   DALI_TEST_CHECK( factory.GetExtension() == NULL );
803   END_TEST;
804 }
805
806 int UtcDaliItemViewLayoutActivatedSignalP(void)
807 {
808   ToolkitTestApplication application;
809
810   // Create the ItemView actor
811   TestItemFactory factory;
812   ItemView view = ItemView::New(factory);
813
814   // Create a grid layout and add it to ItemView
815   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
816   view.AddLayout(*gridLayout);
817
818   Stage::GetCurrent().Add( view );
819
820   // Connect the layout activated signal
821   view.LayoutActivatedSignal().Connect( &OnLayoutActivated );
822
823   gOnLayoutActivatedCalled = false;
824
825   // Render and notify
826   application.SendNotification();
827   application.Render();
828
829   // Activate the grid layout so that the items will be created and added to ItemView
830   Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
831   view.ActivateLayout(0, stageSize, 0.1f);
832
833   // Wait for 0.1 second
834   Wait(application, 100);
835
836   DALI_TEST_EQUALS( gOnLayoutActivatedCalled, true, TEST_LOCATION );
837
838   END_TEST;
839 }