UTC public API updates: stage.h 61/38361/16
authorTom Robinson <tom.robinson@samsung.com>
Fri, 17 Apr 2015 13:32:11 +0000 (14:32 +0100)
committerTom Robinson <tom.robinson@samsung.com>
Wed, 3 Jun 2015 10:32:01 +0000 (03:32 -0700)
Includes build fix for utc dynamics tests.

Includes moving Dynamics API from stage.h to dynamics-world.h in the form of static creator, destroyer and getter.

Change-Id: I5c44e47ff6572144067c960ee8c88896a7b3e193

29 files changed:
.gitignore
automated-tests/src/dali-internal/utc-Dali-DynamicsBodyConfig.cpp
automated-tests/src/dali-internal/utc-Dali-DynamicsShape.cpp
automated-tests/src/dali-internal/utc-Dali-DynamicsWorld.cpp
automated-tests/src/dali/CMakeLists.txt [deleted file]
automated-tests/src/dali/CMakeLists.txt.in [new file with mode: 0644]
automated-tests/src/dali/utc-Dali-Stage.cpp
build/tizen/configure.ac
dali/devel-api/dynamics/dynamics-world.cpp
dali/devel-api/dynamics/dynamics-world.h
dali/internal/event/common/stage-impl.cpp
dali/internal/event/common/stage-impl.h
dali/internal/event/common/thread-local-storage.cpp
dali/internal/event/common/thread-local-storage.h
dali/internal/event/dynamics/dynamics-body-impl.cpp
dali/internal/event/dynamics/dynamics-capsule-shape-impl.cpp
dali/internal/event/dynamics/dynamics-cone-shape-impl.cpp
dali/internal/event/dynamics/dynamics-cube-shape-impl.cpp
dali/internal/event/dynamics/dynamics-cylinder-shape-impl.cpp
dali/internal/event/dynamics/dynamics-joint-impl.cpp
dali/internal/event/dynamics/dynamics-mesh-shape-impl.cpp
dali/internal/event/dynamics/dynamics-notifier.cpp [deleted file]
dali/internal/event/dynamics/dynamics-notifier.h
dali/internal/event/dynamics/dynamics-sphere-shape-impl.cpp
dali/internal/event/dynamics/dynamics-world-impl.cpp
dali/internal/event/dynamics/dynamics-world-impl.h
dali/internal/file.list
dali/public-api/common/stage.cpp
dali/public-api/common/stage.h

index d1d20c1a072c3456042e8f90cf16617787537fbc..4143a881bdce02c9e6fb0c05b989f7b419878245 100644 (file)
@@ -33,6 +33,7 @@ BROWSE
 *.creator
 *.creator.user
 /automated-tests/CMakeLists.txt
