[dali_2.0.15] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-FlexContainer.cpp
1 /*
2  * Copyright (c) 2020 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
24 using namespace Dali;
25 using namespace Toolkit;
26
27 void dali_flexflexContainer_startup(void)
28 {
29   test_return_value = TET_UNDEF;
30 }
31
32 void dali_flexflexContainer_cleanup(void)
33 {
34   test_return_value = TET_PASS;
35 }
36
37 namespace
38 {
39
40 const char* const PROPERTY_NAME_CONTENT_DIRECTION = "contentDirection";
41 const char* const PROPERTY_NAME_FLEX_DIRECTION = "flexDirection";
42 const char* const PROPERTY_NAME_FLEX_WRAP = "flexWrap";
43 const char* const PROPERTY_NAME_JUSTIFY_CONTENT = "justifyContent";
44 const char* const PROPERTY_NAME_ALIGN_ITEMS = "alignItems";
45 const char* const PROPERTY_NAME_ALIGN_CONTENT =  "alignContent";
46 const char* const CHILD_PROPERTY_NAME_FLEX = "flex";
47 const char* const CHILD_PROPERTY_NAME_ALIGN_SELF = "alignSelf";
48 const char* const CHILD_PROPERTY_NAME_FLEX_MARGIN =  "flexMargin";
49
50 } // namespace
51
52 int UtcDaliToolkitFlexContainerConstructorP(void)
53 {
54   ToolkitTestApplication application;
55   tet_infoline(" UtcDaliToolkitFlexContainerConstructorP");
56   FlexContainer flexContainer;
57   DALI_TEST_CHECK( !flexContainer );
58   END_TEST;
59 }
60
61 int UtcDaliToolkitFlexContainerNewP(void)
62 {
63   ToolkitTestApplication application;
64   tet_infoline(" UtcDaliToolkitFlexContainerNewP");
65   FlexContainer flexContainer = FlexContainer::New();
66   DALI_TEST_CHECK( flexContainer );
67   END_TEST;
68 }
69
70 int UtcDaliToolkitFlexContainerDownCastP(void)
71 {
72   ToolkitTestApplication application;
73   tet_infoline(" UtcDaliToolkitFlexContainerDownCastP");
74   FlexContainer flexContainer1 = FlexContainer::New();
75   BaseHandle object( flexContainer1 );
76
77   FlexContainer flexContainer2 = FlexContainer::DownCast( object );
78   DALI_TEST_CHECK( flexContainer2 );
79
80   FlexContainer flexContainer3 = DownCast< FlexContainer >( object );
81   DALI_TEST_CHECK( flexContainer3 );
82   END_TEST;
83 }
84
85 int UtcDaliToolkitFlexContainerDownCastN(void)
86 {
87   ToolkitTestApplication application;
88   tet_infoline(" UtcDaliToolkitFlexContainerDownCastN");
89   BaseHandle uninitializedObject;
90   FlexContainer flexContainer1 = FlexContainer::DownCast( uninitializedObject );
91   DALI_TEST_CHECK( !flexContainer1 );
92
93   FlexContainer flexContainer2 = DownCast< FlexContainer >( uninitializedObject );
94   DALI_TEST_CHECK( !flexContainer2 );
95   END_TEST;
96 }
97
98 int UtcDaliToolkitFlexContainerCopyConstructorP(void)
99 {
100   ToolkitTestApplication application;
101   tet_infoline(" UtcDaliToolkitFlexContainerCopyConstructorP");
102   FlexContainer flexContainer = FlexContainer::New();
103   flexContainer.SetProperty( FlexContainer::Property::FLEX_DIRECTION, FlexContainer::ROW_REVERSE );
104
105   FlexContainer copy( flexContainer );
106   DALI_TEST_CHECK( copy );
107   DALI_TEST_CHECK( copy.GetProperty<int>( FlexContainer::Property::FLEX_DIRECTION ) == flexContainer.GetProperty<int>( FlexContainer::Property::FLEX_DIRECTION ) );
108
109   END_TEST;
110 }
111
112 int UtcDaliFlexContainerMoveConstructor(void)
113 {
114   ToolkitTestApplication application;
115
116   FlexContainer flexContainer = FlexContainer::New();
117   DALI_TEST_EQUALS( 1, flexContainer.GetBaseObject().ReferenceCount(), TEST_LOCATION );
118   flexContainer.SetProperty( FlexContainer::Property::FLEX_DIRECTION, FlexContainer::ROW_REVERSE );
119   DALI_TEST_CHECK( flexContainer.GetProperty<int>( FlexContainer::Property::FLEX_DIRECTION ) == FlexContainer::ROW_REVERSE );
120
121   FlexContainer moved = std::move( flexContainer );
122   DALI_TEST_CHECK( moved );
123   DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
124   DALI_TEST_CHECK( moved.GetProperty<int>( FlexContainer::Property::FLEX_DIRECTION ) == FlexContainer::ROW_REVERSE );
125   DALI_TEST_CHECK( !flexContainer );
126
127   END_TEST;
128 }
129
130 int UtcDaliToolkitFlexContainerAssignmentOperatorP(void)
131 {
132   ToolkitTestApplication application;
133   tet_infoline(" UtcDaliToolkitFlexContainerAssingmentOperatorP");
134   FlexContainer flexContainer = FlexContainer::New();
135   flexContainer.SetProperty( FlexContainer::Property::FLEX_DIRECTION, FlexContainer::ROW_REVERSE );
136
137   FlexContainer copy = flexContainer;
138   DALI_TEST_CHECK( copy );
139   DALI_TEST_CHECK( copy.GetProperty<int>( FlexContainer::Property::FLEX_DIRECTION ) == flexContainer.GetProperty<int>( FlexContainer::Property::FLEX_DIRECTION ) );
140   END_TEST;
141 }
142
143 int UtcDaliFlexContainerMoveAssignment(void)
144 {
145   ToolkitTestApplication application;
146
147   FlexContainer flexContainer = FlexContainer::New();
148   DALI_TEST_EQUALS( 1, flexContainer.GetBaseObject().ReferenceCount(), TEST_LOCATION );
149   flexContainer.SetProperty( FlexContainer::Property::FLEX_DIRECTION, FlexContainer::ROW_REVERSE );
150   DALI_TEST_CHECK( flexContainer.GetProperty<int>( FlexContainer::Property::FLEX_DIRECTION ) == FlexContainer::ROW_REVERSE );
151
152   FlexContainer moved;
153   moved = std::move( flexContainer );
154   DALI_TEST_CHECK( moved );
155   DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
156   DALI_TEST_CHECK( moved.GetProperty<int>( FlexContainer::Property::FLEX_DIRECTION ) == FlexContainer::ROW_REVERSE );
157   DALI_TEST_CHECK( !flexContainer );
158
159   END_TEST;
160 }
161
162 // Positive test case for a method
163 int UtcDaliToolkitFlexContainerGetPropertyP(void)
164 {
165   ToolkitTestApplication application;
166   tet_infoline(" UtcDaliToolkitFlexContainerGetPropertyP");
167   FlexContainer flexContainer = FlexContainer::New();
168   DALI_TEST_CHECK( flexContainer );
169
170   // Check Property Indices are correct
171   DALI_TEST_CHECK( flexContainer.GetPropertyIndex( PROPERTY_NAME_CONTENT_DIRECTION ) == FlexContainer::Property::CONTENT_DIRECTION );
172   DALI_TEST_CHECK( flexContainer.GetPropertyIndex( PROPERTY_NAME_FLEX_DIRECTION ) == FlexContainer::Property::FLEX_DIRECTION );
173   DALI_TEST_CHECK( flexContainer.GetPropertyIndex( PROPERTY_NAME_FLEX_WRAP ) == FlexContainer::Property::FLEX_WRAP );
174   DALI_TEST_CHECK( flexContainer.GetPropertyIndex( PROPERTY_NAME_JUSTIFY_CONTENT ) == FlexContainer::Property::JUSTIFY_CONTENT );
175   DALI_TEST_CHECK( flexContainer.GetPropertyIndex( PROPERTY_NAME_ALIGN_ITEMS ) == FlexContainer::Property::ALIGN_ITEMS );
176   DALI_TEST_CHECK( flexContainer.GetPropertyIndex( PROPERTY_NAME_ALIGN_CONTENT ) == FlexContainer::Property::ALIGN_CONTENT );
177
178   END_TEST;
179 }
180
181 int UtcDaliToolkitFlexContainerSetPropertyP(void)
182 {
183   ToolkitTestApplication application;
184   tet_infoline(" UtcDaliToolkitFlexContainerSetPropertyP");
185   FlexContainer flexContainer = FlexContainer::New();
186   DALI_TEST_CHECK( flexContainer );
187
188   // Add flex container to the stage
189   application.GetScene().Add( flexContainer );
190
191   // Create two actors and add them to the container
192   Actor actor1 = Actor::New();
193   Actor actor2 = Actor::New();
194   DALI_TEST_CHECK( actor1 );
195   DALI_TEST_CHECK( actor2 );
196
197   flexContainer.Add(actor1);
198   flexContainer.Add(actor2);
199
200   // Check content direction property.
201   flexContainer.SetProperty( FlexContainer::Property::CONTENT_DIRECTION, FlexContainer::RTL );
202   DALI_TEST_EQUALS( (FlexContainer::ContentDirection)flexContainer.GetProperty<int>( FlexContainer::Property::CONTENT_DIRECTION ), FlexContainer::RTL, TEST_LOCATION );
203
204   // Check flex direction property.
205   flexContainer.SetProperty( FlexContainer::Property::FLEX_DIRECTION, FlexContainer::COLUMN_REVERSE );
206   DALI_TEST_EQUALS( (FlexContainer::FlexDirection)flexContainer.GetProperty<int>( FlexContainer::Property::FLEX_DIRECTION ), FlexContainer::COLUMN_REVERSE, TEST_LOCATION );
207
208   // Check flex wrap property.
209   flexContainer.SetProperty( FlexContainer::Property::FLEX_WRAP, FlexContainer::WRAP );
210   DALI_TEST_EQUALS( (FlexContainer::WrapType)flexContainer.GetProperty<int>( FlexContainer::Property::FLEX_WRAP ), FlexContainer::WRAP, TEST_LOCATION );
211
212   // Check justify content property.
213   flexContainer.SetProperty( FlexContainer::Property::JUSTIFY_CONTENT, FlexContainer::JUSTIFY_SPACE_BETWEEN );
214   DALI_TEST_EQUALS( (FlexContainer::Justification)flexContainer.GetProperty<int>( FlexContainer::Property::JUSTIFY_CONTENT ), FlexContainer::JUSTIFY_SPACE_BETWEEN, TEST_LOCATION );
215
216   // Check align items property.
217   flexContainer.SetProperty( FlexContainer::Property::ALIGN_ITEMS, FlexContainer::ALIGN_FLEX_START );
218   DALI_TEST_EQUALS( (FlexContainer::Alignment)flexContainer.GetProperty<int>( FlexContainer::Property::ALIGN_ITEMS ), FlexContainer::ALIGN_FLEX_START, TEST_LOCATION );
219
220   // Check align content property.
221   flexContainer.SetProperty( FlexContainer::Property::ALIGN_CONTENT, FlexContainer::ALIGN_STRETCH );
222   DALI_TEST_EQUALS( (FlexContainer::Alignment)flexContainer.GetProperty<int>( FlexContainer::Property::ALIGN_CONTENT ), FlexContainer::ALIGN_STRETCH, TEST_LOCATION );
223
224   END_TEST;
225 }
226
227
228 int UtcDaliToolkitFlexContainerSetPropertyEnumP(void)
229 {
230   ToolkitTestApplication application;
231   tet_infoline(" UtcDaliToolkitFlexContainerSetPropertyEnumP");
232   FlexContainer flexContainer = FlexContainer::New();
233   DALI_TEST_CHECK( flexContainer );
234
235   // Add flex container to the stage
236   application.GetScene().Add( flexContainer );
237
238   // Create two actors and add them to the container
239   Actor actor1 = Actor::New();
240   Actor actor2 = Actor::New();
241   DALI_TEST_CHECK( actor1 );
242   DALI_TEST_CHECK( actor2 );
243
244   flexContainer.Add(actor1);
245   flexContainer.Add(actor2);
246
247   // Check content direction property.
248   flexContainer.SetProperty( FlexContainer::Property::CONTENT_DIRECTION, "RTL" );
249   DALI_TEST_EQUALS( (FlexContainer::ContentDirection)flexContainer.GetProperty<int>( FlexContainer::Property::CONTENT_DIRECTION ), FlexContainer::RTL, TEST_LOCATION );
250
251   // Check flex direction property.
252   flexContainer.SetProperty( FlexContainer::Property::FLEX_DIRECTION, "columnReverse" );
253   DALI_TEST_EQUALS( (FlexContainer::FlexDirection)flexContainer.GetProperty<int>( FlexContainer::Property::FLEX_DIRECTION ), FlexContainer::COLUMN_REVERSE, TEST_LOCATION );
254
255   // Check flex wrap property.
256   flexContainer.SetProperty( FlexContainer::Property::FLEX_WRAP, "wrap" );
257   DALI_TEST_EQUALS( (FlexContainer::WrapType)flexContainer.GetProperty<int>( FlexContainer::Property::FLEX_WRAP ), FlexContainer::WRAP, TEST_LOCATION );
258
259   // Check justify content property.
260   flexContainer.SetProperty( FlexContainer::Property::JUSTIFY_CONTENT, "spaceBetween" );
261   DALI_TEST_EQUALS( (FlexContainer::Justification)flexContainer.GetProperty<int>( FlexContainer::Property::JUSTIFY_CONTENT ), FlexContainer::JUSTIFY_SPACE_BETWEEN, TEST_LOCATION );
262
263   // Check align items property.
264   flexContainer.SetProperty( FlexContainer::Property::ALIGN_ITEMS, "flexStart" );
265   DALI_TEST_EQUALS( (FlexContainer::Alignment)flexContainer.GetProperty<int>( FlexContainer::Property::ALIGN_ITEMS ), FlexContainer::ALIGN_FLEX_START, TEST_LOCATION );
266
267   // Check align content property.
268   flexContainer.SetProperty( FlexContainer::Property::ALIGN_CONTENT, "stretch" );
269   DALI_TEST_EQUALS( (FlexContainer::Alignment)flexContainer.GetProperty<int>( FlexContainer::Property::ALIGN_CONTENT ), FlexContainer::ALIGN_STRETCH, TEST_LOCATION );
270
271   END_TEST;
272 }
273
274 int UtcDaliToolkitFlexContainerSetChildPropertyP(void)
275 {
276   ToolkitTestApplication application;
277   tet_infoline(" UtcDaliToolkitFlexContainerSetChildPropertyP");
278   FlexContainer flexContainer = FlexContainer::New();
279   DALI_TEST_CHECK( flexContainer );
280
281   // Add flex container to the stage
282   application.GetScene().Add( flexContainer );
283
284   // Create an actor and add it to the container
285   Actor actor = Actor::New();
286   DALI_TEST_CHECK( actor );
287
288   flexContainer.Add(actor);
289
290   // Check flex child property.
291   actor.SetProperty( FlexContainer::ChildProperty::FLEX, 2.0f );
292   DALI_TEST_EQUALS( actor.GetProperty<float>( FlexContainer::ChildProperty::FLEX ), 2.0f, TEST_LOCATION );
293   DALI_TEST_CHECK( actor.GetPropertyIndex( CHILD_PROPERTY_NAME_FLEX ) == FlexContainer::ChildProperty::FLEX );
294
295   // Check align self child property.
296   actor.SetProperty( FlexContainer::ChildProperty::ALIGN_SELF, FlexContainer::ALIGN_FLEX_END );
297   DALI_TEST_EQUALS( (FlexContainer::Alignment)actor.GetProperty<int>( FlexContainer::ChildProperty::ALIGN_SELF ), FlexContainer::ALIGN_FLEX_END, TEST_LOCATION );
298   DALI_TEST_CHECK( actor.GetPropertyIndex( CHILD_PROPERTY_NAME_ALIGN_SELF ) == FlexContainer::ChildProperty::ALIGN_SELF );
299
300   // Check flex margin child property.
301   actor.SetProperty( FlexContainer::ChildProperty::FLEX_MARGIN, Vector4( 10.0f, 10.0f, 10.0f, 10.0f ) );
302   DALI_TEST_EQUALS( actor.GetProperty<Vector4>( FlexContainer::ChildProperty::FLEX_MARGIN ), Vector4( 10.0f, 10.0f, 10.0f, 10.0f ), TEST_LOCATION );
303   DALI_TEST_CHECK( actor.GetPropertyIndex( CHILD_PROPERTY_NAME_FLEX_MARGIN ) == FlexContainer::ChildProperty::FLEX_MARGIN );
304
305   application.SendNotification();
306   application.Render();
307
308   END_TEST;
309 }
310
311
312
313 //Functor to test whether RelayoutSignal is emitted
314 class RelayoutSignalHandler : public Dali::ConnectionTracker
315 {
316 public:
317
318   RelayoutSignalHandler( FlexContainer& actor )
319   : mSignalVerified( false ),
320     mActor( actor )
321   {
322   }
323
324   // callback to be connected to RelayoutSignal
325   void RelayoutCallback( Actor actor  )
326   {
327     if( mActor == actor )
328     {
329       mSignalVerified = true;
330     }
331   }
332
333   void Reset()
334   {
335     mSignalVerified = false;
336   }
337
338   bool   mSignalVerified;
339   Actor& mActor;
340 };
341
342 int UtcDaliToolkitFlexContainerRemoveChildP(void)
343 {
344   ToolkitTestApplication application;
345   tet_infoline(" UtcDaliToolkitFlexContainerSetPropertyP");
346   FlexContainer flexContainer = FlexContainer::New();
347   DALI_TEST_CHECK( flexContainer );
348
349   // Add flex container to the stage
350   application.GetScene().Add( flexContainer );
351
352   RelayoutSignalHandler relayoutSignal(flexContainer);
353   flexContainer.OnRelayoutSignal().Connect(&relayoutSignal, &RelayoutSignalHandler::RelayoutCallback );
354
355   // Create two actors and add them to the container
356   Actor actor1 = Actor::New();
357   Actor actor2 = Actor::New();
358   DALI_TEST_CHECK( actor1 );
359   DALI_TEST_CHECK( actor2 );
360
361   flexContainer.Add(actor1);
362   flexContainer.Add(actor2);
363
364   application.SendNotification();
365   application.Render();
366
367   DALI_TEST_EQUALS( relayoutSignal.mSignalVerified, true, TEST_LOCATION );
368   relayoutSignal.Reset();
369
370   DALI_TEST_CHECK( actor1 );
371   DALI_TEST_CHECK( actor2 );
372
373   flexContainer.Remove(actor1);
374   application.SendNotification();
375   application.Render();
376   DALI_TEST_EQUALS( relayoutSignal.mSignalVerified, true, TEST_LOCATION );
377   relayoutSignal.Reset();
378
379   flexContainer.Remove(actor2);
380   application.SendNotification();
381   application.Render();
382   DALI_TEST_EQUALS( relayoutSignal.mSignalVerified, true, TEST_LOCATION );
383   relayoutSignal.Reset();
384
385   END_TEST;
386 }
387
388 namespace
389 {
390
391 // Functors to test whether PreFocusChange signal is emitted when the keyboard focus is about to change
392 class PreFocusChangeCallback : public Dali::ConnectionTracker
393 {
394 public:
395   PreFocusChangeCallback(bool& signalReceived, Actor firstFocusActor)
396   : mSignalVerified(signalReceived),
397     mFirstFocusActor(firstFocusActor),
398     mDirection(Control::KeyboardFocus::LEFT)
399   {
400   }
401
402   Actor Callback(Actor currentFocusedActor, Actor proposedActorToFocus, Control::KeyboardFocus::Direction direction)
403   {
404     tet_infoline("Verifying PreFocusChangeCallback()");
405
406     mSignalVerified = true;
407     mDirection = direction;
408     if( ! proposedActorToFocus )
409     {
410       return mFirstFocusActor;
411     }
412     else
413     {
414       return proposedActorToFocus;
415     }
416   }
417
418   void Reset()
419   {
420     mSignalVerified = false;
421     mDirection = Control::KeyboardFocus::LEFT;
422   }
423
424   bool& mSignalVerified;
425   Actor mFirstFocusActor;
426   Control::KeyboardFocus::Direction mDirection;
427 };
428
429 // Functors to test whether focus changed signal is emitted when the keyboard focus is changed
430 class FocusChangedCallback : public Dali::ConnectionTracker
431 {
432 public:
433   FocusChangedCallback(bool& signalReceived)
434   : mSignalVerified(signalReceived),
435     mOriginalFocusedActor(),
436     mCurrentFocusedActor()
437   {
438   }
439
440   void Callback(Actor originalFocusedActor, Actor currentFocusedActor)
441   {
442     tet_infoline("Verifying FocusChangedCallback()");
443
444     if(originalFocusedActor == mCurrentFocusedActor)
445     {
446       mSignalVerified = true;
447     }
448
449     mOriginalFocusedActor = originalFocusedActor;
450     mCurrentFocusedActor = currentFocusedActor;
451   }
452
453   void Reset()
454   {
455     mSignalVerified = false;
456   }
457
458   bool& mSignalVerified;
459   Actor mOriginalFocusedActor;
460   Actor mCurrentFocusedActor;
461 };
462
463 } // anonymous namespace
464
465
466 int UtcDaliToolkitFlexContainerMoveFocus(void)
467 {
468   ToolkitTestApplication application;
469   tet_infoline(" UtcDaliToolkitFlexContainerSetPropertyP");
470   FlexContainer flexContainer = FlexContainer::New();
471   DALI_TEST_CHECK( flexContainer );
472
473   flexContainer.SetProperty( FlexContainer::Property::FLEX_DIRECTION, FlexContainer::ROW );
474
475   // Add flex container to the stage
476   application.GetScene().Add( flexContainer );
477   Size stageSize = application.GetScene().GetSize();
478
479   RelayoutSignalHandler relayoutSignal(flexContainer);
480   flexContainer.OnRelayoutSignal().Connect(&relayoutSignal, &RelayoutSignalHandler::RelayoutCallback );
481   flexContainer.SetProperty( Actor::Property::SIZE, stageSize );
482
483   // Create two actors and add them to the container
484   Actor actor1 = Actor::New();
485   Actor actor2 = Actor::New();
486   actor1.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE, true );
487   actor2.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE, true );
488   DALI_TEST_CHECK( actor1 );
489   DALI_TEST_CHECK( actor2 );
490
491   flexContainer.Add(actor1);
492   flexContainer.Add(actor2);
493
494   application.SendNotification();
495   application.Render();
496
497   KeyboardFocusManager manager = KeyboardFocusManager::Get();
498   DALI_TEST_CHECK(manager);
499
500   bool preFocusChangeSignalVerified = false;
501   PreFocusChangeCallback preFocusChangeCallback(preFocusChangeSignalVerified, actor1);
502   manager.PreFocusChangeSignal().Connect( &preFocusChangeCallback, &PreFocusChangeCallback::Callback );
503
504   bool focusChangedSignalVerified = false;
505   FocusChangedCallback focusChangedCallback(focusChangedSignalVerified);
506   manager.FocusChangedSignal().Connect( &focusChangedCallback, &FocusChangedCallback::Callback );
507
508   // Move the focus to the right
509   DALI_TEST_EQUALS(manager.MoveFocus(Control::KeyboardFocus::RIGHT), true, TEST_LOCATION);
510   DALI_TEST_CHECK(preFocusChangeCallback.mSignalVerified);
511   DALI_TEST_EQUALS(manager.GetCurrentFocusActor(), actor1, TEST_LOCATION);
512   preFocusChangeCallback.Reset();
513   DALI_TEST_EQUALS(focusChangedCallback.mCurrentFocusedActor, actor1, TEST_LOCATION);
514   focusChangedCallback.Reset();
515
516   // Move the focus towards right
517   DALI_TEST_EQUALS(manager.MoveFocus(Control::KeyboardFocus::RIGHT), true, TEST_LOCATION);
518   DALI_TEST_EQUALS(preFocusChangeCallback.mSignalVerified, true, TEST_LOCATION);
519   DALI_TEST_EQUALS(manager.GetCurrentFocusActor(), actor2, TEST_LOCATION);
520   DALI_TEST_EQUALS(focusChangedCallback.mSignalVerified, true, TEST_LOCATION);
521   DALI_TEST_EQUALS(focusChangedCallback.mCurrentFocusedActor, actor2, TEST_LOCATION);
522
523   preFocusChangeCallback.Reset();
524   focusChangedCallback.Reset();
525
526   // Move the focus towards left
527   DALI_TEST_EQUALS(manager.MoveFocus(Control::KeyboardFocus::LEFT), true, TEST_LOCATION);
528   DALI_TEST_EQUALS(preFocusChangeCallback.mSignalVerified, true, TEST_LOCATION);
529   DALI_TEST_EQUALS(manager.GetCurrentFocusActor(), actor1, TEST_LOCATION);
530   DALI_TEST_EQUALS(focusChangedCallback.mSignalVerified, true, TEST_LOCATION);
531   DALI_TEST_EQUALS(focusChangedCallback.mCurrentFocusedActor, actor1, TEST_LOCATION);
532
533   END_TEST;
534 }
535
536 int UtcDaliToolkitFlexContainerRTLSupportP(void)
537 {
538   ToolkitTestApplication application;
539   tet_infoline(" UtcDaliToolkitFlexContainerRTLSupportP");
540   FlexContainer flexContainer = FlexContainer::New();
541   DALI_TEST_CHECK( flexContainer );
542
543   Actor actor0 = Actor::New();
544
545   application.GetScene().Add( actor0 );
546   actor0.Add( flexContainer );
547
548   // Create two actors and add them to the container
549   Actor actor1 = Actor::New();
550   Actor actor2 = Actor::New();
551   DALI_TEST_CHECK( actor1 );
552   DALI_TEST_CHECK( actor2 );
553
554   flexContainer.Add(actor1);
555   flexContainer.Add(actor2);
556
557   // Check flex direction property.
558   flexContainer.SetProperty( FlexContainer::Property::FLEX_DIRECTION, "row" );
559   DALI_TEST_EQUALS( (FlexContainer::FlexDirection)flexContainer.GetProperty<int>( FlexContainer::Property::FLEX_DIRECTION ), FlexContainer::ROW, TEST_LOCATION );
560
561   // Check content direction property.
562   DALI_TEST_EQUALS( (FlexContainer::ContentDirection)flexContainer.GetProperty<int>( FlexContainer::Property::CONTENT_DIRECTION ), FlexContainer::INHERIT, TEST_LOCATION );
563
564   actor0.SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT );
565   DALI_TEST_EQUALS( (FlexContainer::ContentDirection)flexContainer.GetProperty<int>( FlexContainer::Property::CONTENT_DIRECTION ), FlexContainer::RTL, TEST_LOCATION );
566
567   actor0.SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::LEFT_TO_RIGHT );
568   DALI_TEST_EQUALS( (FlexContainer::ContentDirection)flexContainer.GetProperty<int>( FlexContainer::Property::CONTENT_DIRECTION ), FlexContainer::LTR, TEST_LOCATION );
569
570   flexContainer.SetProperty( FlexContainer::Property::CONTENT_DIRECTION, "RTL" );
571   DALI_TEST_EQUALS( (FlexContainer::ContentDirection)flexContainer.GetProperty<int>( FlexContainer::Property::CONTENT_DIRECTION ), FlexContainer::RTL, TEST_LOCATION );
572
573   flexContainer.SetProperty( FlexContainer::Property::CONTENT_DIRECTION, "LTR" );
574   DALI_TEST_EQUALS( (FlexContainer::ContentDirection)flexContainer.GetProperty<int>( FlexContainer::Property::CONTENT_DIRECTION ), FlexContainer::LTR, TEST_LOCATION );
575
576   actor0.SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT );
577   DALI_TEST_EQUALS( (FlexContainer::ContentDirection)flexContainer.GetProperty<int>( FlexContainer::Property::CONTENT_DIRECTION ), FlexContainer::LTR, TEST_LOCATION );
578
579   flexContainer.SetProperty( FlexContainer::Property::CONTENT_DIRECTION, "inherit" );
580   DALI_TEST_EQUALS( (FlexContainer::ContentDirection)flexContainer.GetProperty<int>( FlexContainer::Property::CONTENT_DIRECTION ), FlexContainer::RTL, TEST_LOCATION );
581
582   actor0.SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::LEFT_TO_RIGHT );
583   DALI_TEST_EQUALS( (FlexContainer::ContentDirection)flexContainer.GetProperty<int>( FlexContainer::Property::CONTENT_DIRECTION ), FlexContainer::LTR, TEST_LOCATION );
584
585   flexContainer.SetProperty( FlexContainer::Property::CONTENT_DIRECTION, "inherit" );
586   DALI_TEST_EQUALS( (FlexContainer::ContentDirection)flexContainer.GetProperty<int>( FlexContainer::Property::CONTENT_DIRECTION ), FlexContainer::LTR, TEST_LOCATION );
587
588   flexContainer.SetProperty( FlexContainer::Property::CONTENT_DIRECTION, "LTR" );
589   application.SendNotification();
590   application.Render();
591
592   flexContainer.SetProperty( FlexContainer::Property::CONTENT_DIRECTION, "RTL" );
593   application.SendNotification();
594   application.Render();
595
596   END_TEST;
597 }