+
+int UtcDaliLayouting_SetLayoutOrder02(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliLayouting_SetLayoutOrder02 - Test the layout item order and the control order");
+
+ Stage stage = Stage::GetCurrent();
+
+ auto rootControl = Control::New();
+ auto absoluteLayout = AbsoluteLayout::New();
+ DevelControl::SetLayout( rootControl, absoluteLayout );
+ rootControl.SetName( "AbsoluteLayout" );
+ stage.Add( rootControl );
+
+ auto hbox = Control::New();
+ auto hboxLayout = LinearLayout::New();
+ hbox.SetName( "HBox");
+
+ rootControl.Add( hbox );
+
+ DevelControl::SetLayout( hbox, hboxLayout );
+
+ // Add child controls
+ std::vector< Control > controls;
+ controls.push_back( CreateLeafControl( 100, 100 ) ); // 0
+ controls.push_back( CreateLeafControl( 100, 100 ) ); // 1
+ controls.push_back( CreateLeafControl( 100, 100 ) ); // 2
+
+ for( auto&& iter : controls )
+ {
+ hbox.Add( iter );
+ }
+
+ // Ensure layouting happens
+ application.SendNotification();
+ application.Render();
+
+ TestLayoutItemOrder( controls, hboxLayout );
+
+ tet_infoline("RaiseToTop");
+
+ controls[0].RaiseToTop(); // 1 2 0
+
+ TestLayoutItemOrder( controls, hboxLayout );
+
+ tet_infoline("LowerToBottom");
+
+ controls[2].LowerToBottom(); // 2 1 0
+
+ TestLayoutItemOrder( controls, hboxLayout );
+
+ tet_infoline("Remove / Add");
+
+ hbox.Remove( controls[2] ); // 1 0
+ hbox.Add( controls[2] ); // 1 0 2
+
+ TestLayoutItemOrder( controls, hboxLayout );
+
+ tet_infoline("SetLayout");
+
+ auto vboxLayout = LinearLayout::New();
+ DevelControl::SetLayout( controls[0], vboxLayout );
+
+ TestLayoutItemOrder( controls, hboxLayout );
+
+ tet_infoline("Raise");
+
+ controls[0].Raise(); // 1 2 0
+
+ TestLayoutItemOrder( controls, hboxLayout );
+
+ tet_infoline("Lower");
+
+ controls[2].Lower(); // 2 1 0
+
+ TestLayoutItemOrder( controls, hboxLayout );
+
+ tet_infoline("SetLayout again");
+
+ auto vboxLayout1 = LinearLayout::New();
+ DevelControl::SetLayout( controls[2], vboxLayout1 );
+
+ TestLayoutItemOrder( controls, hboxLayout );
+
+ DevelControl::SetLayout( controls[2], vboxLayout );
+
+ END_TEST;
+}