2 * Copyright (c) 2020 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>
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;
45 const unsigned int TOTAL_ITEM_NUMBER = 400;
46 const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
48 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
50 static bool gObjectCreatedCallBackCalled;
51 static bool gOnLayoutActivatedCalled; ///< Whether the LayoutActivated signal was invoked.
52 static bool gOnScrollUpdateCalled;
53 static bool gOnWheelEventCalled; ///< Whether the WheelEventSignal signal was invoked.
55 static void TestCallback(BaseHandle handle)
57 gObjectCreatedCallBackCalled = true;
60 static void OnLayoutActivated()
62 gOnLayoutActivatedCalled = true;
65 static void OnScrollUpdate( const Vector2& position )
67 gOnScrollUpdateCalled = true;
70 static bool OnWheelEvent( Actor actor, const Dali::WheelEvent& wheelEvent )
72 gOnWheelEventCalled = true;
76 Integration::TouchEvent GenerateSingleTouch( PointState::Type state, const Vector2& screenPosition, uint32_t time )
78 Integration::TouchEvent touchEvent;
79 Integration::Point point;
80 point.SetState( state );
82 point.SetScreenPosition( screenPosition );
83 point.SetDeviceClass( Device::Class::TOUCH );
84 point.SetDeviceSubclass( Device::Subclass::NONE );
85 touchEvent.points.push_back( point );
86 touchEvent.time = time;
91 * Simulate time passed by.
93 * @note this will always process at least 1 frame (1/60 sec)
95 * @param application Test application instance
96 * @param duration Time to pass in milliseconds.
97 * @return The actual time passed in milliseconds
99 int Wait(ToolkitTestApplication& application, int duration = 0)
103 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
105 application.SendNotification();
106 application.Render(RENDER_FRAME_INTERVAL);
107 time += RENDER_FRAME_INTERVAL;
113 // Implementation of ItemFactory for providing actors to ItemView
114 class TestItemFactory : public ItemFactory
120 * @param application class, stored as reference
126 public: // From ItemFactory
129 * Query the number of items available from the factory.
130 * The maximum available item has an ID of GetNumberOfItems() - 1.
132 virtual unsigned int GetNumberOfItems()
134 return TOTAL_ITEM_NUMBER;
138 * Create an Actor to represent a visible item.
140 * @return the created actor.
142 virtual Actor NewItem(unsigned int itemId)
144 // Create a renderable actor for this item
145 return ImageView::New( TEST_IMAGE_FILE_NAME );
152 int UtcDaliItemViewNew(void)
154 ToolkitTestApplication application;
156 // Create the ItemView actor
157 TestItemFactory factory;
158 ItemView view = ItemView::New(factory);
160 DALI_TEST_CHECK(view);
162 //Additional check to ensure object is created by checking if it's registered
163 ObjectRegistry registry = application.GetCore().GetObjectRegistry();
164 DALI_TEST_CHECK( registry );
166 gObjectCreatedCallBackCalled = false;
167 registry.ObjectCreatedSignal().Connect(&TestCallback);
169 TestItemFactory factory;
170 ItemView view = ItemView::New(factory);
172 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
176 int UtcDaliItemViewCopyConstructor(void)
178 ToolkitTestApplication application;
180 TestItemFactory factory;
181 ItemView itemView = ItemView::New( factory );
182 DALI_TEST_CHECK( itemView );
184 ItemView copy( itemView );
185 DALI_TEST_CHECK( copy );
190 int UtcDaliItemViewCopyAssignment(void)
192 ToolkitTestApplication application;
194 TestItemFactory factory;
195 ItemView itemView = ItemView::New( factory );
196 DALI_TEST_CHECK( itemView );
200 DALI_TEST_CHECK( copy );
201 DALI_TEST_EQUALS( itemView, copy, TEST_LOCATION );
206 int UtcDaliItemViewMoveConstructor(void)
208 ToolkitTestApplication application;
210 TestItemFactory factory;
211 ItemView itemView = ItemView::New( factory );
212 DALI_TEST_EQUALS( 1, itemView.GetBaseObject().ReferenceCount(), TEST_LOCATION );
213 itemView.SetProperty( Actor::Property::SENSITIVE, false );
214 DALI_TEST_CHECK( false == itemView.GetProperty< bool >( Actor::Property::SENSITIVE ) );
216 ItemView moved = std::move( itemView );
217 DALI_TEST_CHECK( moved );
218 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
219 DALI_TEST_CHECK( false == moved.GetProperty< bool >( Actor::Property::SENSITIVE ) );
220 DALI_TEST_CHECK( !itemView );
225 int UtcDaliItemViewMoveAssignment(void)
227 ToolkitTestApplication application;
229 TestItemFactory factory;
230 ItemView itemView = ItemView::New( factory );
231 DALI_TEST_EQUALS( 1, itemView.GetBaseObject().ReferenceCount(), TEST_LOCATION );
232 itemView.SetProperty( Actor::Property::SENSITIVE, false );
233 DALI_TEST_CHECK( false == itemView.GetProperty< bool >( Actor::Property::SENSITIVE ) );
236 moved = std::move( itemView );
237 DALI_TEST_CHECK( moved );
238 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
239 DALI_TEST_CHECK( false == moved.GetProperty< bool >( Actor::Property::SENSITIVE ) );
240 DALI_TEST_CHECK( !itemView );
245 int UtcDaliItemViewDownCast(void)
247 ToolkitTestApplication application;
249 // Create the ItemView actor
250 TestItemFactory factory;
251 const ItemView itemViewConst = ItemView::New(factory);
252 ItemView itemView(itemViewConst);
254 BaseHandle handle(itemView);
256 ItemView newItemView = ItemView::DownCast( handle );
257 DALI_TEST_CHECK( itemView );
258 DALI_TEST_CHECK( newItemView == itemView );
262 int UtcDaliItemViewAddAndGetLayout(void)
264 ToolkitTestApplication application;
266 // Create the ItemView actor
267 TestItemFactory factory;
268 ItemView view = ItemView::New(factory);
270 // Create a grid layout and add it to ItemView
271 ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
272 view.AddLayout(*gridLayout);
274 // As we have added one layout, check the number of layout is now 1
275 DALI_TEST_CHECK(view.GetLayoutCount() == 1);
277 // Create a depth layout and add it to ItemView
278 ItemLayoutPtr depthLayout = DefaultItemLayout::New( DefaultItemLayout::DEPTH );
279 view.AddLayout(*depthLayout);
281 // As we have added another layout, check the number of layout is now 2
282 DALI_TEST_CHECK(view.GetLayoutCount() == 2);
284 // Create a spiral layout and add it to ItemView
285 ItemLayoutPtr spiralLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL );
286 view.AddLayout(*spiralLayout);
288 // As we have added another layout, check the number of layout is now 3
289 DALI_TEST_CHECK(view.GetLayoutCount() == 3);
291 // Check we are getting the correct layout from ItemView
292 DALI_TEST_CHECK(view.GetLayout(0) == gridLayout);
293 DALI_TEST_CHECK(view.GetLayout(1) == depthLayout);
294 DALI_TEST_CHECK(view.GetLayout(2) == spiralLayout);
298 int UtcDaliItemViewAddAndRemoveLayout(void)
300 ToolkitTestApplication application;
302 // Create the ItemView actor
303 TestItemFactory factory;
304 ItemView view = ItemView::New(factory);
306 // Create a grid layout and add it to ItemView
307 ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
308 view.AddLayout(*gridLayout);
310 // As we have added one layout, check the number of layout is now 1
311 DALI_TEST_CHECK(view.GetLayoutCount() == 1);
313 // Create a depth layout and add it to ItemView
314 ItemLayoutPtr depthLayout = DefaultItemLayout::New( DefaultItemLayout::DEPTH );
315 view.AddLayout(*depthLayout);
317 // As we have added another layout, check the number of layout is now 2
318 DALI_TEST_CHECK(view.GetLayoutCount() == 2);
320 // Check we are getting the correct layout from ItemView
321 DALI_TEST_CHECK(view.GetLayout(0) == gridLayout);
322 DALI_TEST_CHECK(view.GetLayout(1) == depthLayout);
324 // Remove the grid layout
325 view.RemoveLayout(0);
327 // As we have removed the grid layout, check the number of layout is now 1
328 DALI_TEST_CHECK(view.GetLayoutCount() == 1);
330 // Check we are getting the correct layout from ItemView
331 DALI_TEST_CHECK(view.GetLayout(0) == depthLayout);
333 // Remove the depth layout
334 view.RemoveLayout(0);
336 // As we also removed the depth layout, check the number of layout is now 0
337 DALI_TEST_CHECK(view.GetLayoutCount() == 0);
341 int UtcDaliItemViewActivateLayoutAndGetActiveLayout(void)
343 ToolkitTestApplication application;
345 // Create the ItemView actor
346 TestItemFactory factory;
347 ItemView view = ItemView::New(factory);
349 // Create a grid layout and add it to ItemView
350 ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
351 view.AddLayout(*gridLayout);
353 // Create a depth layout and add it to ItemView
354 ItemLayoutPtr depthLayout = DefaultItemLayout::New( DefaultItemLayout::DEPTH );
355 view.AddLayout(*depthLayout);
357 // Create a spiral layout and add it to ItemView
358 ItemLayoutPtr spiralLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL );
359 view.AddLayout(*spiralLayout);
361 // As we have added three layouts, check the number of layout is now 3
362 DALI_TEST_CHECK(view.GetLayoutCount() == 3);
364 // Check there is no active layout at the moment
365 DALI_TEST_CHECK(view.GetActiveLayout() == NULL);
367 // Activate the depth layout
368 Vector3 stageSize(application.GetScene().GetSize());
369 view.ActivateLayout(1, stageSize, 0.5f);
371 // Check the current active layout is the depth layout
372 DALI_TEST_CHECK(view.GetActiveLayout() == depthLayout);
374 // Activate the grid layout
375 view.ActivateLayout(0, stageSize, 0.5f);
377 // Check the current active layout is the grid layout
378 DALI_TEST_CHECK(view.GetActiveLayout() == gridLayout);
380 // Activate the spiral layout
381 view.ActivateLayout(2, stageSize, 0.5f);
383 // Check the current active layout is the spiral layout
384 DALI_TEST_CHECK(view.GetActiveLayout() == spiralLayout);
388 int UtcDaliItemViewDeactivateCurrentLayout(void)
390 ToolkitTestApplication application;
392 // Create the ItemView actor
393 TestItemFactory factory;
394 ItemView view = ItemView::New(factory);
396 // Create a grid layout and add it to ItemView
397 ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
398 gridLayout->SetOrientation(ControlOrientation::Down);
399 view.AddLayout(*gridLayout);
401 // Check there is no active layout at the moment
402 DALI_TEST_CHECK(view.GetActiveLayout() == NULL);
404 // Activate the grid layout
405 Vector3 stageSize(application.GetScene().GetSize());
406 view.ActivateLayout(0, stageSize, 0.5f);
408 // Check the current active layout is the grid layout
409 DALI_TEST_CHECK(view.GetActiveLayout() == gridLayout);
411 // Deactivate the current layout
412 view.DeactivateCurrentLayout();
414 // Check there is no active layout at the moment
415 DALI_TEST_CHECK(view.GetActiveLayout() == NULL);
419 int UtcDaliItemViewGetItemAndGetItemId(void)
421 ToolkitTestApplication application;
423 // Create the ItemView actor
424 TestItemFactory factory;
425 ItemView view = ItemView::New(factory);
427 // Create a grid layout and add it to ItemView
428 ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
429 gridLayout->SetOrientation(ControlOrientation::Left);
430 view.AddLayout(*gridLayout);
432 // Activate the grid layout so that the items will be created and added to ItemView
433 Vector3 stageSize(application.GetScene().GetSize());
434 view.ActivateLayout(0, stageSize, 0.5f);
436 // Get the item given the item ID
437 Actor itemActor = view.GetItem(2);
439 // Check we are getting the correct Item ID given the specified actor
440 DALI_TEST_CHECK(view.GetItemId(itemActor) == 2);
444 int UtcDaliItemViewRemoveItem(void)
446 ToolkitTestApplication application;
448 // Create the ItemView actor
449 TestItemFactory factory;
450 ItemView view = ItemView::New(factory);
452 // Create a grid layout and add it to ItemView
453 ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
454 gridLayout->SetOrientation(ControlOrientation::Right);
455 view.AddLayout(*gridLayout);
457 // Activate the grid layout so that the items will be created and added to ItemView
458 Vector3 stageSize(application.GetScene().GetSize());
459 view.ActivateLayout(0, stageSize, 0.5f);
461 // Get the item given the item ID 2 and 3
462 Actor oldItemActorID2 = view.GetItem(2);
463 Actor oldItemActorID3 = view.GetItem(3);
465 // Remove the item with ID 2
466 view.RemoveItem(2, 0.0f);
468 // Get the new item given the item ID 2 and 3
469 Actor newItemActorID2 = view.GetItem(2);
470 Actor newItemActorID3 = view.GetItem(3);
472 // Check the original item with item ID 2 was deleted and now item ID 2 represents the original item with ID 3
473 DALI_TEST_CHECK(view.GetItemId(newItemActorID2) == 2);
474 DALI_TEST_CHECK(oldItemActorID2 != newItemActorID2);
475 DALI_TEST_CHECK(newItemActorID2 == oldItemActorID3);
477 // scroll to the end of item view
478 view.ScrollToItem(TOTAL_ITEM_NUMBER - 1, 0.00f);
480 application.SendNotification();
481 application.Render(0);
483 // Refresh the item view
486 Actor itemActorID390 = view.GetItem(390);
487 DALI_TEST_CHECK(view.GetItemId(itemActorID390) == 390);
489 // Remove the item with ID 2 (which is now before the current item range)
490 view.RemoveItem(2, 0.0f);
492 // Check the original item with item ID 2 was deleted and now item ID 389 represents the original item with ID 390
493 DALI_TEST_CHECK(view.GetItemId(itemActorID390) == 389);
494 DALI_TEST_CHECK(view.GetItem(389) == itemActorID390);
499 int UtcDaliItemViewGetCurrentLayoutPosition(void)
501 ToolkitTestApplication application;
503 // Create the ItemView actor
504 TestItemFactory factory;
505 ItemView view = ItemView::New(factory);
507 // Create a depth layout and add it to ItemView
508 ItemLayoutPtr depthLayout = DefaultItemLayout::New( DefaultItemLayout::DEPTH );
509 depthLayout->SetOrientation(ControlOrientation::Up);
510 view.AddLayout(*depthLayout);
512 // Activate the grid layout so that the items will be created and added to ItemView
513 Vector3 stageSize(application.GetScene().GetSize());
514 view.ActivateLayout(0, stageSize, 0.0f);
516 // Check the current layout position for the 10th items is 9.0f
517 DALI_TEST_EQUALS(view.GetCurrentLayoutPosition(9), 9.0f, TEST_LOCATION );
521 int UtcDaliItemViewSetAndGetMinimumSwipeSpeed(void)
523 ToolkitTestApplication application;
525 // Create the ItemView actor
526 TestItemFactory factory;
527 ItemView view = ItemView::New(factory);
529 // Set the minimum swipe speed to be 1.5f
530 view.SetMinimumSwipeSpeed(1.5f);
532 // Check the minimum swipe speed is 1.5f
533 DALI_TEST_EQUALS(view.GetMinimumSwipeSpeed(), 1.5f, TEST_LOCATION );
537 int UtcDaliItemViewSetAndGetMinimumSwipeDistance(void)
539 ToolkitTestApplication application;
541 // Create the ItemView actor
542 TestItemFactory factory;
543 ItemView view = ItemView::New(factory);
545 // Set the minimum swipe distance to be 2.5f
546 view.SetMinimumSwipeDistance(2.5f);
548 // Check the minimum swipe distance is 2.5f
549 DALI_TEST_EQUALS(view.GetMinimumSwipeDistance(), 2.5f, TEST_LOCATION );
553 int UtcDaliItemViewSetAndGetAnchoring(void)
555 ToolkitTestApplication application;
557 // Create the ItemView actor
558 TestItemFactory factory;
559 ItemView view = ItemView::New(factory);
561 // Disable the anchor animation
562 view.SetAnchoring(false);
564 // Check the anchor animation is disabled
565 DALI_TEST_CHECK(view.GetAnchoring() == false);
569 int UtcDaliItemViewSetAndGetAnchoringDuration(void)
571 ToolkitTestApplication application;
573 // Create the ItemView actor
574 TestItemFactory factory;
575 ItemView view = ItemView::New(factory);
577 // Set the duration of anchor animation to be 1.5f
578 view.SetAnchoringDuration(1.5f);
580 // Check the duration of anchor animation is 1.5f
581 DALI_TEST_EQUALS(view.GetAnchoringDuration(), 1.5f, TEST_LOCATION );
585 int UtcDaliItemViewSetAndGetRefreshInterval(void)
587 ToolkitTestApplication application;
589 // Create the ItemView actor
590 TestItemFactory factory;
591 ItemView view = ItemView::New(factory);
593 // Set the interval between refreshes to be 20
594 view.SetRefreshInterval(20);
598 // Check the interval between refreshes is 20
599 DALI_TEST_CHECK(view.GetRefreshInterval() == 20);
603 int UtcDaliItemViewScrollToItem(void)
605 ToolkitTestApplication application;
607 // Create the ItemView actor
608 TestItemFactory factory;
609 ItemView view = ItemView::New(factory);
610 Vector3 vec(480.0f, 800.0f, 0.0f);
611 ItemLayoutPtr layout = DefaultItemLayout::New( DefaultItemLayout::DEPTH );
613 view.SetProperty( Dali::Actor::Property::NAME,"view actor");
614 view.AddLayout(*layout);
615 view.SetProperty( Actor::Property::SIZE, vec );
617 application.GetScene().Add(view);
618 layout->SetOrientation(ControlOrientation::Down);
619 view.ActivateLayout(0, vec, 0.0f);
621 application.SendNotification();
622 application.Render(0);
625 for(int i = 0; i < 10; ++i)
627 application.Render(16); // 60hz frames
630 // Confirm: we have actors in the view.
631 std::vector<unsigned int> indices;
632 for(unsigned int i = 0; i < 10; i++)
634 Actor testActor = view.GetItem(i);
637 indices.push_back(i);
643 if (!indices.empty())
645 const unsigned int firstTargetIndex = indices[indices.size()-1];
646 // scroll to last item
647 view.ScrollToItem(firstTargetIndex, 0.00f);
648 for(int i = 0; i < 10; ++i)
650 application.Render(16); // 60hz frames
653 std::size_t moveCount = 0;
654 for(std::size_t i = 0; i < indices.size(); i++)
656 float layoutPosBefore = view.GetCurrentLayoutPosition(i);
657 view.ScrollToItem(indices[i], 0.0f);
658 float layoutPosAfter = view.GetCurrentLayoutPosition(i);
660 if (fabs(layoutPosBefore-layoutPosAfter) <= FLT_EPSILON)
666 DALI_TEST_CHECK((moveCount == indices.size()));
671 tet_result(TET_FAIL);
674 application.GetScene().Remove(view);
678 int UtcDaliItemViewSetAndGetWheelScrollDistanceStep(void)
680 ToolkitTestApplication application;
682 // Create the ItemView actor
683 TestItemFactory factory;
684 ItemView view = ItemView::New(factory);
686 // Set the scroll distance step for the wheel event to be 100.0f
687 view.SetWheelScrollDistanceStep(100.0f);
689 // Check the scroll distance step is 100.0f
690 DALI_TEST_EQUALS(view.GetWheelScrollDistanceStep(), 100.0f, TEST_LOCATION );
694 int UtcDaliItemViewInsertItemP(void)
696 ToolkitTestApplication application;
698 // Create the ItemView actor
699 TestItemFactory factory;
700 ItemView view = ItemView::New(factory);
702 // Create a grid layout and add it to ItemView
703 ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID);
704 gridLayout->SetOrientation(ControlOrientation::Left);
705 view.AddLayout(*gridLayout);
707 // Activate the grid layout so that the items will be created and added to ItemView
708 Vector3 stageSize(application.GetScene().GetSize());
709 view.ActivateLayout(0, stageSize, 0.0f);
711 // Get the specified item where new item to be inserted before that
712 Actor itemActor = view.GetItem(2);
714 ItemId id = view.GetItemId( itemActor );
716 // Check we are getting the correct Item ID given the specified actor
717 DALI_TEST_CHECK(view.GetItemId(itemActor) == 2);
719 Actor newActor = Actor::New();
721 view.InsertItem(Item(id, newActor), 0.0f);
723 DALI_TEST_CHECK(view.GetItem(2) == newActor);
725 DALI_TEST_CHECK(view.GetItemId(itemActor) == 3);
726 DALI_TEST_CHECK(view.GetItem(3) == itemActor);
728 // scroll to the end of item view
729 view.ScrollToItem(TOTAL_ITEM_NUMBER - 1, 0.00f);
731 application.SendNotification();
732 application.Render(0);
734 // Refresh the item view
737 Actor itemActorID390 = view.GetItem(390);
738 DALI_TEST_CHECK(view.GetItemId(itemActorID390) == 390);
740 // Insert the item with ID 2 (which is now before the current item range)
741 Actor anotherNewActor = Actor::New();
742 view.InsertItem(Item(id, anotherNewActor), 0.0f);
744 // Check that item ID 391 now represents the original item with ID 390
745 DALI_TEST_CHECK(view.GetItemId(itemActorID390) == 391);
746 DALI_TEST_CHECK(view.GetItem(391) == itemActorID390);
751 int UtcDaliItemViewInsertItemsP(void)
753 ToolkitTestApplication application;
755 // Create the ItemView actor
756 TestItemFactory factory;
757 ItemView view = ItemView::New(factory);
759 // Create a depth layout and add it to ItemView
760 ItemLayoutPtr depthLayout = DefaultItemLayout::New( DefaultItemLayout::DEPTH);
761 depthLayout->SetOrientation(ControlOrientation::Right);
762 view.AddLayout(*depthLayout);
764 // Activate the grid layout so that the items will be created and added to ItemView
765 Vector3 stageSize(application.GetScene().GetSize());
766 view.ActivateLayout(0, stageSize, 0.5f);
768 unsigned int itemCount = view.GetChildCount();
770 // Get the specified item where new items to be inserted before that
771 Actor itemActor = view.GetItem(1);
773 // Check we are getting the correct Item ID given the specified item
774 DALI_TEST_CHECK(view.GetItemId(itemActor) == 1);
776 ItemContainer insertList;
778 for( unsigned int i = 1u; i < 11; ++i )
780 Actor child = view.GetChildAt( i );
781 Actor newActor = Actor::New();
782 newActor.SetProperty( Dali::Actor::Property::NAME,"Inserted");
783 insertList.push_back( Item( view.GetItemId(child), newActor ) );
786 if( !insertList.empty() )
788 view.InsertItems( insertList, 0.5f );
791 DALI_TEST_CHECK(view.GetChildCount() == itemCount + 10);
793 // Check that new items are inserted in the correct positions
794 DALI_TEST_CHECK(view.GetItemId(itemActor) == 11);
795 DALI_TEST_CHECK(view.GetItem(11) == itemActor);
797 ItemIdContainer removeList;
799 for( unsigned int i = 0u; i < view.GetChildCount(); ++i )
801 Actor child = view.GetChildAt( i );
803 if( child.GetProperty< std::string >( Dali::Actor::Property::NAME ) == "Inserted" )
805 removeList.push_back( view.GetItemId(child) );
809 if( ! removeList.empty() )
811 view.RemoveItems( removeList, 0.5f );
814 DALI_TEST_CHECK(view.GetChildCount() == itemCount);
816 // Check that new items are removed correctly so that we are getting the correct Item ID given the specified item
817 DALI_TEST_CHECK(view.GetItemId(itemActor) == 1);
818 DALI_TEST_CHECK(view.GetItem(1) == itemActor);
823 int UtcDaliItemViewReplaceItemP(void)
825 ToolkitTestApplication application;
827 // Create the ItemView actor
828 TestItemFactory factory;
829 ItemView view = ItemView::New(factory);
831 // Create a spiral layout and add it to ItemView
832 ItemLayoutPtr spiralLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL );
833 view.AddLayout(*spiralLayout);
835 // Activate the grid layout so that the items will be created and added to ItemView
836 Vector3 stageSize(application.GetScene().GetSize());
837 view.ActivateLayout(0, stageSize, 0.5f);
839 Actor newActor = Actor::New();
841 view.ReplaceItem( Item( 5, newActor ), 0.5f );
843 DALI_TEST_CHECK(view.GetItem(5) == newActor);
848 int UtcDaliItemViewReplaceItemsP(void)
850 ToolkitTestApplication application;
852 // Create the ItemView actor
853 TestItemFactory factory;
854 ItemView view = ItemView::New(factory);
856 // Create a spiral layout and add it to ItemView
857 ItemLayoutPtr spiralLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL );
858 spiralLayout->SetOrientation( ControlOrientation::Down );
859 view.AddLayout(*spiralLayout);
861 // Activate the grid layout so that the items will be created and added to ItemView
862 Vector3 stageSize(application.GetScene().GetSize());
863 view.ActivateLayout(0, stageSize, 0.5f);
865 ItemContainer replaceList;
867 for( unsigned int i = 0u; i < 10; ++i )
869 Actor child = view.GetItem( i );
870 Actor newActor = Actor::New();
871 newActor.SetProperty( Dali::Actor::Property::NAME,"Replaced");
873 replaceList.push_back( Item( i, newActor ) );
876 if( !replaceList.empty() )
878 view.ReplaceItems( replaceList, 0.5f );
881 DALI_TEST_CHECK(view.GetItem(0).GetProperty< std::string >( Dali::Actor::Property::NAME ) == "Replaced");
882 DALI_TEST_CHECK(view.GetItem(8).GetProperty< std::string >( Dali::Actor::Property::NAME ) == "Replaced");
886 int UtcDaliItemViewGetItemsRangeP(void)
888 ToolkitTestApplication application;
890 // Create the ItemView actor
891 TestItemFactory factory;
892 ItemView view = ItemView::New(factory);
894 // Create a spiral layout and add it to ItemView
895 ItemLayoutPtr spiralLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL );
896 spiralLayout->SetOrientation( ControlOrientation::Left );
897 view.AddLayout(*spiralLayout);
899 // Activate the grid layout so that the items will be created and added to ItemView
900 Vector3 stageSize(application.GetScene().GetSize());
901 view.ActivateLayout(0, stageSize, 0.5f);
903 ItemRange itemRange(0, 0);
905 view.GetItemsRange(itemRange);
907 DALI_TEST_CHECK(itemRange.Within(0));
911 int UtcDaliItemViewSetItemsAnchorPointP(void)
913 ToolkitTestApplication application;
915 // Create the ItemView actor
916 TestItemFactory factory;
917 ItemView view = ItemView::New(factory);
919 // Create a spiral layout and add it to ItemView
920 ItemLayoutPtr spiralLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL );
921 spiralLayout->SetOrientation( ControlOrientation::Right );
922 view.AddLayout(*spiralLayout);
924 // Activate the grid layout so that the items will be created and added to ItemView
925 Vector3 stageSize(application.GetScene().GetSize());
926 view.ActivateLayout(0, stageSize, 0.5f);
928 Vector3 anchorPoint(10.0f, 10.0f, 0.0f);
930 view.SetItemsAnchorPoint(anchorPoint);
932 DALI_TEST_CHECK(view.GetItemsAnchorPoint() == anchorPoint);
933 DALI_TEST_CHECK(view.GetItem(0).GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ) == anchorPoint);
937 int UtcDaliItemViewSetItemsParentOriginP(void)
939 ToolkitTestApplication application;
941 // Create the ItemView actor
942 TestItemFactory factory;
943 ItemView view = ItemView::New(factory);
945 // Create a grid layout and add it to ItemView
946 ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
947 view.AddLayout(*gridLayout);
949 // Activate the grid layout so that the items will be created and added to ItemView
950 Vector3 stageSize(application.GetScene().GetSize());
951 view.ActivateLayout(0, stageSize, 0.5f);
953 Vector3 parentOrigin(10.0f, 10.0f, 0.0f);
955 view.SetItemsParentOrigin(parentOrigin);
957 DALI_TEST_CHECK(view.GetItemsParentOrigin() == parentOrigin);
958 DALI_TEST_CHECK(view.GetItem(0).GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ) == parentOrigin);
962 int UtcDaliItemFactoryGetExtention(void)
964 ToolkitTestApplication application;
965 TestItemFactory factory;
966 DALI_TEST_CHECK( factory.GetExtension() == NULL );
970 int UtcDaliItemViewLayoutActivatedSignalP(void)
972 ToolkitTestApplication application;
974 // Create the ItemView actor
975 TestItemFactory factory;
976 ItemView view = ItemView::New(factory);
978 // Create a grid layout and add it to ItemView
979 ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
980 view.AddLayout(*gridLayout);
982 application.GetScene().Add( view );
984 // Connect the layout activated signal
985 view.LayoutActivatedSignal().Connect( &OnLayoutActivated );
987 gOnLayoutActivatedCalled = false;
990 application.SendNotification();
991 application.Render();
993 // Activate the grid layout so that the items will be created and added to ItemView
994 Vector3 stageSize(application.GetScene().GetSize());
995 view.ActivateLayout(0, stageSize, 0.1f);
997 // Wait for 0.1 second
998 Wait(application, 100);
1000 DALI_TEST_EQUALS( gOnLayoutActivatedCalled, true, TEST_LOCATION );
1005 int UtcDaliItemViewSetGetProperty(void)
1007 ToolkitTestApplication application;
1009 // Create the ItemView actor
1010 TestItemFactory factory;
1011 ItemView view = ItemView::New(factory);
1012 DALI_TEST_CHECK(view);
1014 // Event side properties
1016 // Test "minimumSwipeSpeed" property
1017 DALI_TEST_CHECK( view.GetPropertyIndex("minimumSwipeSpeed") == ItemView::Property::MINIMUM_SWIPE_SPEED );
1018 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::MINIMUM_SWIPE_SPEED).Get<float>(), view.GetMinimumSwipeSpeed(), TEST_LOCATION );
1019 view.SetProperty( ItemView::Property::MINIMUM_SWIPE_SPEED, 2.5f );
1020 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::MINIMUM_SWIPE_SPEED).Get<float>(), 2.5f, TEST_LOCATION );
1022 // Test "minimumSwipeDistance" property
1023 DALI_TEST_CHECK( view.GetPropertyIndex("minimumSwipeDistance") == ItemView::Property::MINIMUM_SWIPE_DISTANCE );
1024 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::MINIMUM_SWIPE_DISTANCE).Get<float>(), view.GetMinimumSwipeDistance(), TEST_LOCATION );
1025 view.SetProperty( ItemView::Property::MINIMUM_SWIPE_DISTANCE, 8.725f );
1026 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::MINIMUM_SWIPE_DISTANCE).Get<float>(), 8.725f, TEST_LOCATION );
1028 // Test "wheelScrollDistanceStep" property
1029 DALI_TEST_CHECK( view.GetPropertyIndex("wheelScrollDistanceStep") == ItemView::Property::WHEEL_SCROLL_DISTANCE_STEP );
1030 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::WHEEL_SCROLL_DISTANCE_STEP).Get<float>(), view.GetWheelScrollDistanceStep(), TEST_LOCATION );
1031 view.SetProperty( ItemView::Property::WHEEL_SCROLL_DISTANCE_STEP, 5.0f );
1032 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::WHEEL_SCROLL_DISTANCE_STEP).Get<float>(), 5.0f, TEST_LOCATION );
1034 // Test "snapToItemEnabled" property
1035 DALI_TEST_CHECK( view.GetPropertyIndex("snapToItemEnabled") == ItemView::Property::SNAP_TO_ITEM_ENABLED );
1036 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::SNAP_TO_ITEM_ENABLED).Get<bool>(), view.GetAnchoring(), TEST_LOCATION );
1037 view.SetProperty( ItemView::Property::SNAP_TO_ITEM_ENABLED, true );
1038 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::SNAP_TO_ITEM_ENABLED).Get<bool>(), true, TEST_LOCATION );
1040 // Test "refreshInterval" property
1041 DALI_TEST_CHECK( view.GetPropertyIndex("refreshInterval") == ItemView::Property::REFRESH_INTERVAL );
1042 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::REFRESH_INTERVAL).Get<float>(), view.GetRefreshInterval(), TEST_LOCATION );
1043 view.SetProperty( ItemView::Property::REFRESH_INTERVAL, 11.0f );
1044 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::REFRESH_INTERVAL).Get<float>(), 11.0f, TEST_LOCATION );
1046 // Test "layout" property
1047 DALI_TEST_CHECK( view.GetPropertyIndex("layout") == ItemView::Property::LAYOUT );
1048 Property::Map gridLayoutProperty;
1049 gridLayoutProperty.Insert( DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::GRID) );
1050 gridLayoutProperty.Insert( DefaultItemLayoutProperty::ITEM_SIZE, Dali::Property::Value(Vector3(200, 200,50)) );
1051 gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_ROW_SPACING, Dali::Property::Value(50.0f) );
1052 gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_COLUMN_NUMBER, Dali::Property::Value(4) );
1054 Property::Map depthLayoutProperty;
1055 depthLayoutProperty.Insert( DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::DEPTH) );
1056 depthLayoutProperty.Insert( DefaultItemLayoutProperty::DEPTH_COLUMN_NUMBER, Dali::Property::Value(3) );
1057 depthLayoutProperty.Insert( DefaultItemLayoutProperty::DEPTH_ROW_NUMBER, Dali::Property::Value(26.0f) );
1059 Property::Map spiralLayoutPrperty;
1060 spiralLayoutPrperty.Insert( DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::SPIRAL) );
1061 spiralLayoutPrperty.Insert( DefaultItemLayoutProperty::SPIRAL_ITEM_SPACING, Dali::Property::Value((Math::PI*2.0f)/9.5f) );
1062 spiralLayoutPrperty.Insert( DefaultItemLayoutProperty::SPIRAL_TOP_ITEM_ALIGNMENT, Dali::Property::Value(-0.125f) );
1064 Property::Map listLayoutPrperty;
1065 listLayoutPrperty.Insert( DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::LIST) );
1066 listLayoutPrperty.Insert( DefaultItemLayoutProperty::ITEM_SIZE, Dali::Property::Value(Vector3(100, 100,50)) );
1069 Property::Array layoutArray;
1070 layoutArray.PushBack(gridLayoutProperty);
1071 layoutArray.PushBack(depthLayoutProperty);
1072 layoutArray.PushBack(spiralLayoutPrperty);
1073 layoutArray.PushBack(listLayoutPrperty);
1075 view.SetProperty( ItemView::Property::LAYOUT, layoutArray);
1077 Property::Array getLayoutArray;
1078 DALI_TEST_CHECK( view.GetProperty( ItemView::Property::LAYOUT ).Get( getLayoutArray ) );
1080 //Check that the result is the same as
1081 DALI_TEST_EQUALS( layoutArray.Count(), getLayoutArray.Count(), TEST_LOCATION );
1082 Property::Map firstLayout = *((getLayoutArray.GetElementAt( 0 )).GetMap());
1084 for( unsigned int mapIdx = 0, mapCount = firstLayout.Count(); mapIdx < mapCount; ++mapIdx )
1086 KeyValuePair propertyPair( firstLayout.GetKeyValue( mapIdx ) );
1087 if(propertyPair.first == DefaultItemLayoutProperty::TYPE)
1089 int layoutType = propertyPair.second.Get<int>();
1090 DALI_TEST_EQUALS( layoutType, (int)DefaultItemLayout::GRID, TEST_LOCATION );
1092 else if(propertyPair.first == DefaultItemLayoutProperty::ITEM_SIZE)
1094 Vector3 size = propertyPair.second.Get<Vector3>();
1095 DALI_TEST_EQUALS( size, Vector3(200, 200,50), TEST_LOCATION );
1097 else if(propertyPair.first == DefaultItemLayoutProperty::GRID_ROW_SPACING)
1099 float spacing = propertyPair.second.Get<float>();
1100 DALI_TEST_EQUALS( spacing, 50.0f, TEST_LOCATION );
1102 else if(propertyPair.first == DefaultItemLayoutProperty::GRID_COLUMN_NUMBER)
1104 int number = propertyPair.second.Get<int>();
1105 DALI_TEST_EQUALS(number, 4, TEST_LOCATION );
1108 view.SetProperty( ItemView::Property::LAYOUT, layoutArray);
1111 // Test "overshootEnabled" property
1112 DALI_TEST_CHECK( view.GetPropertyIndex("overshootEnabled") == Scrollable::Property::OVERSHOOT_ENABLED );
1113 DALI_TEST_EQUALS( view.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), view.IsOvershootEnabled(), TEST_LOCATION );
1114 view.SetProperty( Scrollable::Property::OVERSHOOT_ENABLED, false );
1115 DALI_TEST_EQUALS( view.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), false, TEST_LOCATION );
1117 // Test "overshootSize" property
1118 DALI_TEST_CHECK( view.GetPropertyIndex("overshootSize") == Scrollable::Property::OVERSHOOT_SIZE );
1119 Vector2 overshootSize = Vector2(100.0f,100.0f);
1120 view.SetProperty( Scrollable::Property::OVERSHOOT_SIZE, overshootSize );
1121 DALI_TEST_EQUALS( view.GetProperty(Scrollable::Property::OVERSHOOT_SIZE).Get<Vector2>(), overshootSize, TEST_LOCATION );
1123 // Animatable properties
1125 // Test "layoutPosition" property
1126 DALI_TEST_CHECK( view.GetPropertyIndex("layoutPosition") == ItemView::Property::LAYOUT_POSITION );
1127 view.SetProperty( ItemView::Property::LAYOUT_POSITION, 20.5f );
1129 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::LAYOUT_POSITION).Get<float>(), 20.5f, TEST_LOCATION );
1131 // Test "scrollSpeed" property
1132 DALI_TEST_CHECK( view.GetPropertyIndex("scrollSpeed") == ItemView::Property::SCROLL_SPEED );
1133 view.SetProperty( ItemView::Property::SCROLL_SPEED, 3.35f );
1135 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::SCROLL_SPEED).Get<float>(), 3.35f, TEST_LOCATION );
1137 // Test "overshoot" property
1138 DALI_TEST_CHECK( view.GetPropertyIndex("overshoot") == ItemView::Property::OVERSHOOT );
1139 view.SetProperty( ItemView::Property::OVERSHOOT, 0.15f );
1141 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::OVERSHOOT).Get<float>(), 0.15f, TEST_LOCATION );
1143 // Test "scrollDirection" property
1144 DALI_TEST_CHECK( view.GetPropertyIndex("scrollDirection") == ItemView::Property::SCROLL_DIRECTION );
1145 view.SetProperty( ItemView::Property::SCROLL_DIRECTION, Vector2(0.85f, 0.5f) );
1147 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::SCROLL_DIRECTION).Get<Vector2>(), Vector2(0.85f, 0.5f), TEST_LOCATION );
1149 // Test "layoutOrientation" property
1150 DALI_TEST_CHECK( view.GetPropertyIndex("layoutOrientation") == ItemView::Property::LAYOUT_ORIENTATION );
1151 view.SetProperty( ItemView::Property::LAYOUT_ORIENTATION, 2 );
1153 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::LAYOUT_ORIENTATION).Get<int>(), 2, TEST_LOCATION );
1155 // Test "scrollContentSize" property
1156 DALI_TEST_CHECK( view.GetPropertyIndex("scrollContentSize") == ItemView::Property::SCROLL_CONTENT_SIZE );
1157 view.SetProperty( ItemView::Property::SCROLL_CONTENT_SIZE, 250.0f );
1159 DALI_TEST_EQUALS( view.GetProperty(ItemView::Property::SCROLL_CONTENT_SIZE).Get<float>(), 250.0f, TEST_LOCATION );
1165 int UtcDaliItemViewOvershootVertical(void)
1167 ToolkitTestApplication application;
1168 Dali::Integration::Scene stage = application.GetScene();
1170 // Create the ItemView actor
1171 TestItemFactory factory;
1172 ItemView view = ItemView::New(factory);
1174 // Create a grid layout and add it to ItemView
1175 ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
1176 view.AddLayout(*gridLayout);
1179 // Activate the grid layout so that the items will be created and added to ItemView
1180 Vector3 stageSize(stage.GetSize());
1181 view.ActivateLayout(0, stageSize, 0.5f);
1183 view.SetProperty( Scrollable::Property::OVERSHOOT_ENABLED, true );
1184 DALI_TEST_EQUALS( view.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), true, TEST_LOCATION );
1186 view.SetProperty( Scrollable::Property::OVERSHOOT_SIZE, Vector2(30, 30) );
1190 // Do a pan starting from 100,100 and moving down
1191 Vector2 pos(100.0f, 100.0f);
1193 application.ProcessEvent( GenerateSingleTouch(PointState::DOWN, pos, 100 ) );
1194 application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ) );
1197 Wait(application, 100);
1199 for(int i = 0;i<200;i++)
1201 application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ) );
1206 application.ProcessEvent( GenerateSingleTouch(PointState::UP, pos, 100 ) );
1208 Wait(application, 100);
1210 // Do a pan starting from 100,100 and moving up
1211 pos = Vector2(100.0f, 300.0f);
1213 application.ProcessEvent( GenerateSingleTouch(PointState::DOWN, pos, 100 ) );
1214 application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ) );
1217 Wait(application, 100);
1219 for(int i = 0;i<200;i++)
1221 application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ) );
1226 application.ProcessEvent( GenerateSingleTouch(PointState::UP, pos, 100 ) );
1227 Wait(application, 100);
1231 int UtcDaliItemViewOvershootHorizontal(void)
1233 ToolkitTestApplication application;
1234 Dali::Integration::Scene stage = application.GetScene();
1236 // Create the ItemView actor
1237 TestItemFactory factory;
1238 ItemView view = ItemView::New(factory);
1240 // Create a grid layout and add it to ItemView
1241 ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL );
1242 view.AddLayout(*gridLayout);
1245 // Activate the grid layout so that the items will be created and added to ItemView
1246 Vector3 stageSize(stage.GetSize());
1247 view.ActivateLayout(0, stageSize, 0.5f);
1249 view.SetProperty( Scrollable::Property::OVERSHOOT_ENABLED, true );
1250 DALI_TEST_EQUALS( view.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), true, TEST_LOCATION );
1252 view.SetProperty( Scrollable::Property::OVERSHOOT_SIZE, Vector2(30, 30) );
1256 // Do a pan starting from 100,100 and moving left
1257 Vector2 pos(100.0f, 100.0f);
1258 application.ProcessEvent( GenerateSingleTouch(PointState::DOWN, pos, 100 ));
1259 application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ));
1261 Wait(application, 100);
1263 for(int i = 0;i<200;i++)
1265 application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ) );
1270 application.ProcessEvent( GenerateSingleTouch(PointState::UP, pos, 100 ) );
1271 Wait(application, 100);
1273 // Do a pan starting from 100,100 and moving right
1274 pos = Vector2(100.0f, 100.0f);
1275 application.ProcessEvent( GenerateSingleTouch(PointState::DOWN, pos, 100 ) );
1276 application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ) );
1278 Wait(application, 100);
1280 for(int i = 0;i<200;i++)
1282 application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ) );
1287 application.ProcessEvent( GenerateSingleTouch(PointState::UP, pos, 100 ) );
1288 Wait(application, 100);
1293 int UtcDaliItemEnableDisableRefresh(void)
1295 ToolkitTestApplication application;
1296 Dali::Integration::Scene stage = application.GetScene();
1298 // Create the ItemView actor
1299 TestItemFactory factory;
1300 ItemView view = ItemView::New(factory);
1302 // Create a grid layout and add it to ItemView
1303 ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
1304 view.AddLayout(*gridLayout);
1307 // Activate the grid layout so that the items will be created and added to ItemView
1308 Vector3 stageSize(stage.GetSize());
1309 view.ActivateLayout(0, stageSize, 0.5f);
1311 //Connect to signal scroll updated
1312 view.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
1314 Property::Map attributes;
1315 view.DoAction("enableRefresh", attributes );
1316 gOnScrollUpdateCalled = true;
1317 view.SetProperty( ItemView::Property::LAYOUT_POSITION, 100.0f );
1318 application.SendNotification();
1319 application.Render(1000);
1320 DALI_TEST_EQUALS( gOnScrollUpdateCalled, true, TEST_LOCATION );
1323 view.DoAction("disableRefresh", attributes );
1324 gOnScrollUpdateCalled = false;
1325 view.SetProperty( ItemView::Property::LAYOUT_POSITION, 100.0f );
1326 application.SendNotification();
1327 application.Render(1000);
1329 DALI_TEST_EQUALS( gOnScrollUpdateCalled, false, TEST_LOCATION );
1334 int UtcDaliItemViewWheelEvent(void)
1336 ToolkitTestApplication application;
1337 Dali::Integration::Scene stage = application.GetScene();
1339 // Create the ItemView actor
1340 TestItemFactory factory;
1341 ItemView view = ItemView::New( factory );
1343 // Create a grid layout and add it to ItemView
1344 ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
1345 view.AddLayout( *gridLayout );
1348 // Activate the grid layout so that the items will be created and added to ItemView
1349 Vector3 stageSize( stage.GetSize() );
1350 view.ActivateLayout (0, stageSize, 0.5f );
1352 //Connect to wheel event signal
1353 view.WheelEventSignal().Connect( &OnWheelEvent );
1355 DALI_TEST_CHECK( !gOnWheelEventCalled );
1357 // Render and notify
1358 application.Render();
1359 application.SendNotification();
1360 application.Render();
1361 application.SendNotification();
1363 // Perform a wheel event
1364 Dali::Integration::WheelEvent wheelEvent( Dali::Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, Vector2( 10.0f, 10.0f ), 1, 1000u );
1365 application.ProcessEvent( wheelEvent );
1366 DALI_TEST_CHECK( gOnWheelEventCalled );