2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <dali-toolkit/dali-toolkit.h>
22 #include <dali/integration-api/events/touch-event-integ.h>
25 using namespace Toolkit;
29 static bool gObjectCreatedCallBackCalled;
31 static void TestCallback(BaseHandle handle)
33 gObjectCreatedCallBackCalled = true;
37 void dali_toolbar_startup(void)
39 test_return_value = TET_UNDEF;
42 void dali_toolbar_cleanup(void)
44 test_return_value = TET_PASS;
48 int UtcDaliToolBarNew(void)
50 ToolkitTestApplication application;
51 tet_infoline(" UtcDaliToolBarNew");
55 DALI_TEST_CHECK( !toolbar );
57 toolbar = ToolBar::New();
59 DALI_TEST_CHECK( toolbar );
61 ToolBar toolbar2(toolbar);
63 DALI_TEST_CHECK( toolbar2 == toolbar );
65 //Additional check to ensure object is created by checking if it's registered
66 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
67 DALI_TEST_CHECK( registry );
69 gObjectCreatedCallBackCalled = false;
70 registry.ObjectCreatedSignal().Connect(&TestCallback);
72 ToolBar toolbar = ToolBar::New();
74 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
76 Actor actor = toolbar;
77 toolbar == ToolBar::DownCast( actor );
79 DALI_TEST_CHECK( toolbar );
83 int UtcDaliToolBarSetBackground(void)
85 ToolkitTestApplication application;
86 tet_infoline(" UtcDaliToolBarSetBackground");
90 ImageActor toolBarBackground = CreateSolidColorActor( Color::RED );
92 ToolBar toolbar = ToolBar::New();
93 toolbar.SetBackground( toolBarBackground );
95 Stage::GetCurrent().Add( toolbar );
102 tet_result(TET_PASS);
104 application.SendNotification(); // VCC To be removed!!
105 application.Render(); // VCC To be removed!!
109 int UtcDaliToolBarAddControl01(void)
111 ToolkitTestApplication application;
112 tet_infoline(" UtcDaliToolBarAddControl01");
116 ImageActor control1 = CreateSolidColorActor( Color::RED );
117 control1.SetPreferredSize( Vector2( 100.f, 100.f ) );
118 control1.SetResizePolicy( FIXED, ALL_DIMENSIONS );
119 ImageActor control2 = CreateSolidColorActor( Color::RED );
120 control2.SetPreferredSize( Vector2( 100.f, 100.f ) );
121 control2.SetResizePolicy( FIXED, ALL_DIMENSIONS );
122 ImageActor control3 = CreateSolidColorActor( Color::RED );
123 control3.SetPreferredSize( Vector2( 100.f, 100.f ) );
124 control3.SetResizePolicy( FIXED, ALL_DIMENSIONS );
125 ImageActor control4 = CreateSolidColorActor( Color::RED );
126 control4.SetPreferredSize( Vector2( 100.f, 100.f ) );
127 control4.SetResizePolicy( FIXED, ALL_DIMENSIONS );
128 ImageActor control5 = CreateSolidColorActor( Color::RED );
129 control5.SetPreferredSize( Vector2( 100.f, 100.f ) );
130 control5.SetResizePolicy( FIXED, ALL_DIMENSIONS );
132 ToolBar toolbar = ToolBar::New();
133 toolbar.SetPreferredSize( Vector2( 600.f, 100.f ) );
135 application.Render();
136 application.SendNotification();
137 application.Render();
138 application.SendNotification();
140 toolbar.Add( control1 );
141 toolbar.AddControl( control2, 0.1f, Alignment::HorizontalLeft, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
142 toolbar.AddControl( control3, 0.1f, Alignment::HorizontalCenter, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
143 toolbar.AddControl( control4, 0.1f, Alignment::HorizontalCenter, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
144 toolbar.AddControl( control5, 0.1f, Alignment::HorizontalRight, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
146 ImageActor control6 = CreateSolidColorActor( Color::RED );
147 control6.SetPreferredSize( Vector2( 100.f, 100.f ) );
148 control6.SetResizePolicy( FIXED, ALL_DIMENSIONS );
149 ImageActor control7 = CreateSolidColorActor( Color::RED );
150 control7.SetPreferredSize( Vector2( 100.f, 100.f ) );
151 control7.SetResizePolicy( FIXED, ALL_DIMENSIONS );
152 ImageActor control8 = CreateSolidColorActor( Color::RED );
153 control8.SetPreferredSize( Vector2( 100.f, 100.f ) );
154 control8.SetResizePolicy( FIXED, ALL_DIMENSIONS );
156 application.Render();
157 application.SendNotification();
158 application.Render();
159 application.SendNotification();
161 toolbar.AddControl( control6, 0.4f, Alignment::HorizontalLeft, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
162 toolbar.AddControl( control7, 0.2f, Alignment::HorizontalCenter, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
163 toolbar.AddControl( control8, 0.2f, Alignment::HorizontalRight, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
167 tet_result(TET_FAIL);
170 tet_result(TET_PASS);
174 int UtcDaliToolBarAddControl02(void)
176 ToolkitTestApplication application;
177 tet_infoline(" UtcDaliToolBarAddControl02");
179 bool daliAssert = false;
183 ImageActor control = CreateSolidColorActor( Color::RED );
185 ToolBar toolbar = ToolBar::New();
187 toolbar.AddControl( control, 0.1f, static_cast<Alignment::Type>( 99 ), Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
189 catch( DaliException e )
192 tet_result(TET_PASS);
196 tet_result(TET_FAIL);
201 tet_result(TET_FAIL);
206 int UtcDaliToolBarRemoveControl01(void)
208 ToolkitTestApplication application;
209 tet_infoline(" UtcDaliToolBarRemoveControl01");
213 ImageActor control = CreateSolidColorActor( Color::RED );
215 ToolBar toolbar = ToolBar::New();
216 toolbar.AddControl( control, 0.1f, Alignment::HorizontalLeft );
218 toolbar.RemoveControl( control );
222 tet_result(TET_FAIL);
225 tet_result(TET_PASS);
229 int UtcDaliToolBarRemoveControl02(void)
231 ToolkitTestApplication application;
232 tet_infoline(" UtcDaliToolBarRemoveControl02");
236 ImageActor control01 = CreateSolidColorActor( Color::RED );
237 ImageActor control02 = CreateSolidColorActor( Color::RED );
239 ToolBar toolbar01 = ToolBar::New();
240 ToolBar toolbar02 = ToolBar::New();
241 toolbar01.AddControl( control01, 0.1f, Alignment::HorizontalLeft );
242 toolbar02.AddControl( control02, 0.1f, Alignment::HorizontalLeft );
244 toolbar02.RemoveControl( control01 );
246 catch( Dali::DaliException& e )
248 DALI_TEST_PRINT_ASSERT( e );
249 DALI_TEST_EQUALS(e.condition, "false", TEST_LOCATION);
253 tet_result(TET_FAIL);
258 ImageActor control = CreateSolidColorActor( Color::RED );
260 ToolBar toolbar = ToolBar::New();
261 toolbar.AddControl( control, 0.1f, Alignment::HorizontalLeft );
263 toolbar.RemoveControl( control );
264 toolbar.RemoveControl( control );
268 tet_result(TET_FAIL);
271 tet_result(TET_PASS);