UTC test coverage
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Stage.cpp
index 1ab4559..b41d9cf 100644 (file)
 #include <stdlib.h>
 
 #include <dali/public-api/dali-core.h>
+#include <dali/integration-api/context-notifier.h>
 #include <dali/integration-api/events/key-event-integ.h>
 #include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/devel-api/dynamics/dynamics.h>
 
 #include <dali-test-suite-utils.h>
 
 using namespace Dali;
-using namespace std;
 
 void stage_test_startup(void)
 {
@@ -135,6 +136,45 @@ bool DummyTouchCallback( Actor actor, const TouchEvent& touch )
   return true;
 }
 
+
+struct ContextStatusFunctor
+{
+  ContextStatusFunctor(bool& calledFlag) : mCalledFlag( calledFlag )
+  {
+    mCalledFlag = false;
+  }
+
+  void operator()()
+  {
+    mCalledFlag = true;
+  }
+  void Reset()
+  {
+    mCalledFlag = false;
+  }
+
+  bool& mCalledFlag;
+};
+
+struct SceneCreatedStatusFunctor
+{
+  SceneCreatedStatusFunctor(bool& calledFlag) : mCalledFlag( calledFlag )
+  {
+    mCalledFlag = false;
+  }
+
+  void operator()()
+  {
+    mCalledFlag = true;
+  }
+  void Reset()
+  {
+    mCalledFlag = false;
+  }
+
+  bool& mCalledFlag;
+};
+
 } // unnamed namespace
 
 
@@ -167,6 +207,17 @@ int UtcDaliStageGetCurrent(void)
   END_TEST;
 }
 
+int UtcDaliStageAssign(void)
+{
+  TestApplication application;
+  Stage stage = Stage::GetCurrent();
+  Stage stage2;
+  stage2 = stage;
+
+  DALI_TEST_CHECK(stage2);
+  END_TEST;
+}
+
 int UtcDaliStageIsInstalled(void)
 {
   DALI_TEST_CHECK(!Stage::IsInstalled());
@@ -264,6 +315,21 @@ int UtcDaliStageGetDpi03(void)
   END_TEST;
 }
 
+int UtcDaliStageInitializeDynamicsP(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
+
+  END_TEST;
+}
+
 int UtcDaliStageGetLayerCount(void)
 {
   TestApplication application;
@@ -595,3 +661,42 @@ int UtcDaliStageTouchedSignal(void)
   }
   END_TEST;
 }
+
+int UtcDaliStageContextLostRegainedSignals(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 );
+
+  Integration::Core& core = app.GetCore();
+  Integration::ContextNotifierInterface* notifier = core.GetContextNotifier();
+  notifier->NotifyContextLost();
+  DALI_TEST_EQUALS( contextLost, true, TEST_LOCATION );
+
+  notifier->NotifyContextRegained();
+  DALI_TEST_EQUALS( contextRegained, true, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliStageSceneCreatedSignal(void)
+{
+  TestApplication app;
+  Stage stage = Stage::GetCurrent();
+
+  bool signalCalled = false;
+  SceneCreatedStatusFunctor sceneCreatedFunctor( signalCalled );
+  stage.SceneCreatedSignal().Connect(&app, sceneCreatedFunctor );
+
+  Integration::Core& core = app.GetCore();
+  core.SceneCreated();
+  DALI_TEST_EQUALS( signalCalled, true, TEST_LOCATION );
+
+  END_TEST;
+}