+/automated-tests/src/dali/CMakeLists.txt
 /docs/generated/*
 /build/tizen/doc
 /build/tizen/.cov
index 30ae43402b39319b56e8382468a481931a9c8231..e01c9c5b5f08ecaa5190fdb0c60cae83d4fc16eb 100644 (file)
@@ -41,8 +41,8 @@ int UtcDaliDynamicsBodyConfigNew(void)
   application.Render();
   application.Render();
 
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( !world )
   {
@@ -77,8 +77,8 @@ int UtcDaliDynamicsBodyConfigConstructor(void)
 
   DALI_TEST_CHECK( !config );
 
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( !world )
   {
@@ -107,8 +107,8 @@ int UtcDaliDynamicsBodyConfigType(void)
   application.Render();
   application.Render();
 
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( !world )
   {
@@ -143,8 +143,8 @@ int UtcDaliDynamicsBodyConfigSetShape01(void)
   application.Render();
   application.Render();
 
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( !world )
   {
@@ -179,8 +179,8 @@ int UtcDaliDynamicsBodyConfigSetShape02(void)
   application.Render();
   application.Render();
 
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( !world )
   {
@@ -216,8 +216,8 @@ int UtcDaliDynamicsBodyConfigGetShape(void)
   application.Render();
   application.Render();
 
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( !world )
   {
@@ -247,8 +247,8 @@ int UtcDaliDynamicsBodyConfigMass(void)
 
   const float testMass = 1.23f;
 
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( !world )
   {
@@ -285,8 +285,8 @@ int UtcDaliDynamicsBodyConfigElasticity(void)
 
   const float testElasticity = 0.87f;
 
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( !world )
   {
@@ -323,8 +323,8 @@ int UtcDaliDynamicsBodyConfigFriction(void)
 
   const float testFriction= 0.87f;
 
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( !world )
   {
@@ -361,8 +361,8 @@ int UtcDaliDynamicsBodyConfigLinearDamping(void)
 
   const float testDamping = 0.123f;
 
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( !world )
   {
@@ -399,8 +399,8 @@ int UtcDaliDynamicsBodyConfigAngularDamping(void)
 
   const float testDamping = 0.123f;
 
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( !world )
   {
@@ -437,8 +437,8 @@ int UtcDaliDynamicsBodyConfigLinearSleepVelocity(void)
 
   const float testSleepVelocity = 0.123f;
 
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( !world )
   {
@@ -475,8 +475,8 @@ int UtcDaliDynamicsBodyConfigAngularSleepVelocity(void)
 
   const float testSleepVelocity = 0.123f;
 
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( !world )
   {
@@ -513,8 +513,8 @@ int UtcDaliDynamicsBodyConfigCollisionGroup(void)
 
   const short int testGroup = 0x1234;
 
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( !world )
   {
@@ -551,8 +551,8 @@ int UtcDaliDynamicsBodyConfigCollisionMask(void)
 
   const short int testMask = 0x7ffe;
 
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( !world )
   {
@@ -589,8 +589,8 @@ int UtcDaliDynamicsBodyConfigAnchorHardness(void)
 
   const float testHardness = 0.87f;
 
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( !world )
   {
@@ -627,8 +627,8 @@ int UtcDaliDynamicsBodyConfigVolumeConservation(void)
   application.Render();
   application.Render();
 
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( !world )
   {
@@ -660,8 +660,8 @@ int UtcDaliDynamicsBodyConfigShapeConservation(void)
   application.Render();
   application.Render();
 
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( !world )
   {
index 43f723db15042fa7b4e75424227c128846ea48d0..3acdfc1d000219e12d9c80d004e00368c16d62a3 100644 (file)
@@ -39,8 +39,8 @@ int UtcDaliDynamicsShapeConstructor(void)
   application.Render();
   application.Render();
 
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( world )
   {
@@ -78,8 +78,8 @@ int UtcDaliDynamicsShapeNewCapsule(void)
   application.Render();
   application.Render();
 
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( world )
   {
@@ -113,8 +113,8 @@ int UtcDaliDynamicsShapeNewCone(void)
   application.Render();
   application.Render();
 
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( world )
   {
@@ -147,8 +147,8 @@ int UtcDaliDynamicsShapeNewCube(void)
   application.Render();
   application.Render();
 
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( world )
   {
@@ -180,8 +180,8 @@ int UtcDaliDynamicsShapeNewCylinder(void)
   application.Render();
   application.Render();
 
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( world )
   {
@@ -213,8 +213,8 @@ int UtcDaliDynamicsShapeNewMesh(void)
   application.Render();
   application.Render();
 
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( world )
   {
@@ -246,8 +246,8 @@ int UtcDaliDynamicsShapeNewSphere(void)
   application.Render();
   application.Render();
 
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( world )
   {
@@ -279,8 +279,8 @@ int UtcDaliDynamicsShapeGetType(void)
   application.Render();
   application.Render();
 
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( world )
   {
index f567f9e53aa8ce0fd58334fcb89743138a917989..56120f0989d6e0346320e024a15ac935e2de595c 100644 (file)
 
 using namespace Dali;
 
-int UtcDaliStageInitializeDynamics(void)
+// Note: dali-core needs to be configured and built with --enable-dynamics for these tests to run.
+
+int UtcDaliDynamicsWorldConstructor(void)
 {
 #if !defined(DYNAMICS_SUPPORT)
   tet_infoline("No dynamics support compiled\n");
   return 0;
 #endif
+  tet_infoline("UtcDaliDynamicsWorldConstructor - DynamicsWorld::DynamicsWorld");
+
   TestApplication application;
 
+  // start up
+  application.SendNotification();
+  application.Render();
+  application.Render();
+
+  // Default constructor - create an uninitialized handle
+  DynamicsWorld world;
+  DALI_TEST_CHECK( !world );
+
+  // initialize handle
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  world =  DynamicsWorld::GetInstance( worldConfig );
+
+  DALI_TEST_CHECK( world );
+  END_TEST;
+}
+
+int UtcDaliDynamicsWorldGetInstanceP(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+  tet_infoline( "No dynamics support compiled\n" );
+  return 0;
+#endif
+  TestApplication app;
   Stage stage = Stage::GetCurrent();
-  TraceCallStack& trace = application.GetPlatform().GetTrace();
+  TraceCallStack& trace = app.GetPlatform().GetTrace();
   trace.Enable(true);
-  DALI_TEST_CHECK( stage.InitializeDynamics( DynamicsWorldConfig::New() ) );
+
+  DynamicsWorldConfig config = DynamicsWorldConfig::New();
+
+  bool asserted = false;
+  try
+  {
+    DALI_TEST_CHECK( DynamicsWorld::GetInstance( config ) );
+  }
+  catch( Dali::DaliException& e )
+  {
+    DALI_TEST_PRINT_ASSERT( e );
+    asserted = true;
+  }
+  DALI_TEST_CHECK( !asserted );
+
   DALI_TEST_CHECK( trace.FindMethod( "GetDynamicsFactory" ) );
   DALI_TEST_CHECK( trace.FindMethod( "DynamicsFactory::InitializeDynamics" ) );
+
   END_TEST;
 }
 
-int UtcDaliStageGetDynamicsWorld(void)
+int UtcDaliDynamicsWorldGetInstanceN(void)
 {
-  TestApplication application;
+#if !defined(DYNAMICS_SUPPORT)
+  tet_infoline( "No dynamics support compiled\n" );
+  return 0;
+#endif
+  TestApplication app;
 
-  Stage stage = Stage::GetCurrent();
+  DynamicsWorldConfig config;
+
+  // Check that creating a DynamicsWorld instance without a valid config causes an assert.
+  bool asserted = false;
+  try
+  {
+    DynamicsWorld::GetInstance( config );
+  }
+  catch( Dali::DaliException& e )
+  {
+    DALI_TEST_PRINT_ASSERT( e );
+    DALI_TEST_ASSERT( e, "object && \"DynamicsWorldConfig object is uninitialized!\"", TEST_LOCATION );
+    asserted = true;
+  }
+  DALI_TEST_CHECK( asserted );
 
-  DALI_TEST_CHECK( !stage.GetDynamicsWorld() );
   END_TEST;
 }
 
-int UtcDaliStageTerminateDynamics(void)
+int UtcDaliDynamicsWorldGetP(void)
 {
-  TestApplication application;
+#if !defined(DYNAMICS_SUPPORT)
+  tet_infoline( "No dynamics support compiled\n" );
+  return 0;
+#endif
+  TestApplication app;
 
-  Stage stage = Stage::GetCurrent();
+  DynamicsWorldConfig config = DynamicsWorldConfig::New();
 
-  stage.TerminateDynamics();
+  bool asserted = false;
+  try
+  {
+    DynamicsWorld::GetInstance( config );
+    DynamicsWorld world = DynamicsWorld::Get();
+    DALI_TEST_CHECK( world );
+  }
+  catch( Dali::DaliException& e )
+  {
+    DALI_TEST_PRINT_ASSERT( e );
+    asserted = true;
+  }
+  DALI_TEST_CHECK( !asserted );
 
-  DALI_TEST_CHECK( !stage.GetDynamicsWorld() );
   END_TEST;
 }
 
-int UtcDaliDynamicsWorldConstructor(void)
+int UtcDaliDynamicsWorldGetN(void)
 {
 #if !defined(DYNAMICS_SUPPORT)
-  tet_infoline("No dynamics support compiled\n");
+  tet_infoline( "No dynamics support compiled\n" );
   return 0;
 #endif
-  tet_infoline("UtcDaliDynamicsWorldConstructor - DynamicsWorld::DynamicsWorld");
+  TestApplication app;
 
-  TestApplication application;
-
-  // start up
-  application.SendNotification();
-  application.Render();
-  application.Render();
+  bool asserted = false;
+  try
+  {
+    DynamicsWorld::Get();
+  }
+  catch( Dali::DaliException& e )
+  {
+    DALI_TEST_PRINT_ASSERT( e );
+    DALI_TEST_ASSERT( e, "dynamicsWorld && \"DynamicsWorld doesn't exist\"", TEST_LOCATION );
+    asserted = true;
+  }
+  DALI_TEST_CHECK( asserted );
 
-  // Default constructor - create an uninitialized handle
-  DynamicsWorld world;
-  DALI_TEST_CHECK( !world );
+  END_TEST;
+}
 
-  // initialize handle
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  world = Stage::GetCurrent().InitializeDynamics(worldConfig);
+int UtcDaliDynamicsWorldDestroyInstanceP(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+  tet_infoline( "No dynamics support compiled\n" );
+  return 0;
+#endif
+  TestApplication app;
 
+  DynamicsWorldConfig config = DynamicsWorldConfig::New();
+  DynamicsWorld world = DynamicsWorld::GetInstance( config );
   DALI_TEST_CHECK( world );
+  DynamicsWorld::DestroyInstance();
+
+  // After destroying the instance, check we assert when trying to get the instance,
+  // to prove that it's been removed correctly.
+  bool asserted = false;
+  try
+  {
+    DynamicsWorld::Get();
+  }
+  catch( Dali::DaliException& e )
+  {
+    DALI_TEST_PRINT_ASSERT( e );
+    DALI_TEST_ASSERT( e, "dynamicsWorld && \"DynamicsWorld doesn't exist\"", TEST_LOCATION );
+    asserted = true;
+  }
+  DALI_TEST_CHECK( asserted );
+
+  END_TEST;
+}
+
+int UtcDaliDynamicsWorldDestroyInstanceN(void)
+{
+#if !defined(DYNAMICS_SUPPORT)
+  tet_infoline( "No dynamics support compiled\n" );
+  return 0;
+#endif
+  TestApplication app;
+
+  // Check that calling DestroyInstance() when there is no instance is safe.
+  bool asserted = false;
+  try
+  {
+    DynamicsWorld::DestroyInstance();
+  }
+  catch( Dali::DaliException& e )
+  {
+    DALI_TEST_PRINT_ASSERT( e );
+    asserted = true;
+  }
+  DALI_TEST_CHECK( !asserted );
+
   END_TEST;
 }
 
@@ -107,8 +234,8 @@ int UtcDaliDynamicsWorldGravity(void)
 
   const Vector3 gravity(1.0f, 2.0f, 3.0f);
 
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( !world )
   {
@@ -148,8 +275,8 @@ int UtcDaliDynamicsWorldDebugDrawMode(void)
   application.Render();
 
   const Vector3 gravity(1.0f, 2.0f, 3.0f);
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( !world )
   {
@@ -169,6 +296,7 @@ int UtcDaliDynamicsWorldDebugDrawMode(void)
   application.Render();
 
   DALI_TEST_CHECK( trace.FindMethod( "DynamicsWorld::SetDebugDrawMode" ) );
+  DALI_TEST_CHECK( trace.FindMethod( "DynamicsWorld::SetGravity" ) );
 
   tet_infoline("UtcDaliDynamicsWorldDebugDrawMode - DynamicsWorld::GetDebugDrawMode");
   DALI_TEST_CHECK(mode == world.GetDebugDrawMode());
@@ -189,8 +317,8 @@ int UtcDaliDynamicsWorldRootActor(void)
   application.Render();
 
   const Vector3 gravity(1.0f, 2.0f, 3.0f);
-  DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New());
-  DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) );
+  DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() );
+  DynamicsWorld world( DynamicsWorld::GetInstance( worldConfig ) );
 
   if( !world )
   {
diff --git a/automated-tests/src/dali/CMakeLists.txt b/automated-tests/src/dali/CMakeLists.txt
deleted file mode 100644 (file)
index 4bd48e4..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-SET(PKG_NAME "dali")
-
-SET(EXEC_NAME "tct-${PKG_NAME}-core")
-SET(RPM_NAME "core-${PKG_NAME}-tests")
-
-SET(CAPI_LIB "dali")
-
-SET(TC_SOURCES
-        utc-Dali-Actor.cpp
-        utc-Dali-AlphaFunction.cpp
-        utc-Dali-AngleAxis.cpp
-        utc-Dali-Animation.cpp
-        utc-Dali-Any.cpp
-        utc-Dali-BaseHandle.cpp
-        utc-Dali-BufferImage.cpp
-        utc-Dali-CameraActor.cpp
-        utc-Dali-Constraint.cpp
-        utc-Dali-ConstraintFunction.cpp
-        utc-Dali-Constraints.cpp
-        utc-Dali-ConstraintSource.cpp
-        utc-Dali-ConnectionTracker.cpp
-        utc-Dali-CustomActor.cpp
-        utc-Dali-Degree.cpp
-        utc-Dali-EncodedBufferImage.cpp
-        utc-Dali-FrameBufferImage.cpp
-        utc-Dali-Gesture.cpp
-        utc-Dali-GestureDetector.cpp
-        utc-Dali-Handle.cpp
-        utc-Dali-HoverProcessing.cpp
-        utc-Dali-Image.cpp
-        utc-Dali-ImageActor.cpp
-        utc-Dali-IntrusivePtr.cpp
-        utc-Dali-KeyEvent.cpp
-        utc-Dali-Layer.cpp
-        utc-Dali-LocklessBuffer.cpp
-        utc-Dali-LongPressGesture.cpp
-        utc-Dali-LongPressGestureDetector.cpp
-        utc-Dali-MathUtils.cpp
-        utc-Dali-Matrix.cpp
-        utc-Dali-Matrix3.cpp
-        utc-Dali-NativeImage.cpp
-        utc-Dali-NinePatchImages.cpp
-        utc-Dali-ObjectRegistry.cpp
-        utc-Dali-PanGesture.cpp
-        utc-Dali-PanGestureDetector.cpp
-        utc-Dali-Path.cpp
-        utc-Dali-PinchGesture.cpp
-        utc-Dali-PinchGestureDetector.cpp
-        utc-Dali-Pixel.cpp
-        utc-Dali-PropertyMap.cpp
-        utc-Dali-PropertyArray.cpp
-        utc-Dali-PropertyNotification.cpp
-        utc-Dali-PropertyTypes.cpp
-        utc-Dali-PropertyValue.cpp
-        utc-Dali-Quaternion.cpp
-        utc-Dali-Radian.cpp
-        utc-Dali-Random.cpp
-        utc-Dali-Rect.cpp
-        utc-Dali-RenderTask.cpp
-        utc-Dali-RenderTaskList.cpp
-        utc-Dali-RenderableActor.cpp
-        utc-Dali-ResourceImage.cpp
-        utc-Dali-ShaderEffect.cpp
-        utc-Dali-SignalTemplatesFunctors.cpp
-        utc-Dali-SignalTemplates.cpp
-        utc-Dali-Stage.cpp
-        utc-Dali-TapGesture.cpp
-        utc-Dali-TapGestureDetector.cpp
-        utc-Dali-TouchEventCombiner.cpp
-        utc-Dali-TouchProcessing.cpp
-        utc-Dali-TypeRegistry.cpp
-        utc-Dali-Uint16Pair.cpp
-        utc-Dali-Vector.cpp
-        utc-Dali-Vector2.cpp
-        utc-Dali-Vector3.cpp
-        utc-Dali-Vector4.cpp
-        utc-Dali-WheelEvent.cpp
-)
-
-LIST(APPEND TC_SOURCES
-        dali-test-suite-utils/test-harness.cpp
-        dali-test-suite-utils/dali-test-suite-utils.cpp
-        dali-test-suite-utils/test-application.cpp
-        dali-test-suite-utils/test-dynamics.cpp
-        dali-test-suite-utils/test-gesture-manager.cpp
-        dali-test-suite-utils/test-gl-abstraction.cpp
-        dali-test-suite-utils/test-gl-sync-abstraction.cpp
-        dali-test-suite-utils/test-native-image.cpp
-        dali-test-suite-utils/test-platform-abstraction.cpp
-        dali-test-suite-utils/test-render-controller.cpp
-        dali-test-suite-utils/test-trace-call-stack.cpp
-)
-
-PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
-     dali-core
-)
-
-SET(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -O0 -ggdb --coverage -Wall -Werror=return-type")
-
-FOREACH(directory ${${CAPI_LIB}_LIBRARY_DIRS})
-    SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -L${directory}")
-ENDFOREACH(directory ${CAPI_LIB_LIBRARY_DIRS})
-
-INCLUDE_DIRECTORIES(
-    ../../../
-    ${${CAPI_LIB}_INCLUDE_DIRS}
-    dali-test-suite-utils
-)
-
-ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.cpp ${TC_SOURCES})
-TARGET_LINK_LIBRARIES(${EXEC_NAME}
-    ${${CAPI_LIB}_LIBRARIES}
-)
-
-INSTALL(PROGRAMS ${EXEC_NAME}
-    DESTINATION ${BIN_DIR}/${EXEC_NAME}
-)
diff --git a/automated-tests/src/dali/CMakeLists.txt.in b/automated-tests/src/dali/CMakeLists.txt.in
new file mode 100644 (file)
index 0000000..0598b6f
--- /dev/null
@@ -0,0 +1,117 @@
+SET(PKG_NAME "dali")
+
+SET(EXEC_NAME "tct-${PKG_NAME}-core")
+SET(RPM_NAME "core-${PKG_NAME}-tests")
+
+SET(CAPI_LIB "dali")
+
+SET(TC_SOURCES
+        utc-Dali-Actor.cpp
+        utc-Dali-AlphaFunction.cpp
+        utc-Dali-AngleAxis.cpp
+        utc-Dali-Animation.cpp
+        utc-Dali-Any.cpp
+        utc-Dali-BaseHandle.cpp
+        utc-Dali-BufferImage.cpp
+        utc-Dali-CameraActor.cpp
+        utc-Dali-Constraint.cpp
+        utc-Dali-ConstraintFunction.cpp
+        utc-Dali-Constraints.cpp
+        utc-Dali-ConstraintSource.cpp
+        utc-Dali-ConnectionTracker.cpp
+        utc-Dali-CustomActor.cpp
+        utc-Dali-Degree.cpp
+        utc-Dali-EncodedBufferImage.cpp
+        utc-Dali-FrameBufferImage.cpp
+        utc-Dali-Gesture.cpp
+        utc-Dali-GestureDetector.cpp
+        utc-Dali-Handle.cpp
+        utc-Dali-HoverProcessing.cpp
+        utc-Dali-Image.cpp
+        utc-Dali-ImageActor.cpp
+        utc-Dali-IntrusivePtr.cpp
+        utc-Dali-KeyEvent.cpp
+        utc-Dali-Layer.cpp
+        utc-Dali-LocklessBuffer.cpp
+        utc-Dali-LongPressGesture.cpp
+        utc-Dali-LongPressGestureDetector.cpp
+        utc-Dali-MathUtils.cpp
+        utc-Dali-Matrix.cpp
+        utc-Dali-Matrix3.cpp
+        utc-Dali-NativeImage.cpp
+        utc-Dali-NinePatchImages.cpp
+        utc-Dali-ObjectRegistry.cpp
+        utc-Dali-PanGesture.cpp
+        utc-Dali-PanGestureDetector.cpp
+        utc-Dali-Path.cpp
+        utc-Dali-PinchGesture.cpp
+        utc-Dali-PinchGestureDetector.cpp
+        utc-Dali-Pixel.cpp
+        utc-Dali-PropertyMap.cpp
+        utc-Dali-PropertyArray.cpp
+        utc-Dali-PropertyNotification.cpp
+        utc-Dali-PropertyTypes.cpp
+        utc-Dali-PropertyValue.cpp
+        utc-Dali-Quaternion.cpp
+        utc-Dali-Radian.cpp
+        utc-Dali-Random.cpp
+        utc-Dali-Rect.cpp
+        utc-Dali-RenderTask.cpp
+        utc-Dali-RenderTaskList.cpp
+        utc-Dali-RenderableActor.cpp
+        utc-Dali-ResourceImage.cpp
+        utc-Dali-ShaderEffect.cpp
+        utc-Dali-SignalTemplatesFunctors.cpp
+        utc-Dali-SignalTemplates.cpp
+        utc-Dali-Stage.cpp
+        utc-Dali-TapGesture.cpp
+        utc-Dali-TapGestureDetector.cpp
+        utc-Dali-TouchEventCombiner.cpp
+        utc-Dali-TouchProcessing.cpp
+        utc-Dali-TypeRegistry.cpp
+        utc-Dali-Uint16Pair.cpp
+        utc-Dali-Vector.cpp
+        utc-Dali-Vector2.cpp
+        utc-Dali-Vector3.cpp
+        utc-Dali-Vector4.cpp
+        utc-Dali-WheelEvent.cpp
+)
+
+LIST(APPEND TC_SOURCES
+        dali-test-suite-utils/test-harness.cpp
+        dali-test-suite-utils/dali-test-suite-utils.cpp
+        dali-test-suite-utils/test-application.cpp
+        dali-test-suite-utils/test-dynamics.cpp
+        dali-test-suite-utils/test-gesture-manager.cpp
+        dali-test-suite-utils/test-gl-abstraction.cpp
+        dali-test-suite-utils/test-gl-sync-abstraction.cpp
+        dali-test-suite-utils/test-native-image.cpp
+        dali-test-suite-utils/test-platform-abstraction.cpp
+        dali-test-suite-utils/test-render-controller.cpp
+        dali-test-suite-utils/test-trace-call-stack.cpp
+)
+
+PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
+     dali-core
+)
+
+SET(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} @DYNAMICS_SUPPORT@ -O0 -ggdb --coverage -Wall -Werror=return-type")
+
+FOREACH(directory ${${CAPI_LIB}_LIBRARY_DIRS})
+    SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -L${directory}")
+ENDFOREACH(directory ${CAPI_LIB_LIBRARY_DIRS})
+
+INCLUDE_DIRECTORIES(
+    ../../../
+    ${${CAPI_LIB}_INCLUDE_DIRS}
+    dali-test-suite-utils
+)
+
+ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.cpp ${TC_SOURCES})
+TARGET_LINK_LIBRARIES(${EXEC_NAME}
+    ${${CAPI_LIB}_LIBRARIES}
+)
+
+INSTALL(PROGRAMS ${EXEC_NAME}
+    DESTINATION ${BIN_DIR}/${EXEC_NAME}
+)
index b2042b625c70e4212e51f76f3e3bb05890bc6271..0b3f88f077ad826e5bbef1e0d80afacb19490172 100644 (file)
@@ -24,7 +24,6 @@
 #include <dali/integration-api/events/key-event-integ.h>
 #include <dali/integration-api/events/touch-event-integ.h>
 #include <dali/integration-api/events/wheel-event-integ.h>
-#include <dali/devel-api/dynamics/dynamics.h>
 
 #include <dali-test-suite-utils.h>
 
@@ -43,9 +42,7 @@ void stage_test_cleanup(void)
 namespace
 {
 
-/**
- * Functor for EventProcessingFinished signal
- */
+// Functor for EventProcessingFinished signal
 struct EventProcessingFinishedFunctor
 {
   /**
@@ -169,7 +166,6 @@ bool DummyTouchCallback( Actor actor, const TouchEvent& touch )
   return true;
 }
 
-
 struct ContextStatusFunctor
 {
   ContextStatusFunctor(bool& calledFlag) : mCalledFlag( calledFlag )
@@ -208,19 +204,41 @@ struct SceneCreatedStatusFunctor
   bool& mCalledFlag;
 };
 
+struct ActorCreatedFunctor
+{
+  ActorCreatedFunctor( bool& signalReceived )
+  : mSignalVerified( signalReceived )
+  {
+  }
+
+  void operator()( BaseHandle object )
+  {
+    tet_infoline( "Verifying TestActorCallback()" );
+    Actor actor = Actor::DownCast( object );
+    if( actor )
+    {
+      mSignalVerified = true;
+    }
+  }
+
+  bool& mSignalVerified;
+};
+
 } // unnamed namespace
 
 
-int UtcDaliStageDefaultConstructor(void)
+int UtcDaliStageDefaultConstructorP(void)
 {
   TestApplication application;
   Stage stage;
 
-  DALI_TEST_CHECK(!stage);
+  DALI_TEST_CHECK( !stage );
   END_TEST;
 }
 
-int UtcDaliStageDestructor(void)
+// Note: No negative test for default constructor.
+
+int UtcDaliStageDestructorP(void)
 {
   TestApplication application;
   Stage* stage = new Stage();
@@ -231,70 +249,214 @@ int UtcDaliStageDestructor(void)
   END_TEST;
 }
 
-int UtcDaliStageGetCurrent(void)
+// Note: No negative test for default destructor.
+
+int UtcDaliStageGetCurrentP(void)
 {
   TestApplication application;
   Stage stage = Stage::GetCurrent();
 
-  DALI_TEST_CHECK(stage);
+  DALI_TEST_CHECK( stage );
   END_TEST;
 }
 
-int UtcDaliStageAssign(void)
+int UtcDaliStageGetCurrentN(void)
+{
+  bool asserted = false;
+  try
+  {
+    Stage stage = Stage::GetCurrent();
+  }
+  catch( Dali::DaliException& e )
+  {
+    DALI_TEST_PRINT_ASSERT( e );
+    DALI_TEST_ASSERT( e, "stage && \"Stage doesn't exist\"", TEST_LOCATION );
+    asserted = true;
+  }
+
+  DALI_TEST_CHECK( asserted );
+  END_TEST;
+}
+
+int UtcDaliStageIsInstalledP(void)
 {
   TestApplication application;
-  Stage stage = Stage::GetCurrent();
-  Stage stage2;
-  stage2 = stage;
 
-  DALI_TEST_CHECK(stage2);
+  Stage::GetCurrent();
+
+  DALI_TEST_CHECK( Stage::IsInstalled() );
+  END_TEST;
+}
+
+int UtcDaliStageIsInstalledN(void)
+{
+  DALI_TEST_CHECK( !Stage::IsInstalled() );
+
   END_TEST;
 }
 
-int UtcDaliStageIsInstalled(void)
+int UtcDaliStageCopyConstructorP(void)
 {
-  DALI_TEST_CHECK(!Stage::IsInstalled());
+  TestApplication application;
+  Stage stage = Stage::GetCurrent();
+
+  Stage copyStage( stage );
+
+  DALI_TEST_CHECK( copyStage );
+  DALI_TEST_CHECK( copyStage.GetRootLayer() == stage.GetRootLayer() );
 
+  END_TEST;
+}
+
+// Note: no negative test for UtcDaliStageCopyConstructor.
+
+int UtcDaliStageAssignmentOperatorP(void)
+{
   TestApplication application;
+  const Stage stage = Stage::GetCurrent();
 
-  Stage::GetCurrent();
+  Stage copyStage = stage;
+
+  DALI_TEST_CHECK( copyStage );
+  DALI_TEST_CHECK( copyStage.GetRootLayer() == stage.GetRootLayer() );
 
-  DALI_TEST_CHECK(Stage::IsInstalled());
   END_TEST;
 }
 
-int UtcDaliStageAdd(void)
+// Note: No negative test for UtcDaliStageAssignmentOperator.
+
+int UtcDaliStageAddP(void)
 {
   TestApplication application;
 
   Stage stage = Stage::GetCurrent();
 
   Actor actor = Actor::New();
-  DALI_TEST_CHECK(!actor.OnStage());
+  DALI_TEST_CHECK( !actor.OnStage() );
+
+  stage.Add( actor );
+  DALI_TEST_CHECK( actor.OnStage() );
+  END_TEST;
+}
+
+int UtcDaliStageAddN(void)
+{
+  TestApplication application;
+
+  Stage stage = Stage::GetCurrent();
+  Actor actor;
+
+  bool asserted = false;
+  try
+  {
+    stage.Add( actor );
+  }
+  catch( Dali::DaliException& e )
+  {
+    DALI_TEST_PRINT_ASSERT( e );
+    DALI_TEST_ASSERT( e, "actor && \"Actor handle is empty\"", TEST_LOCATION );
+    asserted = true;
+  }
+
+  DALI_TEST_CHECK( asserted );
 
-  stage.Add(actor);
-  DALI_TEST_CHECK(actor.OnStage());
   END_TEST;
 }
 
-int UtcDaliStageRemove(void)
+int UtcDaliStageRemoveP(void)
 {
   TestApplication application;
 
   Stage stage = Stage::GetCurrent();
 
   Actor actor = Actor::New();
-  DALI_TEST_CHECK(!actor.OnStage());
+  DALI_TEST_CHECK( !actor.OnStage() );
 
-  stage.Add(actor);
-  DALI_TEST_CHECK(actor.OnStage());
+  stage.Add( actor );
+  DALI_TEST_CHECK( actor.OnStage() );
 
   stage.Remove(actor);
-  DALI_TEST_CHECK(!actor.OnStage());
+  DALI_TEST_CHECK( !actor.OnStage() );
+  END_TEST;
+}
+
+int UtcDaliStageRemoveN1(void)
+{
+  TestApplication application;
+
+  Stage stage = Stage::GetCurrent();
+  Actor actor;
+
+  bool asserted = false;
+  try
+  {
+    // Actor is not valid, confirm a removal attempt does assert.
+    stage.Remove( actor );
+  }
+  catch( Dali::DaliException& e )
+  {
+    DALI_TEST_PRINT_ASSERT( e );
+    DALI_TEST_ASSERT( e, "actor && \"Actor handle is empty\"", TEST_LOCATION );
+    asserted = true;
+  }
+
+  DALI_TEST_CHECK( asserted );
+  END_TEST;
+}
+
+int UtcDaliStageRemoveN2(void)
+{
+  TestApplication application;
+
+  Stage stage = Stage::GetCurrent();
+  Actor actor = Actor::New();
+  DALI_TEST_CHECK( !actor.OnStage() );
+
+  bool asserted = false;
+  try
+  {
+    // Actor is not on stage, confirm a removal attempt does not assert / segfault.
+    stage.Remove( actor );
+  }
+  catch( Dali::DaliException& e )
+  {
+    DALI_TEST_PRINT_ASSERT( e );
+    asserted = true;
+  }
+
+  DALI_TEST_CHECK( !asserted );
   END_TEST;
 }
 
-int UtcDaliStageGetSize(void)
+int UtcDaliStageRemoveN3(void)
+{
+  TestApplication application;
+
+  Stage stage = Stage::GetCurrent();
+
+  // Initially we have a default layer
+  DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
+
+  // Check we cannot remove the root layer from the stage.
+  Layer layer = stage.GetRootLayer();
+  bool asserted = true;
+  try
+  {
+    stage.Remove( layer );
+  }
+  catch( Dali::DaliException& e )
+  {
+    DALI_TEST_PRINT_ASSERT( e );
+    DALI_TEST_ASSERT( e, "this != &child && \"Cannot remove actor from itself\"", TEST_LOCATION );
+    asserted = true;
+  }
+
+  DALI_TEST_CHECK( asserted );
+  DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
+  END_TEST;
+}
+
+int UtcDaliStageGetSizeP(void)
 {
   TestApplication application;
 
@@ -302,12 +464,35 @@ int UtcDaliStageGetSize(void)
 
   Vector2 size = stage.GetSize();
 
-  DALI_TEST_EQUALS(size.width,  static_cast<float>(TestApplication::DEFAULT_SURFACE_WIDTH),  TEST_LOCATION);
-  DALI_TEST_EQUALS(size.height, static_cast<float>(TestApplication::DEFAULT_SURFACE_HEIGHT), TEST_LOCATION);
+  DALI_TEST_EQUALS( size.width,  static_cast<float>( TestApplication::DEFAULT_SURFACE_WIDTH ),  TEST_LOCATION );
+  DALI_TEST_EQUALS( size.height, static_cast<float>( TestApplication::DEFAULT_SURFACE_HEIGHT ), TEST_LOCATION );
   END_TEST;
 }
 
-int UtcDaliStageGetDpi01(void)
+int UtcDaliStageGetSizeN(void)
+{
+  TestApplication application;
+
+  Stage stage;
+
+  bool asserted = false;
+  Vector2 size;
+  try
+  {
+    size = stage.GetSize();
+  }
+  catch( Dali::DaliException& e )
+  {
+    DALI_TEST_PRINT_ASSERT( e );
+    DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
+    asserted = true;
+  }
+
+  DALI_TEST_CHECK( asserted );
+  END_TEST;
+}
+
+int UtcDaliStageGetDpiP1(void)
 {
   TestApplication application; // Initializes core DPI to default values
 
@@ -315,129 +500,199 @@ int UtcDaliStageGetDpi01(void)
 
   // Test the default DPI.
   Vector2 dpi = stage.GetDpi();
-  DALI_TEST_EQUALS(dpi.x, static_cast<float>(TestApplication::DEFAULT_HORIZONTAL_DPI), TEST_LOCATION);
-  DALI_TEST_EQUALS(dpi.y, static_cast<float>(TestApplication::DEFAULT_VERTICAL_DPI),   TEST_LOCATION);
+  DALI_TEST_EQUALS( dpi.x, static_cast<float>( TestApplication::DEFAULT_HORIZONTAL_DPI ), TEST_LOCATION );
+  DALI_TEST_EQUALS( dpi.y, static_cast<float>( TestApplication::DEFAULT_VERTICAL_DPI ),   TEST_LOCATION );
   END_TEST;
 }
 
-int UtcDaliStageGetDpi02(void)
+int UtcDaliStageGetDpiP2(void)
 {
   TestApplication application; // Initializes core DPI to default values
 
   // Test that setting core DPI explicitly also sets up the Stage's DPI.
-  application.GetCore().SetDpi(200, 180);
+  application.GetCore().SetDpi( 200, 180 );
 
   Stage stage = Stage::GetCurrent();
   Vector2 dpi = stage.GetDpi();
-  DALI_TEST_EQUALS(dpi.x, 200.0f, TEST_LOCATION);
-  DALI_TEST_EQUALS(dpi.y, 180.0f, TEST_LOCATION);
+  DALI_TEST_EQUALS( dpi.x, 200.0f, TEST_LOCATION );
+  DALI_TEST_EQUALS( dpi.y, 180.0f, TEST_LOCATION );
   END_TEST;
 }
 
-
-int UtcDaliStageGetDpi03(void)
+int UtcDaliStageGetDpiP3(void)
 {
-  TestApplication application(480, 800, 72.0f, 120.0f); // Initializes core DPI with specific values
+  TestApplication application( 480, 800, 72.0f, 120.0f ); // Initializes core DPI with specific values
 
   Stage stage = Stage::GetCurrent();
 
   // Test that setting core DPI explicitly also sets up the Stage's DPI.
   Vector2 dpi = stage.GetDpi();
-  DALI_TEST_EQUALS(dpi.x, 72.0f, TEST_LOCATION);
-  DALI_TEST_EQUALS(dpi.y, 120.0f, TEST_LOCATION);
+  DALI_TEST_EQUALS( dpi.x, 72.0f, TEST_LOCATION );
+  DALI_TEST_EQUALS( dpi.y, 120.0f, TEST_LOCATION) ;
   END_TEST;
 }
 
-int UtcDaliStageInitializeDynamicsP(void)
+/*
+ * This is not a true negative test, we are checking the DPI if it has not been set.
+ * A test for setting negative DPI values would be part of the application core utc tests.
+ */
+int UtcDaliStageGetDpiN(void)
+{
+  TestApplication application; // Initializes core DPI to default values
+
+  Stage stage = Stage::GetCurrent();
+  Vector2 dpi = stage.GetDpi();
+
+  DALI_TEST_EQUALS( dpi.x, 220.0f, TEST_LOCATION );
+  DALI_TEST_EQUALS( dpi.y, 217.0f, TEST_LOCATION );
+  END_TEST;
+}
+
+int UtcDaliStageGetLayerCountP(void)
 {
   TestApplication application;
+
   Stage stage = Stage::GetCurrent();
-  DynamicsWorld world = stage.InitializeDynamics( DynamicsWorldConfig::New() );
 
-#if !defined(DYNAMICS_SUPPORT)
-  DALI_TEST_CHECK(true);
-#else
-  DALI_TEST_CHECK( world );
-#endif
+  // Initially we have a default layer
+  DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
 
+  Layer layer = Layer::New();
+  stage.Add( layer );
+
+  DALI_TEST_EQUALS( stage.GetLayerCount(), 2u, TEST_LOCATION );
   END_TEST;
 }
 
-int UtcDaliStageGetLayerCount(void)
+/*
+ * Not a true negative test, but confirms layer count is not affected by an invalid removal.
+ */
+int UtcDaliStageGetLayerCountN(void)
 {
   TestApplication application;
 
   Stage stage = Stage::GetCurrent();
 
   // Initially we have a default layer
-  DALI_TEST_EQUALS(stage.GetLayerCount(), 1u, TEST_LOCATION);
+  DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
 
   Layer layer = Layer::New();
-  stage.Add(layer);
+  stage.Remove( layer );
 
-  DALI_TEST_EQUALS(stage.GetLayerCount(), 2u, TEST_LOCATION);
+  // Still have 1 layer.
+  DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );
   END_TEST;
 }
 
