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.
23 #include <dali/integration-api/events/touch-event-integ.h>
24 #include <dali/dali.h>
25 #include <dali-toolkit/dali-toolkit.h>
26 #include <dali-toolkit-test-suite-utils.h>
29 using namespace Toolkit;
31 static void Startup();
32 static void Cleanup();
36 static bool gObjectCreatedCallBackCalled;
38 static void TestCallback(BaseHandle handle)
40 gObjectCreatedCallBackCalled = true;
45 void (*tet_startup)() = Startup;
46 void (*tet_cleanup)() = Cleanup;
50 POSITIVE_TC_IDX = 0x01,
54 #define MAX_NUMBER_OF_TESTS 10000
56 struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
59 // Add test functionality for all APIs in the class (Positive and Negative)
60 TEST_FUNCTION( UtcDaliToolBarNew, POSITIVE_TC_IDX );
61 TEST_FUNCTION( UtcDaliToolBarSetBackground, POSITIVE_TC_IDX );
62 TEST_FUNCTION( UtcDaliToolBarAddControl01, POSITIVE_TC_IDX );
63 TEST_FUNCTION( UtcDaliToolBarAddControl02, NEGATIVE_TC_IDX );
64 TEST_FUNCTION( UtcDaliToolBarRemoveControl01, POSITIVE_TC_IDX );
65 TEST_FUNCTION( UtcDaliToolBarRemoveControl02, NEGATIVE_TC_IDX );
67 // Called only once before first test is run.
72 // Called only once after last test is run
78 static void UtcDaliToolBarNew()
80 ToolkitTestApplication application;
81 tet_infoline(" UtcDaliToolBarNew");
85 DALI_TEST_CHECK( !toolbar );
87 toolbar = ToolBar::New();
89 DALI_TEST_CHECK( toolbar );
91 ToolBar toolbar2(toolbar);
93 DALI_TEST_CHECK( toolbar2 == toolbar );
95 //Additional check to ensure object is created by checking if it's registered
96 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
97 DALI_TEST_CHECK( registry );
99 gObjectCreatedCallBackCalled = false;
100 registry.ObjectCreatedSignal().Connect(&TestCallback);
102 ToolBar toolbar = ToolBar::New();
104 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
106 Actor actor = toolbar;
107 toolbar == ToolBar::DownCast( actor );
109 DALI_TEST_CHECK( toolbar );
112 static void UtcDaliToolBarSetBackground()
114 ToolkitTestApplication application;
115 tet_infoline(" UtcDaliToolBarSetBackground");
119 ImageActor toolBarBackground = CreateSolidColorActor( Color::RED );
121 ToolBar toolbar = ToolBar::New();
122 toolbar.SetBackground( toolBarBackground );
124 Stage::GetCurrent().Add( toolbar );
128 tet_result(TET_FAIL);
131 tet_result(TET_PASS);
133 application.SendNotification(); // VCC To be removed!!
134 application.Render(); // VCC To be removed!!
137 static void UtcDaliToolBarAddControl01()
139 ToolkitTestApplication application;
140 tet_infoline(" UtcDaliToolBarAddControl01");
144 ImageActor control1 = CreateSolidColorActor( Color::RED );
145 control1.SetSize( 100.f, 100.f );
146 ImageActor control2 = CreateSolidColorActor( Color::RED );
147 control2.SetSize( 100.f, 100.f );
148 ImageActor control3 = CreateSolidColorActor( Color::RED );
149 control3.SetSize( 100.f, 100.f );
150 ImageActor control4 = CreateSolidColorActor( Color::RED );
151 control4.SetSize( 100.f, 100.f );
152 ImageActor control5 = CreateSolidColorActor( Color::RED );
153 control5.SetSize( 100.f, 100.f );
155 ToolBar toolbar = ToolBar::New();
156 toolbar.SetSize( 600.f, 100.f );
158 application.Render();
159 application.SendNotification();
160 application.Render();
161 application.SendNotification();
163 toolbar.Add( control1 );
164 toolbar.AddControl( control2, 0.1f, Alignment::HorizontalLeft, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
165 toolbar.AddControl( control3, 0.1f, Alignment::HorizontalCenter, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
166 toolbar.AddControl( control4, 0.1f, Alignment::HorizontalCenter, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
167 toolbar.AddControl( control5, 0.1f, Alignment::HorizontalRight, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
169 ImageActor control6 = CreateSolidColorActor( Color::RED );
170 control6.SetSize( 100.f, 100.f );
171 ImageActor control7 = CreateSolidColorActor( Color::RED );
172 control7.SetSize( 100.f, 100.f );
173 ImageActor control8 = CreateSolidColorActor( Color::RED );
174 control8.SetSize( 100.f, 100.f );
176 application.Render();
177 application.SendNotification();
178 application.Render();
179 application.SendNotification();
181 toolbar.AddControl( control6, 0.4f, Alignment::HorizontalLeft, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
182 toolbar.AddControl( control7, 0.2f, Alignment::HorizontalCenter, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
183 toolbar.AddControl( control8, 0.2f, Alignment::HorizontalRight, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
187 tet_result(TET_FAIL);
190 tet_result(TET_PASS);
193 static void UtcDaliToolBarAddControl02()
195 ToolkitTestApplication application;
196 tet_infoline(" UtcDaliToolBarAddControl02");
198 bool daliAssert = false;
202 ImageActor control = CreateSolidColorActor( Color::RED );
204 ToolBar toolbar = ToolBar::New();
206 toolbar.AddControl( control, 0.1f, static_cast<Alignment::Type>( 99 ), Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
208 catch( DaliException e )
211 tet_result(TET_PASS);
215 tet_result(TET_FAIL);
220 tet_result(TET_FAIL);
224 static void UtcDaliToolBarRemoveControl01()
226 ToolkitTestApplication application;
227 tet_infoline(" UtcDaliToolBarRemoveControl01");
231 ImageActor control = CreateSolidColorActor( Color::RED );
233 ToolBar toolbar = ToolBar::New();
234 toolbar.AddControl( control, 0.1f, Alignment::HorizontalLeft );
236 toolbar.RemoveControl( control );
240 tet_result(TET_FAIL);
243 tet_result(TET_PASS);
246 static void UtcDaliToolBarRemoveControl02()
248 ToolkitTestApplication application;
249 tet_infoline(" UtcDaliToolBarRemoveControl02");
253 ImageActor control01 = CreateSolidColorActor( Color::RED );
254 ImageActor control02 = CreateSolidColorActor( Color::RED );
256 ToolBar toolbar01 = ToolBar::New();
257 ToolBar toolbar02 = ToolBar::New();
258 toolbar01.AddControl( control01, 0.1f, Alignment::HorizontalLeft );
259 toolbar02.AddControl( control02, 0.1f, Alignment::HorizontalLeft );
261 toolbar02.RemoveControl( control01 );
263 catch( Dali::DaliException& e )
265 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
266 DALI_TEST_EQUALS(e.mCondition, "false", TEST_LOCATION);
270 tet_result(TET_FAIL);
275 ImageActor control = CreateSolidColorActor( Color::RED );
277 ToolBar toolbar = ToolBar::New();
278 toolbar.AddControl( control, 0.1f, Alignment::HorizontalLeft );
280 toolbar.RemoveControl( control );
281 toolbar.RemoveControl( control );
285 tet_result(TET_FAIL);
288 tet_result(TET_PASS);