Lifecycle controller 04/31304/6
authorKingsley Stephens <k.stephens@partner.samsung.com>
Wed, 3 Dec 2014 13:27:09 +0000 (13:27 +0000)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Thu, 11 Dec 2014 08:56:09 +0000 (00:56 -0800)
Change-Id: Idb04be73b0a7060ef302507723850c23c71875dc

adaptors/common/application-impl.cpp
adaptors/common/file.list
adaptors/common/lifecycle-controller-impl.cpp [new file with mode: 0644]
adaptors/common/lifecycle-controller-impl.h [new file with mode: 0644]
adaptors/public-api/adaptor-framework/lifecycle-controller.cpp [new file with mode: 0644]
adaptors/public-api/adaptor-framework/lifecycle-controller.h [new file with mode: 0644]
adaptors/public-api/dali.h
adaptors/public-api/file.list
automated-tests/src/dali-adaptor-internal/CMakeLists.txt
automated-tests/src/dali-adaptor-internal/utc-Dali-Lifecycle-Controller.cpp [new file with mode: 0644]

index fa976b9..2de1de4 100644 (file)
@@ -26,6 +26,7 @@
 #include <command-line-options.h>
 #include <common/adaptor-impl.h>
 #include <singleton-service-impl.h>
+#include <lifecycle-controller-impl.h>
 
 namespace Dali
 {
@@ -196,6 +197,17 @@ void Application::OnInit()
 
   mInitialized = true;
 
+  // Wire up the LifecycleController
+  Dali::LifecycleController lifecycleController = Dali::LifecycleController::Get();
+
+  InitSignal().Connect( &GetImplementation( lifecycleController ), &LifecycleController::OnInit );
+  TerminateSignal().Connect( &GetImplementation( lifecycleController ), &LifecycleController::OnTerminate );
+  PauseSignal().Connect( &GetImplementation( lifecycleController ), &LifecycleController::OnPause );
+  ResumeSignal().Connect( &GetImplementation( lifecycleController ), &LifecycleController::OnResume );
+  ResetSignal().Connect( &GetImplementation( lifecycleController ), &LifecycleController::OnReset );
+  ResizeSignal().Connect( &GetImplementation( lifecycleController ), &LifecycleController::OnResize );
+  LanguageChangedSignal().Connect( &GetImplementation( lifecycleController ), &LifecycleController::OnLanguageChanged );
+
   Dali::Application application(this);
   mInitSignalV2.Emit( application );
 }
index 98d4cbd..d001d82 100644 (file)
@@ -16,6 +16,7 @@ adaptor_common_internal_src_files = \
   $(adaptor_common_dir)/indicator-impl.cpp  \
   $(adaptor_common_dir)/indicator-buffer.cpp  \
   $(adaptor_common_dir)/kernel-trace.cpp  \
+  $(adaptor_common_dir)/lifecycle-controller-impl.cpp \
   $(adaptor_common_dir)/locale-utils.cpp  \
   $(adaptor_common_dir)/native-bitmap-buffer-impl.cpp \
   $(adaptor_common_dir)/object-profiler.cpp \