-int UtcDaliStageGetLayer(void)
+int UtcDaliStageGetLayerP(void)
 {
   TestApplication application;
 
   Stage stage = Stage::GetCurrent();
 
-  Layer rootLayer = stage.GetLayer(0);
-  DALI_TEST_CHECK(rootLayer);
+  Layer rootLayer = stage.GetLayer( 0 );
+  DALI_TEST_CHECK( rootLayer );
 
   Layer layer = Layer::New();
-  stage.Add(layer);
+  stage.Add( layer );
+
+  Layer sameLayer = stage.GetLayer( 1 );
+  DALI_TEST_CHECK( layer == sameLayer );
+  END_TEST;
+}
+
+int UtcDaliStageGetLayerN(void)
+{
+  TestApplication application;
+
+  Stage stage = Stage::GetCurrent();
 
-  Layer sameLayer = stage.GetLayer(1);
-  DALI_TEST_CHECK(layer == sameLayer);
+  bool asserted = false;
+  try
+  {
+    // Try to get a layer that doesn't exist (note: 0 is the root layer).
+    Layer layer = stage.GetLayer( 1 );
+  }
+  catch( Dali::DaliException& e )
+  {
+    DALI_TEST_PRINT_ASSERT( e );
+    DALI_TEST_ASSERT( e, "depth < mLayers.size()", TEST_LOCATION );
+    asserted = true;
+  }
+
+  DALI_TEST_CHECK( asserted );
   END_TEST;
 }
 
