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 UtcDaliToolBarAddControl01(void)
86 ToolkitTestApplication application;
87 tet_infoline(" UtcDaliToolBarAddControl01");
91 ImageActor control1 = CreateSolidColorActor( Color::RED );
92 control1.SetSize( Vector2( 100.f, 100.f ) );
93 ImageActor control2 = CreateSolidColorActor( Color::RED );
94 control2.SetSize( Vector2( 100.f, 100.f ) );
95 ImageActor control3 = CreateSolidColorActor( Color::RED );
96 control3.SetSize( Vector2( 100.f, 100.f ) );
97 ImageActor control4 = CreateSolidColorActor( Color::RED );
98 control4.SetSize( Vector2( 100.f, 100.f ) );
99 ImageActor control5 = CreateSolidColorActor( Color::RED );
100 control5.SetSize( Vector2( 100.f, 100.f ) );
102 ToolBar toolbar = ToolBar::New();
103 toolbar.SetSize( Vector2( 600.f, 100.f ) );
105 application.Render();
106 application.SendNotification();
107 application.Render();
108 application.SendNotification();
110 toolbar.Add( control1 );
111 toolbar.AddControl( control2, 0.1f, Alignment::HorizontalLeft, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
112 toolbar.AddControl( control3, 0.1f, Alignment::HorizontalCenter, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
113 toolbar.AddControl( control4, 0.1f, Alignment::HorizontalCenter, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
114 toolbar.AddControl( control5, 0.1f, Alignment::HorizontalRight, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
116 ImageActor control6 = CreateSolidColorActor( Color::RED );
117 control6.SetSize( Vector2( 100.f, 100.f ) );
118 ImageActor control7 = CreateSolidColorActor( Color::RED );
119 control7.SetSize( Vector2( 100.f, 100.f ) );
120 ImageActor control8 = CreateSolidColorActor( Color::RED );
121 control8.SetSize( Vector2( 100.f, 100.f ) );
123 application.Render();
124 application.SendNotification();
125 application.Render();
126 application.SendNotification();
128 toolbar.AddControl( control6, 0.4f, Alignment::HorizontalLeft, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
129 toolbar.AddControl( control7, 0.2f, Alignment::HorizontalCenter, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
130 toolbar.AddControl( control8, 0.2f, Alignment::HorizontalRight, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
134 tet_result(TET_FAIL);
137 tet_result(TET_PASS);
141 int UtcDaliToolBarAddControl02(void)
143 ToolkitTestApplication application;
144 tet_infoline(" UtcDaliToolBarAddControl02");
146 bool daliAssert = false;
150 ImageActor control = CreateSolidColorActor( Color::RED );
152 ToolBar toolbar = ToolBar::New();
154 toolbar.AddControl( control, 0.1f, static_cast<Alignment::Type>( 99 ), Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
156 catch( DaliException e )
159 tet_result(TET_PASS);
163 tet_result(TET_FAIL);
168 tet_result(TET_FAIL);
173 int UtcDaliToolBarRemoveControl01(void)
175 ToolkitTestApplication application;
176 tet_infoline(" UtcDaliToolBarRemoveControl01");
180 ImageActor control = CreateSolidColorActor( Color::RED );
182 ToolBar toolbar = ToolBar::New();
183 toolbar.AddControl( control, 0.1f, Alignment::HorizontalLeft );
185 toolbar.RemoveControl( control );
189 tet_result(TET_FAIL);
192 tet_result(TET_PASS);
196 int UtcDaliToolBarRemoveControl02(void)
198 ToolkitTestApplication application;
199 tet_infoline(" UtcDaliToolBarRemoveControl02");
203 ImageActor control01 = CreateSolidColorActor( Color::RED );
204 ImageActor control02 = CreateSolidColorActor( Color::RED );
206 ToolBar toolbar01 = ToolBar::New();
207 ToolBar toolbar02 = ToolBar::New();
208 toolbar01.AddControl( control01, 0.1f, Alignment::HorizontalLeft );
209 toolbar02.AddControl( control02, 0.1f, Alignment::HorizontalLeft );
211 toolbar02.RemoveControl( control01 );
213 catch( Dali::DaliException& e )
215 DALI_TEST_PRINT_ASSERT( e );
216 DALI_TEST_EQUALS(e.condition, "false", TEST_LOCATION);
220 tet_result(TET_FAIL);
225 ImageActor control = CreateSolidColorActor( Color::RED );
227 ToolBar toolbar = ToolBar::New();
228 toolbar.AddControl( control, 0.1f, Alignment::HorizontalLeft );
230 toolbar.RemoveControl( control );
231 toolbar.RemoveControl( control );
235 tet_result(TET_FAIL);
238 tet_result(TET_PASS);