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/public-api/dali-core.h>
22 #include <dali-test-suite-utils.h>
28 int UtcDaliDynamicsBodyConfigNew(void)
30 #if !defined(DYNAMICS_SUPPORT)
31 tet_infoline("No dynamics support compiled\n");
35 tet_infoline("UtcDaliDynamicsBodyConfigNew - DynamicsBodyConfig::New()");
37 TestApplication application;
40 application.SendNotification();
44 DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
45 DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
49 // cannot create dynamics world, log failure and exit
50 DALI_TEST_CHECK( false );
54 DynamicsBodyConfig config(DynamicsBodyConfig::New());
56 DALI_TEST_CHECK( config );
60 int UtcDaliDynamicsBodyConfigConstructor(void)
62 #if !defined(DYNAMICS_SUPPORT)
63 tet_infoline("No dynamics support compiled\n");
66 tet_infoline("UtcDaliDynamicsBodyConfigConstructor - DynamicsBodyConfig::DynamicsBodyConfig()");
68 TestApplication application;
71 application.SendNotification();
75 // Default constructor - create an uninitialized handle
76 DynamicsBodyConfig config;
78 DALI_TEST_CHECK( !config );
80 DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
81 DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
85 // cannot create dynamics world, log failure and exit
86 DALI_TEST_CHECK( false );
91 config = DynamicsBodyConfig::New();
93 DALI_TEST_CHECK( config );
97 int UtcDaliDynamicsBodyConfigType(void)
99 #if !defined(DYNAMICS_SUPPORT)
100 tet_infoline("No dynamics support compiled\n");
103 TestApplication application;
106 application.SendNotification();
107 application.Render();
108 application.Render();
110 DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
111 DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
115 // cannot create dynamics world, log failure and exit
116 DALI_TEST_CHECK( false );
120 DynamicsBodyConfig config(DynamicsBodyConfig::New());
122 tet_infoline("UtcDaliDynamicsBodyConfigType - DynamicsBodyConfig::GetType");
123 DALI_TEST_CHECK( DynamicsBodyConfig::RIGID == config.GetType() );
125 tet_infoline("UtcDaliDynamicsBodyConfigType - DynamicsBodyConfig::SetType(const BodyType)");
126 config.SetType( DynamicsBodyConfig::SOFT );
127 DALI_TEST_CHECK( DynamicsBodyConfig::SOFT == config.GetType() );
131 int UtcDaliDynamicsBodyConfigSetShape01(void)
133 #if !defined(DYNAMICS_SUPPORT)
134 tet_infoline("No dynamics support compiled\n");
137 tet_infoline("UtcDaliDynamicsBodyConfigSetShape01 - DynamicsBodyConfig::SetShape(const DynamicsShape::ShapeType,const Vector3&)");
139 TestApplication application;
142 application.SendNotification();
143 application.Render();
144 application.Render();
146 DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
147 DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
151 // cannot create dynamics world, log failure and exit
152 DALI_TEST_CHECK( false );
156 DynamicsBodyConfig config(DynamicsBodyConfig::New());
158 DALI_TEST_CHECK( DynamicsShape::CUBE == config.GetShape().GetType() );
160 const float radius(1.5f);
161 config.SetShape(DynamicsShape::SPHERE, Vector3(radius, 0.0f, 0.0f));
163 DALI_TEST_CHECK( DynamicsShape::SPHERE == config.GetShape().GetType() );
167 int UtcDaliDynamicsBodyConfigSetShape02(void)
169 #if !defined(DYNAMICS_SUPPORT)
170 tet_infoline("No dynamics support compiled\n");
173 tet_infoline("UtcDaliDynamicsBodyConfigSetShape02 - DynamicsBodyConfig::SetShape(DynamicsShape)");
175 TestApplication application;
178 application.SendNotification();
179 application.Render();
180 application.Render();
182 DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
183 DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
187 // cannot create dynamics world, log failure and exit
188 DALI_TEST_CHECK( false );
192 DynamicsBodyConfig config(DynamicsBodyConfig::New());
194 DALI_TEST_CHECK( DynamicsShape::CUBE == config.GetShape().GetType() );
196 const float radius(1.5f);
197 DynamicsShape shape(DynamicsShape::NewSphere(radius));
198 config.SetShape(shape);
200 DALI_TEST_CHECK( DynamicsShape::SPHERE == config.GetShape().GetType() );
204 int UtcDaliDynamicsBodyConfigGetShape(void)
206 #if !defined(DYNAMICS_SUPPORT)
207 tet_infoline("No dynamics support compiled\n");
210 tet_infoline("UtcDaliDynamicsBodyConfigGetShape - DynamicsBodyConfig::GetShape");
212 TestApplication application;
215 application.SendNotification();
216 application.Render();
217 application.Render();
219 DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
220 DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
224 // cannot create dynamics world, log failure and exit
225 DALI_TEST_CHECK( false );
229 DynamicsBodyConfig config(DynamicsBodyConfig::New());
231 DALI_TEST_CHECK( DynamicsShape::CUBE == config.GetShape().GetType() );
235 int UtcDaliDynamicsBodyConfigMass(void)
237 #if !defined(DYNAMICS_SUPPORT)
238 tet_infoline("No dynamics support compiled\n");
241 TestApplication application;
244 application.SendNotification();
245 application.Render();
246 application.Render();
248 const float testMass = 1.23f;
250 DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
251 DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
255 // cannot create dynamics world, log failure and exit
256 DALI_TEST_CHECK( false );
260 DynamicsBodyConfig config(DynamicsBodyConfig::New());
261 config.SetMass(testMass);
263 tet_infoline("UtcDaliDynamicsBodyConfigMass - DynamicsBodyConfig::GetMass");
264 DALI_TEST_EQUALS( testMass, config.GetMass(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
266 tet_infoline("UtcDaliDynamicsBodyConfigMass - DynamicsBodyConfig::SetMass");
267 const float mass = config.GetMass() + 0.1f;
268 config.SetMass(mass);
269 DALI_TEST_EQUALS( mass, config.GetMass(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
273 int UtcDaliDynamicsBodyConfigElasticity(void)
275 #if !defined(DYNAMICS_SUPPORT)
276 tet_infoline("No dynamics support compiled\n");
279 TestApplication application;
282 application.SendNotification();
283 application.Render();
284 application.Render();
286 const float testElasticity = 0.87f;
288 DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
289 DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
293 // cannot create dynamics world, log failure and exit
294 DALI_TEST_CHECK( false );
298 DynamicsBodyConfig config(DynamicsBodyConfig::New());
299 config.SetElasticity(testElasticity);
301 tet_infoline("UtcDaliDynamicsBodyConfigElasticity- DynamicsBodyConfig::GetElasticity");
302 DALI_TEST_EQUALS( testElasticity, config.GetElasticity(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
304 tet_infoline("UtcDaliDynamicsBodyConfigElasticity - DynamicsBodyConfig::SetElasticity");
305 const float elasticity = config.GetElasticity() + 0.1f;
306 config.SetElasticity(elasticity);
307 DALI_TEST_EQUALS( elasticity, config.GetElasticity(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
311 int UtcDaliDynamicsBodyConfigFriction(void)
313 #if !defined(DYNAMICS_SUPPORT)
314 tet_infoline("No dynamics support compiled\n");
317 TestApplication application;
320 application.SendNotification();
321 application.Render();
322 application.Render();
324 const float testFriction= 0.87f;
326 DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
327 DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
331 // cannot create dynamics world, log failure and exit
332 DALI_TEST_CHECK( false );
336 DynamicsBodyConfig config(DynamicsBodyConfig::New());
337 config.SetFriction(testFriction);
339 tet_infoline("UtcDaliDynamicsBodyConfigFriction - DynamicsBodyConfig::GetFriction");
340 DALI_TEST_EQUALS( testFriction, config.GetFriction(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
342 tet_infoline("UtcDaliDynamicsBodyConfigFriction - DynamicsBodyConfig::SetFriction");
343 const float friction = config.GetFriction() + 0.1f;
344 config.SetFriction(friction);
345 DALI_TEST_EQUALS( friction, config.GetFriction(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
349 int UtcDaliDynamicsBodyConfigLinearDamping(void)
351 #if !defined(DYNAMICS_SUPPORT)
352 tet_infoline("No dynamics support compiled\n");
355 TestApplication application;
358 application.SendNotification();
359 application.Render();
360 application.Render();
362 const float testDamping = 0.123f;
364 DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
365 DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
369 // cannot create dynamics world, log failure and exit
370 DALI_TEST_CHECK( false );
374 DynamicsBodyConfig config(DynamicsBodyConfig::New());
375 config.SetLinearDamping(testDamping);
377 tet_infoline("UtcDaliDynamicsBodyConfigLinearDamping- DynamicsBodyConfig::GetLinearDamping");
378 DALI_TEST_EQUALS( testDamping, config.GetLinearDamping(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
380 tet_infoline("UtcDaliDynamicsBodyConfigLinearDamping - DynamicsBodyConfig::SetLinearDamping");
381 const float damping = config.GetLinearDamping() + 0.1f;
382 config.SetLinearDamping(damping);
383 DALI_TEST_EQUALS( damping, config.GetLinearDamping(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
387 int UtcDaliDynamicsBodyConfigAngularDamping(void)
389 #if !defined(DYNAMICS_SUPPORT)
390 tet_infoline("No dynamics support compiled\n");
393 TestApplication application;
396 application.SendNotification();
397 application.Render();
398 application.Render();
400 const float testDamping = 0.123f;
402 DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
403 DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
407 // cannot create dynamics world, log failure and exit
408 DALI_TEST_CHECK( false );
412 DynamicsBodyConfig config(DynamicsBodyConfig::New());
413 config.SetAngularDamping(testDamping);
415 tet_infoline("UtcDaliDynamicsBodyConfigAngularDamping- DynamicsBodyConfig::GetAngularDamping");
416 DALI_TEST_EQUALS( testDamping, config.GetAngularDamping(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
418 tet_infoline("UtcDaliDynamicsBodyConfigAngularDamping - DynamicsBodyConfig::SetAngularDamping");
419 const float damping = config.GetAngularDamping() + 0.1f;
420 config.SetAngularDamping(damping);
421 DALI_TEST_EQUALS( damping, config.GetAngularDamping(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
425 int UtcDaliDynamicsBodyConfigLinearSleepVelocity(void)
427 #if !defined(DYNAMICS_SUPPORT)
428 tet_infoline("No dynamics support compiled\n");
431 TestApplication application;
434 application.SendNotification();
435 application.Render();
436 application.Render();
438 const float testSleepVelocity = 0.123f;
440 DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
441 DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
445 // cannot create dynamics world, log failure and exit
446 DALI_TEST_CHECK( false );
450 DynamicsBodyConfig config(DynamicsBodyConfig::New());
451 config.SetLinearSleepVelocity(testSleepVelocity);
453 tet_infoline("UtcDaliDynamicsBodyConfigLinearSleepVelocity - DynamicsBodyConfig::GetLinearSleepVelocity");
454 DALI_TEST_EQUALS( testSleepVelocity, config.GetLinearSleepVelocity(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
456 tet_infoline("UtcDaliDynamicsBodyConfigLinearSleepVelocity - DynamicsBodyConfig::SetLinearSleepVelocity");
457 const float sleepVelocity = config.GetLinearSleepVelocity() + 0.1f;
458 config.SetLinearSleepVelocity(sleepVelocity);
459 DALI_TEST_EQUALS( sleepVelocity, config.GetLinearSleepVelocity(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
463 int UtcDaliDynamicsBodyConfigAngularSleepVelocity(void)
465 #if !defined(DYNAMICS_SUPPORT)
466 tet_infoline("No dynamics support compiled\n");
469 TestApplication application;
472 application.SendNotification();
473 application.Render();
474 application.Render();
476 const float testSleepVelocity = 0.123f;
478 DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
479 DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
483 // cannot create dynamics world, log failure and exit
484 DALI_TEST_CHECK( false );
488 DynamicsBodyConfig config(DynamicsBodyConfig::New());
489 config.SetAngularSleepVelocity(testSleepVelocity);
491 tet_infoline("UtcDaliDynamicsBodyConfigAngularSleepVelocity - DynamicsBodyConfig::GetAngularSleepVelocity");
492 DALI_TEST_EQUALS( testSleepVelocity, config.GetAngularSleepVelocity(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
494 tet_infoline("UtcDaliDynamicsBodyConfigAngularSleepVelocity - DynamicsBodyConfig::SetAngularSleepVelocity");
495 const float sleepVelocity = config.GetAngularSleepVelocity() + 0.1f;
496 config.SetAngularSleepVelocity(sleepVelocity);
497 DALI_TEST_EQUALS( sleepVelocity, config.GetAngularSleepVelocity(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
501 int UtcDaliDynamicsBodyConfigCollisionGroup(void)
503 #if !defined(DYNAMICS_SUPPORT)
504 tet_infoline("No dynamics support compiled\n");
507 TestApplication application;
510 application.SendNotification();
511 application.Render();
512 application.Render();
514 const short int testGroup = 0x1234;
516 DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
517 DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
521 // cannot create dynamics world, log failure and exit
522 DALI_TEST_CHECK( false );
526 DynamicsBodyConfig config(DynamicsBodyConfig::New());
527 config.SetCollisionGroup(testGroup);
529 tet_infoline("UtcDaliDynamicsBodyConfigCollisionGroup- DynamicsBodyConfig::GetCollisionGroup");
530 DALI_TEST_EQUALS( testGroup, config.GetCollisionGroup(), TEST_LOCATION );
532 tet_infoline("UtcDaliDynamicsBodyConfigCollisionGroup - DynamicsBodyConfig::SetCollisionGroup");
533 const short int group = config.GetCollisionGroup() + 1;
534 config.SetCollisionGroup(group);
535 DALI_TEST_EQUALS( group, config.GetCollisionGroup(), TEST_LOCATION );
539 int UtcDaliDynamicsBodyConfigCollisionMask(void)
541 #if !defined(DYNAMICS_SUPPORT)
542 tet_infoline("No dynamics support compiled\n");
545 TestApplication application;
548 application.SendNotification();
549 application.Render();
550 application.Render();
552 const short int testMask = 0x7ffe;
554 DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
555 DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
559 // cannot create dynamics world, log failure and exit
560 DALI_TEST_CHECK( false );
564 DynamicsBodyConfig config(DynamicsBodyConfig::New());
565 config.SetCollisionMask(testMask);
567 tet_infoline("UtcDaliDynamicsBodyConfigCollisionMask- DynamicsBodyConfig::GetCollisionMask");
568 DALI_TEST_EQUALS( testMask, config.GetCollisionMask(), TEST_LOCATION );
570 tet_infoline("UtcDaliDynamicsBodyConfigCollisionMask - DynamicsBodyConfig::SetCollisionMask");
571 const short int mask = config.GetCollisionMask() + 1;
572 config.SetCollisionMask(mask);
573 DALI_TEST_EQUALS( mask, config.GetCollisionMask(), TEST_LOCATION );
577 int UtcDaliDynamicsBodyConfigAnchorHardness(void)
579 #if !defined(DYNAMICS_SUPPORT)
580 tet_infoline("No dynamics support compiled\n");
583 TestApplication application;
586 application.SendNotification();
587 application.Render();
588 application.Render();
590 const float testHardness = 0.87f;
592 DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
593 DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
597 // cannot create dynamics world, log failure and exit
598 DALI_TEST_CHECK( false );
602 DynamicsBodyConfig config(DynamicsBodyConfig::New());
603 config.SetAnchorHardness(testHardness);
605 tet_infoline("UtcDaliDynamicsBodyConfigAnchorHardness - DynamicsBodyConfig::GetAnchorHardness");
606 DALI_TEST_EQUALS( testHardness, config.GetAnchorHardness(), Math::MACHINE_EPSILON_0, TEST_LOCATION );
608 tet_infoline("UtcDaliDynamicsBodyConfigAnchorHardness - DynamicsBodyConfig::SetAnchorHardness");
609 const float hardness = config.GetAnchorHardness() + 0.1f;
610 config.SetAnchorHardness(hardness);
611 DALI_TEST_EQUALS( hardness, config.GetAnchorHardness(), Math::MACHINE_EPSILON_1, TEST_LOCATION );
615 int UtcDaliDynamicsBodyConfigVolumeConservation(void)
617 #if !defined(DYNAMICS_SUPPORT)
618 tet_infoline("No dynamics support compiled\n");
621 tet_infoline("UtcDaliDynamicsBodyConfigVolumeConservation");
623 TestApplication application;
626 application.SendNotification();
627 application.Render();
628 application.Render();
630 DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
631 DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
635 // cannot create dynamics world, log failure and exit
636 DALI_TEST_CHECK( false );
640 DynamicsBodyConfig config(DynamicsBodyConfig::New());
642 const float conservation = config.GetVolumeConservation() + 0.1f;
643 config.SetVolumeConservation(conservation);
644 DALI_TEST_EQUALS( conservation, config.GetVolumeConservation(), Math::MACHINE_EPSILON_1, TEST_LOCATION );
648 int UtcDaliDynamicsBodyConfigShapeConservation(void)
650 #if !defined(DYNAMICS_SUPPORT)
651 tet_infoline("No dynamics support compiled\n");
654 tet_infoline("UtcDaliDynamicsBodyConfigShapeConservation");
656 TestApplication application;
659 application.SendNotification();
660 application.Render();
661 application.Render();
663 DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
664 DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
668 // cannot create dynamics world, log failure and exit
669 DALI_TEST_CHECK( false );
673 DynamicsBodyConfig config(DynamicsBodyConfig::New());
675 const float conservation = config.GetShapeConservation() + 0.1f;
676 config.SetShapeConservation(conservation);
677 DALI_TEST_EQUALS( conservation, config.GetShapeConservation(), Math::MACHINE_EPSILON_1, TEST_LOCATION );