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";
45 static bool gObjectCreatedCallBackCalled;
47 static void TestCallback(BaseHandle handle)
49 gObjectCreatedCallBackCalled = true;
59 * function operator to apply the parent size
61 void operator()( Dali::Vector3& current, const PropertyInputContainer& /* inputs */ )
63 current.x = current.y = current.z = 100.0f;
67 // Convenience function to quickly set up a 10x10 table with each cell being 10x10 pixels in size by default.
68 static void SetupTableViewAndActors(TableView& tableView, Actor& actor1, Actor& actor2, Actor& actor3)
70 tableView = TableView::New( 10, 10 ); // 10 by 10 grid.
71 DALI_TEST_CHECK( tableView );
73 Stage::GetCurrent().Add( tableView );
74 tableView.SetSize( Dali::Vector2( 100.0f, 100.0f ) );
76 actor1 = Actor::New();
77 actor2 = Actor::New();
78 actor3 = Actor::New();
80 actor1.SetSize( Dali::Vector2( 10, 10 ) );
81 actor2.SetSize( Dali::Vector2( 10, 10 ) );
82 actor3.SetSize( Dali::Vector2( 10, 10 ) );
84 tableView.AddChild( actor1, TableView::CellPosition( 0, 0 ) );
85 tableView.AddChild( actor2, TableView::CellPosition( 0, 1 ) );
86 tableView.AddChild( actor3, TableView::CellPosition( 1, 0 ) );
91 int UtcDaliTableViewNew(void)
93 ToolkitTestApplication application;
95 TableView tableView = TableView::New(10,10);
96 DALI_TEST_CHECK(tableView);
98 //Additional check to ensure object is created by checking if it's registered
99 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
100 DALI_TEST_CHECK( registry );
102 gObjectCreatedCallBackCalled = false;
103 registry.ObjectCreatedSignal().Connect(&TestCallback);
105 TableView tableView = TableView::New(10,10);
107 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
111 // Test adjusting the metric values for the cell.
112 int UtcDaliTableViewMetricsPadding(void)
114 ToolkitTestApplication application;
116 tet_infoline("UtcDaliTableViewMetricsPadding");
123 SetupTableViewAndActors(tableView, actor1, actor2, actor3);
125 // 1. check that padding works. no padding:
126 tableView.SetCellPadding(Size(0.0f, 0.0f));
127 application.SendNotification();
128 application.Render();
130 DALI_TEST_EQUALS( tableView.GetCellPadding(), Size(0.0f, 0.0f), TEST_LOCATION );
131 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
132 DALI_TEST_EQUALS( actor2.GetCurrentPosition(), Vector3(10.0f, 0.0f, 0.0f), TEST_LOCATION );
133 DALI_TEST_EQUALS( actor3.GetCurrentPosition(), Vector3(0.0f, 10.0f, 0.0f), TEST_LOCATION );
135 // 1. check that padding works. some padding:
136 tableView.SetCellPadding(Size(5.0f, 10.0f));
137 application.SendNotification();
138 application.Render();
140 DALI_TEST_EQUALS( tableView.GetCellPadding(), Size(5.0f, 10.0f), TEST_LOCATION );
141 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(5.0f, 10.0f, 0.0f), TEST_LOCATION );
145 // Test adjusting the metric values for the cell.
146 int UtcDaliTableViewMetricsFixed(void)
148 ToolkitTestApplication application;
150 tet_infoline("UtcDaliTableViewMetricsFixed");
157 SetupTableViewAndActors(tableView, actor1, actor2, actor3);
158 application.SendNotification();
159 application.Render();
161 // 1. check that with no fixed width/heights, actors are in default position.
162 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
163 DALI_TEST_EQUALS( actor2.GetCurrentPosition(), Vector3(10.0f, 0.0f, 0.0f), TEST_LOCATION );
164 DALI_TEST_EQUALS( actor3.GetCurrentPosition(), Vector3(0.0f, 10.0f, 0.0f), TEST_LOCATION );
166 // 2. check that with a fixed width & height, actors to the right and below are offsetted.
167 tableView.SetFixedWidth(0, 20.0f);
168 tableView.SetFixedHeight(0, 50.0f);
169 DALI_TEST_EQUALS( tableView.GetFixedWidth(0), 20.0f, TEST_LOCATION );
170 DALI_TEST_EQUALS( tableView.GetFixedHeight(0), 50.0f, TEST_LOCATION );
172 application.SendNotification();
173 application.Render();
175 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
176 DALI_TEST_EQUALS( actor2.GetCurrentPosition(), Vector3(20.0f, 0.0f, 0.0f), TEST_LOCATION );
177 DALI_TEST_EQUALS( actor3.GetCurrentPosition(), Vector3(0.0f, 50.0f, 0.0f), TEST_LOCATION );
181 // Test adjusting the metric values for the cell.
182 int UtcDaliTableViewMetricsRelative(void)
184 ToolkitTestApplication application;
186 tet_infoline("UtcDaliTableViewMetricsRelative");
193 SetupTableViewAndActors(tableView, actor1, actor2, actor3);
194 application.SendNotification();
195 application.Render();
197 // 1. check that with no relative width/heights, actors are in default position.
198 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
199 DALI_TEST_EQUALS( actor2.GetCurrentPosition(), Vector3(10.0f, 0.0f, 0.0f), TEST_LOCATION );
200 DALI_TEST_EQUALS( actor3.GetCurrentPosition(), Vector3(0.0f, 10.0f, 0.0f), TEST_LOCATION );
202 // 2. check that with a relative width & height, actors to the right and below are offsetted.
203 tableView.SetRelativeWidth(0, 0.3f); // cell 0,0 occupies 30%x50% of the grid (i.e. 30x50 pixels)
204 tableView.SetRelativeHeight(0, 0.5f);
205 DALI_TEST_EQUALS( tableView.GetRelativeWidth(0), 0.3f, TEST_LOCATION );
206 DALI_TEST_EQUALS( tableView.GetRelativeHeight(0), 0.5f, TEST_LOCATION );
208 application.SendNotification();
209 application.Render();
211 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
212 DALI_TEST_EQUALS( actor2.GetCurrentPosition(), Vector3(30.0f, 0.0f, 0.0f), TEST_LOCATION );
213 DALI_TEST_EQUALS( actor3.GetCurrentPosition(), Vector3(0.0f, 50.0f, 0.0f), TEST_LOCATION );
218 // Test Adding/Removing/Finding Children.
219 int UtcDaliTableViewChild(void)
221 ToolkitTestApplication application;
223 tet_infoline("UtcDaliTableViewChild");
225 // Create a 10x10 table-view
226 TableView tableView = TableView::New(10,10);
227 DALI_TEST_CHECK( tableView );
229 // Check if actor doesn't exist.
230 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(0,0)) );
232 // Add an actor to it at 0,0
233 Actor actor = Actor::New();
234 tableView.AddChild(actor, TableView::CellPosition());
237 DALI_TEST_CHECK( tableView.GetChildAt(TableView::CellPosition(0,0)) );
240 tableView.RemoveChildAt(TableView::CellPosition());
242 // Check if actor no longer exists.
243 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(0,0)) );
245 // Add actor to it again, but at 2,5
246 tableView.AddChild(actor, TableView::CellPosition(2,5));
248 // Add another actor somewhere else 7,8
249 Actor actor2 = Actor::New();
250 tableView.AddChild(actor2, TableView::CellPosition(7,8));
254 // Check that no actor exists in a few random places.
255 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(0,0)) );
256 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(2,1)) );
257 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(6,3)) );
258 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(9,5)) );
260 // Check for actors at actual positions.
261 searchActor = tableView.GetChildAt(TableView::CellPosition(2,5));
262 DALI_TEST_CHECK( searchActor == actor);
264 searchActor = tableView.GetChildAt(TableView::CellPosition(7,8));
265 DALI_TEST_CHECK( searchActor == actor2);
267 // Create a second table, and add already added Child to new one.
268 TableView tableView2 = TableView::New(5,5);
269 tableView2.AddChild(actor, TableView::CellPosition(2,2));
270 DALI_TEST_CHECK( tableView2.GetChildAt(TableView::CellPosition(2,2)) );
274 // Test calling Add on it's own (to invoke the OnChildAdd)
275 int UtcDaliTableViewAdd(void)
277 ToolkitTestApplication application;
279 tet_infoline("UtcDaliTableViewAdd");
281 // Create a 4x1 table-view, and just keep adding.
282 TableView tableView = TableView::New(1,4);
283 DALI_TEST_CHECK( tableView );
285 for(unsigned int i = 0;i<16;i++)
287 Actor currentActor = Actor::New();
288 TableView::CellPosition position = TableView::CellPosition();
289 tableView.Add( currentActor );
290 tableView.FindChildPosition(currentActor, position);
291 tet_printf("%dx%d (%d,%d)\n", tableView.GetColumns(), tableView.GetRows(), position.columnIndex, position.rowIndex);
293 DALI_TEST_EQUALS((position.rowIndex * 4 + position.columnIndex), i, TEST_LOCATION);
298 // Test cell modification.
299 int UtcDaliTableViewCells(void)
301 ToolkitTestApplication application;
302 tet_infoline("UtcDaliTableViewCells");
304 // Create a 10x10 table-view
305 TableView tableView = TableView::New(10,10);
306 DALI_TEST_CHECK( tableView );
308 // Add a few actors to the table.
309 Actor actor1 = Actor::New();
310 Actor actor2 = Actor::New();
311 Actor actor3 = Actor::New();
312 actor1.SetName("Actor1");
313 actor2.SetName("Actor2");
314 actor3.SetName("Actor3");
316 // note: positions are specified in reversed cartesian coords - row,col (i.e. y,x)
317 tableView.AddChild(actor1, TableView::CellPosition(0,0));
318 tableView.AddChild(actor2, TableView::CellPosition(5,5));
319 tableView.AddChild(actor3, TableView::CellPosition(7,2));
321 DALI_TEST_CHECK( tableView.GetRows() == 10 && tableView.GetColumns() == 10 );
323 // Add a row between actor1 and actor2 | insert column on actor1 and see what happens...
324 tableView.InsertRow(3);
325 tableView.InsertColumn(0);
326 DALI_TEST_CHECK( tableView.GetRows() == 11 && tableView.GetColumns() == 11 );
328 TableView::CellPosition cellPosition;
331 result = tableView.FindChildPosition(actor1, cellPosition);
332 DALI_TEST_CHECK( result && cellPosition.rowIndex == 0 && cellPosition.columnIndex == 1);
333 result = tableView.FindChildPosition(actor2, cellPosition);
334 DALI_TEST_CHECK( result && cellPosition.rowIndex == 6 && cellPosition.columnIndex == 6);
335 result = tableView.FindChildPosition(actor3, cellPosition);
336 DALI_TEST_CHECK( result && cellPosition.rowIndex == 8 && cellPosition.columnIndex == 3);
338 // Delete a row between actor2 and actor3 | delete column on actor2 and see what happens...
339 tableView.DeleteRow(7);
340 tableView.DeleteColumn(6);
341 DALI_TEST_CHECK( tableView.GetRows() == 10 && tableView.GetColumns() == 10 );
343 result = tableView.FindChildPosition(actor1, cellPosition);
344 DALI_TEST_CHECK( result && cellPosition.rowIndex == 0 && cellPosition.columnIndex == 1);
345 result = tableView.FindChildPosition(actor2, cellPosition);
346 DALI_TEST_CHECK( !result );
347 result = tableView.FindChildPosition(actor3, cellPosition);
348 DALI_TEST_CHECK( result && cellPosition.rowIndex == 7 && cellPosition.columnIndex == 3);
350 // Delete the other two remaining actors by a row delete and a column delete.
351 std::vector<Actor> actorsRemoved;
352 tableView.DeleteRow(0, actorsRemoved);
353 tet_printf("Row Delete >> Actors Removed: %d {", actorsRemoved.size());
354 for(size_t i = 0;i<actorsRemoved.size();i++) tet_printf("%d => %s, ", i, actorsRemoved[i].GetName().c_str());
356 DALI_TEST_EQUALS( static_cast<int>(actorsRemoved.size()), 1, TEST_LOCATION );
357 DALI_TEST_CHECK( actorsRemoved[0] == actor1 );
359 actorsRemoved.clear();
360 tableView.DeleteColumn(3, actorsRemoved);
361 tet_printf("Column Delete >> Actors Removed: %d {", actorsRemoved.size());
362 for(size_t i = 0;i<actorsRemoved.size();i++) tet_printf("%d => %s, ", i, actorsRemoved[i].GetName().c_str());
364 DALI_TEST_EQUALS( static_cast<int>(actorsRemoved.size()), 1, TEST_LOCATION );
365 DALI_TEST_CHECK( actorsRemoved[0] == actor3 );
367 DALI_TEST_CHECK( tableView.GetRows() == 9 && tableView.GetColumns() == 9 );
369 tableView.AddChild(actor1, TableView::CellPosition(5,8));
370 tableView.Resize(100,100);
371 DALI_TEST_CHECK( tableView.GetRows() == 100 && tableView.GetColumns() == 100 );
373 tableView.AddChild(actor2, TableView::CellPosition(69,57));
374 DALI_TEST_CHECK( tableView.FindChildPosition(actor1, cellPosition) && tableView.FindChildPosition(actor2, cellPosition) );
376 tableView.Resize(20,20);
377 DALI_TEST_CHECK( tableView.FindChildPosition(actor1, cellPosition) && !tableView.FindChildPosition(actor2, cellPosition) );
379 actorsRemoved.clear();
380 tableView.Resize(1,1, actorsRemoved);
381 DALI_TEST_CHECK( !tableView.FindChildPosition(actor1, cellPosition) && !tableView.FindChildPosition(actor2, cellPosition) );
382 DALI_TEST_EQUALS( static_cast<int>(actorsRemoved.size()), 1, TEST_LOCATION );
383 DALI_TEST_CHECK( actorsRemoved[0] == actor1 );
385 // Add child outside table size, forcing a resize.
386 tableView.AddChild(actor1, TableView::CellPosition(100, 100, 1, 1));
387 DALI_TEST_CHECK( tableView.GetRows() == 101 && tableView.GetColumns() == 101 );
389 // Add child outside table size, forcing a resize.
390 tableView.AddChild(actor1, TableView::CellPosition(110, 110, 5, 5));
391 DALI_TEST_CHECK( tableView.GetRows() == 115 && tableView.GetColumns() == 115 );
393 DALI_TEST_CHECK( true );
397 int UtcDaliTableViewChildAssert(void)
399 ToolkitTestApplication application;
400 tet_infoline("UtcDaliTableViewChildAssert");
402 // Create a 10x10 table-view
403 TableView tableView = TableView::New(10,10);
404 DALI_TEST_CHECK( tableView );
409 tableView.AddChild( childActor, TableView::CellPosition(0,0,5,5) );
411 tet_result(TET_FAIL);
413 catch( Dali::DaliException& e )
415 DALI_TEST_PRINT_ASSERT( e );
416 DALI_TEST_EQUALS(e.condition, "child", TEST_LOCATION);
421 int UtcDaliTableViewMetricsAssert(void)
423 ToolkitTestApplication application;
424 tet_infoline("UtcDaliTableViewChildAssert");
426 // Create a 10x10 table-view
427 TableView tableView = TableView::New(10,10);
428 DALI_TEST_CHECK( tableView );
434 tableView.SetFixedHeight( 10, 1.0f );
436 tet_result(TET_FAIL);
438 catch( Dali::DaliException& e )
440 DALI_TEST_PRINT_ASSERT( e );
441 DALI_TEST_EQUALS(e.condition, "rowIndex < mRowData.Size()", TEST_LOCATION);
446 tableView.GetFixedHeight( 10 );
448 tet_result(TET_FAIL);
450 catch( Dali::DaliException& e )
452 DALI_TEST_PRINT_ASSERT( e );
453 DALI_TEST_EQUALS(e.condition, "rowIndex < mRowData.Size()", TEST_LOCATION);
458 tableView.SetFixedWidth( 10, 1.0f );
460 tet_result(TET_FAIL);
462 catch( Dali::DaliException& e )
464 DALI_TEST_PRINT_ASSERT( e );
465 DALI_TEST_EQUALS(e.condition, "columnIndex < mColumnData.Size()", TEST_LOCATION);
470 tableView.GetFixedWidth( 10 );
472 tet_result(TET_FAIL);
474 catch( Dali::DaliException& e )
476 DALI_TEST_PRINT_ASSERT( e );
477 DALI_TEST_EQUALS(e.condition, "columnIndex < mColumnData.Size()", TEST_LOCATION);
484 tableView.SetRelativeHeight( 10, 0.1f );
486 tet_result(TET_FAIL);
488 catch( Dali::DaliException& e )
490 DALI_TEST_PRINT_ASSERT( e );
491 DALI_TEST_EQUALS(e.condition, "rowIndex < mRowData.Size()", TEST_LOCATION);
496 tableView.GetRelativeHeight( 10 );
498 tet_result(TET_FAIL);
500 catch( Dali::DaliException& e )
502 DALI_TEST_PRINT_ASSERT( e );
503 DALI_TEST_EQUALS(e.condition, "rowIndex < mRowData.Size()", TEST_LOCATION);
508 tableView.SetRelativeWidth( 10, 0.1f );
510 tet_result(TET_FAIL);
512 catch( Dali::DaliException& e )
514 DALI_TEST_PRINT_ASSERT( e );
515 DALI_TEST_EQUALS(e.condition, "columnIndex < mColumnData.Size()", TEST_LOCATION);
520 tableView.GetRelativeWidth( 10 );
522 tet_result(TET_FAIL);
524 catch( Dali::DaliException& e )
526 DALI_TEST_PRINT_ASSERT( e );
527 DALI_TEST_EQUALS(e.condition, "columnIndex < mColumnData.Size()", TEST_LOCATION);
532 int UtcDaliTableViewSetGetProperty(void)
534 ToolkitTestApplication application;
535 tet_infoline("UtcDaliTableViewSetGetProperty");
537 // Create a 1x1 table-view
538 TableView tableView = TableView::New(1,1);
539 tableView.SetSize( Vector2( 100.0f, 100.0f ) );
540 DALI_TEST_CHECK( tableView );
542 // Test "rows" property
543 DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_ROWS ) == TableView::Property::ROWS );
545 tableView.SetProperty( TableView::Property::ROWS, 4u );
547 DALI_TEST_CHECK( tableView.GetRows() == 4u );
548 DALI_TEST_CHECK( tableView.GetProperty(TableView::Property::ROWS).Get<unsigned int>() == 4u );
550 // Test "columns" property
551 DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_COLUMNS ) == TableView::Property::COLUMNS );
553 tableView.SetProperty( TableView::Property::COLUMNS, 5u );
555 DALI_TEST_CHECK( tableView.GetColumns() == 5u );
556 DALI_TEST_CHECK( tableView.GetProperty(TableView::Property::COLUMNS).Get<unsigned int>() == 5u );
558 // Test "cell-padding" property
559 DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_CELL_PADDING ) == TableView::Property::CELL_PADDING );
561 tableView.SetProperty( TableView::Property::CELL_PADDING, Size( 6.f, 8.f ) );
563 DALI_TEST_EQUALS( tableView.GetCellPadding(), Size(6.f, 8.f), TEST_LOCATION );
564 DALI_TEST_EQUALS( tableView.GetProperty(TableView::Property::CELL_PADDING).Get<Vector2>(), Vector2(6.f,8.f), TEST_LOCATION );
566 //{ "policy": "fixed", "value": 30.0 },
568 item1[ "policy" ] = "fixed";
569 item1[ "value" ] = 30.f;
570 //{ "policy": "relative", "value": 0.2 },
572 item2[ "policy" ] = "relative";
573 item2[ "value" ] = 0.2f;
575 // Test "layout-rows" property
576 DALI_TEST_CHECK( tableView.GetPropertyIndex(PROPERTY_NAME_LAYOUT_ROWS) == TableView::Property::LAYOUT_ROWS );
581 * "1": { "policy": "fixed", "value": 30 },
582 * "3": { "policy": "relative", "value": 0.2 }
585 Property::Map layoutRows;
586 layoutRows[ "1" ] = item1;
587 layoutRows[ "3" ] = item2;
588 tableView.SetProperty( TableView::Property::LAYOUT_ROWS, layoutRows );
590 DALI_TEST_EQUALS( tableView.GetFixedHeight( 1u ), 30.f, TEST_LOCATION );
591 DALI_TEST_EQUALS( tableView.GetRelativeHeight( 3u ), 0.2f, TEST_LOCATION );
593 Property::Map layoutRowsGet = tableView.GetProperty(TableView::Property::LAYOUT_ROWS).Get<Property::Map>();
595 DALI_TEST_EQUALS( layoutRowsGet.GetKey(1).compare(layoutRows.GetKey(0)), 0, TEST_LOCATION );
596 DALI_TEST_CHECK( layoutRowsGet.GetValue(1).GetValue( "policy" ).Get<std::string>().compare(layoutRows.GetValue(0).GetValue( "policy" ).Get<std::string>()) == 0 );
597 DALI_TEST_EQUALS( layoutRowsGet.GetValue(1).GetValue( "value" ).Get<float>(), layoutRows.GetValue(0).GetValue( "value" ).Get<float>(), TEST_LOCATION );
599 DALI_TEST_CHECK( layoutRowsGet.GetKey(3).compare(layoutRows.GetKey(1)) == 0 );
600 DALI_TEST_CHECK( layoutRowsGet.GetValue(3).GetValue( "policy" ).Get<std::string>().compare(layoutRows.GetValue(1).GetValue( "policy" ).Get<std::string>()) == 0 );
601 DALI_TEST_EQUALS( layoutRowsGet.GetValue(3).GetValue( "value" ).Get<float>(), layoutRows.GetValue(1).GetValue( "value" ).Get<float>(), TEST_LOCATION );
603 // Test "layout-columns" property
604 DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_LAYOUT_COLUMNS ) == TableView::Property::LAYOUT_COLUMNS );
609 * "2": { "policy": "relative", "value": 0.2 },
610 * "3": { "policy": "fixed", "value": 30 }
613 Property::Map layoutColumns;
614 layoutColumns[ "2" ] = item2;
615 layoutColumns[ "3" ] = item1;
616 tableView.SetProperty( TableView::Property::LAYOUT_COLUMNS, layoutColumns );
618 DALI_TEST_EQUALS( tableView.GetRelativeWidth( 2u ), 0.2f, TEST_LOCATION );
619 DALI_TEST_EQUALS( tableView.GetFixedWidth( 3u ), 30.f, TEST_LOCATION );
621 Property::Map layoutColumnsGet = tableView.GetProperty(TableView::Property::LAYOUT_COLUMNS).Get<Property::Map>();
622 DALI_TEST_CHECK( layoutColumnsGet.GetKey(2).compare(layoutColumns.GetKey(0)) == 0 );
623 DALI_TEST_CHECK( layoutColumnsGet.GetValue(2).GetValue( "policy" ).Get<std::string>().compare(layoutColumns.GetValue(0).GetValue( "policy" ).Get<std::string>()) == 0 );
624 DALI_TEST_EQUALS( layoutColumnsGet.GetValue(2).GetValue( "value" ).Get<float>(),layoutColumns.GetValue(0).GetValue( "value" ).Get<float>(), TEST_LOCATION );
626 DALI_TEST_CHECK( layoutColumnsGet.GetKey(3).compare(layoutColumns.GetKey(1)) == 0 );
627 DALI_TEST_CHECK( layoutColumnsGet.GetValue(3).GetValue( "policy" ).Get<std::string>().compare(layoutColumns.GetValue(1).GetValue( "policy" ).Get<std::string>()) == 0 );
628 DALI_TEST_EQUALS( layoutColumnsGet.GetValue(3).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 Constraint constraint = Constraint::New<Vector3>( tableView, Actor::Property::SIZE, Constraint100() );
642 DALI_TEST_CHECK( tableView );
644 // Create a child actor with the custom properties
645 Actor child1 = Actor::New();
646 child1.RegisterProperty( TableView::CELL_INDICES_PROPERTY_NAME, Vector2( 3, 4 ) );
647 tableView.Add( child1 );
648 // Check for actors at actual positions.
649 DALI_TEST_CHECK( tableView.GetChildAt(TableView::CellPosition(3,4)) == child1);
651 // Create a second child actor with the custom properties
652 Actor child2 = Actor::New();
654 float columnSpan = 2.f;
655 child2.RegisterProperty( TableView::CELL_INDICES_PROPERTY_NAME, Vector2( 6, 1 ) );
656 child2.RegisterProperty( TableView::ROW_SPAN_PROPERTY_NAME, rowSpan );
657 child2.RegisterProperty( TableView::COLUMN_SPAN_PROPERTY_NAME, columnSpan );
658 tableView.Add( child2 );
659 // Check for actors at actual positions.
660 for( int i=0; i<rowSpan; i++ )
662 for(int j=0; j<columnSpan; j++)
664 DALI_TEST_CHECK( tableView.GetChildAt(TableView::CellPosition(6+i,1+j)) == child2);