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";
44 const Vector2 CELL_SIZE( 10, 10 );
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( CELL_SIZE );
82 actor2.SetSize( CELL_SIZE );
83 actor3.SetSize( CELL_SIZE );
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 UtcDaliTableViewCtorCopyP(void)
94 TestApplication application;
96 TableView actor1 = TableView::New(10,10);
97 TableView actor2( actor1 );
99 DALI_TEST_EQUALS( actor1, actor2, TEST_LOCATION );
103 int UtcDaliTableViewNew(void)
105 ToolkitTestApplication application;
107 TableView tableView = TableView::New(10,10);
108 DALI_TEST_CHECK(tableView);
110 //Additional check to ensure object is created by checking if it's registered
111 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
112 DALI_TEST_CHECK( registry );
114 gObjectCreatedCallBackCalled = false;
115 registry.ObjectCreatedSignal().Connect(&TestCallback);
117 TableView tableView = TableView::New(10,10);
119 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
123 // Test adjusting the metric values for the cell.
124 int UtcDaliTableViewMetricsPadding(void)
126 ToolkitTestApplication application;
128 tet_infoline("UtcDaliTableViewMetricsPadding");
135 SetupTableViewAndActors(tableView, actor1, actor2, actor3);
137 // 1. check that padding works. no padding:
138 tableView.SetCellPadding(Size(0.0f, 0.0f));
139 application.SendNotification();
140 application.Render();
142 DALI_TEST_EQUALS( tableView.GetCellPadding(), Size(0.0f, 0.0f), TEST_LOCATION );
143 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
144 DALI_TEST_EQUALS( actor2.GetCurrentPosition(), Vector3(10.0f, 0.0f, 0.0f), TEST_LOCATION );
145 DALI_TEST_EQUALS( actor3.GetCurrentPosition(), Vector3(0.0f, 10.0f, 0.0f), TEST_LOCATION );
147 // 1. check that padding works. some padding:
148 tableView.SetCellPadding(Size(5.0f, 10.0f));
149 application.SendNotification();
150 application.Render();
152 DALI_TEST_EQUALS( tableView.GetCellPadding(), Size(5.0f, 10.0f), TEST_LOCATION );
153 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(5.0f, 10.0f, 0.0f), TEST_LOCATION );
157 // Test adjusting the metric values for the cell.
158 int UtcDaliTableViewMetricsFit(void)
160 ToolkitTestApplication application;
162 tet_infoline("UtcDaliTableViewMetricsFit");
169 SetupTableViewAndActors(tableView, actor1, actor2, actor3);
170 application.SendNotification();
171 application.Render();
173 // 1. check that with no fixed width/heights, actors are in default position.
174 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
175 DALI_TEST_EQUALS( actor2.GetCurrentPosition(), Vector3(10.0f, 0.0f, 0.0f), TEST_LOCATION );
176 DALI_TEST_EQUALS( actor3.GetCurrentPosition(), Vector3(0.0f, 10.0f, 0.0f), TEST_LOCATION );
178 // 2. check that with a fixed width & height, actors to the right and below are offsetted.
179 tableView.SetFitHeight(0);
180 tableView.SetFitWidth(0);
181 DALI_TEST_EQUALS( tableView.IsFitHeight(0), true, TEST_LOCATION );
182 DALI_TEST_EQUALS( tableView.IsFitWidth(0), true, TEST_LOCATION );
184 application.SendNotification();
185 application.Render();
187 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
188 DALI_TEST_EQUALS( actor2.GetCurrentPosition(), Vector3(10.0f, 0.0f, 0.0f), TEST_LOCATION );
189 DALI_TEST_EQUALS( actor3.GetCurrentPosition(), Vector3(0.0f, 10.0f, 0.0f), TEST_LOCATION );
193 // Test adjusting the metric values for the cell.
194 int UtcDaliTableViewMetricsFixed(void)
196 ToolkitTestApplication application;
198 tet_infoline("UtcDaliTableViewMetricsFixed");
205 SetupTableViewAndActors(tableView, actor1, actor2, actor3);
206 application.SendNotification();
207 application.Render();
209 // 1. check that with no fixed width/heights, actors are in default position.
210 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
211 DALI_TEST_EQUALS( actor2.GetCurrentPosition(), Vector3(10.0f, 0.0f, 0.0f), TEST_LOCATION );
212 DALI_TEST_EQUALS( actor3.GetCurrentPosition(), Vector3(0.0f, 10.0f, 0.0f), TEST_LOCATION );
214 // 2. check that with a fixed width & height, actors to the right and below are offsetted.
215 tableView.SetFixedWidth(0, 20.0f);
216 tableView.SetFixedHeight(0, 50.0f);
217 DALI_TEST_EQUALS( tableView.GetFixedWidth(0), 20.0f, TEST_LOCATION );
218 DALI_TEST_EQUALS( tableView.GetFixedHeight(0), 50.0f, TEST_LOCATION );
220 application.SendNotification();
221 application.Render();
223 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
224 DALI_TEST_EQUALS( actor2.GetCurrentPosition(), Vector3(20.0f, 0.0f, 0.0f), TEST_LOCATION );
225 DALI_TEST_EQUALS( actor3.GetCurrentPosition(), Vector3(0.0f, 50.0f, 0.0f), TEST_LOCATION );
229 // Test adjusting the metric values for the cell.
230 int UtcDaliTableViewMetricsRelative(void)
232 ToolkitTestApplication application;
234 tet_infoline("UtcDaliTableViewMetricsRelative");
241 SetupTableViewAndActors(tableView, actor1, actor2, actor3);
242 application.SendNotification();
243 application.Render();
245 // 1. check that with no relative width/heights, actors are in default position.
246 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
247 DALI_TEST_EQUALS( actor2.GetCurrentPosition(), Vector3(10.0f, 0.0f, 0.0f), TEST_LOCATION );
248 DALI_TEST_EQUALS( actor3.GetCurrentPosition(), Vector3(0.0f, 10.0f, 0.0f), TEST_LOCATION );
250 // 2. check that with a relative width & height, actors to the right and below are offsetted.
251 tableView.SetRelativeWidth(0, 0.3f); // cell 0,0 occupies 30%x50% of the grid (i.e. 30x50 pixels)
252 tableView.SetRelativeHeight(0, 0.5f);
253 DALI_TEST_EQUALS( tableView.GetRelativeWidth(0), 0.3f, TEST_LOCATION );
254 DALI_TEST_EQUALS( tableView.GetRelativeHeight(0), 0.5f, TEST_LOCATION );
256 application.SendNotification();
257 application.Render();
259 DALI_TEST_EQUALS( actor1.GetCurrentPosition(), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION );
260 DALI_TEST_EQUALS( actor2.GetCurrentPosition(), Vector3(30.0f, 0.0f, 0.0f), TEST_LOCATION );
261 DALI_TEST_EQUALS( actor3.GetCurrentPosition(), Vector3(0.0f, 50.0f, 0.0f), TEST_LOCATION );
266 // Test Adding/Removing/Finding Children.
267 int UtcDaliTableViewChild(void)
269 ToolkitTestApplication application;
271 tet_infoline("UtcDaliTableViewChild");
273 // Create a 10x10 table-view
274 TableView tableView = TableView::New(10,10);
275 DALI_TEST_CHECK( tableView );
277 // Check if actor doesn't exist.
278 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(0,0)) );
280 // Add an actor to it at 0,0
281 Actor actor = Actor::New();
282 tableView.AddChild(actor, TableView::CellPosition());
285 DALI_TEST_CHECK( tableView.GetChildAt(TableView::CellPosition(0,0)) );
288 tableView.RemoveChildAt(TableView::CellPosition());
290 // Check if actor no longer exists.
291 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(0,0)) );
293 // Add actor to it again, but at 2,5
294 tableView.AddChild(actor, TableView::CellPosition(2,5));
296 // Add another actor somewhere else 7,8
297 Actor actor2 = Actor::New();
298 tableView.AddChild(actor2, TableView::CellPosition(7,8));
302 // Check that no actor exists in a few random places.
303 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(0,0)) );
304 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(2,1)) );
305 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(6,3)) );
306 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(9,5)) );
308 // Check for actors at actual positions.
309 searchActor = tableView.GetChildAt(TableView::CellPosition(2,5));
310 DALI_TEST_CHECK( searchActor == actor);
312 searchActor = tableView.GetChildAt(TableView::CellPosition(7,8));
313 DALI_TEST_CHECK( searchActor == actor2);
315 // Create a second table, and add already added Child to new one.
316 TableView tableView2 = TableView::New(5,5);
317 tableView2.AddChild(actor, TableView::CellPosition(2,2));
318 DALI_TEST_CHECK( tableView2.GetChildAt(TableView::CellPosition(2,2)) );
322 // Test calling Add on it's own (to invoke the OnChildAdd)
323 int UtcDaliTableViewAdd(void)
325 ToolkitTestApplication application;
327 tet_infoline("UtcDaliTableViewAdd");
329 // Create a 4x1 table-view, and just keep adding.
330 TableView tableView = TableView::New(1,4);
331 DALI_TEST_CHECK( tableView );
333 for(unsigned int i = 0;i<16;i++)
335 Actor currentActor = Actor::New();
336 TableView::CellPosition position = TableView::CellPosition();
337 tableView.Add( currentActor );
338 tableView.FindChildPosition(currentActor, position);
339 tet_printf("%dx%d (%d,%d)\n", tableView.GetColumns(), tableView.GetRows(), position.columnIndex, position.rowIndex);
341 DALI_TEST_EQUALS((position.rowIndex * 4 + position.columnIndex), i, TEST_LOCATION);
346 // Test cell modification.
347 int UtcDaliTableViewCells(void)
349 ToolkitTestApplication application;
350 tet_infoline("UtcDaliTableViewCells");
352 // Create a 10x10 table-view
353 TableView tableView = TableView::New(10,10);
354 DALI_TEST_CHECK( tableView );
356 // Add a few actors to the table.
357 Actor actor1 = Actor::New();
358 Actor actor2 = Actor::New();
359 Actor actor3 = Actor::New();
360 actor1.SetName("Actor1");
361 actor2.SetName("Actor2");
362 actor3.SetName("Actor3");
364 // note: positions are specified in reversed cartesian coords - row,col (i.e. y,x)
365 tableView.AddChild(actor1, TableView::CellPosition(0,0));
366 tableView.AddChild(actor2, TableView::CellPosition(5,5));
367 tableView.AddChild(actor3, TableView::CellPosition(7,2));
369 DALI_TEST_CHECK( tableView.GetRows() == 10 && tableView.GetColumns() == 10 );
371 // Add a row between actor1 and actor2 | insert column on actor1 and see what happens...
372 tableView.InsertRow(3);
373 tableView.InsertColumn(0);
374 DALI_TEST_CHECK( tableView.GetRows() == 11 && tableView.GetColumns() == 11 );
376 TableView::CellPosition cellPosition;
379 result = tableView.FindChildPosition(actor1, cellPosition);
380 DALI_TEST_CHECK( result && cellPosition.rowIndex == 0 && cellPosition.columnIndex == 1);
381 result = tableView.FindChildPosition(actor2, cellPosition);
382 DALI_TEST_CHECK( result && cellPosition.rowIndex == 6 && cellPosition.columnIndex == 6);
383 result = tableView.FindChildPosition(actor3, cellPosition);
384 DALI_TEST_CHECK( result && cellPosition.rowIndex == 8 && cellPosition.columnIndex == 3);
386 // Delete a row between actor2 and actor3 | delete column on actor2 and see what happens...
387 tableView.DeleteRow(7);
388 tableView.DeleteColumn(6);
389 DALI_TEST_CHECK( tableView.GetRows() == 10 && tableView.GetColumns() == 10 );
391 result = tableView.FindChildPosition(actor1, cellPosition);
392 DALI_TEST_CHECK( result && cellPosition.rowIndex == 0 && cellPosition.columnIndex == 1);
393 result = tableView.FindChildPosition(actor2, cellPosition);
394 DALI_TEST_CHECK( !result );
395 result = tableView.FindChildPosition(actor3, cellPosition);
396 DALI_TEST_CHECK( result && cellPosition.rowIndex == 7 && cellPosition.columnIndex == 3);
398 // Delete the other two remaining actors by a row delete and a column delete.
399 std::vector<Actor> actorsRemoved;
400 tableView.DeleteRow(0, actorsRemoved);
401 tet_printf("Row Delete >> Actors Removed: %d {", actorsRemoved.size());
402 for(size_t i = 0;i<actorsRemoved.size();i++) tet_printf("%d => %s, ", i, actorsRemoved[i].GetName().c_str());
404 DALI_TEST_EQUALS( static_cast<int>(actorsRemoved.size()), 1, TEST_LOCATION );
405 DALI_TEST_CHECK( actorsRemoved[0] == actor1 );
407 actorsRemoved.clear();
408 tableView.DeleteColumn(3, actorsRemoved);
409 tet_printf("Column Delete >> Actors Removed: %d {", actorsRemoved.size());
410 for(size_t i = 0;i<actorsRemoved.size();i++) tet_printf("%d => %s, ", i, actorsRemoved[i].GetName().c_str());
412 DALI_TEST_EQUALS( static_cast<int>(actorsRemoved.size()), 1, TEST_LOCATION );
413 DALI_TEST_CHECK( actorsRemoved[0] == actor3 );
415 DALI_TEST_CHECK( tableView.GetRows() == 9 && tableView.GetColumns() == 9 );
417 tableView.AddChild(actor1, TableView::CellPosition(5,8));
418 tableView.Resize(100,100);
419 DALI_TEST_CHECK( tableView.GetRows() == 100 && tableView.GetColumns() == 100 );
421 tableView.AddChild(actor2, TableView::CellPosition(69,57));
422 DALI_TEST_CHECK( tableView.FindChildPosition(actor1, cellPosition) && tableView.FindChildPosition(actor2, cellPosition) );
424 tableView.Resize(20,20);
425 DALI_TEST_CHECK( tableView.FindChildPosition(actor1, cellPosition) && !tableView.FindChildPosition(actor2, cellPosition) );
427 actorsRemoved.clear();
428 tableView.Resize(1,1, actorsRemoved);
429 DALI_TEST_CHECK( !tableView.FindChildPosition(actor1, cellPosition) && !tableView.FindChildPosition(actor2, cellPosition) );
430 DALI_TEST_EQUALS( static_cast<int>(actorsRemoved.size()), 1, TEST_LOCATION );
431 DALI_TEST_CHECK( actorsRemoved[0] == actor1 );
433 // Add child outside table size, forcing a resize.
434 tableView.AddChild(actor1, TableView::CellPosition(100, 100, 1, 1));
435 DALI_TEST_CHECK( tableView.GetRows() == 101 && tableView.GetColumns() == 101 );
437 // Add child outside table size, forcing a resize.
438 tableView.AddChild(actor1, TableView::CellPosition(110, 110, 5, 5));
439 DALI_TEST_CHECK( tableView.GetRows() == 115 && tableView.GetColumns() == 115 );
441 DALI_TEST_CHECK( true );
445 int UtcDaliTableViewChildAssert(void)
447 ToolkitTestApplication application;
448 tet_infoline("UtcDaliTableViewChildAssert");
450 // Create a 10x10 table-view
451 TableView tableView = TableView::New(10,10);
452 DALI_TEST_CHECK( tableView );
457 tableView.AddChild( childActor, TableView::CellPosition(0,0,5,5) );
459 tet_result(TET_FAIL);
461 catch( Dali::DaliException& e )
463 DALI_TEST_PRINT_ASSERT( e );
464 DALI_TEST_EQUALS(e.condition, "child", TEST_LOCATION);
469 int UtcDaliTableViewMetricsAssert(void)
471 ToolkitTestApplication application;
472 tet_infoline("UtcDaliTableViewChildAssert");
474 // Create a 10x10 table-view
475 TableView tableView = TableView::New(10,10);
476 DALI_TEST_CHECK( tableView );
482 tableView.SetFixedHeight( 10, 1.0f );
484 tet_result(TET_FAIL);
486 catch( Dali::DaliException& e )
488 DALI_TEST_PRINT_ASSERT( e );
489 DALI_TEST_EQUALS(e.condition, "rowIndex < mRowData.Size()", TEST_LOCATION);
494 tableView.GetFixedHeight( 10 );
496 tet_result(TET_FAIL);
498 catch( Dali::DaliException& e )
500 DALI_TEST_PRINT_ASSERT( e );
501 DALI_TEST_EQUALS(e.condition, "rowIndex < mRowData.Size()", TEST_LOCATION);
506 tableView.SetFixedWidth( 10, 1.0f );
508 tet_result(TET_FAIL);
510 catch( Dali::DaliException& e )
512 DALI_TEST_PRINT_ASSERT( e );
513 DALI_TEST_EQUALS(e.condition, "columnIndex < mColumnData.Size()", TEST_LOCATION);
518 tableView.GetFixedWidth( 10 );
520 tet_result(TET_FAIL);
522 catch( Dali::DaliException& e )
524 DALI_TEST_PRINT_ASSERT( e );
525 DALI_TEST_EQUALS(e.condition, "columnIndex < mColumnData.Size()", TEST_LOCATION);
532 tableView.SetRelativeHeight( 10, 0.1f );
534 tet_result(TET_FAIL);
536 catch( Dali::DaliException& e )
538 DALI_TEST_PRINT_ASSERT( e );
539 DALI_TEST_EQUALS(e.condition, "rowIndex < mRowData.Size()", TEST_LOCATION);
544 tableView.GetRelativeHeight( 10 );
546 tet_result(TET_FAIL);
548 catch( Dali::DaliException& e )
550 DALI_TEST_PRINT_ASSERT( e );
551 DALI_TEST_EQUALS(e.condition, "rowIndex < mRowData.Size()", TEST_LOCATION);
556 tableView.SetRelativeWidth( 10, 0.1f );
558 tet_result(TET_FAIL);
560 catch( Dali::DaliException& e )
562 DALI_TEST_PRINT_ASSERT( e );
563 DALI_TEST_EQUALS(e.condition, "columnIndex < mColumnData.Size()", TEST_LOCATION);
568 tableView.GetRelativeWidth( 10 );
570 tet_result(TET_FAIL);
572 catch( Dali::DaliException& e )
574 DALI_TEST_PRINT_ASSERT( e );
575 DALI_TEST_EQUALS(e.condition, "columnIndex < mColumnData.Size()", TEST_LOCATION);
580 int UtcDaliTableViewSetGetProperty(void)
582 ToolkitTestApplication application;
583 tet_infoline("UtcDaliTableViewSetGetProperty");
585 // Create a 1x1 table-view
586 TableView tableView = TableView::New(1,1);
587 tableView.SetSize( Vector2( 100.0f, 100.0f ) );
588 DALI_TEST_CHECK( tableView );
590 // Test "rows" property
591 DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_ROWS ) == TableView::Property::ROWS );
593 tableView.SetProperty( TableView::Property::ROWS, 4u );
595 DALI_TEST_CHECK( tableView.GetRows() == 4u );
596 DALI_TEST_CHECK( tableView.GetProperty(TableView::Property::ROWS).Get<unsigned int>() == 4u );
598 // Test "columns" property
599 DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_COLUMNS ) == TableView::Property::COLUMNS );
601 tableView.SetProperty( TableView::Property::COLUMNS, 5u );
603 DALI_TEST_CHECK( tableView.GetColumns() == 5u );
604 DALI_TEST_CHECK( tableView.GetProperty(TableView::Property::COLUMNS).Get<unsigned int>() == 5u );
606 // Test "cell-padding" property
607 DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_CELL_PADDING ) == TableView::Property::CELL_PADDING );
609 tableView.SetProperty( TableView::Property::CELL_PADDING, Size( 6.f, 8.f ) );
611 DALI_TEST_EQUALS( tableView.GetCellPadding(), Size(6.f, 8.f), TEST_LOCATION );
612 DALI_TEST_EQUALS( tableView.GetProperty(TableView::Property::CELL_PADDING).Get<Vector2>(), Vector2(6.f,8.f), TEST_LOCATION );
614 //{ "policy": "fixed", "value": 30.0 },
616 item1[ "policy" ] = "fixed";
617 item1[ "value" ] = 30.f;
618 //{ "policy": "relative", "value": 0.2 },
620 item2[ "policy" ] = "relative";
621 item2[ "value" ] = 0.2f;
623 // Test "layout-rows" property
624 DALI_TEST_CHECK( tableView.GetPropertyIndex(PROPERTY_NAME_LAYOUT_ROWS) == TableView::Property::LAYOUT_ROWS );
629 * "1": { "policy": "fixed", "value": 30 },
630 * "3": { "policy": "relative", "value": 0.2 }
633 Property::Map layoutRows;
634 layoutRows[ "1" ] = item1;
635 layoutRows[ "3" ] = item2;
636 tableView.SetProperty( TableView::Property::LAYOUT_ROWS, layoutRows );
638 DALI_TEST_EQUALS( tableView.GetFixedHeight( 1u ), 30.f, TEST_LOCATION );
639 DALI_TEST_EQUALS( tableView.GetRelativeHeight( 3u ), 0.2f, TEST_LOCATION );
641 Property::Map layoutRowsGet = tableView.GetProperty(TableView::Property::LAYOUT_ROWS).Get<Property::Map>();
643 DALI_TEST_EQUALS( layoutRowsGet.GetKey(1).compare(layoutRows.GetKey(0)), 0, TEST_LOCATION );
644 DALI_TEST_CHECK( layoutRowsGet.GetValue(1).GetValue( "policy" ).Get<std::string>().compare(layoutRows.GetValue(0).GetValue( "policy" ).Get<std::string>()) == 0 );
645 DALI_TEST_EQUALS( layoutRowsGet.GetValue(1).GetValue( "value" ).Get<float>(), layoutRows.GetValue(0).GetValue( "value" ).Get<float>(), TEST_LOCATION );
647 DALI_TEST_CHECK( layoutRowsGet.GetKey(3).compare(layoutRows.GetKey(1)) == 0 );
648 DALI_TEST_CHECK( layoutRowsGet.GetValue(3).GetValue( "policy" ).Get<std::string>().compare(layoutRows.GetValue(1).GetValue( "policy" ).Get<std::string>()) == 0 );
649 DALI_TEST_EQUALS( layoutRowsGet.GetValue(3).GetValue( "value" ).Get<float>(), layoutRows.GetValue(1).GetValue( "value" ).Get<float>(), TEST_LOCATION );
651 // Test "layout-columns" property
652 DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_LAYOUT_COLUMNS ) == TableView::Property::LAYOUT_COLUMNS );
657 * "2": { "policy": "relative", "value": 0.2 },
658 * "3": { "policy": "fixed", "value": 30 }
661 Property::Map layoutColumns;
662 layoutColumns[ "2" ] = item2;
663 layoutColumns[ "3" ] = item1;
664 tableView.SetProperty( TableView::Property::LAYOUT_COLUMNS, layoutColumns );
666 DALI_TEST_EQUALS( tableView.GetRelativeWidth( 2u ), 0.2f, TEST_LOCATION );
667 DALI_TEST_EQUALS( tableView.GetFixedWidth( 3u ), 30.f, TEST_LOCATION );
669 Property::Map layoutColumnsGet = tableView.GetProperty(TableView::Property::LAYOUT_COLUMNS).Get<Property::Map>();
670 DALI_TEST_CHECK( layoutColumnsGet.GetKey(2).compare(layoutColumns.GetKey(0)) == 0 );
671 DALI_TEST_CHECK( layoutColumnsGet.GetValue(2).GetValue( "policy" ).Get<std::string>().compare(layoutColumns.GetValue(0).GetValue( "policy" ).Get<std::string>()) == 0 );
672 DALI_TEST_EQUALS( layoutColumnsGet.GetValue(2).GetValue( "value" ).Get<float>(),layoutColumns.GetValue(0).GetValue( "value" ).Get<float>(), TEST_LOCATION );
674 DALI_TEST_CHECK( layoutColumnsGet.GetKey(3).compare(layoutColumns.GetKey(1)) == 0 );
675 DALI_TEST_CHECK( layoutColumnsGet.GetValue(3).GetValue( "policy" ).Get<std::string>().compare(layoutColumns.GetValue(1).GetValue( "policy" ).Get<std::string>()) == 0 );
676 DALI_TEST_EQUALS( layoutColumnsGet.GetValue(3).GetValue( "value" ).Get<float>(),layoutColumns.GetValue(1).GetValue( "value" ).Get<float>(), TEST_LOCATION );
681 int UtcDaliTableViewCustomProperties(void)
683 ToolkitTestApplication application;
684 tet_infoline("UtcDaliTableViewCustomProperties");
686 // Create a 10x10 table-view
687 TableView tableView = TableView::New(10,10);
688 Constraint constraint = Constraint::New<Vector3>( tableView, Actor::Property::SIZE, Constraint100() );
690 DALI_TEST_CHECK( tableView );
692 // Create a child actor with the custom properties
693 Actor child1 = Actor::New();
694 child1.RegisterProperty( TableView::CELL_INDICES_PROPERTY_NAME, Vector2( 3, 4 ) );
695 tableView.Add( child1 );
696 // Check for actors at actual positions.
697 DALI_TEST_CHECK( tableView.GetChildAt(TableView::CellPosition(3,4)) == child1);
699 // Create a second child actor with the custom properties
700 Actor child2 = Actor::New();
702 float columnSpan = 2.f;
703 child2.RegisterProperty( TableView::CELL_INDICES_PROPERTY_NAME, Vector2( 6, 1 ) );
704 child2.RegisterProperty( TableView::ROW_SPAN_PROPERTY_NAME, rowSpan );
705 child2.RegisterProperty( TableView::COLUMN_SPAN_PROPERTY_NAME, columnSpan );
706 tableView.Add( child2 );
707 // Check for actors at actual positions.
708 for( int i=0; i<rowSpan; i++ )
710 for(int j=0; j<columnSpan; j++)
712 DALI_TEST_CHECK( tableView.GetChildAt(TableView::CellPosition(6+i,1+j)) == child2);