+ ItemView view = ItemView::New(factory);
+
+ // Create a grid layout and add it to ItemView
+ ItemLayoutPtr gridLayout = DefaultItemLayout::New(DefaultItemLayout::GRID);
+ view.AddLayout(*gridLayout);
+
+ application.GetScene().Add(view);
+
+ // Connect the layout activated signal
+ view.LayoutActivatedSignal().Connect(&OnLayoutActivated);
+
+ gOnLayoutActivatedCalled = false;
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Activate the grid layout so that the items will be created and added to ItemView
+ Vector3 stageSize(application.GetScene().GetSize());
+ view.ActivateLayout(0, stageSize, 0.1f);
+
+ // Wait for 0.1 second
+ Wait(application, 100);
+
+ DALI_TEST_EQUALS(gOnLayoutActivatedCalled, true, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliItemViewSetGetProperty(void)
+{
+ ToolkitTestApplication application;
+
+ // Create the ItemView actor
+ TestItemFactory factory;
+ ItemView view = ItemView::New(factory);
+ DALI_TEST_CHECK(view);
+
+ // Event side properties
+
+ // Test "minimumSwipeSpeed" property
+ DALI_TEST_CHECK(view.GetPropertyIndex("minimumSwipeSpeed") == ItemView::Property::MINIMUM_SWIPE_SPEED);
+ DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::MINIMUM_SWIPE_SPEED).Get<float>(), view.GetMinimumSwipeSpeed(), TEST_LOCATION);
+ view.SetProperty(ItemView::Property::MINIMUM_SWIPE_SPEED, 2.5f);
+ DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::MINIMUM_SWIPE_SPEED).Get<float>(), 2.5f, TEST_LOCATION);
+
+ // Test "minimumSwipeDistance" property
+ DALI_TEST_CHECK(view.GetPropertyIndex("minimumSwipeDistance") == ItemView::Property::MINIMUM_SWIPE_DISTANCE);
+ DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::MINIMUM_SWIPE_DISTANCE).Get<float>(), view.GetMinimumSwipeDistance(), TEST_LOCATION);
+ view.SetProperty(ItemView::Property::MINIMUM_SWIPE_DISTANCE, 8.725f);
+ DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::MINIMUM_SWIPE_DISTANCE).Get<float>(), 8.725f, TEST_LOCATION);
+
+ // Test "wheelScrollDistanceStep" property
+ DALI_TEST_CHECK(view.GetPropertyIndex("wheelScrollDistanceStep") == ItemView::Property::WHEEL_SCROLL_DISTANCE_STEP);
+ DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::WHEEL_SCROLL_DISTANCE_STEP).Get<float>(), view.GetWheelScrollDistanceStep(), TEST_LOCATION);
+ view.SetProperty(ItemView::Property::WHEEL_SCROLL_DISTANCE_STEP, 5.0f);
+ DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::WHEEL_SCROLL_DISTANCE_STEP).Get<float>(), 5.0f, TEST_LOCATION);
+
+ // Test "snapToItemEnabled" property
+ DALI_TEST_CHECK(view.GetPropertyIndex("snapToItemEnabled") == ItemView::Property::SNAP_TO_ITEM_ENABLED);
+ DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::SNAP_TO_ITEM_ENABLED).Get<bool>(), view.GetAnchoring(), TEST_LOCATION);
+ view.SetProperty(ItemView::Property::SNAP_TO_ITEM_ENABLED, true);
+ DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::SNAP_TO_ITEM_ENABLED).Get<bool>(), true, TEST_LOCATION);
+
+ // Test "refreshInterval" property
+ DALI_TEST_CHECK(view.GetPropertyIndex("refreshInterval") == ItemView::Property::REFRESH_INTERVAL);
+ DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::REFRESH_INTERVAL).Get<float>(), view.GetRefreshInterval(), TEST_LOCATION);
+ view.SetProperty(ItemView::Property::REFRESH_INTERVAL, 11.0f);
+ DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::REFRESH_INTERVAL).Get<float>(), 11.0f, TEST_LOCATION);
+
+ // Test "layout" property
+ DALI_TEST_CHECK(view.GetPropertyIndex("layout") == ItemView::Property::LAYOUT);
+ Property::Map gridLayoutProperty;
+ gridLayoutProperty.Insert(DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::GRID));
+ gridLayoutProperty.Insert(DefaultItemLayoutProperty::ITEM_SIZE, Dali::Property::Value(Vector3(200, 200, 50)));
+ gridLayoutProperty.Insert(DefaultItemLayoutProperty::GRID_ROW_SPACING, Dali::Property::Value(50.0f));
+ gridLayoutProperty.Insert(DefaultItemLayoutProperty::GRID_COLUMN_NUMBER, Dali::Property::Value(4));
+
+ Property::Map depthLayoutProperty;
+ depthLayoutProperty.Insert(DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::DEPTH));
+ depthLayoutProperty.Insert(DefaultItemLayoutProperty::DEPTH_COLUMN_NUMBER, Dali::Property::Value(3));
+ depthLayoutProperty.Insert(DefaultItemLayoutProperty::DEPTH_ROW_NUMBER, Dali::Property::Value(26.0f));
+
+ Property::Map spiralLayoutPrperty;
+ spiralLayoutPrperty.Insert(DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::SPIRAL));
+ spiralLayoutPrperty.Insert(DefaultItemLayoutProperty::SPIRAL_ITEM_SPACING, Dali::Property::Value((Math::PI * 2.0f) / 9.5f));
+ spiralLayoutPrperty.Insert(DefaultItemLayoutProperty::SPIRAL_TOP_ITEM_ALIGNMENT, Dali::Property::Value(-0.125f));
+
+ Property::Map listLayoutPrperty;
+ listLayoutPrperty.Insert(DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::LIST));
+ listLayoutPrperty.Insert(DefaultItemLayoutProperty::ITEM_SIZE, Dali::Property::Value(Vector3(100, 100, 50)));
+
+ Property::Array layoutArray;
+ layoutArray.PushBack(gridLayoutProperty);
+ layoutArray.PushBack(depthLayoutProperty);
+ layoutArray.PushBack(spiralLayoutPrperty);
+ layoutArray.PushBack(listLayoutPrperty);
+
+ view.SetProperty(ItemView::Property::LAYOUT, layoutArray);
+
+ Property::Array getLayoutArray;
+ DALI_TEST_CHECK(view.GetProperty(ItemView::Property::LAYOUT).Get(getLayoutArray));
+
+ //Check that the result is the same as
+ DALI_TEST_EQUALS(layoutArray.Count(), getLayoutArray.Count(), TEST_LOCATION);
+ Property::Map firstLayout = *((getLayoutArray.GetElementAt(0)).GetMap());
+
+ for(unsigned int mapIdx = 0, mapCount = firstLayout.Count(); mapIdx < mapCount; ++mapIdx)
+ {
+ KeyValuePair propertyPair(firstLayout.GetKeyValue(mapIdx));
+ if(propertyPair.first == DefaultItemLayoutProperty::TYPE)
+ {
+ int layoutType = propertyPair.second.Get<int>();
+ DALI_TEST_EQUALS(layoutType, (int)DefaultItemLayout::GRID, TEST_LOCATION);
+ }
+ else if(propertyPair.first == DefaultItemLayoutProperty::ITEM_SIZE)
+ {
+ Vector3 size = propertyPair.second.Get<Vector3>();
+ DALI_TEST_EQUALS(size, Vector3(200, 200, 50), TEST_LOCATION);
+ }
+ else if(propertyPair.first == DefaultItemLayoutProperty::GRID_ROW_SPACING)
+ {
+ float spacing = propertyPair.second.Get<float>();
+ DALI_TEST_EQUALS(spacing, 50.0f, TEST_LOCATION);
+ }
+ else if(propertyPair.first == DefaultItemLayoutProperty::GRID_COLUMN_NUMBER)
+ {
+ int number = propertyPair.second.Get<int>();
+ DALI_TEST_EQUALS(number, 4, TEST_LOCATION);
+ }
+ }
+ view.SetProperty(ItemView::Property::LAYOUT, layoutArray);
+
+ // Test "overshootEnabled" property
+ DALI_TEST_CHECK(view.GetPropertyIndex("overshootEnabled") == Scrollable::Property::OVERSHOOT_ENABLED);
+ DALI_TEST_EQUALS(view.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), view.IsOvershootEnabled(), TEST_LOCATION);
+ view.SetProperty(Scrollable::Property::OVERSHOOT_ENABLED, false);
+ DALI_TEST_EQUALS(view.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), false, TEST_LOCATION);
+
+ // Test "overshootSize" property
+ DALI_TEST_CHECK(view.GetPropertyIndex("overshootSize") == Scrollable::Property::OVERSHOOT_SIZE);
+ Vector2 overshootSize = Vector2(100.0f, 100.0f);
+ view.SetProperty(Scrollable::Property::OVERSHOOT_SIZE, overshootSize);
+ DALI_TEST_EQUALS(view.GetProperty(Scrollable::Property::OVERSHOOT_SIZE).Get<Vector2>(), overshootSize, TEST_LOCATION);
+
+ // Animatable properties
+
+ // Test "layoutPosition" property
+ DALI_TEST_CHECK(view.GetPropertyIndex("layoutPosition") == ItemView::Property::LAYOUT_POSITION);
+ view.SetProperty(ItemView::Property::LAYOUT_POSITION, 20.5f);
+ Wait(application);
+ DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::LAYOUT_POSITION).Get<float>(), 20.5f, TEST_LOCATION);
+
+ // Test "scrollSpeed" property
+ DALI_TEST_CHECK(view.GetPropertyIndex("scrollSpeed") == ItemView::Property::SCROLL_SPEED);
+ view.SetProperty(ItemView::Property::SCROLL_SPEED, 3.35f);
+ Wait(application);
+ DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::SCROLL_SPEED).Get<float>(), 3.35f, TEST_LOCATION);
+
+ // Test "overshoot" property
+ DALI_TEST_CHECK(view.GetPropertyIndex("overshoot") == ItemView::Property::OVERSHOOT);
+ view.SetProperty(ItemView::Property::OVERSHOOT, 0.15f);
+ Wait(application);
+ DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::OVERSHOOT).Get<float>(), 0.15f, TEST_LOCATION);
+
+ // Test "scrollDirection" property
+ DALI_TEST_CHECK(view.GetPropertyIndex("scrollDirection") == ItemView::Property::SCROLL_DIRECTION);
+ view.SetProperty(ItemView::Property::SCROLL_DIRECTION, Vector2(0.85f, 0.5f));
+ Wait(application);
+ DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::SCROLL_DIRECTION).Get<Vector2>(), Vector2(0.85f, 0.5f), TEST_LOCATION);
+
+ // Test "layoutOrientation" property
+ DALI_TEST_CHECK(view.GetPropertyIndex("layoutOrientation") == ItemView::Property::LAYOUT_ORIENTATION);
+ view.SetProperty(ItemView::Property::LAYOUT_ORIENTATION, 2);
+ Wait(application);
+ DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::LAYOUT_ORIENTATION).Get<int>(), 2, TEST_LOCATION);
+
+ // Test "scrollContentSize" property
+ DALI_TEST_CHECK(view.GetPropertyIndex("scrollContentSize") == ItemView::Property::SCROLL_CONTENT_SIZE);
+ view.SetProperty(ItemView::Property::SCROLL_CONTENT_SIZE, 250.0f);
+ Wait(application);
+ DALI_TEST_EQUALS(view.GetProperty(ItemView::Property::SCROLL_CONTENT_SIZE).Get<float>(), 250.0f, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliItemViewOvershootVertical(void)
+{
+ ToolkitTestApplication application;
+ Dali::Integration::Scene stage = application.GetScene();
+
+ // Create the ItemView actor
+ TestItemFactory factory;
+ ItemView view = ItemView::New(factory);
+
+ // Create a grid layout and add it to ItemView
+ ItemLayoutPtr gridLayout = DefaultItemLayout::New(DefaultItemLayout::GRID);
+ view.AddLayout(*gridLayout);
+ stage.Add(view);
+
+ // Activate the grid layout so that the items will be created and added to ItemView
+ Vector3 stageSize(stage.GetSize());
+ view.ActivateLayout(0, stageSize, 0.5f);
+
+ view.SetProperty(Scrollable::Property::OVERSHOOT_ENABLED, true);
+ DALI_TEST_EQUALS(view.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), true, TEST_LOCATION);
+
+ view.SetProperty(Scrollable::Property::OVERSHOOT_SIZE, Vector2(30, 30));
+
+ Wait(application);
+
+ // Do a pan starting from 100,100 and moving down
+ Vector2 pos(100.0f, 100.0f);
+
+ application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, pos, 100));
+ application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, pos, 100));
+
+ pos.y += 5.0f;
+ Wait(application, 100);
+
+ for(int i = 0; i < 200; i++)
+ {
+ application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, pos, 100));
+ pos.y += 5.0f;
+ Wait(application);
+ }
+
+ application.ProcessEvent(GenerateSingleTouch(PointState::UP, pos, 100));
+
+ Wait(application, 100);
+
+ // Do a pan starting from 100,100 and moving up
+ pos = Vector2(100.0f, 300.0f);
+
+ application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, pos, 100));
+ application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, pos, 100));
+
+ pos.y -= 5.0f;
+ Wait(application, 100);
+
+ for(int i = 0; i < 200; i++)
+ {
+ application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, pos, 100));
+ pos.y -= 5.0f;
+ Wait(application);
+ }
+
+ application.ProcessEvent(GenerateSingleTouch(PointState::UP, pos, 100));
+ Wait(application, 100);
+ END_TEST;
+}
+
+int UtcDaliItemViewOvershootHorizontal(void)
+{
+ ToolkitTestApplication application;
+ Dali::Integration::Scene stage = application.GetScene();
+
+ // Create the ItemView actor
+ TestItemFactory factory;
+ ItemView view = ItemView::New(factory);
+
+ // Create a grid layout and add it to ItemView
+ ItemLayoutPtr gridLayout = DefaultItemLayout::New(DefaultItemLayout::SPIRAL);
+ view.AddLayout(*gridLayout);
+ stage.Add(view);
+
+ // Activate the grid layout so that the items will be created and added to ItemView
+ Vector3 stageSize(stage.GetSize());
+ view.ActivateLayout(0, stageSize, 0.5f);
+
+ view.SetProperty(Scrollable::Property::OVERSHOOT_ENABLED, true);
+ DALI_TEST_EQUALS(view.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), true, TEST_LOCATION);
+
+ view.SetProperty(Scrollable::Property::OVERSHOOT_SIZE, Vector2(30, 30));
+
+ Wait(application);
+
+ // Do a pan starting from 100,100 and moving left
+ Vector2 pos(100.0f, 100.0f);
+ application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, pos, 100));
+ application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, pos, 100));
+ pos.x -= 5.0f;
+ Wait(application, 100);
+
+ for(int i = 0; i < 200; i++)
+ {
+ application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, pos, 100));
+ pos.x -= 5.0f;
+ Wait(application);
+ }
+
+ application.ProcessEvent(GenerateSingleTouch(PointState::UP, pos, 100));
+ Wait(application, 100);
+
+ // Do a pan starting from 100,100 and moving right
+ pos = Vector2(100.0f, 100.0f);
+ application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, pos, 100));
+ application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, pos, 100));
+ pos.x += 5.0f;
+ Wait(application, 100);
+
+ for(int i = 0; i < 200; i++)
+ {
+ application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, pos, 100));
+ pos.x += 5.0f;
+ Wait(application);
+ }
+
+ application.ProcessEvent(GenerateSingleTouch(PointState::UP, pos, 100));
+ Wait(application, 100);
+
+ END_TEST;
+}
+
+int UtcDaliItemEnableDisableRefresh(void)
+{
+ ToolkitTestApplication application;
+ Dali::Integration::Scene stage = application.GetScene();
+
+ // Create the ItemView actor
+ TestItemFactory factory;
+ ItemView view = ItemView::New(factory);
+
+ // Create a grid layout and add it to ItemView
+ ItemLayoutPtr gridLayout = DefaultItemLayout::New(DefaultItemLayout::GRID);
+ view.AddLayout(*gridLayout);
+ stage.Add(view);
+
+ // Activate the grid layout so that the items will be created and added to ItemView
+ Vector3 stageSize(stage.GetSize());
+ view.ActivateLayout(0, stageSize, 0.5f);
+
+ //Connect to signal scroll updated
+ view.ScrollUpdatedSignal().Connect(&OnScrollUpdate);
+
+ Property::Map attributes;
+ view.DoAction("enableRefresh", attributes);
+ gOnScrollUpdateCalled = true;
+ view.SetProperty(ItemView::Property::LAYOUT_POSITION, 100.0f);
+ application.SendNotification();
+ application.Render(1000);
+ DALI_TEST_EQUALS(gOnScrollUpdateCalled, true, TEST_LOCATION);
+
+ view.DoAction("disableRefresh", attributes);
+ gOnScrollUpdateCalled = false;
+ view.SetProperty(ItemView::Property::LAYOUT_POSITION, 100.0f);
+ application.SendNotification();
+ application.Render(1000);
+
+ DALI_TEST_EQUALS(gOnScrollUpdateCalled, false, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliItemViewWheelEvent(void)
+{
+ ToolkitTestApplication application;
+ Dali::Integration::Scene stage = application.GetScene();
+
+ // Create the ItemView actor
+ TestItemFactory factory;
+ ItemView view = ItemView::New(factory);
+
+ // Create a grid layout and add it to ItemView
+ ItemLayoutPtr gridLayout = DefaultItemLayout::New(DefaultItemLayout::GRID);
+ view.AddLayout(*gridLayout);
+ stage.Add(view);
+
+ // Activate the grid layout so that the items will be created and added to ItemView
+ Vector3 stageSize(stage.GetSize());
+ view.ActivateLayout(0, stageSize, 0.5f);
+
+ //Connect to wheel event signal
+ view.WheelEventSignal().Connect(&OnWheelEvent);
+
+ DALI_TEST_CHECK(!gOnWheelEventCalled);
+
+ // Render and notify
+ application.Render();
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
+
+ // Perform a wheel event
+ Dali::Integration::WheelEvent wheelEvent(Dali::Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, Vector2(10.0f, 10.0f), 1, 1000u);
+ application.ProcessEvent(wheelEvent);
+ DALI_TEST_CHECK(gOnWheelEventCalled);
+