+int UtcDaliStageGetRootLayerP(void)
+{
+  TestApplication application;
 
-int UtcDaliStageGetRootLayer(void)
+  Stage stage = Stage::GetCurrent();
+
+  Layer layer = stage.GetLayer( 0 );
+  DALI_TEST_CHECK( layer );
+
+  // Check that GetRootLayer() correctly retreived layer 0.
+  DALI_TEST_CHECK( stage.GetRootLayer() == layer );
+
+  END_TEST;
+}
+
+int UtcDaliStageGetRootLayerN(void)
 {
   TestApplication application;
 
   Stage stage = Stage::GetCurrent();
 
-  Layer rootLayer = stage.GetLayer(0);
+  Layer rootLayer = stage.GetLayer( 0 );
   DALI_TEST_CHECK( rootLayer );
+  DALI_TEST_CHECK( stage.GetRootLayer() == rootLayer );
 
+  // Create a new layer and attempt to lower it below the root layer.
   Layer layer = Layer::New();
   stage.Add( layer );
   layer.LowerToBottom();
 
+  // Check that GetRootLayer still retrieves the same original layer.
+  DALI_TEST_CHECK( stage.GetRootLayer() == rootLayer );
+
+  // Check modifying the root layer is also blocked.
+  rootLayer.RaiseToTop();
   DALI_TEST_CHECK( stage.GetRootLayer() == rootLayer );
+
   END_TEST;
 }
 
-int UtcDaliStageSetBackgroundColor(void)
+int UtcDaliStageSetBackgroundColorP(void)
 {
   TestApplication application;
 
   Stage stage = Stage::GetCurrent();
 
-  Vector4 testColor(0.1f, 0.2f, 0.3f, 1.0f);
-  stage.SetBackgroundColor(testColor);
+  Vector4 testColor( 0.1f, 0.2f, 0.3f, 1.0f );
+  stage.SetBackgroundColor( testColor );
 
-  DALI_TEST_EQUALS(testColor, stage.GetBackgroundColor(), TEST_LOCATION);
+  DALI_TEST_EQUALS( testColor, stage.GetBackgroundColor(), TEST_LOCATION );
   END_TEST;
 }
 
-int UtcDaliStageGetBackgroundColor(void)
+// Note: No negative test for UtcDaliStageSetBackgroundColor as we do not wish to implement
+// range checking for colors due to speed. Colors are clamped with glclampf within GL anyway.
+
+int UtcDaliStageGetBackgroundColorP(void)
 {
   TestApplication application;
 
   Stage stage = Stage::GetCurrent();
 
-  DALI_TEST_EQUALS(Stage::DEFAULT_BACKGROUND_COLOR, stage.GetBackgroundColor(), TEST_LOCATION);
+  DALI_TEST_EQUALS( Stage::DEFAULT_BACKGROUND_COLOR, stage.GetBackgroundColor(), TEST_LOCATION );
   END_TEST;
 }
 
-int UtcDaliStageKeepRendering(void)
+// Note: No negative test for UtcDaliStageGetBackgroundColor as this is covered by UtcDaliStageSetBackgroundColorN.
+
+int UtcDaliStageKeepRenderingP(void)
 {
   TestApplication application;
 
@@ -448,7 +703,7 @@ int UtcDaliStageKeepRendering(void)
   while ( keepUpdating )
   {
     application.SendNotification();
-    keepUpdating = application.Render(1000.0f /*1 second*/);
+    keepUpdating = application.Render( 1000.0f /*1 second*/ );
   }
 
   // Force rendering for the next 5 seconds
@@ -457,20 +712,46 @@ int UtcDaliStageKeepRendering(void)
   application.SendNotification();
 
   // Test that core wants to sleep after 10 seconds
-  keepUpdating = application.Render(1000.0f /*1 second*/);
+  keepUpdating = application.Render( 1000.0f /*1 second*/ );
   DALI_TEST_CHECK( keepUpdating );
-  keepUpdating = application.Render(1000.0f /*2 seconds*/);
+  keepUpdating = application.Render( 1000.0f /*2 seconds*/ );
   DALI_TEST_CHECK( keepUpdating );
-  keepUpdating = application.Render(1000.0f /*3 seconds*/);
+  keepUpdating = application.Render( 1000.0f /*3 seconds*/ );
   DALI_TEST_CHECK( keepUpdating );
-  keepUpdating = application.Render(1000.0f /*4 seconds*/);
+  keepUpdating = application.Render( 1000.0f /*4 seconds*/ );
   DALI_TEST_CHECK( keepUpdating );
-  keepUpdating = application.Render(1000.0f /*5 seconds*/);
+  keepUpdating = application.Render( 1000.0f /*5 seconds*/ );
   DALI_TEST_CHECK( !keepUpdating );
   END_TEST;
 }
 
-int UtcDaliStageEventProcessingFinished(void)
+int UtcDaliStageKeepRenderingN(void)
+{
+  TestApplication application;
+
+  Stage stage = Stage::GetCurrent();
+
+  // Run core until it wants to sleep
+  bool keepUpdating( true );
+  while ( keepUpdating )
+  {
+    application.SendNotification();
+    keepUpdating = application.Render( 1000.0f /*1 second*/ );
+  }
+
+  // Force rendering for the next 5 seconds
+  stage.KeepRendering( -1.0f );
+
+  application.SendNotification();
+
+  // Test that core wants to sleep after 10 seconds
+  keepUpdating = application.Render( 1000.0f /*1 second*/ );
+  DALI_TEST_CHECK( !keepUpdating );
+
+  END_TEST;
+}
+
+int UtcDaliStageEventProcessingFinishedP(void)
 {
   TestApplication application;
   Stage stage = Stage::GetCurrent();
@@ -490,7 +771,25 @@ int UtcDaliStageEventProcessingFinished(void)
   END_TEST;
 }
 
