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