2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
22 #include <dali/integration-api/events/touch-event-integ.h>
23 #include <dali/dali.h>
24 #include <dali-toolkit/dali-toolkit.h>
25 #include <dali-toolkit-test-suite-utils.h>
28 using namespace Toolkit;
30 static void Startup();
31 static void Cleanup();
35 static bool gObjectCreatedCallBackCalled;
37 static void TestCallback(BaseHandle handle)
39 gObjectCreatedCallBackCalled = true;
44 void (*tet_startup)() = Startup;
45 void (*tet_cleanup)() = Cleanup;
49 POSITIVE_TC_IDX = 0x01,
53 #define MAX_NUMBER_OF_TESTS 10000
55 struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
58 // Add test functionality for all APIs in the class (Positive and Negative)
59 TEST_FUNCTION( UtcDaliToolBarNew, POSITIVE_TC_IDX );
60 TEST_FUNCTION( UtcDaliToolBarSetBackground, POSITIVE_TC_IDX );
61 TEST_FUNCTION( UtcDaliToolBarAddControl01, POSITIVE_TC_IDX );
62 TEST_FUNCTION( UtcDaliToolBarAddControl02, NEGATIVE_TC_IDX );
63 TEST_FUNCTION( UtcDaliToolBarRemoveControl01, POSITIVE_TC_IDX );
64 TEST_FUNCTION( UtcDaliToolBarRemoveControl02, NEGATIVE_TC_IDX );
66 // Called only once before first test is run.
71 // Called only once after last test is run
77 static void UtcDaliToolBarNew()
79 ToolkitTestApplication application;
80 tet_infoline(" UtcDaliToolBarNew");
84 DALI_TEST_CHECK( !toolbar );
86 toolbar = ToolBar::New();
88 DALI_TEST_CHECK( toolbar );
90 ToolBar toolbar2(toolbar);
92 DALI_TEST_CHECK( toolbar2 == toolbar );
94 //Additional check to ensure object is created by checking if it's registered
95 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
96 DALI_TEST_CHECK( registry );
98 gObjectCreatedCallBackCalled = false;
99 registry.ObjectCreatedSignal().Connect(&TestCallback);
101 ToolBar toolbar = ToolBar::New();
103 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
105 Actor actor = toolbar;
106 toolbar == ToolBar::DownCast( actor );
108 DALI_TEST_CHECK( toolbar );
111 static void UtcDaliToolBarSetBackground()
113 ToolkitTestApplication application;
114 tet_infoline(" UtcDaliToolBarSetBackground");
118 ImageActor toolBarBackground = CreateSolidColorActor( Color::RED );
120 ToolBar toolbar = ToolBar::New();
121 toolbar.SetBackground( toolBarBackground );
123 Stage::GetCurrent().Add( toolbar );
127 tet_result(TET_FAIL);
130 tet_result(TET_PASS);
132 application.SendNotification(); // VCC To be removed!!
133 application.Render(); // VCC To be removed!!
136 static void UtcDaliToolBarAddControl01()
138 ToolkitTestApplication application;
139 tet_infoline(" UtcDaliToolBarAddControl01");
143 ImageActor control1 = CreateSolidColorActor( Color::RED );
144 control1.SetSize( 100.f, 100.f );
145 ImageActor control2 = CreateSolidColorActor( Color::RED );
146 control2.SetSize( 100.f, 100.f );
147 ImageActor control3 = CreateSolidColorActor( Color::RED );
148 control3.SetSize( 100.f, 100.f );
149 ImageActor control4 = CreateSolidColorActor( Color::RED );
150 control4.SetSize( 100.f, 100.f );
151 ImageActor control5 = CreateSolidColorActor( Color::RED );
152 control5.SetSize( 100.f, 100.f );
154 ToolBar toolbar = ToolBar::New();
155 toolbar.SetSize( 600.f, 100.f );
157 application.Render();
158 application.SendNotification();
159 application.Render();
160 application.SendNotification();
162 toolbar.Add( control1 );
163 toolbar.AddControl( control2, 0.1f, Alignment::HorizontalLeft, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
164 toolbar.AddControl( control3, 0.1f, Alignment::HorizontalCenter, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
165 toolbar.AddControl( control4, 0.1f, Alignment::HorizontalCenter, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
166 toolbar.AddControl( control5, 0.1f, Alignment::HorizontalRight, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
168 ImageActor control6 = CreateSolidColorActor( Color::RED );
169 control6.SetSize( 100.f, 100.f );
170 ImageActor control7 = CreateSolidColorActor( Color::RED );
171 control7.SetSize( 100.f, 100.f );
172 ImageActor control8 = CreateSolidColorActor( Color::RED );
173 control8.SetSize( 100.f, 100.f );
175 application.Render();
176 application.SendNotification();
177 application.Render();
178 application.SendNotification();
180 toolbar.AddControl( control6, 0.4f, Alignment::HorizontalLeft, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
181 toolbar.AddControl( control7, 0.2f, Alignment::HorizontalCenter, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
182 toolbar.AddControl( control8, 0.2f, Alignment::HorizontalRight, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
186 tet_result(TET_FAIL);
189 tet_result(TET_PASS);
192 static void UtcDaliToolBarAddControl02()
194 ToolkitTestApplication application;
195 tet_infoline(" UtcDaliToolBarAddControl02");
197 bool daliAssert = false;
201 ImageActor control = CreateSolidColorActor( Color::RED );
203 ToolBar toolbar = ToolBar::New();
205 toolbar.AddControl( control, 0.1f, static_cast<Alignment::Type>( 99 ), Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
207 catch( DaliException e )
210 tet_result(TET_PASS);
214 tet_result(TET_FAIL);
219 tet_result(TET_FAIL);
223 static void UtcDaliToolBarRemoveControl01()
225 ToolkitTestApplication application;
226 tet_infoline(" UtcDaliToolBarRemoveControl01");
230 ImageActor control = CreateSolidColorActor( Color::RED );
232 ToolBar toolbar = ToolBar::New();
233 toolbar.AddControl( control, 0.1f, Alignment::HorizontalLeft );
235 toolbar.RemoveControl( control );
239 tet_result(TET_FAIL);
242 tet_result(TET_PASS);
245 static void UtcDaliToolBarRemoveControl02()
247 ToolkitTestApplication application;
248 tet_infoline(" UtcDaliToolBarRemoveControl02");
252 ImageActor control01 = CreateSolidColorActor( Color::RED );
253 ImageActor control02 = CreateSolidColorActor( Color::RED );
255 ToolBar toolbar01 = ToolBar::New();
256 ToolBar toolbar02 = ToolBar::New();
257 toolbar01.AddControl( control01, 0.1f, Alignment::HorizontalLeft );
258 toolbar02.AddControl( control02, 0.1f, Alignment::HorizontalLeft );
260 toolbar02.RemoveControl( control01 );
262 catch( Dali::DaliException& e )
264 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
265 DALI_TEST_EQUALS(e.mCondition, "false", TEST_LOCATION);
269 tet_result(TET_FAIL);
274 ImageActor control = CreateSolidColorActor( Color::RED );
276 ToolBar toolbar = ToolBar::New();
277 toolbar.AddControl( control, 0.1f, Alignment::HorizontalLeft );
279 toolbar.RemoveControl( control );
280 toolbar.RemoveControl( control );
284 tet_result(TET_FAIL);
287 tet_result(TET_PASS);