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>
24 using namespace Toolkit;
26 void dali_tableview_startup(void)
28 test_return_value = TET_UNDEF;
31 void dali_tableview_cleanup(void)
33 test_return_value = TET_PASS;
39 const char* const PROPERTY_NAME_ROWS = "rows";
40 const char* const PROPERTY_NAME_COLUMNS = "columns";
41 const char* const PROPERTY_NAME_CELL_PADDING = "cell-padding";
42 const char* const PROPERTY_NAME_LAYOUT_ROWS = "layout-rows";
43 const char* const PROPERTY_NAME_LAYOUT_COLUMNS = "layout-columns";
46 static bool gObjectCreatedCallBackCalled;
48 static void TestCallback(BaseHandle handle)
50 gObjectCreatedCallBackCalled = true;
61 * function operator to apply the parent size
63 Dali::Vector3 operator()(const Dali::Vector3& current)
65 return Dali::Vector3( 100.0f, 100.0f, 100.0f );
69 // Convenience function to quickly set up a 10x10 table with each cell being 10x10 pixels in size by default.
70 static void SetupTableViewAndActors(TableView& tableView, Actor& actor1, Actor& actor2, Actor& actor3)
72 tableView = TableView::New(10,10); // 10 by 10 grid.
73 DALI_TEST_CHECK(tableView);
75 Stage::GetCurrent().Add( tableView );
76 tableView.SetSize( Dali::Vector3( 100.0f, 100.0f, 100.0f ) );
78 actor1 = Actor::New();
79 actor2 = Actor::New();
80 actor3 = Actor::New();
82 actor1.SetSize(10,10);
83 actor2.SetSize(10,10);
84 actor3.SetSize(10,10);
86 tableView.AddChild(actor1, TableView::CellPosition(0,0));
87 tableView.AddChild(actor2, TableView::CellPosition(0,1));
88 tableView.AddChild(actor3, TableView::CellPosition(1,0));
94 int UtcDaliTableViewNew(void)
96 ToolkitTestApplication application;
98 TableView tableView = TableView::New(10,10);
99 DALI_TEST_CHECK(tableView);
101 //Additional check to ensure object is created by checking if it's registered
102 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
103 DALI_TEST_CHECK( registry );
105 gObjectCreatedCallBackCalled = false;
106 registry.ObjectCreatedSignal().Connect(&TestCallback);
108 TableView tableView = TableView::New(10,10);
110 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
114 // Test adjusting the metric values for the cell.
115 int UtcDaliTableViewMetricsPadding(void)
117 ToolkitTestApplication application;
119 tet_infoline("UtcDaliTableViewMetricsPadding");
126 SetupTableViewAndActors(tableView, actor1, actor2, actor3);
128 // 1. check that padding works. no padding:
129 tableView.SetCellPadding(Size(0.0f, 0.0f));
130 application.SendNotification();
131 application.Render();
133 DALI_TEST_EQUALS( tableView.GetCellPadding(), Size(0.0f, 0.0f), TEST_LOCATION );
134 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
135 DALI_TEST_EQUALS( actor2.GetCurrentPosition(), Vector3(10.0f, 0.0f, 0.0f), TEST_LOCATION );
136 DALI_TEST_EQUALS( actor3.GetCurrentPosition(), Vector3(0.0f, 10.0f, 0.0f), TEST_LOCATION );
138 // 1. check that padding works. some padding:
139 tableView.SetCellPadding(Size(5.0f, 10.0f));
140 application.SendNotification();
141 application.Render();
143 DALI_TEST_EQUALS( tableView.GetCellPadding(), Size(5.0f, 10.0f), TEST_LOCATION );
144 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(5.0f, 10.0f, 0.0f), TEST_LOCATION );
148 // Test adjusting the metric values for the cell.
149 int UtcDaliTableViewMetricsFixed(void)
151 ToolkitTestApplication application;
153 tet_infoline("UtcDaliTableViewMetricsFixed");
160 SetupTableViewAndActors(tableView, actor1, actor2, actor3);
161 application.SendNotification();
162 application.Render();
164 // 1. check that with no fixed width/heights, actors are in default position.
165 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
166 DALI_TEST_EQUALS( actor2.GetCurrentPosition(), Vector3(10.0f, 0.0f, 0.0f), TEST_LOCATION );
167 DALI_TEST_EQUALS( actor3.GetCurrentPosition(), Vector3(0.0f, 10.0f, 0.0f), TEST_LOCATION );
169 // 2. check that with a fixed width & height, actors to the right and below are offsetted.
170 tableView.SetFixedWidth(0, 20.0f);
171 tableView.SetFixedHeight(0, 50.0f);
172 DALI_TEST_EQUALS( tableView.GetFixedWidth(0), 20.0f, TEST_LOCATION );
173 DALI_TEST_EQUALS( tableView.GetFixedHeight(0), 50.0f, TEST_LOCATION );
175 application.SendNotification();
176 application.Render();
178 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
179 DALI_TEST_EQUALS( actor2.GetCurrentPosition(), Vector3(20.0f, 0.0f, 0.0f), TEST_LOCATION );
180 DALI_TEST_EQUALS( actor3.GetCurrentPosition(), Vector3(0.0f, 50.0f, 0.0f), TEST_LOCATION );
184 // Test adjusting the metric values for the cell.
185 int UtcDaliTableViewMetricsRelative(void)
187 ToolkitTestApplication application;
189 tet_infoline("UtcDaliTableViewMetricsRelative");
196 SetupTableViewAndActors(tableView, actor1, actor2, actor3);
197 application.SendNotification();
198 application.Render();
200 // 1. check that with no relative width/heights, actors are in default position.
201 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
202 DALI_TEST_EQUALS( actor2.GetCurrentPosition(), Vector3(10.0f, 0.0f, 0.0f), TEST_LOCATION );
203 DALI_TEST_EQUALS( actor3.GetCurrentPosition(), Vector3(0.0f, 10.0f, 0.0f), TEST_LOCATION );
205 // 2. check that with a relative width & height, actors to the right and below are offsetted.
206 tableView.SetRelativeWidth(0, 0.3f); // cell 0,0 occupies 30%x50% of the grid (i.e. 30x50 pixels)
207 tableView.SetRelativeHeight(0, 0.5f);
208 DALI_TEST_EQUALS( tableView.GetRelativeWidth(0), 0.3f, TEST_LOCATION );
209 DALI_TEST_EQUALS( tableView.GetRelativeHeight(0), 0.5f, TEST_LOCATION );
211 application.SendNotification();
212 application.Render();
214 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
215 DALI_TEST_EQUALS( actor2.GetCurrentPosition(), Vector3(30.0f, 0.0f, 0.0f), TEST_LOCATION );
216 DALI_TEST_EQUALS( actor3.GetCurrentPosition(), Vector3(0.0f, 50.0f, 0.0f), TEST_LOCATION );
221 // Test Adding/Removing/Finding Children.
222 int UtcDaliTableViewChild(void)
224 ToolkitTestApplication application;
226 tet_infoline("UtcDaliTableViewChild");
228 // Create a 10x10 table-view
229 TableView tableView = TableView::New(10,10);
230 DALI_TEST_CHECK( tableView );
232 // Check if actor doesn't exist.
233 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(0,0)) );
235 // Add an actor to it at 0,0
236 Actor actor = Actor::New();
237 tableView.AddChild(actor, TableView::CellPosition());
240 DALI_TEST_CHECK( tableView.GetChildAt(TableView::CellPosition(0,0)) );
243 tableView.RemoveChildAt(TableView::CellPosition());
245 // Check if actor no longer exists.
246 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(0,0)) );
248 // Add actor to it again, but at 2,5
249 tableView.AddChild(actor, TableView::CellPosition(2,5));
251 // Add another actor somewhere else 7,8
252 Actor actor2 = Actor::New();
253 tableView.AddChild(actor2, TableView::CellPosition(7,8));
257 // Check that no actor exists in a few random places.
258 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(0,0)) );
259 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(2,1)) );
260 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(6,3)) );
261 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(9,5)) );
263 // Check for actors at actual positions.
264 searchActor = tableView.GetChildAt(TableView::CellPosition(2,5));
265 DALI_TEST_CHECK( searchActor == actor);
267 searchActor = tableView.GetChildAt(TableView::CellPosition(7,8));
268 DALI_TEST_CHECK( searchActor == actor2);
270 // Create a second table, and add already added Child to new one.
271 TableView tableView2 = TableView::New(5,5);
272 tableView2.AddChild(actor, TableView::CellPosition(2,2));
273 DALI_TEST_CHECK( tableView2.GetChildAt(TableView::CellPosition(2,2)) );
277 // Test calling Add on it's own (to invoke the OnChildAdd)
278 int UtcDaliTableViewAdd(void)
280 ToolkitTestApplication application;
282 tet_infoline("UtcDaliTableViewAdd");
284 // Create a 4x1 table-view, and just keep adding.
285 TableView tableView = TableView::New(1,4);
286 DALI_TEST_CHECK( tableView );
288 for(unsigned int i = 0;i<16;i++)
290 Actor currentActor = Actor::New();
291 TableView::CellPosition position = TableView::CellPosition();
292 tableView.Add( currentActor );
293 tableView.FindChildPosition(currentActor, position);
294 tet_printf("%dx%d (%d,%d)\n", tableView.GetColumns(), tableView.GetRows(), position.columnIndex, position.rowIndex);
296 DALI_TEST_EQUALS((position.rowIndex * 4 + position.columnIndex), i, TEST_LOCATION);
301 // Test cell modification.
302 int UtcDaliTableViewCells(void)
304 ToolkitTestApplication application;
305 tet_infoline("UtcDaliTableViewCells");
307 // Create a 10x10 table-view
308 TableView tableView = TableView::New(10,10);
309 DALI_TEST_CHECK( tableView );
311 // Add a few actors to the table.
312 Actor actor1 = Actor::New();
313 Actor actor2 = Actor::New();
314 Actor actor3 = Actor::New();
315 actor1.SetName("Actor1");
316 actor2.SetName("Actor2");
317 actor3.SetName("Actor3");
319 // note: positions are specified in reversed cartesian coords - row,col (i.e. y,x)
320 tableView.AddChild(actor1, TableView::CellPosition(0,0));
321 tableView.AddChild(actor2, TableView::CellPosition(5,5));
322 tableView.AddChild(actor3, TableView::CellPosition(7,2));
324 DALI_TEST_CHECK( tableView.GetRows() == 10 && tableView.GetColumns() == 10 );
326 // Add a row between actor1 and actor2 | insert column on actor1 and see what happens...
327 tableView.InsertRow(3);
328 tableView.InsertColumn(0);
329 DALI_TEST_CHECK( tableView.GetRows() == 11 && tableView.GetColumns() == 11 );
331 TableView::CellPosition cellPosition;
334 result = tableView.FindChildPosition(actor1, cellPosition);
335 DALI_TEST_CHECK( result && cellPosition.rowIndex == 0 && cellPosition.columnIndex == 1);
336 result = tableView.FindChildPosition(actor2, cellPosition);
337 DALI_TEST_CHECK( result && cellPosition.rowIndex == 6 && cellPosition.columnIndex == 6);
338 result = tableView.FindChildPosition(actor3, cellPosition);
339 DALI_TEST_CHECK( result && cellPosition.rowIndex == 8 && cellPosition.columnIndex == 3);
341 // Delete a row between actor2 and actor3 | delete column on actor2 and see what happens...
342 tableView.DeleteRow(7);
343 tableView.DeleteColumn(6);
344 DALI_TEST_CHECK( tableView.GetRows() == 10 && tableView.GetColumns() == 10 );
346 result = tableView.FindChildPosition(actor1, cellPosition);
347 DALI_TEST_CHECK( result && cellPosition.rowIndex == 0 && cellPosition.columnIndex == 1);
348 result = tableView.FindChildPosition(actor2, cellPosition);
349 DALI_TEST_CHECK( !result );
350 result = tableView.FindChildPosition(actor3, cellPosition);
351 DALI_TEST_CHECK( result && cellPosition.rowIndex == 7 && cellPosition.columnIndex == 3);
353 // Delete the other two remaining actors by a row delete and a column delete.
354 std::vector<Actor> actorsRemoved;
355 tableView.DeleteRow(0, actorsRemoved);
356 tet_printf("Row Delete >> Actors Removed: %d {", actorsRemoved.size());
357 for(size_t i = 0;i<actorsRemoved.size();i++) tet_printf("%d => %s, ", i, actorsRemoved[i].GetName().c_str());
359 DALI_TEST_EQUALS( static_cast<int>(actorsRemoved.size()), 1, TEST_LOCATION );
360 DALI_TEST_CHECK( actorsRemoved[0] == actor1 );
362 actorsRemoved.clear();
363 tableView.DeleteColumn(3, actorsRemoved);
364 tet_printf("Column Delete >> Actors Removed: %d {", actorsRemoved.size());
365 for(size_t i = 0;i<actorsRemoved.size();i++) tet_printf("%d => %s, ", i, actorsRemoved[i].GetName().c_str());
367 DALI_TEST_EQUALS( static_cast<int>(actorsRemoved.size()), 1, TEST_LOCATION );
368 DALI_TEST_CHECK( actorsRemoved[0] == actor3 );
370 DALI_TEST_CHECK( tableView.GetRows() == 9 && tableView.GetColumns() == 9 );
372 tableView.AddChild(actor1, TableView::CellPosition(5,8));
373 tableView.Resize(100,100);
374 DALI_TEST_CHECK( tableView.GetRows() == 100 && tableView.GetColumns() == 100 );
376 tableView.AddChild(actor2, TableView::CellPosition(69,57));
377 DALI_TEST_CHECK( tableView.FindChildPosition(actor1, cellPosition) && tableView.FindChildPosition(actor2, cellPosition) );
379 tableView.Resize(20,20);
380 DALI_TEST_CHECK( tableView.FindChildPosition(actor1, cellPosition) && !tableView.FindChildPosition(actor2, cellPosition) );
382 actorsRemoved.clear();
383 tableView.Resize(1,1, actorsRemoved);
384 DALI_TEST_CHECK( !tableView.FindChildPosition(actor1, cellPosition) && !tableView.FindChildPosition(actor2, cellPosition) );
385 DALI_TEST_EQUALS( static_cast<int>(actorsRemoved.size()), 1, TEST_LOCATION );
386 DALI_TEST_CHECK( actorsRemoved[0] == actor1 );
388 // Add child outside table size, forcing a resize.
389 tableView.AddChild(actor1, TableView::CellPosition(100, 100, 1, 1));
390 DALI_TEST_CHECK( tableView.GetRows() == 101 && tableView.GetColumns() == 101 );
392 // Add child outside table size, forcing a resize.
393 tableView.AddChild(actor1, TableView::CellPosition(110, 110, 5, 5));
394 DALI_TEST_CHECK( tableView.GetRows() == 115 && tableView.GetColumns() == 115 );
396 DALI_TEST_CHECK( true );
400 int UtcDaliTableViewChildAssert(void)
402 ToolkitTestApplication application;
403 tet_infoline("UtcDaliTableViewChildAssert");
405 // Create a 10x10 table-view
406 TableView tableView = TableView::New(10,10);
407 DALI_TEST_CHECK( tableView );
412 tableView.AddChild( childActor, TableView::CellPosition(0,0,5,5) );
414 tet_result(TET_FAIL);
416 catch( Dali::DaliException& e )
418 DALI_TEST_PRINT_ASSERT( e );
419 DALI_TEST_EQUALS(e.condition, "child", TEST_LOCATION);
424 int UtcDaliTableViewMetricsAssert(void)
426 ToolkitTestApplication application;
427 tet_infoline("UtcDaliTableViewChildAssert");
429 // Create a 10x10 table-view
430 TableView tableView = TableView::New(10,10);
431 DALI_TEST_CHECK( tableView );
437 tableView.SetFixedHeight( 10, 1.0f );
439 tet_result(TET_FAIL);
441 catch( Dali::DaliException& e )
443 DALI_TEST_PRINT_ASSERT( e );
444 DALI_TEST_EQUALS(e.condition, "rowIndex < mFixedHeights.size()", TEST_LOCATION);
449 tableView.GetFixedHeight( 10 );
451 tet_result(TET_FAIL);
453 catch( Dali::DaliException& e )
455 DALI_TEST_PRINT_ASSERT( e );
456 DALI_TEST_EQUALS(e.condition, "rowIndex < mFixedHeights.size()", TEST_LOCATION);
461 tableView.SetFixedWidth( 10, 1.0f );
463 tet_result(TET_FAIL);
465 catch( Dali::DaliException& e )
467 DALI_TEST_PRINT_ASSERT( e );
468 DALI_TEST_EQUALS(e.condition, "columnIndex < mFixedWidths.size()", TEST_LOCATION);
473 tableView.GetFixedWidth( 10 );
475 tet_result(TET_FAIL);
477 catch( Dali::DaliException& e )
479 DALI_TEST_PRINT_ASSERT( e );
480 DALI_TEST_EQUALS(e.condition, "columnIndex < mFixedWidths.size()", TEST_LOCATION);
487 tableView.SetRelativeHeight( 10, 0.1f );
489 tet_result(TET_FAIL);
491 catch( Dali::DaliException& e )
493 DALI_TEST_PRINT_ASSERT( e );
494 DALI_TEST_EQUALS(e.condition, "rowIndex < mRelativeHeights.size()", TEST_LOCATION);
499 tableView.GetRelativeHeight( 10 );
501 tet_result(TET_FAIL);
503 catch( Dali::DaliException& e )
505 DALI_TEST_PRINT_ASSERT( e );
506 DALI_TEST_EQUALS(e.condition, "rowIndex < mRelativeHeights.size()", TEST_LOCATION);
511 tableView.SetRelativeWidth( 10, 0.1f );
513 tet_result(TET_FAIL);
515 catch( Dali::DaliException& e )
517 DALI_TEST_PRINT_ASSERT( e );
518 DALI_TEST_EQUALS(e.condition, "columnIndex < mRelativeWidths.size()", TEST_LOCATION);
523 tableView.GetRelativeWidth( 10 );
525 tet_result(TET_FAIL);
527 catch( Dali::DaliException& e )
529 DALI_TEST_PRINT_ASSERT( e );
530 DALI_TEST_EQUALS(e.condition, "columnIndex < mRelativeWidths.size()", TEST_LOCATION);
535 int UtcDaliTableViewSetGetProperty(void)
537 ToolkitTestApplication application;
538 tet_infoline("UtcDaliTableViewSetGetProperty");
540 // Create a 1x1 table-view
541 TableView tableView = TableView::New(1,1);
542 tableView.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, Constraint100() ) );
543 DALI_TEST_CHECK( tableView );
545 // Test "rows" property
546 DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_ROWS ) == TableView::PROPERTY_ROWS );
548 tableView.SetProperty( TableView::PROPERTY_ROWS, 4u );
550 DALI_TEST_CHECK( tableView.GetRows() == 4u );
551 DALI_TEST_CHECK( tableView.GetProperty(TableView::PROPERTY_ROWS).Get<unsigned int>() == 4u );
553 // Test "columns" property
554 DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_COLUMNS ) == TableView::PROPERTY_COLUMNS );
556 tableView.SetProperty( TableView::PROPERTY_COLUMNS, 5u );
558 DALI_TEST_CHECK( tableView.GetColumns() == 5u );
559 DALI_TEST_CHECK( tableView.GetProperty(TableView::PROPERTY_COLUMNS).Get<unsigned int>() == 5u );
561 // Test "cell-padding" property
562 DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_CELL_PADDING ) == TableView::PROPERTY_CELL_PADDING );
564 tableView.SetProperty( TableView::PROPERTY_CELL_PADDING, Size( 6.f, 8.f ) );
566 DALI_TEST_EQUALS( tableView.GetCellPadding(), Size(6.f, 8.f), TEST_LOCATION );
567 DALI_TEST_EQUALS( tableView.GetProperty(TableView::PROPERTY_CELL_PADDING).Get<Vector2>(), Vector2(6.f,8.f), TEST_LOCATION );
569 //{ "policy": "fixed", "value": 30.0 },
571 item1[ "policy" ] = "fixed";
572 item1[ "value" ] = 30.f;
573 //{ "policy": "relative", "value": 0.2 },
575 item2[ "policy" ] = "relative";
576 item2[ "value" ] = 0.2f;
578 // Test "layout-rows" property
579 DALI_TEST_CHECK( tableView.GetPropertyIndex(PROPERTY_NAME_LAYOUT_ROWS) == TableView::PROPERTY_LAYOUT_ROWS );
584 * "1": { "policy": "fixed", "value": 30 },
585 * "3": { "policy": "relative", "value": 0.2 }
588 Property::Map layoutRows;
589 layoutRows[ "1" ] = item1;
590 layoutRows[ "3" ] = item2;
591 tableView.SetProperty( TableView::PROPERTY_LAYOUT_ROWS, layoutRows );
593 DALI_TEST_EQUALS( tableView.GetFixedHeight( 1u ), 30.f, TEST_LOCATION );
594 DALI_TEST_EQUALS( tableView.GetRelativeHeight( 3u ), 0.2f, TEST_LOCATION );
596 Property::Map layoutRowsGet = tableView.GetProperty(TableView::PROPERTY_LAYOUT_ROWS).Get<Property::Map>();
597 DALI_TEST_CHECK( layoutRowsGet.GetKey(0).compare(layoutRows.GetKey(0)) == 0 );
598 DALI_TEST_CHECK( layoutRowsGet.GetValue(0).GetValue( "policy" ).Get<std::string>().compare(layoutRows.GetValue(0).GetValue( "policy" ).Get<std::string>()) == 0 );
599 DALI_TEST_EQUALS( layoutRowsGet.GetValue(0).GetValue( "value" ).Get<float>(),layoutRows.GetValue(0).GetValue( "value" ).Get<float>(), TEST_LOCATION );
600 DALI_TEST_CHECK( layoutRowsGet.GetKey(1).compare(layoutRows.GetKey(1)) == 0 );
601 DALI_TEST_CHECK( layoutRowsGet.GetValue(1).GetValue( "policy" ).Get<std::string>().compare(layoutRows.GetValue(1).GetValue( "policy" ).Get<std::string>()) == 0 );
602 DALI_TEST_EQUALS( layoutRowsGet.GetValue(1).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(0).compare(layoutColumns.GetKey(0)) == 0 );
624 DALI_TEST_CHECK( layoutColumnsGet.GetValue(0).GetValue( "policy" ).Get<std::string>().compare(layoutColumns.GetValue(0).GetValue( "policy" ).Get<std::string>()) == 0 );
625 DALI_TEST_EQUALS( layoutColumnsGet.GetValue(0).GetValue( "value" ).Get<float>(),layoutColumns.GetValue(0).GetValue( "value" ).Get<float>(), TEST_LOCATION );
626 DALI_TEST_CHECK( layoutColumnsGet.GetKey(1).compare(layoutColumns.GetKey(1)) == 0 );
627 DALI_TEST_CHECK( layoutColumnsGet.GetValue(1).GetValue( "policy" ).Get<std::string>().compare(layoutColumns.GetValue(1).GetValue( "policy" ).Get<std::string>()) == 0 );
628 DALI_TEST_EQUALS( layoutColumnsGet.GetValue(1).GetValue( "value" ).Get<float>(),layoutColumns.GetValue(1).GetValue( "value" ).Get<float>(), TEST_LOCATION );
633 int UtcDaliTableViewCustomProperties(void)
635 ToolkitTestApplication application;
636 tet_infoline("UtcDaliTableViewCustomProperties");
638 // Create a 10x10 table-view
639 TableView tableView = TableView::New(10,10);
640 tableView.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, Constraint100() ) );
641 DALI_TEST_CHECK( tableView );
643 // Create a child actor with the custom properties
644 Actor child1 = Actor::New();
645 child1.RegisterProperty( TableView::CELL_INDICES_PROPERTY_NAME, Vector2( 3, 4 ) );
646 tableView.Add( child1 );
647 // Check for actors at actual positions.
648 DALI_TEST_CHECK( tableView.GetChildAt(TableView::CellPosition(3,4)) == child1);
650 // Create a second child actor with the custom properties
651 Actor child2 = Actor::New();
653 float columnSpan = 2.f;
654 child2.RegisterProperty( TableView::CELL_INDICES_PROPERTY_NAME, Vector2( 6, 1 ) );
655 child2.RegisterProperty( TableView::ROW_SPAN_PROPERTY_NAME, rowSpan );
656 child2.RegisterProperty( TableView::COLUMN_SPAN_PROPERTY_NAME, columnSpan );
657 tableView.Add( child2 );
658 // Check for actors at actual positions.
659 for( int i=0; i<rowSpan; i++ )
661 for(int j=0; j<columnSpan; j++)
663 DALI_TEST_CHECK( tableView.GetChildAt(TableView::CellPosition(6+i,1+j)) == child2);