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