2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #include <float.h> // for FLT_MAX
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>
26 #include <dali-toolkit/dali-toolkit.h>
29 using namespace Toolkit;
31 void utc_dali_toolkit_item_view_startup(void)
33 test_return_value = TET_UNDEF;
36 void utc_dali_toolkit_item_view_cleanup(void)
38 test_return_value = TET_PASS;
44 const unsigned int TOTAL_ITEM_NUMBER = 100;
45 const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
47 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
49 static bool gObjectCreatedCallBackCalled;
50 static bool gOnLayoutActivatedCalled; ///< Whether the LayoutActivated signal was invoked.
52 static void TestCallback(BaseHandle handle)
54 gObjectCreatedCallBackCalled = true;
57 static void OnLayoutActivated()
59 gOnLayoutActivatedCalled = true;
63 * Simulate time passed by.
65 * @note this will always process at least 1 frame (1/60 sec)
67 * @param application Test application instance
68 * @param duration Time to pass in milliseconds.
69 * @return The actual time passed in milliseconds
71 int Wait(ToolkitTestApplication& application, int duration = 0)
75 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
77 application.SendNotification();
78 application.Render(RENDER_FRAME_INTERVAL);
79 time += RENDER_FRAME_INTERVAL;
85 // Implementation of ItemFactory for providing actors to ItemView
86 class TestItemFactory : public ItemFactory
92 * @param application class, stored as reference
98 public: // From ItemFactory
101 * Query the number of items available from the factory.
102 * The maximum available item has an ID of GetNumberOfItems() - 1.
104 virtual unsigned int GetNumberOfItems()
106 return TOTAL_ITEM_NUMBER;
110 * Create an Actor to represent a visible item.
112 * @return the created actor.
114 virtual Actor NewItem(unsigned int itemId)
116 // Create an image actor for this item
117 Image image = ResourceImage::New( TEST_IMAGE_FILE_NAME );
118 Actor actor = ImageActor::New(image);
127 int UtcDaliItemViewNew(void)
129 ToolkitTestApplication application;
131 // Create the ItemView actor
132 TestItemFactory factory;
133 ItemView view = ItemView::New(factory);
135 DALI_TEST_CHECK(view);
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 );
141 gObjectCreatedCallBackCalled = false;
142 registry.ObjectCreatedSignal().Connect(&TestCallback);
144 TestItemFactory factory;
145 ItemView view = ItemView::New(factory);
147 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
151 int UtcDaliItemViewDownCast(void)
153 ToolkitTestApplication application;
155 // Create the ItemView actor
156 TestItemFactory factory;
157 const ItemView itemViewConst = ItemView::New(factory);
158 ItemView itemView(itemViewConst);
160 BaseHandle handle(itemView);
162 ItemView newItemView = ItemView::DownCast( handle );
163 DALI_TEST_CHECK( itemView );
164 DALI_TEST_CHECK( newItemView == itemView );
168 int UtcDaliItemViewAddAndGetLayout(void)
170 ToolkitTestApplication application;
172 // Create the ItemView actor
173 TestItemFactory factory;
174 ItemView view = ItemView::New(factory);
176 // Create a grid layout and add it to ItemView
177 ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
178 view.AddLayout(*gridLayout);
180 // As we have added one layout, check the number of layout is now 1
181 DALI_TEST_CHECK(view.GetLayoutCount() == 1);
183 // Create a depth layout and add it to ItemView
184 ItemLayoutPtr depthLayout = DefaultItemLayout::New( DefaultItemLayout::DEPTH );
185 view.AddLayout(*depthLayout);
187 // As we have added another layout, check the number of layout is now 2
188 DALI_TEST_CHECK(view.GetLayoutCount() == 2);
190 // Create a spiral layout and add it to ItemView
191 ItemLayoutPtr spiralLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL );
192 view.AddLayout(*spiralLayout);
194 // As we have added another layout, check the number of layout is now 3
195 DALI_TEST_CHECK(view.GetLayoutCount() == 3);
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);
204 int UtcDaliItemViewAddAndRemoveLayout(void)
206 ToolkitTestApplication application;
208 // Create the ItemView actor
209 TestItemFactory factory;
210 ItemView view = ItemView::New(factory);
212 // Create a grid layout and add it to ItemView
213 ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
214 view.AddLayout(*gridLayout);
216 // As we have added one layout, check the number of layout is now 1
217 DALI_TEST_CHECK(view.GetLayoutCount() == 1);
219 // Create a depth layout and add it to ItemView
220 ItemLayoutPtr depthLayout = DefaultItemLayout::New( DefaultItemLayout::DEPTH );
221 view.AddLayout(*depthLayout);
223 // As we have added another layout, check the number of layout is now 2
224 DALI_TEST_CHECK(view.GetLayoutCount() == 2);
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);
230 // Remove the grid layout
231 view.RemoveLayout(0);
233 // As we have removed the grid layout, check the number of layout is now 1
234 DALI_TEST_CHECK(view.GetLayoutCount() == 1);
236 // Check we are getting the correct layout from ItemView
237 DALI_TEST_CHECK(view.GetLayout(0) == depthLayout);
239 // Remove the depth layout
240 view.RemoveLayout(0);
242 // As we also removed the depth layout, check the number of layout is now 0
243 DALI_TEST_CHECK(view.GetLayoutCount() == 0);
247 int UtcDaliItemViewActivateLayoutAndGetActiveLayout(void)
249 ToolkitTestApplication application;
251 // Create the ItemView actor
252 TestItemFactory factory;
253 ItemView view = ItemView::New(factory);
255 // Create a grid layout and add it to ItemView
256 ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
257 view.AddLayout(*gridLayout);
259 // Create a depth layout and add it to ItemView
260 ItemLayoutPtr depthLayout = DefaultItemLayout::New( DefaultItemLayout::DEPTH );
261 view.AddLayout(*depthLayout);
263 // Create a spiral layout and add it to ItemView
264 ItemLayoutPtr spiralLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL );
265 view.AddLayout(*spiralLayout);
267 // As we have added three layouts, check the number of layout is now 3
268 DALI_TEST_CHECK(view.GetLayoutCount() == 3);
270 // Check there is no active layout at the moment
271 DALI_TEST_CHECK(view.GetActiveLayout() == NULL);
273 // Activate the depth layout
274 Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
275 view.ActivateLayout(1, stageSize, 0.5f);
277 // Check the current active layout is the depth layout
278 DALI_TEST_CHECK(view.GetActiveLayout() == depthLayout);
280 // Activate the grid layout
281 view.ActivateLayout(0, stageSize, 0.5f);
283 // Check the current active layout is the grid layout
284 DALI_TEST_CHECK(view.GetActiveLayout() == gridLayout);
286 // Activate the spiral layout
287 view.ActivateLayout(2, stageSize, 0.5f);
289 // Check the current active layout is the spiral layout
290 DALI_TEST_CHECK(view.GetActiveLayout() == spiralLayout);
294 int UtcDaliItemViewDeactivateCurrentLayout(void)
296 ToolkitTestApplication application;
298 // Create the ItemView actor
299 TestItemFactory factory;
300 ItemView view = ItemView::New(factory);
302 // Create a grid layout and add it to ItemView
303 ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
304 view.AddLayout(*gridLayout);
306 // Check there is no active layout at the moment
307 DALI_TEST_CHECK(view.GetActiveLayout() == NULL);
309 // Activate the grid layout
310 Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
311 view.ActivateLayout(0, stageSize, 0.5f);
313 // Check the current active layout is the grid layout
314 DALI_TEST_CHECK(view.GetActiveLayout() == gridLayout);
316 // Deactivate the current layout
317 view.DeactivateCurrentLayout();
319 // Check there is no active layout at the moment
320 DALI_TEST_CHECK(view.GetActiveLayout() == NULL);
324 int UtcDaliItemViewGetItemAndGetItemId(void)
326 ToolkitTestApplication application;
328 // Create the ItemView actor
329 TestItemFactory factory;
330 ItemView view = ItemView::New(factory);
332 // Create a grid layout and add it to ItemView
333 ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
334 view.AddLayout(*gridLayout);
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);
340 // Get the item given the item ID
341 Actor itemActor = view.GetItem(2);
343 // Check we are getting the correct Item ID given the specified actor
344 DALI_TEST_CHECK(view.GetItemId(itemActor) == 2);
348 int UtcDaliItemViewRemoveItem(void)
350 ToolkitTestApplication application;
352 // Create the ItemView actor
353 TestItemFactory factory;
354 ItemView view = ItemView::New(factory);
356 // Create a grid layout and add it to ItemView
357 ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
358 view.AddLayout(*gridLayout);
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);
364 // Get the item given the item ID 2 and 3
365 Actor oldItemActorID2 = view.GetItem(2);
366 Actor oldItemActorID3 = view.GetItem(3);
368 // Remove the item with ID 2
369 view.RemoveItem(2, 0.0f);
371 // Get the new item given the item ID 2
372 Actor newItemActorID2 = view.GetItem(2);
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);
381 int UtcDaliItemViewGetCurrentLayoutPosition(void)
383 ToolkitTestApplication application;
385 // Create the ItemView actor
386 TestItemFactory factory;
387 ItemView view = ItemView::New(factory);
389 // Create a grid layout and add it to ItemView
390 ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
391 view.AddLayout(*gridLayout);
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);
397 // Check the current layout position for the 10th items is 9.0f
398 DALI_TEST_EQUALS(view.GetCurrentLayoutPosition(9), 9.0f, TEST_LOCATION );
402 int UtcDaliItemViewSetAndGetMinimumSwipeSpeed(void)
404 ToolkitTestApplication application;
406 // Create the ItemView actor
407 TestItemFactory factory;
408 ItemView view = ItemView::New(factory);
410 // Set the minimum swipe speed to be 1.5f
411 view.SetMinimumSwipeSpeed(1.5f);
413 // Check the minimum swipe speed is 1.5f
414 DALI_TEST_EQUALS(view.GetMinimumSwipeSpeed(), 1.5f, TEST_LOCATION );
418 int UtcDaliItemViewSetAndGetMinimumSwipeDistance(void)
420 ToolkitTestApplication application;
422 // Create the ItemView actor
423 TestItemFactory factory;
424 ItemView view = ItemView::New(factory);
426 // Set the minimum swipe distance to be 2.5f
427 view.SetMinimumSwipeDistance(2.5f);
429 // Check the minimum swipe distance is 2.5f
430 DALI_TEST_EQUALS(view.GetMinimumSwipeDistance(), 2.5f, TEST_LOCATION );
434 int UtcDaliItemViewSetAndGetAnchoring(void)
436 ToolkitTestApplication application;
438 // Create the ItemView actor
439 TestItemFactory factory;
440 ItemView view = ItemView::New(factory);
442 // Disable the anchor animation
443 view.SetAnchoring(false);
445 // Check the anchor animation is disabled
446 DALI_TEST_CHECK(view.GetAnchoring() == false);
450 int UtcDaliItemViewSetAndGetAnchoringDuration(void)
452 ToolkitTestApplication application;
454 // Create the ItemView actor
455 TestItemFactory factory;
456 ItemView view = ItemView::New(factory);
458 // Set the duration of anchor animation to be 1.5f
459 view.SetAnchoringDuration(1.5f);
461 // Check the duration of anchor animation is 1.5f
462 DALI_TEST_EQUALS(view.GetAnchoringDuration(), 1.5f, TEST_LOCATION );
466 int UtcDaliItemViewSetAndGetRefreshInterval(void)
468 ToolkitTestApplication application;
470 // Create the ItemView actor
471 TestItemFactory factory;
472 ItemView view = ItemView::New(factory);
474 // Set the interval between refreshes to be 20
475 view.SetRefreshInterval(20);
479 // Check the interval between refreshes is 20
480 DALI_TEST_CHECK(view.GetRefreshInterval() == 20);
484 int UtcDaliItemViewScrollToItem(void)
486 ToolkitTestApplication application;
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 );
494 view.SetName("view actor");
495 view.AddLayout(*layout);
498 Stage::GetCurrent().Add(view);
499 layout->SetOrientation(ControlOrientation::Up);
500 view.ActivateLayout(0, vec, 0.0f);
502 application.SendNotification();
503 application.Render(0);
506 for(int i = 0; i < 10; ++i)
508 application.Render(16); // 60hz frames
511 // Confirm: we have actors in the view.
512 std::vector<unsigned int> indices;
513 for(unsigned int i = 0; i < 10; i++)
515 Actor testActor = view.GetItem(i);
518 indices.push_back(i);
524 if (!indices.empty())
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)
531 application.Render(16); // 60hz frames
534 std::size_t moveCount = 0;
535 for(std::size_t i = 0; i < indices.size(); i++)
537 float layoutPosBefore = view.GetCurrentLayoutPosition(i);
538 view.ScrollToItem(indices[i], 0.0f);
539 float layoutPosAfter = view.GetCurrentLayoutPosition(i);
541 if (fabs(layoutPosBefore-layoutPosAfter) <= FLT_EPSILON)
547 DALI_TEST_CHECK((moveCount == indices.size()));
552 tet_result(TET_FAIL);
555 Stage::GetCurrent().Remove(view);
559 int UtcDaliItemViewSetAndGetWheelScrollDistanceStep(void)
561 ToolkitTestApplication application;
563 // Create the ItemView actor
564 TestItemFactory factory;
565 ItemView view = ItemView::New(factory);
567 // Set the scroll distance step for the wheel event to be 100.0f
568 view.SetWheelScrollDistanceStep(100.0f);
570 // Check the scroll distance step is 100.0f
571 DALI_TEST_EQUALS(view.GetWheelScrollDistanceStep(), 100.0f, TEST_LOCATION );
575 int UtcDaliItemViewInsertItemP(void)
577 ToolkitTestApplication application;
579 // Create the ItemView actor
580 TestItemFactory factory;
581 ItemView view = ItemView::New(factory);
583 // Create a grid layout and add it to ItemView
584 ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
585 view.AddLayout(*gridLayout);
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);
591 // Get the item given the item ID
592 Actor itemActor = view.GetItem(2);
594 ItemId id = view.GetItemId( itemActor );
596 // Check we are getting the correct Item ID given the specified actor
597 DALI_TEST_CHECK(view.GetItemId(itemActor) == 2);
599 Actor newActor = Actor::New();
601 view.InsertItem(Item(id, newActor), 0.5f);
603 DALI_TEST_CHECK(view.GetItem(2) == newActor);
607 int UtcDaliItemViewInsertItemsP(void)
609 ToolkitTestApplication application;
611 // Create the ItemView actor
612 TestItemFactory factory;
613 ItemView view = ItemView::New(factory);
615 // Create a grid layout and add it to ItemView
616 ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
617 view.AddLayout(*gridLayout);
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);
623 unsigned int itemCount = view.GetChildCount();
625 ItemContainer insertList;
627 for( unsigned int i = 0u; i < 10; ++i )
629 Actor child = view.GetChildAt( i );
630 Actor newActor = Actor::New();
631 newActor.SetName("Inserted");
632 insertList.push_back( Item( view.GetItemId(child), newActor ) );
635 if( !insertList.empty() )
637 view.InsertItems( insertList, 0.5f );
640 DALI_TEST_CHECK(view.GetChildCount() == itemCount + 10);
642 ItemIdContainer removeList;
644 for( unsigned int i = 0u; i < view.GetChildCount(); ++i )
646 Actor child = view.GetChildAt( i );
648 if( child.GetName() == "Inserted" )
650 removeList.push_back( view.GetItemId(child) );
654 if( ! removeList.empty() )
656 view.RemoveItems( removeList, 0.5f );
659 DALI_TEST_CHECK(view.GetChildCount() == itemCount);
663 int UtcDaliItemViewReplaceItemP(void)
665 ToolkitTestApplication application;
667 // Create the ItemView actor
668 TestItemFactory factory;
669 ItemView view = ItemView::New(factory);
671 // Create a grid layout and add it to ItemView
672 ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
673 view.AddLayout(*gridLayout);
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);
679 Actor newActor = Actor::New();
681 view.ReplaceItem( Item( 0, newActor ), 0.5f );
683 DALI_TEST_CHECK(view.GetItem(0) == newActor);
687 int UtcDaliItemViewReplaceItemsP(void)
689 ToolkitTestApplication application;
691 // Create the ItemView actor
692 TestItemFactory factory;
693 ItemView view = ItemView::New(factory);
695 // Create a grid layout and add it to ItemView
696 ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
697 view.AddLayout(*gridLayout);
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);
703 ItemContainer replaceList;
705 for( unsigned int i = 0u; i < 10; ++i )
707 Actor child = view.GetItem( i );
708 Actor newActor = Actor::New();
709 newActor.SetName("Replaced");
711 replaceList.push_back( Item( i, newActor ) );
714 if( !replaceList.empty() )
716 view.ReplaceItems( replaceList, 0.5f );
719 DALI_TEST_CHECK(view.GetItem(0).GetName() == "Replaced");
720 DALI_TEST_CHECK(view.GetItem(8).GetName() == "Replaced");
724 int UtcDaliItemViewGetItemsRangeP(void)
726 ToolkitTestApplication application;
728 // Create the ItemView actor
729 TestItemFactory factory;
730 ItemView view = ItemView::New(factory);
732 // Create a grid layout and add it to ItemView
733 ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
734 view.AddLayout(*gridLayout);
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);
740 ItemRange itemRange(0, 0);
742 view.GetItemsRange(itemRange);
744 DALI_TEST_CHECK(itemRange.Within(0));
748 int UtcDaliItemViewSetItemsAnchorPointP(void)
750 ToolkitTestApplication application;
752 // Create the ItemView actor
753 TestItemFactory factory;
754 ItemView view = ItemView::New(factory);
756 // Create a grid layout and add it to ItemView
757 ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
758 view.AddLayout(*gridLayout);
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);
764 Vector3 anchorPoint(10.0f, 10.0f, 0.0f);
766 view.SetItemsAnchorPoint(anchorPoint);
768 DALI_TEST_CHECK(view.GetItemsAnchorPoint() == anchorPoint);
769 DALI_TEST_CHECK(view.GetItem(0).GetCurrentAnchorPoint() == anchorPoint);
773 int UtcDaliItemViewSetItemsParentOriginP(void)
775 ToolkitTestApplication application;
777 // Create the ItemView actor
778 TestItemFactory factory;
779 ItemView view = ItemView::New(factory);
781 // Create a grid layout and add it to ItemView
782 ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
783 view.AddLayout(*gridLayout);
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);
789 Vector3 parentOrigin(10.0f, 10.0f, 0.0f);
791 view.SetItemsParentOrigin(parentOrigin);
793 DALI_TEST_CHECK(view.GetItemsParentOrigin() == parentOrigin);
794 DALI_TEST_CHECK(view.GetItem(0).GetCurrentParentOrigin() == parentOrigin);
798 int UtcDaliItemFactoryGetExtention(void)
800 ToolkitTestApplication application;
801 TestItemFactory factory;
802 DALI_TEST_CHECK( factory.GetExtension() == NULL );
806 int UtcDaliItemViewLayoutActivatedSignalP(void)
808 ToolkitTestApplication application;
810 // Create the ItemView actor
811 TestItemFactory factory;
812 ItemView view = ItemView::New(factory);
814 // Create a grid layout and add it to ItemView
815 ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
816 view.AddLayout(*gridLayout);
818 Stage::GetCurrent().Add( view );
820 // Connect the layout activated signal
821 view.LayoutActivatedSignal().Connect( &OnLayoutActivated );
823 gOnLayoutActivatedCalled = false;
826 application.SendNotification();
827 application.Render();
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);
833 // Wait for 0.1 second
834 Wait(application, 100);
836 DALI_TEST_EQUALS( gOnLayoutActivatedCalled, true, TEST_LOCATION );
841 int UtcDaliItemViewSetGetProperty(void)
843 ToolkitTestApplication application;
845 // Create the ItemView actor
846 TestItemFactory factory;
847 ItemView view = ItemView::New(factory);
848 DALI_TEST_CHECK(view);
850 // Event side properties
852 // Test "minimumSwipeSpeed" property
853 DALI_TEST_CHECK( view.GetPropertyIndex("minimumSwipeSpeed") == ItemView::Property::MINIMUM_SWIPE_SPEED );
854 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::MINIMUM_SWIPE_SPEED).Get<float>(), view.GetMinimumSwipeSpeed(), TEST_LOCATION );
855 view.SetProperty( ItemView::Property::MINIMUM_SWIPE_SPEED, 2.5f );
856 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::MINIMUM_SWIPE_SPEED).Get<float>(), 2.5f, TEST_LOCATION );
858 // Test "minimumSwipeDistance" property
859 DALI_TEST_CHECK( view.GetPropertyIndex("minimumSwipeDistance") == ItemView::Property::MINIMUM_SWIPE_DISTANCE );
860 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::MINIMUM_SWIPE_DISTANCE).Get<float>(), view.GetMinimumSwipeDistance(), TEST_LOCATION );
861 view.SetProperty( ItemView::Property::MINIMUM_SWIPE_DISTANCE, 8.725f );
862 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::MINIMUM_SWIPE_DISTANCE).Get<float>(), 8.725f, TEST_LOCATION );
864 // Test "wheelScrollDistanceStep" property
865 DALI_TEST_CHECK( view.GetPropertyIndex("wheelScrollDistanceStep") == ItemView::Property::WHEEL_SCROLL_DISTANCE_STEP );
866 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::WHEEL_SCROLL_DISTANCE_STEP).Get<float>(), view.GetWheelScrollDistanceStep(), TEST_LOCATION );
867 view.SetProperty( ItemView::Property::WHEEL_SCROLL_DISTANCE_STEP, 5.0f );
868 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::WHEEL_SCROLL_DISTANCE_STEP).Get<float>(), 5.0f, TEST_LOCATION );
870 // Test "snapToItemEnabled" property
871 DALI_TEST_CHECK( view.GetPropertyIndex("snapToItemEnabled") == ItemView::Property::SNAP_TO_ITEM_ENABLED );
872 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::SNAP_TO_ITEM_ENABLED).Get<bool>(), view.GetAnchoring(), TEST_LOCATION );
873 view.SetProperty( ItemView::Property::SNAP_TO_ITEM_ENABLED, true );
874 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::SNAP_TO_ITEM_ENABLED).Get<bool>(), true, TEST_LOCATION );
876 // Test "refreshInterval" property
877 DALI_TEST_CHECK( view.GetPropertyIndex("refreshInterval") == ItemView::Property::REFRESH_INTERVAL );
878 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::REFRESH_INTERVAL).Get<float>(), view.GetRefreshInterval(), TEST_LOCATION );
879 view.SetProperty( ItemView::Property::REFRESH_INTERVAL, 11.0f );
880 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::REFRESH_INTERVAL).Get<float>(), 11.0f, TEST_LOCATION );
882 // Test "overshootEnabled" property
883 DALI_TEST_CHECK( view.GetPropertyIndex("overshootEnabled") == Scrollable::Property::OVERSHOOT_ENABLED );
884 DALI_TEST_EQUALS( view.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), view.IsOvershootEnabled(), TEST_LOCATION );
885 view.SetProperty( Scrollable::Property::OVERSHOOT_ENABLED, false );
886 DALI_TEST_EQUALS( view.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), false, TEST_LOCATION );
888 // Animatable properties
890 // Test "layoutPosition" property
891 DALI_TEST_CHECK( view.GetPropertyIndex("layoutPosition") == ItemView::Property::LAYOUT_POSITION );
892 view.SetProperty( ItemView::Property::LAYOUT_POSITION, 20.5f );
894 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::LAYOUT_POSITION).Get<float>(), 20.5f, TEST_LOCATION );
896 // Test "scrollSpeed" property
897 DALI_TEST_CHECK( view.GetPropertyIndex("scrollSpeed") == ItemView::Property::SCROLL_SPEED );
898 view.SetProperty( ItemView::Property::SCROLL_SPEED, 3.35f );
900 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::SCROLL_SPEED).Get<float>(), 3.35f, TEST_LOCATION );
902 // Test "overshoot" property
903 DALI_TEST_CHECK( view.GetPropertyIndex("overshoot") == ItemView::Property::OVERSHOOT );
904 view.SetProperty( ItemView::Property::OVERSHOOT, 0.15f );
906 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::OVERSHOOT).Get<float>(), 0.15f, TEST_LOCATION );
908 // Test "scrollDirection" property
909 DALI_TEST_CHECK( view.GetPropertyIndex("scrollDirection") == ItemView::Property::SCROLL_DIRECTION );
910 view.SetProperty( ItemView::Property::SCROLL_DIRECTION, Vector2(0.85f, 0.5f) );
912 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::SCROLL_DIRECTION).Get<Vector2>(), Vector2(0.85f, 0.5f), TEST_LOCATION );
914 // Test "layoutOrientation" property
915 DALI_TEST_CHECK( view.GetPropertyIndex("layoutOrientation") == ItemView::Property::LAYOUT_ORIENTATION );
916 view.SetProperty( ItemView::Property::LAYOUT_ORIENTATION, 2 );
918 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::LAYOUT_ORIENTATION).Get<int>(), 2, TEST_LOCATION );
920 // Test "scrollContentSize" property
921 DALI_TEST_CHECK( view.GetPropertyIndex("scrollContentSize") == ItemView::Property::SCROLL_CONTENT_SIZE );
922 view.SetProperty( ItemView::Property::SCROLL_CONTENT_SIZE, 250.0f );
924 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::SCROLL_CONTENT_SIZE).Get<float>(), 250.0f, TEST_LOCATION );