/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <dali/integration-api/events/touch-event-integ.h>
#include <dali/integration-api/events/pan-gesture-event.h>
-
using namespace Dali;
using namespace Toolkit;
namespace
{
-const unsigned int TOTAL_ITEM_NUMBER = 100;
+const unsigned int TOTAL_ITEM_NUMBER = 400;
const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
// Remove the item with ID 2
view.RemoveItem(2, 0.0f);
- // Get the new item given the item ID 2
+ // Get the new item given the item ID 2 and 3
Actor newItemActorID2 = view.GetItem(2);
+ Actor newItemActorID3 = view.GetItem(3);
// Check the original item with item ID 2 was deleted and now item ID 2 represents the original item with ID 3
DALI_TEST_CHECK(view.GetItemId(newItemActorID2) == 2);
DALI_TEST_CHECK(oldItemActorID2 != newItemActorID2);
- DALI_TEST_CHECK(newItemActorID2 = oldItemActorID3);
+ DALI_TEST_CHECK(newItemActorID2 == oldItemActorID3);
+
+ // scroll to the end of item view
+ view.ScrollToItem(TOTAL_ITEM_NUMBER - 1, 0.00f);
+
+ application.SendNotification();
+ application.Render(0);
+
+ // Refresh the item view
+ view.Refresh();
+
+ Actor itemActorID390 = view.GetItem(390);
+ DALI_TEST_CHECK(view.GetItemId(itemActorID390) == 390);
+
+ // Remove the item with ID 2 (which is now before the current item range)
+ view.RemoveItem(2, 0.0f);
+
+ // Check the original item with item ID 2 was deleted and now item ID 389 represents the original item with ID 390
+ DALI_TEST_CHECK(view.GetItemId(itemActorID390) == 389);
+ DALI_TEST_CHECK(view.GetItem(389) == itemActorID390);
+
END_TEST;
}
TestItemFactory factory;
ItemView view = ItemView::New(factory);
- // Create a depth layout and add it to ItemView
- ItemLayoutPtr depthLayout = DefaultItemLayout::New( DefaultItemLayout::DEPTH);
- depthLayout->SetOrientation(ControlOrientation::Left);
- view.AddLayout(*depthLayout);
+ // Create a grid layout and add it to ItemView
+ ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID);
+ gridLayout->SetOrientation(ControlOrientation::Left);
+ view.AddLayout(*gridLayout);
// Activate the grid layout so that the items will be created and added to ItemView
Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
- view.ActivateLayout(0, stageSize, 0.5f);
+ view.ActivateLayout(0, stageSize, 0.0f);
- // Get the item given the item ID
+ // Get the specified item where new item to be inserted before that
Actor itemActor = view.GetItem(2);
ItemId id = view.GetItemId( itemActor );
Actor newActor = Actor::New();
- view.InsertItem(Item(id, newActor), 0.5f);
+ view.InsertItem(Item(id, newActor), 0.0f);
DALI_TEST_CHECK(view.GetItem(2) == newActor);
+
+ DALI_TEST_CHECK(view.GetItemId(itemActor) == 3);
+ DALI_TEST_CHECK(view.GetItem(3) == itemActor);
+
+ // scroll to the end of item view
+ view.ScrollToItem(TOTAL_ITEM_NUMBER - 1, 0.00f);
+
+ application.SendNotification();
+ application.Render(0);
+
+ // Refresh the item view
+ view.Refresh();
+
+ Actor itemActorID390 = view.GetItem(390);
+ DALI_TEST_CHECK(view.GetItemId(itemActorID390) == 390);
+
+ // Insert the item with ID 2 (which is now before the current item range)
+ Actor anotherNewActor = Actor::New();
+ view.InsertItem(Item(id, anotherNewActor), 0.0f);
+
+ // Check that item ID 391 now represents the original item with ID 390
+ DALI_TEST_CHECK(view.GetItemId(itemActorID390) == 391);
+ DALI_TEST_CHECK(view.GetItem(391) == itemActorID390);
+
END_TEST;
}
unsigned int itemCount = view.GetChildCount();
+ // Get the specified item where new items to be inserted before that
+ Actor itemActor = view.GetItem(1);
+
+ // Check we are getting the correct Item ID given the specified item
+ DALI_TEST_CHECK(view.GetItemId(itemActor) == 1);
+
ItemContainer insertList;
- for( unsigned int i = 0u; i < 10; ++i )
+ for( unsigned int i = 1u; i < 11; ++i )
{
Actor child = view.GetChildAt( i );
Actor newActor = Actor::New();
DALI_TEST_CHECK(view.GetChildCount() == itemCount + 10);
+ // Check that new items are inserted in the correct positions
+ DALI_TEST_CHECK(view.GetItemId(itemActor) == 11);
+ DALI_TEST_CHECK(view.GetItem(11) == itemActor);
+
ItemIdContainer removeList;
for( unsigned int i = 0u; i < view.GetChildCount(); ++i )
}
DALI_TEST_CHECK(view.GetChildCount() == itemCount);
+
+ // Check that new items are removed correctly so that we are getting the correct Item ID given the specified item
+ DALI_TEST_CHECK(view.GetItemId(itemActor) == 1);
+ DALI_TEST_CHECK(view.GetItem(1) == itemActor);
+
END_TEST;
}
Actor newActor = Actor::New();
- view.ReplaceItem( Item( 0, newActor ), 0.5f );
+ view.ReplaceItem( Item( 5, newActor ), 0.5f );
+
+ DALI_TEST_CHECK(view.GetItem(5) == newActor);
- DALI_TEST_CHECK(view.GetItem(0) == newActor);
END_TEST;
}
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