Merge "Fix for lock up on Text Shadow ( not clearing up rendertask correctly )" into...
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TableView.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <iostream>
19 #include <stdlib.h>
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <dali-toolkit/dali-toolkit.h>
22
23 using namespace Dali;
24 using namespace Toolkit;
25
26 void dali_tableview_startup(void)
27 {
28   test_return_value = TET_UNDEF;
29 }
30
31 void dali_tableview_cleanup(void)
32 {
33   test_return_value = TET_PASS;
34 }
35
36 namespace
37 {
38
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
45 static bool gObjectCreatedCallBackCalled;
46
47 static void TestCallback(BaseHandle handle)
48 {
49   gObjectCreatedCallBackCalled = true;
50 }
51
52 struct Constraint100
53 {
54   Constraint100( )
55   {
56   }
57
58   /**
59    * function operator to apply the parent size
60    */
61   Dali::Vector3 operator()(const Dali::Vector3& current)
62   {
63     return Dali::Vector3( 100.0f, 100.0f, 100.0f );
64   }
65 };
66
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)
69 {
70   tableView = TableView::New( 10, 10 ); // 10 by 10 grid.
71   DALI_TEST_CHECK( tableView );
72
73   tableView.SetRelayoutEnabled( true );
74
75   Stage::GetCurrent().Add( tableView );
76   tableView.SetPreferredSize( Dali::Vector2( 100.0f, 100.0f ) );
77
78   actor1 = Actor::New();
79   actor2 = Actor::New();
80   actor3 = Actor::New();
81
82   actor1.SetRelayoutEnabled( true );
83   actor1.SetPreferredSize( Dali::Vector2( 10, 10 ) );
84   actor2.SetRelayoutEnabled( true );
85   actor2.SetPreferredSize( Dali::Vector2( 10, 10 ) );
86   actor3.SetRelayoutEnabled( true );
87   actor3.SetPreferredSize( Dali::Vector2( 10, 10 ) );
88
89   tableView.AddChild( actor1, TableView::CellPosition( 0, 0 ) );
90   tableView.AddChild( actor2, TableView::CellPosition( 0, 1 ) );
91   tableView.AddChild( actor3, TableView::CellPosition( 1, 0 ) );
92 }
93
94 } // namespace
95
96 int UtcDaliTableViewNew(void)
97 {
98   ToolkitTestApplication application;
99
100   TableView tableView = TableView::New(10,10);
101   DALI_TEST_CHECK(tableView);
102
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 );
106
107   gObjectCreatedCallBackCalled = false;
108   registry.ObjectCreatedSignal().Connect(&TestCallback);
109   {
110     TableView tableView = TableView::New(10,10);
111   }
112   DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
113   END_TEST;
114 }
115
116 // Test adjusting the metric values for the cell.
117 int UtcDaliTableViewMetricsPadding(void)
118 {
119   ToolkitTestApplication application;
120
121   tet_infoline("UtcDaliTableViewMetricsPadding");
122
123   TableView tableView;
124   Actor actor1;
125   Actor actor2;
126   Actor actor3;
127
128   SetupTableViewAndActors(tableView, actor1, actor2, actor3);
129
130   // 1. check that padding works. no padding:
131   tableView.SetCellPadding(Size(0.0f, 0.0f));
132   application.SendNotification();
133   application.Render();
134
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 );
139
140   // 1. check that padding works. some padding:
141   tableView.SetCellPadding(Size(5.0f, 10.0f));
142   application.SendNotification();
143   application.Render();
144
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 );
147   END_TEST;
148 }
149
150 // Test adjusting the metric values for the cell.
151 int UtcDaliTableViewMetricsFixed(void)
152 {
153   ToolkitTestApplication application;
154
155   tet_infoline("UtcDaliTableViewMetricsFixed");
156
157   TableView tableView;
158   Actor actor1;
159   Actor actor2;
160   Actor actor3;
161
162   SetupTableViewAndActors(tableView, actor1, actor2, actor3);
163   application.SendNotification();
164   application.Render();
165
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 );
170
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 );
176
177   application.SendNotification();
178   application.Render();
179
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 );
183   END_TEST;
184 }
185
186 // Test adjusting the metric values for the cell.
187 int UtcDaliTableViewMetricsRelative(void)
188 {
189   ToolkitTestApplication application;
190
191   tet_infoline("UtcDaliTableViewMetricsRelative");
192
193   TableView tableView;
194   Actor actor1;
195   Actor actor2;
196   Actor actor3;
197
198   SetupTableViewAndActors(tableView, actor1, actor2, actor3);
199   application.SendNotification();
200   application.Render();
201
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 );
206
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 );
212
213   application.SendNotification();
214   application.Render();
215
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 );
219   END_TEST;
220 }
221
222
223 // Test Adding/Removing/Finding Children.
224 int UtcDaliTableViewChild(void)
225 {
226   ToolkitTestApplication application;
227
228   tet_infoline("UtcDaliTableViewChild");
229
230   // Create a 10x10 table-view
231   TableView tableView = TableView::New(10,10);
232   DALI_TEST_CHECK( tableView );
233
234   // Check if actor doesn't exist.
235   DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(0,0)) );
236
237   // Add an actor to it at 0,0
238   Actor actor = Actor::New();
239   tableView.AddChild(actor, TableView::CellPosition());
240
241   // Check if exists.
242   DALI_TEST_CHECK( tableView.GetChildAt(TableView::CellPosition(0,0)) );
243
244   // Remove this actor
245   tableView.RemoveChildAt(TableView::CellPosition());
246
247   // Check if actor no longer exists.
248   DALI_TEST_CHECK( !tableView.GetChildAt(TableView::CellPosition(0,0)) );
249
250   // Add actor to it again, but at 2,5
251   tableView.AddChild(actor, TableView::CellPosition(2,5));
252
253   // Add another actor somewhere else 7,8
254   Actor actor2 = Actor::New();
255   tableView.AddChild(actor2, TableView::CellPosition(7,8));
256
257   Actor searchActor;
258
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)) );
264
265   // Check for actors at actual positions.
266   searchActor = tableView.GetChildAt(TableView::CellPosition(2,5));
267   DALI_TEST_CHECK( searchActor == actor);
268
269   searchActor = tableView.GetChildAt(TableView::CellPosition(7,8));
270   DALI_TEST_CHECK( searchActor == actor2);
271
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)) );
276   END_TEST;
277 }
278
279 // Test calling Add on it's own (to invoke the OnChildAdd)
280 int UtcDaliTableViewAdd(void)
281 {
282   ToolkitTestApplication application;
283
284   tet_infoline("UtcDaliTableViewAdd");
285
286   // Create a 4x1 table-view, and just keep adding.
287   TableView tableView = TableView::New(1,4);
288   DALI_TEST_CHECK( tableView );
289
290   for(unsigned int i = 0;i<16;i++)
291   {
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);
297
298     DALI_TEST_EQUALS((position.rowIndex * 4 + position.columnIndex), i, TEST_LOCATION);
299   }
300   END_TEST;
301 }
302
303 // Test cell modification.
304 int UtcDaliTableViewCells(void)
305 {
306   ToolkitTestApplication application;
307   tet_infoline("UtcDaliTableViewCells");
308
309   // Create a 10x10 table-view
310   TableView tableView = TableView::New(10,10);
311   DALI_TEST_CHECK( tableView );
312
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");
320
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));
325
326   DALI_TEST_CHECK( tableView.GetRows() == 10 && tableView.GetColumns() == 10 );
327
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 );
332
333   TableView::CellPosition cellPosition;
334   bool result;
335
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);
342
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 );
347
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);
354
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());
360   tet_printf("}\n");
361   DALI_TEST_EQUALS( static_cast<int>(actorsRemoved.size()), 1, TEST_LOCATION );
362   DALI_TEST_CHECK( actorsRemoved[0] == actor1 );
363
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());
368   tet_printf("}\n");
369   DALI_TEST_EQUALS( static_cast<int>(actorsRemoved.size()), 1, TEST_LOCATION );
370   DALI_TEST_CHECK( actorsRemoved[0] == actor3 );
371
372   DALI_TEST_CHECK( tableView.GetRows() == 9 && tableView.GetColumns() == 9 );
373
374   tableView.AddChild(actor1, TableView::CellPosition(5,8));
375   tableView.Resize(100,100);
376   DALI_TEST_CHECK( tableView.GetRows() == 100 && tableView.GetColumns() == 100 );
377
378   tableView.AddChild(actor2, TableView::CellPosition(69,57));
379   DALI_TEST_CHECK( tableView.FindChildPosition(actor1, cellPosition) && tableView.FindChildPosition(actor2, cellPosition) );
380
381   tableView.Resize(20,20);
382   DALI_TEST_CHECK( tableView.FindChildPosition(actor1, cellPosition) && !tableView.FindChildPosition(actor2, cellPosition) );
383
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 );
389
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 );
393
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 );
397
398   DALI_TEST_CHECK( true );
399   END_TEST;
400 }
401
402 int UtcDaliTableViewChildAssert(void)
403 {
404   ToolkitTestApplication application;
405   tet_infoline("UtcDaliTableViewChildAssert");
406
407   // Create a 10x10 table-view
408   TableView tableView = TableView::New(10,10);
409   DALI_TEST_CHECK( tableView );
410   Actor childActor;
411
412   try
413   {
414     tableView.AddChild( childActor, TableView::CellPosition(0,0,5,5) );
415     // should assert
416     tet_result(TET_FAIL);
417   }
418   catch( Dali::DaliException& e )
419   {
420     DALI_TEST_PRINT_ASSERT( e );
421     DALI_TEST_EQUALS(e.condition, "child", TEST_LOCATION);
422   }
423   END_TEST;
424 }
425
426 int UtcDaliTableViewMetricsAssert(void)
427 {
428   ToolkitTestApplication application;
429   tet_infoline("UtcDaliTableViewChildAssert");
430
431   // Create a 10x10 table-view
432   TableView tableView = TableView::New(10,10);
433   DALI_TEST_CHECK( tableView );
434
435   // fixeds...
436
437   try
438   {
439     tableView.SetFixedHeight( 10, 1.0f );
440
441     tet_result(TET_FAIL);
442   }
443   catch( Dali::DaliException& e )
444   {
445     DALI_TEST_PRINT_ASSERT( e );
446     DALI_TEST_EQUALS(e.condition, "rowIndex < mRowData.Size()", TEST_LOCATION);
447   }
448
449   try
450   {
451     tableView.GetFixedHeight( 10 );
452
453     tet_result(TET_FAIL);
454   }
455   catch( Dali::DaliException& e )
456   {
457     DALI_TEST_PRINT_ASSERT( e );
458     DALI_TEST_EQUALS(e.condition, "rowIndex < mRowData.Size()", TEST_LOCATION);
459   }
460
461   try
462   {
463     tableView.SetFixedWidth( 10, 1.0f );
464
465     tet_result(TET_FAIL);
466   }
467   catch( Dali::DaliException& e )
468   {
469     DALI_TEST_PRINT_ASSERT( e );
470     DALI_TEST_EQUALS(e.condition, "columnIndex < mColumnData.Size()", TEST_LOCATION);
471   }
472
473   try
474   {
475     tableView.GetFixedWidth( 10 );
476
477     tet_result(TET_FAIL);
478   }
479   catch( Dali::DaliException& e )
480   {
481     DALI_TEST_PRINT_ASSERT( e );
482     DALI_TEST_EQUALS(e.condition, "columnIndex < mColumnData.Size()", TEST_LOCATION);
483   }
484
485   // relatives...
486
487   try
488   {
489     tableView.SetRelativeHeight( 10, 0.1f );
490
491     tet_result(TET_FAIL);
492   }
493   catch( Dali::DaliException& e )
494   {
495     DALI_TEST_PRINT_ASSERT( e );
496     DALI_TEST_EQUALS(e.condition, "rowIndex < mRowData.Size()", TEST_LOCATION);
497   }
498
499   try
500   {
501     tableView.GetRelativeHeight( 10 );
502
503     tet_result(TET_FAIL);
504   }
505   catch( Dali::DaliException& e )
506   {
507     DALI_TEST_PRINT_ASSERT( e );
508     DALI_TEST_EQUALS(e.condition, "rowIndex < mRowData.Size()", TEST_LOCATION);
509   }
510
511   try
512   {
513     tableView.SetRelativeWidth( 10, 0.1f );
514
515     tet_result(TET_FAIL);
516   }
517   catch( Dali::DaliException& e )
518   {
519     DALI_TEST_PRINT_ASSERT( e );
520     DALI_TEST_EQUALS(e.condition, "columnIndex < mColumnData.Size()", TEST_LOCATION);
521   }
522
523   try
524   {
525     tableView.GetRelativeWidth( 10 );
526
527     tet_result(TET_FAIL);
528   }
529   catch( Dali::DaliException& e )
530   {
531     DALI_TEST_PRINT_ASSERT( e );
532     DALI_TEST_EQUALS(e.condition, "columnIndex < mColumnData.Size()", TEST_LOCATION);
533   }
534   END_TEST;
535 }
536
537 int UtcDaliTableViewSetGetProperty(void)
538 {
539   ToolkitTestApplication application;
540   tet_infoline("UtcDaliTableViewSetGetProperty");
541
542   // Create a 1x1 table-view
543   TableView tableView = TableView::New(1,1);
544   tableView.SetPreferredSize( Vector2( 100.0f, 100.0f ) );
545   DALI_TEST_CHECK( tableView );
546
547   // Test "rows" property
548   DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_ROWS ) == TableView::Property::ROWS );
549
550   tableView.SetProperty( TableView::Property::ROWS, 4u );
551
552   DALI_TEST_CHECK( tableView.GetRows() == 4u );
553   DALI_TEST_CHECK( tableView.GetProperty(TableView::Property::ROWS).Get<unsigned int>() == 4u );
554
555   // Test "columns" property
556   DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_COLUMNS ) == TableView::Property::COLUMNS );
557
558   tableView.SetProperty( TableView::Property::COLUMNS, 5u );
559
560   DALI_TEST_CHECK( tableView.GetColumns() == 5u );
561   DALI_TEST_CHECK( tableView.GetProperty(TableView::Property::COLUMNS).Get<unsigned int>() == 5u );
562
563   // Test "cell-padding" property
564   DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_CELL_PADDING ) == TableView::Property::CELL_PADDING );
565
566   tableView.SetProperty( TableView::Property::CELL_PADDING, Size( 6.f, 8.f ) );
567
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 );
570
571   //{ "policy": "fixed", "value": 30.0 },
572   Property::Map item1;
573   item1[ "policy" ] = "fixed";
574   item1[ "value" ] = 30.f;
575   //{ "policy": "relative", "value": 0.2 },
576   Property::Map item2;
577   item2[ "policy" ] = "relative";
578   item2[ "value" ] = 0.2f;
579
580   // Test "layout-rows" property
581   DALI_TEST_CHECK( tableView.GetPropertyIndex(PROPERTY_NAME_LAYOUT_ROWS) == TableView::Property::LAYOUT_ROWS );
582
583   /*
584    * "layout-rows":
585    *  {
586    *    "1": { "policy": "fixed", "value": 30 },
587    *    "3": { "policy": "relative", "value": 0.2 }
588    *   }
589    */
590   Property::Map layoutRows;
591   layoutRows[ "1" ] = item1;
592   layoutRows[ "3" ] = item2;
593   tableView.SetProperty( TableView::Property::LAYOUT_ROWS, layoutRows );
594
595   DALI_TEST_EQUALS( tableView.GetFixedHeight( 1u ), 30.f, TEST_LOCATION );
596   DALI_TEST_EQUALS( tableView.GetRelativeHeight( 3u ), 0.2f, TEST_LOCATION );
597
598   Property::Map layoutRowsGet = tableView.GetProperty(TableView::Property::LAYOUT_ROWS).Get<Property::Map>();
599
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 );
603
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 );
607
608   // Test "layout-columns" property
609   DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_LAYOUT_COLUMNS ) == TableView::Property::LAYOUT_COLUMNS );
610
611   /*
612    * "layout-columns":
613    *  {
614    *    "2": { "policy": "relative", "value": 0.2 },
615    *    "3": { "policy": "fixed", "value": 30 }
616    *   }
617    */
618   Property::Map layoutColumns;
619   layoutColumns[ "2" ] = item2;
620   layoutColumns[ "3" ] = item1;
621   tableView.SetProperty( TableView::Property::LAYOUT_COLUMNS, layoutColumns );
622
623   DALI_TEST_EQUALS( tableView.GetRelativeWidth( 2u ), 0.2f, TEST_LOCATION );
624   DALI_TEST_EQUALS( tableView.GetFixedWidth( 3u ), 30.f, TEST_LOCATION );
625
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 );
630
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 );
634
635   END_TEST;
636 }
637
638 int UtcDaliTableViewCustomProperties(void)
639 {
640   ToolkitTestApplication application;
641   tet_infoline("UtcDaliTableViewCustomProperties");
642
643   // Create a 10x10 table-view
644   TableView tableView = TableView::New(10,10);
645   tableView.ApplyConstraint( Constraint::New<Vector3>( Actor::Property::SIZE, Constraint100() ) );
646   DALI_TEST_CHECK( tableView );
647
648   // Create a child actor with the custom properties
649   Actor child1 = Actor::New();
650   child1.RegisterProperty( TableView::CELL_INDICES_PROPERTY_NAME, Vector2( 3, 4 ) );
651   tableView.Add( child1 );
652   // Check for actors at actual positions.
653   DALI_TEST_CHECK( tableView.GetChildAt(TableView::CellPosition(3,4)) == child1);
654
655   // Create a second child actor with the custom properties
656   Actor child2 = Actor::New();
657   float rowSpan = 3.f;
658   float columnSpan = 2.f;
659   child2.RegisterProperty( TableView::CELL_INDICES_PROPERTY_NAME, Vector2( 6, 1 ) );
660   child2.RegisterProperty( TableView::ROW_SPAN_PROPERTY_NAME, rowSpan );
661   child2.RegisterProperty( TableView::COLUMN_SPAN_PROPERTY_NAME, columnSpan );
662   tableView.Add( child2 );
663   // Check for actors at actual positions.
664   for( int i=0; i<rowSpan; i++ )
665   {
666     for(int j=0; j<columnSpan; j++)
667     {
668       DALI_TEST_CHECK( tableView.GetChildAt(TableView::CellPosition(6+i,1+j)) == child2);
669     }
670   }
671
672   END_TEST;
673 }