diff --git a/adaptors/common/lifecycle-controller-impl.cpp b/adaptors/common/lifecycle-controller-impl.cpp
new file mode 100644 (file)
index 0000000..ba43537
--- /dev/null
@@ -0,0 +1,221 @@
+/*
+ * 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 "lifecycle-controller-impl.h"
+
+// INTERNAL INCLUDES
+#include <dali/public-api/object/type-registry.h>
+#include <adaptor-impl.h>
+#include <singleton-service-impl.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+
+BaseHandle Create()
+{
+  BaseHandle handle( LifecycleController::Get() );
+
+  if ( !handle && Adaptor::IsAvailable() )
+  {
+    Dali::SingletonService service( SingletonService::Get() );
+    if ( service )
+    {
+      Dali::LifecycleController lifecycleController = Dali::LifecycleController( new LifecycleController() );
+      service.Register( typeid( lifecycleController ), lifecycleController );
+      handle = lifecycleController;
+    }
+  }
+
+  return handle;
+}
+TypeRegistration LIFECYCLE_CONTROLLER_TYPE( typeid(Dali::LifecycleController), typeid(Dali::BaseHandle), Create, true /* Create Instance At Startup */ );
+
+} // unnamed namespace
+
+Dali::LifecycleController LifecycleController::Get()
+{
+  Dali::LifecycleController lifecycleController;
+
+  Dali::SingletonService service( SingletonService::Get() );
+  if ( service )
+  {
+    // Check whether the singleton is already created
+    Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::LifecycleController ) );
+    if(handle)
+    {
+      // If so, downcast the handle
+      lifecycleController = Dali::LifecycleController( dynamic_cast< LifecycleController* >( handle.GetObjectPtr() ) );
+    }
+    else
+    {
+      lifecycleController = Dali::LifecycleController( new LifecycleController() );
+      service.Register( typeid( lifecycleController ), lifecycleController );
+    }
+  }
+
+  return lifecycleController;
+}
+
+LifecycleController::LifecycleController()
+{
+}
+
+LifecycleController::~LifecycleController()
+{
+}
+
+Dali::LifecycleController::LifecycleSignalV2& LifecycleController::InitSignal()
+{
+  return mInitSignal;
+}
+
+void LifecycleController::EmitInitSignal()
+{
+  if( !mInitSignal.Empty() )
+  {
+    mInitSignal.Emit();
+  }
+}
+
+Dali::LifecycleController::LifecycleSignalV2& LifecycleController::TerminateSignal()
+{
+  return mTerminateSignal;
+}
+
+void LifecycleController::EmitTerminateSignal()
+{
+  if( !mTerminateSignal.Empty() )
+  {
+    mTerminateSignal.Emit();
+  }
+}
+
+Dali::LifecycleController::LifecycleSignalV2& LifecycleController::PauseSignal()
+{
+  return mPauseSignal;
+}
+
+void LifecycleController::EmitPauseSignal()
+{
+  if( !mPauseSignal.Empty() )
+  {
+    mPauseSignal.Emit();
+  }
+}
+
+Dali::LifecycleController::LifecycleSignalV2& LifecycleController::ResumeSignal()
+{
+  return mResumeSignal;
+}
+
+void LifecycleController::EmitResumeSignal()
+{
+  if( !mResumeSignal.Empty() )
+  {
+    mResumeSignal.Emit();
+  }
+}
+
+Dali::LifecycleController::LifecycleSignalV2& LifecycleController::ResetSignal()
+{
+  return mResetSignal;
+}
+
+void LifecycleController::EmitResetSignal()
+{
+  if( !mResetSignal.Empty() )
+  {
+    mResetSignal.Emit();
+  }
+}
+
+Dali::LifecycleController::LifecycleSignalV2& LifecycleController::ResizeSignal()
+{
+  return mResizeSignal;
+}
+
+void LifecycleController::EmitResizeSignal()
+{
+  if( !mResizeSignal.Empty() )
+  {
+    mResizeSignal.Emit();
+  }
+}
+
+Dali::LifecycleController::LifecycleSignalV2& LifecycleController::LanguageChangedSignal()
+{
+  return mLanguageChangedSignal;
+}
+
+void LifecycleController::EmitLanguageChangedSignal()
+{
+  if( !mLanguageChangedSignal.Empty() )
+  {
+    mLanguageChangedSignal.Emit();
+  }
+}
+
+void LifecycleController::OnInit( Dali::Application& app )
+{
+  EmitInitSignal();
+}
+
+void LifecycleController::OnTerminate( Dali::Application& app )
+{
+  EmitTerminateSignal();
+}
+
+void LifecycleController::OnPause( Dali::Application& app )
+{
+  EmitPauseSignal();
+}
+
+void LifecycleController::OnResume( Dali::Application& app )
+{
+  EmitResumeSignal();
+}
+
+void LifecycleController::OnReset( Dali::Application& app )
+{
+  EmitResetSignal();
+}
+
+void LifecycleController::OnLanguageChanged( Dali::Application& app )
+{
+  EmitLanguageChangedSignal();
+}
+
+void LifecycleController::OnResize( Dali::Application& app )
+{
+  EmitResizeSignal();
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
diff --git a/adaptors/common/lifecycle-controller-impl.h b/adaptors/common/lifecycle-controller-impl.h
new file mode 100644 (file)
index 0000000..73cd6ca
--- /dev/null
@@ -0,0 +1,227 @@
+#ifndef __DALI_INTERNAL_LIFECYCLE_CONTROLLER_H__
+#define __DALI_INTERNAL_LIFECYCLE_CONTROLLER_H__
+
+/*
+ * 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/ref-object.h>
+#include <dali/public-api/object/base-object.h>
+
+// INTERNAL INCLUDES
+#include <lifecycle-controller.h>
+#include <application.h>
+
+namespace Dali
+{
+
+class Adaptor;
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * This provides signals that are emitted according the lifecylce of the program.
+ */
+class LifecycleController : public BaseObject, public ConnectionTracker
+{
+public:
+
+  // Creation & Destruction
+
+  /**
+   * Constructor.
+   */
+  LifecycleController();
+
+  /**
+   * Retrieve the initialized instance of the LifecycleController.
+   * @return Handle to LifecycleController.
+   */
+  static Dali::LifecycleController Get();
+
+  // Signals
+
+  /**
+   * @copydoc Dali::StyleMonitor::InitSignal()
+   */
+  Dali::LifecycleController::LifecycleSignalV2& InitSignal();
+
+  /**
+   * @copydoc Dali::StyleMonitor::TerminateSignal()
+   */
+  Dali::LifecycleController::LifecycleSignalV2& TerminateSignal();
+
+  /**
+   * @copydoc Dali::StyleMonitor::PauseSignal()
+   */
+  Dali::LifecycleController::LifecycleSignalV2& PauseSignal();
+
+  /**
+   * @copydoc Dali::StyleMonitor::ResumeSignal()
+   */
+  Dali::LifecycleController::LifecycleSignalV2& ResumeSignal();
+
+  /**
+   * @copydoc Dali::StyleMonitor::ResetSignal()
+   */
+  Dali::LifecycleController::LifecycleSignalV2& ResetSignal();
+
+  /**
+   * @copydoc Dali::StyleMonitor::ResizeSignal()
+   */
+  Dali::LifecycleController::LifecycleSignalV2& ResizeSignal();
+
+  /**
+   * @copydoc Dali::StyleMonitor::LanguageChangedSignal()
+   */
+  Dali::LifecycleController::LifecycleSignalV2& LanguageChangedSignal();
+
+public:
+
+  /**
+   * Called when the framework is initialised.
+   *
+   * @param[in] app The application instance
+   */
+  void OnInit( Dali::Application& app );
+
+  /**
+   * Called when the framework is terminated.
+   *
+   * @param[in] app The application instance
+   */
+  void OnTerminate( Dali::Application& app );
+
+  /**
+   * Called when the framework is paused.
+   *
+   * @param[in] app The application instance
+   */
+  void OnPause( Dali::Application& app );
+
+  /**
+   * Called when the framework resumes from a paused state.
+   *
+   * @param[in] app The application instance
+   */
+  void OnResume( Dali::Application& app );
+
+  /**
+   * Called when the framework informs the application that it should reset itself.
+   *
+   * @param[in] app The application instance
+   */
+  void OnReset( Dali::Application& app );
+
+  /**
+   * Called when the framework informs the application that the language of the device has changed.
+   *
+   * @param[in] app The application instance
+   */
+  void OnLanguageChanged( Dali::Application& app );
+
+  /**
+   * Signal handler when the adaptor's window resizes itself.
+   *
+   * @param[in] app The application instance
+   */
+  void OnResize( Dali::Application& app );
+
+protected:
+
+  /**
+   * Virtual Destructor.
+   */
+  virtual ~LifecycleController();
+
+private:
+
+  /**
+   * Emit the init signal.
+   */
+  void EmitInitSignal();
+
+  /**
+   * Emit the init signal.
+   */
+  void EmitTerminateSignal();
+
+  /**
+   * Emit the init signal.
+   */
+  void EmitPauseSignal();
+
+  /**
+   * Emit the init signal.
+   */
+  void EmitResumeSignal();
+
+  /**
+   * Emit the init signal.
+   */
+  void EmitResetSignal();
+
+  /**
+   * Emit the init signal.
+   */
+  void EmitResizeSignal();
+
+  /**
+   * Emit the init signal.
+   */
+  void EmitLanguageChangedSignal();
+
+private:
+
+  // Signals
+  Dali::LifecycleController::LifecycleSignalV2 mInitSignal;
+  Dali::LifecycleController::LifecycleSignalV2 mTerminateSignal;
+  Dali::LifecycleController::LifecycleSignalV2 mPauseSignal;
+  Dali::LifecycleController::LifecycleSignalV2 mResumeSignal;
+  Dali::LifecycleController::LifecycleSignalV2 mResetSignal;
+  Dali::LifecycleController::LifecycleSignalV2 mResizeSignal;
+  Dali::LifecycleController::LifecycleSignalV2 mLanguageChangedSignal;
+
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+// Additional Helpers for public-api forwarding methods
+
+inline Internal::Adaptor::LifecycleController& GetImplementation(Dali::LifecycleController& controller)
+{
+  DALI_ASSERT_ALWAYS(controller && "Controller handle is empty");
+  BaseObject& handle = controller.GetBaseObject();
+  return static_cast<Internal::Adaptor::LifecycleController&>(handle);
+}
+
+inline const Internal::Adaptor::LifecycleController& GetImplementation(const Dali::LifecycleController& controller)
+{
+  DALI_ASSERT_ALWAYS(controller && "Controller handle is empty");
+  const BaseObject& handle = controller.GetBaseObject();
+  return static_cast<const Internal::Adaptor::LifecycleController&>(handle);
+}
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_LIFECYCLE_CONTROLLER_H__
diff --git a/adaptors/public-api/adaptor-framework/lifecycle-controller.cpp b/adaptors/public-api/adaptor-framework/lifecycle-controller.cpp
new file mode 100644 (file)
index 0000000..a5996f7
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * 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 <lifecycle-controller.h>
+
+// INTERNAL INCLUDES
+#include <lifecycle-controller-impl.h>
+
+namespace Dali
+{
+
+LifecycleController::LifecycleController()
+{
+}
+
+LifecycleController::LifecycleController(const LifecycleController& controller)
+: BaseHandle(controller)
+{
+}
+
+LifecycleController LifecycleController::Get()
+{
+  return Internal::Adaptor::LifecycleController::Get();
+}
+
+LifecycleController::~LifecycleController()
+{
+}
+
+LifecycleController::LifecycleSignalV2& LifecycleController::InitSignal()
+{
+  return GetImplementation(*this).InitSignal();
+}
+
+LifecycleController::LifecycleSignalV2& LifecycleController::TerminateSignal()
+{
+  return GetImplementation(*this).TerminateSignal();
+}
+
+LifecycleController::LifecycleSignalV2& LifecycleController::PauseSignal()
+{
+  return GetImplementation(*this).PauseSignal();
+}
+
+LifecycleController::LifecycleSignalV2& LifecycleController::ResumeSignal()
+{
+  return GetImplementation(*this).ResumeSignal();
+}
+
+LifecycleController::LifecycleSignalV2& LifecycleController::ResetSignal()
+{
+  return GetImplementation(*this).ResetSignal();
+}
+
+LifecycleController::LifecycleSignalV2& LifecycleController::ResizeSignal()
+{
+  return GetImplementation(*this).ResizeSignal();
+}
+
+LifecycleController::LifecycleSignalV2& LifecycleController::LanguageChangedSignal()
+{
+  return GetImplementation(*this).LanguageChangedSignal();
+}
+
+LifecycleController& LifecycleController::operator=(const LifecycleController& monitor)
+{
+  if( *this != monitor )
+  {
+    BaseHandle::operator=(monitor);
+  }
+  return *this;
+}
+
+LifecycleController::LifecycleController(Internal::Adaptor::LifecycleController* internal)
+: BaseHandle(internal)
+{
+}
+
+} // namespace Dali
diff --git a/adaptors/public-api/adaptor-framework/lifecycle-controller.h b/adaptors/public-api/adaptor-framework/lifecycle-controller.h
new file mode 100644 (file)
index 0000000..0549a59
--- /dev/null
@@ -0,0 +1,154 @@
+#ifndef __DALI_LIFECYCLE_CONTROLLER_H__
+#define __DALI_LIFECYCLE_CONTROLLER_H__
+
+/*
+ * 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/base-handle.h>
+#include <dali/public-api/signals/dali-signal-v2.h>
+
+namespace Dali
+{
+
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class LifecycleController;
+}
+}
+
+/**
+ * @brief Provides application lifecycle events.
+ *
+ * Connect to the signals of this class to receive notification of events in the lifecycle
+ * of the application. The following example shows how to connect to the Init signal. This
+ * could be done for example in the constructor of a singleton that is known to be created
+ * at startup.
+ *
+ * @code
+ * void MyClass::MyClass()
+ * {
+ *   LifecycleController::Get().InitSignal().Connect( this, &MyClass::OnApplicationInit );
+ * }
+ *
+ * void MyClass::OnApplicationInit()
+ * {
+ *   // ... Do something on init
+ * }
+ * @endcode
+ */
+class DALI_IMPORT_API LifecycleController : public BaseHandle
+{
+public: // Typedefs
+
+  typedef SignalV2< void (void) > LifecycleSignalV2;   ///< Lifecycle Signal type
+
+public: // Creation & Destruction
+
+  /**
+   * @brief Create an uninitialized LifecycleController handle.
+   *
+   * Calling member functions when uninitialized is not allowed.
+   */
+  LifecycleController();
+
+  /**
+   * @brief Creates a copy of the handle.
+   *
+   * The copy will point to the same implementation as the original.
+   * @param[in]  monitor  The LifecycleController to copy from.
+   */
+  LifecycleController(const LifecycleController& monitor);
+
+  /**
+   * @brief Retrieve the initialized instance of the LifecycleController.
+   * @return Handle to LifecycleController.
+   */
+  static LifecycleController Get();
+
+  /**
+   * @brief Destructor
+   *
+   * This is non-virtual since derived Handle types must not contain data or virtual methods.
+   */
+  ~LifecycleController();
+
+public: // Signals
+
+  /**
+   * The user should connect to this signal to determine when they should initialise
+   * their application.
+   */
+  LifecycleSignalV2& InitSignal();
+
+  /**
+   * The user should connect to this signal to determine when they should terminate
+   * their application
+   */
+  LifecycleSignalV2& TerminateSignal();
+
+  /**
+   * The user should connect to this signal if they need to perform any special
+   * activities when the application is about to be paused.
+   */
+  LifecycleSignalV2& PauseSignal();
+
+  /**
+   * The user should connect to this signal if they need to perform any special
+   * activities when the application has resumed.
+   */
+  LifecycleSignalV2& ResumeSignal();
+
+  /**
+   * This signal is sent when the system requires the user to reinitialise itself.
+   */
+  LifecycleSignalV2& ResetSignal();
+
+  /**
+   * This signal is emitted when the window the application is rendering on is resized.
+   */
+  LifecycleSignalV2& ResizeSignal();
+
+  /**
+   * This signal is emitted when the language is changed on the device.
+   */
+  LifecycleSignalV2& LanguageChangedSignal();
+
+public: // Operators
+
+  /**
+   * @brief Assignment operator.
+   *
+   * The handle points to the same implementation as the one being copied from.
+   * @param[in]  controller  The LifecycleController to copy from.
+   * @return reference to this object
+   */
+  LifecycleController& operator=(const LifecycleController& controller);
+
+public: // Not intended for application developers
+  /**
+   * @brief This constructor is used internally to create a handle from an object pointer.
+   * @param [in] lifecycleController A pointer to the internal LifecycleController.
+   */
+  explicit DALI_INTERNAL LifecycleController(Internal::Adaptor::LifecycleController* lifecycleController);
+};
+
+} // namespace Dali
+
+#endif // __DALI_LIFECYCLE_CONTROLLER_H__
index 86159b5..47ad33a 100644 (file)
@@ -39,6 +39,7 @@
 #include <dali/public-api/adaptor-framework/haptic-player.h>
 #include <dali/public-api/adaptor-framework/imf-manager.h>
 #include <dali/public-api/adaptor-framework/key.h>
+#include <dali/public-api/adaptor-framework/lifecycle-controller.h>
 #include <dali/public-api/adaptor-framework/orientation.h>
 #include <dali/public-api/adaptor-framework/physical-keyboard.h>
 #include <dali/public-api/adaptor-framework/pixmap-image.h>
index 7e0c9b0..2d05a5a 100644 (file)
@@ -12,6 +12,7 @@ public_api_src_files = \
   $(adaptor_public_api_dir)/adaptor-framework/haptic-player.cpp \
   $(adaptor_public_api_dir)/adaptor-framework/imf-manager.cpp \
   $(adaptor_public_api_dir)/adaptor-framework/key.cpp \
+  $(adaptor_public_api_dir)/adaptor-framework/lifecycle-controller.cpp \
   $(adaptor_public_api_dir)/adaptor-framework/orientation.cpp \
   $(adaptor_public_api_dir)/adaptor-framework/physical-keyboard.cpp \
   $(adaptor_public_api_dir)/adaptor-framework/pixmap-image.cpp \
@@ -47,6 +48,7 @@ public_api_adaptor_framework_header_files = \
   $(adaptor_public_api_dir)/adaptor-framework/haptic-player.h \
   $(adaptor_public_api_dir)/adaptor-framework/imf-manager.h \
   $(adaptor_public_api_dir)/adaptor-framework/key.h \
+  $(adaptor_public_api_dir)/adaptor-framework/lifecycle-controller.h \
   $(adaptor_public_api_dir)/adaptor-framework/orientation.h \
   $(adaptor_public_api_dir)/adaptor-framework/physical-keyboard.h \
   $(adaptor_public_api_dir)/adaptor-framework/pixmap-image.h \
index a4e4fe3..b677e9e 100644 (file)
@@ -9,6 +9,7 @@ SET(TC_SOURCES
     utc-Dali-GifLoader.cpp
     utc-Dali-TiltSensor.cpp
     utc-Dali-CommandLineOptions.cpp
+    utc-Dali-Lifecycle-Controller.cpp
 )
 
 LIST(APPEND TC_SOURCES
diff --git a/automated-tests/src/dali-adaptor-internal/utc-Dali-Lifecycle-Controller.cpp b/automated-tests/src/dali-adaptor-internal/utc-Dali-Lifecycle-Controller.cpp
new file mode 100644 (file)
index 0000000..06755f4
--- /dev/null
@@ -0,0 +1,218 @@
+/*
+ * 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <stdlib.h>
+#include <iostream>
+#include <dali.h>
+#include <dali-test-suite-utils.h>
+
+#include <lifecycle-controller-impl.h>
+
+using namespace Dali;
+
+void utc_dali_lifecycle_controller_startup(void)
+{
+  test_return_value = TET_UNDEF;
+}
+
+void utc_dali_lifecycle_controller_cleanup(void)
+{
+  test_return_value = TET_PASS;
+}
+
+namespace
+{
+
+bool g_OnInitCalled = false;
+bool g_OnTerminateCalled = false;
+bool g_OnPauseCalled = false;
+bool g_OnResumeCalled = false;
+bool g_OnResetCalled = false;
+bool g_OnResizeCalled = false;
+bool g_OnLanguageChangedCalled = false;
+
+void OnInit()
+{
+  g_OnInitCalled = true;
+}
+
+void OnTerminate()
+{
+  g_OnTerminateCalled = true;
+}
+
+void OnPause()
+{
+  g_OnPauseCalled = true;
+}
+
+void OnResume()
+{
+  g_OnResumeCalled = true;
+}
+
+void OnReset()
+{
+  g_OnResetCalled = true;
+}
+
+void OnResize()
+{
+  g_OnResizeCalled = true;
+}
+
+void OnLanguageChanged()
+{
+  g_OnLanguageChangedCalled = true;
+}
+
+} // anonymous namespace
+
+int UtcDaliLifecycleControllerGet(void)
+{
+  // Attempt to retrieve LifecycleController before creating application
+  LifecycleController lifecycleController;
+  lifecycleController = LifecycleController::Get();
+  DALI_TEST_CHECK( !lifecycleController );
+
+  Application application = Application::New();
+
+  lifecycleController = LifecycleController::Get();
+  DALI_TEST_CHECK( lifecycleController );
+
+  END_TEST;
+}
+
+int UtcDaliLifecycleControllerSignalInit(void)
+{
+  Application application = Application::New();
+
+  DALI_TEST_CHECK( !g_OnInitCalled );
+
+  LifecycleController lifecycleController = LifecycleController::Get();
+
+  lifecycleController.InitSignal().Connect( &OnInit );
+
+  GetImplementation( lifecycleController ).OnInit( application );
+
+  DALI_TEST_CHECK( g_OnInitCalled );
+
+  END_TEST;
+}
+
+int UtcDaliLifecycleControllerSignalTerminate(void)
+{
+  Application application = Application::New();
+
+  DALI_TEST_CHECK( !g_OnTerminateCalled );
+
+  LifecycleController lifecycleController = LifecycleController::Get();
+
+  lifecycleController.TerminateSignal().Connect( &OnTerminate );
+
+  GetImplementation( lifecycleController ).OnTerminate( application );
+
+  DALI_TEST_CHECK( g_OnTerminateCalled );
+
+  END_TEST;
+}
+
+int UtcDaliLifecycleControllerSignalPause(void)
+{
+  Application application = Application::New();
+
+  DALI_TEST_CHECK( !g_OnPauseCalled );
+
+  LifecycleController lifecycleController = LifecycleController::Get();
+
+  lifecycleController.PauseSignal().Connect( &OnPause );
+
+  GetImplementation( lifecycleController ).OnPause( application );
+
+  DALI_TEST_CHECK( g_OnPauseCalled );
+
+  END_TEST;
+}
+
+int UtcDaliLifecycleControllerSignalResume(void)
+{
+  Application application = Application::New();
+
+  DALI_TEST_CHECK( !g_OnResumeCalled );
+
+  LifecycleController lifecycleController = LifecycleController::Get();
+
+  lifecycleController.ResumeSignal().Connect( &OnResume );
+
+  GetImplementation( lifecycleController ).OnResume( application );
+
+  DALI_TEST_CHECK( g_OnResumeCalled );
+
+  END_TEST;
+}
+
+int UtcDaliLifecycleControllerSignalReset(void)
+{
+  Application application = Application::New();
+
+  DALI_TEST_CHECK( !g_OnResetCalled );
+
+  LifecycleController lifecycleController = LifecycleController::Get();
+
+  lifecycleController.ResetSignal().Connect( &OnReset );
+
+  GetImplementation( lifecycleController ).OnReset( application );
+
+  DALI_TEST_CHECK( g_OnResetCalled );
+
+  END_TEST;
+}
+
+int UtcDaliLifecycleControllerSignalResize(void)
+{
+  Application application = Application::New();
+
+  DALI_TEST_CHECK( !g_OnResizeCalled );
+
+  LifecycleController lifecycleController = LifecycleController::Get();
+
+  lifecycleController.ResizeSignal().Connect( &OnResize );
+
+  GetImplementation( lifecycleController ).OnResize( application );
+
+  DALI_TEST_CHECK( g_OnResizeCalled );
+
+  END_TEST;
+}
+
+int UtcDaliLifecycleControllerSignalLanguageChanged(void)
+{
+  Application application = Application::New();
+
+  DALI_TEST_CHECK( !g_OnLanguageChangedCalled );
+
+  LifecycleController lifecycleController = LifecycleController::Get();
+
+  lifecycleController.LanguageChangedSignal().Connect( &OnLanguageChanged );
+
+  GetImplementation( lifecycleController ).OnLanguageChanged( application );
+
+  DALI_TEST_CHECK( g_OnLanguageChangedCalled );
+
+  END_TEST;
+}