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.
19 #include <dali-toolkit-test-suite-utils.h>
20 #include <dali-toolkit/dali-toolkit.h>
21 #include <dali/integration-api/events/touch-event-integ.h>
24 using namespace Toolkit;
28 static bool gObjectCreatedCallBackCalled;
30 static void TestCallback(BaseHandle handle)
32 gObjectCreatedCallBackCalled = true;
36 void dali_toolbar_startup(void)
38 test_return_value = TET_UNDEF;
41 void dali_toolbar_cleanup(void)
43 test_return_value = TET_PASS;
47 int UtcDaliToolBarNew(void)
49 ToolkitTestApplication application;
50 tet_infoline(" UtcDaliToolBarNew");
54 DALI_TEST_CHECK( !toolbar );
56 toolbar = ToolBar::New();
58 DALI_TEST_CHECK( toolbar );
60 ToolBar toolbar2(toolbar);
62 DALI_TEST_CHECK( toolbar2 == toolbar );
64 //Additional check to ensure object is created by checking if it's registered
65 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
66 DALI_TEST_CHECK( registry );
68 gObjectCreatedCallBackCalled = false;
69 registry.ObjectCreatedSignal().Connect(&TestCallback);
71 ToolBar toolbar = ToolBar::New();
73 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
75 Actor actor = toolbar;
76 toolbar == ToolBar::DownCast( actor );
78 DALI_TEST_CHECK( toolbar );
82 int UtcDaliToolBarSetBackground(void)
84 ToolkitTestApplication application;
85 tet_infoline(" UtcDaliToolBarSetBackground");
89 ImageActor toolBarBackground = CreateSolidColorActor( Color::RED );
91 ToolBar toolbar = ToolBar::New();
92 toolbar.SetBackground( toolBarBackground );
94 Stage::GetCurrent().Add( toolbar );
101 tet_result(TET_PASS);
103 application.SendNotification(); // VCC To be removed!!
104 application.Render(); // VCC To be removed!!
108 int UtcDaliToolBarAddControl01(void)
110 ToolkitTestApplication application;
111 tet_infoline(" UtcDaliToolBarAddControl01");
115 ImageActor control1 = CreateSolidColorActor( Color::RED );
116 control1.SetSize( 100.f, 100.f );
117 ImageActor control2 = CreateSolidColorActor( Color::RED );
118 control2.SetSize( 100.f, 100.f );
119 ImageActor control3 = CreateSolidColorActor( Color::RED );
120 control3.SetSize( 100.f, 100.f );
121 ImageActor control4 = CreateSolidColorActor( Color::RED );
122 control4.SetSize( 100.f, 100.f );
123 ImageActor control5 = CreateSolidColorActor( Color::RED );
124 control5.SetSize( 100.f, 100.f );
126 ToolBar toolbar = ToolBar::New();
127 toolbar.SetSize( 600.f, 100.f );
129 application.Render();
130 application.SendNotification();
131 application.Render();
132 application.SendNotification();
134 toolbar.Add( control1 );
135 toolbar.AddControl( control2, 0.1f, Alignment::HorizontalLeft, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
136 toolbar.AddControl( control3, 0.1f, Alignment::HorizontalCenter, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
137 toolbar.AddControl( control4, 0.1f, Alignment::HorizontalCenter, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
138 toolbar.AddControl( control5, 0.1f, Alignment::HorizontalRight, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
140 ImageActor control6 = CreateSolidColorActor( Color::RED );
141 control6.SetSize( 100.f, 100.f );
142 ImageActor control7 = CreateSolidColorActor( Color::RED );
143 control7.SetSize( 100.f, 100.f );
144 ImageActor control8 = CreateSolidColorActor( Color::RED );
145 control8.SetSize( 100.f, 100.f );
147 application.Render();
148 application.SendNotification();
149 application.Render();
150 application.SendNotification();
152 toolbar.AddControl( control6, 0.4f, Alignment::HorizontalLeft, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
153 toolbar.AddControl( control7, 0.2f, Alignment::HorizontalCenter, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
154 toolbar.AddControl( control8, 0.2f, Alignment::HorizontalRight, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
158 tet_result(TET_FAIL);
161 tet_result(TET_PASS);
165 int UtcDaliToolBarAddControl02(void)
167 ToolkitTestApplication application;
168 tet_infoline(" UtcDaliToolBarAddControl02");
170 bool daliAssert = false;
174 ImageActor control = CreateSolidColorActor( Color::RED );
176 ToolBar toolbar = ToolBar::New();
178 toolbar.AddControl( control, 0.1f, static_cast<Alignment::Type>( 99 ), Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
180 catch( DaliException e )
183 tet_result(TET_PASS);
187 tet_result(TET_FAIL);
192 tet_result(TET_FAIL);
197 int UtcDaliToolBarRemoveControl01(void)
199 ToolkitTestApplication application;
200 tet_infoline(" UtcDaliToolBarRemoveControl01");
204 ImageActor control = CreateSolidColorActor( Color::RED );
206 ToolBar toolbar = ToolBar::New();
207 toolbar.AddControl( control, 0.1f, Alignment::HorizontalLeft );
209 toolbar.RemoveControl( control );
213 tet_result(TET_FAIL);
216 tet_result(TET_PASS);
220 int UtcDaliToolBarRemoveControl02(void)
222 ToolkitTestApplication application;
223 tet_infoline(" UtcDaliToolBarRemoveControl02");
227 ImageActor control01 = CreateSolidColorActor( Color::RED );
228 ImageActor control02 = CreateSolidColorActor( Color::RED );
230 ToolBar toolbar01 = ToolBar::New();
231 ToolBar toolbar02 = ToolBar::New();
232 toolbar01.AddControl( control01, 0.1f, Alignment::HorizontalLeft );
233 toolbar02.AddControl( control02, 0.1f, Alignment::HorizontalLeft );
235 toolbar02.RemoveControl( control01 );
237 catch( Dali::DaliException& e )
239 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
240 DALI_TEST_EQUALS(e.mCondition, "false", TEST_LOCATION);
244 tet_result(TET_FAIL);
249 ImageActor control = CreateSolidColorActor( Color::RED );
251 ToolBar toolbar = ToolBar::New();
252 toolbar.AddControl( control, 0.1f, Alignment::HorizontalLeft );
254 toolbar.RemoveControl( control );
255 toolbar.RemoveControl( control );
259 tet_result(TET_FAIL);
262 tet_result(TET_PASS);