X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit-unmanaged%2Futc-Dali-TableView.cpp;h=fe75b1ddad6188b3f171a438806e4f8773e64ebb;hp=d46f57d9a9d07cd6a15deee6d327ecf45e79bf34;hb=93fb6a1d3dc8872275bde30ef6a05407a67d694c;hpb=fa6279fb2830427d5ab569ca14e6ade1557ef2fa diff --git a/automated-tests/src/dali-toolkit-unmanaged/utc-Dali-TableView.cpp b/automated-tests/src/dali-toolkit-unmanaged/utc-Dali-TableView.cpp index d46f57d..fe75b1d 100644 --- a/automated-tests/src/dali-toolkit-unmanaged/utc-Dali-TableView.cpp +++ b/automated-tests/src/dali-toolkit-unmanaged/utc-Dali-TableView.cpp @@ -1,18 +1,19 @@ -// -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://floralicense.org/license/ -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// +/* + * Copyright (c) 2014 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ #include #include @@ -34,6 +35,15 @@ void dali_tableview_cleanup(void) namespace { + +const char* const PROPERTY_NAME_ROWS = "rows"; +const char* const PROPERTY_NAME_COLUMNS = "columns"; +const char* const PROPERTY_NAME_CELL_PADDING = "cell-padding"; +const char* const PROPERTY_NAME_LAYOUT_ANIMATION_DURATION = "layout-animation-duration"; +const char* const PROPERTY_NAME_LAYOUT_ROWS = "layout-rows"; +const char* const PROPERTY_NAME_LAYOUT_COLUMNS = "layout-columns"; + + static bool gObjectCreatedCallBackCalled; static void TestCallback(BaseHandle handle) @@ -540,3 +550,146 @@ int UtcDaliTableViewMetricsAssert(void) } END_TEST; } + +int UtcDaliTableViewSetGetProperty(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliTableViewSetGetProperty"); + + // Create a 1x1 table-view + TableView tableView = TableView::New(1,1); + tableView.ApplyConstraint( Constraint::New( Actor::SIZE, Constraint100() ) ); + DALI_TEST_CHECK( tableView ); + + // Test "rows" property + DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_ROWS ) == TableView::PROPERTY_ROWS ); + + tableView.SetProperty( TableView::PROPERTY_ROWS, 4u ); + + DALI_TEST_CHECK( tableView.GetRows() == 4u ); + DALI_TEST_CHECK( tableView.GetProperty(TableView::PROPERTY_ROWS).Get() == 4u ); + + // Test "columns" property + DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_COLUMNS ) == TableView::PROPERTY_COLUMNS ); + + tableView.SetProperty( TableView::PROPERTY_COLUMNS, 5u ); + + DALI_TEST_CHECK( tableView.GetColumns() == 5u ); + DALI_TEST_CHECK( tableView.GetProperty(TableView::PROPERTY_COLUMNS).Get() == 5u ); + + // Test "cell-padding" property + DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_CELL_PADDING ) == TableView::PROPERTY_CELL_PADDING ); + + tableView.SetProperty( TableView::PROPERTY_CELL_PADDING, Size( 6.f, 8.f ) ); + + DALI_TEST_EQUALS( tableView.GetCellPadding(), Size(6.f, 8.f), TEST_LOCATION ); + DALI_TEST_EQUALS( tableView.GetProperty(TableView::PROPERTY_CELL_PADDING).Get(), Vector2(6.f,8.f), TEST_LOCATION ); + + // Test "layout-animation-duration" property + DALI_TEST_CHECK( tableView.GetPropertyIndex(PROPERTY_NAME_LAYOUT_ANIMATION_DURATION) == TableView::PROPERTY_LAYOUT_ANIMATION_DURATION ); + + tableView.SetProperty( TableView::PROPERTY_LAYOUT_ANIMATION_DURATION, 1.5f ); + + DALI_TEST_EQUALS( tableView.GetLayoutAnimationDuration(), 1.5f, TEST_LOCATION ); + DALI_TEST_EQUALS( tableView.GetProperty(TableView::PROPERTY_LAYOUT_ANIMATION_DURATION).Get(), 1.5f, TEST_LOCATION ); + + //{ "policy": "fixed", "value": 30.0 }, + Property::Map item1; + item1[ "policy" ] = "fixed"; + item1[ "value" ] = 30.f; + //{ "policy": "relative", "value": 0.2 }, + Property::Map item2; + item2[ "policy" ] = "relative"; + item2[ "value" ] = 0.2f; + + // Test "layout-rows" property + DALI_TEST_CHECK( tableView.GetPropertyIndex(PROPERTY_NAME_LAYOUT_ROWS) == TableView::PROPERTY_LAYOUT_ROWS ); + + /* + * "layout-rows": + * { + * "1": { "policy": "fixed", "value": 30 }, + * "3": { "policy": "relative", "value": 0.2 } + * } + */ + Property::Map layoutRows; + layoutRows[ "1" ] = item1; + layoutRows[ "3" ] = item2; + tableView.SetProperty( TableView::PROPERTY_LAYOUT_ROWS, layoutRows ); + + DALI_TEST_EQUALS( tableView.GetFixedHeight( 1u ), 30.f, TEST_LOCATION ); + DALI_TEST_EQUALS( tableView.GetRelativeHeight( 3u ), 0.2f, TEST_LOCATION ); + + Property::Map layoutRowsGet = tableView.GetProperty(TableView::PROPERTY_LAYOUT_ROWS).Get(); + DALI_TEST_CHECK( layoutRowsGet.GetKey(0).compare(layoutRows.GetKey(0)) == 0 ); + DALI_TEST_CHECK( layoutRowsGet.GetValue(0).GetValue( "policy" ).Get().compare(layoutRows.GetValue(0).GetValue( "policy" ).Get()) == 0 ); + DALI_TEST_EQUALS( layoutRowsGet.GetValue(0).GetValue( "value" ).Get(),layoutRows.GetValue(0).GetValue( "value" ).Get(), TEST_LOCATION ); + DALI_TEST_CHECK( layoutRowsGet.GetKey(1).compare(layoutRows.GetKey(1)) == 0 ); + DALI_TEST_CHECK( layoutRowsGet.GetValue(1).GetValue( "policy" ).Get().compare(layoutRows.GetValue(1).GetValue( "policy" ).Get()) == 0 ); + DALI_TEST_EQUALS( layoutRowsGet.GetValue(1).GetValue( "value" ).Get(),layoutRows.GetValue(1).GetValue( "value" ).Get(), TEST_LOCATION ); + + // Test "layout-columns" property + DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_LAYOUT_COLUMNS ) == TableView::PROPERTY_LAYOUT_COLUMNS ); + + /* + * "layout-columns": + * { + * "2": { "policy": "relative", "value": 0.2 }, + * "3": { "policy": "fixed", "value": 30 } + * } + */ + Property::Map layoutColumns; + layoutColumns[ "2" ] = item2; + layoutColumns[ "3" ] = item1; + tableView.SetProperty( TableView::PROPERTY_LAYOUT_COLUMNS, layoutColumns ); + + DALI_TEST_EQUALS( tableView.GetRelativeWidth( 2u ), 0.2f, TEST_LOCATION ); + DALI_TEST_EQUALS( tableView.GetFixedWidth( 3u ), 30.f, TEST_LOCATION ); + + Property::Map layoutColumnsGet = tableView.GetProperty(TableView::PROPERTY_LAYOUT_COLUMNS).Get(); + DALI_TEST_CHECK( layoutColumnsGet.GetKey(0).compare(layoutColumns.GetKey(0)) == 0 ); + DALI_TEST_CHECK( layoutColumnsGet.GetValue(0).GetValue( "policy" ).Get().compare(layoutColumns.GetValue(0).GetValue( "policy" ).Get()) == 0 ); + DALI_TEST_EQUALS( layoutColumnsGet.GetValue(0).GetValue( "value" ).Get(),layoutColumns.GetValue(0).GetValue( "value" ).Get(), TEST_LOCATION ); + DALI_TEST_CHECK( layoutColumnsGet.GetKey(1).compare(layoutColumns.GetKey(1)) == 0 ); + DALI_TEST_CHECK( layoutColumnsGet.GetValue(1).GetValue( "policy" ).Get().compare(layoutColumns.GetValue(1).GetValue( "policy" ).Get()) == 0 ); + DALI_TEST_EQUALS( layoutColumnsGet.GetValue(1).GetValue( "value" ).Get(),layoutColumns.GetValue(1).GetValue( "value" ).Get(), TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliTableViewCustomProperties(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliTableViewCustomProperties"); + + // Create a 10x10 table-view + TableView tableView = TableView::New(10,10); + tableView.ApplyConstraint( Constraint::New( Actor::SIZE, Constraint100() ) ); + DALI_TEST_CHECK( tableView ); + + // Create a child actor with the custom properties + Actor child1 = Actor::New(); + child1.RegisterProperty( TableView::CELL_INDICES_PROPERTY_NAME, Vector2( 3, 4 ) ); + tableView.Add( child1 ); + // Check for actors at actual positions. + DALI_TEST_CHECK( tableView.GetChildAt(TableView::CellPosition(3,4)) == child1); + + // Create a second child actor with the custom properties + Actor child2 = Actor::New(); + float rowSpan = 3.f; + float columnSpan = 2.f; + child2.RegisterProperty( TableView::CELL_INDICES_PROPERTY_NAME, Vector2( 6, 1 ) ); + child2.RegisterProperty( TableView::ROW_SPAN_PROPERTY_NAME, rowSpan ); + child2.RegisterProperty( TableView::COLUMN_SPAN_PROPERTY_NAME, columnSpan ); + tableView.Add( child2 ); + // Check for actors at actual positions. + for( int i=0; i