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_ANIMATION_DURATION = "layout-animation-duration";
43 const char* const PROPERTY_NAME_LAYOUT_ROWS = "layout-rows";
44 const char* const PROPERTY_NAME_LAYOUT_COLUMNS = "layout-columns";
47 static bool gObjectCreatedCallBackCalled;
49 static void TestCallback(BaseHandle handle)
51 gObjectCreatedCallBackCalled = true;
62 * function operator to apply the parent size
64 Dali::Vector3 operator()(const Dali::Vector3& current)
66 return Dali::Vector3( 100.0f, 100.0f, 100.0f );
70 // Convenience function to quickly set up a 10x10 table with each cell being 10x10 pixels in size by default.
71 static void SetupTableViewAndActors(TableView& tableView, Actor& actor1, Actor& actor2, Actor& actor3)
73 tableView = TableView::New(10,10); // 10 by 10 grid.
74 DALI_TEST_CHECK(tableView);
76 Stage::GetCurrent().Add( tableView );
77 tableView.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, Constraint100() ) );
78 tableView.SetLayoutAnimationDuration(0.0f);
80 actor1 = Actor::New();
81 actor2 = Actor::New();
82 actor3 = Actor::New();
84 actor1.SetSize(10,10);
85 actor2.SetSize(10,10);
86 actor3.SetSize(10,10);
88 tableView.AddChild(actor1, TableView::CellPosition(0,0));
89 tableView.AddChild(actor2, TableView::CellPosition(0,1));
90 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 animation duration setting.
224 int UtcDaliTableViewAnimation(void)
226 ToolkitTestApplication application;
228 tet_infoline("UtcDaliTableViewAnimation");
229 TableView tableView = TableView::New(10,10);
230 DALI_TEST_CHECK(tableView);
232 tableView.SetLayoutAnimationDuration(5.0f);
233 DALI_TEST_EQUALS(tableView.GetLayoutAnimationDuration(), 5.0f, TEST_LOCATION);
235 tableView.SetLayoutAnimationDuration(2.5f);
236 DALI_TEST_EQUALS(tableView.GetLayoutAnimationDuration(), 2.5f, TEST_LOCATION);
240 // Test Adding/Removing/Finding Children.
241 int UtcDaliTableViewChild(void)
243 ToolkitTestApplication application;
245 tet_infoline("UtcDaliTableViewChild");
247 // Create a 10x10 table-view
248 TableView tableView = TableView::New(10,10);
249 DALI_TEST_CHECK( tableView );
251 // Check if actor doesn't exist.
252 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(0,0)) );
254 // Add an actor to it at 0,0
255 Actor actor = Actor::New();
256 tableView.AddChild(actor, TableView::CellPosition());
259 DALI_TEST_CHECK( tableView.GetChildAt(TableView::CellPosition(0,0)) );
262 tableView.RemoveChildAt(TableView::CellPosition());
264 // Check if actor no longer exists.
265 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(0,0)) );
267 // Add actor to it again, but at 2,5
268 tableView.AddChild(actor, TableView::CellPosition(2,5));
270 // Add another actor somewhere else 7,8
271 Actor actor2 = Actor::New();
272 tableView.AddChild(actor2, TableView::CellPosition(7,8));
276 // Check that no actor exists in a few random places.
277 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(0,0)) );
278 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(2,1)) );
279 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(6,3)) );
280 DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(9,5)) );
282 // Check for actors at actual positions.
283 searchActor = tableView.GetChildAt(TableView::CellPosition(2,5));
284 DALI_TEST_CHECK( searchActor == actor);
286 searchActor = tableView.GetChildAt(TableView::CellPosition(7,8));
287 DALI_TEST_CHECK( searchActor == actor2);
289 // Create a second table, and add already added Child to new one.
290 TableView tableView2 = TableView::New(5,5);
291 tableView2.AddChild(actor, TableView::CellPosition(2,2));
292 DALI_TEST_CHECK( tableView2.GetChildAt(TableView::CellPosition(2,2)) );
296 // Test calling Add on it's own (to invoke the OnChildAdd)
297 int UtcDaliTableViewAdd(void)
299 ToolkitTestApplication application;
301 tet_infoline("UtcDaliTableViewAdd");
303 // Create a 4x1 table-view, and just keep adding.
304 TableView tableView = TableView::New(1,4);
305 DALI_TEST_CHECK( tableView );
307 for(unsigned int i = 0;i<16;i++)
309 Actor currentActor = Actor::New();
310 TableView::CellPosition position = TableView::CellPosition();
311 tableView.Add( currentActor );
312 tableView.FindChildPosition(currentActor, position);
313 tet_printf("%dx%d (%d,%d)\n", tableView.GetColumns(), tableView.GetRows(), position.columnIndex, position.rowIndex);
315 DALI_TEST_EQUALS((position.rowIndex * 4 + position.columnIndex), i, TEST_LOCATION);
320 // Test cell modification.
321 int UtcDaliTableViewCells(void)
323 ToolkitTestApplication application;
324 tet_infoline("UtcDaliTableViewCells");
326 // Create a 10x10 table-view
327 TableView tableView = TableView::New(10,10);
328 DALI_TEST_CHECK( tableView );
330 // Add a few actors to the table.
331 Actor actor1 = Actor::New();
332 Actor actor2 = Actor::New();
333 Actor actor3 = Actor::New();
334 actor1.SetName("Actor1");
335 actor2.SetName("Actor2");
336 actor3.SetName("Actor3");
338 // note: positions are specified in reversed cartesian coords - row,col (i.e. y,x)
339 tableView.AddChild(actor1, TableView::CellPosition(0,0));
340 tableView.AddChild(actor2, TableView::CellPosition(5,5));
341 tableView.AddChild(actor3, TableView::CellPosition(7,2));
343 DALI_TEST_CHECK( tableView.GetRows() == 10 && tableView.GetColumns() == 10 );
345 // Add a row between actor1 and actor2 | insert column on actor1 and see what happens...
346 tableView.InsertRow(3);
347 tableView.InsertColumn(0);
348 DALI_TEST_CHECK( tableView.GetRows() == 11 && tableView.GetColumns() == 11 );
350 TableView::CellPosition cellPosition;
353 result = tableView.FindChildPosition(actor1, cellPosition);
354 DALI_TEST_CHECK( result && cellPosition.rowIndex == 0 && cellPosition.columnIndex == 1);
355 result = tableView.FindChildPosition(actor2, cellPosition);
356 DALI_TEST_CHECK( result && cellPosition.rowIndex == 6 && cellPosition.columnIndex == 6);
357 result = tableView.FindChildPosition(actor3, cellPosition);
358 DALI_TEST_CHECK( result && cellPosition.rowIndex == 8 && cellPosition.columnIndex == 3);
360 // Delete a row between actor2 and actor3 | delete column on actor2 and see what happens...
361 tableView.DeleteRow(7);
362 tableView.DeleteColumn(6);
363 DALI_TEST_CHECK( tableView.GetRows() == 10 && tableView.GetColumns() == 10 );
365 result = tableView.FindChildPosition(actor1, cellPosition);
366 DALI_TEST_CHECK( result && cellPosition.rowIndex == 0 && cellPosition.columnIndex == 1);
367 result = tableView.FindChildPosition(actor2, cellPosition);
368 DALI_TEST_CHECK( !result );
369 result = tableView.FindChildPosition(actor3, cellPosition);
370 DALI_TEST_CHECK( result && cellPosition.rowIndex == 7 && cellPosition.columnIndex == 3);
372 // Delete the other two remaining actors by a row delete and a column delete.
373 std::vector<Actor> actorsRemoved;
374 tableView.DeleteRow(0, actorsRemoved);
375 tet_printf("Row Delete >> Actors Removed: %d {", actorsRemoved.size());
376 for(size_t i = 0;i<actorsRemoved.size();i++) tet_printf("%d => %s, ", i, actorsRemoved[i].GetName().c_str());
378 DALI_TEST_EQUALS( static_cast<int>(actorsRemoved.size()), 1, TEST_LOCATION );
379 DALI_TEST_CHECK( actorsRemoved[0] == actor1 );
381 actorsRemoved.clear();
382 tableView.DeleteColumn(3, actorsRemoved);
383 tet_printf("Column Delete >> Actors Removed: %d {", actorsRemoved.size());
384 for(size_t i = 0;i<actorsRemoved.size();i++) tet_printf("%d => %s, ", i, actorsRemoved[i].GetName().c_str());
386 DALI_TEST_EQUALS( static_cast<int>(actorsRemoved.size()), 1, TEST_LOCATION );
387 DALI_TEST_CHECK( actorsRemoved[0] == actor3 );
389 DALI_TEST_CHECK( tableView.GetRows() == 9 && tableView.GetColumns() == 9 );
391 tableView.AddChild(actor1, TableView::CellPosition(5,8));
392 tableView.Resize(100,100);
393 DALI_TEST_CHECK( tableView.GetRows() == 100 && tableView.GetColumns() == 100 );
395 tableView.AddChild(actor2, TableView::CellPosition(69,57));
396 DALI_TEST_CHECK( tableView.FindChildPosition(actor1, cellPosition) && tableView.FindChildPosition(actor2, cellPosition) );
398 tableView.Resize(20,20);
399 DALI_TEST_CHECK( tableView.FindChildPosition(actor1, cellPosition) && !tableView.FindChildPosition(actor2, cellPosition) );
401 actorsRemoved.clear();
402 tableView.Resize(1,1, actorsRemoved);
403 DALI_TEST_CHECK( !tableView.FindChildPosition(actor1, cellPosition) && !tableView.FindChildPosition(actor2, cellPosition) );
404 DALI_TEST_EQUALS( static_cast<int>(actorsRemoved.size()), 1, TEST_LOCATION );
405 DALI_TEST_CHECK( actorsRemoved[0] == actor1 );
407 // Add child outside table size, forcing a resize.
408 tableView.AddChild(actor1, TableView::CellPosition(100, 100, 1, 1));
409 DALI_TEST_CHECK( tableView.GetRows() == 101 && tableView.GetColumns() == 101 );
411 // Add child outside table size, forcing a resize.
412 tableView.AddChild(actor1, TableView::CellPosition(110, 110, 5, 5));
413 DALI_TEST_CHECK( tableView.GetRows() == 115 && tableView.GetColumns() == 115 );
415 DALI_TEST_CHECK( true );
419 int UtcDaliTableViewChildAssert(void)
421 ToolkitTestApplication application;
422 tet_infoline("UtcDaliTableViewChildAssert");
424 // Create a 10x10 table-view
425 TableView tableView = TableView::New(10,10);
426 DALI_TEST_CHECK( tableView );
431 tableView.AddChild( childActor, TableView::CellPosition(0,0,5,5) );
433 tet_result(TET_FAIL);
435 catch( Dali::DaliException& e )
437 DALI_TEST_PRINT_ASSERT( e );
438 DALI_TEST_EQUALS(e.condition, "child", TEST_LOCATION);
443 int UtcDaliTableViewMetricsAssert(void)
445 ToolkitTestApplication application;
446 tet_infoline("UtcDaliTableViewChildAssert");
448 // Create a 10x10 table-view
449 TableView tableView = TableView::New(10,10);
450 DALI_TEST_CHECK( tableView );
456 tableView.SetFixedHeight( 10, 1.0f );
458 tet_result(TET_FAIL);
460 catch( Dali::DaliException& e )
462 DALI_TEST_PRINT_ASSERT( e );
463 DALI_TEST_EQUALS(e.condition, "rowIndex < mFixedHeights.size()", TEST_LOCATION);
468 tableView.GetFixedHeight( 10 );
470 tet_result(TET_FAIL);
472 catch( Dali::DaliException& e )
474 DALI_TEST_PRINT_ASSERT( e );
475 DALI_TEST_EQUALS(e.condition, "rowIndex < mFixedHeights.size()", TEST_LOCATION);
480 tableView.SetFixedWidth( 10, 1.0f );
482 tet_result(TET_FAIL);
484 catch( Dali::DaliException& e )
486 DALI_TEST_PRINT_ASSERT( e );
487 DALI_TEST_EQUALS(e.condition, "columnIndex < mFixedWidths.size()", TEST_LOCATION);
492 tableView.GetFixedWidth( 10 );
494 tet_result(TET_FAIL);
496 catch( Dali::DaliException& e )
498 DALI_TEST_PRINT_ASSERT( e );
499 DALI_TEST_EQUALS(e.condition, "columnIndex < mFixedWidths.size()", TEST_LOCATION);
506 tableView.SetRelativeHeight( 10, 0.1f );
508 tet_result(TET_FAIL);
510 catch( Dali::DaliException& e )
512 DALI_TEST_PRINT_ASSERT( e );
513 DALI_TEST_EQUALS(e.condition, "rowIndex < mRelativeHeights.size()", TEST_LOCATION);
518 tableView.GetRelativeHeight( 10 );
520 tet_result(TET_FAIL);
522 catch( Dali::DaliException& e )
524 DALI_TEST_PRINT_ASSERT( e );
525 DALI_TEST_EQUALS(e.condition, "rowIndex < mRelativeHeights.size()", TEST_LOCATION);
530 tableView.SetRelativeWidth( 10, 0.1f );
532 tet_result(TET_FAIL);
534 catch( Dali::DaliException& e )
536 DALI_TEST_PRINT_ASSERT( e );
537 DALI_TEST_EQUALS(e.condition, "columnIndex < mRelativeWidths.size()", TEST_LOCATION);
542 tableView.GetRelativeWidth( 10 );
544 tet_result(TET_FAIL);
546 catch( Dali::DaliException& e )
548 DALI_TEST_PRINT_ASSERT( e );
549 DALI_TEST_EQUALS(e.condition, "columnIndex < mRelativeWidths.size()", TEST_LOCATION);
554 int UtcDaliTableViewSetGetProperty(void)
556 ToolkitTestApplication application;
557 tet_infoline("UtcDaliTableViewSetGetProperty");
559 // Create a 1x1 table-view
560 TableView tableView = TableView::New(1,1);
561 tableView.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, Constraint100() ) );
562 DALI_TEST_CHECK( tableView );
564 // Test "rows" property
565 DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_ROWS ) == TableView::PROPERTY_ROWS );
567 tableView.SetProperty( TableView::PROPERTY_ROWS, 4u );
569 DALI_TEST_CHECK( tableView.GetRows() == 4u );
570 DALI_TEST_CHECK( tableView.GetProperty(TableView::PROPERTY_ROWS).Get<unsigned int>() == 4u );
572 // Test "columns" property
573 DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_COLUMNS ) == TableView::PROPERTY_COLUMNS );
575 tableView.SetProperty( TableView::PROPERTY_COLUMNS, 5u );
577 DALI_TEST_CHECK( tableView.GetColumns() == 5u );
578 DALI_TEST_CHECK( tableView.GetProperty(TableView::PROPERTY_COLUMNS).Get<unsigned int>() == 5u );
580 // Test "cell-padding" property
581 DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_CELL_PADDING ) == TableView::PROPERTY_CELL_PADDING );
583 tableView.SetProperty( TableView::PROPERTY_CELL_PADDING, Size( 6.f, 8.f ) );
585 DALI_TEST_EQUALS( tableView.GetCellPadding(), Size(6.f, 8.f), TEST_LOCATION );
586 DALI_TEST_EQUALS( tableView.GetProperty(TableView::PROPERTY_CELL_PADDING).Get<Vector2>(), Vector2(6.f,8.f), TEST_LOCATION );
588 // Test "layout-animation-duration" property
589 DALI_TEST_CHECK( tableView.GetPropertyIndex(PROPERTY_NAME_LAYOUT_ANIMATION_DURATION) == TableView::PROPERTY_LAYOUT_ANIMATION_DURATION );
591 tableView.SetProperty( TableView::PROPERTY_LAYOUT_ANIMATION_DURATION, 1.5f );
593 DALI_TEST_EQUALS( tableView.GetLayoutAnimationDuration(), 1.5f, TEST_LOCATION );
594 DALI_TEST_EQUALS( tableView.GetProperty(TableView::PROPERTY_LAYOUT_ANIMATION_DURATION).Get<float>(), 1.5f, TEST_LOCATION );
596 //{ "policy": "fixed", "value": 30.0 },
598 item1[ "policy" ] = "fixed";
599 item1[ "value" ] = 30.f;
600 //{ "policy": "relative", "value": 0.2 },
602 item2[ "policy" ] = "relative";
603 item2[ "value" ] = 0.2f;
605 // Test "layout-rows" property
606 DALI_TEST_CHECK( tableView.GetPropertyIndex(PROPERTY_NAME_LAYOUT_ROWS) == TableView::PROPERTY_LAYOUT_ROWS );
611 * "1": { "policy": "fixed", "value": 30 },
612 * "3": { "policy": "relative", "value": 0.2 }
615 Property::Map layoutRows;
616 layoutRows[ "1" ] = item1;
617 layoutRows[ "3" ] = item2;
618 tableView.SetProperty( TableView::PROPERTY_LAYOUT_ROWS, layoutRows );
620 DALI_TEST_EQUALS( tableView.GetFixedHeight( 1u ), 30.f, TEST_LOCATION );
621 DALI_TEST_EQUALS( tableView.GetRelativeHeight( 3u ), 0.2f, TEST_LOCATION );
623 Property::Map layoutRowsGet = tableView.GetProperty(TableView::PROPERTY_LAYOUT_ROWS).Get<Property::Map>();
624 DALI_TEST_CHECK( layoutRowsGet.GetKey(0).compare(layoutRows.GetKey(0)) == 0 );
625 DALI_TEST_CHECK( layoutRowsGet.GetValue(0).GetValue( "policy" ).Get<std::string>().compare(layoutRows.GetValue(0).GetValue( "policy" ).Get<std::string>()) == 0 );
626 DALI_TEST_EQUALS( layoutRowsGet.GetValue(0).GetValue( "value" ).Get<float>(),layoutRows.GetValue(0).GetValue( "value" ).Get<float>(), TEST_LOCATION );
627 DALI_TEST_CHECK( layoutRowsGet.GetKey(1).compare(layoutRows.GetKey(1)) == 0 );
628 DALI_TEST_CHECK( layoutRowsGet.GetValue(1).GetValue( "policy" ).Get<std::string>().compare(layoutRows.GetValue(1).GetValue( "policy" ).Get<std::string>()) == 0 );
629 DALI_TEST_EQUALS( layoutRowsGet.GetValue(1).GetValue( "value" ).Get<float>(),layoutRows.GetValue(1).GetValue( "value" ).Get<float>(), TEST_LOCATION );
631 // Test "layout-columns" property
632 DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_LAYOUT_COLUMNS ) == TableView::PROPERTY_LAYOUT_COLUMNS );
637 * "2": { "policy": "relative", "value": 0.2 },
638 * "3": { "policy": "fixed", "value": 30 }
641 Property::Map layoutColumns;
642 layoutColumns[ "2" ] = item2;
643 layoutColumns[ "3" ] = item1;
644 tableView.SetProperty( TableView::PROPERTY_LAYOUT_COLUMNS, layoutColumns );
646 DALI_TEST_EQUALS( tableView.GetRelativeWidth( 2u ), 0.2f, TEST_LOCATION );
647 DALI_TEST_EQUALS( tableView.GetFixedWidth( 3u ), 30.f, TEST_LOCATION );
649 Property::Map layoutColumnsGet = tableView.GetProperty(TableView::PROPERTY_LAYOUT_COLUMNS).Get<Property::Map>();
650 DALI_TEST_CHECK( layoutColumnsGet.GetKey(0).compare(layoutColumns.GetKey(0)) == 0 );
651 DALI_TEST_CHECK( layoutColumnsGet.GetValue(0).GetValue( "policy" ).Get<std::string>().compare(layoutColumns.GetValue(0).GetValue( "policy" ).Get<std::string>()) == 0 );
652 DALI_TEST_EQUALS( layoutColumnsGet.GetValue(0).GetValue( "value" ).Get<float>(),layoutColumns.GetValue(0).GetValue( "value" ).Get<float>(), TEST_LOCATION );
653 DALI_TEST_CHECK( layoutColumnsGet.GetKey(1).compare(layoutColumns.GetKey(1)) == 0 );
654 DALI_TEST_CHECK( layoutColumnsGet.GetValue(1).GetValue( "policy" ).Get<std::string>().compare(layoutColumns.GetValue(1).GetValue( "policy" ).Get<std::string>()) == 0 );
655 DALI_TEST_EQUALS( layoutColumnsGet.GetValue(1).GetValue( "value" ).Get<float>(),layoutColumns.GetValue(1).GetValue( "value" ).Get<float>(), TEST_LOCATION );
660 int UtcDaliTableViewCustomProperties(void)
662 ToolkitTestApplication application;
663 tet_infoline("UtcDaliTableViewCustomProperties");
665 // Create a 10x10 table-view
666 TableView tableView = TableView::New(10,10);
667 tableView.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, Constraint100() ) );
668 DALI_TEST_CHECK( tableView );
670 // Create a child actor with the custom properties
671 Actor child1 = Actor::New();
672 child1.RegisterProperty( TableView::CELL_INDICES_PROPERTY_NAME, Vector2( 3, 4 ) );
673 tableView.Add( child1 );
674 // Check for actors at actual positions.
675 DALI_TEST_CHECK( tableView.GetChildAt(TableView::CellPosition(3,4)) == child1);
677 // Create a second child actor with the custom properties
678 Actor child2 = Actor::New();
680 float columnSpan = 2.f;
681 child2.RegisterProperty( TableView::CELL_INDICES_PROPERTY_NAME, Vector2( 6, 1 ) );
682 child2.RegisterProperty( TableView::ROW_SPAN_PROPERTY_NAME, rowSpan );
683 child2.RegisterProperty( TableView::COLUMN_SPAN_PROPERTY_NAME, columnSpan );
684 tableView.Add( child2 );
685 // Check for actors at actual positions.
686 for( int i=0; i<rowSpan; i++ )
688 for(int j=0; j<columnSpan; j++)
690 DALI_TEST_CHECK( tableView.GetChildAt(TableView::CellPosition(6+i,1+j)) == child2);