Dali 3D User Interface Engine
utc-Dali-ToolBar.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #include <iostream>
19 #include <stdlib.h>
24 
25 using namespace Dali;
26 using namespace Toolkit;
27 
28 namespace
29 {
31 
32 static void TestCallback(BaseHandle handle)
33 {
34  gObjectCreatedCallBackCalled = true;
35 }
36 } // namespace
37 
39 {
41 }
42 
44 {
46 }
47 
48 
50 {
51  ToolkitTestApplication application;
52  tet_infoline(" UtcDaliToolBarNew");
53 
54  ToolBar toolbar;
55 
56  DALI_TEST_CHECK( !toolbar );
57 
58  toolbar = ToolBar::New();
59 
60  DALI_TEST_CHECK( toolbar );
61 
62  ToolBar toolbar2(toolbar);
63 
64  DALI_TEST_CHECK( toolbar2 == toolbar );
65 
66  //Additional check to ensure object is created by checking if it's registered
68  DALI_TEST_CHECK( registry );
69 
71  registry.ObjectCreatedSignal().Connect(&TestCallback);
72  {
73  ToolBar toolbar = ToolBar::New();
74  }
76 
77  Actor actor = toolbar;
78  toolbar == ToolBar::DownCast( actor );
79 
80  DALI_TEST_CHECK( toolbar );
81  END_TEST;
82 }
83 
85 {
86  ToolkitTestApplication application;
87  tet_infoline(" UtcDaliToolBarAddControl01");
88 
89  try
90  {
92  control1.SetSize( Vector2( 100.f, 100.f ) );
94  control2.SetSize( Vector2( 100.f, 100.f ) );
96  control3.SetSize( Vector2( 100.f, 100.f ) );
98  control4.SetSize( Vector2( 100.f, 100.f ) );
100  control5.SetSize( Vector2( 100.f, 100.f ) );
101 
102  ToolBar toolbar = ToolBar::New();
103  toolbar.SetSize( Vector2( 600.f, 100.f ) );
104 
105  application.Render();
106  application.SendNotification();
107  application.Render();
108  application.SendNotification();
109 
110  toolbar.Add( control1 );
111  toolbar.AddControl( control2, 0.1f, Alignment::HorizontalLeft, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
112  toolbar.AddControl( control3, 0.1f, Alignment::HorizontalCenter, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
113  toolbar.AddControl( control4, 0.1f, Alignment::HorizontalCenter, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
114  toolbar.AddControl( control5, 0.1f, Alignment::HorizontalRight, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
115 
117  control6.SetSize( Vector2( 100.f, 100.f ) );
119  control7.SetSize( Vector2( 100.f, 100.f ) );
121  control8.SetSize( Vector2( 100.f, 100.f ) );
122 
123  application.Render();
124  application.SendNotification();
125  application.Render();
126  application.SendNotification();
127 
128  toolbar.AddControl( control6, 0.4f, Alignment::HorizontalLeft, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
129  toolbar.AddControl( control7, 0.2f, Alignment::HorizontalCenter, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
130  toolbar.AddControl( control8, 0.2f, Alignment::HorizontalRight, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
131  }
132  catch( ... )
133  {
135  }
136 
138  END_TEST;
139 }
140 
142 {
143  ToolkitTestApplication application;
144  tet_infoline(" UtcDaliToolBarAddControl02");
145 
146  bool daliAssert = false;
147 
148  try
149  {
151 
152  ToolBar toolbar = ToolBar::New();
153 
154  toolbar.AddControl( control, 0.1f, static_cast<Alignment::Type>( 99 ), Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
155  }
156  catch( DaliException e )
157  {
158  daliAssert = true;
160  }
161  catch( ... )
162  {
164  }
165 
166  if( !daliAssert )
167  {
169  }
170  END_TEST;
171 }
172 
174 {
175  ToolkitTestApplication application;
176  tet_infoline(" UtcDaliToolBarRemoveControl01");
177 
178  try
179  {
181 
182  ToolBar toolbar = ToolBar::New();
183  toolbar.AddControl( control, 0.1f, Alignment::HorizontalLeft );
184 
185  toolbar.RemoveControl( control );
186  }
187  catch( ... )
188  {
190  }
191 
193  END_TEST;
194 }
195 
197 {
198  ToolkitTestApplication application;
199  tet_infoline(" UtcDaliToolBarRemoveControl02");
200 
201  try
202  {
205 
206  ToolBar toolbar01 = ToolBar::New();
207  ToolBar toolbar02 = ToolBar::New();
208  toolbar01.AddControl( control01, 0.1f, Alignment::HorizontalLeft );
209  toolbar02.AddControl( control02, 0.1f, Alignment::HorizontalLeft );
210 
211  toolbar02.RemoveControl( control01 );
212  }
213  catch( Dali::DaliException& e )
214  {
217  }
218  catch( ... )
219  {
221  }
222 
223  try
224  {
226 
227  ToolBar toolbar = ToolBar::New();
228  toolbar.AddControl( control, 0.1f, Alignment::HorizontalLeft );
229 
230  toolbar.RemoveControl( control );
231  toolbar.RemoveControl( control );
232  }
233  catch( ... )
234  {
236  }
237 
239  END_TEST;
240 }
Dali Docs Home
Read more about Dali