(AutomatedTests) Added automated tests for SingletonService 86/26986/4
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 2 Sep 2014 16:47:38 +0000 (17:47 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Mon, 8 Sep 2014 09:48:09 +0000 (10:48 +0100)
Change-Id: I59e9aa7267ee699709071a3999274d3d25b98dfe

automated-tests/src/dali-adaptor/CMakeLists.txt
automated-tests/src/dali-adaptor/utc-Dali-SingletonService.cpp [new file with mode: 0644]

index 87835bd..b93ccbf 100644 (file)
@@ -6,6 +6,7 @@ SET(RPM_NAME "core-${PKG_NAME}-tests")
 SET(CAPI_LIB "dali-adaptor")
 SET(TC_SOURCES
     utc-Dali-Key.cpp
+    utc-Dali-SingletonService.cpp
     utc-Dali-Timer.cpp
 )
 
@@ -29,6 +30,7 @@ PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
 )
 
 SET(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -O0 -ggdb --coverage -Wall -Werror=return-type")
+SET(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} ${${CAPI_LIB}_CFLAGS_OTHER}")
 
 FOREACH(directory ${${CAPI_LIB}_LIBRARY_DIRS})
     SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -L${directory}")
diff --git a/automated-tests/src/dali-adaptor/utc-Dali-SingletonService.cpp b/automated-tests/src/dali-adaptor/utc-Dali-SingletonService.cpp
new file mode 100644 (file)
index 0000000..1078a64
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * 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>
+
+using namespace Dali;
+
+namespace
+{
+
+class TestHandle : public BaseHandle
+{
+public:
+  TestHandle() {}
+  TestHandle( BaseObject* object ) : BaseHandle( object ) {}
+};
+
+class TestObject : public BaseObject
+{
+};
+
+} // unnamed namespace
+
+void utc_dali_singleton_service_startup(void)
+{
+  test_return_value = TET_UNDEF;
+}
+
+void utc_dali_singleton_service_cleanup(void)
+{
+  test_return_value = TET_PASS;
+}
+
+int UtcDaliSingletonServiceGet(void)
+{
+  // Attempt to retrieve SingletonService before creating application
+  SingletonService singletonService;
+  singletonService = SingletonService::Get();
+  DALI_TEST_CHECK( !singletonService );
+
+  // Create Application class, should be able to retrieve SingletonService now
+  Application application = Application::New();
+  singletonService = SingletonService::Get();
+  DALI_TEST_CHECK( singletonService );
+
+  END_TEST;
+}
+
+int UtcDaliSingletonServiceRegisterAndGetSingleton(void)
+{
+  Application application = Application::New();
+  SingletonService singletonService( SingletonService::Get() );
+
+  // Attempt to register an empty handle
+  TestHandle handle;
+  singletonService.Register( typeid( handle ), handle );
+  DALI_TEST_CHECK( !singletonService.GetSingleton( typeid( handle ) ) );
+
+  // Create an actor instance and retrieve, should be valid this time
+  handle = TestHandle( new TestObject );
+  singletonService.Register( typeid( handle ), handle );
+  DALI_TEST_CHECK( singletonService.GetSingleton( typeid( handle ) ) );
+
+  END_TEST;
+}