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>
23 using namespace Dali::Toolkit;
25 void dali_page_startup(void)
27 test_return_value = TET_UNDEF;
30 void dali_page_cleanup(void)
32 test_return_value = TET_PASS;
37 static bool gObjectCreatedCallBackCalled;
38 static void TestCallback(BaseHandle handle)
40 gObjectCreatedCallBackCalled = true;
47 int UtcDaliPageNew(void)
49 ToolkitTestApplication application;
50 tet_infoline("UtcDaliPageNew");
53 // Check that this handle is uninitialized
54 DALI_TEST_CHECK( !naviItem );
56 naviItem = Page::New();
57 // Check that the Dali resource is successfully created
58 DALI_TEST_CHECK( naviItem );
60 Page naviItem2( naviItem );
61 DALI_TEST_CHECK( naviItem2 == naviItem );
63 // Additional check to ensure the object is created by checking whether it is registered
64 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
65 DALI_TEST_CHECK( registry );
66 gObjectCreatedCallBackCalled = false;
67 registry.ObjectCreatedSignal().Connect( TestCallback );
69 Page naviItem = Page::New();
71 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
75 int UtcDaliPageDownCast(void)
77 ToolkitTestApplication application;
78 tet_infoline( "UtcDaliPageDownCast" );
80 Page naviItem = Page::New();
81 BaseHandle handle( naviItem );
83 Page newNaviItem = Page::DownCast( handle );
84 DALI_TEST_CHECK( naviItem );
85 DALI_TEST_CHECK( newNaviItem == naviItem );
89 int UtcDaliPageSetGetTitle(void)
91 ToolkitTestApplication application;
92 tet_infoline( "UtcDaliPageSetGetTitle" );
94 Page naviItem = Page::New();
95 DALI_TEST_CHECK( naviItem.GetTitle().empty() );
97 std::string str( "ItemTitle" );
98 naviItem.SetTitle( str );
99 DALI_TEST_CHECK( naviItem.GetTitle() == str );
103 int UtcDaliPageSetGetSubTitle(void)
105 ToolkitTestApplication application;
106 tet_infoline( "UtcDaliPageSetGetSubTitle" );
108 Page naviItem = Page::New();
109 DALI_TEST_CHECK( naviItem.GetSubTitle().empty() );
111 std::string str( "ItemSubTitle" );
112 naviItem.SetSubTitle( str );
113 DALI_TEST_CHECK( naviItem.GetSubTitle() == str );
117 int UtcDaliPageSetGetTitleIcon(void)
119 ToolkitTestApplication application;
120 tet_infoline( "UtcDaliPageSetGetTitleIcon" );
122 Page naviItem = Page::New();
123 DALI_TEST_CHECK( !naviItem.GetTitleIcon() );
125 Actor titleIcon = Actor::New();
126 naviItem.SetTitleIcon( titleIcon );
127 DALI_TEST_CHECK( naviItem.GetTitleIcon() == titleIcon );
131 int UtcDaliPageAddGetToolBarControl(void)
133 ToolkitTestApplication application;
134 tet_infoline( "UtcDaliPageAddGetToolBarControl" );
136 Page naviItem = Page::New();
137 Page::ControlOnBarContainer container = naviItem.GetControlsOnToolBar();
138 // Check that the container is empty in the beginning
139 DALI_TEST_CHECK( container.empty() );
141 // Add control, check whether adding successfully, also check the container size
142 PushButton firstControl = PushButton::New();
143 DALI_TEST_CHECK( naviItem.AddControlToToolBar(firstControl, Alignment::HorizontalLeft) );
144 container = naviItem.GetControlsOnToolBar();
145 DALI_TEST_CHECK( container.size() == 1 );
147 // Add control, check whether adding successfully, also check the container size
148 PushButton secondControl = PushButton::New();
149 DALI_TEST_CHECK( naviItem.AddControlToToolBar(secondControl, Alignment::HorizontalCenter) );
150 container = naviItem.GetControlsOnToolBar();
151 DALI_TEST_CHECK( container.size() == 2 );
153 // The control adding fails, as the alignment is not HorizontalLeft/HorizontalCenter/HorizontalRight
154 PushButton thirdControl = PushButton::New();
155 DALI_TEST_CHECK( !naviItem.AddControlToToolBar(thirdControl, Alignment::VerticalCenter) );
156 container = naviItem.GetControlsOnToolBar();
157 DALI_TEST_CHECK( container.size() == 2 );
159 // Add control, check whether adding successfully, also check the container size
160 PushButton fourthControl = PushButton::New();
161 DALI_TEST_CHECK( naviItem.AddControlToToolBar(fourthControl, Alignment::HorizontalRight) );
162 container = naviItem.GetControlsOnToolBar();
163 DALI_TEST_CHECK( container.size() == 3 );
165 // The control adding fails, as the control itself is uninitialized
166 PushButton fifthControl;
167 DALI_TEST_CHECK( !naviItem.AddControlToToolBar(fifthControl, Alignment::HorizontalCenter) );
168 container = naviItem.GetControlsOnToolBar();
169 DALI_TEST_CHECK( container.size() == 3 );
171 // check the content of the three successfully added ControlOnBar objects
172 DALI_TEST_CHECK( container[0]->control == firstControl );
173 DALI_TEST_CHECK( container[0]->alignment == Alignment::HorizontalLeft );
174 DALI_TEST_CHECK( container[1]->control == secondControl );
175 DALI_TEST_CHECK( container[1]->alignment == Alignment::HorizontalCenter );
176 DALI_TEST_CHECK( container[2]->control == fourthControl );
177 DALI_TEST_CHECK( container[2]->alignment == Alignment::HorizontalRight );
181 int UtcDaliPageAddGetTitleBarControl(void)
183 ToolkitTestApplication application;
184 tet_infoline( "UtcDaliPageAddGetTitleBarControl" );
186 Page naviItem = Page::New();
187 ActorContainer container = naviItem.GetControlsOnTitleBar();
188 // Check that the container is empty in the beginning
189 DALI_TEST_CHECK( container.empty() );
191 // Add control, check whether adding successfully, also check the container size
192 PushButton firstControl = PushButton::New();
193 DALI_TEST_CHECK( naviItem.AddControlToTitleBar(firstControl) );
194 container = naviItem.GetControlsOnTitleBar();
195 DALI_TEST_CHECK( container.size() == 1 );
197 // The control adding fails, as the control itself is uninitialized
198 PushButton secondControl;
199 DALI_TEST_CHECK( !naviItem.AddControlToTitleBar(secondControl) );
200 container = naviItem.GetControlsOnTitleBar();
201 DALI_TEST_CHECK( container.size() == 1 );
203 // Add control, check whether adding successfully, also check the container size
204 PushButton thirdControl = PushButton::New();
205 DALI_TEST_CHECK( naviItem.AddControlToTitleBar(thirdControl) );
206 container = naviItem.GetControlsOnTitleBar();
207 DALI_TEST_CHECK( container.size() == 2 );
209 // check the content of the three successfully added Controls
210 DALI_TEST_CHECK( container[0] == firstControl );
211 DALI_TEST_CHECK( container[1] == thirdControl );
215 int UtcDaliPageSetGetPopupMenu(void)
217 ToolkitTestApplication application;
218 tet_infoline( "UtcDaliPageSetGetPopupMenu" );
220 Page naviItem = Page::New();
221 DALI_TEST_CHECK( !naviItem.GetPopupMenu() );
223 Toolkit::Popup menu = Toolkit::Popup::New();
224 naviItem.SetPopupMenu( menu );
225 DALI_TEST_CHECK( menu == naviItem.GetPopupMenu() );