5ec6b5f44a1ac94a56fc9a337533b8c4a5571157
[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 <dali-toolkit-test-suite-utils.h>
19 #include <dali-toolkit/dali-toolkit.h>
20 #include <dali-toolkit/devel-api/controls/table-view/table-view.h>
21 #include <stdlib.h>
22 #include <iostream>
23 #include <sstream>
24
25 using namespace Dali;
26 using namespace Toolkit;
27
28 void dali_tableview_startup(void)
29 {
30   test_return_value = TET_UNDEF;
31 }
32
33 void dali_tableview_cleanup(void)
34 {
35   test_return_value = TET_PASS;
36 }
37
38 namespace
39 {
40 const char* const PROPERTY_NAME_ROWS           = "rows";
41 const char* const PROPERTY_NAME_COLUMNS        = "columns";
42 const char* const PROPERTY_NAME_CELL_PADDING   = "cellPadding";
43 const char* const PROPERTY_NAME_LAYOUT_ROWS    = "layoutRows";
44 const char* const PROPERTY_NAME_LAYOUT_COLUMNS = "layoutColumns";
45 const Vector2     CELL_SIZE(10, 10);
46
47 static bool gObjectCreatedCallBackCalled;
48
49 static void TestCallback(BaseHandle handle)
50 {
51   gObjectCreatedCallBackCalled = true;
52 }
53
54 struct Constraint100
55 {
56   Constraint100()
57   {
58   }
59
60   /**
61    * function operator to apply the parent size
62    */
63   void operator()(Dali::Vector3& current, const PropertyInputContainer& /* inputs */)
64   {
65     current.x = current.y = current.z = 100.0f;
66   }
67 };
68
69 // Convenience function to quickly set up a 10x10 table with each cell being 10x10 pixels in size by default.
70 static void SetupTableViewAndActors(Integration::Scene scene, TableView& tableView, Actor& actor1, Actor& actor2, Actor& actor3)
71 {
72   tableView = TableView::New(10, 10); // 10 by 10 grid.
73   DALI_TEST_CHECK(tableView);
74
75   scene.Add(tableView);
76   tableView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
77
78   actor1 = Actor::New();
79   actor2 = Actor::New();
80   actor3 = Actor::New();
81
82   actor1.SetProperty(Actor::Property::SIZE, CELL_SIZE);
83   actor2.SetProperty(Actor::Property::SIZE, CELL_SIZE);
84   actor3.SetProperty(Actor::Property::SIZE, CELL_SIZE);
85
86   tableView.AddChild(actor1, TableView::CellPosition(0, 0));
87   tableView.AddChild(actor2, TableView::CellPosition(0, 1));
88   tableView.AddChild(actor3, TableView::CellPosition(1, 0));
89 }
90
91 } // namespace
92
93 int UtcDaliTableViewCtorCopyP(void)
94 {
95   ToolkitTestApplication application;
96
97   TableView actor1 = TableView::New(10, 10);
98   TableView actor2(actor1);
99
100   DALI_TEST_EQUALS(actor1, actor2, TEST_LOCATION);
101   END_TEST;
102 }
103
104 int UtcDaliTableViewNew(void)
105 {
106   ToolkitTestApplication application;
107
108   TableView tableView = TableView::New(10, 10);
109   DALI_TEST_CHECK(tableView);
110
111   //Additional check to ensure object is created by checking if it's registered
112   ObjectRegistry registry = application.GetCore().GetObjectRegistry();
113   DALI_TEST_CHECK(registry);
114
115   gObjectCreatedCallBackCalled = false;
116   registry.ObjectCreatedSignal().Connect(&TestCallback);
117   {
118     TableView tableView = TableView::New(10, 10);
119   }
120   DALI_TEST_CHECK(gObjectCreatedCallBackCalled);
121   END_TEST;
122 }
123
124 // Test adjusting the metric values for the cell.
125 int UtcDaliTableViewMetricsPadding(void)
126 {
127   ToolkitTestApplication application;
128
129   tet_infoline("UtcDaliTableViewMetricsPadding");
130
131   TableView tableView;
132   Actor     actor1;
133   Actor     actor2;
134   Actor     actor3;
135
136   SetupTableViewAndActors(application.GetScene(), tableView, actor1, actor2, actor3);
137
138   // 1. check that padding works. no padding:
139   tableView.SetCellPadding(Size(0.0f, 0.0f));
140   application.SendNotification();
141   application.Render();
142
143   DALI_TEST_EQUALS(tableView.GetCellPadding(), Size(0.0f, 0.0f), TEST_LOCATION);
144   DALI_TEST_EQUALS(actor1.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
145   DALI_TEST_EQUALS(actor2.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(10.0f, 0.0f, 0.0f), TEST_LOCATION);
146   DALI_TEST_EQUALS(actor3.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(0.0f, 10.0f, 0.0f), TEST_LOCATION);
147
148   // 1. check that padding works. some padding:
149   tableView.SetCellPadding(Size(5.0f, 10.0f));
150   application.SendNotification();
151   application.Render();
152
153   DALI_TEST_EQUALS(tableView.GetCellPadding(), Size(5.0f, 10.0f), TEST_LOCATION);
154   DALI_TEST_EQUALS(actor1.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(5.0f, 10.0f, 0.0f), TEST_LOCATION);
155   END_TEST;
156 }
157
158 // Test adjusting the metric values for the cell.
159 int UtcDaliTableViewMetricsFit(void)
160 {
161   ToolkitTestApplication application;
162
163   tet_infoline("UtcDaliTableViewMetricsFit");
164
165   TableView tableView;
166   Actor     actor1;
167   Actor     actor2;
168   Actor     actor3;
169
170   SetupTableViewAndActors(application.GetScene(), tableView, actor1, actor2, actor3);
171   application.SendNotification();
172   application.Render();
173
174   // 1. check that with no fixed width/heights, actors are in default position.
175   DALI_TEST_EQUALS(actor1.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
176   DALI_TEST_EQUALS(actor2.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(10.0f, 0.0f, 0.0f), TEST_LOCATION);
177   DALI_TEST_EQUALS(actor3.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(0.0f, 10.0f, 0.0f), TEST_LOCATION);
178
179   // 2. check that with a fixed width & height, actors to the right and below are offsetted.
180   tableView.SetFitHeight(0);
181   tableView.SetFitWidth(0);
182   DALI_TEST_EQUALS(tableView.IsFitHeight(0), true, TEST_LOCATION);
183   DALI_TEST_EQUALS(tableView.IsFitWidth(0), true, TEST_LOCATION);
184
185   application.SendNotification();
186   application.Render();
187
188   DALI_TEST_EQUALS(actor1.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
189   DALI_TEST_EQUALS(actor2.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(10.0f, 0.0f, 0.0f), TEST_LOCATION);
190   DALI_TEST_EQUALS(actor3.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(0.0f, 10.0f, 0.0f), TEST_LOCATION);
191
192   tableView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
193   application.SendNotification();
194   application.Render();
195
196   DALI_TEST_EQUALS(actor1.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(90.0f, 0.0f, 0.0f), TEST_LOCATION);
197   DALI_TEST_EQUALS(actor2.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(80.0f, 0.0f, 0.0f), TEST_LOCATION);
198   DALI_TEST_EQUALS(actor3.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(90.0f, 10.0f, 0.0f), TEST_LOCATION);
199
200   tableView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::LEFT_TO_RIGHT);
201   application.SendNotification();
202   application.Render();
203
204   DALI_TEST_EQUALS(actor1.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
205   DALI_TEST_EQUALS(actor2.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(10.0f, 0.0f, 0.0f), TEST_LOCATION);
206   DALI_TEST_EQUALS(actor3.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(0.0f, 10.0f, 0.0f), TEST_LOCATION);
207
208   END_TEST;
209 }
210
211 // Test adjusting the metric values for the cell.
212 int UtcDaliTableViewMetricsFixed(void)
213 {
214   ToolkitTestApplication application;
215
216   tet_infoline("UtcDaliTableViewMetricsFixed");
217
218   TableView tableView;
219   Actor     actor1;
220   Actor     actor2;
221   Actor     actor3;
222
223   SetupTableViewAndActors(application.GetScene(), tableView, actor1, actor2, actor3);
224   application.SendNotification();
225   application.Render();
226
227   // 1. check that with no fixed width/heights, actors are in default position.
228   DALI_TEST_EQUALS(actor1.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
229   DALI_TEST_EQUALS(actor2.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(10.0f, 0.0f, 0.0f), TEST_LOCATION);
230   DALI_TEST_EQUALS(actor3.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(0.0f, 10.0f, 0.0f), TEST_LOCATION);
231
232   // 2. check that with a fixed width & height, actors to the right and below are offsetted.
233   tableView.SetFixedWidth(0, 20.0f);
234   tableView.SetFixedHeight(0, 50.0f);
235   DALI_TEST_EQUALS(tableView.GetFixedWidth(0), 20.0f, TEST_LOCATION);
236   DALI_TEST_EQUALS(tableView.GetFixedHeight(0), 50.0f, TEST_LOCATION);
237
238   application.SendNotification();
239   application.Render();
240
241   DALI_TEST_EQUALS(actor1.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
242   DALI_TEST_EQUALS(actor2.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(20.0f, 0.0f, 0.0f), TEST_LOCATION);
243   DALI_TEST_EQUALS(actor3.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(0.0f, 50.0f, 0.0f), TEST_LOCATION);
244   END_TEST;
245 }
246
247 // Test adjusting the metric values for the cell.
248 int UtcDaliTableViewMetricsRelative(void)
249 {
250   ToolkitTestApplication application;
251
252   tet_infoline("UtcDaliTableViewMetricsRelative");
253
254   TableView tableView;
255   Actor     actor1;
256   Actor     actor2;
257   Actor     actor3;
258
259   SetupTableViewAndActors(application.GetScene(), tableView, actor1, actor2, actor3);
260   application.SendNotification();
261   application.Render();
262
263   // 1. check that with no relative width/heights, actors are in default position.
264   DALI_TEST_EQUALS(actor1.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
265   DALI_TEST_EQUALS(actor2.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(10.0f, 0.0f, 0.0f), TEST_LOCATION);
266   DALI_TEST_EQUALS(actor3.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(0.0f, 10.0f, 0.0f), TEST_LOCATION);
267
268   // 2. check that with a relative width & height, actors to the right and below are offsetted.
269   tableView.SetRelativeWidth(0, 0.3f); // cell 0,0 occupies 30%x50% of the grid (i.e. 30x50 pixels)
270   tableView.SetRelativeHeight(0, 0.5f);
271   DALI_TEST_EQUALS(tableView.GetRelativeWidth(0), 0.3f, TEST_LOCATION);
272   DALI_TEST_EQUALS(tableView.GetRelativeHeight(0), 0.5f, TEST_LOCATION);
273
274   application.SendNotification();
275   application.Render();
276
277   DALI_TEST_EQUALS(actor1.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
278   DALI_TEST_EQUALS(actor2.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(30.0f, 0.0f, 0.0f), TEST_LOCATION);
279   DALI_TEST_EQUALS(actor3.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(0.0f, 50.0f, 0.0f), TEST_LOCATION);
280   END_TEST;
281 }
282
283 // Test Adding/Removing/Finding Children.
284 int UtcDaliTableViewChild(void)
285 {
286   ToolkitTestApplication application;
287
288   tet_infoline("UtcDaliTableViewChild");
289
290   // Create a 10x10 table-view
291   TableView tableView = TableView::New(10, 10);
292   DALI_TEST_CHECK(tableView);
293
294   // Check if actor doesn't exist.
295   DALI_TEST_CHECK(!tableView.GetChildAt(TableView::CellPosition(0, 0)));
296
297   // Add an actor to it at 0,0
298   Actor actor = Actor::New();
299   tableView.AddChild(actor, TableView::CellPosition());
300
301   // Check if exists.
302   DALI_TEST_CHECK(tableView.GetChildAt(TableView::CellPosition(0, 0)));
303
304   // Remove this actor
305   tableView.RemoveChildAt(TableView::CellPosition());
306
307   // Check if actor no longer exists.
308   DALI_TEST_CHECK(!tableView.GetChildAt(TableView::CellPosition(0, 0)));
309
310   // Add actor to it again, but at 2,5
311   tableView.AddChild(actor, TableView::CellPosition(2, 5));
312
313   // Add another actor somewhere else 7,8
314   Actor actor2 = Actor::New();
315   tableView.AddChild(actor2, TableView::CellPosition(7, 8));
316
317   Actor searchActor;
318
319   // Check that no actor exists in a few random places.
320   DALI_TEST_CHECK(!tableView.GetChildAt(TableView::CellPosition(0, 0)));
321   DALI_TEST_CHECK(!tableView.GetChildAt(TableView::CellPosition(2, 1)));
322   DALI_TEST_CHECK(!tableView.GetChildAt(TableView::CellPosition(6, 3)));
323   DALI_TEST_CHECK(!tableView.GetChildAt(TableView::CellPosition(9, 5)));
324
325   // Check for actors at actual positions.
326   searchActor = tableView.GetChildAt(TableView::CellPosition(2, 5));
327   DALI_TEST_CHECK(searchActor == actor);
328
329   searchActor = tableView.GetChildAt(TableView::CellPosition(7, 8));
330   DALI_TEST_CHECK(searchActor == actor2);
331
332   // Create a second table, and add already added Child to new one.
333   TableView tableView2 = TableView::New(5, 5);
334   tableView2.AddChild(actor, TableView::CellPosition(2, 2));
335   DALI_TEST_CHECK(tableView2.GetChildAt(TableView::CellPosition(2, 2)));
336   END_TEST;
337 }
338
339 // Test calling Add on it's own (to invoke the OnChildAdd)
340 int UtcDaliTableViewAdd(void)
341 {
342   ToolkitTestApplication application;
343
344   tet_infoline("UtcDaliTableViewAdd");
345
346   // Create a 4x1 table-view, and just keep adding.
347   TableView tableView = TableView::New(1, 4);
348   DALI_TEST_CHECK(tableView);
349
350   for(unsigned int i = 0; i < 16; i++)
351   {
352     Actor                   currentActor = Actor::New();
353     TableView::CellPosition position     = TableView::CellPosition();
354     tableView.Add(currentActor);
355     tableView.FindChildPosition(currentActor, position);
356     tet_printf("%dx%d (%d,%d)\n", tableView.GetColumns(), tableView.GetRows(), position.columnIndex, position.rowIndex);
357
358     DALI_TEST_EQUALS((position.rowIndex * 4 + position.columnIndex), i, TEST_LOCATION);
359   }
360   END_TEST;
361 }
362
363 // Test cell modification.
364 int UtcDaliTableViewCells(void)
365 {
366   ToolkitTestApplication application;
367   tet_infoline("UtcDaliTableViewCells");
368
369   // Create a 10x10 table-view
370   TableView tableView = TableView::New(10, 10);
371   DALI_TEST_CHECK(tableView);
372
373   // Add a few actors to the table.
374   Actor actor1 = Actor::New();
375   Actor actor2 = Actor::New();
376   Actor actor3 = Actor::New();
377   actor1.SetProperty(Dali::Actor::Property::NAME, "Actor1");
378   actor2.SetProperty(Dali::Actor::Property::NAME, "Actor2");
379   actor3.SetProperty(Dali::Actor::Property::NAME, "Actor3");
380
381   // note: positions are specified in reversed cartesian coords - row,col (i.e. y,x)
382   tableView.AddChild(actor1, TableView::CellPosition(0, 0));
383   tableView.AddChild(actor2, TableView::CellPosition(5, 5));
384   tableView.AddChild(actor3, TableView::CellPosition(7, 2));
385
386   DALI_TEST_CHECK(tableView.GetRows() == 10 && tableView.GetColumns() == 10);
387
388   // Add a row between actor1 and actor2 | insert column on actor1 and see what happens...
389   tableView.InsertRow(3);
390   tableView.InsertColumn(0);
391   DALI_TEST_CHECK(tableView.GetRows() == 11 && tableView.GetColumns() == 11);
392
393   TableView::CellPosition cellPosition;
394   bool                    result;
395
396   result = tableView.FindChildPosition(actor1, cellPosition);
397   DALI_TEST_CHECK(result && cellPosition.rowIndex == 0 && cellPosition.columnIndex == 1);
398   result = tableView.FindChildPosition(actor2, cellPosition);
399   DALI_TEST_CHECK(result && cellPosition.rowIndex == 6 && cellPosition.columnIndex == 6);
400   result = tableView.FindChildPosition(actor3, cellPosition);
401   DALI_TEST_CHECK(result && cellPosition.rowIndex == 8 && cellPosition.columnIndex == 3);
402
403   // Delete a row between actor2 and actor3 | delete column on actor2 and see what happens...
404   tableView.DeleteRow(7);
405   tableView.DeleteColumn(6);
406   DALI_TEST_CHECK(tableView.GetRows() == 10 && tableView.GetColumns() == 10);
407
408   result = tableView.FindChildPosition(actor1, cellPosition);
409   DALI_TEST_CHECK(result && cellPosition.rowIndex == 0 && cellPosition.columnIndex == 1);
410   result = tableView.FindChildPosition(actor2, cellPosition);
411   DALI_TEST_CHECK(!result);
412   result = tableView.FindChildPosition(actor3, cellPosition);
413   DALI_TEST_CHECK(result && cellPosition.rowIndex == 7 && cellPosition.columnIndex == 3);
414
415   // Delete the other two remaining actors by a row delete and a column delete.
416   std::vector<Actor> actorsRemoved;
417   tableView.DeleteRow(0, actorsRemoved);
418   tet_printf("Row Delete >> Actors Removed: %d {", actorsRemoved.size());
419   for(size_t i = 0; i < actorsRemoved.size(); i++) tet_printf("%d => %s, ", i, actorsRemoved[i].GetProperty<std::string>(Dali::Actor::Property::NAME).c_str());
420   tet_printf("}\n");
421   DALI_TEST_EQUALS(static_cast<int>(actorsRemoved.size()), 1, TEST_LOCATION);
422   DALI_TEST_CHECK(actorsRemoved[0] == actor1);
423
424   actorsRemoved.clear();
425   tableView.DeleteColumn(3, actorsRemoved);
426   tet_printf("Column Delete >> Actors Removed: %d {", actorsRemoved.size());
427   for(size_t i = 0; i < actorsRemoved.size(); i++) tet_printf("%d => %s, ", i, actorsRemoved[i].GetProperty<std::string>(Dali::Actor::Property::NAME).c_str());
428   tet_printf("}\n");
429   DALI_TEST_EQUALS(static_cast<int>(actorsRemoved.size()), 1, TEST_LOCATION);
430   DALI_TEST_CHECK(actorsRemoved[0] == actor3);
431
432   DALI_TEST_CHECK(tableView.GetRows() == 9 && tableView.GetColumns() == 9);
433
434   tableView.AddChild(actor1, TableView::CellPosition(5, 8));
435   tableView.Resize(100, 100);
436   DALI_TEST_CHECK(tableView.GetRows() == 100 && tableView.GetColumns() == 100);
437
438   tableView.AddChild(actor2, TableView::CellPosition(69, 57));
439   DALI_TEST_CHECK(tableView.FindChildPosition(actor1, cellPosition) && tableView.FindChildPosition(actor2, cellPosition));
440
441   tableView.Resize(20, 20);
442   DALI_TEST_CHECK(tableView.FindChildPosition(actor1, cellPosition) && !tableView.FindChildPosition(actor2, cellPosition));
443
444   actorsRemoved.clear();
445   tableView.Resize(1, 1, actorsRemoved);
446   DALI_TEST_CHECK(!tableView.FindChildPosition(actor1, cellPosition) && !tableView.FindChildPosition(actor2, cellPosition));
447   DALI_TEST_EQUALS(static_cast<int>(actorsRemoved.size()), 1, TEST_LOCATION);
448   DALI_TEST_CHECK(actorsRemoved[0] == actor1);
449
450   // Add child outside table size, forcing a resize.
451   tableView.AddChild(actor1, TableView::CellPosition(100, 100, 1, 1));
452   DALI_TEST_CHECK(tableView.GetRows() == 101 && tableView.GetColumns() == 101);
453
454   // Add child outside table size, forcing a resize.
455   tableView.AddChild(actor1, TableView::CellPosition(110, 110, 5, 5));
456   DALI_TEST_CHECK(tableView.GetRows() == 115 && tableView.GetColumns() == 115);
457
458   // Set the alignment of the cell
459   tableView.SetCellAlignment(TableView::CellPosition(100, 100, 1, 1), HorizontalAlignment::CENTER, VerticalAlignment::CENTER);
460   tableView.SetCellAlignment(TableView::CellPosition(110, 110, 5, 5), HorizontalAlignment::LEFT, VerticalAlignment::TOP);
461
462   DALI_TEST_CHECK(true);
463   END_TEST;
464 }
465
466 int UtcDaliTableViewChildAssert(void)
467 {
468   ToolkitTestApplication application;
469   tet_infoline("UtcDaliTableViewChildAssert");
470
471   // Create a 10x10 table-view
472   TableView tableView = TableView::New(10, 10);
473   DALI_TEST_CHECK(tableView);
474   Actor childActor;
475
476   try
477   {
478     tableView.AddChild(childActor, TableView::CellPosition(0, 0, 5, 5));
479     // should assert
480     tet_result(TET_FAIL);
481   }
482   catch(Dali::DaliException& e)
483   {
484     DALI_TEST_PRINT_ASSERT(e);
485     DALI_TEST_EQUALS(e.condition, "child", TEST_LOCATION);
486   }
487   END_TEST;
488 }
489
490 int UtcDaliTableViewMetricsAssert(void)
491 {
492   ToolkitTestApplication application;
493   tet_infoline("UtcDaliTableViewChildAssert");
494
495   // Create a 10x10 table-view
496   TableView tableView = TableView::New(10, 10);
497   DALI_TEST_CHECK(tableView);
498
499   // fixeds...
500
501   try
502   {
503     tableView.SetFixedHeight(10, 1.0f);
504
505     tet_result(TET_FAIL);
506   }
507   catch(Dali::DaliException& e)
508   {
509     DALI_TEST_PRINT_ASSERT(e);
510     DALI_TEST_EQUALS(e.condition, "rowIndex < mRowData.Size()", TEST_LOCATION);
511   }
512
513   try
514   {
515     tableView.GetFixedHeight(10);
516
517     tet_result(TET_FAIL);
518   }
519   catch(Dali::DaliException& e)
520   {
521     DALI_TEST_PRINT_ASSERT(e);
522     DALI_TEST_EQUALS(e.condition, "rowIndex < mRowData.Size()", TEST_LOCATION);
523   }
524
525   try
526   {
527     tableView.SetFixedWidth(10, 1.0f);
528
529     tet_result(TET_FAIL);
530   }
531   catch(Dali::DaliException& e)
532   {
533     DALI_TEST_PRINT_ASSERT(e);
534     DALI_TEST_EQUALS(e.condition, "columnIndex < mColumnData.Size()", TEST_LOCATION);
535   }
536
537   try
538   {
539     tableView.GetFixedWidth(10);
540
541     tet_result(TET_FAIL);
542   }
543   catch(Dali::DaliException& e)
544   {
545     DALI_TEST_PRINT_ASSERT(e);
546     DALI_TEST_EQUALS(e.condition, "columnIndex < mColumnData.Size()", TEST_LOCATION);
547   }
548
549   // relatives...
550
551   try
552   {
553     tableView.SetRelativeHeight(10, 0.1f);
554
555     tet_result(TET_FAIL);
556   }
557   catch(Dali::DaliException& e)
558   {
559     DALI_TEST_PRINT_ASSERT(e);
560     DALI_TEST_EQUALS(e.condition, "rowIndex < mRowData.Size()", TEST_LOCATION);
561   }
562
563   try
564   {
565     tableView.GetRelativeHeight(10);
566
567     tet_result(TET_FAIL);
568   }
569   catch(Dali::DaliException& e)
570   {
571     DALI_TEST_PRINT_ASSERT(e);
572     DALI_TEST_EQUALS(e.condition, "rowIndex < mRowData.Size()", TEST_LOCATION);
573   }
574
575   try
576   {
577     tableView.SetRelativeWidth(10, 0.1f);
578
579     tet_result(TET_FAIL);
580   }
581   catch(Dali::DaliException& e)
582   {
583     DALI_TEST_PRINT_ASSERT(e);
584     DALI_TEST_EQUALS(e.condition, "columnIndex < mColumnData.Size()", TEST_LOCATION);
585   }
586
587   try
588   {
589     tableView.GetRelativeWidth(10);
590
591     tet_result(TET_FAIL);
592   }
593   catch(Dali::DaliException& e)
594   {
595     DALI_TEST_PRINT_ASSERT(e);
596     DALI_TEST_EQUALS(e.condition, "columnIndex < mColumnData.Size()", TEST_LOCATION);
597   }
598   END_TEST;
599 }
600
601 int UtcDaliTableViewSetGetProperty(void)
602 {
603   ToolkitTestApplication application;
604   tet_infoline("UtcDaliTableViewSetGetProperty");
605
606   // Create a 1x1 table-view
607   TableView tableView = TableView::New(1, 1);
608   tableView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
609   DALI_TEST_CHECK(tableView);
610
611   // Test "rows" property
612   DALI_TEST_CHECK(tableView.GetPropertyIndex(PROPERTY_NAME_ROWS) == TableView::Property::ROWS);
613
614   tableView.SetProperty(TableView::Property::ROWS, 7);
615
616   DALI_TEST_CHECK(tableView.GetRows() == 7u);
617   DALI_TEST_CHECK(tableView.GetProperty(TableView::Property::ROWS).Get<int>() == 7);
618
619   // Test "columns" property
620   DALI_TEST_CHECK(tableView.GetPropertyIndex(PROPERTY_NAME_COLUMNS) == TableView::Property::COLUMNS);
621
622   tableView.SetProperty(TableView::Property::COLUMNS, 8);
623
624   DALI_TEST_CHECK(tableView.GetColumns() == 8u);
625   DALI_TEST_CHECK(tableView.GetProperty(TableView::Property::COLUMNS).Get<int>() == 8);
626
627   // Test "cellPadding" property
628   DALI_TEST_CHECK(tableView.GetPropertyIndex(PROPERTY_NAME_CELL_PADDING) == TableView::Property::CELL_PADDING);
629
630   tableView.SetProperty(TableView::Property::CELL_PADDING, Size(6.f, 8.f));
631
632   DALI_TEST_EQUALS(tableView.GetCellPadding(), Size(6.f, 8.f), TEST_LOCATION);
633   DALI_TEST_EQUALS(tableView.GetProperty(TableView::Property::CELL_PADDING).Get<Vector2>(), Vector2(6.f, 8.f), TEST_LOCATION);
634
635   //{ "policy": "fixed", "value": 30.0 },
636   Property::Map item1;
637   item1["policy"] = "fixed";
638   item1["value"]  = 30.f;
639   //{ "policy": "relative", "value": 0.2 },
640   Property::Map item2;
641   item2["policy"] = "relative";
642   item2["value"]  = 0.2f;
643   //{ "policy": "fill"},
644   Property::Map item3;
645   item3["policy"] = "fill";
646   //{ "policy": "fit"},
647   Property::Map item4;
648   item4["policy"] = "fit";
649
650   // Test "layoutRows" property
651   DALI_TEST_CHECK(tableView.GetPropertyIndex(PROPERTY_NAME_LAYOUT_ROWS) == TableView::Property::LAYOUT_ROWS);
652
653   /*
654    * "layoutRows":
655    *  {
656    *    "1": { "policy": "fixed", "value": 30 },
657    *    "3": { "policy": "relative", "value": 0.2 },
658    *    "4": { "policy": "fill" },
659    *    "6": { "policy": "fit" },
660    *   }
661    */
662   Property::Map layoutRows;
663   layoutRows["1"] = item1;
664   layoutRows["3"] = item2;
665   layoutRows["4"] = item3;
666   layoutRows["6"] = item4;
667   tableView.SetProperty(TableView::Property::LAYOUT_ROWS, layoutRows);
668
669   DALI_TEST_EQUALS(tableView.GetFixedHeight(1u), 30.f, TEST_LOCATION);
670   DALI_TEST_EQUALS(tableView.GetRelativeHeight(3u), 0.2f, TEST_LOCATION);
671
672   Property::Map layoutRowsGet = tableView.GetProperty(TableView::Property::LAYOUT_ROWS).Get<Property::Map>();
673
674   DALI_TEST_EQUALS(layoutRowsGet.GetKey(1).compare(layoutRows.GetKey(0)), 0, TEST_LOCATION);
675   Property::Map* childMap = layoutRowsGet.GetValue(1).GetMap();
676   DALI_TEST_CHECK(childMap->Find("policy")->Get<std::string>().compare("fixed") == 0);
677   DALI_TEST_EQUALS(childMap->Find("value")->Get<float>(), 30.f, TEST_LOCATION);
678
679   childMap = layoutRowsGet.GetValue(3).GetMap();
680   DALI_TEST_CHECK(layoutRowsGet.GetKey(3).compare(layoutRows.GetKey(1)) == 0);
681   DALI_TEST_CHECK(childMap->Find("policy")->Get<std::string>().compare("relative") == 0);
682   DALI_TEST_EQUALS(childMap->Find("value")->Get<float>(), 0.2f, TEST_LOCATION);
683
684   childMap = layoutRowsGet.GetValue(4).GetMap();
685   DALI_TEST_CHECK(layoutRowsGet.GetKey(4).compare(layoutRows.GetKey(2)) == 0);
686   DALI_TEST_CHECK(childMap->Find("policy")->Get<std::string>().compare("fill") == 0);
687
688   childMap = layoutRowsGet.GetValue(6).GetMap();
689   DALI_TEST_CHECK(layoutRowsGet.GetKey(6).compare(layoutRows.GetKey(3)) == 0);
690   DALI_TEST_CHECK(childMap->Find("policy")->Get<std::string>().compare("fit") == 0);
691
692   // Test "layoutColumns" property
693   DALI_TEST_CHECK(tableView.GetPropertyIndex(PROPERTY_NAME_LAYOUT_COLUMNS) == TableView::Property::LAYOUT_COLUMNS);
694
695   /*
696    * "layoutColumns":
697    *  {
698    *    "2": { "policy": "relative", "value": 0.2 },
699    *    "3": { "policy": "fixed", "value": 30 },
700    *    "5": { "policy": "fit" },
701    *    "7": { "policy": "fill" }
702    *   }
703    */
704   Property::Map layoutColumns;
705   layoutColumns["2"] = item2;
706   layoutColumns["3"] = item1;
707   layoutColumns["5"] = item4;
708   layoutColumns["7"] = item3;
709   tableView.SetProperty(TableView::Property::LAYOUT_COLUMNS, layoutColumns);
710
711   DALI_TEST_EQUALS(tableView.GetRelativeWidth(2u), 0.2f, TEST_LOCATION);
712   DALI_TEST_EQUALS(tableView.GetFixedWidth(3u), 30.f, TEST_LOCATION);
713
714   Property::Map layoutColumnsGet = tableView.GetProperty(TableView::Property::LAYOUT_COLUMNS).Get<Property::Map>();
715
716   DALI_TEST_CHECK(layoutColumnsGet.GetKey(2).compare(layoutColumns.GetKey(0)) == 0);
717   childMap = layoutColumnsGet.GetValue(2).GetMap();
718   DALI_TEST_CHECK(childMap->Find("policy")->Get<std::string>().compare("relative") == 0);
719   DALI_TEST_EQUALS(childMap->Find("value")->Get<float>(), 0.2f, TEST_LOCATION);
720
721   childMap = layoutColumnsGet.GetValue(3).GetMap();
722   DALI_TEST_CHECK(layoutColumnsGet.GetKey(3).compare(layoutColumns.GetKey(1)) == 0);
723   DALI_TEST_CHECK(childMap->Find("policy")->Get<std::string>().compare("fixed") == 0);
724   DALI_TEST_EQUALS(childMap->Find("value")->Get<float>(), 30.f, TEST_LOCATION);
725
726   childMap = layoutColumnsGet.GetValue(5).GetMap();
727   DALI_TEST_CHECK(layoutColumnsGet.GetKey(5).compare(layoutColumns.GetKey(2)) == 0);
728   DALI_TEST_CHECK(childMap->Find("policy")->Get<std::string>().compare("fit") == 0);
729
730   childMap = layoutColumnsGet.GetValue(7).GetMap();
731   DALI_TEST_CHECK(layoutColumnsGet.GetKey(7).compare(layoutColumns.GetKey(3)) == 0);
732   DALI_TEST_CHECK(childMap->Find("policy")->Get<std::string>().compare("fill") == 0);
733
734   END_TEST;
735 }
736
737 int UtcDaliTableViewChildProperties(void)
738 {
739   ToolkitTestApplication application;
740   tet_infoline("UtcDaliTableViewChildProperties");
741
742   // Create a 10x10 table-view
743   TableView tableView = TableView::New(10, 10);
744   application.GetScene().Add(tableView);
745   tableView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
746
747   DALI_TEST_CHECK(tableView);
748
749   // Create a child actor with the custom properties
750   Actor child1 = Actor::New();
751   child1.SetProperty(TableView::ChildProperty::CELL_INDEX, Vector2(3, 4));
752   tableView.Add(child1);
753   // Check for actors at actual positions.
754   DALI_TEST_CHECK(tableView.GetChildAt(TableView::CellPosition(3, 4)) == child1);
755
756   // Create a second child actor with the custom properties
757   Actor child2     = Actor::New();
758   float rowSpan    = 3.f;
759   float columnSpan = 2.f;
760   child2.SetProperty(TableView::ChildProperty::CELL_INDEX, Vector2(6, 1));
761   child2.SetProperty(TableView::ChildProperty::ROW_SPAN, rowSpan);
762   child2.SetProperty(TableView::ChildProperty::COLUMN_SPAN, columnSpan);
763   tableView.Add(child2);
764   // Check for actors at actual positions.
765   for(int i = 0; i < rowSpan; i++)
766   {
767     for(int j = 0; j < columnSpan; j++)
768     {
769       DALI_TEST_CHECK(tableView.GetChildAt(TableView::CellPosition(6 + i, 1 + j)) == child2);
770     }
771   }
772
773   // Create a third child actor with the cell alignment properties
774   Actor child3 = Actor::New();
775   child3.SetProperty(Actor::Property::SIZE, Vector2(5.f, 5.f));
776   child3.SetProperty(TableView::ChildProperty::CELL_HORIZONTAL_ALIGNMENT, "center");
777   child3.SetProperty(TableView::ChildProperty::CELL_VERTICAL_ALIGNMENT, "bottom");
778   tableView.Add(child3);
779
780   // store the actor in the first available cell
781   DALI_TEST_CHECK(tableView.GetChildAt(TableView::CellPosition(0, 0)) == child3)
782   application.SendNotification();
783   application.Render();
784
785   DALI_TEST_EQUALS(child3.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT), AnchorPoint::TOP_LEFT, TEST_LOCATION);
786   DALI_TEST_EQUALS(child3.GetCurrentProperty<Vector3>(Actor::Property::PARENT_ORIGIN), ParentOrigin::TOP_LEFT, TEST_LOCATION);
787   DALI_TEST_EQUALS(child3.GetCurrentProperty<Vector3>(Actor::Property::POSITION), Vector3(2.5f, 5.0f, 0.0f), TEST_LOCATION);
788
789   END_TEST;
790 }
791
792 int UtcDaliTableViewGetChildAtN(void)
793 {
794   ToolkitTestApplication application;
795
796   TableView tableView = TableView::New(10, 10);
797
798   Actor actor = tableView.GetChildAt(TableView::CellPosition(200, 200));
799   DALI_TEST_CHECK(!actor);
800
801   END_TEST;
802 }
803
804 int UtcDaliTableViewAddChildN(void)
805 {
806   ToolkitTestApplication application;
807
808   TableView tableView = TableView::New(10, 10);
809   DALI_TEST_CHECK(tableView.AddChild(Actor::New(), TableView::CellPosition(0, 0)));
810   DALI_TEST_CHECK(!tableView.AddChild(Actor::New(), TableView::CellPosition(0, 0)));
811
812   END_TEST;
813 }
814
815 int UtcDaliTableViewInsertRowAtZero(void)
816 {
817   ToolkitTestApplication application;
818
819   TableView tableView = TableView::New(10, 10);
820   DALI_TEST_CHECK(tableView.AddChild(Actor::New(), TableView::CellPosition(0, 0, 10, 10)));
821   tableView.InsertRow(0);
822
823   DALI_TEST_CHECK(tableView.GetRows() == 11);
824
825   END_TEST;
826 }
827
828 int UtcDaliTableViewDeleteRowAtZero(void)
829 {
830   ToolkitTestApplication application;
831
832   TableView tableView = TableView::New(10, 10);
833   DALI_TEST_CHECK(tableView.AddChild(Actor::New(), TableView::CellPosition(0, 0, 10, 10)));
834   tableView.DeleteRow(0);
835
836   DALI_TEST_CHECK(tableView.GetRows() == 9);
837
838   END_TEST;
839 }
840
841 int UtcDaliTableViewInsertColumnAtZero(void)
842 {
843   ToolkitTestApplication application;
844
845   TableView tableView = TableView::New(10, 10);
846   DALI_TEST_CHECK(tableView.AddChild(Actor::New(), TableView::CellPosition(0, 0, 10, 10)));
847   tableView.InsertColumn(0);
848
849   DALI_TEST_CHECK(tableView.GetColumns() == 11);
850
851   END_TEST;
852 }
853
854 int UtcDaliTableViewDeleteColumnAtZero(void)
855 {
856   ToolkitTestApplication application;
857
858   TableView tableView = TableView::New(10, 10);
859   DALI_TEST_CHECK(tableView.AddChild(Actor::New(), TableView::CellPosition(0, 0, 10, 10)));
860   tableView.DeleteColumn(0);
861
862   DALI_TEST_CHECK(tableView.GetColumns() == 9);
863
864   END_TEST;
865 }
866
867 int UtcDaliTableViewTypeRegistry(void)
868 {
869   ToolkitTestApplication application;
870
871   TypeRegistry typeRegistry = TypeRegistry::Get();
872   DALI_TEST_CHECK(typeRegistry);
873
874   TypeInfo typeInfo = typeRegistry.GetTypeInfo("TableView");
875   DALI_TEST_CHECK(typeInfo);
876
877   BaseHandle handle = typeInfo.CreateInstance();
878   DALI_TEST_CHECK(handle);
879
880   TableView view = TableView::DownCast(handle);
881   DALI_TEST_CHECK(view);
882
883   END_TEST;
884 }
885
886 int UtcDaliTableViewKeyboardFocus(void)
887 {
888   ToolkitTestApplication application;
889
890   TableView tableView = TableView::New(4, 4);
891   tableView.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
892   tableView.SetProperty(Dali::Actor::Property::NAME, "TableView");
893
894   for(int row = 0; row < 4; ++row)
895   {
896     for(int col = 0; col < 4; ++col)
897     {
898       Control            control = Control::New();
899       std::ostringstream str;
900       str << row << "-" << col;
901       control.SetProperty(Dali::Actor::Property::NAME, str.str());
902       control.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
903       tableView.AddChild(control, TableView::CellPosition(row, col));
904     }
905   }
906
907   application.GetScene().Add(tableView);
908
909   application.SendNotification();
910   application.Render();
911
912   Actor firstFocusActor = Toolkit::Internal::GetImplementation(tableView).GetNextKeyboardFocusableActor(Actor(), Control::KeyboardFocus::RIGHT, true);
913   DALI_TEST_CHECK(firstFocusActor);
914   DALI_TEST_CHECK(firstFocusActor.GetProperty<std::string>(Dali::Actor::Property::NAME) == "0-0");
915
916   KeyboardFocusManager manager = KeyboardFocusManager::Get();
917   manager.SetFocusGroupLoop(true);
918   manager.SetCurrentFocusActor(firstFocusActor);
919
920   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "0-0");
921   manager.MoveFocus(Control::KeyboardFocus::RIGHT);
922   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "0-1");
923   manager.MoveFocus(Control::KeyboardFocus::RIGHT);
924   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "0-2");
925   manager.MoveFocus(Control::KeyboardFocus::RIGHT);
926   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "0-3");
927   manager.MoveFocus(Control::KeyboardFocus::RIGHT);
928   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "1-0");
929
930   manager.MoveFocus(Control::KeyboardFocus::LEFT);
931   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "0-3");
932   manager.MoveFocus(Control::KeyboardFocus::LEFT);
933   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "0-2");
934   manager.MoveFocus(Control::KeyboardFocus::LEFT);
935   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "0-1");
936   manager.MoveFocus(Control::KeyboardFocus::LEFT);
937   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "0-0");
938   manager.MoveFocus(Control::KeyboardFocus::LEFT);
939   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "3-3");
940
941   manager.MoveFocus(Control::KeyboardFocus::RIGHT);
942   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "0-0");
943   manager.MoveFocus(Control::KeyboardFocus::RIGHT);
944   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "0-1");
945
946   manager.MoveFocus(Control::KeyboardFocus::DOWN);
947   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "1-1");
948   manager.MoveFocus(Control::KeyboardFocus::DOWN);
949   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "2-1");
950   manager.MoveFocus(Control::KeyboardFocus::DOWN);
951   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "3-1");
952   manager.MoveFocus(Control::KeyboardFocus::DOWN);
953   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "0-1");
954
955   manager.MoveFocus(Control::KeyboardFocus::UP);
956   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "3-1");
957   manager.MoveFocus(Control::KeyboardFocus::UP);
958   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "2-1");
959   manager.MoveFocus(Control::KeyboardFocus::UP);
960   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "1-1");
961   manager.MoveFocus(Control::KeyboardFocus::UP);
962   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "0-1");
963
964   END_TEST;
965 }
966
967 int UtcDaliTableViewKeyboardFocusInNestedTableView(void)
968 {
969   ToolkitTestApplication application;
970
971   TableView tableView = TableView::New(3, 3);
972   tableView.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
973   tableView.SetProperty(Dali::Actor::Property::NAME, "TableView");
974
975   for(int row = 0; row < 3; ++row)
976   {
977     for(int col = 0; col < 3; ++col)
978     {
979       std::ostringstream str;
980       str << row << "-" << col;
981
982       if(row == 1 && col == 1)
983       {
984         // Add a nested 2x2 table view in the middle cell of the parent table view
985         TableView childTableView = TableView::New(2, 2);
986         childTableView.SetProperty(Dali::Actor::Property::NAME, str.str());
987
988         for(int childRow = 0; childRow < 2; childRow++)
989         {
990           for(int childCol = 0; childCol < 2; childCol++)
991           {
992             Control            control = Control::New();
993             std::ostringstream nameStr;
994             nameStr << row << "-" << col << "-" << childRow << "-" << childCol;
995             control.SetProperty(Dali::Actor::Property::NAME, nameStr.str());
996             control.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
997             childTableView.AddChild(control, TableView::CellPosition(childRow, childCol));
998           }
999         }
1000         tableView.AddChild(childTableView, TableView::CellPosition(row, col));
1001       }
1002       else
1003       {
1004         Control control = Control::New();
1005         control.SetProperty(Dali::Actor::Property::NAME, str.str());
1006         control.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
1007         tableView.AddChild(control, TableView::CellPosition(row, col));
1008       }
1009     }
1010   }
1011
1012   application.GetScene().Add(tableView);
1013
1014   application.SendNotification();
1015   application.Render();
1016
1017   Actor firstFocusActor = Toolkit::Internal::GetImplementation(tableView).GetNextKeyboardFocusableActor(Actor(), Control::KeyboardFocus::RIGHT, true);
1018   DALI_TEST_CHECK(firstFocusActor);
1019   DALI_TEST_CHECK(firstFocusActor.GetProperty<std::string>(Dali::Actor::Property::NAME) == "0-0");
1020
1021   KeyboardFocusManager manager = KeyboardFocusManager::Get();
1022   manager.SetFocusGroupLoop(false);
1023   manager.SetCurrentFocusActor(firstFocusActor);
1024
1025   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "0-0");
1026   manager.MoveFocus(Control::KeyboardFocus::RIGHT);
1027   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "0-1");
1028   manager.MoveFocus(Control::KeyboardFocus::RIGHT);
1029   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "0-2");
1030   manager.MoveFocus(Control::KeyboardFocus::RIGHT);
1031   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "1-0");
1032   manager.MoveFocus(Control::KeyboardFocus::RIGHT);
1033   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "1-1-0-0");
1034   manager.MoveFocus(Control::KeyboardFocus::RIGHT);
1035   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "1-1-0-1");
1036   manager.MoveFocus(Control::KeyboardFocus::RIGHT);
1037   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "1-1-1-0");
1038   manager.MoveFocus(Control::KeyboardFocus::RIGHT);
1039   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "1-1-1-1");
1040   manager.MoveFocus(Control::KeyboardFocus::RIGHT);
1041   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "1-2");
1042   manager.MoveFocus(Control::KeyboardFocus::RIGHT);
1043   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "2-0");
1044   manager.MoveFocus(Control::KeyboardFocus::RIGHT);
1045   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "2-1");
1046   manager.MoveFocus(Control::KeyboardFocus::RIGHT);
1047   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "2-2");
1048
1049   manager.MoveFocus(Control::KeyboardFocus::LEFT);
1050   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "2-1");
1051   manager.MoveFocus(Control::KeyboardFocus::LEFT);
1052   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "2-0");
1053   manager.MoveFocus(Control::KeyboardFocus::LEFT);
1054   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "1-2");
1055   manager.MoveFocus(Control::KeyboardFocus::LEFT);
1056   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "1-1-1-1");
1057   manager.MoveFocus(Control::KeyboardFocus::LEFT);
1058   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "1-1-1-0");
1059   manager.MoveFocus(Control::KeyboardFocus::LEFT);
1060   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "1-1-0-1");
1061   manager.MoveFocus(Control::KeyboardFocus::LEFT);
1062   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "1-1-0-0");
1063   manager.MoveFocus(Control::KeyboardFocus::LEFT);
1064   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "1-0");
1065   manager.MoveFocus(Control::KeyboardFocus::LEFT);
1066   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "0-2");
1067   manager.MoveFocus(Control::KeyboardFocus::LEFT);
1068   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "0-1");
1069   manager.MoveFocus(Control::KeyboardFocus::LEFT);
1070   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "0-0");
1071
1072   manager.MoveFocus(Control::KeyboardFocus::RIGHT);
1073   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "0-1");
1074   manager.MoveFocus(Control::KeyboardFocus::DOWN);
1075   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "1-1-0-0");
1076   manager.MoveFocus(Control::KeyboardFocus::DOWN);
1077   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "1-1-1-0");
1078   manager.MoveFocus(Control::KeyboardFocus::DOWN);
1079   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "2-1");
1080
1081   manager.MoveFocus(Control::KeyboardFocus::UP);
1082   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "1-1-1-1");
1083   manager.MoveFocus(Control::KeyboardFocus::UP);
1084   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "1-1-0-1");
1085   manager.MoveFocus(Control::KeyboardFocus::UP);
1086   DALI_TEST_CHECK(manager.GetCurrentFocusActor().GetProperty<std::string>(Dali::Actor::Property::NAME) == "0-1");
1087
1088   END_TEST;
1089 }