From: Inkyun Kil Date: Wed, 14 Aug 2019 01:07:17 +0000 (+0900) Subject: [UTC][component-based-application][ACR-1415][Add component-based-application TCs] X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=45f96df2f3f892c492445cfaa6eaa7548e6e6d58;p=test%2Ftct%2Fnative%2Fapi.git [UTC][component-based-application][ACR-1415][Add component-based-application TCs] Change-Id: Ibc1956a9b29e470f76ae81a70d5cf416d779f8c5 Signed-off-by: Inkyun Kil --- diff --git a/packaging/utc/core-component-based-application-tests.spec b/packaging/utc/core-component-based-application-tests.spec new file mode 100755 index 000000000..9e01a5639 --- /dev/null +++ b/packaging/utc/core-component-based-application-tests.spec @@ -0,0 +1,86 @@ +%define MODULE_NAME component-based-application +%define MODULE_LIBNAME component-based-application +Name: core-%{MODULE_NAME}-tests +Summary: Core API unit TC (%{name}) +Version: 0.1 +Release: 0 +Group: Development/Tools +License: Apache License, Version 2.0 +Source0: %{name}-%{version}.tar.gz +BuildRequires: pkgconfig(%{MODULE_LIBNAME}) +BuildRequires: cmake +BuildRequires: pkgconfig(glib-2.0) +BuildRequires: pkgconfig(gobject-2.0) +BuildRequires: pkgconfig(capi-appfw-application) +BuildRequires: pkgconfig(bundle) +BuildRequires: pkgconfig(ecore) +BuildRequires: pkgconfig(capi-appfw-app-manager) +BuildRequires: pkgconfig(capi-system-info) +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(elementary) + +%description +Core API unit TC (%{name}) + +%prep +%setup -q + +%build + +%define PREFIX "%{_libdir}/%{name}" + +export LDFLAGS+="-Wl,--rpath=%{PREFIX} -Wl,--as-needed" + +%if %{?ASAN_BUILD:1}0 + %if %{?DEVICE_BUILD_TYPE_MOBILE:1}0 + cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="utc" -DDEVICE_BUILD_TYPE="mobile" -DASANBUILD="true" -DCMAKE_INSTALL_PREFIX=%{_prefix} + %endif + %if %{?DEVICE_BUILD_TYPE_WEARABLE:1}0 + cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="utc" -DDEVICE_BUILD_TYPE="wearable" -DASANBUILD="true" -DCMAKE_INSTALL_PREFIX=%{_prefix} + %endif + %if %{?DEVICE_BUILD_TYPE_TV:1}0 + cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="utc" -DDEVICE_BUILD_TYPE="tv" -DASANBUILD="true" -DCMAKE_INSTALL_PREFIX=%{_prefix} + %endif + %if %{?DEVICE_BUILD_TYPE_TIZENIOT:1}0 + cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="utc" -DDEVICE_BUILD_TYPE="tizeniot" -DASANBUILD="true" -DCMAKE_INSTALL_PREFIX=%{_prefix} + %endif +%else + %if %{?DEVICE_BUILD_TYPE_MOBILE:1}0 + cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="utc" -DDEVICE_BUILD_TYPE="mobile" -DASANBUILD="false" -DCMAKE_INSTALL_PREFIX=%{_prefix} + %endif + %if %{?DEVICE_BUILD_TYPE_WEARABLE:1}0 + cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="utc" -DDEVICE_BUILD_TYPE="wearable" -DASANBUILD="false" -DCMAKE_INSTALL_PREFIX=%{_prefix} + %endif + %if %{?DEVICE_BUILD_TYPE_TV:1}0 + cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="utc" -DDEVICE_BUILD_TYPE="tv" -DASANBUILD="false" -DCMAKE_INSTALL_PREFIX=%{_prefix} + %endif + %if %{?DEVICE_BUILD_TYPE_TIZENIOT:1}0 + cmake . -DMODULE="%{MODULE_NAME}" -DBUILDTCTYPE="utc" -DDEVICE_BUILD_TYPE="tizeniot" -DASANBUILD="false" -DCMAKE_INSTALL_PREFIX=%{_prefix} + %endif +%endif + +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +%make_install +mkdir -p %{buildroot}/usr/share/license +cp LICENSE %{buildroot}/usr/share/license/%{name} +mkdir -p %{buildroot}/usr/share/packages/ +cp packaging/utc/%{name}.xml %{buildroot}/usr/share/packages/ +mkdir -p %{buildroot}/usr/apps/%{name}/bin +mkdir -p %{buildroot}/usr/apps/%{name}/data +mkdir -p %{buildroot}/usr/apps/%{name}/res +cp -r src/utc/application/res/* %{buildroot}/usr/apps/%{name}/res + +%post +chown -R owner:users /usr/apps/%{name}/data +chsmack -a %{name} /usr/apps/%{name}/data + +%postun + + +%files +/usr/apps/%{name}/* +/usr/share/packages/%{name}.xml +/usr/share/license/%{name} diff --git a/packaging/utc/core-component-based-application-tests.xml b/packaging/utc/core-component-based-application-tests.xml new file mode 100755 index 000000000..78e77d32a --- /dev/null +++ b/packaging/utc/core-component-based-application-tests.xml @@ -0,0 +1,23 @@ + + + + test + Core API test Application + + + + + + + + + + + + + + + http://tizen.org/privilege/appmanager.launch + http://tizen.org/privilege/packagemanager.info + + diff --git a/src/utc/component-based-application/CMakeLists.txt b/src/utc/component-based-application/CMakeLists.txt new file mode 100644 index 000000000..12c9ff610 --- /dev/null +++ b/src/utc/component-based-application/CMakeLists.txt @@ -0,0 +1,44 @@ +SET(PKG_NAME "component-based-application") + +SET(EXEC_NAME "tct-${PKG_NAME}-core") +SET(RPM_NAME "core-${PKG_NAME}-tests") + +SET(CAPI_LIB "component-based-application") +SET(TC_SOURCES + utc-component-based-app.c + utc-component-common.c +) + +PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED + ${CAPI_LIB} + capi-appfw-application + capi-system-info + glib-2.0 + bundle + dlog + elementary +) + +INCLUDE_DIRECTORIES( + ${${CAPI_LIB}_INCLUDE_DIRS} +) + +ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.c ${TC_SOURCES} ${COMMON_FILE}) +TARGET_LINK_LIBRARIES(${EXEC_NAME} + ${${CAPI_LIB}_LIBRARIES} + bundle +) + +INSTALL(PROGRAMS ${EXEC_NAME} + DESTINATION ${BIN_DIR}/${RPM_NAME}/bin +) + +IF( DEFINED ASAN ) +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Wall -pie -g -fsanitize=address -fsanitize-recover=address -U_FORTIFY_SOURCE -fno-omit-frame-pointer") +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib -Wl,-fsanitize=address") +ELSE() +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g -fPIE -Wall") +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib -pie") +ENDIF() + +ADD_SUBDIRECTORY(component_app) diff --git a/src/utc/component-based-application/assert_common.h b/src/utc/component-based-application/assert_common.h new file mode 100755 index 000000000..935b4ad1d --- /dev/null +++ b/src/utc/component-based-application/assert_common.h @@ -0,0 +1,94 @@ +#ifndef __ASSERT_COMMON_H__ +#define __ASSERT_COMMON_H__ + +#include +#include +#include +#include +#define MAX_TIMER_CNT 10 + +#ifdef LOG_TAG +#undef LOG_TAG +#define LOG_TAG "component-based-application-tests" +#endif + +int utc_result; + +#define assert_with_exit(exp) do { \ + if (!(exp)) { \ + dlog_print(DLOG_ERROR, LOG_TAG, \ + "Assert fail in %s:%d\n", __FILE__, __LINE__); \ + dlog_print(DLOG_ERROR, LOG_TAG, \ + "Following expression is not true:\n" \ + "%s\n", #exp); \ + utc_result = 1; \ + ui_app_exit(); \ + return 1; \ + } \ + } while (0) + +#define assert_eq_with_exit(var, ref) do { \ + if (var != ref) { \ + dlog_print(DLOG_ERROR, LOG_TAG, \ + "Assert fail in %s:%d\n", __FILE__, __LINE__); \ + dlog_print(DLOG_ERROR, LOG_TAG, \ + "Values \"%s\" and \"%s\" are not equal:\n" \ + "%s == %d, %s == %d\n", \ + #var, #ref, #var, (int)var, #ref, (int)ref); \ + utc_result = 1; \ + ui_app_exit(); \ + return 1; \ + } \ + } while (0) + +#define assert_neq_with_exit(var, ref) do { \ + if (var == ref) { \ + dlog_print(DLOG_ERROR, LOG_TAG, \ + "Assert fail in %s:%d\n", __FILE__, __LINE__); \ + dlog_print(DLOG_ERROR, LOG_TAG, \ + "Values \"%s\" and \"%s\" are equal:\n" \ + "%s == %s == %d\n", \ + #var, #ref, #var, #ref, (int)ref); \ + utc_result = 1; \ + ui_app_exit(); \ + return 1; \ + } \ + } while (0) + +#define assert_eq_without_exit(var, ref) do { \ + if (var != ref) { \ + dlog_print(DLOG_ERROR, LOG_TAG, \ + "Assert fail in %s:%d\n", __FILE__, __LINE__); \ + dlog_print(DLOG_ERROR, LOG_TAG, \ + "Values \"%s\" and \"%s\" are not equal:\n" \ + "%s == %d, %s == %d\n", \ + #var, #ref, #var, var, #ref, ref); \ + utc_result = 1; \ + return 1; \ + } \ + } while (0) + +#define assert_neq_without_exit(var, ref) do { \ + if (var == ref) { \ + dlog_print(DLOG_ERROR, LOG_TAG, \ + "Assert fail in %s:%d\n", __FILE__, __LINE__); \ + dlog_print(DLOG_ERROR, LOG_TAG, \ + "Values \"%s\" and \"%s\" are equal:\n" \ + "%s == %s == %d\n", \ + #var, #ref, #var, #ref, ref); \ + utc_result = 1; \ + return 1; \ + } \ + } while (0) + +#define normal_exit(result) do { \ + utc_result = result; \ + ui_app_exit(); \ + } while (0) + +#define set_result(result) do { \ + dlog_print(DLOG_INFO, LOG_TAG, "result: %d", result); \ + utc_result = result; \ + } while (0) + +#endif /* __ASSERT_COMMON_H__ */ diff --git a/src/utc/component-based-application/res/mobile/org.example.componentbased-1.0.0-arm.tpk b/src/utc/component-based-application/res/mobile/org.example.componentbased-1.0.0-arm.tpk new file mode 100755 index 000000000..1ca73eeb6 Binary files /dev/null and b/src/utc/component-based-application/res/mobile/org.example.componentbased-1.0.0-arm.tpk differ diff --git a/src/utc/component-based-application/res/mobile/org.example.componentbased-1.0.0-i386.tpk b/src/utc/component-based-application/res/mobile/org.example.componentbased-1.0.0-i386.tpk new file mode 100755 index 000000000..37695d5e8 Binary files /dev/null and b/src/utc/component-based-application/res/mobile/org.example.componentbased-1.0.0-i386.tpk differ diff --git a/src/utc/component-based-application/res/mobile/org.tizen.helloworld-1.0.0-arm.tpk b/src/utc/component-based-application/res/mobile/org.tizen.helloworld-1.0.0-arm.tpk new file mode 100644 index 000000000..44c8d544e Binary files /dev/null and b/src/utc/component-based-application/res/mobile/org.tizen.helloworld-1.0.0-arm.tpk differ diff --git a/src/utc/component-based-application/res/mobile/org.tizen.helloworld-1.0.0-i386.tpk b/src/utc/component-based-application/res/mobile/org.tizen.helloworld-1.0.0-i386.tpk new file mode 100755 index 000000000..3a12252fb Binary files /dev/null and b/src/utc/component-based-application/res/mobile/org.tizen.helloworld-1.0.0-i386.tpk differ diff --git a/src/utc/component-based-application/res/tizeniot/org.example.componentbased-1.0.0-arm.tpk b/src/utc/component-based-application/res/tizeniot/org.example.componentbased-1.0.0-arm.tpk new file mode 100755 index 000000000..1ca73eeb6 Binary files /dev/null and b/src/utc/component-based-application/res/tizeniot/org.example.componentbased-1.0.0-arm.tpk differ diff --git a/src/utc/component-based-application/res/tizeniot/org.example.componentbased-1.0.0-i386.tpk b/src/utc/component-based-application/res/tizeniot/org.example.componentbased-1.0.0-i386.tpk new file mode 100755 index 000000000..37695d5e8 Binary files /dev/null and b/src/utc/component-based-application/res/tizeniot/org.example.componentbased-1.0.0-i386.tpk differ diff --git a/src/utc/component-based-application/res/tizeniot/org.tizen.helloworld-1.0.0-arm.tpk b/src/utc/component-based-application/res/tizeniot/org.tizen.helloworld-1.0.0-arm.tpk new file mode 100755 index 000000000..44c8d544e Binary files /dev/null and b/src/utc/component-based-application/res/tizeniot/org.tizen.helloworld-1.0.0-arm.tpk differ diff --git a/src/utc/component-based-application/res/tizeniot/org.tizen.helloworld-1.0.0-i386.tpk b/src/utc/component-based-application/res/tizeniot/org.tizen.helloworld-1.0.0-i386.tpk new file mode 100755 index 000000000..3a12252fb Binary files /dev/null and b/src/utc/component-based-application/res/tizeniot/org.tizen.helloworld-1.0.0-i386.tpk differ diff --git a/src/utc/component-based-application/res/tv/org.example.componentbased-1.0.0-arm.tpk b/src/utc/component-based-application/res/tv/org.example.componentbased-1.0.0-arm.tpk new file mode 100755 index 000000000..1ca73eeb6 Binary files /dev/null and b/src/utc/component-based-application/res/tv/org.example.componentbased-1.0.0-arm.tpk differ diff --git a/src/utc/component-based-application/res/tv/org.example.componentbased-1.0.0-i386.tpk b/src/utc/component-based-application/res/tv/org.example.componentbased-1.0.0-i386.tpk new file mode 100755 index 000000000..37695d5e8 Binary files /dev/null and b/src/utc/component-based-application/res/tv/org.example.componentbased-1.0.0-i386.tpk differ diff --git a/src/utc/component-based-application/res/tv/org.tizen.helloworld-1.0.0-arm.tpk b/src/utc/component-based-application/res/tv/org.tizen.helloworld-1.0.0-arm.tpk new file mode 100755 index 000000000..44c8d544e Binary files /dev/null and b/src/utc/component-based-application/res/tv/org.tizen.helloworld-1.0.0-arm.tpk differ diff --git a/src/utc/component-based-application/res/tv/org.tizen.helloworld-1.0.0-i386.tpk b/src/utc/component-based-application/res/tv/org.tizen.helloworld-1.0.0-i386.tpk new file mode 100755 index 000000000..3a12252fb Binary files /dev/null and b/src/utc/component-based-application/res/tv/org.tizen.helloworld-1.0.0-i386.tpk differ diff --git a/src/utc/component-based-application/res/wearable/org.example.componentbased-1.0.0-arm.tpk b/src/utc/component-based-application/res/wearable/org.example.componentbased-1.0.0-arm.tpk new file mode 100755 index 000000000..1ca73eeb6 Binary files /dev/null and b/src/utc/component-based-application/res/wearable/org.example.componentbased-1.0.0-arm.tpk differ diff --git a/src/utc/component-based-application/res/wearable/org.example.componentbased-1.0.0-i386.tpk b/src/utc/component-based-application/res/wearable/org.example.componentbased-1.0.0-i386.tpk new file mode 100755 index 000000000..37695d5e8 Binary files /dev/null and b/src/utc/component-based-application/res/wearable/org.example.componentbased-1.0.0-i386.tpk differ diff --git a/src/utc/component-based-application/res/wearable/org.tizen.helloworld-1.0.0-arm.tpk b/src/utc/component-based-application/res/wearable/org.tizen.helloworld-1.0.0-arm.tpk new file mode 100755 index 000000000..44c8d544e Binary files /dev/null and b/src/utc/component-based-application/res/wearable/org.tizen.helloworld-1.0.0-arm.tpk differ diff --git a/src/utc/component-based-application/res/wearable/org.tizen.helloworld-1.0.0-i386.tpk b/src/utc/component-based-application/res/wearable/org.tizen.helloworld-1.0.0-i386.tpk new file mode 100755 index 000000000..3a12252fb Binary files /dev/null and b/src/utc/component-based-application/res/wearable/org.tizen.helloworld-1.0.0-i386.tpk differ diff --git a/src/utc/component-based-application/tct-component-based-application-core.c b/src/utc/component-based-application/tct-component-based-application-core.c new file mode 100644 index 000000000..fdf4a2b76 --- /dev/null +++ b/src/utc/component-based-application/tct-component-based-application-core.c @@ -0,0 +1,155 @@ +// +// 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. +// +#include "tct_common.h" +#include "assert_common.h" + +#ifdef MOBILE //Starts MOBILE +#include "tct-component-based-application-core_mobile.h" +#endif //MOBILE //End MOBILE + +#ifdef WEARABLE //Starts WEARABLE +#include "tct-component-based-application-core_wearable.h" +#endif //WEARABLE //End WEARABLE + +#ifdef TV //Starts TV +#include "tct-component-based-application-core_tv.h" +#endif //TV //End TV + +#ifdef TIZENIOT //Starts TIZENIOT +#include "tct-component-based-application-core_tizeniot.h" +#endif //TIZENIOT //End TIZENIOT + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +static char *pszGetTCName; +static void (*cleanup_func)(void); + +static gboolean run_testcases(gpointer user_data) { + + int i; + + utc_result = -1; + cleanup_func = NULL; + dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Executing TC Name = %s", __FUNCTION__, __LINE__, pszGetTCName); + for (i = 0; tc_array[i].name; i++) { + if (strncmp(pszGetTCName, tc_array[i].name, strlen(pszGetTCName)) == 0) { + DUMP_UTC_ERRLOG(); + dlog_print(DLOG_INFO, "NativeTCT", "%s : Startup begin", pszGetTCName); + if (tc_array[i].startup) { + tc_array[i].startup(); + } + dlog_print(DLOG_INFO, "NativeTCT", "%s : Startup end", pszGetTCName); + + dlog_print(DLOG_INFO, "NativeTCT", "%s : Body begin", pszGetTCName); + tc_array[i].function(); + dlog_print(DLOG_INFO, "NativeTCT", "%s", pszGetTCName); + dlog_print(DLOG_INFO, "NativeTCT", "%s : Body end", pszGetTCName); + + dlog_print(DLOG_INFO, "NativeTCT", "%s : Cleanup function pointer assigned", pszGetTCName); + if (tc_array[i].cleanup){ + cleanup_func = tc_array[i].cleanup; + } + + return FALSE; + } + } + + dlog_print(DLOG_ERROR, "NativeTCT", "[%s:%d] Unable to execute %s : Unknown Test Case Name", __FUNCTION__, __LINE__, pszGetTCName); + PRINT_UTC_LOG("\\n[%s][Line : %d]Unable to execute %s : Unknown Test Case Name\\n", __FILE__, __LINE__, pszGetTCName); + PRINT_TC_RESULT("%d", 1); + FREE_MEMORY_TC(pszGetTCName); + ui_app_exit(); + + return FALSE; +} + +static void app_control(app_control_h app_control, void *data) +{ + + int nRet = 0; + nRet = app_control_get_extra_data(app_control, "testcase_name", &pszGetTCName); + if(nRet != APP_CONTROL_ERROR_NONE) + { + dlog_print(DLOG_ERROR, "NativeTCT", "[%s:%d] app_control_get_extra_data returns error = %d", __FUNCTION__, __LINE__, nRet); + PRINT_UTC_LOG("\\n[%s][Line : %d]Unable to fetch test case name: app_control_get_extra_data API call fails\\n", __FILE__, __LINE__); + PRINT_TC_RESULT("%d",1); + FREE_MEMORY_TC(pszGetTCName); + return; + } + + run_testcases(NULL); + + + return; +} + +static bool app_create(void *data) +{ + return true; +} + +static void app_terminate(void *data) +{ + dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Application Package is now Terminating", __FUNCTION__, __LINE__); +} + +int main(int argc, char *argv[]) +{ + int ret; + + //setting gcda file location for coverage + setenv("GCOV_PREFIX", "/tmp", 1); + dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Coverage *.gcda File location set to /tmp/home/abuild/rpmbuild/BUILD/ ", __FUNCTION__, __LINE__); + + ui_app_lifecycle_callback_s event_callback = {0,}; + event_callback.create = app_create; + event_callback.terminate = app_terminate; + event_callback.app_control = app_control; + + dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Application Main Function is Invoked", __FUNCTION__, __LINE__); + + ret = ui_app_main(argc, argv, &event_callback, NULL); + if (ret != APP_ERROR_NONE) { + dlog_print(DLOG_ERROR, "NativeTCT", "Application ui_app_main call gets failed. err = %d", ret); + PRINT_UTC_LOG("\\n[%s][Line : %d]Application ui_app_main call gets failed. err = %d\\n", __FILE__, __LINE__, ret); + PRINT_TC_RESULT("%d", 1); + return ret; + } + + CLOSE_UTC_ERRLOG(); + PRINT_TC_RESULT("%d", utc_result); + if (cleanup_func) { + dlog_print(DLOG_INFO, "NativeTCT", "%s : Cleanup begin", pszGetTCName); + cleanup_func(); + dlog_print(DLOG_INFO, "NativeTCT", "%s : Cleanup end", pszGetTCName); + } + FREE_MEMORY_TC(pszGetTCName); + + dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Application Package is Terminated", __FUNCTION__, __LINE__); + return ret; +} diff --git a/src/utc/component-based-application/tct-component-based-application-core_mobile.h b/src/utc/component-based-application/tct-component-based-application-core_mobile.h new file mode 100644 index 000000000..e63a35378 --- /dev/null +++ b/src/utc/component-based-application/tct-component-based-application-core_mobile.h @@ -0,0 +1,68 @@ +// +// Copyright (c) 2019 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. +// +#ifndef __TCT_COMPONENT_BASED_APPLICATION_NATIVE_H__ +#define __TCT_COMPONENT_BASED_APPLICATION_NATIVE_H__ + +#include "testcase.h" +#include "tct_common.h" + +extern void utc_component_based_application_startup(void); +extern void utc_component_based_application_cleanup(void); + +extern int utc_component_based_app_main_p(void); +extern int utc_component_based_app_main_n(void); +extern int utc_component_based_app_add_frame_component_p(void); +extern int utc_component_based_app_add_frame_component_n(void); +extern int utc_component_based_app_add_service_component_p(void); +extern int utc_component_based_app_add_service_component_n(void); +extern int utc_frame_component_get_display_status_p(void); +extern int utc_frame_component_get_display_status_n(void); +extern int utc_frame_component_get_window_p(void); +extern int utc_frame_component_get_window_n(void); +extern int utc_component_register_action_p(void); +extern int utc_component_register_action_n(void); +extern int utc_component_deregister_action_p(void); +extern int utc_component_deregister_action_n(void); +extern int utc_component_send_launch_request_sync_p(void); +extern int utc_component_send_launch_request_sync_n(void); +extern int utc_component_send_launch_request_async_p(void); +extern int utc_component_send_launch_request_async_n(void); +extern int utc_component_based_app_exit_p(void); + +testcase tc_array[] = { + {"utc_component_based_app_main_p", utc_component_based_app_main_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_based_app_main_n", utc_component_based_app_main_n, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_based_app_add_frame_component_p", utc_component_based_app_add_frame_component_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_based_app_add_frame_component_n", utc_component_based_app_add_frame_component_n, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_based_app_add_service_component_p", utc_component_based_app_add_service_component_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_based_app_add_service_component_n", utc_component_based_app_add_service_component_n, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_frame_component_get_display_status_p", utc_frame_component_get_display_status_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_frame_component_get_display_status_n", utc_frame_component_get_display_status_n, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_frame_component_get_window_p", utc_frame_component_get_window_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_frame_component_get_window_n", utc_frame_component_get_window_n, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_register_action_p", utc_component_register_action_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_register_action_n", utc_component_register_action_n, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_deregister_action_p", utc_component_deregister_action_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_deregister_action_n", utc_component_deregister_action_n, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_send_launch_request_sync_p", utc_component_send_launch_request_sync_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_send_launch_request_sync_n", utc_component_send_launch_request_sync_n, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_send_launch_request_async_p", utc_component_send_launch_request_async_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_send_launch_request_async_n", utc_component_send_launch_request_async_n, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_based_app_exit_p", utc_component_based_app_exit_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {NULL, NULL} +}; + +#endif // __TCT_COMPONENT_BASED_APPLICATION_NATIVE_H__ diff --git a/src/utc/component-based-application/tct-component-based-application-core_tizeniot.h b/src/utc/component-based-application/tct-component-based-application-core_tizeniot.h new file mode 100644 index 000000000..e63a35378 --- /dev/null +++ b/src/utc/component-based-application/tct-component-based-application-core_tizeniot.h @@ -0,0 +1,68 @@ +// +// Copyright (c) 2019 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. +// +#ifndef __TCT_COMPONENT_BASED_APPLICATION_NATIVE_H__ +#define __TCT_COMPONENT_BASED_APPLICATION_NATIVE_H__ + +#include "testcase.h" +#include "tct_common.h" + +extern void utc_component_based_application_startup(void); +extern void utc_component_based_application_cleanup(void); + +extern int utc_component_based_app_main_p(void); +extern int utc_component_based_app_main_n(void); +extern int utc_component_based_app_add_frame_component_p(void); +extern int utc_component_based_app_add_frame_component_n(void); +extern int utc_component_based_app_add_service_component_p(void); +extern int utc_component_based_app_add_service_component_n(void); +extern int utc_frame_component_get_display_status_p(void); +extern int utc_frame_component_get_display_status_n(void); +extern int utc_frame_component_get_window_p(void); +extern int utc_frame_component_get_window_n(void); +extern int utc_component_register_action_p(void); +extern int utc_component_register_action_n(void); +extern int utc_component_deregister_action_p(void); +extern int utc_component_deregister_action_n(void); +extern int utc_component_send_launch_request_sync_p(void); +extern int utc_component_send_launch_request_sync_n(void); +extern int utc_component_send_launch_request_async_p(void); +extern int utc_component_send_launch_request_async_n(void); +extern int utc_component_based_app_exit_p(void); + +testcase tc_array[] = { + {"utc_component_based_app_main_p", utc_component_based_app_main_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_based_app_main_n", utc_component_based_app_main_n, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_based_app_add_frame_component_p", utc_component_based_app_add_frame_component_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_based_app_add_frame_component_n", utc_component_based_app_add_frame_component_n, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_based_app_add_service_component_p", utc_component_based_app_add_service_component_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_based_app_add_service_component_n", utc_component_based_app_add_service_component_n, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_frame_component_get_display_status_p", utc_frame_component_get_display_status_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_frame_component_get_display_status_n", utc_frame_component_get_display_status_n, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_frame_component_get_window_p", utc_frame_component_get_window_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_frame_component_get_window_n", utc_frame_component_get_window_n, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_register_action_p", utc_component_register_action_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_register_action_n", utc_component_register_action_n, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_deregister_action_p", utc_component_deregister_action_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_deregister_action_n", utc_component_deregister_action_n, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_send_launch_request_sync_p", utc_component_send_launch_request_sync_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_send_launch_request_sync_n", utc_component_send_launch_request_sync_n, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_send_launch_request_async_p", utc_component_send_launch_request_async_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_send_launch_request_async_n", utc_component_send_launch_request_async_n, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_based_app_exit_p", utc_component_based_app_exit_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {NULL, NULL} +}; + +#endif // __TCT_COMPONENT_BASED_APPLICATION_NATIVE_H__ diff --git a/src/utc/component-based-application/tct-component-based-application-core_wearable.h b/src/utc/component-based-application/tct-component-based-application-core_wearable.h new file mode 100644 index 000000000..e63a35378 --- /dev/null +++ b/src/utc/component-based-application/tct-component-based-application-core_wearable.h @@ -0,0 +1,68 @@ +// +// Copyright (c) 2019 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. +// +#ifndef __TCT_COMPONENT_BASED_APPLICATION_NATIVE_H__ +#define __TCT_COMPONENT_BASED_APPLICATION_NATIVE_H__ + +#include "testcase.h" +#include "tct_common.h" + +extern void utc_component_based_application_startup(void); +extern void utc_component_based_application_cleanup(void); + +extern int utc_component_based_app_main_p(void); +extern int utc_component_based_app_main_n(void); +extern int utc_component_based_app_add_frame_component_p(void); +extern int utc_component_based_app_add_frame_component_n(void); +extern int utc_component_based_app_add_service_component_p(void); +extern int utc_component_based_app_add_service_component_n(void); +extern int utc_frame_component_get_display_status_p(void); +extern int utc_frame_component_get_display_status_n(void); +extern int utc_frame_component_get_window_p(void); +extern int utc_frame_component_get_window_n(void); +extern int utc_component_register_action_p(void); +extern int utc_component_register_action_n(void); +extern int utc_component_deregister_action_p(void); +extern int utc_component_deregister_action_n(void); +extern int utc_component_send_launch_request_sync_p(void); +extern int utc_component_send_launch_request_sync_n(void); +extern int utc_component_send_launch_request_async_p(void); +extern int utc_component_send_launch_request_async_n(void); +extern int utc_component_based_app_exit_p(void); + +testcase tc_array[] = { + {"utc_component_based_app_main_p", utc_component_based_app_main_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_based_app_main_n", utc_component_based_app_main_n, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_based_app_add_frame_component_p", utc_component_based_app_add_frame_component_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_based_app_add_frame_component_n", utc_component_based_app_add_frame_component_n, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_based_app_add_service_component_p", utc_component_based_app_add_service_component_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_based_app_add_service_component_n", utc_component_based_app_add_service_component_n, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_frame_component_get_display_status_p", utc_frame_component_get_display_status_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_frame_component_get_display_status_n", utc_frame_component_get_display_status_n, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_frame_component_get_window_p", utc_frame_component_get_window_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_frame_component_get_window_n", utc_frame_component_get_window_n, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_register_action_p", utc_component_register_action_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_register_action_n", utc_component_register_action_n, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_deregister_action_p", utc_component_deregister_action_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_deregister_action_n", utc_component_deregister_action_n, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_send_launch_request_sync_p", utc_component_send_launch_request_sync_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_send_launch_request_sync_n", utc_component_send_launch_request_sync_n, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_send_launch_request_async_p", utc_component_send_launch_request_async_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_send_launch_request_async_n", utc_component_send_launch_request_async_n, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {"utc_component_based_app_exit_p", utc_component_based_app_exit_p, utc_component_based_application_startup, utc_component_based_application_cleanup}, + {NULL, NULL} +}; + +#endif // __TCT_COMPONENT_BASED_APPLICATION_NATIVE_H__ diff --git a/src/utc/component-based-application/utc-component-based-app.c b/src/utc/component-based-application/utc-component-based-app.c new file mode 100644 index 000000000..bbf09e01a --- /dev/null +++ b/src/utc/component-based-application/utc-component-based-app.c @@ -0,0 +1,577 @@ +// +// Copyright (c) 2019 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. +// + +#include +#include +#include +#include +#include + +#include "assert.h" +#include "assert_common.h" + +#define TIZEN_FEATURE_SCREEN "http://tizen.org/feature/screen" + +static const char *g_app_id = "org.example.componentbased"; +static const char *g_frame_comp_id = "frame_comp_test"; +static const char *g_service_comp_id = "service_comp_test"; +static const char *g_extra_key = "component_utc_func"; + +void utc_component_based_application_startup(void) +{ +} + +void utc_component_based_application_cleanup(void) +{ +} + +static int __app_control_send(const char *app_id, const char *component_id, + const char *extra_data) +{ + app_control_h handle = NULL; + app_control_h reply; + app_control_result_e result = APP_CONTROL_RESULT_FAILED; + int ret; + + ret = app_control_create(&handle); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create app control"); + return -1; + } + + ret = app_control_set_app_id(handle, app_id); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set application ID"); + goto end; + } + + if (component_id) { + ret = app_control_set_component_id(handle, component_id); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, + "Failed to set component ID"); + goto end; + } + } + + if (extra_data) { + ret = app_control_add_extra_data(handle, g_extra_key, extra_data); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, + "Failed to add extra data"); + goto end; + } + } + + ret = app_control_send_launch_request_sync(handle, + &reply, &result); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, + "Failed to send launch request async"); + } + +end: + if (handle) + app_control_destroy(handle); + + return result; +} + +static void result_cb(app_control_h h, app_control_error_e result, void *user_data) +{ + dlog_print(DLOG_INFO, LOG_TAG, "reult_cb result[%d]", result); +} + +static void reply_cb(app_control_h req, + app_control_h reply, app_control_error_e result, void *user_data) +{ + dlog_print(DLOG_INFO, LOG_TAG, "reply_cb result[%d]", result); + + if (result == APP_CONTROL_RESULT_SUCCEEDED) + normal_exit(0); + else + normal_exit(1); +} + +static int __app_control_send_async(const char *app_id, const char *component_id, + const char *extra_data) +{ + app_control_h handle = NULL; + int ret; + + dlog_print(DLOG_ERROR, LOG_TAG, " app control async"); + ret = app_control_create(&handle); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create app control"); + return -1; + } + + ret = app_control_set_app_id(handle, app_id); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set application ID"); + goto end; + } + + if (component_id) { + ret = app_control_set_component_id(handle, component_id); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, + "Failed to set component ID"); + goto end; + } + } + + ret = app_control_add_extra_data(handle, g_extra_key, extra_data); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, + "Failed to add extra data"); + goto end; + } + + ret = app_control_send_launch_request_async(handle, + result_cb, reply_cb, NULL); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, + "Failed to send launch request async"); + } + +end: + if (handle) + app_control_destroy(handle); + + return ret; +} + +static Evas_Object* __frame_component_create_cb( + component_h context, + void *user_data) +{ + return NULL; +} + +static void __frame_component_start_cb( + component_h context, + app_control_h app_control, + bool restarted, + void *user_data) +{ +} + +static void __frame_component_resume_cb( + component_h context, + void *user_data) +{ +} + +static void __frame_component_pause_cb( + component_h context, + void *user_data) +{ +} + +static void __frame_component_stop_cb( + component_h context, + void *user_data) +{ +} + +static void __frame_component_destroy_cb( + component_h context, + void *user_data) +{ +} + +static void __frame_component_restore_content_cb( + component_h context, + bundle *content, + void *user_data) +{ +} + +static void __frame_component_save_content_cb( + component_h context, + bundle *content, + void *user_data) +{ +} + +static void __frame_component_action_cb(component_h context, + const char *action, app_control_h app_control, + void *user_data) +{ +} + +static void __frame_component_device_orientation_changed_cb( + component_h context, + component_device_orientation_e orientation, + void *user_data) +{ +} + +static void __frame_component_language_changed_cb( + component_h context, + const char *language, + void *user_data) +{ +} + +static void __frame_component_region_format_changed_cb( + component_h context, + const char *region, + void *user_data) +{ +} + +static void __frame_component_low_battery_cb( + component_h context, + component_low_battery_status_e status, + void *user_data) +{ +} + +static void __frame_component_low_memory_cb( + component_h context, + component_low_memory_status_e status, + void *user_data) +{ +} + +static void __frame_component_suspended_state_changed_cb( + component_h context, + component_suspended_state_e state, + void *user_data) +{ +} + +static bool __service_component_create_cb( + component_h context, + void *user_data) +{ + return false; +} + +static void __service_component_start_command_cb( + component_h context, + app_control_h app_control, + bool restarted, + void *user_data) +{ +} + +static void __service_component_destroy_cb( + component_h context, + void *user_data) +{ +} + +static void __service_component_save_content_cb( + component_h context, + bundle *content, + void *user_data) +{ +} + +static void __service_component_action_cb(component_h context, + const char *action, app_control_h app_control, + void *user_data) +{ +} + +static void __service_component_device_orientation_changed_cb( + component_h context, + component_device_orientation_e orientation, + void *user_data) +{ +} + +static void __service_component_language_changed_cb( + component_h context, + const char *language, + void *user_data) +{ +} + +static void __service_component_region_format_changed_cb( + component_h context, + const char *region, + void *user_data) +{ +} + +static void __service_component_low_battery_cb( + component_h context, + component_low_battery_status_e status, + void *user_data) +{ +} + +static void __service_component_low_memory_cb( + component_h context, + component_low_memory_status_e status, + void *user_data) +{ +} + +static void __service_component_suspended_state_changed_cb( + component_h context, + component_suspended_state_e state, + void *user_data) +{ +} + +/** + * @testcase utc_component_based_app_main_p + * @since_tizen 5.5 + * @description Run component based application with arguments. + */ +int utc_component_based_app_main_p(void) +{ + int ret; + + ret = __app_control_send(g_app_id, g_service_comp_id, + "utc_component_based_app_main"); + assert_eq_with_exit(ret, APP_CONTROL_RESULT_SUCCEEDED); + + normal_exit(0); + return 0; +} + +/** + * @testcase utc_component_based_app_main_n + * @since_tizen 5.5 + * @description Run component based application with invalid parameter. + */ +int utc_component_based_app_main_n(void) +{ + int ret; + + ret = component_based_app_main(0, NULL, NULL, NULL); + assert_eq_without_exit(ret, APP_ERROR_INVALID_PARAMETER); + + normal_exit(0); + return 0; +} + +/** + * @testcase utc_component_based_app_add_frame_component_p + * @since_tizen 5.5 + * @description Adds frame component to component based application with arguments. + */ +int utc_component_based_app_add_frame_component_p(void) +{ + component_class_h comp = NULL; + const char *comp_id = "frame_comp_test"; + + frame_component_lifecycle_callback_s cb = { + .create = __frame_component_create_cb, + .start = __frame_component_start_cb, + .resume = __frame_component_resume_cb, + .pause = __frame_component_pause_cb, + .stop = __frame_component_stop_cb, + .destroy = __frame_component_destroy_cb, + .restore_content = __frame_component_restore_content_cb, + .save_content = __frame_component_save_content_cb, + .action = __frame_component_action_cb, + .device_orientation_changed = __frame_component_device_orientation_changed_cb, + .language_changed = __frame_component_language_changed_cb, + .region_format_changed = __frame_component_region_format_changed_cb, + .low_battery = __frame_component_low_battery_cb, + .low_memory = __frame_component_low_memory_cb, + .suspended_state_changed = __frame_component_suspended_state_changed_cb + }; + + comp = component_based_app_add_frame_component(comp, comp_id, &cb, NULL); + assert_with_exit(comp != NULL); + assert_with_exit(get_last_result() == APP_ERROR_NONE); + + normal_exit(0); + return 0; +} + +/** + * @testcase utc_component_based_app_add_frame_component_n + * @since_tizen 5.5 + * @description Adds frame component to component based application with invalid parameter. + */ +int utc_component_based_app_add_frame_component_n(void) +{ + component_class_h comp = NULL; + const char *comp_id = "frame_comp_test"; + + comp = component_based_app_add_frame_component(comp, comp_id, NULL, NULL); + assert_with_exit(get_last_result() == APP_ERROR_INVALID_PARAMETER); + + normal_exit(0); + return 0; +} + +/** + * @testcase utc_component_based_app_add_service_component_p + * @since_tizen 5.5 + * @description Adds service component to component based application with arguments. + */ +int utc_component_based_app_add_service_component_p(void) +{ + component_class_h comp = NULL; + const char *comp_id = "service_comp_test"; + + service_component_lifecycle_callback_s cb = { + .create = __service_component_create_cb, + .start_command = __service_component_start_command_cb, + .destroy = __service_component_destroy_cb, + .save_content = __service_component_save_content_cb, + .action = __service_component_action_cb, + .device_orientation_changed = __service_component_device_orientation_changed_cb, + .language_changed = __service_component_language_changed_cb, + .region_format_changed = __service_component_region_format_changed_cb, + .low_battery = __service_component_low_battery_cb, + .low_memory = __service_component_low_memory_cb, + .suspended_state_changed = __service_component_suspended_state_changed_cb + }; + + comp = component_based_app_add_service_component(comp, comp_id, &cb, NULL); + assert_with_exit(comp != NULL); + assert_with_exit(get_last_result() == APP_ERROR_NONE); + + normal_exit(0); + return 0; +} + +/** + * @testcase utc_component_based_app_add_service_component_n + * @since_tizen 5.5 + * @description Adds service component to component based application with invalid parameter. + */ +int utc_component_based_app_add_service_component_n(void) +{ + component_class_h comp = NULL; + const char *comp_id = "service_comp_test"; + + comp = component_based_app_add_service_component(comp, comp_id, NULL, NULL); + assert_with_exit(get_last_result() == APP_ERROR_INVALID_PARAMETER); + + normal_exit(0); + return 0; +} + + +/** + * @testcase utc_frame_component_get_display_status_p + * @since_tizen 5.5 + * @description Gets the display status of frame component. + */ +int utc_frame_component_get_display_status_p(void) +{ + int ret; + bool is_screen = false; + + /* For IOT headless */ + system_info_get_platform_bool(TIZEN_FEATURE_SCREEN, &is_screen); + dlog_print(DLOG_INFO, "NativeTCT", "%d", is_screen); + if (!is_screen) { + normal_exit(0); + return 0; + } + + ret = __app_control_send_async(g_app_id, g_frame_comp_id, + "utc_frame_component_get_display_status"); + assert_eq_with_exit(ret, APP_CONTROL_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_frame_component_get_display_status_n + * @since_tizen 5.5 + * @description Gets the display status of frame component with invalid parameter. + */ +int utc_frame_component_get_display_status_n(void) +{ + int ret; + component_display_status_e display; + + ret = frame_component_get_display_status(NULL, &display); + assert_eq_with_exit(ret, COMPONENT_ERROR_INVALID_PARAMETER); + + normal_exit(0); + return 0; +} + +/** + * @testcase utc_frame_component_get_window_p + * @since_tizen 5.5 + * @description Gets the window of frame component. + */ +int utc_frame_component_get_window_p(void) +{ + int ret; + bool is_screen = false; + + /* For IOT headless */ + system_info_get_platform_bool(TIZEN_FEATURE_SCREEN, &is_screen); + dlog_print(DLOG_INFO, "NativeTCT", "%d", is_screen); + if (!is_screen) { + normal_exit(0); + return 0; + } + + ret = __app_control_send(g_app_id, g_frame_comp_id, + "utc_frame_component_get_window"); + assert_eq_with_exit(ret, APP_CONTROL_RESULT_SUCCEEDED); + + normal_exit(0); + return 0; +} + +/** + * @testcase utc_frame_component_get_window_n + * @since_tizen 5.5 + * @description Gets the window of frame component with invalid parameter. + */ +int utc_frame_component_get_window_n(void) +{ + int ret; + Evas_Object *window; + + ret = frame_component_get_window(NULL, &window); + assert_eq_with_exit(ret, COMPONENT_ERROR_INVALID_PARAMETER); + + normal_exit(0); + return 0; +} + +/** + * @testcase utc_component_based_app_exit_p + * @since_tizen 5.5 + * @description Exit component based application. + */ +int utc_component_based_app_exit_p(void) +{ + int ret; + bool running; + + ret = __app_control_send_async(g_app_id, g_service_comp_id, + "utc_component_based_app_exit"); + assert_eq_with_exit(ret, APP_CONTROL_RESULT_SUCCEEDED); + + sleep(5); + + ret = component_manager_is_running(g_service_comp_id, &running); + assert_eq_with_exit(running, false); + + normal_exit(0); + return 0; +} diff --git a/src/utc/component-based-application/utc-component-common.c b/src/utc/component-based-application/utc-component-common.c new file mode 100644 index 000000000..73f0d06c8 --- /dev/null +++ b/src/utc/component-based-application/utc-component-common.c @@ -0,0 +1,280 @@ +// +// Copyright (c) 2019 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. +// + +#include +#include +#include +#include + +#include "assert.h" +#include "assert_common.h" + + +static const char *g_app_id = "org.example.componentbased"; +static const char *g_service_comp_id = "service_comp_test"; +static const char *g_extra_key = "component_utc_func"; + +static int __app_control_send(const char *app_id, const char *component_id, + const char *extra_data) +{ + app_control_h handle = NULL; + app_control_h reply; + app_control_result_e result = APP_CONTROL_RESULT_FAILED; + int ret; + + ret = app_control_create(&handle); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create app control"); + return -1; + } + + ret = app_control_set_app_id(handle, app_id); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set application ID"); + goto end; + } + + if (component_id) { + ret = app_control_set_component_id(handle, component_id); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, + "Failed to set component ID"); + goto end; + } + } + + ret = app_control_add_extra_data(handle, g_extra_key, extra_data); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, + "Failed to add extra data"); + goto end; + } + + ret = app_control_send_launch_request_sync(handle, + &reply, &result); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, + "Failed to send launch request sync"); + } + +end: + if (handle) + app_control_destroy(handle); + + return result; +} + +/** + * @testcase utc_component_get_id_p + * @since_tizen 5.5 + * @description Get component id. + */ +int utc_component_get_id_p(void) +{ + int ret; + + ret = __app_control_send(g_app_id, g_service_comp_id, + "utc_component_get_id"); + assert_eq_with_exit(ret, APP_CONTROL_RESULT_SUCCEEDED); + + normal_exit(0); + return 0; +} + +/** + * @testcase utc_component_get_id_n + * @since_tizen 5.5 + * @description Get component id with invalid parameter. + */ +int utc_component_get_id_n(void) +{ + int ret; + char *id; + + ret = component_get_id(NULL, &id); + assert_eq_with_exit(ret, COMPONENT_ERROR_INVALID_PARAMETER); + + normal_exit(0); + return 0; +} + +/** + * @testcase utc_component_get_instance_id_p + * @since_tizen 5.5 + * @description Get component instance id. + */ +int utc_component_get_instance_id_p(void) +{ + int ret; + + ret = __app_control_send(g_app_id, g_service_comp_id, + "utc_component_get_instance_id"); + assert_eq_with_exit(ret, APP_CONTROL_RESULT_SUCCEEDED); + + normal_exit(0); + return 0; +} + +/** + * @testcase utc_component_get_instance_id_n + * @since_tizen 5.5 + * @description Get component instance id with invalid parameter. + */ +int utc_component_get_instance_id_n(void) +{ + int ret; + char *id; + + ret = component_get_instance_id(NULL, &id); + assert_eq_with_exit(ret, COMPONENT_ERROR_INVALID_PARAMETER); + + normal_exit(0); + return 0; +} + +/** + * @testcase utc_component_register_action_p + * @since_tizen 5.5 + * @description Register appcontrol action. + */ +int utc_component_register_action_p(void) +{ + int ret; + + ret = __app_control_send(g_app_id, g_service_comp_id, + "utc_component_register_action"); + assert_eq_with_exit(ret, APP_CONTROL_RESULT_SUCCEEDED); + + normal_exit(0); + return 0; +} + +/** + * @testcase utc_component_register_action_n + * @since_tizen 5.5 + * @description Register appcontrol action with invalid parameter. + */ +int utc_component_register_action_n(void) +{ + int ret; + const char *action = "action"; + + ret = component_register_action(NULL, action); + assert_eq_with_exit(ret, COMPONENT_ERROR_INVALID_PARAMETER); + + normal_exit(0); + return 0; +} + +/** + * @testcase utc_component_deregister_action_p + * @since_tizen 5.5 + * @description Deregister appcontrol action. + */ +int utc_component_deregister_action_p(void) +{ + int ret; + + ret = __app_control_send(g_app_id, g_service_comp_id, + "utc_component_deregister_action"); + assert_eq_with_exit(ret, APP_CONTROL_RESULT_SUCCEEDED); + + normal_exit(0); + return 0; +} + +/** + * @testcase utc_component_deregister_action_n + * @since_tizen 5.5 + * @description Deregister appcontrol action with invalid parameter. + */ +int utc_component_deregister_action_n(void) +{ + int ret; + const char *action = "action"; + + ret = component_deregister_action(NULL, action); + assert_eq_with_exit(ret, COMPONENT_ERROR_INVALID_PARAMETER); + + normal_exit(0); + return 0; +} + +/** + * @testcase utc_component_send_launch_request_sync_p + * @since_tizen 5.5 + * @description Sends the launch request synchronously. + */ +int utc_component_send_launch_request_sync_p(void) +{ + int ret; + + ret = __app_control_send(g_app_id, g_service_comp_id, + "utc_component_launch_sync"); + assert_eq_with_exit(ret, APP_CONTROL_RESULT_SUCCEEDED); + + normal_exit(0); + return 0; +} + +/** + * @testcase utc_component_send_launch_request_sync_n + * @since_tizen 5.5 + * @description Sends the launch request synchronously with invalid parameter. + */ +int utc_component_send_launch_request_sync_n(void) +{ + int ret; + + ret = component_send_launch_request_sync(NULL, NULL, NULL, NULL); + assert_eq_with_exit(ret, COMPONENT_ERROR_INVALID_PARAMETER); + + normal_exit(0); + return 0; +} + +/** + * @testcase utc_component_send_launch_request_async_p + * @since_tizen 5.5 + * @description Sends the launch request asynchronously. + */ +int utc_component_send_launch_request_async_p(void) +{ + int ret; + + ret = __app_control_send(g_app_id, g_service_comp_id, + "utc_component_launch_async"); + assert_eq_with_exit(ret, APP_CONTROL_RESULT_SUCCEEDED); + + normal_exit(0); + return 0; +} + +/** + * @testcase utc_component_send_launch_request_async_n + * @since_tizen 5.5 + * @description Sends the launch request asynchronously with invalid parameter. + */ +int utc_component_send_launch_request_async_n(void) +{ + int ret; + + ret = component_send_launch_request_async(NULL, NULL, NULL, NULL, NULL); + assert_eq_with_exit(ret, COMPONENT_ERROR_INVALID_PARAMETER); + + normal_exit(0); + return 0; +}