2 * Copyright (c) 2018 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-toolkit/devel-api/controls/scene3d-view/scene3d-view.h>
25 using namespace Dali::Toolkit;
27 void dali_scene_view_startup(void)
29 test_return_value = TET_UNDEF;
32 void dali_scene_view_cleanup(void)
34 test_return_value = TET_PASS;
41 * For the AnimatedCube.gltf and its Assets
42 * Donated by Norbert Nopper for glTF testing.
43 * Take from https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/AnimatedCube
45 const char* TEST_GLTF_FILE_NAME = TEST_RESOURCE_DIR "/AnimatedCube.gltf";
47 * For the diffuse and specular cube map texture.
48 * These textures are based off version of Wave engine sample
49 * Take from https://github.com/WaveEngine/Samples
51 * Copyright (c) 2016 Wave Coorporation
53 * Permission is hereby granted, free of charge, to any person obtaining a copy
54 * of this software and associated documentation files (the "Software"), to
55 * deal in the Software without restriction, including without limitation the
56 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
57 * sell copies of the Software, and to permit persons to whom the Software is
58 * furnished to do so, subject to the following conditions:
60 * The above copyright notice and this permission notice shall be included in
61 * all copies or substantial portions of the Software.
63 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
64 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
65 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
66 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
67 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
68 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
71 const char* TEST_DIFFUSE_TEXTURE = TEST_RESOURCE_DIR "/forest_diffuse_cubemap.png";
72 const char* TEST_SPECULAR_TEXTURE = TEST_RESOURCE_DIR "/forest_specular_cubemap.png";
75 int UtcDaliScene3dViewConstructorP(void)
77 TestApplication application;
79 Scene3dView scene3dView;
81 DALI_TEST_CHECK( !scene3dView );
85 int UtcDaliScene3dViewCopyConstructorP(void)
87 TestApplication application;
89 // Initialize an object, ref count == 1
90 Scene3dView scene3dView = Scene3dView::New( TEST_GLTF_FILE_NAME );
92 Scene3dView copy( scene3dView );
93 DALI_TEST_CHECK( copy );
97 int UtcDaliScene3dViewCopyConstructor2P(void)
99 TestApplication application;
101 // Initialize an object, ref count == 1
102 Toolkit::Scene3dView scene3dView = Toolkit::Scene3dView::New( TEST_GLTF_FILE_NAME, TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE, Vector4::ONE );
104 Scene3dView copy( scene3dView );
105 DALI_TEST_CHECK( copy );
109 int UtcDaliScene3dViewAssignmentOperatorP(void)
111 TestApplication application;
113 Scene3dView scene3dView = Scene3dView::New( TEST_GLTF_FILE_NAME );
115 Scene3dView copy( scene3dView );
116 DALI_TEST_CHECK( copy );
118 DALI_TEST_CHECK( scene3dView == copy );
122 int UtcDaliScene3dViewNewP(void)
124 ToolkitTestApplication application;
125 tet_infoline(" UtcDaliScene3dViewNewP");
127 // Create the Slider actor
128 Scene3dView scene3dView;
129 DALI_TEST_CHECK( !scene3dView );
131 scene3dView = Scene3dView::New( TEST_GLTF_FILE_NAME );
132 DALI_TEST_CHECK( scene3dView );
137 int UtcDaliScene3dViewDestructorP(void)
139 ToolkitTestApplication application;
141 Scene3dView* scene3dView = new Scene3dView();
144 DALI_TEST_CHECK( true );
148 int UtcDaliScene3dViewDownCast(void)
150 ToolkitTestApplication application;
151 tet_infoline(" UtcDaliScene3dViewDownCast");
153 Toolkit::Scene3dView view = Toolkit::Scene3dView::New( TEST_GLTF_FILE_NAME );
154 BaseHandle handle(view);
156 Toolkit::Scene3dView scene3dView = Toolkit::Scene3dView::DownCast( handle );
157 DALI_TEST_CHECK( view );
158 DALI_TEST_CHECK( scene3dView );
159 DALI_TEST_CHECK( scene3dView == view );
163 int UtcDaliScene3dViewSetLight(void)
165 ToolkitTestApplication application;
166 tet_infoline(" UtcDaliScene3dViewSetLight");
168 Toolkit::Scene3dView view = Toolkit::Scene3dView::New( TEST_GLTF_FILE_NAME );
170 bool lightSet = view.SetLight( Scene3dView::LightType::DIRECTIONAL_LIGHT, Vector3( 1.0, 1.0, -1.0 ), Vector3( 0.3, 0.3, 0.3 ) );
171 DALI_TEST_CHECK( lightSet );
172 bool lightSet2 = view.SetLight( Scene3dView::LightType::POINT_LIGHT, Vector3( 1.0, 1.0, -1.0 ), Vector3( 0.3, 0.3, 0.3 ) );
173 DALI_TEST_CHECK( lightSet2 );
178 int UtcDaliScene3dViewGetCamera(void)
180 ToolkitTestApplication application;
181 tet_infoline(" UtcDaliScene3dViewGetCamera");
183 Toolkit::Scene3dView view = Toolkit::Scene3dView::New( TEST_GLTF_FILE_NAME );
185 CameraActor camera = view.GetDefaultCamera();
186 DALI_TEST_CHECK( camera );
188 CameraActor camera2 = view.GetCamera( -1 );
189 DALI_TEST_CHECK( !camera2 );
191 CameraActor camera3 = view.GetCamera( 0 );
192 DALI_TEST_CHECK( camera3 );
194 CameraActor camera4 = view.GetCamera( view.GetCameraCount() - 1 );
195 DALI_TEST_CHECK( camera4 );
200 int UtcDaliScene3dViewAnimations(void)
202 ToolkitTestApplication application;
203 tet_infoline(" UtcDaliScene3dViewAnimations");
205 Toolkit::Scene3dView view = Toolkit::Scene3dView::New( TEST_GLTF_FILE_NAME );
207 bool playAnimation = view.PlayAnimations();
208 DALI_TEST_CHECK( playAnimation );
213 int UtcDaliScene3dViewAnimations2(void)
215 ToolkitTestApplication application;
216 tet_infoline(" UtcDaliScene3dViewAnimations2");
218 Toolkit::Scene3dView view = Toolkit::Scene3dView::New( TEST_GLTF_FILE_NAME );
220 bool animated = true;
221 unsigned int animationCount = view.GetAnimationCount();
222 for( unsigned int i = 0; i < animationCount; ++i )
224 animated = ( animated && view.PlayAnimation( i ) );
226 DALI_TEST_CHECK( animated );