Applying changes to Scene::New()
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-ItemLayout.cpp
1 /*
2  * Copyright (c) 2017 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
21 // Need to override adaptor classes for toolkit test harness, so include
22 // test harness headers before dali headers.
23 #include <dali-toolkit-test-suite-utils.h>
24
25 #include <dali.h>
26 #include <dali-toolkit/dali-toolkit.h>
27
28 using namespace Dali;
29 using namespace Toolkit;
30
31 namespace
32 {
33 const unsigned int TOTAL_ITEM_NUMBER = 200;
34 const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
35
36
37 // Implementation of ItemFactory for providing actors to ItemView
38 class TestItemFactory : public ItemFactory
39 {
40 public:
41
42   /**
43    * Constructor
44    * @param application class, stored as reference
45    */
46   TestItemFactory()
47   {
48   }
49
50   /**
51    * Virtual destructor.
52    */
53   virtual ~TestItemFactory()
54   {
55   }
56
57 public: // From ItemFactory
58
59   /**
60    * Query the number of items available from the factory.
61    * The maximum available item has an ID of GetNumberOfItems() - 1.
62    */
63   virtual unsigned int GetNumberOfItems()
64   {
65     return TOTAL_ITEM_NUMBER;
66   }
67
68   /**
69    * Create an Actor to represent a visible item.
70    * @param itemId
71    * @return the created actor.
72    */
73   virtual Actor NewItem(unsigned int itemId)
74   {
75     // Create a renderable actor for this item
76     Image image = ResourceImage::New( TEST_IMAGE_FILE_NAME );
77     Actor actor = CreateRenderableActor(image);
78
79     return actor;
80   }
81 };
82
83 class TestItemLayout;
84
85 typedef IntrusivePtr<TestItemLayout> TestItemLayoutPtr;
86
87 // Implementation of ItemLayout
88 class TestItemLayout : public ItemLayout
89 {
90 public:
91
92   /**
93    * Constructor
94    */
95   TestItemLayout()
96   {
97   }
98
99   /**
100    * Virtual destructor.
101    */
102   virtual ~TestItemLayout()
103   {
104   }
105
106   /**
107    * Create a new grid layout.
108    */
109   static TestItemLayoutPtr New()
110   {
111     return TestItemLayoutPtr(new TestItemLayout());
112   }
113
114 public: // From ItemLayout
115
116   /**
117    * Query the minimum valid layout position; this is a negative value.
118    *
119    * When scrolling, the first item will move within the range 0 to GetMinimumLayoutPosition().
120    * @param[in] numberOfItems The current number of items in the layout.
121    * @param[in] layoutSize The size of the layout area.
122    * @return The minimum layout position.
123    */
124   virtual float GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const
125   {
126     return 0.0f;
127   }
128
129   /**
130    * Query the closest anchor position for the given layout position.
131    *
132    * This anchor position is the position where all the items in the layout are aligned to
133    * their rounded layout positions in integer.
134    * @param[in] layoutPosition The layout position.
135    * @return The closest anchor position for the given layout position.
136    */
137   virtual float GetClosestAnchorPosition(float layoutPosition) const
138   {
139     return 0.0f;
140   }
141
142   /**
143    * Query the layout position for the first item in the layout to move to when the layout
144    * needs to scroll to a particular item.
145    *
146    * @param[in] itemId The ID of an item in the layout.
147    * @return The layout position for the first item in the layout to move to.
148    */
149   virtual float GetItemScrollToPosition(unsigned int itemId) const
150   {
151     return 0.0f;
152   }
153
154   /**
155    * Query the items within a given layout-area.
156    *
157    * @param[in] firstItemPosition The layout-position of the first item in the layout.
158    * @param[in] layoutSize The size of the layout area.
159    * @return The ID of the first & last visible item.
160    */
161   virtual ItemRange GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const
162   {
163     return ItemRange(0, 10);
164   }
165
166   /**
167    * Query the number of items that should be reserved, for scrolling purposes.
168    *
169    * @param[in] layoutSize The size of the layout area.
170    * @return The number of extra items.
171    */
172   virtual unsigned int GetReserveItemCount(Vector3 layoutSize) const
173   {
174     return 0;
175   }
176
177   /**
178    * Retrieve the default size of an item in the layout.
179    *
180    * @param[in] itemId The ID of an item in the layout.
181    * @param[in] layoutSize The layout size
182    * @param[out] itemSize The target size of an item.
183    */
184   virtual void GetDefaultItemSize( unsigned int itemId, const Vector3& layoutSize, Vector3& itemSize ) const
185   {
186   }
187
188   /**
189    * @brief Query the scroll direction of the layout.
190    * @return The scroll direction in degrees.
191    */
192   virtual Degree GetScrollDirection() const
193   {
194     return Degree( 0.0f );
195   }
196
197   /**
198    * @brief Query the scroll speed factor of the layout while dragging.
199    * @return The scroll speed factor of the layout.
200    */
201   virtual float GetScrollSpeedFactor() const
202   {
203     return 0;
204   }
205
206   /**
207    * @brief Query the maximum swipe speed in pixels per second.
208    * @return speed The maximum swipe speed.
209    */
210   virtual float GetMaximumSwipeSpeed() const
211   {
212     return 0;
213   }
214
215   /**
216    * @brief Get the duration of the flick animation in second.
217    * @return The duration of the flick animation.
218    */
219   virtual float GetItemFlickAnimationDuration() const
220   {
221     return 0;
222   }
223
224   /*
225    * @brief Applies constraints defined by the layout to an actor.
226    *
227    * @param[in] actor The actor to constrain.
228    * @param[in] itemId The ID of the item represented by the actor.
229    * @param[in] layoutSize the current size of the item view instance.
230    * @param[in] itemViewActor The item view instance which requests the application of constraints.
231    */
232   virtual void ApplyConstraints( Actor& actor, const int itemId, const Vector3& layoutSize, const Actor& itemViewActor )
233   {
234   }
235
236   /**
237    * @brief Gets the position of a given item
238    *
239    * @param[in] itemID id of the item we want to get its position
240    * @param[in] currentLayoutPosition the current layout position of the item view instance
241    * @param[in] layoutSize the current size of the item view instance
242    * @return The item position (x,y,z)
243    */
244   virtual Vector3 GetItemPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize) const
245   {
246     return Vector3::ZERO;
247   }
248 };
249
250 } // namespace
251
252 int UtcDaliItemLayoutSetAndGetOrientation(void)
253 {
254   ToolkitTestApplication application;
255
256   // Create the ItemView actor
257   TestItemFactory factory;
258   ItemView view = ItemView::New(factory);
259
260   // Create a grid layout and add it to ItemView
261   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
262   view.AddLayout(*gridLayout);
263
264   // Set the orientation of the layout to be horizontal from left to right
265   ItemLayoutPtr layout = view.GetLayout(0);
266
267   DALI_TEST_CHECK(gridLayout == layout);
268
269   layout->SetOrientation(ControlOrientation::Left);
270
271   // Check the orientation of the layout is horizontal from left to right
272   DALI_TEST_CHECK(layout->GetOrientation() == ControlOrientation::Left);
273
274   Vector3 itemSize(100.0f, 100.0f, 100.0f);
275   layout->SetItemSize(itemSize);
276
277   Vector3 itemSize1;
278   layout->GetItemSize(0u, Vector3(Stage::GetCurrent().GetSize()), itemSize1);
279
280   DALI_TEST_CHECK(itemSize == itemSize1);
281
282   float position = layout->GetClosestOnScreenLayoutPosition(0, 0.0f, Vector3(Stage::GetCurrent().GetSize()));
283
284   DALI_TEST_EQUALS(position, 0.0f, TEST_LOCATION);
285
286   int focusItem = layout->GetNextFocusItemID(0, TOTAL_ITEM_NUMBER, Control::KeyboardFocus::LEFT, true);
287
288   DALI_TEST_CHECK(focusItem != 0);
289
290   float flickSpeedFactor = layout->GetFlickSpeedFactor();
291
292   DALI_TEST_CHECK(flickSpeedFactor != 0.0f);
293
294   // White box test here: -( itemId / NoOfItemsPerRow(default 4) ) * NoOfItemsPerRow
295   DALI_TEST_EQUALS( -1.0f, gridLayout->GetItemScrollToPosition( 1 ), TEST_LOCATION );
296
297   ItemLayoutPtr depthLayout = DefaultItemLayout::New( DefaultItemLayout::DEPTH );
298   view.AddLayout(*depthLayout);
299
300   layout = view.GetLayout(1);
301   DALI_TEST_CHECK(depthLayout == layout);
302
303   ItemLayoutPtr listLayout = DefaultItemLayout::New( DefaultItemLayout::LIST );
304   view.AddLayout(*listLayout);
305
306   layout = view.GetLayout(2);
307   DALI_TEST_CHECK(listLayout == layout);
308
309   ItemLayoutPtr spiralLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL );
310   view.AddLayout(*spiralLayout);
311
312   layout = view.GetLayout(3);
313   DALI_TEST_CHECK(spiralLayout == layout);
314   END_TEST;
315 }
316
317 int UtcDaliItemLayoutGetExtension(void)
318 {
319   ToolkitTestApplication application;
320
321   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
322   DALI_TEST_CHECK( gridLayout );
323   DALI_TEST_CHECK( !gridLayout->GetExtension() );
324
325   END_TEST;
326 }
327
328 int UtcDaliItemLayoutGetClosestOnScreenLayoutPosition(void)
329 {
330   ToolkitTestApplication application;
331
332   TestItemLayoutPtr layout = TestItemLayout::New();
333   DALI_TEST_CHECK( layout );
334   DALI_TEST_EQUALS(layout->GetClosestOnScreenLayoutPosition(0, 0.0f, Vector3::ZERO), 0.0f, TEST_LOCATION );
335   DALI_TEST_EQUALS(layout->GetClosestOnScreenLayoutPosition(0, 0.0f, Vector3(-800.0f, -1200.0f, 0.0f)), 0.0f, TEST_LOCATION );
336
337   END_TEST;
338 }
339
340 int UtcDaliItemLayoutGetNextFocusItemID(void)
341 {
342   ToolkitTestApplication application;
343
344   TestItemLayoutPtr layout = TestItemLayout::New();
345   DALI_TEST_CHECK( layout );
346   DALI_TEST_EQUALS(layout->GetNextFocusItemID(0, 100, Control::KeyboardFocus::LEFT, true), 99, TEST_LOCATION );
347   DALI_TEST_EQUALS(layout->GetNextFocusItemID(110, 100, Control::KeyboardFocus::RIGHT, true), 0, TEST_LOCATION );
348
349   END_TEST;
350 }
351
352 int UtcDaliItemLayoutSetAndGetLayoutProperties(void)
353 {
354   ToolkitTestApplication application;
355
356   // Create the ItemView actor
357   TestItemFactory factory;
358   ItemView view = ItemView::New(factory);
359
360   // Create a grid layout and add it to ItemView
361   ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
362
363   // Set the property of the grid layout
364   Property::Map gridLayoutProperty;
365   gridLayoutProperty.Insert( DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::GRID) );
366   gridLayoutProperty.Insert( DefaultItemLayoutProperty::ITEM_SIZE, Dali::Property::Value(Vector3(200, 200,50)) );
367   gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_ROW_SPACING, Dali::Property::Value(50.0f) );
368   gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_COLUMN_NUMBER, Dali::Property::Value(4) );
369   gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_COLUMN_SPACING, Dali::Property::Value(50.0f) );
370   gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_TOP_MARGIN, Dali::Property::Value(95.0f) );
371   gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_BOTTOM_MARGIN, Dali::Property::Value(20.0f) );
372   gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_SIDE_MARGIN, Dali::Property::Value(20.0f) );
373   gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_SCROLL_SPEED_FACTOR, Dali::Property::Value(0.03f) );
374   gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_ITEM_FLICK_ANIMATION_DURATION, Dali::Property::Value(0.015f) );
375   gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_MAXIMUM_SWIPE_SPEED, Dali::Property::Value(100.0f) );
376   gridLayoutProperty.Insert( DefaultItemLayoutProperty::ORIENTATION, Dali::Property::Value((int)ControlOrientation::Up) );
377   gridLayout->SetLayoutProperties(gridLayoutProperty);
378
379   view.AddLayout(*gridLayout);
380   ItemLayoutPtr layout = view.GetLayout(0);
381   DALI_TEST_CHECK(gridLayout == layout);
382   Property::Map firstLayout = gridLayout->GetLayoutProperties();
383
384   //Check all the properties of grid layout
385   DALI_TEST_EQUALS( gridLayoutProperty.Count(), firstLayout.Count(), TEST_LOCATION );
386
387   for( unsigned int mapIdx = 0, mapCount = firstLayout.Count(); mapIdx < mapCount; ++mapIdx )
388   {
389     KeyValuePair propertyPair( firstLayout.GetKeyValue( mapIdx ) );
390     if(propertyPair.first == DefaultItemLayoutProperty::TYPE)
391     {
392       int layoutType = propertyPair.second.Get<int>();
393       DALI_TEST_EQUALS( layoutType, (int)DefaultItemLayout::GRID, TEST_LOCATION );
394     }
395     else if(propertyPair.first == DefaultItemLayoutProperty::ITEM_SIZE)
396     {
397       Vector3 size = propertyPair.second.Get<Vector3>();
398       DALI_TEST_EQUALS( size, Vector3(200, 200,50), TEST_LOCATION );
399     }
400     else if(propertyPair.first == DefaultItemLayoutProperty::GRID_ROW_SPACING)
401     {
402       float rowSpacing = propertyPair.second.Get<float>();
403       DALI_TEST_EQUALS( rowSpacing, 50.0f, TEST_LOCATION );
404     }
405     else if(propertyPair.first == DefaultItemLayoutProperty::GRID_COLUMN_NUMBER)
406     {
407       int number = propertyPair.second.Get<int>();
408       DALI_TEST_EQUALS(number, 4, TEST_LOCATION );
409     }
410     else if(propertyPair.first == DefaultItemLayoutProperty::GRID_COLUMN_SPACING)
411     {
412       float columnSpacing = propertyPair.second.Get<float>();
413       DALI_TEST_EQUALS(columnSpacing, 50.0f, TEST_LOCATION );
414     }
415     else if(propertyPair.first == DefaultItemLayoutProperty::GRID_TOP_MARGIN)
416     {
417       float topMargin = propertyPair.second.Get<float>();
418       DALI_TEST_EQUALS(topMargin, 95.0f, TEST_LOCATION );
419     }
420     else if(propertyPair.first == DefaultItemLayoutProperty::GRID_BOTTOM_MARGIN)
421     {
422       float bottomMargin = propertyPair.second.Get<float>();
423       DALI_TEST_EQUALS(bottomMargin, 20.0f, TEST_LOCATION );
424     }
425     else if(propertyPair.first == DefaultItemLayoutProperty::GRID_SIDE_MARGIN)
426     {
427       float sideMargin = propertyPair.second.Get<float>();
428       DALI_TEST_EQUALS(sideMargin, 20.0f, TEST_LOCATION );
429     }
430     else if(propertyPair.first == DefaultItemLayoutProperty::GRID_SCROLL_SPEED_FACTOR)
431     {
432       float scrollSpeedFactor = propertyPair.second.Get<float>();
433       DALI_TEST_EQUALS(scrollSpeedFactor, 0.03f, TEST_LOCATION );
434     }
435     else if(propertyPair.first == DefaultItemLayoutProperty::GRID_ITEM_FLICK_ANIMATION_DURATION)
436     {
437       float animationDuration = propertyPair.second.Get<float>();
438       DALI_TEST_EQUALS(animationDuration, 0.015f, TEST_LOCATION );
439     }
440     else if(propertyPair.first == DefaultItemLayoutProperty::GRID_MAXIMUM_SWIPE_SPEED)
441     {
442       float swipSpeed = propertyPair.second.Get<float>();
443       DALI_TEST_EQUALS(swipSpeed, 100.0f, TEST_LOCATION );
444     }
445   }
446   ItemLayoutPtr depthLayout = DefaultItemLayout::New( DefaultItemLayout::DEPTH );
447
448   // Set the property of the depth layout
449   Property::Map depthLayoutProperty;
450   depthLayoutProperty.Insert( DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::DEPTH) );
451   depthLayoutProperty.Insert( DefaultItemLayoutProperty::DEPTH_COLUMN_NUMBER, Dali::Property::Value(3) );
452   depthLayoutProperty.Insert( DefaultItemLayoutProperty::DEPTH_ROW_NUMBER, Dali::Property::Value(26.0f) );
453   depthLayoutProperty.Insert( DefaultItemLayoutProperty::DEPTH_ROW_SPACING, Dali::Property::Value(55.0f) );
454   depthLayoutProperty.Insert( DefaultItemLayoutProperty::DEPTH_TILT_ANGLE, Dali::Property::Value(Math::PI*0.15f) );
455   depthLayoutProperty.Insert( DefaultItemLayoutProperty::DEPTH_ITEM_TILT_ANGLE, Dali::Property::Value(-Math::PI*0.025f ) );
456   depthLayoutProperty.Insert( DefaultItemLayoutProperty::DEPTH_SCROLL_SPEED_FACTOR, Dali::Property::Value(0.02f) );
457   depthLayoutProperty.Insert( DefaultItemLayoutProperty::DEPTH_ITEM_FLICK_ANIMATION_DURATION, Dali::Property::Value(0.03f) );
458   depthLayoutProperty.Insert( DefaultItemLayoutProperty::DEPTH_MAXIMUM_SWIPE_SPEED, Dali::Property::Value(50.0f) );
459   depthLayoutProperty.Insert( DefaultItemLayoutProperty::ORIENTATION, Dali::Property::Value((int)ControlOrientation::Up) );
460   depthLayout->SetLayoutProperties(depthLayoutProperty);
461
462   view.AddLayout(*depthLayout);
463   layout = view.GetLayout(1);
464   DALI_TEST_CHECK(depthLayout == layout);
465
466   Property::Map secondLayout = depthLayout->GetLayoutProperties();
467
468   //Check all the properties of grid layout
469   DALI_TEST_EQUALS( depthLayoutProperty.Count(), secondLayout.Count(), TEST_LOCATION );
470   for( unsigned int mapIdx = 0, mapCount = secondLayout.Count(); mapIdx < mapCount; ++mapIdx )
471   {
472     KeyValuePair propertyPair( secondLayout.GetKeyValue( mapIdx ) );
473     if(propertyPair.first == DefaultItemLayoutProperty::TYPE)
474     {
475       int layoutType = propertyPair.second.Get<int>();
476       DALI_TEST_EQUALS( layoutType, (int)DefaultItemLayout::DEPTH, TEST_LOCATION );
477     }
478     else if(propertyPair.first == DefaultItemLayoutProperty::ORIENTATION)
479     {
480       int orientation = propertyPair.second.Get<int>();
481       DALI_TEST_EQUALS(orientation, (int)ControlOrientation::Up, TEST_LOCATION );
482     }
483     else if(propertyPair.first == DefaultItemLayoutProperty::ITEM_SIZE)
484     {
485       Vector3 size = propertyPair.second.Get<Vector3>();
486       DALI_TEST_EQUALS( size, Vector3(200, 200,50), TEST_LOCATION );
487     }
488
489     else if(propertyPair.first == DefaultItemLayoutProperty::DEPTH_COLUMN_NUMBER)
490     {
491       int columnNumber = propertyPair.second.Get<int>();
492       DALI_TEST_EQUALS( columnNumber, 3, TEST_LOCATION );
493     }
494     else if(propertyPair.first == DefaultItemLayoutProperty::DEPTH_ROW_NUMBER)
495     {
496       float rowNumber = propertyPair.second.Get<float>();
497       DALI_TEST_EQUALS(rowNumber, 26.0f, TEST_LOCATION );
498     }
499     else if(propertyPair.first == DefaultItemLayoutProperty::DEPTH_ROW_SPACING)
500     {
501       float rowSpacing = propertyPair.second.Get<float>();
502       DALI_TEST_EQUALS(rowSpacing, 55.0f, TEST_LOCATION );
503     }
504     else if(propertyPair.first == DefaultItemLayoutProperty::DEPTH_TILT_ANGLE)
505     {
506       float tiltAngle = propertyPair.second.Get<float>();
507       DALI_TEST_EQUALS(tiltAngle, Math::PI*0.15f, TEST_LOCATION );
508     }
509     else if(propertyPair.first == DefaultItemLayoutProperty::DEPTH_ITEM_TILT_ANGLE)
510     {
511       float itemTiltAngle = propertyPair.second.Get<float>();
512       DALI_TEST_EQUALS(itemTiltAngle, -Math::PI*0.025f, TEST_LOCATION );
513     }
514     else if(propertyPair.first == DefaultItemLayoutProperty::DEPTH_SCROLL_SPEED_FACTOR)
515     {
516       float scrollSpeedFactor = propertyPair.second.Get<float>();
517       DALI_TEST_EQUALS(scrollSpeedFactor, 0.02f, TEST_LOCATION );
518     }
519
520     else if(propertyPair.first == DefaultItemLayoutProperty::DEPTH_ITEM_FLICK_ANIMATION_DURATION)
521     {
522       float animationDuration = propertyPair.second.Get<float>();
523       DALI_TEST_EQUALS(animationDuration, 0.03f, TEST_LOCATION );
524     }
525     else if(propertyPair.first == DefaultItemLayoutProperty::DEPTH_MAXIMUM_SWIPE_SPEED)
526     {
527       float swipSpeed = propertyPair.second.Get<float>();
528       DALI_TEST_EQUALS(swipSpeed, 50.0f, TEST_LOCATION );
529     }
530   }
531   ItemLayoutPtr spiralLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL );
532
533   // Set the property of the spiral layout
534   Property::Map spiralLayoutPrperty;
535   spiralLayoutPrperty.Insert( DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::SPIRAL) );
536   spiralLayoutPrperty.Insert( DefaultItemLayoutProperty::SPIRAL_ITEM_SPACING, Dali::Property::Value((Math::PI*2.0f)/9.5f) );
537   spiralLayoutPrperty.Insert( DefaultItemLayoutProperty::SPIRAL_TOP_ITEM_ALIGNMENT, Dali::Property::Value(-0.125f) );
538   spiralLayoutPrperty.Insert( DefaultItemLayoutProperty::SPIRAL_REVOLUTION_DISTANCE, Dali::Property::Value(190.0f) );
539   spiralLayoutPrperty.Insert( DefaultItemLayoutProperty::SPIRAL_SCROLL_SPEED_FACTOR, Dali::Property::Value(0.01f) );
540   spiralLayoutPrperty.Insert( DefaultItemLayoutProperty::SPIRAL_ITEM_FLICK_ANIMATION_DURATION, Dali::Property::Value(0.1f) );
541   spiralLayoutPrperty.Insert( DefaultItemLayoutProperty::SPIRAL_MAXIMUM_SWIPE_SPEED, Dali::Property::Value(30.0f) );
542   spiralLayout->SetLayoutProperties(spiralLayoutPrperty);
543
544   view.AddLayout(*spiralLayout);
545   layout = view.GetLayout(2);
546   DALI_TEST_CHECK(spiralLayout == layout);
547
548   Property::Map thridLayout = spiralLayout->GetLayoutProperties();
549
550   //Check all the properties of grid layout
551   DALI_TEST_EQUALS( spiralLayoutPrperty.Count(), thridLayout.Count(), TEST_LOCATION );
552
553   for( unsigned int mapIdx = 0, mapCount = thridLayout.Count(); mapIdx < mapCount; ++mapIdx )
554   {
555     KeyValuePair propertyPair( thridLayout.GetKeyValue( mapIdx ) );
556     if(propertyPair.first == DefaultItemLayoutProperty::TYPE)
557     {
558       int layoutType = propertyPair.second.Get<int>();
559       DALI_TEST_EQUALS( layoutType, (int)DefaultItemLayout::SPIRAL, TEST_LOCATION );
560     }
561     else if(propertyPair.first == DefaultItemLayoutProperty::SPIRAL_ITEM_SPACING)
562     {
563       float columnNumber = propertyPair.second.Get<float>();
564       DALI_TEST_EQUALS( columnNumber, (Math::PI*2.0f)/9.5f, TEST_LOCATION );
565     }
566     else if(propertyPair.first == DefaultItemLayoutProperty::SPIRAL_TOP_ITEM_ALIGNMENT)
567     {
568       float rowNumber = propertyPair.second.Get<float>();
569       DALI_TEST_EQUALS(rowNumber, -0.125f, TEST_LOCATION );
570     }
571     else if(propertyPair.first == DefaultItemLayoutProperty::SPIRAL_REVOLUTION_DISTANCE)
572     {
573       float rowSpacing = propertyPair.second.Get<float>();
574       DALI_TEST_EQUALS(rowSpacing, 190.0f, TEST_LOCATION );
575     }
576     else if(propertyPair.first == DefaultItemLayoutProperty::SPIRAL_SCROLL_SPEED_FACTOR)
577     {
578       float scrollSpeedFactor = propertyPair.second.Get<float>();
579       DALI_TEST_EQUALS(scrollSpeedFactor, 0.01f, TEST_LOCATION );
580     }
581
582     else if(propertyPair.first == DefaultItemLayoutProperty::SPIRAL_ITEM_FLICK_ANIMATION_DURATION)
583     {
584       float animationDuration = propertyPair.second.Get<float>();
585       DALI_TEST_EQUALS(animationDuration, 0.1f, TEST_LOCATION );
586     }
587     else if(propertyPair.first == DefaultItemLayoutProperty::SPIRAL_MAXIMUM_SWIPE_SPEED)
588     {
589       float swipSpeed = propertyPair.second.Get<float>();
590       DALI_TEST_EQUALS(swipSpeed, 30.0f, TEST_LOCATION );
591     }
592   }
593   Dali::Stage stage = Dali::Stage::GetCurrent();
594   Vector3 stageSize(stage.GetSize());
595   view.ActivateLayout(0, stageSize, 0.5f);
596   view.ActivateLayout(1, stageSize, 0.5f);
597   view.ActivateLayout(2, stageSize, 0.5f);
598   END_TEST;
599
600 }
601
602 int UtcDaliItemRangeIntersection(void)
603 {
604   ToolkitTestApplication application;
605
606   unsigned int uBeginItemFirst = 100u, uEndItemFirst = 300u;
607   unsigned int uBeginItemSecond = 290u, uEndItemSecond = 400;
608   unsigned int uInterBeginCheck=290u , uInterEndCheck=301u;
609   bool bIsInThisRange = false, bOutOfThisRange = false;
610
611   Toolkit::ItemRange objItemRangeFirst(uBeginItemFirst, uEndItemFirst);
612   Toolkit::ItemRange objItemRangeSecond(uBeginItemSecond, uEndItemSecond);
613   ItemRange itmInterSect = objItemRangeFirst.Intersection(objItemRangeSecond);
614
615   bIsInThisRange = itmInterSect.Within(uInterBeginCheck);
616   DALI_TEST_EQUALS(bIsInThisRange, true, TEST_LOCATION );
617
618   bOutOfThisRange = itmInterSect.Within(uInterEndCheck);
619   DALI_TEST_EQUALS(bOutOfThisRange, false, TEST_LOCATION );
620
621   END_TEST;
622 }