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>
24 using namespace Dali::Toolkit;
26 void dali_page_startup(void)
28 test_return_value = TET_UNDEF;
31 void dali_page_cleanup(void)
33 test_return_value = TET_PASS;
38 static bool gObjectCreatedCallBackCalled;
39 static void TestCallback(BaseHandle handle)
41 gObjectCreatedCallBackCalled = true;
48 int UtcDaliPageNew(void)
50 ToolkitTestApplication application;
51 tet_infoline("UtcDaliPageNew");
54 // Check that this handle is uninitialized
55 DALI_TEST_CHECK( !naviItem );
57 naviItem = Page::New();
58 // Check that the Dali resource is successfully created
59 DALI_TEST_CHECK( naviItem );
61 Page naviItem2( naviItem );
62 DALI_TEST_CHECK( naviItem2 == naviItem );
64 // Additional check to ensure the object is created by checking whether it is registered
65 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
66 DALI_TEST_CHECK( registry );
67 gObjectCreatedCallBackCalled = false;
68 registry.ObjectCreatedSignal().Connect( TestCallback );
70 Page naviItem = Page::New();
72 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
76 int UtcDaliPageDownCast(void)
78 ToolkitTestApplication application;
79 tet_infoline( "UtcDaliPageDownCast" );
81 Page naviItem = Page::New();
82 BaseHandle handle( naviItem );
84 Page newNaviItem = Page::DownCast( handle );
85 DALI_TEST_CHECK( naviItem );
86 DALI_TEST_CHECK( newNaviItem == naviItem );
90 int UtcDaliPageSetGetTitle(void)
92 ToolkitTestApplication application;
93 tet_infoline( "UtcDaliPageSetGetTitle" );
95 Page naviItem = Page::New();
96 DALI_TEST_CHECK( naviItem.GetTitle().empty() );
98 std::string str( "ItemTitle" );
99 naviItem.SetTitle( str );
100 DALI_TEST_CHECK( naviItem.GetTitle() == str );
104 int UtcDaliPageSetGetSubTitle(void)
106 ToolkitTestApplication application;
107 tet_infoline( "UtcDaliPageSetGetSubTitle" );
109 Page naviItem = Page::New();
110 DALI_TEST_CHECK( naviItem.GetSubTitle().empty() );
112 std::string str( "ItemSubTitle" );
113 naviItem.SetSubTitle( str );
114 DALI_TEST_CHECK( naviItem.GetSubTitle() == str );
118 int UtcDaliPageSetGetTitleIcon(void)
120 ToolkitTestApplication application;
121 tet_infoline( "UtcDaliPageSetGetTitleIcon" );
123 Page naviItem = Page::New();
124 DALI_TEST_CHECK( !naviItem.GetTitleIcon() );
126 Actor titleIcon = Actor::New();
127 naviItem.SetTitleIcon( titleIcon );
128 DALI_TEST_CHECK( naviItem.GetTitleIcon() == titleIcon );
132 int UtcDaliPageAddGetToolBarControl(void)
134 ToolkitTestApplication application;
135 tet_infoline( "UtcDaliPageAddGetToolBarControl" );
137 Page naviItem = Page::New();
138 Page::ControlOnBarContainer container = naviItem.GetControlsOnToolBar();
139 // Check that the container is empty in the beginning
140 DALI_TEST_CHECK( container.empty() );
142 // Add control, check whether adding successfully, also check the container size
143 PushButton firstControl = PushButton::New();
144 DALI_TEST_CHECK( naviItem.AddControlToToolBar(firstControl, Alignment::HorizontalLeft) );
145 container = naviItem.GetControlsOnToolBar();
146 DALI_TEST_CHECK( container.size() == 1 );
148 // Add control, check whether adding successfully, also check the container size
149 PushButton secondControl = PushButton::New();
150 DALI_TEST_CHECK( naviItem.AddControlToToolBar(secondControl, Alignment::HorizontalCenter) );
151 container = naviItem.GetControlsOnToolBar();
152 DALI_TEST_CHECK( container.size() == 2 );
154 // The control adding fails, as the alignment is not HorizontalLeft/HorizontalCenter/HorizontalRight
155 PushButton thirdControl = PushButton::New();
156 DALI_TEST_CHECK( !naviItem.AddControlToToolBar(thirdControl, Alignment::VerticalCenter) );
157 container = naviItem.GetControlsOnToolBar();
158 DALI_TEST_CHECK( container.size() == 2 );
160 // Add control, check whether adding successfully, also check the container size
161 PushButton fourthControl = PushButton::New();
162 DALI_TEST_CHECK( naviItem.AddControlToToolBar(fourthControl, Alignment::HorizontalRight) );
163 container = naviItem.GetControlsOnToolBar();
164 DALI_TEST_CHECK( container.size() == 3 );
166 // The control adding fails, as the control itself is uninitialized
167 PushButton fifthControl;
168 DALI_TEST_CHECK( !naviItem.AddControlToToolBar(fifthControl, Alignment::HorizontalCenter) );
169 container = naviItem.GetControlsOnToolBar();
170 DALI_TEST_CHECK( container.size() == 3 );
172 // check the content of the three successfully added ControlOnBar objects
173 DALI_TEST_CHECK( container[0]->control == firstControl );
174 DALI_TEST_CHECK( container[0]->alignment == Alignment::HorizontalLeft );
175 DALI_TEST_CHECK( container[1]->control == secondControl );
176 DALI_TEST_CHECK( container[1]->alignment == Alignment::HorizontalCenter );
177 DALI_TEST_CHECK( container[2]->control == fourthControl );
178 DALI_TEST_CHECK( container[2]->alignment == Alignment::HorizontalRight );
182 int UtcDaliPageAddGetTitleBarControl(void)
184 ToolkitTestApplication application;
185 tet_infoline( "UtcDaliPageAddGetTitleBarControl" );
187 Page naviItem = Page::New();
188 ActorContainer container = naviItem.GetControlsOnTitleBar();
189 // Check that the container is empty in the beginning
190 DALI_TEST_CHECK( container.empty() );
192 // Add control, check whether adding successfully, also check the container size
193 PushButton firstControl = PushButton::New();
194 DALI_TEST_CHECK( naviItem.AddControlToTitleBar(firstControl) );
195 container = naviItem.GetControlsOnTitleBar();
196 DALI_TEST_CHECK( container.size() == 1 );
198 // The control adding fails, as the control itself is uninitialized
199 PushButton secondControl;
200 DALI_TEST_CHECK( !naviItem.AddControlToTitleBar(secondControl) );
201 container = naviItem.GetControlsOnTitleBar();
202 DALI_TEST_CHECK( container.size() == 1 );
204 // Add control, check whether adding successfully, also check the container size
205 PushButton thirdControl = PushButton::New();
206 DALI_TEST_CHECK( naviItem.AddControlToTitleBar(thirdControl) );
207 container = naviItem.GetControlsOnTitleBar();
208 DALI_TEST_CHECK( container.size() == 2 );
210 // check the content of the three successfully added Controls
211 DALI_TEST_CHECK( container[0] == firstControl );
212 DALI_TEST_CHECK( container[1] == thirdControl );
216 int UtcDaliPageSetGetPopupMenu(void)
218 ToolkitTestApplication application;
219 tet_infoline( "UtcDaliPageSetGetPopupMenu" );
221 Page naviItem = Page::New();
222 DALI_TEST_CHECK( !naviItem.GetPopupMenu() );
224 Toolkit::Popup menu = Toolkit::Popup::New();
225 naviItem.SetPopupMenu( menu );
226 DALI_TEST_CHECK( menu == naviItem.GetPopupMenu() );