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>
23 #include <dali-toolkit/devel-api/controls/tool-bar/tool-bar.h>
26 using namespace Toolkit;
30 static bool gObjectCreatedCallBackCalled;
32 static void TestCallback(BaseHandle handle)
34 gObjectCreatedCallBackCalled = true;
38 void dali_toolbar_startup(void)
40 test_return_value = TET_UNDEF;
43 void dali_toolbar_cleanup(void)
45 test_return_value = TET_PASS;
49 int UtcDaliToolBarNew(void)
51 ToolkitTestApplication application;
52 tet_infoline(" UtcDaliToolBarNew");
56 DALI_TEST_CHECK( !toolbar );
58 toolbar = ToolBar::New();
60 DALI_TEST_CHECK( toolbar );
62 ToolBar toolbar2(toolbar);
64 DALI_TEST_CHECK( toolbar2 == toolbar );
66 //Additional check to ensure object is created by checking if it's registered
67 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
68 DALI_TEST_CHECK( registry );
70 gObjectCreatedCallBackCalled = false;
71 registry.ObjectCreatedSignal().Connect(&TestCallback);
73 ToolBar toolbar = ToolBar::New();
75 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
77 Actor actor = toolbar;
78 toolbar == ToolBar::DownCast( actor );
80 DALI_TEST_CHECK( toolbar );
84 int UtcDaliToolBarSetBackground(void)
86 ToolkitTestApplication application;
87 tet_infoline(" UtcDaliToolBarSetBackground");
91 ImageActor toolBarBackground = CreateSolidColorActor( Color::RED );
93 ToolBar toolbar = ToolBar::New();
94 toolbar.SetBackground( toolBarBackground );
96 Stage::GetCurrent().Add( toolbar );
100 tet_result(TET_FAIL);
103 tet_result(TET_PASS);
105 application.SendNotification(); // VCC To be removed!!
106 application.Render(); // VCC To be removed!!
110 int UtcDaliToolBarAddControl01(void)
112 ToolkitTestApplication application;
113 tet_infoline(" UtcDaliToolBarAddControl01");
117 ImageActor control1 = CreateSolidColorActor( Color::RED );
118 control1.SetSize( Vector2( 100.f, 100.f ) );
119 ImageActor control2 = CreateSolidColorActor( Color::RED );
120 control2.SetSize( Vector2( 100.f, 100.f ) );
121 ImageActor control3 = CreateSolidColorActor( Color::RED );
122 control3.SetSize( Vector2( 100.f, 100.f ) );
123 ImageActor control4 = CreateSolidColorActor( Color::RED );
124 control4.SetSize( Vector2( 100.f, 100.f ) );
125 ImageActor control5 = CreateSolidColorActor( Color::RED );
126 control5.SetSize( Vector2( 100.f, 100.f ) );
128 ToolBar toolbar = ToolBar::New();
129 toolbar.SetSize( Vector2( 600.f, 100.f ) );
131 application.Render();
132 application.SendNotification();
133 application.Render();
134 application.SendNotification();
136 toolbar.Add( control1 );
137 toolbar.AddControl( control2, 0.1f, Alignment::HorizontalLeft, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
138 toolbar.AddControl( control3, 0.1f, Alignment::HorizontalCenter, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
139 toolbar.AddControl( control4, 0.1f, Alignment::HorizontalCenter, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
140 toolbar.AddControl( control5, 0.1f, Alignment::HorizontalRight, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
142 ImageActor control6 = CreateSolidColorActor( Color::RED );
143 control6.SetSize( Vector2( 100.f, 100.f ) );
144 ImageActor control7 = CreateSolidColorActor( Color::RED );
145 control7.SetSize( Vector2( 100.f, 100.f ) );
146 ImageActor control8 = CreateSolidColorActor( Color::RED );
147 control8.SetSize( Vector2( 100.f, 100.f ) );
149 application.Render();
150 application.SendNotification();
151 application.Render();
152 application.SendNotification();
154 toolbar.AddControl( control6, 0.4f, Alignment::HorizontalLeft, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
155 toolbar.AddControl( control7, 0.2f, Alignment::HorizontalCenter, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
156 toolbar.AddControl( control8, 0.2f, Alignment::HorizontalRight, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
160 tet_result(TET_FAIL);
163 tet_result(TET_PASS);
167 int UtcDaliToolBarAddControl02(void)
169 ToolkitTestApplication application;
170 tet_infoline(" UtcDaliToolBarAddControl02");
172 bool daliAssert = false;
176 ImageActor control = CreateSolidColorActor( Color::RED );
178 ToolBar toolbar = ToolBar::New();
180 toolbar.AddControl( control, 0.1f, static_cast<Alignment::Type>( 99 ), Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
182 catch( DaliException e )
185 tet_result(TET_PASS);
189 tet_result(TET_FAIL);
194 tet_result(TET_FAIL);
199 int UtcDaliToolBarRemoveControl01(void)
201 ToolkitTestApplication application;
202 tet_infoline(" UtcDaliToolBarRemoveControl01");
206 ImageActor control = CreateSolidColorActor( Color::RED );
208 ToolBar toolbar = ToolBar::New();
209 toolbar.AddControl( control, 0.1f, Alignment::HorizontalLeft );
211 toolbar.RemoveControl( control );
215 tet_result(TET_FAIL);
218 tet_result(TET_PASS);
222 int UtcDaliToolBarRemoveControl02(void)
224 ToolkitTestApplication application;
225 tet_infoline(" UtcDaliToolBarRemoveControl02");
229 ImageActor control01 = CreateSolidColorActor( Color::RED );
230 ImageActor control02 = CreateSolidColorActor( Color::RED );
232 ToolBar toolbar01 = ToolBar::New();
233 ToolBar toolbar02 = ToolBar::New();
234 toolbar01.AddControl( control01, 0.1f, Alignment::HorizontalLeft );
235 toolbar02.AddControl( control02, 0.1f, Alignment::HorizontalLeft );
237 toolbar02.RemoveControl( control01 );
239 catch( Dali::DaliException& e )
241 DALI_TEST_PRINT_ASSERT( e );
242 DALI_TEST_EQUALS(e.condition, "false", TEST_LOCATION);
246 tet_result(TET_FAIL);
251 ImageActor control = CreateSolidColorActor( Color::RED );
253 ToolBar toolbar = ToolBar::New();
254 toolbar.AddControl( control, 0.1f, Alignment::HorizontalLeft );
256 toolbar.RemoveControl( control );
257 toolbar.RemoveControl( control );
261 tet_result(TET_FAIL);
264 tet_result(TET_PASS);