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/public-api/dali-core.h>
21 #include <dali-test-suite-utils.h>
22 #include <dali/devel-api/dynamics/dynamics.h>
27 int UtcDaliDynamicsJointConstructor(void)
29 tet_infoline("UtcDaliDynamicsJointConstructor - DynamicsJoint::DynamicsJoint");
31 TestApplication application;
34 application.SendNotification();
40 DALI_TEST_CHECK( !joint );
44 int UtcDaliDynamicsJointLinearLimit(void)
46 #if !defined(DYNAMICS_SUPPORT)
47 tet_infoline("No dynamics support compiled\n");
50 TestApplication application;
53 application.SendNotification();
57 DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
58 DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
63 // cannot create dynamics world, log failure and exit
64 DALI_TEST_CHECK( false );
68 DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
69 Actor actor1(Actor::New());
70 actor1.EnableDynamics(bodyConfig);
71 Actor actor2(Actor::New());
72 actor2.EnableDynamics(bodyConfig);
74 DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) );
78 tet_infoline("UtcDaliDynamicsJointLinearLimit - DynamicsJoint::SetLinearLimit()");
79 joint.SetLinearLimit(DynamicsJoint::LINEAR_X, 0.0f, 1.0f);
81 DALI_TEST_CHECK( true );
85 int UtcDaliDynamicsJointAngularLimit(void)
87 #if !defined(DYNAMICS_SUPPORT)
88 tet_infoline("No dynamics support compiled\n");
91 TestApplication application;
94 application.SendNotification();
98 DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
99 DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
103 // cannot create dynamics world, log failure and exit
104 DALI_TEST_CHECK( false );
108 DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
109 Actor actor1(Actor::New());
110 actor1.EnableDynamics(bodyConfig);
111 Actor actor2(Actor::New());
112 actor2.EnableDynamics(bodyConfig);
114 DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) );
116 tet_infoline("UtcDaliDynamicsJointAngularLimit - DynamicsJoint::SetAngularLimit()");
117 joint.SetAngularLimit(DynamicsJoint::ANGULAR_X, Degree(0.0f), Degree(1.0f) );
118 DALI_TEST_CHECK( true );
122 int UtcDaliDynamicsJointEnableSpring(void)
124 #if !defined(DYNAMICS_SUPPORT)
125 tet_infoline("No dynamics support compiled\n");
128 TestApplication application;
131 application.SendNotification();
132 application.Render();
133 application.Render();
135 DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
136 DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
140 // cannot create dynamics world, log failure and exit
141 DALI_TEST_CHECK( false );
145 DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
146 Actor actor1(Actor::New());
147 actor1.EnableDynamics(bodyConfig);
148 Actor actor2(Actor::New());
149 actor2.EnableDynamics(bodyConfig);
151 DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) );
153 tet_infoline("UtcDaliDynamicsJointEnableSpring");
154 joint.EnableSpring(DynamicsJoint::LINEAR_X, true );
155 DALI_TEST_CHECK( true );
159 int UtcDaliDynamicsJointSetSpringStiffness(void)
161 #if !defined(DYNAMICS_SUPPORT)
162 tet_infoline("No dynamics support compiled\n");
165 TestApplication application;
168 application.SendNotification();
169 application.Render();
170 application.Render();
172 DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
173 DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
177 // cannot create dynamics world, log failure and exit
178 DALI_TEST_CHECK( false );
182 DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
183 Actor actor1(Actor::New());
184 actor1.EnableDynamics(bodyConfig);
185 Actor actor2(Actor::New());
186 actor2.EnableDynamics(bodyConfig);
188 DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) );
190 tet_infoline("UtcDaliDynamicsJointSetSpringStiffness");
191 joint.SetSpringStiffness(DynamicsJoint::LINEAR_X, 1.0f );
192 DALI_TEST_CHECK( true );
196 int UtcDaliDynamicsJointSetSpringCenterPoint(void)
198 #if !defined(DYNAMICS_SUPPORT)
199 tet_infoline("No dynamics support compiled\n");
202 TestApplication application;
205 application.SendNotification();
206 application.Render();
207 application.Render();
209 DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
210 DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
214 // cannot create dynamics world, log failure and exit
215 DALI_TEST_CHECK( false );
219 DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
220 Actor actor1(Actor::New());
221 actor1.EnableDynamics(bodyConfig);
222 Actor actor2(Actor::New());
223 actor2.EnableDynamics(bodyConfig);
225 DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) );
227 tet_infoline("UtcDaliDynamicsJointSetSpringCenterPoint");
228 joint.SetSpringCenterPoint(DynamicsJoint::LINEAR_X, 0.5f );
229 DALI_TEST_CHECK( true );
233 int UtcDaliDynamicsJointEnableMotor(void)
235 #if !defined(DYNAMICS_SUPPORT)
236 tet_infoline("No dynamics support compiled\n");
239 TestApplication application;
242 application.SendNotification();
243 application.Render();
244 application.Render();
246 DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
247 DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
251 // cannot create dynamics world, log failure and exit
252 DALI_TEST_CHECK( false );
256 DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
257 Actor actor1(Actor::New());
258 actor1.EnableDynamics(bodyConfig);
259 Actor actor2(Actor::New());
260 actor2.EnableDynamics(bodyConfig);
262 DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) );
264 tet_infoline("UtcDaliDynamicsJointEnableMotor");
265 joint.EnableMotor(DynamicsJoint::LINEAR_X, true );
266 DALI_TEST_CHECK( true );
270 int UtcDaliDynamicsJointSetMotorVelocity(void)
272 #if !defined(DYNAMICS_SUPPORT)
273 tet_infoline("No dynamics support compiled\n");
276 TestApplication application;
279 application.SendNotification();
280 application.Render();
281 application.Render();
283 DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
284 DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
288 // cannot create dynamics world, log failure and exit
289 DALI_TEST_CHECK( false );
293 DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
294 Actor actor1(Actor::New());
295 actor1.EnableDynamics(bodyConfig);
296 Actor actor2(Actor::New());
297 actor2.EnableDynamics(bodyConfig);
299 DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) );
301 tet_infoline("UtcDaliDynamicsJointSetMotorVelocity");
302 joint.SetMotorVelocity(DynamicsJoint::LINEAR_X, 1.0f );
303 DALI_TEST_CHECK( true );
307 int UtcDaliDynamicsJointSetMotorForce(void)
309 #if !defined(DYNAMICS_SUPPORT)
310 tet_infoline("No dynamics support compiled\n");
313 TestApplication application;
316 application.SendNotification();
317 application.Render();
318 application.Render();
320 DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
321 DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
325 // cannot create dynamics world, log failure and exit
326 DALI_TEST_CHECK( false );
330 DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
331 Actor actor1(Actor::New());
332 actor1.EnableDynamics(bodyConfig);
333 Actor actor2(Actor::New());
334 actor2.EnableDynamics(bodyConfig);
336 DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) );
338 tet_infoline("UtcDaliDynamicsJointSetMotorForce");
339 joint.SetMotorForce(DynamicsJoint::LINEAR_X, 0.5f );
340 DALI_TEST_CHECK( true );
344 int UtcDaliDynamicsJointGetActor(void)
346 #if !defined(DYNAMICS_SUPPORT)
347 tet_infoline("No dynamics support compiled\n");
350 TestApplication application;
353 application.SendNotification();
354 application.Render();
355 application.Render();
357 DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
358 DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
362 // cannot create dynamics world, log failure and exit
363 DALI_TEST_CHECK( false );
367 DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New());
368 Actor actor1(Actor::New());
369 actor1.EnableDynamics(bodyConfig);
370 Actor actor2(Actor::New());
371 actor2.EnableDynamics(bodyConfig);
373 DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) );
375 tet_infoline("UtcDaliDynamicsJointGetActor");
376 DALI_TEST_CHECK( joint.GetActor(true) == actor1 && joint.GetActor(false) == actor2 );