-int UtcDaliStageSignalKeyEvent(void)
+int UtcDaliStageEventProcessingFinishedN(void)
+{
+  TestApplication application;
+  Stage stage = Stage::GetCurrent();
+
+  bool eventProcessingFinished = false;
+  EventProcessingFinishedFunctor functor( eventProcessingFinished );
+  stage.EventProcessingFinishedSignal().Connect( &application, functor );
+
+  Actor actor( Actor::New() );
+  stage.Add( actor );
+
+  // Do not complete event processing and confirm the signal has not been emitted.
+  DALI_TEST_CHECK( !eventProcessingFinished );
+
+  END_TEST;
+}
+
+int UtcDaliStageSignalKeyEventP(void)
 {
   TestApplication application;
   Stage stage = Stage::GetCurrent();
@@ -499,51 +798,66 @@ int UtcDaliStageSignalKeyEvent(void)
   KeyEventReceivedFunctor functor( data );
   stage.KeyEventSignal().Connect( &application, functor );
 
-  Integration::KeyEvent event( "i","i", 0, 0, 0, Integration::KeyEvent::Down );
+  Integration::KeyEvent event( "i", "i", 0, 0, 0, Integration::KeyEvent::Down );
   application.ProcessEvent( event );
 
   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
   DALI_TEST_CHECK( event.keyModifier == data.receivedKeyEvent.keyModifier );
   DALI_TEST_CHECK( event.keyName == data.receivedKeyEvent.keyPressedName );
   DALI_TEST_CHECK( event.keyString == data.receivedKeyEvent.keyPressed );
-  DALI_TEST_CHECK( event.state == static_cast<Integration::KeyEvent::State>(data.receivedKeyEvent.state) );
+  DALI_TEST_CHECK( event.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
 
   data.Reset();
 
-  Integration::KeyEvent event2( "i","i", 0, 0, 0, Integration::KeyEvent::Up );
+  Integration::KeyEvent event2( "i", "i", 0, 0, 0, Integration::KeyEvent::Up );
   application.ProcessEvent( event2 );
 
   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
   DALI_TEST_CHECK( event2.keyModifier == data.receivedKeyEvent.keyModifier );
   DALI_TEST_CHECK( event2.keyName == data.receivedKeyEvent.keyPressedName );
   DALI_TEST_CHECK( event2.keyString == data.receivedKeyEvent.keyPressed );
-  DALI_TEST_CHECK( event2.state == static_cast<Integration::KeyEvent::State>(data.receivedKeyEvent.state) );
+  DALI_TEST_CHECK( event2.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
 
   data.Reset();
 
-  Integration::KeyEvent event3( "a","a", 0, 0, 0, Integration::KeyEvent::Down );
+  Integration::KeyEvent event3( "a", "a", 0, 0, 0, Integration::KeyEvent::Down );
   application.ProcessEvent( event3 );
 
   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
   DALI_TEST_CHECK( event3.keyModifier == data.receivedKeyEvent.keyModifier );
   DALI_TEST_CHECK( event3.keyName == data.receivedKeyEvent.keyPressedName );
   DALI_TEST_CHECK( event3.keyString == data.receivedKeyEvent.keyPressed );
-  DALI_TEST_CHECK( event3.state == static_cast<Integration::KeyEvent::State>(data.receivedKeyEvent.state) );
+  DALI_TEST_CHECK( event3.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
 
   data.Reset();
 
-  Integration::KeyEvent event4( "a","a", 0, 0, 0, Integration::KeyEvent::Up );
+  Integration::KeyEvent event4( "a", "a", 0, 0, 0, Integration::KeyEvent::Up );
   application.ProcessEvent( event4 );
 
   DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
   DALI_TEST_CHECK( event4.keyModifier == data.receivedKeyEvent.keyModifier );
   DALI_TEST_CHECK( event4.keyName == data.receivedKeyEvent.keyPressedName );
   DALI_TEST_CHECK( event4.keyString == data.receivedKeyEvent.keyPressed );
-  DALI_TEST_CHECK( event4.state == static_cast<Integration::KeyEvent::State>(data.receivedKeyEvent.state) );
+  DALI_TEST_CHECK( event4.state == static_cast<Integration::KeyEvent::State>( data.receivedKeyEvent.state ) );
+  END_TEST;
+}
+
+int UtcDaliStageSignalKeyEventN(void)
+{
+  TestApplication application;
+  Stage stage = Stage::GetCurrent();
+
+  KeyEventSignalData data;
+  KeyEventReceivedFunctor functor( data );
+  stage.KeyEventSignal().Connect( &application, functor );
+
+  // Check that a non-pressed key events data is not modified.
+  DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
+
   END_TEST;
 }
 
-int UtcDaliStageTouchedSignal(void)
+int UtcDaliStageTouchedSignalP(void)
 {
   TestApplication application;
   Stage stage = Stage::GetCurrent();
@@ -552,11 +866,11 @@ int UtcDaliStageTouchedSignal(void)
   TouchedFunctor functor( data );
   stage.TouchedSignal().Connect( &application, functor );
 
-  // Render and notify
+  // Render and notify.
   application.SendNotification();
   application.Render();
 
-  // NO ACTORS, SINGLE TOUCH, DOWN, MOTION THEN UP
+  // Basic test: No actors, single touch (down then up).
   {
     Integration::TouchEvent touchEvent;
     touchEvent.points.push_back( TouchPoint( 0, TouchPoint::Down, 10.0f, 10.0f ) );
@@ -567,13 +881,6 @@ int UtcDaliStageTouchedSignal(void)
     DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
     data.Reset();
 
-    touchEvent.points[0].state = TouchPoint::Motion;
-    touchEvent.points[0].screen.x = 12.0f; // Some motion
-    application.ProcessEvent( touchEvent );
-
-    DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
-    data.Reset();
-
     touchEvent.points[0].state = TouchPoint::Up;
     application.ProcessEvent( touchEvent );
 
@@ -583,8 +890,7 @@ int UtcDaliStageTouchedSignal(void)
     data.Reset();
   }
 
-  // Add an actor to the scene
-
+  // Add an actor to the scene.
   Actor actor = Actor::New();
   actor.SetSize( 100.0f, 100.0f );
   actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
@@ -592,11 +898,11 @@ int UtcDaliStageTouchedSignal(void)
   actor.TouchedSignal().Connect( &DummyTouchCallback );
   stage.Add( actor );
 
-  // Render and notify
+  // Render and notify.
   application.SendNotification();
   application.Render();
 
-  // ACTOR ON SCENE, SINGLE TOUCH, DOWN IN ACTOR, MOTION THEN UP OUTSIDE ACTOR
+  // Actor on scene, single touch, down in actor, motion, then up outside actor.
   {
     Integration::TouchEvent touchEvent;
     touchEvent.points.push_back( TouchPoint( 0, TouchPoint::Down, 10.0f, 10.0f ) );
@@ -623,79 +929,161 @@ int UtcDaliStageTouchedSignal(void)
     data.Reset();
   }
 
-  // INTERRUPTED BEFORE DOWN AND INTERRUPTED AFTER DOWN
+  // Multiple touch. Should only receive a touch on first down and last up.
   {
     Integration::TouchEvent touchEvent;
-    touchEvent.points.push_back( TouchPoint( 0, TouchPoint::Interrupted, 10.0f, 10.0f ) );
-    application.ProcessEvent( touchEvent );
 
+    // 1st point
+    touchEvent.points.push_back( TouchPoint( 0, TouchPoint::Down, 10.0f, 10.0f ) );
+    application.ProcessEvent( touchEvent );
     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
-    DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0 );
-    DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
-    DALI_TEST_CHECK( data.receivedTouchEvent.points[0].state == TouchPoint::Interrupted );
+    DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 1, TEST_LOCATION );
     data.Reset();
 
-    touchEvent.points[0].state = TouchPoint::Down;
+    // 2nd point
+    touchEvent.points[0].state = TouchPoint::Stationary;
+    touchEvent.points.push_back( TouchPoint( 1, TouchPoint::Down, 50.0f, 50.0f ) );
     application.ProcessEvent( touchEvent );
+    DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
+    DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 0, TEST_LOCATION );
+    data.Reset();
 
-    DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
-    DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0 );
-    DALI_TEST_CHECK( data.receivedTouchEvent.points[0].hitActor == actor );
-    DALI_TEST_CHECK( data.receivedTouchEvent.points[0].state == TouchPoint::Down );
+    // Primary point is up
+    touchEvent.points[0].state = TouchPoint::Up;
+    touchEvent.points[1].state = TouchPoint::Stationary;
+    application.ProcessEvent( touchEvent );
+    DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
+    DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 0, TEST_LOCATION );
     data.Reset();
 
-    touchEvent.points[0].state = TouchPoint::Interrupted;
+    // Remove 1st point now, 2nd point is now in motion
+    touchEvent.points.erase( touchEvent.points.begin() );
+    touchEvent.points[0].state = TouchPoint::Motion;
+    touchEvent.points[0].screen.x = 150.0f;
     application.ProcessEvent( touchEvent );
+    DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
+    DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 0, TEST_LOCATION );
+    data.Reset();
 
+    // Final point Up
+    touchEvent.points[0].state = TouchPoint::Up;
+    application.ProcessEvent( touchEvent );
     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
-    DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0 );
-    DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
-    DALI_TEST_CHECK( data.receivedTouchEvent.points[0].state == TouchPoint::Interrupted );
+    DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 1, TEST_LOCATION );
     data.Reset();
   }
+  END_TEST;
+}
 
-  // MULTIPLE TOUCH, SHOULD ONLY RECEIVE TOUCH ON FIRST DOWN AND LAST UP
+int UtcDaliStageTouchedSignalN(void)
+{
+  TestApplication application;
+  Stage stage = Stage::GetCurrent();
+
+  TouchedSignalData data;
+  TouchedFunctor functor( data );
+  stage.TouchedSignal().Connect( &application, functor );
+
+  // Render and notify.
+  application.SendNotification();
+  application.Render();
+
+  // Confirm functor not called before there has been any touch event.
+  DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
+
+  // No actors, single touch, down, motion then up.
   {
     Integration::TouchEvent touchEvent;
-
-    // 1st point
     touchEvent.points.push_back( TouchPoint( 0, TouchPoint::Down, 10.0f, 10.0f ) );
     application.ProcessEvent( touchEvent );
+
     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
+    DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0 );
+    DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
     data.Reset();
 
-    // 2nd point
-    touchEvent.points[0].state = TouchPoint::Stationary;
-    touchEvent.points.push_back( TouchPoint( 1, TouchPoint::Down, 50.0f, 50.0f ) );
+    // Confirm there is no signal when the touchpoint is only moved.
+    touchEvent.points[0].state = TouchPoint::Motion;
+    touchEvent.points[0].screen.x = 1200.0f; // Some motion
     application.ProcessEvent( touchEvent );
+
     DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
     data.Reset();
 
-    // Primary point is up
+    // Confirm a following up event generates a signal.
     touchEvent.points[0].state = TouchPoint::Up;
-    touchEvent.points[1].state = TouchPoint::Stationary;
     application.ProcessEvent( touchEvent );
-    DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
+
+    DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
+    DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0 );
+    DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
     data.Reset();
+  }
 
-    // Remove 1st point now, 2nd point is now in motion
-    touchEvent.points.erase( touchEvent.points.begin() );
-    touchEvent.points[0].state = TouchPoint::Motion;
-    touchEvent.points[0].screen.x = 150.0f;
+  // Add an actor to the scene.
+  Actor actor = Actor::New();
+  actor.SetSize( 100.0f, 100.0f );
+  actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
+  actor.TouchedSignal().Connect( &DummyTouchCallback );
+  stage.Add( actor );
+
+  // Render and notify.
+  application.SendNotification();
+  application.Render();
+
+  // Actor on scene. Interrupted before down and interrupted after down.
+  {
+    Integration::TouchEvent touchEvent;
+    touchEvent.points.push_back( TouchPoint( 0, TouchPoint::Interrupted, 10.0f, 10.0f ) );
     application.ProcessEvent( touchEvent );
-    DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
+
+    DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
+    DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0 );
+    DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
+    DALI_TEST_CHECK( data.receivedTouchEvent.points[0].state == TouchPoint::Interrupted );
     data.Reset();
 
-    // Final point Up
-    touchEvent.points[0].state = TouchPoint::Up;
+    touchEvent.points[0].state = TouchPoint::Down;
     application.ProcessEvent( touchEvent );
+
     DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
+    DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0 );
+    DALI_TEST_CHECK( data.receivedTouchEvent.points[0].hitActor == actor );
+    DALI_TEST_CHECK( data.receivedTouchEvent.points[0].state == TouchPoint::Down );
+    data.Reset();
+
+    touchEvent.points[0].state = TouchPoint::Interrupted;
+    application.ProcessEvent( touchEvent );
+
+    DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
+    DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0 );
+    DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor );
+    DALI_TEST_CHECK( data.receivedTouchEvent.points[0].state == TouchPoint::Interrupted );
+
+    DALI_TEST_EQUALS( data.receivedTouchEvent.GetPointCount(), 1, TEST_LOCATION );
+
+    // Check that getting info about a non-existent point causes an assert.
+    bool asserted = false;
+    try
+    {
+      data.receivedTouchEvent.GetPoint( 1 );
+    }
+    catch( Dali::DaliException& e )
+    {
+      DALI_TEST_PRINT_ASSERT( e );
+      DALI_TEST_ASSERT( e, "point < points.size() && \"No point at index\"", TEST_LOCATION );
+      asserted = true;
+    }
+    DALI_TEST_CHECK( asserted );
+
     data.Reset();
   }
+
   END_TEST;
 }
 
-int UtcDaliStageSignalWheelEvent(void)
+int UtcDaliStageSignalWheelEventP(void)
 {
   TestApplication application;
   Stage stage = Stage::GetCurrent();
@@ -730,37 +1118,95 @@ int UtcDaliStageSignalWheelEvent(void)
   END_TEST;
 }
 
-int UtcDaliStageContextLostRegainedSignals(void)
+int UtcDaliStageContextLostSignalP(void)
 {
   TestApplication app;
   Stage stage = Stage::GetCurrent();
 
   bool contextLost = false;
-  bool contextRegained = false;
   ContextStatusFunctor contextLostFunctor( contextLost );
-  ContextStatusFunctor contextRegainedFunctor( contextRegained );
-  stage.ContextLostSignal().Connect(&app, contextLostFunctor );
-  stage.ContextRegainedSignal().Connect(&app, contextRegainedFunctor );
+  stage.ContextLostSignal().Connect( &app, contextLostFunctor );
 
-  Integration::Core& core = app.GetCore();
-  Integration::ContextNotifierInterface* notifier = core.GetContextNotifier();
+  Integration::ContextNotifierInterface* notifier = app.GetCore().GetContextNotifier();
   notifier->NotifyContextLost();
   DALI_TEST_EQUALS( contextLost, true, TEST_LOCATION );
 
+  END_TEST;
+}
+
+int UtcDaliStageContextLostSignalN(void)
+{
+  TestApplication app;
+  Stage stage;
+
+  // Check that connecting to the signal with a bad stage instance causes an assert.
+  bool asserted = false;
+  bool contextLost = false;
+  ContextStatusFunctor contextLostFunctor( contextLost );
+  try
+  {
+    stage.ContextLostSignal().Connect( &app, contextLostFunctor );
+  }
+  catch( Dali::DaliException& e )
+  {
+    DALI_TEST_PRINT_ASSERT( e );
+    DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
+    asserted = true;
+  }
+  DALI_TEST_CHECK( asserted );
+
+  END_TEST;
+}
+
+int UtcDaliStageContextRegainedSignalP(void)
+{
+  TestApplication app;
+  Stage stage = Stage::GetCurrent();
+
+  bool contextRegained = false;
+  ContextStatusFunctor contextRegainedFunctor( contextRegained );
+  stage.ContextRegainedSignal().Connect( &app, contextRegainedFunctor );
+
+  Integration::ContextNotifierInterface* notifier = app.GetCore().GetContextNotifier();
+  notifier->NotifyContextLost();
   notifier->NotifyContextRegained();
   DALI_TEST_EQUALS( contextRegained, true, TEST_LOCATION );
 
   END_TEST;
 }
 
-int UtcDaliStageSceneCreatedSignal(void)
+int UtcDaliStageContextRegainedSignalN(void)
+{
+  TestApplication app;
+  Stage stage;
+
+  // Check that connecting to the signal with a bad stage instance causes an assert.
+  bool asserted = false;
+  bool contextRegained = false;
+  ContextStatusFunctor contextRegainedFunctor( contextRegained );
+  try
+  {
+    stage.ContextRegainedSignal().Connect( &app, contextRegainedFunctor );
+  }
+  catch( Dali::DaliException& e )
+  {
+    DALI_TEST_PRINT_ASSERT( e );
+    DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
+    asserted = true;
+  }
+  DALI_TEST_CHECK( asserted );
+
+  END_TEST;
+}
+
+int UtcDaliStageSceneCreatedSignalP(void)
 {
   TestApplication app;
   Stage stage = Stage::GetCurrent();
 
   bool signalCalled = false;
   SceneCreatedStatusFunctor sceneCreatedFunctor( signalCalled );
-  stage.SceneCreatedSignal().Connect(&app, sceneCreatedFunctor );
+  stage.SceneCreatedSignal().Connect( &app, sceneCreatedFunctor );
 
   Integration::Core& core = app.GetCore();
   core.SceneCreated();
@@ -768,3 +1214,110 @@ int UtcDaliStageSceneCreatedSignal(void)
 
   END_TEST;
 }
