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.SetSize( 100.f, 100.f );
118 ImageActor control2 = CreateSolidColorActor( Color::RED );
119 control2.SetSize( 100.f, 100.f );
120 ImageActor control3 = CreateSolidColorActor( Color::RED );
121 control3.SetSize( 100.f, 100.f );
122 ImageActor control4 = CreateSolidColorActor( Color::RED );
123 control4.SetSize( 100.f, 100.f );
124 ImageActor control5 = CreateSolidColorActor( Color::RED );
125 control5.SetSize( 100.f, 100.f );
127 ToolBar toolbar = ToolBar::New();
128 toolbar.SetSize( 600.f, 100.f );
130 application.Render();
131 application.SendNotification();
132 application.Render();
133 application.SendNotification();
135 toolbar.Add( control1 );
136 toolbar.AddControl( control2, 0.1f, Alignment::HorizontalLeft, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
137 toolbar.AddControl( control3, 0.1f, Alignment::HorizontalCenter, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
138 toolbar.AddControl( control4, 0.1f, Alignment::HorizontalCenter, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
139 toolbar.AddControl( control5, 0.1f, Alignment::HorizontalRight, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
141 ImageActor control6 = CreateSolidColorActor( Color::RED );
142 control6.SetSize( 100.f, 100.f );
143 ImageActor control7 = CreateSolidColorActor( Color::RED );
144 control7.SetSize( 100.f, 100.f );
145 ImageActor control8 = CreateSolidColorActor( Color::RED );
146 control8.SetSize( 100.f, 100.f );
148 application.Render();
149 application.SendNotification();
150 application.Render();
151 application.SendNotification();
153 toolbar.AddControl( control6, 0.4f, Alignment::HorizontalLeft, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
154 toolbar.AddControl( control7, 0.2f, Alignment::HorizontalCenter, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
155 toolbar.AddControl( control8, 0.2f, Alignment::HorizontalRight, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
159 tet_result(TET_FAIL);
162 tet_result(TET_PASS);
166 int UtcDaliToolBarAddControl02(void)
168 ToolkitTestApplication application;
169 tet_infoline(" UtcDaliToolBarAddControl02");
171 bool daliAssert = false;
175 ImageActor control = CreateSolidColorActor( Color::RED );
177 ToolBar toolbar = ToolBar::New();
179 toolbar.AddControl( control, 0.1f, static_cast<Alignment::Type>( 99 ), Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
181 catch( DaliException e )
184 tet_result(TET_PASS);
188 tet_result(TET_FAIL);
193 tet_result(TET_FAIL);
198 int UtcDaliToolBarRemoveControl01(void)
200 ToolkitTestApplication application;
201 tet_infoline(" UtcDaliToolBarRemoveControl01");
205 ImageActor control = CreateSolidColorActor( Color::RED );
207 ToolBar toolbar = ToolBar::New();
208 toolbar.AddControl( control, 0.1f, Alignment::HorizontalLeft );
210 toolbar.RemoveControl( control );
214 tet_result(TET_FAIL);
217 tet_result(TET_PASS);
221 int UtcDaliToolBarRemoveControl02(void)
223 ToolkitTestApplication application;
224 tet_infoline(" UtcDaliToolBarRemoveControl02");
228 ImageActor control01 = CreateSolidColorActor( Color::RED );
229 ImageActor control02 = CreateSolidColorActor( Color::RED );
231 ToolBar toolbar01 = ToolBar::New();
232 ToolBar toolbar02 = ToolBar::New();
233 toolbar01.AddControl( control01, 0.1f, Alignment::HorizontalLeft );
234 toolbar02.AddControl( control02, 0.1f, Alignment::HorizontalLeft );
236 toolbar02.RemoveControl( control01 );
238 catch( Dali::DaliException& e )
240 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
241 DALI_TEST_EQUALS(e.mCondition, "false", TEST_LOCATION);
245 tet_result(TET_FAIL);
250 ImageActor control = CreateSolidColorActor( Color::RED );
252 ToolBar toolbar = ToolBar::New();
253 toolbar.AddControl( control, 0.1f, Alignment::HorizontalLeft );
255 toolbar.RemoveControl( control );
256 toolbar.RemoveControl( control );
260 tet_result(TET_FAIL);
263 tet_result(TET_PASS);