2 * Copyright (c) 2014 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 <dali-toolkit-test-suite-utils.h>
21 #include <dali-toolkit/dali-toolkit.h>
22 #include <dali-toolkit/devel-api/controls/table-view/table-view.h>
25 using namespace Toolkit;
27 void dali_tableview_startup(void)
29 test_return_value = TET_UNDEF;
32 void dali_tableview_cleanup(void)
34 test_return_value = TET_PASS;
40 const char* const PROPERTY_NAME_ROWS = "rows";
41 const char* const PROPERTY_NAME_COLUMNS = "columns";
42 const char* const PROPERTY_NAME_CELL_PADDING = "cell-padding";
43 const char* const PROPERTY_NAME_LAYOUT_ROWS = "layout-rows";
44 const char* const PROPERTY_NAME_LAYOUT_COLUMNS = "layout-columns";
46 static bool gObjectCreatedCallBackCalled;
48 static void TestCallback(BaseHandle handle)
50 gObjectCreatedCallBackCalled = true;
60 * function operator to apply the parent size
62 void operator()( Dali::Vector3& current, const PropertyInputContainer& /* inputs */ )
64 current.x = current.y = current.z = 100.0f;
68 // Convenience function to quickly set up a 10x10 table with each cell being 10x10 pixels in size by default.
69 static void SetupTableViewAndActors(TableView& tableView, Actor& actor1, Actor& actor2, Actor& actor3)
71 tableView = TableView::New( 10, 10 ); // 10 by 10 grid.
72 DALI_TEST_CHECK( tableView );
74 Stage::GetCurrent().Add( tableView );
75 tableView.SetSize( Dali::Vector2( 100.0f, 100.0f ) );
77 actor1 = Actor::New();
78 actor2 = Actor::New();
79 actor3 = Actor::New();
81 actor1.SetSize( Dali::Vector2( 10, 10 ) );
82 actor2.SetSize( Dali::Vector2( 10, 10 ) );
83 actor3.SetSize( Dali::Vector2( 10, 10 ) );
85 tableView.AddChild( actor1, TableView::CellPosition( 0, 0 ) );
86 tableView.AddChild( actor2, TableView::CellPosition( 0, 1 ) );
87 tableView.AddChild( actor3, TableView::CellPosition( 1, 0 ) );
92 int UtcDaliTableViewNew(void)
94 ToolkitTestApplication application;
96 TableView tableView = TableView::New(10,10);
97 DALI_TEST_CHECK(tableView);
99 //Additional check to ensure object is created by checking if it's registered
100 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
101 DALI_TEST_CHECK( registry );
103 gObjectCreatedCallBackCalled = false;
104 registry.ObjectCreatedSignal().Connect(&TestCallback);
106 TableView tableView = TableView::New(10,10);
108 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
112 // Test adjusting the metric values for the cell.
113 int UtcDaliTableViewMetricsPadding(void)
115 ToolkitTestApplication application;
117 tet_infoline("UtcDaliTableViewMetricsPadding");
124 SetupTableViewAndActors(tableView, actor1, actor2, actor3);
126 // 1. check that padding works. no padding:
127 tableView.SetCellPadding(Size(0.0f, 0.0f));
128 application.SendNotification();
129 application.Render();
131 DALI_TEST_EQUALS( tableView.GetCellPadding(), Size(0.0f, 0.0f), TEST_LOCATION );
132 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
133 DALI_TEST_EQUALS( actor2.GetCurrentPosition(), Vector3(10.0f, 0.0f, 0.0f), TEST_LOCATION );
134 DALI_TEST_EQUALS( actor3.GetCurrentPosition(), Vector3(0.0f, 10.0f, 0.0f), TEST_LOCATION );
136 // 1. check that padding works. some padding:
137 tableView.SetCellPadding(Size(5.0f, 10.0f));
138 application.SendNotification();
139 application.Render();
141 DALI_TEST_EQUALS( tableView.GetCellPadding(), Size(5.0f, 10.0f), TEST_LOCATION );
142 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(5.0f, 10.0f, 0.0f), TEST_LOCATION );
146 // Test adjusting the metric values for the cell.
147 int UtcDaliTableViewMetricsFixed(void)
149 ToolkitTestApplication application;
151 tet_infoline("UtcDaliTableViewMetricsFixed");
158 SetupTableViewAndActors(tableView, actor1, actor2, actor3);
159 application.SendNotification();
160 application.Render();
162 // 1. check that with no fixed width/heights, actors are in default position.
163 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
164 DALI_TEST_EQUALS( actor2.GetCurrentPosition(), Vector3(10.0f, 0.0f, 0.0f), TEST_LOCATION );
165 DALI_TEST_EQUALS( actor3.GetCurrentPosition(), Vector3(0.0f, 10.0f, 0.0f), TEST_LOCATION );
167 // 2. check that with a fixed width & height, actors to the right and below are offsetted.
168 tableView.SetFixedWidth(0, 20.0f);
169 tableView.SetFixedHeight(0, 50.0f);
170 DALI_TEST_EQUALS( tableView.GetFixedWidth(0), 20.0f, TEST_LOCATION );
171 DALI_TEST_EQUALS( tableView.GetFixedHeight(0), 50.0f, TEST_LOCATION );
173 application.SendNotification();
174 application.Render();
176 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
177 DALI_TEST_EQUALS( actor2.GetCurrentPosition(), Vector3(20.0f, 0.0f, 0.0f), TEST_LOCATION );
178 DALI_TEST_EQUALS( actor3.GetCurrentPosition(), Vector3(0.0f, 50.0f, 0.0f), TEST_LOCATION );
182 // Test adjusting the metric values for the cell.
183 int UtcDaliTableViewMetricsRelative(void)
185 ToolkitTestApplication application;
187 tet_infoline("UtcDaliTableViewMetricsRelative");
194 SetupTableViewAndActors(tableView, actor1, actor2, actor3);
195 application.SendNotification();
196 application.Render();
198 // 1. check that with no relative width/heights, actors are in default position.
199 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
200 DALI_TEST_EQUALS( actor2.GetCurrentPosition(), Vector3(10.0f, 0.0f, 0.0f), TEST_LOCATION );
201 DALI_TEST_EQUALS( actor3.GetCurrentPosition(), Vector3(0.0f, 10.0f, 0.0f), TEST_LOCATION );
203 // 2. check that with a relative width & height, actors to the right and below are offsetted.
204 tableView.SetRelativeWidth(0, 0.3f); // cell 0,0 occupies 30%x50% of the grid (i.e. 30x50 pixels)
205 tableView.SetRelativeHeight(0, 0.5f);
206 DALI_TEST_EQUALS( tableView.GetRelativeWidth(0), 0.3f, TEST_LOCATION );
207 DALI_TEST_EQUALS( tableView.GetRelativeHeight(0), 0.5f, TEST_LOCATION );
209 application.SendNotification();
210 application.Render();
212 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
213 DALI_TEST_EQUALS( actor2.GetCurrentPosition(), Vector3(30.0f, 0.0f, 0.0f), TEST_LOCATION );
214 DALI_TEST_EQUALS( actor3.GetCurrentPosition(), Vector3(0.0f, 50.0f, 0.0f), TEST_LOCATION );
219 // Test Adding/Removing/Finding Children.
220 int UtcDaliTableViewChild(void)
222 ToolkitTestApplication application;
224 tet_infoline("UtcDaliTableViewChild");
226 // Create a 10x10 table-view
227 TableView tableView = TableView::New(10,10);
228 DALI_TEST_CHECK( tableView );
230 // Check if actor doesn't exist.
231 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(0,0)) );
233 // Add an actor to it at 0,0
234 Actor actor = Actor::New();
235 tableView.AddChild(actor, TableView::CellPosition());
238 DALI_TEST_CHECK( tableView.GetChildAt(TableView::CellPosition(0,0)) );
241 tableView.RemoveChildAt(TableView::CellPosition());
243 // Check if actor no longer exists.
244 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(0,0)) );
246 // Add actor to it again, but at 2,5
247 tableView.AddChild(actor, TableView::CellPosition(2,5));
249 // Add another actor somewhere else 7,8
250 Actor actor2 = Actor::New();
251 tableView.AddChild(actor2, TableView::CellPosition(7,8));
255 // Check that no actor exists in a few random places.
256 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(0,0)) );
257 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(2,1)) );
258 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(6,3)) );
259 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(9,5)) );
261 // Check for actors at actual positions.
262 searchActor = tableView.GetChildAt(TableView::CellPosition(2,5));
263 DALI_TEST_CHECK( searchActor == actor);
265 searchActor = tableView.GetChildAt(TableView::CellPosition(7,8));
266 DALI_TEST_CHECK( searchActor == actor2);
268 // Create a second table, and add already added Child to new one.
269 TableView tableView2 = TableView::New(5,5);
270 tableView2.AddChild(actor, TableView::CellPosition(2,2));
271 DALI_TEST_CHECK( tableView2.GetChildAt(TableView::CellPosition(2,2)) );
275 // Test calling Add on it's own (to invoke the OnChildAdd)
276 int UtcDaliTableViewAdd(void)
278 ToolkitTestApplication application;
280 tet_infoline("UtcDaliTableViewAdd");
282 // Create a 4x1 table-view, and just keep adding.
283 TableView tableView = TableView::New(1,4);
284 DALI_TEST_CHECK( tableView );
286 for(unsigned int i = 0;i<16;i++)
288 Actor currentActor = Actor::New();
289 TableView::CellPosition position = TableView::CellPosition();
290 tableView.Add( currentActor );
291 tableView.FindChildPosition(currentActor, position);
292 tet_printf("%dx%d (%d,%d)\n", tableView.GetColumns(), tableView.GetRows(), position.columnIndex, position.rowIndex);
294 DALI_TEST_EQUALS((position.rowIndex * 4 + position.columnIndex), i, TEST_LOCATION);
299 // Test cell modification.
300 int UtcDaliTableViewCells(void)
302 ToolkitTestApplication application;
303 tet_infoline("UtcDaliTableViewCells");
305 // Create a 10x10 table-view
306 TableView tableView = TableView::New(10,10);
307 DALI_TEST_CHECK( tableView );
309 // Add a few actors to the table.
310 Actor actor1 = Actor::New();
311 Actor actor2 = Actor::New();
312 Actor actor3 = Actor::New();
313 actor1.SetName("Actor1");
314 actor2.SetName("Actor2");
315 actor3.SetName("Actor3");
317 // note: positions are specified in reversed cartesian coords - row,col (i.e. y,x)
318 tableView.AddChild(actor1, TableView::CellPosition(0,0));
319 tableView.AddChild(actor2, TableView::CellPosition(5,5));
320 tableView.AddChild(actor3, TableView::CellPosition(7,2));
322 DALI_TEST_CHECK( tableView.GetRows() == 10 && tableView.GetColumns() == 10 );
324 // Add a row between actor1 and actor2 | insert column on actor1 and see what happens...
325 tableView.InsertRow(3);
326 tableView.InsertColumn(0);
327 DALI_TEST_CHECK( tableView.GetRows() == 11 && tableView.GetColumns() == 11 );
329 TableView::CellPosition cellPosition;
332 result = tableView.FindChildPosition(actor1, cellPosition);
333 DALI_TEST_CHECK( result && cellPosition.rowIndex == 0 && cellPosition.columnIndex == 1);
334 result = tableView.FindChildPosition(actor2, cellPosition);
335 DALI_TEST_CHECK( result && cellPosition.rowIndex == 6 && cellPosition.columnIndex == 6);
336 result = tableView.FindChildPosition(actor3, cellPosition);
337 DALI_TEST_CHECK( result && cellPosition.rowIndex == 8 && cellPosition.columnIndex == 3);
339 // Delete a row between actor2 and actor3 | delete column on actor2 and see what happens...
340 tableView.DeleteRow(7);
341 tableView.DeleteColumn(6);
342 DALI_TEST_CHECK( tableView.GetRows() == 10 && tableView.GetColumns() == 10 );
344 result = tableView.FindChildPosition(actor1, cellPosition);
345 DALI_TEST_CHECK( result && cellPosition.rowIndex == 0 && cellPosition.columnIndex == 1);
346 result = tableView.FindChildPosition(actor2, cellPosition);
347 DALI_TEST_CHECK( !result );
348 result = tableView.FindChildPosition(actor3, cellPosition);
349 DALI_TEST_CHECK( result && cellPosition.rowIndex == 7 && cellPosition.columnIndex == 3);
351 // Delete the other two remaining actors by a row delete and a column delete.
352 std::vector<Actor> actorsRemoved;
353 tableView.DeleteRow(0, actorsRemoved);
354 tet_printf("Row Delete >> Actors Removed: %d {", actorsRemoved.size());
355 for(size_t i = 0;i<actorsRemoved.size();i++) tet_printf("%d => %s, ", i, actorsRemoved[i].GetName().c_str());
357 DALI_TEST_EQUALS( static_cast<int>(actorsRemoved.size()), 1, TEST_LOCATION );
358 DALI_TEST_CHECK( actorsRemoved[0] == actor1 );
360 actorsRemoved.clear();
361 tableView.DeleteColumn(3, actorsRemoved);
362 tet_printf("Column Delete >> Actors Removed: %d {", actorsRemoved.size());
363 for(size_t i = 0;i<actorsRemoved.size();i++) tet_printf("%d => %s, ", i, actorsRemoved[i].GetName().c_str());
365 DALI_TEST_EQUALS( static_cast<int>(actorsRemoved.size()), 1, TEST_LOCATION );
366 DALI_TEST_CHECK( actorsRemoved[0] == actor3 );
368 DALI_TEST_CHECK( tableView.GetRows() == 9 && tableView.GetColumns() == 9 );
370 tableView.AddChild(actor1, TableView::CellPosition(5,8));
371 tableView.Resize(100,100);
372 DALI_TEST_CHECK( tableView.GetRows() == 100 && tableView.GetColumns() == 100 );
374 tableView.AddChild(actor2, TableView::CellPosition(69,57));
375 DALI_TEST_CHECK( tableView.FindChildPosition(actor1, cellPosition) && tableView.FindChildPosition(actor2, cellPosition) );
377 tableView.Resize(20,20);
378 DALI_TEST_CHECK( tableView.FindChildPosition(actor1, cellPosition) && !tableView.FindChildPosition(actor2, cellPosition) );
380 actorsRemoved.clear();
381 tableView.Resize(1,1, actorsRemoved);
382 DALI_TEST_CHECK( !tableView.FindChildPosition(actor1, cellPosition) && !tableView.FindChildPosition(actor2, cellPosition) );
383 DALI_TEST_EQUALS( static_cast<int>(actorsRemoved.size()), 1, TEST_LOCATION );
384 DALI_TEST_CHECK( actorsRemoved[0] == actor1 );
386 // Add child outside table size, forcing a resize.
387 tableView.AddChild(actor1, TableView::CellPosition(100, 100, 1, 1));
388 DALI_TEST_CHECK( tableView.GetRows() == 101 && tableView.GetColumns() == 101 );
390 // Add child outside table size, forcing a resize.
391 tableView.AddChild(actor1, TableView::CellPosition(110, 110, 5, 5));
392 DALI_TEST_CHECK( tableView.GetRows() == 115 && tableView.GetColumns() == 115 );
394 DALI_TEST_CHECK( true );
398 int UtcDaliTableViewChildAssert(void)
400 ToolkitTestApplication application;
401 tet_infoline("UtcDaliTableViewChildAssert");
403 // Create a 10x10 table-view
404 TableView tableView = TableView::New(10,10);
405 DALI_TEST_CHECK( tableView );
410 tableView.AddChild( childActor, TableView::CellPosition(0,0,5,5) );
412 tet_result(TET_FAIL);
414 catch( Dali::DaliException& e )
416 DALI_TEST_PRINT_ASSERT( e );
417 DALI_TEST_EQUALS(e.condition, "child", TEST_LOCATION);
422 int UtcDaliTableViewMetricsAssert(void)
424 ToolkitTestApplication application;
425 tet_infoline("UtcDaliTableViewChildAssert");
427 // Create a 10x10 table-view
428 TableView tableView = TableView::New(10,10);
429 DALI_TEST_CHECK( tableView );
435 tableView.SetFixedHeight( 10, 1.0f );
437 tet_result(TET_FAIL);
439 catch( Dali::DaliException& e )
441 DALI_TEST_PRINT_ASSERT( e );
442 DALI_TEST_EQUALS(e.condition, "rowIndex < mRowData.Size()", TEST_LOCATION);
447 tableView.GetFixedHeight( 10 );
449 tet_result(TET_FAIL);
451 catch( Dali::DaliException& e )
453 DALI_TEST_PRINT_ASSERT( e );
454 DALI_TEST_EQUALS(e.condition, "rowIndex < mRowData.Size()", TEST_LOCATION);
459 tableView.SetFixedWidth( 10, 1.0f );
461 tet_result(TET_FAIL);
463 catch( Dali::DaliException& e )
465 DALI_TEST_PRINT_ASSERT( e );
466 DALI_TEST_EQUALS(e.condition, "columnIndex < mColumnData.Size()", TEST_LOCATION);
471 tableView.GetFixedWidth( 10 );
473 tet_result(TET_FAIL);
475 catch( Dali::DaliException& e )
477 DALI_TEST_PRINT_ASSERT( e );
478 DALI_TEST_EQUALS(e.condition, "columnIndex < mColumnData.Size()", TEST_LOCATION);
485 tableView.SetRelativeHeight( 10, 0.1f );
487 tet_result(TET_FAIL);
489 catch( Dali::DaliException& e )
491 DALI_TEST_PRINT_ASSERT( e );
492 DALI_TEST_EQUALS(e.condition, "rowIndex < mRowData.Size()", TEST_LOCATION);
497 tableView.GetRelativeHeight( 10 );
499 tet_result(TET_FAIL);
501 catch( Dali::DaliException& e )
503 DALI_TEST_PRINT_ASSERT( e );
504 DALI_TEST_EQUALS(e.condition, "rowIndex < mRowData.Size()", TEST_LOCATION);
509 tableView.SetRelativeWidth( 10, 0.1f );
511 tet_result(TET_FAIL);
513 catch( Dali::DaliException& e )
515 DALI_TEST_PRINT_ASSERT( e );
516 DALI_TEST_EQUALS(e.condition, "columnIndex < mColumnData.Size()", TEST_LOCATION);
521 tableView.GetRelativeWidth( 10 );
523 tet_result(TET_FAIL);
525 catch( Dali::DaliException& e )
527 DALI_TEST_PRINT_ASSERT( e );
528 DALI_TEST_EQUALS(e.condition, "columnIndex < mColumnData.Size()", TEST_LOCATION);
533 int UtcDaliTableViewSetGetProperty(void)
535 ToolkitTestApplication application;
536 tet_infoline("UtcDaliTableViewSetGetProperty");
538 // Create a 1x1 table-view
539 TableView tableView = TableView::New(1,1);
540 tableView.SetSize( Vector2( 100.0f, 100.0f ) );
541 DALI_TEST_CHECK( tableView );
543 // Test "rows" property
544 DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_ROWS ) == TableView::Property::ROWS );
546 tableView.SetProperty( TableView::Property::ROWS, 4u );
548 DALI_TEST_CHECK( tableView.GetRows() == 4u );
549 DALI_TEST_CHECK( tableView.GetProperty(TableView::Property::ROWS).Get<unsigned int>() == 4u );
551 // Test "columns" property
552 DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_COLUMNS ) == TableView::Property::COLUMNS );
554 tableView.SetProperty( TableView::Property::COLUMNS, 5u );
556 DALI_TEST_CHECK( tableView.GetColumns() == 5u );
557 DALI_TEST_CHECK( tableView.GetProperty(TableView::Property::COLUMNS).Get<unsigned int>() == 5u );
559 // Test "cell-padding" property
560 DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_CELL_PADDING ) == TableView::Property::CELL_PADDING );
562 tableView.SetProperty( TableView::Property::CELL_PADDING, Size( 6.f, 8.f ) );
564 DALI_TEST_EQUALS( tableView.GetCellPadding(), Size(6.f, 8.f), TEST_LOCATION );
565 DALI_TEST_EQUALS( tableView.GetProperty(TableView::Property::CELL_PADDING).Get<Vector2>(), Vector2(6.f,8.f), TEST_LOCATION );
567 //{ "policy": "fixed", "value": 30.0 },
569 item1[ "policy" ] = "fixed";
570 item1[ "value" ] = 30.f;
571 //{ "policy": "relative", "value": 0.2 },
573 item2[ "policy" ] = "relative";
574 item2[ "value" ] = 0.2f;
576 // Test "layout-rows" property
577 DALI_TEST_CHECK( tableView.GetPropertyIndex(PROPERTY_NAME_LAYOUT_ROWS) == TableView::Property::LAYOUT_ROWS );
582 * "1": { "policy": "fixed", "value": 30 },
583 * "3": { "policy": "relative", "value": 0.2 }
586 Property::Map layoutRows;
587 layoutRows[ "1" ] = item1;
588 layoutRows[ "3" ] = item2;
589 tableView.SetProperty( TableView::Property::LAYOUT_ROWS, layoutRows );
591 DALI_TEST_EQUALS( tableView.GetFixedHeight( 1u ), 30.f, TEST_LOCATION );
592 DALI_TEST_EQUALS( tableView.GetRelativeHeight( 3u ), 0.2f, TEST_LOCATION );
594 Property::Map layoutRowsGet = tableView.GetProperty(TableView::Property::LAYOUT_ROWS).Get<Property::Map>();
596 DALI_TEST_EQUALS( layoutRowsGet.GetKey(1).compare(layoutRows.GetKey(0)), 0, TEST_LOCATION );
597 DALI_TEST_CHECK( layoutRowsGet.GetValue(1).GetValue( "policy" ).Get<std::string>().compare(layoutRows.GetValue(0).GetValue( "policy" ).Get<std::string>()) == 0 );
598 DALI_TEST_EQUALS( layoutRowsGet.GetValue(1).GetValue( "value" ).Get<float>(), layoutRows.GetValue(0).GetValue( "value" ).Get<float>(), TEST_LOCATION );
600 DALI_TEST_CHECK( layoutRowsGet.GetKey(3).compare(layoutRows.GetKey(1)) == 0 );
601 DALI_TEST_CHECK( layoutRowsGet.GetValue(3).GetValue( "policy" ).Get<std::string>().compare(layoutRows.GetValue(1).GetValue( "policy" ).Get<std::string>()) == 0 );
602 DALI_TEST_EQUALS( layoutRowsGet.GetValue(3).GetValue( "value" ).Get<float>(), layoutRows.GetValue(1).GetValue( "value" ).Get<float>(), TEST_LOCATION );
604 // Test "layout-columns" property
605 DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_LAYOUT_COLUMNS ) == TableView::Property::LAYOUT_COLUMNS );
610 * "2": { "policy": "relative", "value": 0.2 },
611 * "3": { "policy": "fixed", "value": 30 }
614 Property::Map layoutColumns;
615 layoutColumns[ "2" ] = item2;
616 layoutColumns[ "3" ] = item1;
617 tableView.SetProperty( TableView::Property::LAYOUT_COLUMNS, layoutColumns );
619 DALI_TEST_EQUALS( tableView.GetRelativeWidth( 2u ), 0.2f, TEST_LOCATION );
620 DALI_TEST_EQUALS( tableView.GetFixedWidth( 3u ), 30.f, TEST_LOCATION );
622 Property::Map layoutColumnsGet = tableView.GetProperty(TableView::Property::LAYOUT_COLUMNS).Get<Property::Map>();
623 DALI_TEST_CHECK( layoutColumnsGet.GetKey(2).compare(layoutColumns.GetKey(0)) == 0 );
624 DALI_TEST_CHECK( layoutColumnsGet.GetValue(2).GetValue( "policy" ).Get<std::string>().compare(layoutColumns.GetValue(0).GetValue( "policy" ).Get<std::string>()) == 0 );
625 DALI_TEST_EQUALS( layoutColumnsGet.GetValue(2).GetValue( "value" ).Get<float>(),layoutColumns.GetValue(0).GetValue( "value" ).Get<float>(), TEST_LOCATION );
627 DALI_TEST_CHECK( layoutColumnsGet.GetKey(3).compare(layoutColumns.GetKey(1)) == 0 );
628 DALI_TEST_CHECK( layoutColumnsGet.GetValue(3).GetValue( "policy" ).Get<std::string>().compare(layoutColumns.GetValue(1).GetValue( "policy" ).Get<std::string>()) == 0 );
629 DALI_TEST_EQUALS( layoutColumnsGet.GetValue(3).GetValue( "value" ).Get<float>(),layoutColumns.GetValue(1).GetValue( "value" ).Get<float>(), TEST_LOCATION );
634 int UtcDaliTableViewCustomProperties(void)
636 ToolkitTestApplication application;
637 tet_infoline("UtcDaliTableViewCustomProperties");
639 // Create a 10x10 table-view
640 TableView tableView = TableView::New(10,10);
641 Constraint constraint = Constraint::New<Vector3>( tableView, Actor::Property::SIZE, Constraint100() );
643 DALI_TEST_CHECK( tableView );
645 // Create a child actor with the custom properties
646 Actor child1 = Actor::New();
647 child1.RegisterProperty( TableView::CELL_INDICES_PROPERTY_NAME, Vector2( 3, 4 ) );
648 tableView.Add( child1 );
649 // Check for actors at actual positions.
650 DALI_TEST_CHECK( tableView.GetChildAt(TableView::CellPosition(3,4)) == child1);
652 // Create a second child actor with the custom properties
653 Actor child2 = Actor::New();
655 float columnSpan = 2.f;
656 child2.RegisterProperty( TableView::CELL_INDICES_PROPERTY_NAME, Vector2( 6, 1 ) );
657 child2.RegisterProperty( TableView::ROW_SPAN_PROPERTY_NAME, rowSpan );
658 child2.RegisterProperty( TableView::COLUMN_SPAN_PROPERTY_NAME, columnSpan );
659 tableView.Add( child2 );
660 // Check for actors at actual positions.
661 for( int i=0; i<rowSpan; i++ )
663 for(int j=0; j<columnSpan; j++)
665 DALI_TEST_CHECK( tableView.GetChildAt(TableView::CellPosition(6+i,1+j)) == child2);