+
+int UtcDaliStageSceneCreatedSignalN(void)
+{
+  TestApplication app;
+  Stage stage;
+
+  // Check that connecting to the signal with a bad stage instance causes an assert.
+  bool asserted = false;
+  bool signalCalled = false;
+  SceneCreatedStatusFunctor sceneCreatedFunctor( signalCalled );
+  try
+  {
+    stage.SceneCreatedSignal().Connect( &app, sceneCreatedFunctor );
+  }
+  catch( Dali::DaliException& e )
+  {
+    DALI_TEST_PRINT_ASSERT( e );
+    DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
+    asserted = true;
+  }
+  DALI_TEST_CHECK( asserted );
+
+  END_TEST;
+}
+
+int UtcDaliStageGetRenderTaskListP(void)
+{
+  TestApplication app;
+  Stage stage = Stage::GetCurrent();
+
+  // Check we get a valid instance.
+  const RenderTaskList& tasks = stage.GetRenderTaskList();
+
+  // There should be 1 task by default.
+  DALI_TEST_EQUALS( tasks.GetTaskCount(), 1, TEST_LOCATION );
+
+  // RenderTaskList has it's own UTC tests.
+  // But we can confirm that GetRenderTaskList in Stage retrieves the same RenderTaskList each time.
+  RenderTask newTask = stage.GetRenderTaskList().CreateTask();
+
+  DALI_TEST_EQUALS( stage.GetRenderTaskList().GetTask( 1 ), newTask, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliStageGetRenderTaskListN(void)
+{
+  TestApplication app;
+  Stage stage;
+
+  // Check that getting the render task list with a bad stage instance causes an assert.
+  bool asserted = false;
+  try
+  {
+    stage.GetRenderTaskList();
+  }
+  catch( Dali::DaliException& e )
+  {
+    DALI_TEST_PRINT_ASSERT( e );
+    DALI_TEST_ASSERT( e, "stage && \"Stage handle is empty\"", TEST_LOCATION );
+    asserted = true;
+  }
+  DALI_TEST_CHECK( asserted );
+
+  END_TEST;
+}
+
+int UtcDaliStageGetObjectRegistryP(void)
+{
+  TestApplication app;
+  Stage stage = Stage::GetCurrent();
+
+  ObjectRegistry objectRegistry = stage.GetObjectRegistry();
+
+  // Object registry tests are covered in their own module.
+  // However we want a basic test to confirm the returned registry is valid and works.
+  bool verified = false;
+  ActorCreatedFunctor test( verified );
+  objectRegistry.ObjectCreatedSignal().Connect( &app, test );
+
+  Actor actor = Actor::New();
+  DALI_TEST_CHECK( test.mSignalVerified );
+
+  END_TEST;
+}
+
+int UtcDaliStageGetObjectRegistryN(void)
+{
+  TestApplication app;
+  Stage stage;
+
+  // Check that getting the object registry with a bad stage instance DOES NOT cause an assert.
+  // This is because GetCurrent() is used, always creating a stage if one does not exist.
+  bool asserted = false;
+  try
+  {
+    stage.GetObjectRegistry();
+  }
+  catch( Dali::DaliException& e )
+  {
+    DALI_TEST_PRINT_ASSERT( e );
+    asserted = true;
+  }
+  DALI_TEST_CHECK( !asserted );
+
+  END_TEST;
+}
index 1394e184223aec4487895a5b4555f071c9c7a53f..47442e4c881ceac71939f4df31b4d214c97994f0 100644 (file)
@@ -117,6 +117,7 @@ AC_CONFIG_FILES([
  dali-core/Makefile
  dali-core.pc
  ../../automated-tests/CMakeLists.txt
+ ../../automated-tests/src/dali/CMakeLists.txt
 ])
 
 AC_OUTPUT
index 28723fe0f7868f252526bd9c52480b7a84dc10e9..71fd8f28b6ca011061437c827f091e858eeb8f94 100644 (file)
@@ -26,6 +26,7 @@
 #include <dali/internal/event/dynamics/dynamics-body-impl.h>
 #include <dali/internal/event/dynamics/dynamics-joint-impl.h>
 #include <dali/internal/event/dynamics/dynamics-world-impl.h>
+#include <dali/internal/event/dynamics/dynamics-world-config-impl.h>
 #endif
 
 namespace Dali
@@ -54,6 +55,35 @@ DynamicsWorld& DynamicsWorld::operator=(const DynamicsWorld& rhs)
   return *this;
 }
 
+DynamicsWorld DynamicsWorld::GetInstance( DynamicsWorldConfig configuration )
+{
+#ifdef DYNAMICS_SUPPORT
+  Internal::DynamicsWorldConfigPtr configImpl( &( GetImplementation( configuration ) ) );
+
+  return DynamicsWorld( Internal::DynamicsWorld::GetInstance( configImpl ).Get() );
+#else
+  return DynamicsWorld();
+#endif
+}
+
+DynamicsWorld DynamicsWorld::Get()
+{
+#ifdef DYNAMICS_SUPPORT
+  Internal::DynamicsWorld* dynamicsWorld = Internal::DynamicsWorld::Get().Get();
+  DALI_ASSERT_ALWAYS( dynamicsWorld && "DynamicsWorld doesn't exist" );
+  return DynamicsWorld( dynamicsWorld );
+#else
+  return DynamicsWorld();
+#endif
+}
+
+void DynamicsWorld::DestroyInstance()
+{
+#ifdef DYNAMICS_SUPPORT
+  Internal::DynamicsWorld::DestroyInstance();
+#endif
+}
+
 void DynamicsWorld::SetGravity(const Vector3& gravity )
 {
 #ifdef DYNAMICS_SUPPORT
index 7ed5d0b0297be1e213faa551b62fb2c7bad614ec..6ac71093b48f68c4c49173162c59a0dea430df27 100644 (file)
@@ -25,6 +25,7 @@
 #include <dali/public-api/object/base-handle.h>
 
 // INTERNAL INCLUDES
+#include <dali/devel-api/dynamics/dynamics-world-config.h>
 #include <dali/public-api/signals/dali-signal.h>
 
 namespace Dali
@@ -134,6 +135,41 @@ public:
    */
   DynamicsWorld& operator=(const DynamicsWorld& rhs);
 
+  /**
+   * @brief Static / singleton creator and getter.
+   * Initialise the Dynamics simulation and create a DynamicsWorld object.
+   *
+   * Only one instance of DynamicsWorld will be created, so calling this method multiple times
+   * will return the same DynamicsWorld object.
+   *
+   * If an instance already exists, it is returned regardless of configuration being passed in.
+   *
+   * @param[in] configuration A DynamicsWorldConfig object describing the required capabilities of the dynamics world.
+   * @return A handle to the world object of the dynamics simulation, or an empty handle if Dynamics is not capable
+   *         of supporting a requirement in the configuration as it is not available on the platform.
+   */
+  static DynamicsWorld GetInstance( DynamicsWorldConfig configuration );
+
+  /**
+   * @brief Static / singleton getter.
+   * Get a handle to the world object of the dynamics simulation.
+   *
+   * Does not create an instance, use only if the instance is known to exist.
+   *
+   * @return A pointer to the dynamics world if it is installed.
+   */
+  static DynamicsWorld Get();
+
+  /**
+   * @brief Static instance cleanup.
+   * Terminate the dynamics simulation.
+   *
+   * Calls Actor::DisableDynamics on all dynamics enabled actors,
+   * all handles to any DynamicsBody or DynamicsJoint objects held by applications
+   * will become detached from their actors and the simulation therefore should be discarded.
+   */
+  static void DestroyInstance();
+
 // Methods that modify the simulation
 public:
 
index 34deb3b95008b42dc1097b5de462b6ea484f465e..1e1dc481695584dde1905174b0fd277fb2dc234a 100644 (file)
 #include <dali/public-api/object/type-registry.h>
 #include <dali/public-api/render-tasks/render-task-list.h>
 
-#ifdef DYNAMICS_SUPPORT
-#include <dali/internal/event/dynamics/dynamics-world-config-impl.h>
-#include <dali/internal/event/dynamics/dynamics-world-impl.h>
-#include <dali/integration-api/dynamics/dynamics-factory-intf.h>
-#include <dali/integration-api/dynamics/dynamics-world-settings.h>
-#endif
-
 using Dali::Internal::SceneGraph::Node;
 
 namespace Dali
@@ -473,47 +466,6 @@ void Stage::SetDpi(Vector2 dpi)
   mDpi = dpi;
 }
 
-#ifdef DYNAMICS_SUPPORT
-
-DynamicsNotifier& Stage::GetDynamicsNotifier()
-{
-  return mDynamicsNotifier;
-}
-
-DynamicsWorldPtr Stage::InitializeDynamics(DynamicsWorldConfigPtr config)
-{
-  if( !mDynamicsFactory )
-  {
-    mDynamicsFactory = ThreadLocalStorage::Get().GetPlatformAbstraction().GetDynamicsFactory();
-  }
-
-  if( mDynamicsFactory && !mDynamicsWorld )
-  {
-    if( mDynamicsFactory->InitializeDynamics( *(config->GetSettings()) ) )
-    {
-      mDynamicsWorld = DynamicsWorld::New();
-      mDynamicsWorld->Initialize( *this, *mDynamicsFactory, config );
-    }
-  }
-  return mDynamicsWorld;
-}
-
-DynamicsWorldPtr Stage::GetDynamicsWorld()
-{
-  return mDynamicsWorld;
-}
-
-void Stage::TerminateDynamics()
-{
-  if( mDynamicsWorld )
-  {
-    mDynamicsWorld->Terminate(*this);
-    mDynamicsWorld = NULL;
-  }
-}
-
-#endif // DYNAMICS_SUPPORT
-
 void Stage::KeepRendering( float durationSeconds )
 {
   // Send message to keep rendering
@@ -648,9 +600,6 @@ Stage::Stage( AnimationPlaylist& playlist,
   mBackgroundColor(Dali::Stage::DEFAULT_BACKGROUND_COLOR),
   mViewMode( MONO ),
   mStereoBase( DEFAULT_STEREO_BASE ),
-#ifdef DYNAMICS_SUPPORT
-  mDynamicsFactory(NULL),
-#endif
   mSystemOverlay(NULL)
 {
 }
index fa16d70ce5c8dceaca634154191ccd30bc287953..33c7cc90badd7bc92eb5b49e76422696e66b7792 100644 (file)
 #include <dali/public-api/math/vector4.h>
 #include <dali/public-api/render-tasks/render-task.h>
 
-#ifdef DYNAMICS_SUPPORT
-#include <dali/internal/event/dynamics/dynamics-declarations.h>
-#include <dali/internal/event/dynamics/dynamics-notifier.h>
-#endif
-
 namespace Dali
 {
 
@@ -49,7 +44,6 @@ struct Vector2;
 namespace Integration
 {
 class SystemOverlay;
-class DynamicsFactory;
 }
 
 namespace Internal
@@ -282,31 +276,6 @@ public:
    */
   void SetDpi( Vector2 dpi );
 
-#ifdef DYNAMICS_SUPPORT
-
-  /**
-   * Return the Dynamics Simulation Notifier object
-   * @return The Dynamics Simulation Notifier object
-   */
-  DynamicsNotifier& GetDynamicsNotifier();
-
-  /**
-   * @copydoc Dali::Stage::InitializeDynamics
-   */
-  DynamicsWorldPtr InitializeDynamics(DynamicsWorldConfigPtr config);
-
-  /**
-   * @copydoc Dali::Stage::GetDynamicsWorld
-   */
-  DynamicsWorldPtr GetDynamicsWorld();
-
-  /**
-   * @copydoc Dali::Stage::TerminateDynamics
-   */
-  void TerminateDynamics();
-
-#endif // DYNAMICS_SUPPORT
-
   NotificationManager& GetNotificationManager()
   {
     return mNotificationManager;
@@ -479,16 +448,6 @@ private:
   // The object registry
   ObjectRegistryPtr mObjectRegistry;
 
-#ifdef DYNAMICS_SUPPORT
-
-  DynamicsNotifier mDynamicsNotifier;
-
-  // The Dynamics simulation world object
-  Integration::DynamicsFactory* mDynamicsFactory;   // Not owned pointer to DynamicsFactory (PlatformAbstraction will clean up)
-  DynamicsWorldPtr mDynamicsWorld;
-
-#endif // DYNAMICS_SUPPORT
-
   // The list of render-tasks
   IntrusivePtr<RenderTaskList> mRenderTaskList;
 
index 04944f9d75841c04a936945ee2e8e0d2d6f7a566..ce9f1a4da07fb2422a530b3523b9ba4f59363132 100644 (file)
@@ -34,7 +34,10 @@ __thread ThreadLocalStorage* threadLocal = NULL;
 }
 
 ThreadLocalStorage::ThreadLocalStorage(Core* core)
-: mCore(core)
+: mCore( core )
+#ifdef DYNAMICS_SUPPORT
+, mDynamicsWorldInstance( NULL )
+#endif
 {
   DALI_ASSERT_ALWAYS( threadLocal == NULL && "Cannot create more than one ThreadLocalStorage object" );
 
@@ -48,6 +51,12 @@ ThreadLocalStorage::~ThreadLocalStorage()
 
 void ThreadLocalStorage::Remove()
 {
+#ifdef DYNAMICS_SUPPORT
+  if( mDynamicsWorldInstance )
+  {
+    mDynamicsWorldInstance.Reset();
+  }
+#endif
   threadLocal = NULL;
 }
 
@@ -69,6 +78,18 @@ ThreadLocalStorage* ThreadLocalStorage::GetInternal()
   return threadLocal;
 }
 
+#ifdef DYNAMICS_SUPPORT
+Dali::Internal::DynamicsWorldPtr ThreadLocalStorage::GetDynamicsWorldInstance()
+{
+  if( !mDynamicsWorldInstance )
+  {
+    // Create the instance if it doesn't exist.
+    mDynamicsWorldInstance = DynamicsWorld::New();
+  }
+  return mDynamicsWorldInstance;
+}
+#endif
+
 Dali::Integration::PlatformAbstraction& ThreadLocalStorage::GetPlatformAbstraction()
 {
   return mCore->GetPlatform();
index 01dbcbf7249f81b7c875b320defe6658bb1e874e..90e37224d158889d8705d815da3a661d86a4422c 100644 (file)
@@ -20,6 +20,9 @@
 
 // INTERNAL INCLUDES
 #include <dali/internal/event/common/stage-def.h>
+#ifdef DYNAMICS_SUPPORT
+#include <dali/internal/event/dynamics/dynamics-world-impl.h>
+#endif
 
 namespace Dali
 {
@@ -98,6 +101,14 @@ public:
    */
   Dali::Integration::PlatformAbstraction& GetPlatformAbstraction();
 
+#ifdef DYNAMICS_SUPPORT
+  /**
+   * Get DynamicsWorld instance
+   * @return A pointer to the current DynamicsWorld.
+   */
+  Dali::Internal::DynamicsWorldPtr GetDynamicsWorldInstance();
+#endif
+
   /**
    * Retrieve the update manager
    * @return reference to update manager
@@ -154,7 +165,10 @@ public:
 
 private:
 
-  Core* mCore;                            ///< reference to core
+  Core* mCore;                                              ///< reference to core
+#ifdef DYNAMICS_SUPPORT
+  Dali::Internal::DynamicsWorldPtr mDynamicsWorldInstance;  ///< Instance of DynamicsWorld (This does not need to be in core)
+#endif
 
 };
 
index cef2353c2ec35934ea8f7ae3f0ea5c07f6d1c3fd..857669428a507da6e136968662b187523dd4ef8e 100644 (file)
@@ -52,8 +52,7 @@ DynamicsBody::DynamicsBody(const std::string& name, DynamicsBodyConfigPtr config
   DALI_ASSERT_DEBUG(config);
 
   StagePtr stage( Stage::GetCurrent() );
-
-  DynamicsWorldPtr world( stage->GetDynamicsWorld() );
+  DynamicsWorldPtr world( DynamicsWorld::Get() );
 
   mDynamicsBody = new SceneGraph::DynamicsBody( *(world->GetSceneObject()), node );
 
@@ -92,7 +91,7 @@ DynamicsBody::~DynamicsBody()
   {
     DeleteBodyMessage( *( Stage::GetCurrent() ), *(GetSceneObject()) );
 
-    DynamicsWorldPtr world( Stage::GetCurrent()->GetDynamicsWorld() );
+    DynamicsWorldPtr world( DynamicsWorld::Get() );
 
     if( world )
     {
index 90db76d58bdbd3212ec080597a5d97bbed93b191..0b860b25d45e16d7495cf26dd236ced2f9f5e662 100644 (file)
@@ -37,15 +37,14 @@ DynamicsCapsuleShape::DynamicsCapsuleShape(const float radius, const float lengt
 {
   DALI_LOG_INFO(Debug::Filter::gDynamics, Debug::Verbose, "%s - (radius:%.1f length:%.1f)\n", __PRETTY_FUNCTION__, radius, length);
 
-  StagePtr stage( Stage::GetCurrent() );
-  DynamicsWorldPtr world( stage->GetDynamicsWorld() );
+  DynamicsWorldPtr world( DynamicsWorld::Get() );
   DALI_ASSERT_ALWAYS( world && "No Dynamics World !");
 
   SceneGraph::DynamicsCapsuleShape* capsuleShape = new SceneGraph::DynamicsCapsuleShape( *world->GetSceneObject() );
   mDynamicsShape = capsuleShape;
 
   // Queue a message to ensure the underlying dynamics object is created in the update thread
-  InitializeDynamicsCapsuleShapeMessage( *stage, *capsuleShape, radius, length );
+  InitializeDynamicsCapsuleShapeMessage( *Stage::GetCurrent(), *capsuleShape, radius, length );
 }
 
 DynamicsCapsuleShape::~DynamicsCapsuleShape()
index fd1915defade7f8dbe137e92847531fe03bc869f..0b463800a575e438f7b38cb358f3812bee121522 100644 (file)
@@ -37,15 +37,14 @@ DynamicsConeShape::DynamicsConeShape(const float radius, const float length)
 {
   DALI_LOG_INFO(Debug::Filter::gDynamics, Debug::Verbose, "%s - (radius:%.1f length:%.1f)\n", __PRETTY_FUNCTION__, radius, length);
 
-  StagePtr stage( Stage::GetCurrent() );
-  DynamicsWorldPtr world( stage->GetDynamicsWorld() );
+  DynamicsWorldPtr world( DynamicsWorld::Get() );
   DALI_ASSERT_ALWAYS( world && "No Dynamics World !");
 
   SceneGraph::DynamicsConeShape* coneShape = new SceneGraph::DynamicsConeShape( *world->GetSceneObject() );
   mDynamicsShape = coneShape;
 
   // Queue a message to ensure the underlying dynamics object is created in the update thread
-  InitializeDynamicsConeShapeMessage( *stage, *coneShape, radius, length );
+  InitializeDynamicsConeShapeMessage( *Stage::GetCurrent(), *coneShape, radius, length );
 }
 
 DynamicsConeShape::~DynamicsConeShape()
index 73e19459a56b0467a4b028fb5fc8d85a5385f4ef..8a7d40ceb4f8bbe94bc749a1a182db130b5ad9a2 100644 (file)
@@ -37,15 +37,14 @@ DynamicsCubeShape::DynamicsCubeShape(const Vector3& dimensions)
 {
   DALI_LOG_INFO(Debug::Filter::gDynamics, Debug::Verbose, "%s - (dimensions[%1.02f %1.02f %1.02f])\n", __PRETTY_FUNCTION__, dimensions.x, dimensions.y, dimensions.z);
 
-  StagePtr stage( Stage::GetCurrent() );
-  DynamicsWorldPtr world( stage->GetDynamicsWorld() );
+  DynamicsWorldPtr world( DynamicsWorld::Get() );
   DALI_ASSERT_ALWAYS( world && "No Dynamics World !");
 
   SceneGraph::DynamicsCubeShape* cubeShape = new SceneGraph::DynamicsCubeShape( *world->GetSceneObject() );
   mDynamicsShape = cubeShape;
 
   // Queue a message to ensure the underlying dynamics object is created in the update thread
-  InitializeDynamicsCubeShapeMessage( *stage, *cubeShape, dimensions );
+  InitializeDynamicsCubeShapeMessage( *Stage::GetCurrent(), *cubeShape, dimensions );
 }
 
 DynamicsCubeShape::~DynamicsCubeShape()
index bf05d6542b7d10c7ccc94dc95a07e57bc8a02637..ab99873a6fa5688d242a6a649c6db84bff8b6552 100644 (file)
@@ -37,15 +37,14 @@ DynamicsCylinderShape::DynamicsCylinderShape(const float radius, const float len
 {
   DALI_LOG_INFO(Debug::Filter::gDynamics, Debug::Verbose, "%s - (radius:%.1f length:%.1f)\n", __PRETTY_FUNCTION__, radius, length);
 
-  StagePtr stage( Stage::GetCurrent() );
-  DynamicsWorldPtr world( stage->GetDynamicsWorld() );
+  DynamicsWorldPtr world( DynamicsWorld::Get() );
   DALI_ASSERT_ALWAYS( world && "No Dynamics World !");
 
   SceneGraph::DynamicsCylinderShape* cylinderShape = new SceneGraph::DynamicsCylinderShape( *world->GetSceneObject() );
   mDynamicsShape = cylinderShape;
 
   // Queue a message to ensure the underlying dynamics object is created in the update thread
-  InitializeDynamicsCylinderShapeMessage( *stage, *cylinderShape, radius, length );
+  InitializeDynamicsCylinderShapeMessage( *Stage::GetCurrent(), *cylinderShape, radius, length );
 }
 
 DynamicsCylinderShape::~DynamicsCylinderShape()
index 3ddcdd853e292b3d18cd0d05ee96efc3bc5de626..3f09ff61c9ea4606844d9a429d78498af7787de4 100644 (file)
@@ -300,7 +300,7 @@ ActorPtr DynamicsJoint::GetActor( const bool first ) const
 {
   DynamicsBodyPtr body( first ? mBodyA : mBodyB );
 
-  return Stage::GetCurrent()->GetDynamicsWorld()->GetMappedActor( body->GetSceneObject() );
+  return DynamicsWorld::Get()->GetMappedActor( body->GetSceneObject() );
 }
 
 void DynamicsJoint::Connect( EventThreadServices& eventThreadServices )
index c074caa8d0ec33e4df3abc38df4897c70b04c861..0e91ad839bd0cc4521bbaa9996cf6142e1a6dce9 100644 (file)
@@ -37,8 +37,7 @@ DynamicsMeshShape::DynamicsMeshShape(Mesh& mesh)
 {
   DALI_LOG_INFO(Debug::Filter::gDynamics, Debug::Verbose, "%s\n", __PRETTY_FUNCTION__);
 
-  StagePtr stage( Stage::GetCurrent() );
-  DynamicsWorldPtr world( stage->GetDynamicsWorld() );
+  DynamicsWorldPtr world( DynamicsWorld::Get() );
   DALI_ASSERT_ALWAYS( world && "No Dynamics World !");
   ResourceManager& resourceManager( ThreadLocalStorage::Get().GetResourceManager() );
 
@@ -46,7 +45,7 @@ DynamicsMeshShape::DynamicsMeshShape(Mesh& mesh)
   mDynamicsShape = meshShape;
 
   // Queue a message to ensure the underlying dynamics object is created in the update thread
-  InitializeDynamicsMeshShapeMessage( *stage, *meshShape );
+  InitializeDynamicsMeshShapeMessage( *Stage::GetCurrent(), *meshShape );
 }
 
 DynamicsMeshShape::~DynamicsMeshShape()
diff --git a/dali/internal/event/dynamics/dynamics-notifier.cpp b/dali/internal/event/dynamics/dynamics-notifier.cpp
deleted file mode 100644 (file)
index 09cf29d..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/event/dynamics/dynamics-notifier.h>
-
-// INTERNAL HEADERS
-#include <dali/integration-api/debug.h>
-#include <dali/integration-api/dynamics/dynamics-collision-data.h>
-
-#include <dali/internal/event/common/stage-impl.h>
-#include <dali/internal/event/dynamics/dynamics-world-impl.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-DynamicsNotifier::DynamicsNotifier()
-{
-}
-
-DynamicsNotifier::~DynamicsNotifier()
-{
-}
-
-void DynamicsNotifier::CollisionImpact( Integration::DynamicsCollisionData* collisionData )
-{
-  if( Stage::GetCurrent()->GetDynamicsWorld() )
-  {
-    Stage::GetCurrent()->GetDynamicsWorld()->CollisionImpact(collisionData);
-  }
-  delete collisionData;
-}
-
-void DynamicsNotifier::CollisionScrape( Integration::DynamicsCollisionData* collisionData )
-{
-}
-
-void DynamicsNotifier::CollisionDisperse( Integration::DynamicsCollisionData* collisionData )
-{
-  if( Stage::GetCurrent()->GetDynamicsWorld() )
-  {
-    Stage::GetCurrent()->GetDynamicsWorld()->CollisionDisperse(collisionData);
-  }
-  delete collisionData;
-}
-
-} // namespace Internal
-
-} // namespace Dali
index 1cfea87ed5ea70a942ddac9793a0651103868532..00763211ad998e9dedd0b3056cc97c94e19be271 100644 (file)
@@ -34,13 +34,6 @@ struct DynamicsCollisionData;
 namespace Internal
 {
 
-namespace SceneGraph
-{
-
-class DynamicsBody;
-
-} // namespace SceneGraph
-
 /**
  * Interface used by the update-thread to trigger collision event signals.
  */
@@ -51,32 +44,36 @@ public:
   /**
    * Constructor.
    */
-  DynamicsNotifier();
+  DynamicsNotifier()
+  {
+  }
 
   /**
    * Virtual destructor.
    */
-  virtual ~DynamicsNotifier();
+  virtual ~DynamicsNotifier()
+  {
+  }
 
   /**
    * Invoked when the simulation detects a new collision between two bodies.
    * @param[in] collisionData Contains information about the colliding bodies, their
    *                          points of contact, and impact magnitude
    */
-  void CollisionImpact( Integration::DynamicsCollisionData* collisionData );
+  virtual void CollisionImpact( Integration::DynamicsCollisionData* collisionData ) = 0;
 
   /**
    * Invoked when the simulation detects two bodies already in collision scraping against each other.
    * @param[in] collisionData Contains information about the colliding bodies, their
    *                          points of contact, and impact magnitude
    */
-  void CollisionScrape( Integration::DynamicsCollisionData* collisionData );
+  virtual void CollisionScrape( Integration::DynamicsCollisionData* collisionData ) = 0;
 
   /**
    * Invoked when the simulation detects two previously colliding bodies moving apart.
    * @param[in] collisionData Contains information about the colliding bodies.
    */
-  void CollisionDisperse( Integration::DynamicsCollisionData* collisionData );
+  virtual void CollisionDisperse( Integration::DynamicsCollisionData* collisionData ) = 0;
 }; // class DynamicsNotifier
 
 inline MessageBase* CollisionImpactMessage( DynamicsNotifier& dynamicsNotifier, Integration::DynamicsCollisionData* collisionData )
index bd8c657d9cb5af47579ab97604c55f751cc847fa..8267cf9457d6ce581ddfd29e908bd502229b6096 100644 (file)
@@ -35,15 +35,14 @@ DynamicsSphereShape::DynamicsSphereShape(const float radius)
 {
   DALI_LOG_INFO(Debug::Filter::gDynamics, Debug::Verbose, "%s - (radius: %f)\n", __PRETTY_FUNCTION__, radius);
 
-  StagePtr stage( Stage::GetCurrent() );
-  DynamicsWorldPtr world( stage->GetDynamicsWorld() );
+  DynamicsWorldPtr world( DynamicsWorld::Get() );
   DALI_ASSERT_ALWAYS( world && "No Dynamics World !");
 
   SceneGraph::DynamicsSphereShape* sphereShape = new SceneGraph::DynamicsSphereShape(  *world->GetSceneObject() );
   mDynamicsShape = sphereShape;
 
   // Queue a message to ensure the underlying dynamics object is created in the update thread
-  InitializeDynamicsSphereShapeMessage( *stage, *sphereShape, radius );
+  InitializeDynamicsSphereShapeMessage( *Stage::GetCurrent(), *sphereShape, radius );
 }
 
 DynamicsSphereShape::~DynamicsSphereShape()
index 22f74b55507ec57920304d085991200491bf64d3..6c8056fdeb248298b48070a1fde0e0d40d22ce79 100644 (file)
 // INTERNAL INCLUDES
 #include <dali/integration-api/debug.h>
 #include <dali/integration-api/dynamics/dynamics-collision-data.h>
+#include <dali/integration-api/dynamics/dynamics-factory-intf.h>
 #include <dali/integration-api/dynamics/dynamics-world-settings.h>
+#include <dali/integration-api/platform-abstraction.h>
 #include <dali/internal/event/actors/actor-impl.h>
 #include <dali/internal/event/common/stage-impl.h>
+#include <dali/internal/event/common/thread-local-storage.h>
 #include <dali/internal/event/dynamics/dynamics-body-impl.h>
 #include <dali/internal/event/dynamics/dynamics-collision-impl.h>
 #include <dali/internal/event/dynamics/dynamics-joint-impl.h>
@@ -50,8 +53,8 @@ const char* const SIGNAL_COLLISION = "collision";
 
 BaseHandle Create()
 {
-  DynamicsWorldPtr p = Stage::GetCurrent()->GetDynamicsWorld();
-  return Dali::DynamicsWorld(p.Get());
+  DynamicsWorldPtr p = DynamicsWorld::Get();
+  return Dali::DynamicsWorld( p.Get() );
 }
 
 TypeRegistration mType( typeid(Dali::DynamicsWorld), typeid(Dali::Handle), Create );
@@ -78,9 +81,49 @@ DynamicsWorld::DynamicsWorld(const std::string& name)
   DALI_LOG_INFO(Debug::Filter::gDynamics, Debug::Verbose, "%s - (\"%s\")\n", __PRETTY_FUNCTION__, name.c_str());
 }
 
+DynamicsWorldPtr DynamicsWorld::GetInstance( DynamicsWorldConfigPtr configuration )
+{
+  Dali::Integration::DynamicsFactory* dynamicsFactoryInstance = ThreadLocalStorage::Get().GetPlatformAbstraction().GetDynamicsFactory();
+  Dali::Internal::DynamicsWorldPtr dynamicsWorldInstance = ThreadLocalStorage::Get().GetDynamicsWorldInstance();
+
+  if( dynamicsFactoryInstance && dynamicsWorldInstance )
+  {
+    if( dynamicsFactoryInstance->InitializeDynamics( *( configuration->GetSettings() ) ) )
+    {
+      StagePtr stage = Stage::GetCurrent();
+      if( stage != NULL )
+      {
+        dynamicsWorldInstance->Initialize( *stage, *dynamicsFactoryInstance, configuration );
+      }
+    }
+  }
+
+  return dynamicsWorldInstance;
+}
+
+DynamicsWorldPtr DynamicsWorld::Get()
+{
+  return ThreadLocalStorage::Get().GetDynamicsWorldInstance();
+}
+
+void DynamicsWorld::DestroyInstance()
+{
+  Dali::Internal::DynamicsWorldPtr dynamicsWorldInstance = ThreadLocalStorage::Get().GetDynamicsWorldInstance();
+
+  if( dynamicsWorldInstance )
+  {
+    StagePtr stage = Stage::GetCurrent();
+    if( stage )
+    {
+      dynamicsWorldInstance->Terminate( *stage );
+    }
+    dynamicsWorldInstance.Reset();
+  }
+}
+
 void DynamicsWorld::Initialize(Stage& stage, Integration::DynamicsFactory& dynamicsFactory, DynamicsWorldConfigPtr config)
 {
-  mDynamicsWorld = new SceneGraph::DynamicsWorld( stage.GetDynamicsNotifier(),
+  mDynamicsWorld = new SceneGraph::DynamicsWorld( *this,
                                                   stage.GetNotificationManager(),
                                                   dynamicsFactory );
 
@@ -114,18 +157,6 @@ DynamicsWorld::~DynamicsWorld()
   DALI_LOG_INFO(Debug::Filter::gDynamics, Debug::Verbose, "%s\n", __PRETTY_FUNCTION__);
 }
 
-DynamicsWorldPtr DynamicsWorld::Get()
-{
-  DynamicsWorldPtr world;
-
-  StagePtr stage = Stage::GetCurrent();
-  if( stage != NULL )
-  {
-    world = stage->GetDynamicsWorld();
-  }
-  return world;
-}
-
 bool DynamicsWorld::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
 {
   bool connected( true );
@@ -270,6 +301,8 @@ void DynamicsWorld::CollisionImpact( Integration::DynamicsCollisionData* collisi
       }
     }
   }
+
+  delete collisionData;
 }
 
 void DynamicsWorld::CollisionScrape( Integration::DynamicsCollisionData* collisionData )
@@ -319,6 +352,8 @@ void DynamicsWorld::CollisionDisperse( Integration::DynamicsCollisionData* colli
       }
     }
   }
+
+  delete collisionData;
 }
 
 void DynamicsWorld::MapActor(SceneGraph::DynamicsBody* sceneObject, Actor& actor)
