2 * Copyright (c) 2022 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.
18 #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>
25 #include <dali-toolkit/dali-toolkit.h>
26 #include <dali/integration-api/events/touch-event-integ.h>
27 #include <dali/integration-api/events/wheel-event-integ.h>
30 using namespace Toolkit;
32 void utc_dali_toolkit_item_view_startup(void)
34 test_return_value = TET_UNDEF;
37 void utc_dali_toolkit_item_view_cleanup(void)
39 test_return_value = TET_PASS;
44 const unsigned int TOTAL_ITEM_NUMBER = 400;
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.
51 static bool gOnScrollUpdateCalled;
52 static bool gOnWheelEventCalled; ///< Whether the WheelEventSignal signal was invoked.
54 static void TestCallback(BaseHandle handle)
56 gObjectCreatedCallBackCalled = true;
59 static void OnLayoutActivated()
61 gOnLayoutActivatedCalled = true;
64 static void OnScrollUpdate(const Vector2& position)
66 gOnScrollUpdateCalled = true;
69 static bool OnWheelEvent(Actor actor, const Dali::WheelEvent& wheelEvent)
71 gOnWheelEventCalled = true;
75 Integration::TouchEvent GenerateSingleTouch(PointState::Type state, const Vector2& screenPosition, uint32_t time)
77 Integration::TouchEvent touchEvent;
78 Integration::Point point;
79 point.SetState(state);
81 point.SetScreenPosition(screenPosition);
82 point.SetDeviceClass(Device::Class::TOUCH);
83 point.SetDeviceSubclass(Device::Subclass::NONE);
84 touchEvent.points.push_back(point);
85 touchEvent.time = time;
90 * Simulate time passed by.
92 * @note this will always process at least 1 frame (1/60 sec)
94 * @param application Test application instance
95 * @param duration Time to pass in milliseconds.
96 * @return The actual time passed in milliseconds
98 int Wait(ToolkitTestApplication& application, int duration = 0)
102 for(int i = 0; i <= (duration / RENDER_FRAME_INTERVAL); i++)
104 application.SendNotification();
105 application.Render(RENDER_FRAME_INTERVAL);
106 time += RENDER_FRAME_INTERVAL;
112 // Implementation of ItemFactory for providing actors to ItemView
113 class TestItemFactory : public ItemFactory
118 * @param application class, stored as reference
124 public: // From ItemFactory
126 * Query the number of items available from the factory.
127 * The maximum available item has an ID of GetNumberOfItems() - 1.
129 virtual unsigned int GetNumberOfItems()
131 return TOTAL_ITEM_NUMBER;
135 * Create an Actor to represent a visible item.
137 * @return the created actor.
139 virtual Actor NewItem(unsigned int itemId)
141 // Create a renderable actor for this item
142 return ImageView::New(TEST_IMAGE_FILE_NAME);
148 int UtcDaliItemViewNew(void)
150 ToolkitTestApplication application;
152 // Create the ItemView actor
153 TestItemFactory factory;
154 ItemView view = ItemView::New(factory);
156 DALI_TEST_CHECK(view);
158 //Additional check to ensure object is created by checking if it's registered
159 ObjectRegistry registry = application.GetCore().GetObjectRegistry();
160 DALI_TEST_CHECK(registry);
162 gObjectCreatedCallBackCalled = false;
163 registry.ObjectCreatedSignal().Connect(&TestCallback);
165 TestItemFactory factory;
166 ItemView view = ItemView::New(factory);
168 DALI_TEST_CHECK(gObjectCreatedCallBackCalled);
172 int UtcDaliItemViewCopyConstructor(void)
174 ToolkitTestApplication application;
176 TestItemFactory factory;
177 ItemView itemView = ItemView::New(factory);
178 DALI_TEST_CHECK(itemView);
180 ItemView copy(itemView);
181 DALI_TEST_CHECK(copy);
186 int UtcDaliItemViewCopyAssignment(void)
188 ToolkitTestApplication application;
190 TestItemFactory factory;
191 ItemView itemView = ItemView::New(factory);
192 DALI_TEST_CHECK(itemView);
196 DALI_TEST_CHECK(copy);
197 DALI_TEST_EQUALS(itemView, copy, TEST_LOCATION);
202 int UtcDaliItemViewMoveConstructor(void)
204 ToolkitTestApplication application;
206 TestItemFactory factory;
207 ItemView itemView = ItemView::New(factory);
208 DALI_TEST_EQUALS(1, itemView.GetBaseObject().ReferenceCount(), TEST_LOCATION);
209 itemView.SetProperty(Actor::Property::SENSITIVE, false);
210 DALI_TEST_CHECK(false == itemView.GetProperty<bool>(Actor::Property::SENSITIVE));
212 ItemView moved = std::move(itemView);
213 DALI_TEST_CHECK(moved);
214 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
215 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
216 DALI_TEST_CHECK(!itemView);
221 int UtcDaliItemViewMoveAssignment(void)
223 ToolkitTestApplication application;
225 TestItemFactory factory;
226 ItemView itemView = ItemView::New(factory);
227 DALI_TEST_EQUALS(1, itemView.GetBaseObject().ReferenceCount(), TEST_LOCATION);
228 itemView.SetProperty(Actor::Property::SENSITIVE, false);
229 DALI_TEST_CHECK(false == itemView.GetProperty<bool>(Actor::Property::SENSITIVE));
232 moved = std::move(itemView);
233 DALI_TEST_CHECK(moved);
234 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
235 DALI_TEST_CHECK(false == moved.GetProperty<bool>(Actor::Property::SENSITIVE));
236 DALI_TEST_CHECK(!itemView);
241 int UtcDaliItemViewDownCast(void)
243 ToolkitTestApplication application;
245 // Create the ItemView actor
246 TestItemFactory factory;
247 const ItemView itemViewConst = ItemView::New(factory);
248 ItemView itemView(itemViewConst);
250 BaseHandle handle(itemView);
252 ItemView newItemView = ItemView::DownCast(handle);
253 DALI_TEST_CHECK(itemView);
254 DALI_TEST_CHECK(newItemView == itemView);
258 int UtcDaliItemViewAddAndGetLayout(void)
260 ToolkitTestApplication application;
262 // Create the ItemView actor
263 TestItemFactory factory;
264 ItemView view = ItemView::New(factory);
266 // Create a grid layout and add it to ItemView
267 ItemLayoutPtr gridLayout = DefaultItemLayout::New(DefaultItemLayout::GRID);
268 view.AddLayout(*gridLayout);
270 // As we have added one layout, check the number of layout is now 1
271 DALI_TEST_CHECK(view.GetLayoutCount() == 1);
273 // Create a depth layout and add it to ItemView
274 ItemLayoutPtr depthLayout = DefaultItemLayout::New(DefaultItemLayout::DEPTH);
275 view.AddLayout(*depthLayout);
277 // As we have added another layout, check the number of layout is now 2
278 DALI_TEST_CHECK(view.GetLayoutCount() == 2);
280 // Create a spiral layout and add it to ItemView
281 ItemLayoutPtr spiralLayout = DefaultItemLayout::New(DefaultItemLayout::SPIRAL);
282 view.AddLayout(*spiralLayout);
284 // As we have added another layout, check the number of layout is now 3
285 DALI_TEST_CHECK(view.GetLayoutCount() == 3);
287 // Check we are getting the correct layout from ItemView
288 DALI_TEST_CHECK(view.GetLayout(0) == gridLayout);
289 DALI_TEST_CHECK(view.GetLayout(1) == depthLayout);
290 DALI_TEST_CHECK(view.GetLayout(2) == spiralLayout);
294 int UtcDaliItemViewAddAndRemoveLayout(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 // As we have added one layout, check the number of layout is now 1
307 DALI_TEST_CHECK(view.GetLayoutCount() == 1);
309 // Create a depth layout and add it to ItemView
310 ItemLayoutPtr depthLayout = DefaultItemLayout::New(DefaultItemLayout::DEPTH);
311 view.AddLayout(*depthLayout);
313 // As we have added another layout, check the number of layout is now 2
314 DALI_TEST_CHECK(view.GetLayoutCount() == 2);
316 // Check we are getting the correct layout from ItemView
317 DALI_TEST_CHECK(view.GetLayout(0) == gridLayout);
318 DALI_TEST_CHECK(view.GetLayout(1) == depthLayout);
320 // Remove the grid layout
321 view.RemoveLayout(0);
323 // As we have removed the grid layout, check the number of layout is now 1
324 DALI_TEST_CHECK(view.GetLayoutCount() == 1);
326 // Check we are getting the correct layout from ItemView
327 DALI_TEST_CHECK(view.GetLayout(0) == depthLayout);
329 // Remove the depth layout
330 view.RemoveLayout(0);
332 // As we also removed the depth layout, check the number of layout is now 0
333 DALI_TEST_CHECK(view.GetLayoutCount() == 0);
337 int UtcDaliItemViewActivateLayoutAndGetActiveLayout(void)
339 ToolkitTestApplication application;
341 // Create the ItemView actor
342 TestItemFactory factory;
343 ItemView view = ItemView::New(factory);
345 // Create a grid layout and add it to ItemView
346 ItemLayoutPtr gridLayout = DefaultItemLayout::New(DefaultItemLayout::GRID);
347 view.AddLayout(*gridLayout);
349 // Create a depth layout and add it to ItemView
350 ItemLayoutPtr depthLayout = DefaultItemLayout::New(DefaultItemLayout::DEPTH);
351 view.AddLayout(*depthLayout);
353 // Create a spiral layout and add it to ItemView
354 ItemLayoutPtr spiralLayout = DefaultItemLayout::New(DefaultItemLayout::SPIRAL);
355 view.AddLayout(*spiralLayout);
357 // As we have added three layouts, check the number of layout is now 3
358 DALI_TEST_CHECK(view.GetLayoutCount() == 3);
360 // Check there is no active layout at the moment
361 DALI_TEST_CHECK(!view.GetActiveLayout());
363 // Activate the depth layout
364 Vector3 stageSize(application.GetScene().GetSize());
365 view.ActivateLayout(1, stageSize, 0.5f);
367 // Check the current active layout is the depth layout
368 DALI_TEST_CHECK(view.GetActiveLayout() == depthLayout);
370 // Activate the grid layout
371 view.ActivateLayout(0, stageSize, 0.5f);
373 // Check the current active layout is the grid layout
374 DALI_TEST_CHECK(view.GetActiveLayout() == gridLayout);
376 // Activate the spiral layout
377 view.ActivateLayout(2, stageSize, 0.5f);
379 // Check the current active layout is the spiral layout
380 DALI_TEST_CHECK(view.GetActiveLayout() == spiralLayout);
384 int UtcDaliItemViewDeactivateCurrentLayout(void)
386 ToolkitTestApplication application;
388 // Create the ItemView actor
389 TestItemFactory factory;
390 ItemView view = ItemView::New(factory);
392 // Create a grid layout and add it to ItemView
393 ItemLayoutPtr gridLayout = DefaultItemLayout::New(DefaultItemLayout::GRID);
394 gridLayout->SetOrientation(ControlOrientation::Down);
395 view.AddLayout(*gridLayout);
397 // Check there is no active layout at the moment
398 DALI_TEST_CHECK(!view.GetActiveLayout());
400 // Activate the grid layout
401 Vector3 stageSize(application.GetScene().GetSize());
402 view.ActivateLayout(0, stageSize, 0.5f);
404 // Check the current active layout is the grid layout
405 DALI_TEST_CHECK(view.GetActiveLayout() == gridLayout);
407 // Deactivate the current layout
408 view.DeactivateCurrentLayout();
410 // Check there is no active layout at the moment
411 DALI_TEST_CHECK(!view.GetActiveLayout());
415 int UtcDaliItemViewGetItemAndGetItemId(void)
417 ToolkitTestApplication application;
419 // Create the ItemView actor
420 TestItemFactory factory;
421 ItemView view = ItemView::New(factory);
423 // Create a grid layout and add it to ItemView
424 ItemLayoutPtr gridLayout = DefaultItemLayout::New(DefaultItemLayout::GRID);
425 gridLayout->SetOrientation(ControlOrientation::Left);
426 view.AddLayout(*gridLayout);
428 // Activate the grid layout so that the items will be created and added to ItemView
429 Vector3 stageSize(application.GetScene().GetSize());
430 view.ActivateLayout(0, stageSize, 0.5f);
432 // Get the item given the item ID
433 Actor itemActor = view.GetItem(2);
435 // Check we are getting the correct Item ID given the specified actor
436 DALI_TEST_CHECK(view.GetItemId(itemActor) == 2);
440 int UtcDaliItemViewRemoveItem(void)
442 ToolkitTestApplication application;
444 // Create the ItemView actor
445 TestItemFactory factory;
446 ItemView view = ItemView::New(factory);
448 // Create a grid layout and add it to ItemView
449 ItemLayoutPtr gridLayout = DefaultItemLayout::New(DefaultItemLayout::GRID);
450 gridLayout->SetOrientation(ControlOrientation::Right);
451 view.AddLayout(*gridLayout);
453 // Activate the grid layout so that the items will be created and added to ItemView
454 Vector3 stageSize(application.GetScene().GetSize());
455 view.ActivateLayout(0, stageSize, 0.5f);
457 // Get the item given the item ID 2 and 3
458 Actor oldItemActorID2 = view.GetItem(2);
459 Actor oldItemActorID3 = view.GetItem(3);
461 // Remove the item with ID 2
462 view.RemoveItem(2, 0.0f);
464 // Get the new item given the item ID 2 and 3
465 Actor newItemActorID2 = view.GetItem(2);
466 Actor newItemActorID3 = view.GetItem(3);
468 // Check the original item with item ID 2 was deleted and now item ID 2 represents the original item with ID 3
469 DALI_TEST_CHECK(view.GetItemId(newItemActorID2) == 2);
470 DALI_TEST_CHECK(oldItemActorID2 != newItemActorID2);
471 DALI_TEST_CHECK(newItemActorID2 == oldItemActorID3);
473 // scroll to the end of item view
474 view.ScrollToItem(TOTAL_ITEM_NUMBER - 1, 0.00f);
476 application.SendNotification();
477 application.Render(0);
479 // Refresh the item view
482 Actor itemActorID390 = view.GetItem(390);
483 DALI_TEST_CHECK(view.GetItemId(itemActorID390) == 390);
485 // Remove the item with ID 2 (which is now before the current item range)
486 view.RemoveItem(2, 0.0f);
488 // Check the original item with item ID 2 was deleted and now item ID 389 represents the original item with ID 390
489 DALI_TEST_CHECK(view.GetItemId(itemActorID390) == 389);
490 DALI_TEST_CHECK(view.GetItem(389) == itemActorID390);
495 int UtcDaliItemViewGetCurrentLayoutPosition(void)
497 ToolkitTestApplication application;
499 // Create the ItemView actor
500 TestItemFactory factory;
501 ItemView view = ItemView::New(factory);
503 // Create a depth layout and add it to ItemView
504 ItemLayoutPtr depthLayout = DefaultItemLayout::New(DefaultItemLayout::DEPTH);
505 depthLayout->SetOrientation(ControlOrientation::Up);
506 view.AddLayout(*depthLayout);
508 // Activate the grid layout so that the items will be created and added to ItemView
509 Vector3 stageSize(application.GetScene().GetSize());
510 view.ActivateLayout(0, stageSize, 0.0f);
512 // Check the current layout position for the 10th items is 9.0f
513 DALI_TEST_EQUALS(view.GetCurrentLayoutPosition(9), 9.0f, TEST_LOCATION);
517 int UtcDaliItemViewSetAndGetMinimumSwipeSpeed(void)
519 ToolkitTestApplication application;
521 // Create the ItemView actor
522 TestItemFactory factory;
523 ItemView view = ItemView::New(factory);
525 // Set the minimum swipe speed to be 1.5f
526 view.SetMinimumSwipeSpeed(1.5f);
528 // Check the minimum swipe speed is 1.5f
529 DALI_TEST_EQUALS(view.GetMinimumSwipeSpeed(), 1.5f, TEST_LOCATION);
533 int UtcDaliItemViewSetAndGetMinimumSwipeDistance(void)
535 ToolkitTestApplication application;
537 // Create the ItemView actor
538 TestItemFactory factory;
539 ItemView view = ItemView::New(factory);
541 // Set the minimum swipe distance to be 2.5f
542 view.SetMinimumSwipeDistance(2.5f);
544 // Check the minimum swipe distance is 2.5f
545 DALI_TEST_EQUALS(view.GetMinimumSwipeDistance(), 2.5f, TEST_LOCATION);
549 int UtcDaliItemViewSetAndGetAnchoring(void)
551 ToolkitTestApplication application;
553 // Create the ItemView actor
554 TestItemFactory factory;
555 ItemView view = ItemView::New(factory);
557 // Disable the anchor animation
558 view.SetAnchoring(false);
560 // Check the anchor animation is disabled
561 DALI_TEST_CHECK(view.GetAnchoring() == false);
565 int UtcDaliItemViewSetAndGetAnchoringDuration(void)
567 ToolkitTestApplication application;
569 // Create the ItemView actor
570 TestItemFactory factory;
571 ItemView view = ItemView::New(factory);
573 // Set the duration of anchor animation to be 1.5f
574 view.SetAnchoringDuration(1.5f);
576 // Check the duration of anchor animation is 1.5f
577 DALI_TEST_EQUALS(view.GetAnchoringDuration(), 1.5f, TEST_LOCATION);
581 int UtcDaliItemViewSetAndGetRefreshInterval(void)
583 ToolkitTestApplication application;
585 // Create the ItemView actor
586 TestItemFactory factory;
587 ItemView view = ItemView::New(factory);
589 // Set the interval between refreshes to be 20
590 view.SetRefreshInterval(20);
594 // Check the interval between refreshes is 20
595 DALI_TEST_CHECK(view.GetRefreshInterval() == 20);
599 int UtcDaliItemViewScrollToItem(void)
601 ToolkitTestApplication application;
603 // Create the ItemView actor
604 TestItemFactory factory;
605 ItemView view = ItemView::New(factory);
606 Vector3 vec(480.0f, 800.0f, 0.0f);
607 ItemLayoutPtr layout = DefaultItemLayout::New(DefaultItemLayout::DEPTH);
609 view.SetProperty(Dali::Actor::Property::NAME, "view actor");
610 view.AddLayout(*layout);
611 view.SetProperty(Actor::Property::SIZE, vec);
613 application.GetScene().Add(view);
614 layout->SetOrientation(ControlOrientation::Down);
615 view.ActivateLayout(0, vec, 0.0f);
617 application.SendNotification();
618 application.Render(0);
621 for(int i = 0; i < 10; ++i)
623 application.Render(16); // 60hz frames
626 // Confirm: we have actors in the view.
627 std::vector<unsigned int> indices;
628 for(unsigned int i = 0; i < 10; i++)
630 Actor testActor = view.GetItem(i);
633 indices.push_back(i);
641 const unsigned int firstTargetIndex = indices[indices.size() - 1];
642 // scroll to last item
643 view.ScrollToItem(firstTargetIndex, 0.00f);
644 for(int i = 0; i < 10; ++i)
646 application.Render(16); // 60hz frames
649 std::size_t moveCount = 0;
650 for(std::size_t i = 0; i < indices.size(); i++)
652 float layoutPosBefore = view.GetCurrentLayoutPosition(i);
653 view.ScrollToItem(indices[i], 0.0f);
654 float layoutPosAfter = view.GetCurrentLayoutPosition(i);
656 if(fabs(layoutPosBefore - layoutPosAfter) <= FLT_EPSILON)
662 DALI_TEST_CHECK((moveCount == indices.size()));
667 tet_result(TET_FAIL);
670 application.GetScene().Remove(view);
674 int UtcDaliItemViewSetAndGetWheelScrollDistanceStep(void)
676 ToolkitTestApplication application;
678 // Create the ItemView actor
679 TestItemFactory factory;
680 ItemView view = ItemView::New(factory);
682 // Set the scroll distance step for the wheel event to be 100.0f
683 view.SetWheelScrollDistanceStep(100.0f);
685 // Check the scroll distance step is 100.0f
686 DALI_TEST_EQUALS(view.GetWheelScrollDistanceStep(), 100.0f, TEST_LOCATION);
690 int UtcDaliItemViewInsertItemP(void)
692 ToolkitTestApplication application;
694 // Create the ItemView actor
695 TestItemFactory factory;
696 ItemView view = ItemView::New(factory);
698 // Create a grid layout and add it to ItemView
699 ItemLayoutPtr gridLayout = DefaultItemLayout::New(DefaultItemLayout::GRID);
700 gridLayout->SetOrientation(ControlOrientation::Left);
701 view.AddLayout(*gridLayout);
703 // Activate the grid layout so that the items will be created and added to ItemView
704 Vector3 stageSize(application.GetScene().GetSize());
705 view.ActivateLayout(0, stageSize, 0.0f);
707 // Get the specified item where new item to be inserted before that
708 Actor itemActor = view.GetItem(2);
710 ItemId id = view.GetItemId(itemActor);
712 // Check we are getting the correct Item ID given the specified actor
713 DALI_TEST_CHECK(view.GetItemId(itemActor) == 2);
715 Actor newActor = Actor::New();
717 view.InsertItem(Item(id, newActor), 0.0f);
719 DALI_TEST_CHECK(view.GetItem(2) == newActor);
721 DALI_TEST_CHECK(view.GetItemId(itemActor) == 3);
722 DALI_TEST_CHECK(view.GetItem(3) == itemActor);
724 // scroll to the end of item view
725 view.ScrollToItem(TOTAL_ITEM_NUMBER - 1, 0.00f);
727 application.SendNotification();
728 application.Render(0);
730 // Refresh the item view
733 Actor itemActorID390 = view.GetItem(390);
734 DALI_TEST_CHECK(view.GetItemId(itemActorID390) == 390);
736 // Insert the item with ID 2 (which is now before the current item range)
737 Actor anotherNewActor = Actor::New();
738 view.InsertItem(Item(id, anotherNewActor), 0.0f);
740 // Check that item ID 391 now represents the original item with ID 390
741 DALI_TEST_CHECK(view.GetItemId(itemActorID390) == 391);
742 DALI_TEST_CHECK(view.GetItem(391) == itemActorID390);
747 int UtcDaliItemViewInsertItemsP(void)
749 ToolkitTestApplication application;
751 // Create the ItemView actor
752 TestItemFactory factory;
753 ItemView view = ItemView::New(factory);
755 // Create a depth layout and add it to ItemView
756 ItemLayoutPtr depthLayout = DefaultItemLayout::New(DefaultItemLayout::DEPTH);
757 depthLayout->SetOrientation(ControlOrientation::Right);
758 view.AddLayout(*depthLayout);
760 // Activate the grid layout so that the items will be created and added to ItemView
761 Vector3 stageSize(application.GetScene().GetSize());
762 view.ActivateLayout(0, stageSize, 0.5f);
764 unsigned int itemCount = view.GetChildCount();
766 // Get the specified item where new items to be inserted before that
767 Actor itemActor = view.GetItem(1);
769 // Check we are getting the correct Item ID given the specified item
770 DALI_TEST_CHECK(view.GetItemId(itemActor) == 1);
772 ItemContainer insertList;
774 for(unsigned int i = 1u; i < 11; ++i)
776 Actor child = view.GetChildAt(i);
777 Actor newActor = Actor::New();
778 newActor.SetProperty(Dali::Actor::Property::NAME, "Inserted");
779 insertList.push_back(Item(view.GetItemId(child), newActor));
782 if(!insertList.empty())
784 view.InsertItems(insertList, 0.5f);
787 DALI_TEST_CHECK(view.GetChildCount() == itemCount + 10);
789 // Check that new items are inserted in the correct positions
790 DALI_TEST_CHECK(view.GetItemId(itemActor) == 11);
791 DALI_TEST_CHECK(view.GetItem(11) == itemActor);
793 ItemIdContainer removeList;
795 for(unsigned int i = 0u; i < view.GetChildCount(); ++i)
797 Actor child = view.GetChildAt(i);
799 if(child.GetProperty<std::string>(Dali::Actor::Property::NAME) == "Inserted")
801 removeList.push_back(view.GetItemId(child));
805 if(!removeList.empty())
807 view.RemoveItems(removeList, 0.5f);
810 DALI_TEST_CHECK(view.GetChildCount() == itemCount);
812 // Check that new items are removed correctly so that we are getting the correct Item ID given the specified item
813 DALI_TEST_CHECK(view.GetItemId(itemActor) == 1);
814 DALI_TEST_CHECK(view.GetItem(1) == itemActor);
819 int UtcDaliItemViewReplaceItemP(void)
821 ToolkitTestApplication application;
823 // Create the ItemView actor
824 TestItemFactory factory;
825 ItemView view = ItemView::New(factory);
827 // Create a spiral layout and add it to ItemView
828 ItemLayoutPtr spiralLayout = DefaultItemLayout::New(DefaultItemLayout::SPIRAL);
829 view.AddLayout(*spiralLayout);
831 // Activate the grid layout so that the items will be created and added to ItemView
832 Vector3 stageSize(application.GetScene().GetSize());
833 view.ActivateLayout(0, stageSize, 0.5f);
835 Actor newActor = Actor::New();
837 view.ReplaceItem(Item(5, newActor), 0.5f);
839 DALI_TEST_CHECK(view.GetItem(5) == newActor);
844 int UtcDaliItemViewReplaceItemsP(void)
846 ToolkitTestApplication application;
848 // Create the ItemView actor
849 TestItemFactory factory;
850 ItemView view = ItemView::New(factory);
852 // Create a spiral layout and add it to ItemView
853 ItemLayoutPtr spiralLayout = DefaultItemLayout::New(DefaultItemLayout::SPIRAL);
854 spiralLayout->SetOrientation(ControlOrientation::Down);
855 view.AddLayout(*spiralLayout);
857 // Activate the grid layout so that the items will be created and added to ItemView
858 Vector3 stageSize(application.GetScene().GetSize());
859 view.ActivateLayout(0, stageSize, 0.5f);
861 ItemContainer replaceList;
863 for(unsigned int i = 0u; i < 10; ++i)
865 Actor child = view.GetItem(i);
866 Actor newActor = Actor::New();
867 newActor.SetProperty(Dali::Actor::Property::NAME, "Replaced");
869 replaceList.push_back(Item(i, newActor));
872 if(!replaceList.empty())
874 view.ReplaceItems(replaceList, 0.5f);
877 DALI_TEST_CHECK(view.GetItem(0).GetProperty<std::string>(Dali::Actor::Property::NAME) == "Replaced");
878 DALI_TEST_CHECK(view.GetItem(8).GetProperty<std::string>(Dali::Actor::Property::NAME) == "Replaced");
882 int UtcDaliItemViewGetItemsRangeP(void)
884 ToolkitTestApplication application;
886 // Create the ItemView actor
887 TestItemFactory factory;
888 ItemView view = ItemView::New(factory);
890 // Create a spiral layout and add it to ItemView
891 ItemLayoutPtr spiralLayout = DefaultItemLayout::New(DefaultItemLayout::SPIRAL);
892 spiralLayout->SetOrientation(ControlOrientation::Left);
893 view.AddLayout(*spiralLayout);
895 // Activate the grid layout so that the items will be created and added to ItemView
896 Vector3 stageSize(application.GetScene().GetSize());
897 view.ActivateLayout(0, stageSize, 0.5f);
899 ItemRange itemRange(0, 0);
901 view.GetItemsRange(itemRange);
903 DALI_TEST_CHECK(itemRange.Within(0));
907 int UtcDaliItemViewSetItemsAnchorPointP(void)
909 ToolkitTestApplication application;
911 // Create the ItemView actor
912 TestItemFactory factory;
913 ItemView view = ItemView::New(factory);
915 // Create a spiral layout and add it to ItemView
916 ItemLayoutPtr spiralLayout = DefaultItemLayout::New(DefaultItemLayout::SPIRAL);
917 spiralLayout->SetOrientation(ControlOrientation::Right);
918 view.AddLayout(*spiralLayout);
920 // Activate the grid layout so that the items will be created and added to ItemView
921 Vector3 stageSize(application.GetScene().GetSize());
922 view.ActivateLayout(0, stageSize, 0.5f);
924 Vector3 anchorPoint(10.0f, 10.0f, 0.0f);
926 view.SetItemsAnchorPoint(anchorPoint);
928 DALI_TEST_CHECK(view.GetItemsAnchorPoint() == anchorPoint);
929 DALI_TEST_CHECK(view.GetItem(0).GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT) == anchorPoint);
933 int UtcDaliItemViewSetItemsParentOriginP(void)
935 ToolkitTestApplication application;
937 // Create the ItemView actor
938 TestItemFactory factory;
939 ItemView view = ItemView::New(factory);
941 // Create a grid layout and add it to ItemView
942 ItemLayoutPtr gridLayout = DefaultItemLayout::New(DefaultItemLayout::GRID);
943 view.AddLayout(*gridLayout);
945 // Activate the grid layout so that the items will be created and added to ItemView
946 Vector3 stageSize(application.GetScene().GetSize());
947 view.ActivateLayout(0, stageSize, 0.5f);
949 Vector3 parentOrigin(10.0f, 10.0f, 0.0f);
951 view.SetItemsParentOrigin(parentOrigin);
953 DALI_TEST_CHECK(view.GetItemsParentOrigin() == parentOrigin);
954 DALI_TEST_CHECK(view.GetItem(0).GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN) == parentOrigin);
958 int UtcDaliItemFactoryGetExtention(void)
960 ToolkitTestApplication application;
961 TestItemFactory factory;
962 DALI_TEST_CHECK(factory.GetExtension() == NULL);
966 int UtcDaliItemViewLayoutActivatedSignalP(void)
968 ToolkitTestApplication application;
970 // Create the ItemView actor
971 TestItemFactory factory;
972 ItemView view = ItemView::New(factory);
974 // Create a grid layout and add it to ItemView
975 ItemLayoutPtr gridLayout = DefaultItemLayout::New(DefaultItemLayout::GRID);
976 view.AddLayout(*gridLayout);
978 application.GetScene().Add(view);
980 // Connect the layout activated signal
981 view.LayoutActivatedSignal().Connect(&OnLayoutActivated);
983 gOnLayoutActivatedCalled = false;
986 application.SendNotification();
987 application.Render();
989 // Activate the grid layout so that the items will be created and added to ItemView
990 Vector3 stageSize(application.GetScene().GetSize());
991 view.ActivateLayout(0, stageSize, 0.1f);
993 // Wait for 0.1 second
994 Wait(application, 100);
996 DALI_TEST_EQUALS(gOnLayoutActivatedCalled, true, TEST_LOCATION);
1001 int UtcDaliItemViewSetGetProperty(void)
1003 ToolkitTestApplication application;
1005 // Create the ItemView actor
1006 TestItemFactory factory;
1007 ItemView view = ItemView::New(factory);
1008 DALI_TEST_CHECK(view);
1010 // Event side properties
1012 // Test "minimumSwipeSpeed" property
1013 DALI_TEST_CHECK(view.GetPropertyIndex("minimumSwipeSpeed") == ItemView::Property::MINIMUM_SWIPE_SPEED);
1014 DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::MINIMUM_SWIPE_SPEED).Get<float>(), view.GetMinimumSwipeSpeed(), TEST_LOCATION);
1015 view.SetProperty(ItemView::Property::MINIMUM_SWIPE_SPEED, 2.5f);
1016 DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::MINIMUM_SWIPE_SPEED).Get<float>(), 2.5f, TEST_LOCATION);
1018 // Test "minimumSwipeDistance" property
1019 DALI_TEST_CHECK(view.GetPropertyIndex("minimumSwipeDistance") == ItemView::Property::MINIMUM_SWIPE_DISTANCE);
1020 DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::MINIMUM_SWIPE_DISTANCE).Get<float>(), view.GetMinimumSwipeDistance(), TEST_LOCATION);
1021 view.SetProperty(ItemView::Property::MINIMUM_SWIPE_DISTANCE, 8.725f);
1022 DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::MINIMUM_SWIPE_DISTANCE).Get<float>(), 8.725f, TEST_LOCATION);
1024 // Test "wheelScrollDistanceStep" property
1025 DALI_TEST_CHECK(view.GetPropertyIndex("wheelScrollDistanceStep") == ItemView::Property::WHEEL_SCROLL_DISTANCE_STEP);
1026 DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::WHEEL_SCROLL_DISTANCE_STEP).Get<float>(), view.GetWheelScrollDistanceStep(), TEST_LOCATION);
1027 view.SetProperty(ItemView::Property::WHEEL_SCROLL_DISTANCE_STEP, 5.0f);
1028 DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::WHEEL_SCROLL_DISTANCE_STEP).Get<float>(), 5.0f, TEST_LOCATION);
1030 // Test "snapToItemEnabled" property
1031 DALI_TEST_CHECK(view.GetPropertyIndex("snapToItemEnabled") == ItemView::Property::SNAP_TO_ITEM_ENABLED);
1032 DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::SNAP_TO_ITEM_ENABLED).Get<bool>(), view.GetAnchoring(), TEST_LOCATION);
1033 view.SetProperty(ItemView::Property::SNAP_TO_ITEM_ENABLED, true);
1034 DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::SNAP_TO_ITEM_ENABLED).Get<bool>(), true, TEST_LOCATION);
1036 // Test "refreshInterval" property
1037 DALI_TEST_CHECK(view.GetPropertyIndex("refreshInterval") == ItemView::Property::REFRESH_INTERVAL);
1038 DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::REFRESH_INTERVAL).Get<float>(), view.GetRefreshInterval(), TEST_LOCATION);
1039 view.SetProperty(ItemView::Property::REFRESH_INTERVAL, 11.0f);
1040 DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::REFRESH_INTERVAL).Get<float>(), 11.0f, TEST_LOCATION);
1042 // Test "layout" property
1043 DALI_TEST_CHECK(view.GetPropertyIndex("layout") == ItemView::Property::LAYOUT);
1044 Property::Map gridLayoutProperty;
1045 gridLayoutProperty.Insert(DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::GRID));
1046 gridLayoutProperty.Insert(DefaultItemLayoutProperty::ITEM_SIZE, Dali::Property::Value(Vector3(200, 200, 50)));
1047 gridLayoutProperty.Insert(DefaultItemLayoutProperty::GRID_ROW_SPACING, Dali::Property::Value(50.0f));
1048 gridLayoutProperty.Insert(DefaultItemLayoutProperty::GRID_COLUMN_NUMBER, Dali::Property::Value(4));
1050 Property::Map depthLayoutProperty;
1051 depthLayoutProperty.Insert(DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::DEPTH));
1052 depthLayoutProperty.Insert(DefaultItemLayoutProperty::DEPTH_COLUMN_NUMBER, Dali::Property::Value(3));
1053 depthLayoutProperty.Insert(DefaultItemLayoutProperty::DEPTH_ROW_NUMBER, Dali::Property::Value(26.0f));
1055 Property::Map spiralLayoutPrperty;
1056 spiralLayoutPrperty.Insert(DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::SPIRAL));
1057 spiralLayoutPrperty.Insert(DefaultItemLayoutProperty::SPIRAL_ITEM_SPACING, Dali::Property::Value((Math::PI * 2.0f) / 9.5f));
1058 spiralLayoutPrperty.Insert(DefaultItemLayoutProperty::SPIRAL_TOP_ITEM_ALIGNMENT, Dali::Property::Value(-0.125f));
1060 Property::Map listLayoutPrperty;
1061 listLayoutPrperty.Insert(DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::LIST));
1062 listLayoutPrperty.Insert(DefaultItemLayoutProperty::ITEM_SIZE, Dali::Property::Value(Vector3(100, 100, 50)));
1064 Property::Array layoutArray;
1065 layoutArray.PushBack(gridLayoutProperty);
1066 layoutArray.PushBack(depthLayoutProperty);
1067 layoutArray.PushBack(spiralLayoutPrperty);
1068 layoutArray.PushBack(listLayoutPrperty);
1070 view.SetProperty(ItemView::Property::LAYOUT, layoutArray);
1072 Property::Array getLayoutArray;
1073 DALI_TEST_CHECK(view.GetProperty(ItemView::Property::LAYOUT).Get(getLayoutArray));
1075 //Check that the result is the same as
1076 DALI_TEST_EQUALS(layoutArray.Count(), getLayoutArray.Count(), TEST_LOCATION);
1077 Property::Map firstLayout = *((getLayoutArray.GetElementAt(0)).GetMap());
1079 for(unsigned int mapIdx = 0, mapCount = firstLayout.Count(); mapIdx < mapCount; ++mapIdx)
1081 KeyValuePair propertyPair(firstLayout.GetKeyValue(mapIdx));
1082 if(propertyPair.first == DefaultItemLayoutProperty::TYPE)
1084 int layoutType = propertyPair.second.Get<int>();
1085 DALI_TEST_EQUALS(layoutType, (int)DefaultItemLayout::GRID, TEST_LOCATION);
1087 else if(propertyPair.first == DefaultItemLayoutProperty::ITEM_SIZE)
1089 Vector3 size = propertyPair.second.Get<Vector3>();
1090 DALI_TEST_EQUALS(size, Vector3(200, 200, 50), TEST_LOCATION);
1092 else if(propertyPair.first == DefaultItemLayoutProperty::GRID_ROW_SPACING)
1094 float spacing = propertyPair.second.Get<float>();
1095 DALI_TEST_EQUALS(spacing, 50.0f, TEST_LOCATION);
1097 else if(propertyPair.first == DefaultItemLayoutProperty::GRID_COLUMN_NUMBER)
1099 int number = propertyPair.second.Get<int>();
1100 DALI_TEST_EQUALS(number, 4, TEST_LOCATION);
1103 view.SetProperty(ItemView::Property::LAYOUT, layoutArray);
1105 // Test "overshootEnabled" property
1106 DALI_TEST_CHECK(view.GetPropertyIndex("overshootEnabled") == Scrollable::Property::OVERSHOOT_ENABLED);
1107 DALI_TEST_EQUALS(view.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), view.IsOvershootEnabled(), TEST_LOCATION);
1108 view.SetProperty(Scrollable::Property::OVERSHOOT_ENABLED, false);
1109 DALI_TEST_EQUALS(view.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), false, TEST_LOCATION);
1111 // Test "overshootSize" property
1112 DALI_TEST_CHECK(view.GetPropertyIndex("overshootSize") == Scrollable::Property::OVERSHOOT_SIZE);
1113 Vector2 overshootSize = Vector2(100.0f, 100.0f);
1114 view.SetProperty(Scrollable::Property::OVERSHOOT_SIZE, overshootSize);
1115 DALI_TEST_EQUALS(view.GetProperty(Scrollable::Property::OVERSHOOT_SIZE).Get<Vector2>(), overshootSize, TEST_LOCATION);
1117 // Animatable properties
1119 // Test "layoutPosition" property
1120 DALI_TEST_CHECK(view.GetPropertyIndex("layoutPosition") == ItemView::Property::LAYOUT_POSITION);
1121 view.SetProperty(ItemView::Property::LAYOUT_POSITION, 20.5f);
1123 DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::LAYOUT_POSITION).Get<float>(), 20.5f, TEST_LOCATION);
1125 // Test "scrollSpeed" property
1126 DALI_TEST_CHECK(view.GetPropertyIndex("scrollSpeed") == ItemView::Property::SCROLL_SPEED);
1127 view.SetProperty(ItemView::Property::SCROLL_SPEED, 3.35f);
1129 DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::SCROLL_SPEED).Get<float>(), 3.35f, TEST_LOCATION);
1131 // Test "overshoot" property
1132 DALI_TEST_CHECK(view.GetPropertyIndex("overshoot") == ItemView::Property::OVERSHOOT);
1133 view.SetProperty(ItemView::Property::OVERSHOOT, 0.15f);
1135 DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::OVERSHOOT).Get<float>(), 0.15f, TEST_LOCATION);
1137 // Test "scrollDirection" property
1138 DALI_TEST_CHECK(view.GetPropertyIndex("scrollDirection") == ItemView::Property::SCROLL_DIRECTION);
1139 view.SetProperty(ItemView::Property::SCROLL_DIRECTION, Vector2(0.85f, 0.5f));
1141 DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::SCROLL_DIRECTION).Get<Vector2>(), Vector2(0.85f, 0.5f), TEST_LOCATION);
1143 // Test "layoutOrientation" property
1144 DALI_TEST_CHECK(view.GetPropertyIndex("layoutOrientation") == ItemView::Property::LAYOUT_ORIENTATION);
1145 view.SetProperty(ItemView::Property::LAYOUT_ORIENTATION, 2);
1147 DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::LAYOUT_ORIENTATION).Get<int>(), 2, TEST_LOCATION);
1149 // Test "scrollContentSize" property
1150 DALI_TEST_CHECK(view.GetPropertyIndex("scrollContentSize") == ItemView::Property::SCROLL_CONTENT_SIZE);
1151 view.SetProperty(ItemView::Property::SCROLL_CONTENT_SIZE, 250.0f);
1153 DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::SCROLL_CONTENT_SIZE).Get<float>(), 250.0f, TEST_LOCATION);
1158 int UtcDaliItemViewOvershootVertical(void)
1160 ToolkitTestApplication application;
1161 Dali::Integration::Scene stage = application.GetScene();
1163 // Create the ItemView actor
1164 TestItemFactory factory;
1165 ItemView view = ItemView::New(factory);
1167 // Create a grid layout and add it to ItemView
1168 ItemLayoutPtr gridLayout = DefaultItemLayout::New(DefaultItemLayout::GRID);
1169 view.AddLayout(*gridLayout);
1172 // Activate the grid layout so that the items will be created and added to ItemView
1173 Vector3 stageSize(stage.GetSize());
1174 view.ActivateLayout(0, stageSize, 0.5f);
1176 view.SetProperty(Scrollable::Property::OVERSHOOT_ENABLED, true);
1177 DALI_TEST_EQUALS(view.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), true, TEST_LOCATION);
1179 view.SetProperty(Scrollable::Property::OVERSHOOT_SIZE, Vector2(30, 30));
1183 // Do a pan starting from 100,100 and moving down
1184 Vector2 pos(100.0f, 100.0f);
1186 application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, pos, 100));
1187 application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, pos, 100));
1190 Wait(application, 100);
1192 for(int i = 0; i < 200; i++)
1194 application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, pos, 100));
1199 application.ProcessEvent(GenerateSingleTouch(PointState::UP, pos, 100));
1201 Wait(application, 100);
1203 // Do a pan starting from 100,100 and moving up
1204 pos = Vector2(100.0f, 300.0f);
1206 application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, pos, 100));
1207 application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, pos, 100));
1210 Wait(application, 100);
1212 for(int i = 0; i < 200; i++)
1214 application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, pos, 100));
1219 application.ProcessEvent(GenerateSingleTouch(PointState::UP, pos, 100));
1220 Wait(application, 100);
1224 int UtcDaliItemViewOvershootHorizontal(void)
1226 ToolkitTestApplication application;
1227 Dali::Integration::Scene stage = application.GetScene();
1229 // Create the ItemView actor
1230 TestItemFactory factory;
1231 ItemView view = ItemView::New(factory);
1233 // Create a grid layout and add it to ItemView
1234 ItemLayoutPtr gridLayout = DefaultItemLayout::New(DefaultItemLayout::SPIRAL);
1235 view.AddLayout(*gridLayout);
1238 // Activate the grid layout so that the items will be created and added to ItemView
1239 Vector3 stageSize(stage.GetSize());
1240 view.ActivateLayout(0, stageSize, 0.5f);
1242 view.SetProperty(Scrollable::Property::OVERSHOOT_ENABLED, true);
1243 DALI_TEST_EQUALS(view.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), true, TEST_LOCATION);
1245 view.SetProperty(Scrollable::Property::OVERSHOOT_SIZE, Vector2(30, 30));
1249 // Do a pan starting from 100,100 and moving left
1250 Vector2 pos(100.0f, 100.0f);
1251 application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, pos, 100));
1252 application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, pos, 100));
1254 Wait(application, 100);
1256 for(int i = 0; i < 200; i++)
1258 application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, pos, 100));
1263 application.ProcessEvent(GenerateSingleTouch(PointState::UP, pos, 100));
1264 Wait(application, 100);
1266 // Do a pan starting from 100,100 and moving right
1267 pos = Vector2(100.0f, 100.0f);
1268 application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, pos, 100));
1269 application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, pos, 100));
1271 Wait(application, 100);
1273 for(int i = 0; i < 200; i++)
1275 application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, pos, 100));
1280 application.ProcessEvent(GenerateSingleTouch(PointState::UP, pos, 100));
1281 Wait(application, 100);
1286 int UtcDaliItemEnableDisableRefresh(void)
1288 ToolkitTestApplication application;
1289 Dali::Integration::Scene stage = application.GetScene();
1291 // Create the ItemView actor
1292 TestItemFactory factory;
1293 ItemView view = ItemView::New(factory);
1295 // Create a grid layout and add it to ItemView
1296 ItemLayoutPtr gridLayout = DefaultItemLayout::New(DefaultItemLayout::GRID);
1297 view.AddLayout(*gridLayout);
1300 // Activate the grid layout so that the items will be created and added to ItemView
1301 Vector3 stageSize(stage.GetSize());
1302 view.ActivateLayout(0, stageSize, 0.5f);
1304 //Connect to signal scroll updated
1305 view.ScrollUpdatedSignal().Connect(&OnScrollUpdate);
1307 Property::Map attributes;
1308 view.DoAction("enableRefresh", attributes);
1309 gOnScrollUpdateCalled = true;
1310 view.SetProperty(ItemView::Property::LAYOUT_POSITION, 100.0f);
1311 application.SendNotification();
1312 application.Render(1000);
1313 DALI_TEST_EQUALS(gOnScrollUpdateCalled, true, TEST_LOCATION);
1315 view.DoAction("disableRefresh", attributes);
1316 gOnScrollUpdateCalled = false;
1317 view.SetProperty(ItemView::Property::LAYOUT_POSITION, 100.0f);
1318 application.SendNotification();
1319 application.Render(1000);
1321 DALI_TEST_EQUALS(gOnScrollUpdateCalled, false, TEST_LOCATION);
1326 int UtcDaliItemViewWheelEvent(void)
1328 ToolkitTestApplication application;
1329 Dali::Integration::Scene stage = application.GetScene();
1331 // Create the ItemView actor
1332 TestItemFactory factory;
1333 ItemView view = ItemView::New(factory);
1335 // Create a grid layout and add it to ItemView
1336 ItemLayoutPtr gridLayout = DefaultItemLayout::New(DefaultItemLayout::GRID);
1337 view.AddLayout(*gridLayout);
1340 // Activate the grid layout so that the items will be created and added to ItemView
1341 Vector3 stageSize(stage.GetSize());
1342 view.ActivateLayout(0, stageSize, 0.5f);
1344 //Connect to wheel event signal
1345 view.WheelEventSignal().Connect(&OnWheelEvent);
1347 DALI_TEST_CHECK(!gOnWheelEventCalled);
1349 // Render and notify
1350 application.Render();
1351 application.SendNotification();
1352 application.Render();
1353 application.SendNotification();
1355 // Perform a wheel event
1356 Dali::Integration::WheelEvent wheelEvent(Dali::Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, Vector2(10.0f, 10.0f), 1, 1000u);
1357 application.ProcessEvent(wheelEvent);
1358 DALI_TEST_CHECK(gOnWheelEventCalled);