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.
21 #include <dali-toolkit-test-suite-utils.h>
22 #include <dali-toolkit/dali-toolkit.h>
23 #include <dali-toolkit/devel-api/controls/navigation-view/navigation-view.h>
26 using namespace Toolkit;
28 void dali_navigationView_startup(void)
30 test_return_value = TET_UNDEF;
33 void dali_navigationView_cleanup(void)
35 test_return_value = TET_PASS;
38 int UtcDaliNavigationTypeRegistry(void)
40 ToolkitTestApplication application;
42 TypeRegistry typeRegistry = TypeRegistry::Get();
43 DALI_TEST_CHECK( typeRegistry );
45 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "NavigationView" );
46 DALI_TEST_CHECK( typeInfo );
48 BaseHandle handle = typeInfo.CreateInstance();
49 DALI_TEST_CHECK( handle );
51 NavigationView view = NavigationView::DownCast( handle );
52 DALI_TEST_CHECK( view );
57 int UtcDaliNavigationViewNew(void)
59 ToolkitTestApplication application;
61 NavigationView navigationView;
62 DALI_TEST_CHECK( !navigationView );
64 navigationView = NavigationView::New();
65 DALI_TEST_CHECK( navigationView );
67 application.GetScene().Add( navigationView );
69 application.SendNotification();
75 int UtcDaliNavigationViewCopyAndAssignment(void)
77 ToolkitTestApplication application;
79 NavigationView view = NavigationView::New();
80 DALI_TEST_CHECK( view );
82 NavigationView copy( view );
83 DALI_TEST_CHECK( copy == view );
85 NavigationView assign;
86 DALI_TEST_CHECK( !assign );
88 DALI_TEST_CHECK( assign == view );
92 DALI_TEST_CHECK( assign );
93 DALI_TEST_CHECK( assign == view );
98 int UtcDaliNavigationViewDownCast(void)
100 ToolkitTestApplication application;
102 BaseHandle view = NavigationView::New();
103 DALI_TEST_CHECK( NavigationView::DownCast( view ) );
106 DALI_TEST_CHECK( ! NavigationView::DownCast( empty ) );
108 BaseHandle another = Actor::New();
109 DALI_TEST_CHECK( ! NavigationView::DownCast( another ) );
114 int UtcDaliNavigationViewPush(void)
116 ToolkitTestApplication application;
118 Integration::Scene stage = application.GetScene();
120 // 1 Create and Add Navigation View to stage, actor count should be zero
121 NavigationView naviView = NavigationView::New();
122 stage.Add( naviView );
124 DALI_TEST_EQUALS( naviView.GetChildCount(), 0, TEST_LOCATION );
126 // 2 Add Actor to Navigation View, actor count should increase to 1
128 Actor TestParentActor1 = Actor::New();
129 naviView.Push( TestParentActor1 );
131 DALI_TEST_EQUALS( naviView.GetChildCount(), 1, TEST_LOCATION );
136 int UtcDaliNavigationViewPop(void)
138 ToolkitTestApplication application;
140 Integration::Scene stage = application.GetScene();
142 // 1 Create Navigation View
143 NavigationView naviView = NavigationView::New();
144 stage.Add( naviView );
146 // 2 Push initial Actor
147 Actor testParentActor1 = Actor::New();
148 testParentActor1.SetProperty( Dali::Actor::Property::NAME,"TestParentActor1");
149 naviView.Push( testParentActor1 );
150 DALI_TEST_EQUALS( naviView.GetChildCount(), 1 , TEST_LOCATION );
152 // 3 Push Second Actor which contains a child actor
153 Actor testParentActor2 = Actor::New();
154 testParentActor2.SetProperty( Dali::Actor::Property::NAME,"TestParentActor2");
155 Actor testChildActor1 = Actor::New();
156 testParentActor2.Add( testChildActor1 );
157 naviView.Push( testParentActor2 );
160 // 4 Pop head actor, it should be TestParentActor2
161 Actor poppedActor = naviView.Pop();
162 DALI_TEST_EQUALS( poppedActor.GetProperty< std::string >( Dali::Actor::Property::NAME ) , "TestParentActor2", TEST_LOCATION );
164 // 5 Navigation View child count should be 1
165 DALI_TEST_EQUALS( naviView.GetChildCount(), 1 , TEST_LOCATION );
171 int UtcDaliNavigationViewPushAndPop(void)
173 ToolkitTestApplication application;
175 Integration::Scene stage = application.GetScene();
177 // 1 Create Navigation View
178 NavigationView naviView = NavigationView::New();
179 stage.Add( naviView );
181 // 2 Push initial Actor
182 Actor testParentActor1 = Actor::New();
183 testParentActor1.SetProperty( Dali::Actor::Property::NAME,"TestParentActor1");
184 naviView.Push( testParentActor1 );
185 DALI_TEST_EQUALS( naviView.GetChildCount(), 1 , TEST_LOCATION );
187 // 3 Push Second Actor which contains a child actor
188 Actor testParentActor2 = Actor::New();
189 testParentActor2.SetProperty( Dali::Actor::Property::NAME,"TestParentActor2");
190 Actor testChildActor1 = Actor::New();
191 testParentActor2.Add( testChildActor1 );
192 naviView.Push( testParentActor2 );
194 // 3 Push third Actor which contains a child actor
195 Actor testParentActor3 = Actor::New();
196 testParentActor3.SetProperty( Dali::Actor::Property::NAME,"TestParentActor3");
197 Actor testChildActor2 = Actor::New();
198 testParentActor2.Add( testChildActor2 );
199 naviView.Push( testParentActor3 );
201 // 4 Pop head actor, it should be TestParentActor3
202 Actor poppedActor = naviView.Pop();
203 DALI_TEST_EQUALS( poppedActor.GetProperty< std::string >( Dali::Actor::Property::NAME ) , "TestParentActor3", TEST_LOCATION );
205 // 5 Pop head actor, it should be TestParentActor2
206 Actor poppedActor2 = naviView.Pop();
207 DALI_TEST_EQUALS( poppedActor2.GetProperty< std::string >( Dali::Actor::Property::NAME ) , "TestParentActor2", TEST_LOCATION );
213 int UtcDaliNavigationViewPreventLastPop(void)
215 ToolkitTestApplication application;
217 Integration::Scene stage = application.GetScene();
219 // 1 Create Navigation View
220 NavigationView naviView = NavigationView::New();
221 stage.Add( naviView );
223 // 2 Push initial Actor
224 Actor testParentActor1 = Actor::New();
225 testParentActor1.SetProperty( Dali::Actor::Property::NAME,"TestParentActor1");
226 naviView.Push( testParentActor1 );
227 DALI_TEST_EQUALS( naviView.GetChildCount(), 1 , TEST_LOCATION );
229 // 3 Push Second Actor which contains a child actor
230 Actor testParentActor2 = Actor::New();
231 testParentActor2.SetProperty( Dali::Actor::Property::NAME,"TestParentActor2");
232 Actor testChildActor1 = Actor::New();
233 testParentActor2.Add( testChildActor1 );
234 naviView.Push( testParentActor2 );
236 // 4 Pop head actor, it should be TestParentActor2
237 Actor poppedActor1 = naviView.Pop();
238 DALI_TEST_EQUALS( poppedActor1.GetProperty< std::string >( Dali::Actor::Property::NAME ) , "TestParentActor2", TEST_LOCATION );
241 // 5 Try to Pop head actor, Should be empty hence can not get name of Actor
242 Actor poppedActorEmpty = naviView.Pop();
246 const std::string hasNoName = poppedActorEmpty.GetProperty< std::string >( Dali::Actor::Property::NAME );
247 tet_infoline( hasNoName.c_str() );
248 DALI_TEST_CHECK( false ); // should not get here
252 DALI_TEST_CHECK( true );