index 9bd35f60d4e61eff40d459fc7ff1a38b62854235..1817c49f76b047c96e0705f998ea596b6884abe6 100644 (file)
@@ -23,6 +23,7 @@
 #include <dali/devel-api/common/map-wrapper.h>
 #include <dali/internal/common/message.h>
 #include <dali/internal/event/actors/actor-declarations.h>
+#include <dali/internal/event/dynamics/dynamics-notifier.h>
 #include <dali/internal/event/dynamics/dynamics-declarations.h>
 #include <dali/internal/event/effects/shader-declarations.h>
 #include <dali/devel-api/dynamics/dynamics-world.h>
@@ -54,7 +55,7 @@ class DynamicsWorld;
 } // namespace SceneGraph
 
 /// @copydoc Dali::DynamicsWorld
-class DynamicsWorld : public BaseObject
+class DynamicsWorld : public BaseObject, public Dali::Internal::DynamicsNotifier
 {
 public:
   static DynamicsWorldPtr New();
@@ -79,12 +80,29 @@ private:
   DynamicsWorld& operator=(const DynamicsWorld&);
 
 public:
+
   /**
-   * Singleton getter
-   * @return A pointer to the dynamics world if it is installed
+   * @copydoc Dali::DynamicsWorld::GetInstance()
+   */
+  static DynamicsWorldPtr GetInstance( DynamicsWorldConfigPtr configuration );
+
+  /**
+   * @copydoc Dali::DynamicsWorld::Get()
    */
   static DynamicsWorldPtr Get();
 
+  /**
+   * @copydoc Dali::DynamicsWorld::DestroyInstance()
+   */
+  static void DestroyInstance();
+
+  /**
+   * Gets the instance of the Dynamics Notifier, if created with GetInstance().
+   *
+   * @return The DynamicsNotifier instance.
+   */
+  static DynamicsNotifier& GetNotifier();
+
   /**
    * Connects a callback function with the object's signals.
    * @param[in] object The object providing the signal.
index c9d3df4cbe4f98406be7115b483bf08c50ee472d..1db3f1cbb3b960802ea5687afb70c3889f6fce5a 100644 (file)
@@ -178,7 +178,6 @@ internal_dynamics_src_files = \
   $(internal_src_dir)/event/dynamics/dynamics-cube-shape-impl.cpp \
   $(internal_src_dir)/event/dynamics/dynamics-cylinder-shape-impl.cpp \
   $(internal_src_dir)/event/dynamics/dynamics-joint-impl.cpp \
-  $(internal_src_dir)/event/dynamics/dynamics-notifier.cpp \
   $(internal_src_dir)/event/dynamics/dynamics-mesh-shape-impl.cpp \
   $(internal_src_dir)/event/dynamics/dynamics-shape-impl.cpp \
   $(internal_src_dir)/event/dynamics/dynamics-sphere-shape-impl.cpp \
index abf0b11db9783b50f6d98e74a0c96566689638b1..99d3c6635299c22054d5c576ad0fef3239e20526 100644 (file)
 #include <dali/public-api/actors/layer.h>
 #include <dali/public-api/object/object-registry.h>
 
-#include <dali/devel-api/dynamics/dynamics-world.h>
-#include <dali/devel-api/dynamics/dynamics-world-config.h>
-
-#ifdef DYNAMICS_SUPPORT
-#include <dali/internal/event/dynamics/dynamics-declarations.h>
-#include <dali/internal/event/dynamics/dynamics-world-config-impl.h>
-#include <dali/internal/event/dynamics/dynamics-world-impl.h>
-#endif
-
 namespace Dali
 {
 
@@ -136,33 +127,6 @@ ObjectRegistry Stage::GetObjectRegistry() const
   return ObjectRegistry(&internal);
 }
 
-DynamicsWorld Stage::InitializeDynamics(DynamicsWorldConfig config)
-{
-#ifdef DYNAMICS_SUPPORT
-  Internal::DynamicsWorldConfigPtr configImpl( &(GetImplementation(config)) );
-
-  return DynamicsWorld( GetImplementation(*this).InitializeDynamics(configImpl).Get() );
-#else
-  return DynamicsWorld();
-#endif
-}
-
-DynamicsWorld Stage::GetDynamicsWorld()
-{
-#ifdef DYNAMICS_SUPPORT
-  return DynamicsWorld( GetImplementation(*this).GetDynamicsWorld().Get() );
-#else
-  return DynamicsWorld();
-#endif
-}
-
-void Stage::TerminateDynamics()
-{
-#ifdef DYNAMICS_SUPPORT
-  GetImplementation(*this).TerminateDynamics();
-#endif
-}
-
 void Stage::KeepRendering( float durationSeconds )
 {
   GetImplementation(*this).KeepRendering( durationSeconds );
index 5ea7d9425324d5c546fd660cd916057b76c3845a..59305b686d7b229d108a1c0a9bf391dc63357de0 100644 (file)
@@ -37,8 +37,6 @@ class RenderTaskList;
 struct Vector2;
 struct Vector3;
 struct Vector4;
-class DynamicsWorld;
-class DynamicsWorldConfig;
 struct KeyEvent;
 struct TouchEvent;
 struct WheelEvent;
@@ -212,35 +210,6 @@ public:
    */
   ObjectRegistry GetObjectRegistry() const;
 
-  // Dynamics
-
-  /**
-   * @brief Initialise the dynamics simulation and create a DynamicsWorld object.
-   *
-   * Only one instance of DynamicsWorld will be created, so calling this method multiple times
-   * will return the same DynamicsWorld object.
-   * @param[in] config A DynamicsWorldConfig object describing the required capabilities of the dynamics world.
-   * @return A handle to the world object of the dynamics simulation, or an empty handle if Dynamics capable
-   *         of supporting the requirement in config is not available on the platform.
-   */
-  DynamicsWorld InitializeDynamics(DynamicsWorldConfig config);
-
-  /**
-   * @brief Get a handle to the world object of the dynamics simulation.
-   *
-   * @return A handle to the world object of the dynamics simulation
-   */
-  DynamicsWorld GetDynamicsWorld();
-
-  /**
-   * @brief Terminate the dynamics simulation.
-   *
-   * Calls Actor::DisableDynamics on all dynamics enabled actors,
-   * all handles to any DynamicsBody or DynamicsJoint objects held by applications
-   * will become detached from their actors and the simulation therefore should be discarded.
-   */
-  void TerminateDynamics();
-
   // Rendering
 
   /**