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 tableView.SetRelayoutEnabled( true );
75 Stage::GetCurrent().Add( tableView );
76 tableView.SetSize( Dali::Vector2( 100.0f, 100.0f ) );
78 actor1 = Actor::New();
79 actor2 = Actor::New();
80 actor3 = Actor::New();
82 actor1.SetRelayoutEnabled( true );
83 actor1.SetSize( Dali::Vector2( 10, 10 ) );
84 actor2.SetRelayoutEnabled( true );
85 actor2.SetSize( Dali::Vector2( 10, 10 ) );
86 actor3.SetRelayoutEnabled( true );
87 actor3.SetSize( Dali::Vector2( 10, 10 ) );
89 tableView.AddChild( actor1, TableView::CellPosition( 0, 0 ) );
90 tableView.AddChild( actor2, TableView::CellPosition( 0, 1 ) );
91 tableView.AddChild( actor3, TableView::CellPosition( 1, 0 ) );
96 int UtcDaliTableViewNew(void)
98 ToolkitTestApplication application;
100 TableView tableView = TableView::New(10,10);
101 DALI_TEST_CHECK(tableView);
103 //Additional check to ensure object is created by checking if it's registered
104 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
105 DALI_TEST_CHECK( registry );
107 gObjectCreatedCallBackCalled = false;
108 registry.ObjectCreatedSignal().Connect(&TestCallback);
110 TableView tableView = TableView::New(10,10);
112 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
116 // Test adjusting the metric values for the cell.
117 int UtcDaliTableViewMetricsPadding(void)
119 ToolkitTestApplication application;
121 tet_infoline("UtcDaliTableViewMetricsPadding");
128 SetupTableViewAndActors(tableView, actor1, actor2, actor3);
130 // 1. check that padding works. no padding:
131 tableView.SetCellPadding(Size(0.0f, 0.0f));
132 application.SendNotification();
133 application.Render();
135 DALI_TEST_EQUALS( tableView.GetCellPadding(), Size(0.0f, 0.0f), TEST_LOCATION );
136 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
137 DALI_TEST_EQUALS( actor2.GetCurrentPosition(), Vector3(10.0f, 0.0f, 0.0f), TEST_LOCATION );
138 DALI_TEST_EQUALS( actor3.GetCurrentPosition(), Vector3(0.0f, 10.0f, 0.0f), TEST_LOCATION );
140 // 1. check that padding works. some padding:
141 tableView.SetCellPadding(Size(5.0f, 10.0f));
142 application.SendNotification();
143 application.Render();
145 DALI_TEST_EQUALS( tableView.GetCellPadding(), Size(5.0f, 10.0f), TEST_LOCATION );
146 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(5.0f, 10.0f, 0.0f), TEST_LOCATION );
150 // Test adjusting the metric values for the cell.
151 int UtcDaliTableViewMetricsFixed(void)
153 ToolkitTestApplication application;
155 tet_infoline("UtcDaliTableViewMetricsFixed");
162 SetupTableViewAndActors(tableView, actor1, actor2, actor3);
163 application.SendNotification();
164 application.Render();
166 // 1. check that with no fixed width/heights, actors are in default position.
167 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
168 DALI_TEST_EQUALS( actor2.GetCurrentPosition(), Vector3(10.0f, 0.0f, 0.0f), TEST_LOCATION );
169 DALI_TEST_EQUALS( actor3.GetCurrentPosition(), Vector3(0.0f, 10.0f, 0.0f), TEST_LOCATION );
171 // 2. check that with a fixed width & height, actors to the right and below are offsetted.
172 tableView.SetFixedWidth(0, 20.0f);
173 tableView.SetFixedHeight(0, 50.0f);
174 DALI_TEST_EQUALS( tableView.GetFixedWidth(0), 20.0f, TEST_LOCATION );
175 DALI_TEST_EQUALS( tableView.GetFixedHeight(0), 50.0f, TEST_LOCATION );
177 application.SendNotification();
178 application.Render();
180 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
181 DALI_TEST_EQUALS( actor2.GetCurrentPosition(), Vector3(20.0f, 0.0f, 0.0f), TEST_LOCATION );
182 DALI_TEST_EQUALS( actor3.GetCurrentPosition(), Vector3(0.0f, 50.0f, 0.0f), TEST_LOCATION );
186 // Test adjusting the metric values for the cell.
187 int UtcDaliTableViewMetricsRelative(void)
189 ToolkitTestApplication application;
191 tet_infoline("UtcDaliTableViewMetricsRelative");
198 SetupTableViewAndActors(tableView, actor1, actor2, actor3);
199 application.SendNotification();
200 application.Render();
202 // 1. check that with no relative width/heights, actors are in default position.
203 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
204 DALI_TEST_EQUALS( actor2.GetCurrentPosition(), Vector3(10.0f, 0.0f, 0.0f), TEST_LOCATION );
205 DALI_TEST_EQUALS( actor3.GetCurrentPosition(), Vector3(0.0f, 10.0f, 0.0f), TEST_LOCATION );
207 // 2. check that with a relative width & height, actors to the right and below are offsetted.
208 tableView.SetRelativeWidth(0, 0.3f); // cell 0,0 occupies 30%x50% of the grid (i.e. 30x50 pixels)
209 tableView.SetRelativeHeight(0, 0.5f);
210 DALI_TEST_EQUALS( tableView.GetRelativeWidth(0), 0.3f, TEST_LOCATION );
211 DALI_TEST_EQUALS( tableView.GetRelativeHeight(0), 0.5f, TEST_LOCATION );
213 application.SendNotification();
214 application.Render();
216 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
217 DALI_TEST_EQUALS( actor2.GetCurrentPosition(), Vector3(30.0f, 0.0f, 0.0f), TEST_LOCATION );
218 DALI_TEST_EQUALS( actor3.GetCurrentPosition(), Vector3(0.0f, 50.0f, 0.0f), TEST_LOCATION );
223 // Test Adding/Removing/Finding Children.
224 int UtcDaliTableViewChild(void)
226 ToolkitTestApplication application;
228 tet_infoline("UtcDaliTableViewChild");
230 // Create a 10x10 table-view
231 TableView tableView = TableView::New(10,10);
232 DALI_TEST_CHECK( tableView );
234 // Check if actor doesn't exist.
235 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(0,0)) );
237 // Add an actor to it at 0,0
238 Actor actor = Actor::New();
239 tableView.AddChild(actor, TableView::CellPosition());
242 DALI_TEST_CHECK( tableView.GetChildAt(TableView::CellPosition(0,0)) );
245 tableView.RemoveChildAt(TableView::CellPosition());
247 // Check if actor no longer exists.
248 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(0,0)) );
250 // Add actor to it again, but at 2,5
251 tableView.AddChild(actor, TableView::CellPosition(2,5));
253 // Add another actor somewhere else 7,8
254 Actor actor2 = Actor::New();
255 tableView.AddChild(actor2, TableView::CellPosition(7,8));
259 // Check that no actor exists in a few random places.
260 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(0,0)) );
261 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(2,1)) );
262 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(6,3)) );
263 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(9,5)) );
265 // Check for actors at actual positions.
266 searchActor = tableView.GetChildAt(TableView::CellPosition(2,5));
267 DALI_TEST_CHECK( searchActor == actor);
269 searchActor = tableView.GetChildAt(TableView::CellPosition(7,8));
270 DALI_TEST_CHECK( searchActor == actor2);
272 // Create a second table, and add already added Child to new one.
273 TableView tableView2 = TableView::New(5,5);
274 tableView2.AddChild(actor, TableView::CellPosition(2,2));
275 DALI_TEST_CHECK( tableView2.GetChildAt(TableView::CellPosition(2,2)) );
279 // Test calling Add on it's own (to invoke the OnChildAdd)
280 int UtcDaliTableViewAdd(void)
282 ToolkitTestApplication application;
284 tet_infoline("UtcDaliTableViewAdd");
286 // Create a 4x1 table-view, and just keep adding.
287 TableView tableView = TableView::New(1,4);
288 DALI_TEST_CHECK( tableView );
290 for(unsigned int i = 0;i<16;i++)
292 Actor currentActor = Actor::New();
293 TableView::CellPosition position = TableView::CellPosition();
294 tableView.Add( currentActor );
295 tableView.FindChildPosition(currentActor, position);
296 tet_printf("%dx%d (%d,%d)\n", tableView.GetColumns(), tableView.GetRows(), position.columnIndex, position.rowIndex);
298 DALI_TEST_EQUALS((position.rowIndex * 4 + position.columnIndex), i, TEST_LOCATION);
303 // Test cell modification.
304 int UtcDaliTableViewCells(void)
306 ToolkitTestApplication application;
307 tet_infoline("UtcDaliTableViewCells");
309 // Create a 10x10 table-view
310 TableView tableView = TableView::New(10,10);
311 DALI_TEST_CHECK( tableView );
313 // Add a few actors to the table.
314 Actor actor1 = Actor::New();
315 Actor actor2 = Actor::New();
316 Actor actor3 = Actor::New();
317 actor1.SetName("Actor1");
318 actor2.SetName("Actor2");
319 actor3.SetName("Actor3");
321 // note: positions are specified in reversed cartesian coords - row,col (i.e. y,x)
322 tableView.AddChild(actor1, TableView::CellPosition(0,0));
323 tableView.AddChild(actor2, TableView::CellPosition(5,5));
324 tableView.AddChild(actor3, TableView::CellPosition(7,2));
326 DALI_TEST_CHECK( tableView.GetRows() == 10 && tableView.GetColumns() == 10 );
328 // Add a row between actor1 and actor2 | insert column on actor1 and see what happens...
329 tableView.InsertRow(3);
330 tableView.InsertColumn(0);
331 DALI_TEST_CHECK( tableView.GetRows() == 11 && tableView.GetColumns() == 11 );
333 TableView::CellPosition cellPosition;
336 result = tableView.FindChildPosition(actor1, cellPosition);
337 DALI_TEST_CHECK( result && cellPosition.rowIndex == 0 && cellPosition.columnIndex == 1);
338 result = tableView.FindChildPosition(actor2, cellPosition);
339 DALI_TEST_CHECK( result && cellPosition.rowIndex == 6 && cellPosition.columnIndex == 6);
340 result = tableView.FindChildPosition(actor3, cellPosition);
341 DALI_TEST_CHECK( result && cellPosition.rowIndex == 8 && cellPosition.columnIndex == 3);
343 // Delete a row between actor2 and actor3 | delete column on actor2 and see what happens...
344 tableView.DeleteRow(7);
345 tableView.DeleteColumn(6);
346 DALI_TEST_CHECK( tableView.GetRows() == 10 && tableView.GetColumns() == 10 );
348 result = tableView.FindChildPosition(actor1, cellPosition);
349 DALI_TEST_CHECK( result && cellPosition.rowIndex == 0 && cellPosition.columnIndex == 1);
350 result = tableView.FindChildPosition(actor2, cellPosition);
351 DALI_TEST_CHECK( !result );
352 result = tableView.FindChildPosition(actor3, cellPosition);
353 DALI_TEST_CHECK( result && cellPosition.rowIndex == 7 && cellPosition.columnIndex == 3);
355 // Delete the other two remaining actors by a row delete and a column delete.
356 std::vector<Actor> actorsRemoved;
357 tableView.DeleteRow(0, actorsRemoved);
358 tet_printf("Row Delete >> Actors Removed: %d {", actorsRemoved.size());
359 for(size_t i = 0;i<actorsRemoved.size();i++) tet_printf("%d => %s, ", i, actorsRemoved[i].GetName().c_str());
361 DALI_TEST_EQUALS( static_cast<int>(actorsRemoved.size()), 1, TEST_LOCATION );
362 DALI_TEST_CHECK( actorsRemoved[0] == actor1 );
364 actorsRemoved.clear();
365 tableView.DeleteColumn(3, actorsRemoved);
366 tet_printf("Column Delete >> Actors Removed: %d {", actorsRemoved.size());
367 for(size_t i = 0;i<actorsRemoved.size();i++) tet_printf("%d => %s, ", i, actorsRemoved[i].GetName().c_str());
369 DALI_TEST_EQUALS( static_cast<int>(actorsRemoved.size()), 1, TEST_LOCATION );
370 DALI_TEST_CHECK( actorsRemoved[0] == actor3 );
372 DALI_TEST_CHECK( tableView.GetRows() == 9 && tableView.GetColumns() == 9 );
374 tableView.AddChild(actor1, TableView::CellPosition(5,8));
375 tableView.Resize(100,100);
376 DALI_TEST_CHECK( tableView.GetRows() == 100 && tableView.GetColumns() == 100 );
378 tableView.AddChild(actor2, TableView::CellPosition(69,57));
379 DALI_TEST_CHECK( tableView.FindChildPosition(actor1, cellPosition) && tableView.FindChildPosition(actor2, cellPosition) );
381 tableView.Resize(20,20);
382 DALI_TEST_CHECK( tableView.FindChildPosition(actor1, cellPosition) && !tableView.FindChildPosition(actor2, cellPosition) );
384 actorsRemoved.clear();
385 tableView.Resize(1,1, actorsRemoved);
386 DALI_TEST_CHECK( !tableView.FindChildPosition(actor1, cellPosition) && !tableView.FindChildPosition(actor2, cellPosition) );
387 DALI_TEST_EQUALS( static_cast<int>(actorsRemoved.size()), 1, TEST_LOCATION );
388 DALI_TEST_CHECK( actorsRemoved[0] == actor1 );
390 // Add child outside table size, forcing a resize.
391 tableView.AddChild(actor1, TableView::CellPosition(100, 100, 1, 1));
392 DALI_TEST_CHECK( tableView.GetRows() == 101 && tableView.GetColumns() == 101 );
394 // Add child outside table size, forcing a resize.
395 tableView.AddChild(actor1, TableView::CellPosition(110, 110, 5, 5));
396 DALI_TEST_CHECK( tableView.GetRows() == 115 && tableView.GetColumns() == 115 );
398 DALI_TEST_CHECK( true );
402 int UtcDaliTableViewChildAssert(void)
404 ToolkitTestApplication application;
405 tet_infoline("UtcDaliTableViewChildAssert");
407 // Create a 10x10 table-view
408 TableView tableView = TableView::New(10,10);
409 DALI_TEST_CHECK( tableView );
414 tableView.AddChild( childActor, TableView::CellPosition(0,0,5,5) );
416 tet_result(TET_FAIL);
418 catch( Dali::DaliException& e )
420 DALI_TEST_PRINT_ASSERT( e );
421 DALI_TEST_EQUALS(e.condition, "child", TEST_LOCATION);
426 int UtcDaliTableViewMetricsAssert(void)
428 ToolkitTestApplication application;
429 tet_infoline("UtcDaliTableViewChildAssert");
431 // Create a 10x10 table-view
432 TableView tableView = TableView::New(10,10);
433 DALI_TEST_CHECK( tableView );
439 tableView.SetFixedHeight( 10, 1.0f );
441 tet_result(TET_FAIL);
443 catch( Dali::DaliException& e )
445 DALI_TEST_PRINT_ASSERT( e );
446 DALI_TEST_EQUALS(e.condition, "rowIndex < mRowData.Size()", TEST_LOCATION);
451 tableView.GetFixedHeight( 10 );
453 tet_result(TET_FAIL);
455 catch( Dali::DaliException& e )
457 DALI_TEST_PRINT_ASSERT( e );
458 DALI_TEST_EQUALS(e.condition, "rowIndex < mRowData.Size()", TEST_LOCATION);
463 tableView.SetFixedWidth( 10, 1.0f );
465 tet_result(TET_FAIL);
467 catch( Dali::DaliException& e )
469 DALI_TEST_PRINT_ASSERT( e );
470 DALI_TEST_EQUALS(e.condition, "columnIndex < mColumnData.Size()", TEST_LOCATION);
475 tableView.GetFixedWidth( 10 );
477 tet_result(TET_FAIL);
479 catch( Dali::DaliException& e )
481 DALI_TEST_PRINT_ASSERT( e );
482 DALI_TEST_EQUALS(e.condition, "columnIndex < mColumnData.Size()", TEST_LOCATION);
489 tableView.SetRelativeHeight( 10, 0.1f );
491 tet_result(TET_FAIL);
493 catch( Dali::DaliException& e )
495 DALI_TEST_PRINT_ASSERT( e );
496 DALI_TEST_EQUALS(e.condition, "rowIndex < mRowData.Size()", TEST_LOCATION);
501 tableView.GetRelativeHeight( 10 );
503 tet_result(TET_FAIL);
505 catch( Dali::DaliException& e )
507 DALI_TEST_PRINT_ASSERT( e );
508 DALI_TEST_EQUALS(e.condition, "rowIndex < mRowData.Size()", TEST_LOCATION);
513 tableView.SetRelativeWidth( 10, 0.1f );
515 tet_result(TET_FAIL);
517 catch( Dali::DaliException& e )
519 DALI_TEST_PRINT_ASSERT( e );
520 DALI_TEST_EQUALS(e.condition, "columnIndex < mColumnData.Size()", TEST_LOCATION);
525 tableView.GetRelativeWidth( 10 );
527 tet_result(TET_FAIL);
529 catch( Dali::DaliException& e )
531 DALI_TEST_PRINT_ASSERT( e );
532 DALI_TEST_EQUALS(e.condition, "columnIndex < mColumnData.Size()", TEST_LOCATION);
537 int UtcDaliTableViewSetGetProperty(void)
539 ToolkitTestApplication application;
540 tet_infoline("UtcDaliTableViewSetGetProperty");
542 // Create a 1x1 table-view
543 TableView tableView = TableView::New(1,1);
544 tableView.SetSize( Vector2( 100.0f, 100.0f ) );
545 DALI_TEST_CHECK( tableView );
547 // Test "rows" property
548 DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_ROWS ) == TableView::Property::ROWS );
550 tableView.SetProperty( TableView::Property::ROWS, 4u );
552 DALI_TEST_CHECK( tableView.GetRows() == 4u );
553 DALI_TEST_CHECK( tableView.GetProperty(TableView::Property::ROWS).Get<unsigned int>() == 4u );
555 // Test "columns" property
556 DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_COLUMNS ) == TableView::Property::COLUMNS );
558 tableView.SetProperty( TableView::Property::COLUMNS, 5u );
560 DALI_TEST_CHECK( tableView.GetColumns() == 5u );
561 DALI_TEST_CHECK( tableView.GetProperty(TableView::Property::COLUMNS).Get<unsigned int>() == 5u );
563 // Test "cell-padding" property
564 DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_CELL_PADDING ) == TableView::Property::CELL_PADDING );
566 tableView.SetProperty( TableView::Property::CELL_PADDING, Size( 6.f, 8.f ) );
568 DALI_TEST_EQUALS( tableView.GetCellPadding(), Size(6.f, 8.f), TEST_LOCATION );
569 DALI_TEST_EQUALS( tableView.GetProperty(TableView::Property::CELL_PADDING).Get<Vector2>(), Vector2(6.f,8.f), TEST_LOCATION );
571 //{ "policy": "fixed", "value": 30.0 },
573 item1[ "policy" ] = "fixed";
574 item1[ "value" ] = 30.f;
575 //{ "policy": "relative", "value": 0.2 },
577 item2[ "policy" ] = "relative";
578 item2[ "value" ] = 0.2f;
580 // Test "layout-rows" property
581 DALI_TEST_CHECK( tableView.GetPropertyIndex(PROPERTY_NAME_LAYOUT_ROWS) == TableView::Property::LAYOUT_ROWS );
586 * "1": { "policy": "fixed", "value": 30 },
587 * "3": { "policy": "relative", "value": 0.2 }
590 Property::Map layoutRows;
591 layoutRows[ "1" ] = item1;
592 layoutRows[ "3" ] = item2;
593 tableView.SetProperty( TableView::Property::LAYOUT_ROWS, layoutRows );
595 DALI_TEST_EQUALS( tableView.GetFixedHeight( 1u ), 30.f, TEST_LOCATION );
596 DALI_TEST_EQUALS( tableView.GetRelativeHeight( 3u ), 0.2f, TEST_LOCATION );
598 Property::Map layoutRowsGet = tableView.GetProperty(TableView::Property::LAYOUT_ROWS).Get<Property::Map>();
600 DALI_TEST_EQUALS( layoutRowsGet.GetKey(1).compare(layoutRows.GetKey(0)), 0, TEST_LOCATION );
601 DALI_TEST_CHECK( layoutRowsGet.GetValue(1).GetValue( "policy" ).Get<std::string>().compare(layoutRows.GetValue(0).GetValue( "policy" ).Get<std::string>()) == 0 );
602 DALI_TEST_EQUALS( layoutRowsGet.GetValue(1).GetValue( "value" ).Get<float>(), layoutRows.GetValue(0).GetValue( "value" ).Get<float>(), TEST_LOCATION );
604 DALI_TEST_CHECK( layoutRowsGet.GetKey(3).compare(layoutRows.GetKey(1)) == 0 );
605 DALI_TEST_CHECK( layoutRowsGet.GetValue(3).GetValue( "policy" ).Get<std::string>().compare(layoutRows.GetValue(1).GetValue( "policy" ).Get<std::string>()) == 0 );
606 DALI_TEST_EQUALS( layoutRowsGet.GetValue(3).GetValue( "value" ).Get<float>(), layoutRows.GetValue(1).GetValue( "value" ).Get<float>(), TEST_LOCATION );
608 // Test "layout-columns" property
609 DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_LAYOUT_COLUMNS ) == TableView::Property::LAYOUT_COLUMNS );
614 * "2": { "policy": "relative", "value": 0.2 },
615 * "3": { "policy": "fixed", "value": 30 }
618 Property::Map layoutColumns;
619 layoutColumns[ "2" ] = item2;
620 layoutColumns[ "3" ] = item1;
621 tableView.SetProperty( TableView::Property::LAYOUT_COLUMNS, layoutColumns );
623 DALI_TEST_EQUALS( tableView.GetRelativeWidth( 2u ), 0.2f, TEST_LOCATION );
624 DALI_TEST_EQUALS( tableView.GetFixedWidth( 3u ), 30.f, TEST_LOCATION );
626 Property::Map layoutColumnsGet = tableView.GetProperty(TableView::Property::LAYOUT_COLUMNS).Get<Property::Map>();
627 DALI_TEST_CHECK( layoutColumnsGet.GetKey(2).compare(layoutColumns.GetKey(0)) == 0 );
628 DALI_TEST_CHECK( layoutColumnsGet.GetValue(2).GetValue( "policy" ).Get<std::string>().compare(layoutColumns.GetValue(0).GetValue( "policy" ).Get<std::string>()) == 0 );
629 DALI_TEST_EQUALS( layoutColumnsGet.GetValue(2).GetValue( "value" ).Get<float>(),layoutColumns.GetValue(0).GetValue( "value" ).Get<float>(), TEST_LOCATION );
631 DALI_TEST_CHECK( layoutColumnsGet.GetKey(3).compare(layoutColumns.GetKey(1)) == 0 );
632 DALI_TEST_CHECK( layoutColumnsGet.GetValue(3).GetValue( "policy" ).Get<std::string>().compare(layoutColumns.GetValue(1).GetValue( "policy" ).Get<std::string>()) == 0 );
633 DALI_TEST_EQUALS( layoutColumnsGet.GetValue(3).GetValue( "value" ).Get<float>(),layoutColumns.GetValue(1).GetValue( "value" ).Get<float>(), TEST_LOCATION );
638 int UtcDaliTableViewCustomProperties(void)
640 ToolkitTestApplication application;
641 tet_infoline("UtcDaliTableViewCustomProperties");
643 // Create a 10x10 table-view
644 TableView tableView = TableView::New(10,10);
645 Constraint constraint = Constraint::New<Vector3>( tableView, Actor::Property::SIZE, Constraint100() );
647 DALI_TEST_CHECK( tableView );
649 // Create a child actor with the custom properties
650 Actor child1 = Actor::New();
651 child1.RegisterProperty( TableView::CELL_INDICES_PROPERTY_NAME, Vector2( 3, 4 ) );
652 tableView.Add( child1 );
653 // Check for actors at actual positions.
654 DALI_TEST_CHECK( tableView.GetChildAt(TableView::CellPosition(3,4)) == child1);
656 // Create a second child actor with the custom properties
657 Actor child2 = Actor::New();
659 float columnSpan = 2.f;
660 child2.RegisterProperty( TableView::CELL_INDICES_PROPERTY_NAME, Vector2( 6, 1 ) );
661 child2.RegisterProperty( TableView::ROW_SPAN_PROPERTY_NAME, rowSpan );
662 child2.RegisterProperty( TableView::COLUMN_SPAN_PROPERTY_NAME, columnSpan );
663 tableView.Add( child2 );
664 // Check for actors at actual positions.
665 for( int i=0; i<rowSpan; i++ )
667 for(int j=0; j<columnSpan; j++)
669 DALI_TEST_CHECK( tableView.GetChildAt(TableView::CellPosition(6+i,1+j)) == child2);