Yoga API wrapped by FlexLayout
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-FlexNode.cpp
1 /*
2  * Copyright (c) 2019 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 #include <dali/devel-api/actors/actor-devel.h>
23 #include <dali-toolkit/devel-api/layouting/flex-node.h>
24
25 using namespace Dali;
26 using namespace Toolkit;
27
28 void dali_flexNodeContainer_startup(void)
29 {
30   test_return_value = TET_UNDEF;
31 }
32
33 void dali_flexNodeContainer_cleanup(void)
34 {
35   test_return_value = TET_PASS;
36 }
37
38 namespace
39 {
40
41 const Flex::SizeTuple ITEM_SIZE = Flex::SizeTuple{ 10.0f, 10.0f };
42 const Flex::SizeTuple ITEM_SIZE_CALLBACK_TEST = Flex::SizeTuple{ 15.0f, 15.0f };
43
44 Flex::SizeTuple MeasureChild( Actor child, float width, int measureModeWidth, float height, int measureModeHeight)
45 {
46   Flex::SizeTuple childSize = ITEM_SIZE;
47   if (child.GetName() == "callbackTest")
48   {
49     childSize = ITEM_SIZE_CALLBACK_TEST;
50   }
51   tet_printf(" MeasureChild test callback executed (%f,%f)\n", childSize.width, childSize.height );
52   return childSize;
53 }
54
55 }
56
57 int UtcDaliToolkitFlexNodeConstructorP(void)
58 {
59   ToolkitTestApplication application;
60   tet_infoline(" UtcDaliToolkitFlexNodeNewP");
61   Flex::Node* flexNode = new Flex::Node();
62   DALI_TEST_CHECK( flexNode );
63   END_TEST;
64 }
65
66 int UtcDaliToolkitFlexNodeAddChildrenRowP(void)
67 {
68   ToolkitTestApplication application;
69   tet_infoline(" UtcDaliToolkitFlexNodeAddChildrenRowP");
70   Flex::Node* flexNode = new Flex::Node();
71   DALI_TEST_CHECK( flexNode );
72
73   // Position elements as a Row
74   flexNode->SetFlexDirection(Flex::FlexDirection::ROW);
75
76   // Create two actors and add them to the parent flex node
77   Actor actor1 = Actor::New();
78   Actor actor2 = Actor::New();
79   DALI_TEST_CHECK( actor1 );
80   DALI_TEST_CHECK( actor2 );
81
82   flexNode->AddChild(actor1, &MeasureChild, 0);
83   flexNode->AddChild(actor2, &MeasureChild, 1);
84
85   DALI_TEST_EQUALS( (int)flexNode->GetFlexDirection(), (int)Flex::FlexDirection::ROW, TEST_LOCATION );
86
87   flexNode->CalculateLayout(480, 800, false);
88
89   Vector4 actor1Frame = flexNode->GetNodeFrame(0);
90   Vector4 actor2Frame = flexNode->GetNodeFrame(1);
91
92   tet_printf("Actor 1 frame(left:%f,top:%f,right:%f,bottom:%f)\n", actor1Frame.x, actor1Frame.y, actor1Frame.z, actor1Frame.w);
93   tet_printf("Actor 2 frame(left:%f,top:%f,right:%f,bottom:%f)\n", actor2Frame.x, actor2Frame.y, actor2Frame.z, actor2Frame.w);
94
95   DALI_TEST_EQUALS( actor1Frame, Vector4( 0.0f, 0.0f, ITEM_SIZE.width, ITEM_SIZE.height ), TEST_LOCATION );
96   DALI_TEST_EQUALS( actor2Frame, Vector4( ITEM_SIZE.width, 0.0f, ITEM_SIZE.width * 2, ITEM_SIZE.height ), TEST_LOCATION );
97
98   END_TEST;
99 }
100
101 int UtcDaliToolkitFlexNodeAddChildrenColumnP(void)
102 {
103   ToolkitTestApplication application;
104   tet_infoline("UtcDaliToolkitFlexNodeAddChildrenColumnP");
105   Flex::Node* flexNode = new Flex::Node();
106   DALI_TEST_CHECK( flexNode );
107
108   // Position elements in a Column
109   flexNode->SetFlexDirection(Flex::FlexDirection::COLUMN);
110
111   // Create two actors and add them to the parent flex node
112   Actor actor1 = Actor::New();
113   Actor actor2 = Actor::New();
114   DALI_TEST_CHECK( actor1 );
115   DALI_TEST_CHECK( actor2 );
116
117   flexNode->AddChild(actor1, &MeasureChild, 0);
118   flexNode->AddChild(actor2, &MeasureChild, 1);
119
120   flexNode->CalculateLayout(480, 800, false);
121
122   Vector4 root = flexNode->GetNodeFrame(-1); // -1 is the root
123   Vector4 actor1Frame = flexNode->GetNodeFrame(0); // 0 is first child
124   Vector4 actor2Frame = flexNode->GetNodeFrame(1); // 1 is second child
125
126   tet_printf("Root frame(left:%f,top:%f,right:%f,bottom:%f)\n", root.x, root.y, root.z, root.w);
127
128   tet_printf("Actor 1 frame(left:%f,top:%f,right:%f,bottom:%f)\n", actor1Frame.x, actor1Frame.y, actor1Frame.z, actor1Frame.w);
129   tet_printf("Actor 2 frame(left:%f,top:%f,right:%f,bottom:%f)\n", actor2Frame.x, actor2Frame.y, actor2Frame.z, actor2Frame.w);
130
131   DALI_TEST_EQUALS( actor1Frame, Vector4( 0.0f, 0.0f, ITEM_SIZE.width, ITEM_SIZE.height ), TEST_LOCATION );
132   DALI_TEST_EQUALS( actor2Frame, Vector4( 0.0f, ITEM_SIZE.height, ITEM_SIZE.width, ITEM_SIZE.height *2 ), TEST_LOCATION );
133
134   END_TEST;
135 }
136
137
138 int UtcDaliToolkitFlexNodeAddChildrenColumnJustify(void)
139 {
140   ToolkitTestApplication application;
141   tet_infoline("UtcDaliToolkitFlexNodeAddChildrenColumnJustify");
142   Flex::Node* flexNode = new Flex::Node();
143   DALI_TEST_CHECK( flexNode );
144
145   // Position elements in a Column
146   flexNode->SetFlexDirection(Flex::FlexDirection::COLUMN);
147
148   tet_infoline("Justify to the Start, align to start");
149   flexNode->SetFlexJustification(Flex::Justification::FLEX_START);
150   flexNode->SetFlexItemsAlignment( Flex::Alignment::FLEX_START );
151
152   // Create two actors and add them to the parent flex node
153   Actor actor1 = Actor::New();
154   Actor actor2 = Actor::New();
155   DALI_TEST_CHECK( actor1 );
156   DALI_TEST_CHECK( actor2 );
157
158   DALI_TEST_EQUALS( (int)flexNode->GetFlexJustification(), (int)Flex::Justification::FLEX_START, TEST_LOCATION );
159   DALI_TEST_EQUALS( (int)flexNode->GetFlexItemsAlignment(), (int)Flex::Alignment::FLEX_START, TEST_LOCATION );
160
161   flexNode->AddChild(actor1, &MeasureChild, 0);
162   flexNode->AddChild(actor2, &MeasureChild, 1);
163
164   flexNode->CalculateLayout(480, 800, false);
165
166   Vector4 root = flexNode->GetNodeFrame(-1); // -1 is the root
167   Vector4 actor1Frame = flexNode->GetNodeFrame(0); // 0 is first child
168   Vector4 actor2Frame = flexNode->GetNodeFrame(1); // 1 is second child
169
170   tet_printf("Root frame(left:%f,top:%f,right:%f,bottom:%f)\n", root.x, root.y, root.z, root.w);
171
172   tet_printf("Actor 1 frame(left:%f,top:%f,right:%f,bottom:%f)\n", actor1Frame.x, actor1Frame.y, actor1Frame.z, actor1Frame.w);
173   tet_printf("Actor 2 frame(left:%f,top:%f,right:%f,bottom:%f)\n", actor2Frame.x, actor2Frame.y, actor2Frame.z, actor2Frame.w);
174
175   /*
176     ---------
177     |1      |
178     |2      |
179     |       |
180     |       |
181     |       |
182     ---------
183   */
184
185   DALI_TEST_EQUALS( actor1Frame, Vector4( 0.0f, 0.0f, ITEM_SIZE.width, ITEM_SIZE.height ), TEST_LOCATION );
186   DALI_TEST_EQUALS( actor2Frame, Vector4( 0.0f, ITEM_SIZE.height, ITEM_SIZE.width, ITEM_SIZE.height *2 ), TEST_LOCATION );
187
188   tet_infoline(" Justify to the End, items should now be displayed at the bottom");
189   flexNode->SetFlexJustification( Flex::Justification::FLEX_END );
190   flexNode->SetFlexItemsAlignment( Flex::Alignment::FLEX_START );
191
192   // Recalulate layout
193   flexNode->CalculateLayout(480, 800, false);
194
195   root = flexNode->GetNodeFrame(-1); // -1 is the root
196   actor1Frame = flexNode->GetNodeFrame(0); // 0 is first child
197   actor2Frame = flexNode->GetNodeFrame(1); // 1 is second child
198
199   tet_printf("Root frame(left:%f,top:%f,right:%f,bottom:%f)\n", root.x, root.y, root.z, root.w);
200
201   tet_printf("Actor 1 frame(left:%f,top:%f,right:%f,bottom:%f)\n", actor1Frame.x, actor1Frame.y, actor1Frame.z, actor1Frame.w);
202   tet_printf("Actor 2 frame(left:%f,top:%f,right:%f,bottom:%f)\n", actor2Frame.x, actor2Frame.y, actor2Frame.z, actor2Frame.w);
203
204   /*
205     ---------
206     |       |
207     |       |
208     |       |
209     |1      |
210     |2      |
211     ---------
212   */
213
214   DALI_TEST_EQUALS( actor1Frame, Vector4( 0.0f, root.w - (ITEM_SIZE.height*2), ITEM_SIZE.width,  root.w - ITEM_SIZE.height ), TEST_LOCATION );
215   DALI_TEST_EQUALS( actor2Frame, Vector4( 0.0f, root.w - ITEM_SIZE.height, ITEM_SIZE.width, root.w ), TEST_LOCATION );
216
217   tet_infoline(" Align to End, items should now be displayed at the bottom and the end");
218   flexNode->SetFlexJustification( Flex::Justification::FLEX_END );
219   flexNode->SetFlexItemsAlignment( Flex::Alignment::FLEX_END );
220   // Recalulate layout
221   flexNode->CalculateLayout(480, 800, false);
222
223   root = flexNode->GetNodeFrame(-1); // -1 is the root
224   actor1Frame = flexNode->GetNodeFrame(0); // 0 is first child
225   actor2Frame = flexNode->GetNodeFrame(1); // 1 is second child
226
227   tet_printf("Actor 1 frame(left:%f,top:%f,right:%f,bottom:%f)\n", actor1Frame.x, actor1Frame.y, actor1Frame.z, actor1Frame.w);
228   tet_printf("Actor 2 frame(left:%f,top:%f,right:%f,bottom:%f)\n", actor2Frame.x, actor2Frame.y, actor2Frame.z, actor2Frame.w);
229
230   /*
231     ---------
232     |       |
233     |       |
234     |       |
235     |      1|
236     |      2|
237     ---------
238   */
239
240   DALI_TEST_EQUALS( actor1Frame, Vector4( root.z - ITEM_SIZE.width, root.w - (ITEM_SIZE.height*2), root.z,  root.w - ITEM_SIZE.height ), TEST_LOCATION );
241   DALI_TEST_EQUALS( actor2Frame, Vector4( root.z - ITEM_SIZE.width, root.w - ITEM_SIZE.height, root.z, root.w ), TEST_LOCATION );
242
243   END_TEST;
244 }
245
246 int UtcDaliToolkitFlexNodeSizingP(void)
247 {
248   ToolkitTestApplication application;
249   tet_infoline(" UtcDaliToolkitFlexNodeSizingP");
250   Flex::Node* flexNode = new Flex::Node();
251   DALI_TEST_CHECK( flexNode );
252
253   // Create two actors and add them to the parent flex node
254   Actor actor1 = Actor::New();
255   Actor actor2 = Actor::New();
256   DALI_TEST_CHECK( actor1 );
257   DALI_TEST_CHECK( actor2 );
258
259   flexNode->AddChild(actor1, &MeasureChild, 0);
260   flexNode->AddChild(actor2, &MeasureChild, 1);
261
262   flexNode->CalculateLayout(480, 800, false);
263
264   DALI_TEST_EQUALS( flexNode->GetFlexWidth(), 480.0f, TEST_LOCATION );
265   DALI_TEST_EQUALS( flexNode->GetFlexHeight(), 800.0f, TEST_LOCATION );
266
267   END_TEST;
268 }
269
270 int UtcDaliToolkitFlexNodeWrapModeP(void)
271 {
272   ToolkitTestApplication application;
273   tet_infoline("UtcDaliToolkitFlexNodeWrapModeP");
274   Flex::Node* flexNode = new Flex::Node();
275   DALI_TEST_CHECK( flexNode );
276
277   // Position elements in a Column
278   flexNode->SetFlexDirection( Flex::FlexDirection::ROW );
279   flexNode->SetFlexAlignment( Flex::Alignment::FLEX_START );
280   flexNode->SetFlexWrap( Flex::WrapType::NO_WRAP );
281
282   // Create two actors and add them to the parent flex node
283   Actor actor1 = Actor::New();
284   Actor actor2 = Actor::New();
285   Actor actor3 = Actor::New();
286   Actor actor4 = Actor::New();
287
288   DALI_TEST_EQUALS( (int)flexNode->GetFlexJustification(), (int)Flex::Justification::FLEX_START, TEST_LOCATION );
289   DALI_TEST_EQUALS( (int)flexNode->GetFlexItemsAlignment(), (int)Flex::Alignment::FLEX_START, TEST_LOCATION );
290   DALI_TEST_EQUALS( (int)flexNode->GetFlexAlignment(), (int)Flex::Alignment::FLEX_START, TEST_LOCATION );
291   DALI_TEST_EQUALS( (int)flexNode->GetFlexWrap(), (int)Flex::WrapType::NO_WRAP, TEST_LOCATION );
292
293   flexNode->AddChild( actor1, &MeasureChild, 0 );
294   flexNode->AddChild( actor2, &MeasureChild, 1 );
295   flexNode->AddChild( actor2, &MeasureChild, 2 );
296   flexNode->AddChild( actor2, &MeasureChild, 3 );
297
298   flexNode->CalculateLayout(30, 800, false);
299
300   Vector4 root = flexNode->GetNodeFrame(-1); // -1 is the root
301   Vector4 actor1Frame = flexNode->GetNodeFrame(0); // 0 is first child
302   Vector4 actor2Frame = flexNode->GetNodeFrame(1); // 1 is second child
303   Vector4 actor3Frame = flexNode->GetNodeFrame(2); // 2 is first child
304   Vector4 actor4Frame = flexNode->GetNodeFrame(3); // 3 is second child
305
306   tet_printf("Root frame(left:%f,top:%f,right:%f,bottom:%f)\n", root.x, root.y, root.z, root.w);
307   tet_printf("Actor 1 frame(left:%f,top:%f,right:%f,bottom:%f)\n", actor1Frame.x, actor1Frame.y, actor1Frame.z, actor1Frame.w);
308   tet_printf("Actor 2 frame(left:%f,top:%f,right:%f,bottom:%f)\n", actor2Frame.x, actor2Frame.y, actor2Frame.z, actor2Frame.w);
309   tet_printf("Actor 3 frame(left:%f,top:%f,right:cdt%f,bottom:%f)\n", actor3Frame.x, actor3Frame.y, actor3Frame.z, actor3Frame.w);
310   tet_printf("Actor 4 frame(left:%f,top:%f,right:%f,bottom:%f)\n", actor4Frame.x, actor4Frame.y, actor4Frame.z, actor4Frame.w);
311
312   /*
313     -------
314     |1 2 3 4     |
315     |     |
316     |     |
317     |     |
318     |     |
319     -------
320   */
321
322   DALI_TEST_EQUALS( actor1Frame, Vector4( 0.0f,            0.0f, ITEM_SIZE.width, ITEM_SIZE.height ), TEST_LOCATION );
323   DALI_TEST_EQUALS( actor2Frame, Vector4( ITEM_SIZE.width, 0.0f, ITEM_SIZE.width*2, ITEM_SIZE.height ), TEST_LOCATION );
324   DALI_TEST_EQUALS( actor3Frame, Vector4( ITEM_SIZE.width*2, 0.0f, ITEM_SIZE.width*3, ITEM_SIZE.height ), TEST_LOCATION );
325   DALI_TEST_EQUALS( actor4Frame, Vector4( ITEM_SIZE.width*3, 0.0f, ITEM_SIZE.width*4, ITEM_SIZE.height ), TEST_LOCATION );
326
327   flexNode->SetFlexWrap( Flex::WrapType::WRAP );
328
329   flexNode->CalculateLayout( 30, 800, false );
330   root = flexNode->GetNodeFrame(-1); // -1 is the root
331
332   DALI_TEST_EQUALS( (int)flexNode->GetFlexWrap(), (int)Flex::WrapType::WRAP, TEST_LOCATION );
333   tet_printf("Root frame(left:%f,top:%f,right:%f,bottom:%f)\n", root.x, root.y, root.z, root.w);
334
335   actor1Frame = flexNode->GetNodeFrame(0); // 0 is first child
336   actor2Frame = flexNode->GetNodeFrame(1); // 1 is second child
337   actor3Frame = flexNode->GetNodeFrame(2); // 2 is first child
338   actor4Frame = flexNode->GetNodeFrame(3); // 3 is second child
339
340   tet_printf("Actor 1 frame(left:%f,top:%f,right:%f,bottom:%f)\n", actor1Frame.x, actor1Frame.y, actor1Frame.z, actor1Frame.w);
341   tet_printf("Actor 2 frame(left:%f,top:%f,right:%f,bottom:%f)\n", actor2Frame.x, actor2Frame.y, actor2Frame.z, actor2Frame.w);
342   tet_printf("Actor 3 frame(left:%f,top:%f,right:%f,bottom:%f)\n", actor3Frame.x, actor3Frame.y, actor3Frame.z, actor3Frame.w);
343   tet_printf("Actor 4 frame(left:%f,top:%f,right:%f,bottom:%f)\n", actor4Frame.x, actor4Frame.y, actor4Frame.z, actor4Frame.w);
344
345   /*
346     -------
347     |1 2 3|     |
348     |4    |
349     |     |
350     |     |
351     |     |
352     -------
353   */
354
355   DALI_TEST_EQUALS( actor1Frame, Vector4( 0.0f,            0.0f, ITEM_SIZE.width, ITEM_SIZE.height ), TEST_LOCATION );
356   DALI_TEST_EQUALS( actor2Frame, Vector4( ITEM_SIZE.width, 0.0f, ITEM_SIZE.width*2, ITEM_SIZE.height ), TEST_LOCATION );
357   DALI_TEST_EQUALS( actor3Frame, Vector4( ITEM_SIZE.width*2, 0.0f, ITEM_SIZE.width*3, ITEM_SIZE.height ), TEST_LOCATION );
358   DALI_TEST_EQUALS( actor4Frame, Vector4( 0.0,ITEM_SIZE.height, ITEM_SIZE.width, ITEM_SIZE.height*2 ), TEST_LOCATION );
359
360
361   END_TEST;
362 }
363
364 int UtcDaliToolkitFlexNodeRemoveChildP(void)
365 {
366   ToolkitTestApplication application;
367   tet_infoline(" UtcDaliToolkitFlexNodeRemoveChildP");
368   Flex::Node* flexNode = new Flex::Node();
369   DALI_TEST_CHECK( flexNode );
370
371   // Create two actors and add them to the parent flex node
372   Actor actor1 = Actor::New();
373   Actor actor2 = Actor::New();
374   actor1.SetName("Actor1");
375   actor2.SetName("Actor2");
376
377   DALI_TEST_CHECK( actor1 );
378   DALI_TEST_CHECK( actor2 );
379
380   flexNode->AddChild(actor1, &MeasureChild, 0);
381   flexNode->AddChild(actor2, &MeasureChild, 1);
382
383   flexNode->CalculateLayout(480, 800, false);
384
385   Vector4 actor1Frame = flexNode->GetNodeFrame(0);
386   Vector4 actor2Frame = flexNode->GetNodeFrame(1);
387
388   tet_printf("Actor 1 frame(%f,%f,%f,%f)\n", actor1Frame.x, actor1Frame.y, actor1Frame.z, actor1Frame.w);
389   tet_printf("Actor 2 frame(%f,%f,%f,%f)\n", actor2Frame.x, actor2Frame.y, actor2Frame.z, actor2Frame.w);
390
391   DALI_TEST_EQUALS( actor2Frame, Vector4( 0.0f, ITEM_SIZE.width, ITEM_SIZE.width, ITEM_SIZE.height*2 ), TEST_LOCATION );
392
393   flexNode->RemoveChild(actor1);
394
395   flexNode->CalculateLayout(480, 800, false);
396
397   actor2Frame = flexNode->GetNodeFrame(0);
398
399   tet_printf("Actor 1 frame(%f,%f,%f,%f)\n", actor1Frame.x, actor1Frame.y, actor1Frame.z, actor1Frame.w);
400   tet_printf("Actor 2 frame(%f,%f,%f,%f)\n", actor2Frame.x, actor2Frame.y, actor2Frame.z, actor2Frame.w);
401
402   DALI_TEST_EQUALS( actor2Frame, Vector4( 0.0f, 0.0f, ITEM_SIZE.width, ITEM_SIZE.height ), TEST_LOCATION );
403
404   END_TEST;
405 }
406
407 int UtcDaliToolkitFlexNodeRemoveAllChildrenP(void)
408 {
409   ToolkitTestApplication application;
410   tet_infoline(" UtcDaliToolkitFlexNodeRemoveAllChildrenP");
411   Flex::Node* flexNode = new Flex::Node();
412   DALI_TEST_CHECK( flexNode );
413
414   // Create two actors and add them to the parent flex node
415   Actor actor1 = Actor::New();
416   Actor actor2 = Actor::New();
417   actor1.SetName("Actor1");
418   actor2.SetName("Actor2");
419
420   DALI_TEST_CHECK( actor1 );
421   DALI_TEST_CHECK( actor2 );
422
423   flexNode->AddChild(actor1, &MeasureChild, 0);
424   flexNode->AddChild(actor2, &MeasureChild, 1);
425
426   flexNode->CalculateLayout(480, 800, false);
427
428   Vector4 actor1Frame = flexNode->GetNodeFrame(0);
429   Vector4 actor2Frame = flexNode->GetNodeFrame(1);
430
431   tet_printf("Actor 1 frame(%f,%f,%f,%f)\n", actor1Frame.x, actor1Frame.y, actor1Frame.z, actor1Frame.w);
432   tet_printf("Actor 2 frame(%f,%f,%f,%f)\n", actor2Frame.x, actor2Frame.y, actor2Frame.z, actor2Frame.w);
433
434   flexNode->RemoveChild(actor1);
435   flexNode->RemoveChild(actor2);
436
437   flexNode->CalculateLayout(480, 800, false);
438
439   Vector4 actor1FrameRemoved = flexNode->GetNodeFrame(0);
440   Vector4 actor2FrameRemoved = flexNode->GetNodeFrame(1);
441
442   tet_printf("Actor 1 frame(%f,%f,%f,%f)\n", actor1FrameRemoved.x, actor1FrameRemoved.y, actor1FrameRemoved.z, actor1FrameRemoved.w);
443   tet_printf("Actor 2 frame(%f,%f,%f,%f)\n", actor2FrameRemoved.x, actor2FrameRemoved.y, actor2FrameRemoved.z, actor2FrameRemoved.w);
444
445   DALI_TEST_NOT_EQUALS( actor1Frame, actor1FrameRemoved, 0.1, TEST_LOCATION );
446   DALI_TEST_NOT_EQUALS( actor2Frame, actor2FrameRemoved, 0.1, TEST_LOCATION );
447
448   END_TEST;
449 }
450
451 int UtcDaliToolkitFlexNodePaddingMarginP(void)
452 {
453   ToolkitTestApplication application;
454   tet_infoline(" UtcDaliToolkitFlexNodePaddingMarginP");
455   Flex::Node* flexNode = new Flex::Node();
456   DALI_TEST_CHECK( flexNode );
457   flexNode->SetFlexDirection( Flex::FlexDirection::ROW );
458
459   // Create two actors and add them to the parent flex node
460   Actor actor1 = Actor::New();
461   Actor actor2 = Actor::New();
462   DALI_TEST_CHECK( actor1 );
463   DALI_TEST_CHECK( actor2 );
464
465   flexNode->AddChild(actor1, &MeasureChild, 0);
466   flexNode->AddChild(actor2, &MeasureChild, 1);
467
468   Extents padding( 5,5,5,5);
469   Extents margin( 5,5,5,5);
470
471   flexNode->SetPadding( padding );
472   flexNode->SetMargin( margin );
473
474   flexNode->CalculateLayout(480, 800, false);
475
476   Vector4 actor1Frame = flexNode->GetNodeFrame(0);
477   Vector4 actor2Frame = flexNode->GetNodeFrame(1);
478
479   /*  p = padding
480   -----
481   |ppppp|
482   |p1 2p|
483   |p   p|
484   |ppppp|
485   -------
486   */
487   DALI_TEST_EQUALS( actor1Frame, Vector4( 5.0f, 5.0f, ITEM_SIZE.width +5 , ITEM_SIZE.height + 5 ), TEST_LOCATION );
488   DALI_TEST_EQUALS( actor2Frame, Vector4( 5+ ITEM_SIZE.width, 5.0f, (ITEM_SIZE.width*2) +5, ITEM_SIZE.height +5 ), TEST_LOCATION );
489
490   END_TEST;
491 }
492
493 int UtcDaliToolkitFlexNodeCallbackTestP(void)
494 {
495   ToolkitTestApplication application;
496   tet_infoline("UtcDaliToolkitFlexNodeCallbackTestP");
497   Flex::Node* flexNode = new Flex::Node();
498   DALI_TEST_CHECK( flexNode );
499
500   // Position elements in a Column
501   flexNode->SetFlexDirection(Flex::FlexDirection::COLUMN);
502
503   // Create two actors and add them to the parent flex node
504   Actor actor1 = Actor::New();
505   Actor actor2 = Actor::New();
506
507   actor1.SetName("callbackTest");
508
509   DALI_TEST_CHECK( actor1 );
510   DALI_TEST_CHECK( actor2 );
511
512   flexNode->AddChild(actor1, &MeasureChild, 0);
513   flexNode->AddChild(actor2, &MeasureChild, 1);
514
515   flexNode->CalculateLayout(480, 800, false);
516
517   Vector4 root = flexNode->GetNodeFrame(-1); // -1 is the root
518   Vector4 actor1Frame = flexNode->GetNodeFrame(0); // 0 is first child
519   Vector4 actor2Frame = flexNode->GetNodeFrame(1); // 1 is second child
520
521   tet_printf("Root frame(left:%f,top:%f,right:%f,bottom:%f)\n", root.x, root.y, root.z, root.w);
522
523   tet_printf("Actor 1 frame(left:%f,top:%f,right:%f,bottom:%f)\n", actor1Frame.x, actor1Frame.y, actor1Frame.z, actor1Frame.w);
524   tet_printf("Actor 2 frame(left:%f,top:%f,right:%f,bottom:%f)\n", actor2Frame.x, actor2Frame.y, actor2Frame.z, actor2Frame.w);
525
526   DALI_TEST_EQUALS( actor1Frame, Vector4( 0.0f, 0.0f, ITEM_SIZE_CALLBACK_TEST.width, ITEM_SIZE_CALLBACK_TEST.height ), TEST_LOCATION );
527   DALI_TEST_EQUALS( actor2Frame, Vector4( 0.0f, ITEM_SIZE_CALLBACK_TEST.height, ITEM_SIZE.width, ITEM_SIZE_CALLBACK_TEST.height + ITEM_SIZE.height ), TEST_LOCATION );
528
529   END_TEST;
530 }