Dali 3D User Interface Engine
utc-Dali-Model3dView.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17 
18 #include <iostream>
19 #include <stdlib.h>
23 
24 
25 using namespace Dali;
26 using namespace Dali::Toolkit;
27 
28 
30 {
32 }
33 
35 {
37 }
38 
39 namespace
40 {
41 const char * TEST_OBJ_FILE_NAME = "Dino.obj";
42 const char * TEST_MTL_FILE_NAME = "Dino.mtl";
43 //const char * TEST_IMG_PATH = "";
44 }
45 
46 // Negative test case for a method
48 {
49  ToolkitTestApplication application;
50  tet_infoline(" UtcDaliModel3dViewUninitialized");
51 
53 
54  try
55  {
56  // New() must be called to create a Model3dView or it wont be valid.
57  Actor a = Actor::New();
58  view.Add( a );
59  DALI_TEST_CHECK( false );
60  }
61  catch (Dali::DaliException& e)
62  {
63  // Tests that a negative test of an assertion succeeds
65  DALI_TEST_CHECK(!view);
66  }
67  END_TEST;
68 }
69 
70 // Positive test case for a method
72 {
73  ToolkitTestApplication application;
74  tet_infoline(" UtcDaliModel3dViewNew");
75 
77  DALI_TEST_CHECK( view );
78 
80  DALI_TEST_CHECK( view2 );
81  END_TEST;
82 }
83 
84 // Positive test case for a method
86 {
87  ToolkitTestApplication application;
88  tet_infoline(" UtcDaliModelViewDownCast");
89 
91  BaseHandle handle(view);
92 
94  DALI_TEST_CHECK( view );
95  DALI_TEST_CHECK( modelView );
96  DALI_TEST_CHECK( modelView == view );
97  END_TEST;
98 }
99 
100 
101 // Positive test case for a method
103 {
104  ToolkitTestApplication application;
105  tet_infoline(" UtcDaliModel3dViewPropertyNames");
106 
108  DALI_TEST_CHECK( view );
109 
110  view.SetProperty( Model3dView::Property::GEOMETRY_URL, Dali::Property::Value( TEST_OBJ_FILE_NAME ) );
111  Property::Value val = view.GetProperty( Model3dView::Property::GEOMETRY_URL );
112  std::string obj_file_name;
113  DALI_TEST_CHECK( val.Get( obj_file_name ) );
115 
116  view.SetProperty( Model3dView::Property::MATERIAL_URL, Dali::Property::Value( TEST_MTL_FILE_NAME ) );
117  val = view.GetProperty( Model3dView::Property::MATERIAL_URL );
118  DALI_TEST_CHECK( val.Get( obj_file_name ) );
120 
121  //modelView.SetProperty( Model3dView::Property::MTL_URL, Dali::Property::Value( mtlUrl ) );
122  //modelView.SetProperty( Model3dView::Property::IMAGES_URL, Dali::Property::Value( imagesUrl ) );
123 
124  END_TEST;
125 }
126 
127 // Positive test case for a method
129 {
130  ToolkitTestApplication application;
131  tet_infoline(" UtcDaliModel3dViewAddRemove");
132 
134  DALI_TEST_CHECK( view );
135 
136  Actor actor = Actor::New();
137  DALI_TEST_CHECK( !actor.OnStage() );
138 
139 
141  view.SetSize(Stage::GetCurrent().GetSize());
142  view.Add(actor);
143  Stage::GetCurrent().Add(view);
144 
145  DALI_TEST_CHECK( actor.OnStage() );
146 
147  view.Remove(actor);
148 
149  DALI_TEST_CHECK( !actor.OnStage() );
150  END_TEST;
151 }
152 
153 
155 {
156  ToolkitTestApplication application;
157 
159  DALI_TEST_CHECK( view );
160 
161  Model3dView copy( view );
162  DALI_TEST_CHECK( view == copy );
163 
164  Model3dView assign;
165  DALI_TEST_CHECK( ! assign );
166 
167  assign = copy;
168  DALI_TEST_CHECK( assign == view );
169 
170  END_TEST;
171 }
172 
174 {
175  ToolkitTestApplication application;
176 
177  TypeRegistry typeRegistry = TypeRegistry::Get();
178  DALI_TEST_CHECK( typeRegistry );
179 
180  TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Model3dView" );
181  DALI_TEST_CHECK( typeInfo );
182 
183  BaseHandle handle = typeInfo.CreateInstance();
184  DALI_TEST_CHECK( handle );
185 
186  Model3dView view = Model3dView::DownCast( handle );
187  DALI_TEST_CHECK( view );
188 
189  END_TEST;
190 }
191 
193 {
194  ToolkitTestApplication application;
195 
197 
198  Stage::GetCurrent().Add( view );
199 
200  application.SendNotification();
201  application.Render();
202 
203  Vector3 size( 200.0f, 300.0f, 0.0f );
204  view.SetSize( size );
205 
206  application.SendNotification();
207  application.Render();
208 
210 
211  END_TEST;
212 }
Dali Docs Home
Read more about Dali