Moving RunnableWidgetObject tests from wrt-extra to wrt
authorKarol Pawlowski <k.pawlowski@samsung.com>
Tue, 12 Feb 2013 14:24:29 +0000 (15:24 +0100)
committerGerrit Code Review <gerrit2@kim11>
Wed, 13 Feb 2013 07:00:09 +0000 (16:00 +0900)
[Issue#]        LINUXWRT-83
[Problem]       Tests for wrt should be in wrt, no wrt-extra
[Cause]         N/A
[Solution]      N/A
[Verification]  Build wrt repository

Change-Id: I35b1abdbd9a536341332ced08911588b5d36ffa4

18 files changed:
CMakeLists.txt
packaging/wrt.spec
tests/CMakeLists.txt [new file with mode: 0644]
tests/widgets/CMakeLists.txt [new file with mode: 0644]
tests/widgets/CMakeUtils.txt [new file with mode: 0644]
tests/widgets/TestCases.cpp [new file with mode: 0644]
tests/widgets/TestInit.cpp [new file with mode: 0644]
tests/widgets/common/CMakeLists.txt [new file with mode: 0644]
tests/widgets/common/include/InstallerWrapper.h [new file with mode: 0644]
tests/widgets/common/include/RunnableObjectStateTester.h [new file with mode: 0644]
tests/widgets/common/include/TestBase.h [new file with mode: 0644]
tests/widgets/common/include/WidgetRunner.h [new file with mode: 0644]
tests/widgets/common/include/loop_control.h [new file with mode: 0644]
tests/widgets/common/src/InstallerWrapper.cpp [new file with mode: 0644]
tests/widgets/common/src/RunnableObjectStateTester.cpp [new file with mode: 0644]
tests/widgets/common/src/TestBase.cpp [new file with mode: 0644]
tests/widgets/common/src/WidgetRunner.cpp [new file with mode: 0644]
tests/widgets/common/src/loop_control.cpp [new file with mode: 0644]

index 408bfc7..80d7176 100644 (file)
@@ -41,6 +41,7 @@ IF(NOT CMAKE_BUILD_TYPE)
 ENDIF(NOT CMAKE_BUILD_TYPE)
 
 OPTION(DPL_LOG "DPL logs status" ON)
+OPTION(WITH_TESTS "Build tests" OFF)
 
 # logs can be only enabled in debug mode
 IF(CMAKE_BUILD_TYPE MATCHES "Profiling" AND DPL_LOG)
@@ -50,6 +51,7 @@ ELSE(CMAKE_BUILD_TYPE MATCHES "Profiling" AND DPL_LOG)
     MESSAGE(STATUS "Logging enabled for DPL")
 ENDIF(CMAKE_BUILD_TYPE MATCHES "Profiling" AND DPL_LOG)
 
+MESSAGE(STATUS "WITH_TESTS: " ${WITH_TESTS})
 MESSAGE(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
 OPTION(PROFILING "Profiling status" OFF)
 IF(CMAKE_BUILD_TYPE MATCHES "Profiling")
@@ -230,10 +232,18 @@ INSTALL(FILES   ${PROJECT_SOURCE_DIR}/data/generic_popup_horizontal.edj
 ADD_SUBDIRECTORY(src)
 ADD_SUBDIRECTORY(po)
 
-set(PKGCONFIG_DIR ${PROJECT_SOURCE_DIR}/pkgconfig)
+SET(WRT_API_NEW_INCLUDES
+    "${PROJECT_SOURCE_DIR}/src/api_new/"
+    "${PROJECT_SOURCE_DIR}/src/domain/")
+
+SET(PKGCONFIG_DIR ${PROJECT_SOURCE_DIR}/pkgconfig)
 
 CONFIGURE_FILE(${PKGCONFIG_DIR}/wrt-core.pc.in
     ${PKGCONFIG_DIR}/wrt-core.pc @ONLY)
 INSTALL(FILES ${PKGCONFIG_DIR}/wrt-core.pc DESTINATION lib/pkgconfig)
 
+IF(WITH_TESTS)
+    add_subdirectory(tests)
+ENDIF(WITH_TESTS)
+
 
index c4f5511..67f54c2 100644 (file)
@@ -70,13 +70,19 @@ wrt library development headers
 %prep
 %setup -q
 
+%define with_tests 0
+%if "%{WITH_TESTS}" == "ON" || "%{WITH_TESTS}" == "Y" || "%{WITH_TESTS}" == "YES" || "%{WITH_TESTS}" == "TRUE" || "%{WITH_TESTS}" == "1"
+    %define with_tests 1
+%endif
+
 %build
 export LDFLAGS+="-Wl,--rpath=/usr/lib"
 
 cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \
         -DDPL_LOG="ON"                    \
         -DPROJECT_VERSION=%{version} \
-        -DCMAKE_BUILD_TYPE=%{?build_type:%build_type}
+        -DCMAKE_BUILD_TYPE=%{?build_type:%build_type} \
+        %{?WITH_TESTS:-DWITH_TESTS=%WITH_TESTS}
 make %{?jobs:-j%jobs}
 
 %install
@@ -150,6 +156,9 @@ systemctl daemon-reload
 %attr(644,root,root) %{_datadir}/edje/wrt/*
 %attr(644,root,root) %{_datadir}/edje/ace/*
 %attr(644,root,root) /usr/etc/wrt/*
+%if %{with_tests}
+    %attr(755,root,root) %{_bindir}/wrt-tests-wrt
+%endif
 
 ## wrt-launchpad-daemon #######################################################
 %attr(755,root,root) %{_bindir}/wrt_launchpad_daemon
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644 (file)
index 0000000..da45ba9
--- /dev/null
@@ -0,0 +1,19 @@
+# Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    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.
+#
+# @file        CMakeLists.txt
+# @author      Karol Pawlowski (k.pawlowski@samsung.com)
+#
+
+ADD_SUBDIRECTORY(widgets)
diff --git a/tests/widgets/CMakeLists.txt b/tests/widgets/CMakeLists.txt
new file mode 100644 (file)
index 0000000..c85a378
--- /dev/null
@@ -0,0 +1,81 @@
+# Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    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.
+#
+# @file        CMakeLists.txt
+# @author      Karol Pawlowski (k.pawlowski@samsung.com)
+#
+
+# TODO cleanup dependencies
+PKG_CHECK_MODULES(COMMON_LIB_PKGS
+    dbus-1
+    libpcrecpp
+    dpl-efl
+    dpl-test-efl
+    dpl-utils-efl
+    dpl-wrt-dao-ro
+    dpl-event-efl
+    wrt-plugins-widgetdb
+    glib-2.0
+    gthread-2.0
+    ewebkit2
+    edje
+    ecore
+    ecore-x
+    ecore-imf
+    ecore-ipc
+    ecore-evas
+    ecore-file
+    ecore-input
+    evas
+    eina
+    elementary
+    vconf
+    aul
+    libidn
+    libiri
+    REQUIRED
+    )
+
+INCLUDE(CMakeUtils.txt)
+
+pkg_search_module(dpl REQUIRED dpl-efl)
+pkg_search_module(dpl-test REQUIRED dpl-test-efl)
+
+SET(WRT_TEST_LIBRARY "wrt-tests-libs")
+
+include_directories(
+  ${dpl_INCLUDE_DIRS}
+  ${dpl-test_INCLUDE_DIRS}
+  ${CMAKE_CURRENT_SOURCE_DIR}/common
+  ${WRT_API_NEW_INCLUDES}
+)
+
+ADD_SUBDIRECTORY(common)
+
+SET(MISC_TESTS_SOURCES
+    ${CMAKE_CURRENT_SOURCE_DIR}/TestInit.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/TestCases.cpp
+)
+
+SET(MISC_TESTS_TARGET "wrt-tests-wrt")
+
+WRT_TEST_BUILD(${MISC_TESTS_TARGET} ${MISC_TESTS_SOURCES})
+WRT_TEST_INSTALL(${MISC_TESTS_TARGET})
+target_link_libraries(${MISC_TESTS_TARGET}
+  ${dpl_LIBRARIES}
+  ${dpl-test_LIBRARIES}
+  ${WRT_TEST_LIBRARY}
+  ${TARGET_CORE_MODULE_LIB}
+  ${COMMON_LIB_PKGS_LIBRARIES}
+)
diff --git a/tests/widgets/CMakeUtils.txt b/tests/widgets/CMakeUtils.txt
new file mode 100644 (file)
index 0000000..265869f
--- /dev/null
@@ -0,0 +1,182 @@
+# @file        CMakeUtils.txt
+# @author      Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
+# @author      Pawel Sikorski (p.sikorski@samsung.com)
+# @author      Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+# @version     1.0
+# @brief
+#
+
+#
+# Discovers target's INCLUDE_DIRECTORIES and LINK_DIRECTORIES.
+# This is done by retrieving the directory target was built in and
+# fetching appropriate properties of that directory.
+FUNCTION(WRT_INTROSPECT_TARGET PREFIX TARGET_NAME)
+  GET_TARGET_PROPERTY(LOCATION ${TARGET_NAME} LOCATION)
+  IF(${LOCATION} STREQUAL "LOCATION-NOTFOUND")
+    MESSAGE(FATAL_ERROR "Target '${TARGET_NAME}' introspection failed")
+  ELSE(${LOCATION} STREQUAL "LOCATION-NOTFOUND")
+    STRING(FIND ${LOCATION} "/" LAST_SLASH_POSITION REVERSE)
+    STRING(SUBSTRING ${LOCATION} 0 ${LAST_SLASH_POSITION} LOCATION)
+
+    GET_DIRECTORY_PROPERTY(INCLUDE_DIRS DIRECTORY ${LOCATION} INCLUDE_DIRECTORIES)
+    SET("${PREFIX}_INCLUDE_DIRS" ${INCLUDE_DIRS} PARENT_SCOPE)
+
+    GET_DIRECTORY_PROPERTY(LIBRARY_DIRS DIRECTORY ${LOCATION} LINK_DIRECTORIES)
+    SET("${PREFIX}_LIBRARY_DIRS" ${LIBRARY_DIRS} PARENT_SCOPE)
+  ENDIF(${LOCATION} STREQUAL "LOCATION-NOTFOUND")
+ENDFUNCTION(WRT_INTROSPECT_TARGET)
+
+FUNCTION(WRT_TEST_LIBRARY)
+  SET_PROPERTY(GLOBAL APPEND PROPERTY COMMON_TESTS_LIBRARY ${ARGV})
+ENDFUNCTION(WRT_TEST_LIBRARY)
+
+#
+# Replacement functions for standard (w/o "WRT_" prefix) CMake functions.
+# They store supplied arguments in global properties to assign them to tests.
+# Anything added with this functions is used by all targets that are built with
+# WRT_TEST_BUILD function.
+
+#
+# Appends directories to global property TESTS_INCLUDE_DIRS which is
+# then read by WRT_TEST_BUILD and its content is forwarded to
+# command INCLUDE_DIRECTORIES() (for all targets).
+FUNCTION(WRT_INCLUDE_DIRECTORIES)
+  SET_PROPERTY(GLOBAL APPEND PROPERTY TESTS_INCLUDE_DIRS ${ARGV})
+ENDFUNCTION(WRT_INCLUDE_DIRECTORIES)
+
+#
+# Appends directories to global property TESTS_LIBRARY_DIRS which is
+# then read by WRT_TEST_BUILD and its content is forwarded to
+# command LINK_DIRECTORIES() (for all targets).
+FUNCTION(WRT_LINK_DIRECTORIES)
+  SET_PROPERTY(GLOBAL APPEND PROPERTY TESTS_LIBRARY_DIRS ${ARGV})
+ENDFUNCTION(WRT_LINK_DIRECTORIES)
+
+#
+# Appends directories to global property TESTS_LIBRARIES which is
+# then read by WRT_TEST_BUILD and its content is forwarded to
+# command TARGET_LINK_LIBRARIES() (for all targets).
+FUNCTION(WRT_TARGET_LINK_LIBRARIES)
+  SET_PROPERTY(GLOBAL APPEND PROPERTY TESTS_LIBRARIES ${ARGV})
+ENDFUNCTION(WRT_TARGET_LINK_LIBRARIES)
+
+#
+# Convenience method that fills TESTS_INCLUDE_DIRS, TESTS_LIBRARY_DIRS
+# and TESTS_LIBRARIES with values discovered from introspecting supplied
+# targets.
+# Function takes arbitrary number of targets.
+FUNCTION(WRT_ADD_INTERNAL_DEPENDENCIES)
+  FOREACH(DEPENDENCY ${ARGV})
+    WRT_INTROSPECT_TARGET(prefix ${DEPENDENCY})
+    WRT_INCLUDE_DIRECTORIES(${prefix_INCLUDE_DIRS})
+    WRT_LINK_DIRECTORIES(${prefix_LIBRARY_DIRS})
+    WRT_TARGET_LINK_LIBRARIES(${DEPENDENCY})
+  ENDFOREACH(DEPENDENCY)
+ENDFUNCTION(WRT_ADD_INTERNAL_DEPENDENCIES)
+
+
+#
+# Replacement functions for standard (w/o "WRT_" prefix) CMake functions.
+# They store supplied arguments in global properties to assign them to specific
+# tests. Properties names are based on the test target name.
+# Anything added with this functions is used only by the specified target that
+# is built with WRT_TEST_BUILD function.
+
+#
+# Appends directories to global property ${TARGET_NAME}_INCLUDE_DIRS
+# which is then read by WRT_TEST_BUILD and its content is forwarded to
+# command INCLUDE_DIRECTORIES() (for specified target).
+FUNCTION(WRT_TEST_INCLUDE_DIRECTORIES TARGET_NAME)
+  SET_PROPERTY(GLOBAL APPEND PROPERTY ${TARGET_NAME}_INCLUDE_DIRS ${ARGN})
+ENDFUNCTION(WRT_TEST_INCLUDE_DIRECTORIES)
+
+#
+# Appends directories to global property ${TARGET_NAME}_LIBRARY_DIRS
+# which is then read by WRT_TEST_BUILD and its content is forwarded to
+# command LINK_DIRECTORIES() (for specified target).
+FUNCTION(WRT_TEST_LINK_DIRECTORIES TARGET_NAME)
+  SET_PROPERTY(GLOBAL APPEND PROPERTY ${TARGET_NAME}_LIBRARY_DIRS ${ARGN})
+ENDFUNCTION(WRT_TEST_LINK_DIRECTORIES)
+
+#
+# Appends directories to global property ${TARGET_NAME}_LIBRARIES
+# which is then read by WRT_TEST_BUILD and its content is forwarded to
+# command TARGET_LINK_LIBRARIES() (for specified target).
+FUNCTION(WRT_TEST_TARGET_LINK_LIBRARIES TARGET_NAME)
+  SET_PROPERTY(GLOBAL APPEND PROPERTY ${TARGET_NAME}_LIBRARIES ${ARGN})
+ENDFUNCTION(WRT_TEST_TARGET_LINK_LIBRARIES)
+
+#
+# Convenience method that fills ${TARGET_NAME}_INCLUDE_DIRS,
+# ${TARGET_NAME}_LIBRARY_DIRS and ${TARGET_NAME}_LIBRARIES with
+# values discovered from introspecting supplied targets.
+# Function takes arbitrary number of targets.
+FUNCTION(WRT_TEST_ADD_INTERNAL_DEPENDENCIES TARGET_NAME)
+  FOREACH(DEPENDENCY ${ARGN})
+    WRT_INTROSPECT_TARGET(prefix ${DEPENDENCY})
+    WRT_TEST_INCLUDE_DIRECTORIES(${TARGET_NAME} ${prefix_INCLUDE_DIRS})
+    WRT_TEST_LINK_DIRECTORIES(${TARGET_NAME} ${prefix_LIBRARY_DIRS})
+    WRT_TEST_TARGET_LINK_LIBRARIES(${TARGET_NAME} ${DEPENDENCY})
+  ENDFOREACH(DEPENDENCY)
+ENDFUNCTION(WRT_TEST_ADD_INTERNAL_DEPENDENCIES)
+
+# Functions used to build test targets (proper sources, includes, libs are
+# added automatically)
+FUNCTION(WRT_TEST_BUILD TARGET_NAME)
+    SET(SOURCES "${ARGN}")
+    ADD_EXECUTABLE("${TARGET_NAME}" ${SOURCES})
+
+    # get include dirs global property
+    GET_PROPERTY(INCLUDE_DIRS GLOBAL PROPERTY TESTS_INCLUDE_DIRS)
+    GET_PROPERTY(TEST_INCLUDE_DIRS GLOBAL PROPERTY ${TARGET_NAME}_INCLUDE_DIRS)
+    INCLUDE_DIRECTORIES(
+        ${INCLUDE_DIRS}
+        ${TEST_INCLUDE_DIRS}
+    )
+
+    # get library dirs global property
+    GET_PROPERTY(LIBRARY_DIRS GLOBAL PROPERTY TESTS_LIBRARY_DIRS)
+    GET_PROPERTY(TEST_LIBRARY_DIRS GLOBAL PROPERTY ${TARGET_NAME}_LIBRARY_DIRS)
+    LINK_DIRECTORIES(
+        ${LIBRARY_DIRS}
+        ${TEST_LIBRARY_DIRS}
+    )
+
+    # get link libraries global property
+    GET_PROPERTY(LINK_LIBRARIES GLOBAL PROPERTY TESTS_LIBRARIES)
+    GET_PROPERTY(TEST_LIBRARIES GLOBAL PROPERTY ${TARGET_NAME}_LIBRARIES)
+    TARGET_LINK_LIBRARIES("${TARGET_NAME}"
+        ${LINK_LIBRARIES}
+        ${TEST_LIBRARIES}
+    )
+ENDFUNCTION(WRT_TEST_BUILD)
+
+FUNCTION(WRT_TEST_INSTALL)
+    SET_TARGET_PROPERTIES(${ARGV} PROPERTIES
+        BUILD_WITH_INSTALL_RPATH ON
+        INSTALL_RPATH_USE_LINK_PATH ON
+    )
+    INSTALL(TARGETS ${ARGV}
+        DESTINATION bin
+        PERMISSIONS OWNER_READ
+                    OWNER_WRITE
+                    OWNER_EXECUTE
+                    GROUP_READ
+                    GROUP_EXECUTE
+                    WORLD_READ
+                    WORLD_EXECUTE
+    )
+ENDFUNCTION(WRT_TEST_INSTALL)
+
+# Takes arbitrary number of arguments and concatenates them using ':' character.
+# Rationale:
+#   CMake list when converted to a string is joined with ';' character. However,
+#   GCC takes strings with multiple elements separated with ':' (e.g. list of
+#   paths). Used typically when generating DB schemas with ORM mechanism.
+FUNCTION(WRT_CONVERT_TO_GCC_LIST OUTPUT_VARIABLE)
+    FOREACH(ITEM ${ARGN})
+        LIST(APPEND ITEMS ${ITEM})
+    ENDFOREACH(ITEM)
+    STRING(REPLACE ";" ":" OUTPUT "${ITEMS}")
+    SET("${OUTPUT_VARIABLE}" "${OUTPUT}" PARENT_SCOPE)
+ENDFUNCTION(WRT_CONVERT_TO_GCC_LIST)
diff --git a/tests/widgets/TestCases.cpp b/tests/widgets/TestCases.cpp
new file mode 100644 (file)
index 0000000..8a6a411
--- /dev/null
@@ -0,0 +1,1172 @@
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    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.
+ */
+/**
+ * @file    TestCases.cpp
+ * @author  Karol Pawłowski (k.pawlowski@samsung.com)
+ * @author  Tomasz Iwanek (t.iwanek@samsung.com)
+ * @version 1.0
+ */
+
+#include <dpl/test/test_runner.h>
+#include <dpl/singleton_impl.h>
+#include <dpl/log/log.h>
+#include <RunnableObjectStateTester.h>
+#include <i_runnable_widget_object.h>
+
+namespace {
+
+const std::string miscWidgetsStuff = "/opt/share/widget/tests/misc/";
+
+struct Result {
+    bool m_exc;
+    bool m_exd;
+    bool m_exs;
+    std::string message;
+    Result(bool exc = false, bool exd = false, bool exs = false)
+        : m_exc(exc), m_exd(exd), m_exs(exs) {}
+};
+
+}
+
+RUNNER_TEST_GROUP_INIT(RunnableWidgetObjectState)
+
+//for call methods to get starting state or do clean up after test
+#define CALL_TESTER( ARGUMENT )                                        \
+        tester.perform##ARGUMENT();                                    \
+
+//for performing test and catch excpeted and unexpected exceptions
+#define RUNNABLE_TESTER( ARGUMENT )                                    \
+    Result res;                                                        \
+    Try                                                                \
+    {                                                                  \
+        LogDebug("perform start");                                     \
+        CALL_TESTER( ARGUMENT )                                        \
+        LogDebug("perform stop");                                      \
+    }                                                                  \
+    Catch(WRT::IRunnableWidgetObject::MethodInvocationForbidden)       \
+    {                                                                  \
+        res.m_exc = true;                                              \
+        res.message = _rethrown_exception.DumpToString();              \
+        res.message += "(MethodInvocationForbidden)";                  \
+    }                                                                  \
+    Catch(DPL::Exception)                                              \
+    {                                                                  \
+        res.m_exd = true;                                              \
+        res.message = _rethrown_exception.DumpToString();              \
+        res.message += "(DPL::Exception)";                             \
+    }                                                                  \
+    Catch(std::exception)                                              \
+    {                                                                  \
+        res.m_exs = true;                                              \
+        res.message = _rethrown_exception.what();                      \
+        res.message += "(std::exception)";                             \
+    }                                                                  \
+
+
+//check of function success
+#define SHOULD_BE_ALLOWED( ARGUMENT )                                  \
+    {                                                                  \
+    RUNNABLE_TESTER( ARGUMENT )                                        \
+    if(res.m_exc || res.m_exs || res.m_exd)                            \
+    {                                                                  \
+        ok = false;                                                    \
+        reason = "Exception throwed when not expected in ";            \
+        reason += __FUNCTION__;                                        \
+        reason += " calling ";                                         \
+        reason += #ARGUMENT;                                           \
+        reason += "message ";                                          \
+        reason += res.message;                                         \
+    }                                                                  \
+    }                                                                  \
+
+
+//check of function failure
+#define SHOULD_BE_FORBIDDEN( ARGUMENT )                                \
+    {                                                                  \
+    RUNNABLE_TESTER( ARGUMENT )                                        \
+    if(!res.m_exc)                                                     \
+    {                                                                  \
+        ok = false;                                                    \
+        reason = "MethodInvocationForbidden should be throwed";        \
+        reason += " when calling ";                                    \
+        reason += #ARGUMENT;                                           \
+    }                                                                  \
+    }                                                                  \
+
+
+//marcos for hiding lamdba expression and and presenting it as if it is test body
+#define RUNNABLE_TESTER_START                                                              \
+    bool ok = true;                                                                        \
+    std::string reason;                                                                    \
+    auto func = [&ok,&reason](RunnableObjectStateTester & tester)                          \
+    {                                                                                      \
+        Try                                                                                \
+        {                                                                                  \
+
+
+#define RUNNABLE_TESTER_STOP                                                               \
+        }                                                                                  \
+        Catch(DPL::Exception)                                                              \
+        {                                                                                  \
+            LogDebug("RunnableWidgetObjectStateTest has failed");                          \
+        }                                                                                  \
+        Catch(std::exception)                                                              \
+        {                                                                                  \
+            reason = "Unknown exception";                                                  \
+            ok = false;                                                                    \
+        }                                                                                  \
+    };                                                                                     \
+    RunnableObjectStateTester & instance = RunnableObjectStateTesterSingleton::Instance(); \
+    instance.runTest(func);                                                                \
+    RUNNER_ASSERT_MSG(ok, reason);                                                         \
+
+//Initial
+/*
+Name: state_Initial_CheckBeforeLaunch
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method CheckBeforeLaunch in state Initial
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Initial_CheckBeforeLaunch)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    SHOULD_BE_FORBIDDEN( CheckBeforeLaunch );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Initial_PrepareView
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method PrepareView in state Initial
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_Initial_PrepareView)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    SHOULD_BE_ALLOWED( PrepareView );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Initial_Show
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Show in state Initial
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Initial_Show)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    SHOULD_BE_FORBIDDEN( Show );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Initial_Hide
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Hide in state Initial
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Initial_Hide)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    SHOULD_BE_FORBIDDEN( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Initial_Suspend
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Suspend in state Initial
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Initial_Suspend)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    SHOULD_BE_FORBIDDEN( Suspend );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Initial_Resume
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Resume in state Initial
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Initial_Resume)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    SHOULD_BE_FORBIDDEN( Resume );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Initial_Reset
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Reset in state Initial
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Initial_Reset)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    SHOULD_BE_FORBIDDEN( Reset );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Initial_GetCurrentWebview
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method GetCurrentWebview in state Initial
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Initial_GetCurrentWebview)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    SHOULD_BE_FORBIDDEN( GetCurrentWebview );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Initial_SetUserDelegates
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method SetUserDelegates in state Initial
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Initial_SetUserDelegates)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    SHOULD_BE_FORBIDDEN( SetUserDelegates );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Initial_Backward
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Backward in state Initial
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Initial_Backward)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    SHOULD_BE_FORBIDDEN( Backward );
+    RUNNABLE_TESTER_STOP
+}
+
+
+//Prepared
+/*
+Name: state_Prepared_CheckBeforeLaunch
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method CheckBeforeLaunch in state Prepared
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_Prepared_CheckBeforeLaunch)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    SHOULD_BE_ALLOWED( CheckBeforeLaunch );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Prepared_PrepareView
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method PrepareView in state Prepared
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Prepared_PrepareView)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    SHOULD_BE_FORBIDDEN( PrepareView );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Prepared_Show
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Show in state Prepared
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Prepared_Show)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    SHOULD_BE_FORBIDDEN( Show );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Prepared_Hide
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Hide in state Prepared
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_Prepared_Hide)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    SHOULD_BE_ALLOWED( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Prepared_Suspend
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Suspend in state Prepared
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Prepared_Suspend)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    SHOULD_BE_FORBIDDEN( Suspend );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Prepared_Resume
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Resume in state Prepared
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Prepared_Resume)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    SHOULD_BE_FORBIDDEN( Resume );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Prepared_Reset
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Reset in state Prepared
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Prepared_Reset)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    SHOULD_BE_FORBIDDEN( Reset );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Prepared_GetCurrentWebview
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method GetCurrentWebview in state Prepared
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_Prepared_GetCurrentWebview)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    SHOULD_BE_ALLOWED( GetCurrentWebview );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Prepared_SetUserDelegates
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method SetUserDelegates in state Prepared
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Prepared_SetUserDelegates)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    SHOULD_BE_FORBIDDEN( SetUserDelegates );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Prepared_Backward
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Backward in state Prepared
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Prepared_Backward)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    SHOULD_BE_FORBIDDEN( Backward );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+//SecChecked
+/*
+Name: state_SecChecked_CheckBeforeLaunch
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method CheckBeforeLaunch in state SecChecked
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_SecChecked_CheckBeforeLaunch)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    SHOULD_BE_FORBIDDEN( CheckBeforeLaunch );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_SecChecked_PrepareView
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method PrepareView in state SecChecked
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_SecChecked_PrepareView)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    SHOULD_BE_FORBIDDEN( PrepareView );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_SecChecked_Show
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Show in state SecChecked
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_SecChecked_Show)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( SetUserDelegates );
+    SHOULD_BE_ALLOWED( Show );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_SecChecked_Hide
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Hide in state SecChecked
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_SecChecked_Hide)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    SHOULD_BE_ALLOWED( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_SecChecked_Suspend
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Suspend in state SecChecked
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_SecChecked_Suspend)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    SHOULD_BE_FORBIDDEN( Suspend );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_SecChecked_Resume
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Resume in state SecChecked
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_SecChecked_Resume)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    SHOULD_BE_FORBIDDEN( Resume );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_SecChecked_Reset
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Reset in state SecChecked
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_SecChecked_Reset)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    SHOULD_BE_FORBIDDEN( Reset );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_SecChecked_GetCurrentWebview
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method GetCurrentWebview in state SecChecked
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_SecChecked_GetCurrentWebview)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    SHOULD_BE_ALLOWED( GetCurrentWebview );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_SecChecked_SetUserDelegates
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method SetUserDelegates in state SecChecked
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_SecChecked_SetUserDelegates)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    SHOULD_BE_ALLOWED( SetUserDelegates );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_SecChecked_Backward
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Backward in state SecChecked
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_SecChecked_Backward)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    SHOULD_BE_FORBIDDEN( Backward );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+//Showed
+/*
+Name: state_Showed_CheckBeforeLaunch
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method CheckBeforeLaunch in state Showed
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Showed_CheckBeforeLaunch)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    SHOULD_BE_FORBIDDEN( CheckBeforeLaunch );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Showed_PrepareView
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method PrepareView in state Showed
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Showed_PrepareView)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    SHOULD_BE_FORBIDDEN( PrepareView );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Showed_Show
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Show in state Showed
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Showed_Show)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    SHOULD_BE_FORBIDDEN( Show );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Showed_Hide
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Hide in state Showed
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_Showed_Hide)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    SHOULD_BE_ALLOWED( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Showed_Suspend
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Suspend in state Showed
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_Showed_Suspend)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    SHOULD_BE_ALLOWED( Suspend );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Showed_Resume
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Resume in state Showed
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Showed_Resume)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    SHOULD_BE_FORBIDDEN( Resume );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Showed_Reset
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Reset in state Showed
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_Showed_Reset)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    SHOULD_BE_ALLOWED( Reset );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Showed_GetCurrentWebview
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method GetCurrentWebview in state Showed
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_Showed_GetCurrentWebview)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    SHOULD_BE_ALLOWED( GetCurrentWebview );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Showed_SetUserDelegates
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method SetUserDelegates in state Showed
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Showed_SetUserDelegates)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    SHOULD_BE_FORBIDDEN( SetUserDelegates );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Showed_Backward
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Backward in state Showed
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_Showed_Backward)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    SHOULD_BE_ALLOWED( Backward );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+//Suspended
+/*
+Name: state_Suspended_CheckBeforeLaunch
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method CheckBeforeLaunch in state Suspended
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Suspended_CheckBeforeLaunch)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    SHOULD_BE_FORBIDDEN( CheckBeforeLaunch );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Suspended_PrepareView
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method PrepareView in state Suspended
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Suspended_PrepareView)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    SHOULD_BE_FORBIDDEN( PrepareView );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Suspended_Show
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Show in state Suspended
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Suspended_Show)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    SHOULD_BE_FORBIDDEN( Show );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Suspended_Hide
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Hide in state Suspended
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_Suspended_Hide)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    SHOULD_BE_ALLOWED( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Suspended_Suspend
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Suspend in state Suspended
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Suspended_Suspend)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    SHOULD_BE_FORBIDDEN( Suspend );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Suspended_Resume
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Resume in state Suspended
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_Suspended_Resume)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    SHOULD_BE_ALLOWED( Resume );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Suspended_Reset
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Reset in state Suspended
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_Suspended_Reset)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    SHOULD_BE_ALLOWED( Reset );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Suspended_GetCurrentWebview
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method GetCurrentWebview in state Suspended
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_Suspended_GetCurrentWebview)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    SHOULD_BE_ALLOWED( GetCurrentWebview );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Suspended_SetUserDelegates
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method SetUserDelegates in state Suspended
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Suspended_SetUserDelegates)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    SHOULD_BE_FORBIDDEN( SetUserDelegates );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Suspended_Backward
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Backward in state Suspended
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Suspended_Backward)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    SHOULD_BE_FORBIDDEN( Backward );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+//Hidden
+/*
+Name: state_Hidden_CheckBeforeLaunch
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method CheckBeforeLaunch in state Hidden
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Hidden_CheckBeforeLaunch)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    CALL_TESTER( Hide );
+    SHOULD_BE_FORBIDDEN( CheckBeforeLaunch );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Hidden_PrepareView
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method PrepareView in state Hidden
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Hidden_PrepareView)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    CALL_TESTER( Hide );
+    SHOULD_BE_FORBIDDEN( PrepareView );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Hidden_Show
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Show in state Hidden
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Hidden_Show)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    CALL_TESTER( Hide );
+    SHOULD_BE_FORBIDDEN( Show );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Hidden_Hide
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Hide in state Hidden
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Hidden_Hide)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    CALL_TESTER( Hide );
+    SHOULD_BE_FORBIDDEN( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Hidden_Suspend
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Suspend in state Hidden
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Hidden_Suspend)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    CALL_TESTER( Hide );
+    SHOULD_BE_FORBIDDEN( Suspend );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Hidden_Resume
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Resume in state Hidden
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Hidden_Resume)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    CALL_TESTER( Hide );
+    SHOULD_BE_FORBIDDEN( Resume );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Hidden_Reset
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Reset in state Hidden
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Hidden_Reset)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    CALL_TESTER( Hide );
+    SHOULD_BE_FORBIDDEN( Reset );
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( Hide );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Hidden_GetCurrentWebview
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method GetCurrentWebview in state Hidden
+Expected: Transistion should pass
+*/
+RUNNER_TEST(state_Hidden_GetCurrentWebview)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    CALL_TESTER( Hide );
+    SHOULD_BE_ALLOWED( GetCurrentWebview );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Hidden_SetUserDelegates
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method SetUserDelegates in state Hidden
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Hidden_SetUserDelegates)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    CALL_TESTER( Hide );
+    SHOULD_BE_FORBIDDEN( SetUserDelegates );
+    RUNNABLE_TESTER_STOP
+}
+
+/*
+Name: state_Hidden_Backward
+Description: Checks if RunnableWidgetObject
+ correctly reacts to calling method Backward in state Hidden
+Expected: Transistion should fail
+*/
+RUNNER_TEST(state_Hidden_Backward)
+{
+    RUNNER_FAIL;
+    RUNNABLE_TESTER_START
+    CALL_TESTER( PrepareView );
+    CALL_TESTER( CheckBeforeLaunch );
+    CALL_TESTER( Show );
+    CALL_TESTER( Suspend );
+    CALL_TESTER( Hide );
+    SHOULD_BE_FORBIDDEN( Backward );
+    RUNNABLE_TESTER_STOP
+}
+
diff --git a/tests/widgets/TestInit.cpp b/tests/widgets/TestInit.cpp
new file mode 100644 (file)
index 0000000..2e1ac8f
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    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.
+ */
+/**
+ * @file    TestInit.cpp
+ * @author  Tomasz Iwanek (t.iwanek@samsung.com)
+ * @version 1.0
+ * @brief   main for misc tests
+ */
+
+#include <dpl/test/test_runner.h>
+#include <dpl/log/log.h>
+#include <dpl/wrt-dao-ro/WrtDatabase.h>
+
+int main (int argc, char *argv[])
+{
+    LogInfo("Starting tests");
+
+    WrtDB::WrtDatabase::attachToThreadRW();
+    int status =
+        DPL::Test::TestRunnerSingleton::Instance().ExecTestRunner(argc, argv);
+    WrtDB::WrtDatabase::detachFromThread();
+
+    return status;
+}
diff --git a/tests/widgets/common/CMakeLists.txt b/tests/widgets/common/CMakeLists.txt
new file mode 100644 (file)
index 0000000..426d1ff
--- /dev/null
@@ -0,0 +1,44 @@
+# Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    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.
+#
+# @file        CMakeLists.txt
+# @author      Tomasz Iwanek (t.iwanek@samsung.com)
+# @version     1.0
+# @brief
+#
+
+SET(COMMON_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/include")
+
+WRT_TEST_LIBRARY(${WRT_TEST_LIBRARY})
+
+WRT_INCLUDE_DIRECTORIES(
+    ${COMMON_LIB_PKGS_INCLUDE_DIRS}
+    ${COMMON_INCLUDES}
+    ${WRT_API_NEW_INCLUDES}
+    )
+
+WRT_LINK_DIRECTORIES(${COMMON_LIB_PKGS_LIBRARY_DIRS})
+WRT_TARGET_LINK_LIBRARIES(${COMMON_LIB_PKGS_LIBRARIES})
+
+SET(WRT_DETAIL_SOURCES
+    ${CMAKE_CURRENT_SOURCE_DIR}/src/InstallerWrapper.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/src/WidgetRunner.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/src/loop_control.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/src/TestBase.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/src/RunnableObjectStateTester.cpp
+)
+
+INCLUDE_DIRECTORIES(${COMMON_INCLUDES})
+INCLUDE_DIRECTORIES(${COMMON_LIB_PKGS_INCLUDE_DIRS})
+ADD_LIBRARY(${WRT_TEST_LIBRARY} STATIC ${WRT_DETAIL_SOURCES})
diff --git a/tests/widgets/common/include/InstallerWrapper.h b/tests/widgets/common/include/InstallerWrapper.h
new file mode 100644 (file)
index 0000000..7bce1cd
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    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.
+ */
+
+#ifndef WRT_TESTS_W3C_TESTS_INSTALLER_WRAPPER_H
+#define WRT_TESTS_W3C_TESTS_INSTALLER_WRAPPER_H
+
+#include <string>
+
+namespace InstallerWrapper
+{
+
+typedef int InstallResult;
+const InstallResult WrongWidgetPackage = -2;
+const InstallResult OtherError = -1;
+const InstallResult Success = 0;
+
+InstallResult install(
+        const std::string& path,
+        std::string& tizenId,
+        const std::string& user = "");
+bool uninstall(const std::string& tizenId);
+bool uninstallByGuid(const std::string& guid);
+/**
+ * @brief killWrtClients kills processes that matches 'wrt-client'
+ * @return True if any client was killed
+ */
+bool sigintWrtClients();
+
+}
+
+#endif//WRT_TESTS_W3C_TESTS_INSTALLER_WRAPPER_H
diff --git a/tests/widgets/common/include/RunnableObjectStateTester.h b/tests/widgets/common/include/RunnableObjectStateTester.h
new file mode 100644 (file)
index 0000000..da5eae7
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    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.
+ */
+/**
+ * @file        RunnableObjectStateTester.h
+ * @author      Tomasz Iwanek (t.iwanek@samsung.com)
+ * @brief       Tester for RunnableWidgetObject's states
+ */
+
+#ifndef WRT_EXTRA_AUTO_TESTS_COMMON_INCLUDE_RUNNABLE_OBJECT_STATE_TESTER_H
+#define WRT_EXTRA_AUTO_TESTS_COMMON_INCLUDE_RUNNABLE_OBJECT_STATE_TESTER_H
+
+#include <memory>
+#include <functional>
+#include <vector>
+#include <Evas.h>
+#include <dpl/exception.h>
+#include <dpl/application.h>
+#include <dpl/generic_event.h>
+#include <dpl/event/controller.h>
+#include <dpl/type_list.h>
+#include <dpl/task.h>
+#include <dpl/singleton.h>
+#include <dpl/string.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+#include <dpl/wrt-dao-ro/common_dao_types.h>
+#include <i_runnable_widget_object.h>
+#include <core_module.h>
+
+#include <InstallerWrapper.h>
+
+DECLARE_GENERIC_EVENT_0(NextStepEvent)
+
+class RunnableObjectStateTester : public DPL::ApplicationExt,
+        private DPL::Event::Controller<DPL::TypeListDecl<NextStepEvent>::Type>,
+        public DPL::TaskDecl<RunnableObjectStateTester>
+{
+public:
+    typedef std::function<void(RunnableObjectStateTester&)> Test;
+
+    DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
+    DECLARE_EXCEPTION_TYPE(Base, CoreModuleFailure)
+    DECLARE_EXCEPTION_TYPE(Base, CallbackFailure)
+
+    RunnableObjectStateTester();
+    ~RunnableObjectStateTester();
+
+    void performCheckBeforeLaunch();
+    void performPrepareView();
+
+    void performShow();
+    void performHide();
+    void performSuspend();
+    void performResume();
+    void performReset();
+
+    void performGetCurrentWebview();
+    void performSetUserDelegates();
+    void performBackward();
+
+    void performTest();
+
+    void runTest(Test func);
+
+    void OnEventReceived(const NextStepEvent& /*event*/);
+
+    void loadFinishCallback(Evas_Object*);
+
+private:
+    std::string m_handle;
+    WrtDB::WidgetDAOReadOnlyPtr m_dao;
+    WRT::RunnableWidgetObjectPtr m_widget;
+    Test m_func;
+    const std::string m_widgetPath;
+    std::vector<Evas_Object *> m_windows; //for created windows for PrepareView
+};
+
+typedef DPL::Singleton<RunnableObjectStateTester> RunnableObjectStateTesterSingleton;
+
+#endif // WRT_EXTRA_AUTO_TESTS_COMMON_INCLUDE_RUNNABLE_OBJECT_STATE_TESTER_H
diff --git a/tests/widgets/common/include/TestBase.h b/tests/widgets/common/include/TestBase.h
new file mode 100644 (file)
index 0000000..125f7b4
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    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.
+ */
+#ifndef WRT_EXTRA_AUTO_TESTS_COMMON_INCLUDE_TESTBASE_H
+#define WRT_EXTRA_AUTO_TESTS_COMMON_INCLUDE_TESTBASE_H
+
+#include <string>
+
+#include <dpl/noncopyable.h>
+#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+#include <dpl/localization/LanguageTagsProvider.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+
+#include <WidgetRunner.h>
+
+class TestBase : DPL::Noncopyable
+{
+protected:
+    LanguageTags m_tags;
+
+    WrtDB::WidgetDAOReadOnly* dao;
+
+    std::string m_widgetPath;
+    std::string m_widgetName;
+    WrtDB::WidgetPkgName m_widgetTizenId;
+    bool m_wrongWidgetPackage;
+
+    void CheckRunnerResult(InstallerWrapper::WidgetRunner & runner);
+
+public:
+    TestBase(const std::string & path, const std::string & directory);
+    virtual ~TestBase();
+
+    void StartTest();
+    void CheckIsValid();
+    void CheckIsNotValid();
+
+    void MakeScreenshot();
+    /**
+     * @brief CheckWidgetJsHook
+     * @param hookFile hook file
+     */
+    void CheckWidgetJsHook(const char* hookFile = "hook.js");
+    void CheckWidgetJsReady();
+};
+
+
+#endif // WRT_EXTRA_AUTO_TESTS_COMMON_INCLUDE_TESTBASE_H
diff --git a/tests/widgets/common/include/WidgetRunner.h b/tests/widgets/common/include/WidgetRunner.h
new file mode 100644 (file)
index 0000000..e1256dc
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    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.
+ */
+
+#ifndef WRT_TESTS_W3C_TESTS_WIDGET_RUNNER_H
+#define WRT_TESTS_W3C_TESTS_WIDGET_RUNNER_H
+
+#include <dpl/exception.h>
+#include <string>
+
+namespace InstallerWrapper {
+
+    const std::string tmpFile = "/tmp/widget_runner_tmp_result_file";
+    const std::string TEST_OK = "OK";
+    const std::string TEST_FAIL = "FAIL";
+    const std::string TEST_EXCEPTION = "EXCEPTION";
+    const std::string TEST_MANUAL = "MANUAL";
+
+    class WidgetRunner {
+    public:
+        WidgetRunner(std::string widgetTizenId, const std::string & name);
+        bool addTestHook(const char* packageName, const char* hookFile = "hook.js");
+        /**
+         * @brief run Launches test in wrt-client and collect its output from 4 descriptor
+         * @param hasHook if true messages from js hook are expected in debug
+         * @return true if success
+         */
+        bool run(bool doScreen = false);
+        std::string getResult() const;
+        std::string getResultWidgetName() const;
+        /**
+         * @brief setHasHook Stes if test has a hook
+         * @param hasHook value
+         */
+        void setHasHook(bool hasHook);
+    private:
+
+        DECLARE_EXCEPTION_TYPE(DPL::Exception, GetArgException)
+
+        //timeout for 'popen'ed' process output (in seconds)
+        static const unsigned popenTimeout;
+
+        std::string m_widgetTizenId;
+        std::string m_name; //name of file is fs
+        std::string m_result; //result of test
+        std::string m_resultWidgetName; //name as test presents itselfs
+        bool m_hasHook;
+        std::string getArg(FILE* file, std::string & lastBuffer);
+        /**
+         * @brief getArgs
+         *
+         * Reads parameters from file descriptor
+         *
+         * @param file fiel descriptor
+         * @param id id of widget
+         * @param result result value
+         * @param resultWidgetName widget name
+         * @throw WidgetRunner::GetArgException if parameters cannot be read
+         */
+        void getArgs(FILE* file, std::string & id, std::string & result,
+                std::string & resultWidgetName);
+        /**
+         * @brief getArgs
+         *
+         * Reads only text from widget initialzation
+         *
+         * @param file file descriptor
+         * @param initText first inital text from widget initialization
+         * @throw WidgetRunner::GetArgException if parameters cannot be read
+         */
+        void getInitWidgetText(FILE* file, std::string initText);
+        /**
+         * @brief calculateArgumentAndBuffer
+         *
+         * Receives argument from buffer
+         *
+         * @param arg argument to be set
+         * @param lastBuffer buffer to be modified
+         *
+         * Both parameters will be modified
+         *
+         * @return true if arg was succesfully read
+         */
+        bool calculateArgumentAndBuffer(std::string & arg, std::string & lastBuffer);
+    };
+}
+
+#endif /* WRT_TESTS_W3C_TESTS_WIDGET_RUNNER_H */
+
diff --git a/tests/widgets/common/include/loop_control.h b/tests/widgets/common/include/loop_control.h
new file mode 100644 (file)
index 0000000..30aa6e8
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    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.
+ */
+/*
+ * @file        loop_control.cpp
+ * @author      Jaroslaw Osmanski (j.osmanski@samsung.com)
+ * @version     1.0
+ * @brief       This file is the definitions of loop controlling utilities
+ */
+
+
+#ifndef LOOP_CONTROL_H_
+#define LOOP_CONTROL_H_
+
+namespace LoopControl
+{
+
+void init_loop(int argc, char *argv[]);
+void wait_for_wrt_init();
+void finish_wait_for_wrt_init();
+void quit_loop();
+
+void wrt_start_loop();
+void wrt_end_loop();
+
+void *abstract_window();
+
+}
+
+#endif /* LOOP_CONTROL_H_ */
diff --git a/tests/widgets/common/src/InstallerWrapper.cpp b/tests/widgets/common/src/InstallerWrapper.cpp
new file mode 100644 (file)
index 0000000..40e680e
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    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.
+ */
+
+#include "InstallerWrapper.h"
+
+#include <dpl/log/log.h>
+
+#include <cstdio>
+
+namespace
+{
+
+const std::string params = "DPL_USE_OLD_STYLE_LOGS=0 "
+    "DPL_USE_OLD_STYLE_PEDANTIC_LOGS=0 WRT_TEST_MODE=1 ";
+const std::string installCmd = params + "wrt-installer -if ";
+const std::string uninstallCmd = params + "wrt-installer -un ";
+const std::string uninstallByGuidCmd = params + "wrt-installer -ug \"";
+const std::string redirection =  " 2>&1";
+const std::string INSTALLER_MESSAGE_ID_LINE =
+    "## wrt-installer : %s installation was successful.\n";
+const std::string INSTALLER_MESSSGE_START = "## wrt-installer : ";
+
+std::string getAndCutInstallerLogLine(std::string &src)
+{
+    size_t startIndex = src.find(INSTALLER_MESSSGE_START);
+    if (startIndex == std::string::npos)
+    {
+        LogWarning("Installer message can not be found");
+        return std::string();
+    }
+    size_t newLineIndex = src.find("\n", startIndex);
+    std::string line = src.substr(startIndex, newLineIndex - startIndex + 1);
+    src.erase(0, newLineIndex + 1);
+    return line;
+}
+
+}
+
+namespace InstallerWrapper
+{
+
+InstallResult install(
+        const std::string& path,
+        std::string& tizenId,
+        const std::string& user)
+{
+    std::string msg;
+
+    auto cmd = installCmd + path + redirection;
+    if(user.length()) //if other user should be used
+    {
+        cmd = "su " + user + " -c '" + cmd + "'";
+    }
+    LogDebug("executing: " << cmd);
+    auto filehandle = popen(cmd.c_str(), "r");
+    if (!filehandle) {
+        return OtherError;
+    }
+
+    char buffer[1024] = "";
+    int ret;
+    while ((ret = fread_unlocked(buffer,
+                                 sizeof(char),
+                                 sizeof(buffer)/sizeof(char),
+                                 filehandle)) > 0)
+    {
+        msg += buffer;
+    }
+    LogDebug(msg);
+    auto err = pclose(filehandle);
+    if (!WIFEXITED(err)) {
+        return OtherError;
+    }
+    if (0 != WEXITSTATUS(err)) {
+        if (1 == WEXITSTATUS(err)) {
+            return WrongWidgetPackage;
+        }
+        return OtherError;
+    }
+    char id[10];
+
+    std::string line;
+    while ((line = getAndCutInstallerLogLine(msg)) != "")
+    {
+        if (line.find("successful") != std::string::npos)
+        {
+            int nr = sscanf(line.c_str(), INSTALLER_MESSAGE_ID_LINE.c_str(), id);
+            if (1 != nr)
+            {
+                LogWarning("Can not read widget ID from message: " << line);
+                return OtherError;
+            }
+            tizenId = id;
+            if (tizenId != "plugin")
+            {
+                return Success;
+            }
+        }
+    }
+
+    return OtherError;
+}
+
+bool uninstall(const std::string& tizenId)
+{
+    std::string cmd = uninstallCmd + tizenId + " > /dev/null 2>/dev/null";
+    LogDebug("executing: " << cmd);
+    return (system(cmd.c_str()) == EXIT_SUCCESS);
+}
+
+bool uninstallByGuid(const std::string& guid)
+{
+    std::string cmd = uninstallByGuidCmd + guid + "\" > /dev/null 2>/dev/null";
+    LogDebug("executing: " << cmd);
+    return (system(cmd.c_str()) == EXIT_SUCCESS);
+}
+
+bool sigintWrtClients()
+{
+    return (system("pkill -2 wrt-client") == 0);
+}
+
+}
+
diff --git a/tests/widgets/common/src/RunnableObjectStateTester.cpp b/tests/widgets/common/src/RunnableObjectStateTester.cpp
new file mode 100644 (file)
index 0000000..5a67e4a
--- /dev/null
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    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.
+ */
+/**
+ * @file        RunnableObjectStateTester.cpp
+ * @author      Tomasz Iwanek (t.iwanek@samsung.com)
+ * @brief       Tester for RunnableWidgetObject's states
+ */
+
+#include "RunnableObjectStateTester.h"
+
+#include <dpl/framework_efl.h>
+#include <dpl/localization/w3c_file_localization.h>
+#include <vector>
+#include <string>
+#include <dpl/noncopyable.h>
+#include <dpl/log/log.h>
+#include <dpl/singleton_impl.h>
+#include <dpl/foreach.h>
+
+IMPLEMENT_SINGLETON(RunnableObjectStateTester)
+
+namespace {
+const std::string widgetPathMnimal = "/opt/share/widget/tests/misc/widgets/minimal.wgt";
+const int widgetInitializationTimeBounding = 3;
+}
+
+RunnableObjectStateTester::RunnableObjectStateTester()
+    : DPL::ApplicationExt(1, NULL, "test-app"),
+      DPL::TaskDecl<RunnableObjectStateTester>(this),
+      m_widgetPath(widgetPathMnimal)
+{
+    LogDebug("enter");
+
+    int argc = 0;
+    const char * argv[] = { "wrt-tests-wrt" };
+    if (!getenv("ELM_ENGINE")) {
+        if (setenv("ELM_ENGINE", "gl", 1)) {
+                LogDebug("Enable backend");
+        }
+    }
+    setenv("COREGL_FASTPATH", "1", 1);
+    DPL::Log::LogSystemSingleton::Instance().SetTag("WRT-CLIENT");
+
+    Touch();
+
+    //initialize
+    elm_init(argc, const_cast<char**>(argv));
+    if(!WRT::CoreModuleSingleton::Instance().Init())
+    {
+        ThrowMsg(CoreModuleFailure, "Init() fails");
+    }
+
+    InstallerWrapper::install(m_widgetPath, m_handle);
+
+    AddStep(&RunnableObjectStateTester::performTest);
+}
+
+RunnableObjectStateTester::~RunnableObjectStateTester()
+{
+    LogDebug("enter");
+    WRT::CoreModuleSingleton::Instance().Terminate();
+    InstallerWrapper::uninstall(m_handle);
+    elm_shutdown();
+}
+
+void RunnableObjectStateTester::performCheckBeforeLaunch()
+{
+    m_widget->CheckBeforeLaunch();
+}
+
+void RunnableObjectStateTester::performPrepareView()
+{
+    LogDebug("win");
+    Evas_Object * window = elm_win_util_standard_add("wrt-core-test", "wrt-core-test");
+    LogDebug("resize");
+    evas_object_resize(window, 100, 100);
+    LogDebug("ok");
+    evas_object_show(window);
+    m_windows.push_back(window);
+
+    DPL::OptionalString startUrl = W3CFileLocalization::getStartFile(m_dao);
+    if (startUrl.IsNull()) {
+        LogError("startUrl is null");
+        ThrowMsg(CoreModuleFailure, "startUrl is null");
+    }
+    LogDebug("start url done");
+
+    m_widget->PrepareView(DPL::ToUTF8String(*startUrl),
+            window);
+}
+
+void RunnableObjectStateTester::performShow()
+{
+    m_widget->Show();
+}
+
+void RunnableObjectStateTester::performHide()
+{
+    m_widget->Hide();
+}
+
+void RunnableObjectStateTester::performSuspend()
+{
+    m_widget->Suspend();
+}
+
+void RunnableObjectStateTester::performResume()
+{
+    m_widget->Resume();
+}
+
+void RunnableObjectStateTester::performReset()
+{
+    m_widget->Reset();
+}
+
+void RunnableObjectStateTester::performGetCurrentWebview()
+{
+    m_widget->GetCurrentWebview();
+}
+
+void RunnableObjectStateTester::performSetUserDelegates()
+{
+    WRT::UserDelegatesPtr dlgs(new WRT::UserDelegates);
+    dlgs->loadFinish = DPL::MakeDelegate(this, &RunnableObjectStateTester::loadFinishCallback);
+    m_widget->SetUserDelegates(dlgs);
+}
+
+void RunnableObjectStateTester::performBackward()
+{
+    m_widget->Backward();
+}
+
+void RunnableObjectStateTester::OnEventReceived(const NextStepEvent& /*event*/)
+{
+    NextStep();
+}
+
+void RunnableObjectStateTester::loadFinishCallback(Evas_Object* /*evas*/)
+{
+    LogDebug("enter");
+}
+
+void RunnableObjectStateTester::runTest(RunnableObjectStateTester::Test func)
+{
+    m_widget = WRT::CoreModuleSingleton::Instance().getRunnableWidgetObject(m_handle);
+    if(!m_widget)
+    {
+        ThrowMsg(CoreModuleFailure, "getRunnableWidgetObject() fails");
+    }
+
+    m_dao.reset(new WrtDB::WidgetDAOReadOnly(DPL::FromASCIIString(m_handle)));
+    m_func = func;
+    SwitchToStep(&RunnableObjectStateTester::performTest);
+    DPL::Event::ControllerEventHandler<NextStepEvent>::PostTimedEvent(NextStepEvent(), 1.0); //TODO: time hazard
+
+    elm_run(); //elm_run should be called instead of ecore_main_loop
+}
+
+void RunnableObjectStateTester::performTest()
+{
+    LogDebug("enter");
+
+    Try {
+        m_func(*this);
+    } Catch(DPL::Exception) {
+        LogDebug("Test broken not at condition to be checked. Check other tests");
+        LogDebug(_rethrown_exception.DumpToString());
+    }
+
+    Quit();
+    FOREACH(ptr, m_windows)
+    {
+        evas_object_del(*ptr);
+    }
+    m_windows.clear();
+    m_widget.reset();
+
+    LogDebug("leave");
+}
diff --git a/tests/widgets/common/src/TestBase.cpp b/tests/widgets/common/src/TestBase.cpp
new file mode 100644 (file)
index 0000000..4e5d524
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    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.
+ */
+
+#include <TestBase.h>
+
+#include <dpl/string.h>
+
+#include <InstallerWrapper.h>
+#include <dpl/test/test_runner.h>
+
+using namespace WrtDB;
+
+TestBase::TestBase(const std::string & path, const std::string & directory) :
+    dao(0),
+    m_widgetPath (std::string(WrtDB::GlobalConfig::GetTestsDataPath()) +
+                + "/" + directory + "/" + path),
+    m_widgetName(path.substr(0, path.find_first_of('.'))),
+    m_wrongWidgetPackage(false)
+{
+    LanguageTagsProviderSingleton::Instance().setLanguageTagsFromLocales("en");
+    m_tags = LanguageTagsProviderSingleton::Instance().getLanguageTags();
+}
+
+TestBase::~TestBase()
+{
+    LogDebug("Finishing test case");
+
+    LogDebug("deleting dao");
+    if (dao)
+    {
+        delete dao;
+        LogDebug("Uninstalling widget " << m_widgetTizenId);
+        InstallerWrapper::uninstall(DPL::ToUTF8String(m_widgetTizenId));
+    }
+
+    LogDebug("Finished");
+}
+
+void TestBase::StartTest()
+{
+    std::string id;
+    InstallerWrapper::InstallResult result =
+            InstallerWrapper::install(m_widgetPath, id);
+    if (InstallerWrapper::OtherError == result) {
+        this->dao = NULL;
+        m_wrongWidgetPackage = false;
+    } else if (InstallerWrapper::WrongWidgetPackage == result) {
+        this->dao = NULL;
+        m_wrongWidgetPackage = true;
+    } else {
+        m_widgetTizenId = DPL::FromASCIIString(id);
+        this->dao = new WidgetDAOReadOnly(m_widgetTizenId);
+    }
+}
+
+void TestBase::CheckIsNotValid()
+{
+    DPL::String msg;
+    if (dao)
+    {
+        msg = L"Widget should not be installed but has been anyway";
+    } else if (!m_wrongWidgetPackage) {
+        msg = L"Unknown error happend";
+    }
+
+    RUNNER_ASSERT_MSG(!dao && m_wrongWidgetPackage,
+                      "Install finished with: " << msg);
+}
+
+void TestBase::CheckIsValid()
+{
+    DPL::String msg;
+    if (!dao) {
+        if (m_wrongWidgetPackage) {
+            msg = L"Wrong widget package";
+        } else {
+            msg = L"Unknown error happend";
+        }
+    }
+
+    RUNNER_ASSERT_MSG(dao && !m_wrongWidgetPackage,
+                      "Install finished with: " << msg);
+}
+
+void TestBase::MakeScreenshot()
+{
+    InstallerWrapper::WidgetRunner runner(DPL::ToUTF8String(m_widgetTizenId), m_widgetName);
+    if (!runner.run(true)) {
+        RUNNER_ASSERT_MSG(false, "Screenshot was not made");
+    }
+}
+
+void TestBase::CheckWidgetJsHook(const char* hookFile)
+{
+    DPL::String package_name = this->dao->getPkgName();
+    InstallerWrapper::WidgetRunner runner(DPL::ToUTF8String(m_widgetTizenId), m_widgetName);
+    RUNNER_ASSERT_MSG(
+        runner.addTestHook(DPL::ToUTF8String(package_name).c_str(), hookFile),
+        "Couldn't add hook to " << hookFile);
+    RUNNER_ASSERT_MSG(runner.run(true), "Get test result for "
+            << runner.getResultWidgetName());
+    std::string res = runner.getResult();
+    RUNNER_ASSERT_MSG(InstallerWrapper::TEST_OK == res,
+            "Test " << runner.getResultWidgetName() << " result: " << res);
+}
+
+void TestBase::CheckWidgetJsReady()
+{
+    InstallerWrapper::WidgetRunner runner(DPL::ToUTF8String(m_widgetTizenId), m_widgetName);
+
+    runner.setHasHook(true);
+
+    if (runner.run(false)) {
+        CheckRunnerResult(runner);
+    } else {
+        RUNNER_ASSERT_MSG(false, "Fail to get test result for "
+                << runner.getResultWidgetName());
+    }
+}
+
+void TestBase::CheckRunnerResult(InstallerWrapper::WidgetRunner & runner)
+{
+    std::string res = runner.getResult();
+    LogDebug("Result: " << res);
+    if (InstallerWrapper::TEST_OK == res) {
+        RUNNER_ASSERT_MSG(true, "Test " << runner.getResultWidgetName()
+                << " passed");
+    }
+    else if (InstallerWrapper::TEST_FAIL == res){
+        RUNNER_ASSERT_MSG(false, "Test " << runner.getResultWidgetName()
+                << " failed");
+    }
+    else if (InstallerWrapper::TEST_EXCEPTION == res) {
+        RUNNER_ASSERT_MSG(false, "Test " << runner.getResultWidgetName()
+                << " threw exception");
+    }
+    else {
+        RUNNER_ASSERT_MSG(false, "Unknown result: " << res);
+    }
+}
diff --git a/tests/widgets/common/src/WidgetRunner.cpp b/tests/widgets/common/src/WidgetRunner.cpp
new file mode 100644 (file)
index 0000000..fb83e1b
--- /dev/null
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    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.
+ */
+
+#include "WidgetRunner.h"
+
+#include <stdio.h>
+#include <cstdlib>
+#include <fcntl.h>
+#include <dpl/assert.h>
+#include <dpl/log/log.h>
+#include <dpl/wrt-dao-ro/widget_config.h>
+#include <dpl/wrt-dao-ro/global_dao_read_only.h>
+#include <dpl/scoped_fclose.h>
+#include <dpl/utils/wrt_global_settings.h>
+#include <dpl/string.h>
+
+#include <InstallerWrapper.h>
+
+namespace InstallerWrapper {
+
+    const unsigned WidgetRunner::popenTimeout = 10;
+
+    WidgetRunner::WidgetRunner(std::string widgeTizenId, const std::string & name) {
+        m_widgetTizenId = widgeTizenId;
+        m_name = name;
+        m_hasHook = false;
+    }
+
+    bool WidgetRunner::addTestHook(const char* packageName, const char* hookFile)
+    {
+        Assert(packageName != NULL && "packageName is null");
+        std::string widgetHookJs(
+                WrtDB::WidgetConfig::GetWidgetBasePath(
+                        DPL::FromUTF8String(std::string(packageName))));
+        widgetHookJs += WrtDB::GlobalConfig::GetWidgetSrcPath();
+        widgetHookJs += "/";
+        widgetHookJs += hookFile;
+        DPL::ScopedFClose fp;
+        fp.Reset(fopen(widgetHookJs.c_str(), "r"));
+        if (!fp) {
+            LogError(widgetHookJs << " not found");
+            m_hasHook = false;
+            return false;
+        } else {
+            std::string command(
+                "sed -i \"s/function hook(id, result, message){};/"
+                "function hook(id, result, message){widget \\&\\& "
+                "widget.__test \\&\\& "
+                "(widget.__test.setEvaluator(function()"
+                "{return result == 'pass';}),"
+                "widget.__test.run(0.000000));}; /\" ");
+            command += widgetHookJs;
+            system(command.c_str());
+            m_hasHook = true;
+            return true;
+        }
+    }
+
+    void WidgetRunner::getInitWidgetText(FILE* file, std::string initText)
+    {
+        std::string lastBuffer;
+        initText = getArg(file, lastBuffer);
+        LogDebug("Init Widget text: " << initText);
+    }
+
+    void WidgetRunner::getArgs(FILE* file, std::string & id,
+            std::string & result, std::string & resultWidgetName) {
+        std::string lastBuffer;
+        id = getArg(file, lastBuffer);
+        LogDebug("ID: " << id);
+        resultWidgetName = getArg(file, lastBuffer);
+        LogDebug("ResultWidgetName: " << resultWidgetName);
+        result = getArg(file, lastBuffer);
+        LogDebug("Result: " << result);
+    }
+
+    std::string WidgetRunner::getArg(FILE* file, std::string & lastBuffer) {
+        const int count = 100;
+        const int fd = fileno(file);
+
+        std::string arg;
+        char buffer[count];
+        bool done = false;
+        int tries = popenTimeout;
+
+        while (!done) {
+            ssize_t rcount = read(fd, buffer, count);
+            if (rcount == -1 && errno == EAGAIN) {
+                sleep(1);
+                if (tries > 0) {
+                    tries--;
+                } else {
+                    Throw(GetArgException);
+                }
+            } else if (rcount > 0) {
+                //copy buffer
+                for (ssize_t i = 0; i < rcount; i++) {
+                    lastBuffer += buffer[i];
+                }
+            } else {
+                //pipe closed
+                Throw(GetArgException);
+            }
+            //receive requested argument from buffer
+            done = calculateArgumentAndBuffer(arg, lastBuffer);
+        }
+
+        return arg;
+    }
+
+    bool WidgetRunner::calculateArgumentAndBuffer(std::string & arg,
+            std::string & lastBuffer) {
+        //get argument
+        int posOfN = lastBuffer.find_first_of('\n');
+        int posOfT = lastBuffer.find_first_of('\t');
+        if (posOfN >= 0) {
+            if (posOfT >= 0) {
+                if (posOfN < posOfT) {
+                    arg = lastBuffer.substr(0, posOfN);
+                    lastBuffer = lastBuffer.substr(posOfN + 1,
+                            lastBuffer.length());
+                    return true;
+                } else {
+                    arg = lastBuffer.substr(0, posOfT);
+                    lastBuffer = lastBuffer.substr(posOfT + 1,
+                            lastBuffer.length());
+                    return true;
+                }
+            } else {
+                arg = lastBuffer.substr(0, posOfN);
+                lastBuffer = lastBuffer.substr(posOfN + 1,
+                        lastBuffer.length());
+                return true;
+            }
+        } else {
+            if (posOfT >= 0) {
+                arg = lastBuffer.substr(0, posOfT);
+                lastBuffer = lastBuffer.substr(posOfT + 1,
+                        lastBuffer.length());
+                return true;
+            }
+        }
+        return false;
+    }
+
+    bool WidgetRunner::run(bool doScreen) {
+        std::string command;
+        if (!m_hasHook) {
+            command += "DEBUG_LOAD_FINISH=1 ";
+        } else {
+            command += "DEBUG_LOAD_FINISH=0 ";
+        }
+        command += "wrt-client -t ";
+        command += m_widgetTizenId;
+        command += " 4>&1 2>>\"";
+        command += tmpFile;
+        command += "\" 1>>\"";
+        command += tmpFile + "\"";
+        LogDebug(command);
+
+        FILE* result = popen(command.c_str(), "r");
+        fcntl(fileno(result), F_SETFL, O_NONBLOCK);
+
+        if (result) {
+            Try
+            {
+                if (m_hasHook) {
+                    std::string id;
+                    // widget id, test result, widget name
+                    getArgs(result, id, m_result, m_resultWidgetName);
+                } else {
+                    std::string m_test_id;
+                    getInitWidgetText(result, m_test_id);
+                    //this constant string is also in wrt repo, make it constant?
+                    if (m_test_id == "didFinishLoadForFrameCallback: ready")
+                    {
+                        m_resultWidgetName = InstallerWrapper::TEST_MANUAL;
+                    }
+                }
+            }
+
+            Catch(GetArgException) {
+                LogDebug("Test result is not complete");
+            }
+
+            if (GlobalSettings::MakeScreenTestModeEnabled())
+            {
+                if (doScreen) {
+                    if (!m_hasHook) {
+                        LogDebug("Sleeping");
+                        sleep(popenTimeout);
+                    }
+                    //make a screenshot
+                    std::string command = std::string("xwd -root -out ") + m_name
+                            + ".xwd ";
+                    LogDebug("Running system command: " << command);
+                    system(command.c_str());
+                }
+            }
+            // close widget (sigint)
+            sigintWrtClients();
+            pclose(result);
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    std::string WidgetRunner::getResult() const {
+        return m_result;
+    }
+
+    std::string WidgetRunner::getResultWidgetName() const {
+        return m_resultWidgetName;
+    }
+
+    void WidgetRunner::setHasHook(bool hasHook) {
+        m_hasHook = hasHook;
+    }
+}
diff --git a/tests/widgets/common/src/loop_control.cpp b/tests/widgets/common/src/loop_control.cpp
new file mode 100644 (file)
index 0000000..eed375c
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    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.
+ */
+/*
+ * @file        loop_control.cpp
+ * @author      Jaroslaw Osmanski (j.osmanski@samsung.com)
+ * @version     1.0
+ * @brief       This is implementation of EFL version of loop control
+ */
+
+#include <loop_control.h>
+#include <dpl/log/log.h>
+
+#include <dpl/framework_efl.h>
+
+#include <glib.h>
+#include <glib-object.h>
+
+
+namespace LoopControl
+{
+void init_loop(int argc, char *argv[])
+{
+    (void)argc;
+    (void)argv;
+    g_type_init();
+    g_thread_init(NULL);
+
+    LogInfo("Starting");
+    elm_init(argc, argv);
+}
+
+void wait_for_wrt_init()
+{
+    ecore_main_loop_begin();
+}
+
+void finish_wait_for_wrt_init()
+{
+    ecore_main_loop_quit();
+}
+
+void quit_loop()
+{
+    elm_shutdown();
+}
+
+void wrt_start_loop()
+{
+    ecore_main_loop_begin();
+}
+
+void wrt_end_loop()
+{
+    ecore_main_loop_quit();
+}
+
+void *abstract_window()
+{
+    return elm_win_add(NULL, "hello", ELM_WIN_BASIC);
+}
+
+}//end of LoopControl namespace