diff options
author | Hwankyu Jhun <h.jhun@samsung.com> | 2020-09-22 15:16:59 +0900 |
---|---|---|
committer | Hwankyu Jhun <h.jhun@samsung.com> | 2020-09-25 14:04:38 +0900 |
commit | d5ef31b45f46acf1ac0a93e1e0c6680e619c6283 (patch) | |
tree | 3b01e2ff945d4dcdd27a178e512d49f3a7d91c6e | |
parent | 552d7faaed436757481319807a78b3b249f4b232 (diff) | |
download | aul-1-d5ef31b45f46acf1ac0a93e1e0c6680e619c6283.tar.gz aul-1-d5ef31b45f46acf1ac0a93e1e0c6680e619c6283.tar.bz2 aul-1-d5ef31b45f46acf1ac0a93e1e0c6680e619c6283.zip |
Remove implicit launch resolution
To improve implicit launch performance, AMD finds the matched
applications when getting the implicit launch request.
This patch adds an executable file that is app-control-tests.
We can test implicit launch using app-control-tests.
Requires:
- https://review.tizen.org/gerrit/#/c/platform/core/appfw/amd/+/244538/
Change-Id: Ib619e9b85a6cfdefef99bf7b380d3c29c1f571e9
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
30 files changed, 1164 insertions, 195 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c51f23aa..84f3d9eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,8 @@ SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Mo SET(TARGET_AUL "aul") ENABLE_TESTING() -SET(TARGET_AUL_UNIT_TEST "aul-unit-test") +SET(TARGET_AUL_UNIT_TESTS "aul-unit-tests") +SET(TARGET_APP_CONTROL_TESTS "app-control-tests") INCLUDE(FindPkgConfig) INCLUDE(ApplyPkgConfig) @@ -112,11 +113,11 @@ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/aul.pc DESTINATION ${LIB_INSTALL_DIR}/ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/feature/preexec_list.txt DESTINATION ${SHARE_INSTALL_PREFIX}/aul ) INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/miregex DESTINATION ${SHARE_INSTALL_PREFIX}/aul ) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/aul.conf DESTINATION /etc/dbus-1/system.d) -INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION include/aul/ +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION include/aul FILES_MATCHING PATTERN "*.h" ) -INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/aul/api/ DESTINATION include/aul/api/ +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/aul/api/ DESTINATION include/aul/api FILES_MATCHING PATTERN "*.h" ) diff --git a/include/aul_cmd.h b/include/aul_cmd.h index 9528c2d4..44d6b7cb 100644 --- a/include/aul_cmd.h +++ b/include/aul_cmd.h @@ -189,6 +189,8 @@ enum app_cmd { APP_GROUP_ADD = 149, APP_GROUP_REMOVE = 150, + APP_GET_APPID_LIST = 151, + APP_CMD_MAX }; diff --git a/include/aul_key.h b/include/aul_key.h index 039d0fb9..f1d237ff 100644 --- a/include/aul_key.h +++ b/include/aul_key.h @@ -783,3 +783,9 @@ * @since_tizen 6.0 */ #define AUL_K_INSERT_BEFORE_WINDOW "__K_INSERT_BEFORE_WINDOW" + +/** + * @brief Definition for AUL: The list of application ID. + * @since_tizen 6.0 + */ +#define AUL_K_APPID_LIST "__AUL_K_APPID_LIST__" diff --git a/include/aul_svc_internal.h b/include/aul_svc_internal.h index bc66f7df..b191882d 100644 --- a/include/aul_svc_internal.h +++ b/include/aul_svc_internal.h @@ -156,6 +156,50 @@ int aul_svc_info_get_mime_subtype(aul_svc_info_h h, char **mime_subtype); */ int aul_svc_info_destroy(aul_svc_info_h h); +/** + * @brief Resolves the app control. + * @since_tizen 6.0 + * @remarks The @appid_array should be released using aul_svc_free_appid_array(). + * + * @param[in] b The bundle object + * @param[in] uid The user ID + * @param[out] appid_array The array pointer of the appid + * @param[out] len The array length + * @return @c 0 on success, + * otherwise a negative error value + * @remarks This API is only for App Framework internally. + * @see aul_svc_free_appid_array() + */ +int aul_svc_resolve(bundle *b, uid_t uid, char ***appid_array, + unsigned int *len); + +/** + * @brief Gets an array of application ID. + * @since_tizen 6.0 + * @remarks The @appid_array should be released using aul_svc_free_appid_array(). + * + * @param[in] b The bundle object + * @param[in] uid The user ID + * @param[out] appid_array The array pointer of the appid + * @param[out] len The array length + * @return @c 0 on success, + * otherwise a negative error value + * @remarks This API is only for App Framework internally. + * @see aul_svc_free_appid_array() + */ +int aul_svc_get_appid_array(bundle *b, uid_t uid, char ***appid_array, + unsigned int *len); + +/** + * @brief Release an array of application ID. + * @since_tizen 6.0 + * + * @param[in] appid_array The array pointer of the appid + * @param[in] len The array length + * @remarks This API is only for App Framework internally. + */ +void aul_svc_free_appid_array(char **appid_array, unsigned int len); + #ifdef __cplusplus } #endif diff --git a/packaging/aul.spec b/packaging/aul.spec index 19e2460f..f9af71c2 100755 --- a/packaging/aul.spec +++ b/packaging/aul.spec @@ -35,6 +35,11 @@ BuildRequires: pkgconfig(uuid) BuildRequires: pkgconfig(libsmack) BuildRequires: pkgconfig(gmock) +%if 0%{?gcov:1} +BuildRequires: lcov +BuildRequires: zip +%endif + Recommends: amd Recommends: amd-mod-component-manager Recommends: amd-mod-watchdog @@ -58,18 +63,39 @@ Requires: %{name} = %{version}-%{release} %description test Application utility library (test tools) +################################################# +# aul-gcov +################################################# +%if 0%{?gcov:1} +%package gcov +Summary: AUL (gcov) +Group: Application Framework/Testing + +%description gcov +AUL gcov objects +%endif + %if "%{?_prelink_enable}" == "y" %define tizen_feature_prelink 1 %else %define tizen_feature_prelink 0 %endif +%define _aulresdir /opt/usr/home/owner/share/aul/res + %prep %setup -q sed -i 's|TZ_SYS_DB|%{TZ_SYS_DB}|g' %{SOURCE1001} cp %{SOURCE1001} . %build +%if 0%{?gcov:1} +export CFLAGS+=" -fprofile-arcs -ftest-coverage" +export CXXFLAGS+=" -fprofile-arcs -ftest-coverage" +export FFLAGS+=" -fprofile-arcs -ftest-coverage" +export LDFLAGS+=" -lgcov" +%endif + %if 0%{?simulator} CFLAGS="%{optflags} -D__emul__"; export CFLAGS %endif @@ -82,6 +108,7 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` %cmake -DFULLVER=%{version} \ -DMAJORVER=${MAJORVER} \ -D_TIZEN_FEATURE_PRELINK:BOOL=${_TIZEN_FEATURE_PRELINK} \ + -DAUL_RES_DIR=%{_aulresdir} \ . %__make %{?_smp_mflags} @@ -89,6 +116,20 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` sqlite3 .appsvc.db < ./data/appsvc_db.sql sqlite3 .component.db < ./parser/component/data/component_db.sql +%if 0%{?gcov:1} +mkdir -p gcov-obj +find . -name '*.gcno' -exec cp '{}' gcov-obj ';' +%endif + +%check +ctest --output-on-failure %{?_smp_mflags} +%if 0%{?gcov:1} +lcov -c --ignore-errors graph --no-external -q -d . -o %{name}.info +genhtml %{name}.info -o %{name}.out +zip -r %{name}.zip %{name}.out %{name}.info +install -m 0644 %{name}.zip %{buildroot}%{_datadir}/gcov/ +%endif + %install rm -rf %{buildroot} %make_install @@ -106,6 +147,11 @@ cp -R %{_builddir}/%{name}-%{version}/alias/* %{buildroot}%{_datadir}/appsvc mkdir -p %{buildroot}%{_sysconfdir}/gumd/useradd.d cp -f scripts/12_appsvc-add.post %{buildroot}%{_sysconfdir}/gumd/useradd.d/12_appsvc-add.post +%if 0%{?gcov:1} +mkdir -p %{buildroot}%{_datadir}/gcov/obj +install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj +%endif + %preun %post @@ -120,10 +166,16 @@ chmod 666 %{TZ_SYS_DB}/.component.db-journal chsmack -a 'User::Home' %{TZ_SYS_DB}/.component.db chsmack -a 'User::Home' %{TZ_SYS_DB}/.component.db-journal - %postun /sbin/ldconfig +%post test +%if 0%{?gcov:1} +%{_bindir}/aul-unit-tests +%endif +chmod +x %{_aulresdir}/tpk/install.sh +%{_aulresdir}/tpk/install.sh + %files %license LICENSE %manifest %{name}.manifest @@ -151,10 +203,21 @@ chsmack -a 'User::Home' %{TZ_SYS_DB}/.component.db-journal %attr(0755,root,root) %{_datadir}/upgrade/scripts/501.component_upgrade.sh %files test +%{_bindir}/app-control-tests +%{_bindir}/aul-unit-tests %{_bindir}/open_app +%{_aulresdir}/* %files devel %{_includedir}/aul/*.h %{_includedir}/aul/api/*.h %{_libdir}/*.so %{_libdir}/pkgconfig/*.pc + +################################################# +# aul-gcov +################################################# +%if 0%{?gcov:1} +%files gcov +%{_datadir}/gcov/* +%endif diff --git a/src/aul_cmd.c b/src/aul_cmd.c index e6a0e623..4913eaa4 100755 --- a/src/aul_cmd.c +++ b/src/aul_cmd.c @@ -191,6 +191,8 @@ API const char *aul_cmd_convert_to_string(int cmd) "APP_GROUP_ADD", "APP_GROUP_REMOVE", + "APP_GET_APPID_LIST", + "CUSTOM_COMMAND" }; diff --git a/src/service.c b/src/service.c index 6fb38f33..f9b4618b 100755 --- a/src/service.c +++ b/src/service.c @@ -32,14 +32,15 @@ #include "aul.h" #include "aul_api.h" -#include "aul_svc.h" +#include "aul_app_group.h" +#include "aul_error.h" #include "aul_sock.h" +#include "aul_svc.h" #include "aul_svc_db.h" -#include "aul_util.h" +#include "aul_svc_internal.h" #include "aul_svc_priv_key.h" +#include "aul_util.h" #include "launch.h" -#include "aul_svc_internal.h" -#include "aul_app_group.h" #define MAX_CHECKSUM_BUF 2048 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) @@ -741,93 +742,6 @@ static void __free_pkg_list(GSList *list) g_slist_free(list); } -static gchar *__make_checksum(const char *op, const char *uri, const char *mime) -{ - char buf[MAX_CHECKSUM_BUF]; - gchar *checksum; - - snprintf(buf, sizeof(buf), "%s:%s:%s", op, uri, mime); - checksum = g_compute_checksum_for_string(G_CHECKSUM_MD5, buf, -1); - - return checksum; -} - -static char *__get_cache(const char *checksum, uid_t uid) -{ - app_pkt_t *pkt = NULL; - int fd; - int ret; - bundle *b; - char buf[MAX_PID_STR_BUFSZ]; - char *appid; - - b = bundle_create(); - if (b == NULL) { - _E("out of memory"); - return NULL; - } - - snprintf(buf, sizeof(buf), "%d", uid); - bundle_add(b, AUL_K_TARGET_UID, buf); - bundle_add(b, AUL_K_CHECKSUM, checksum); - - fd = aul_sock_send_bundle(AUL_UTIL_PID, uid, APP_GET_APPID_FROM_CACHE, - b, AUL_SOCK_ASYNC); - bundle_free(b); - if (fd <= 0) - return NULL; - - ret = aul_sock_recv_reply_pkt(fd, &pkt); - if (ret < 0) - return NULL; - - if (pkt->cmd == APP_GET_APPID_FROM_CACHE) { - if (pkt->data[0] == 0) { - free(pkt); - return NULL; - } - appid = strdup((const char *)(pkt->data)); - free(pkt); - return appid; - } - free(pkt); - - return NULL; -} - -static void __put_cache(const char *checksum, const char *appid, uid_t uid) -{ - int ret; - bundle *b; - char buf[MAX_PID_STR_BUFSZ]; - - b = bundle_create(); - if (!b) { - _E("out of memory"); - return; - } - - snprintf(buf, sizeof(buf), "%d", uid); - bundle_add(b, AUL_K_TARGET_UID, buf); - bundle_add(b, AUL_K_CHECKSUM, checksum); - bundle_add(b, AUL_K_APPID, appid); - - ret = app_send_cmd_for_uid(AUL_UTIL_PID, uid, APP_SET_CACHE, b); - - if (ret < 0) - _E("Failed to set cache : %d", ret); - - bundle_free(b); -} - -static void __put_cache_with_info(const char *checksum, const char *info, uid_t uid) -{ - char buf[PATH_MAX]; - - snprintf(buf, sizeof(buf), "@APP_SELECTOR %s", info); - __put_cache(checksum, buf, uid); -} - static void __invalidate_cache(uid_t uid) { int ret; @@ -962,8 +876,8 @@ typedef struct resolution_info_s { bundle *b; uid_t uid; aul_svc_resolve_info_t ri; - gchar *checksum; - char *cache; + char **appid_array; + unsigned int len; } resolution_info_t; typedef int (*resolution_handler)(resolution_info_t *info); @@ -972,55 +886,17 @@ static int __resolution_pre(resolution_info_t *info) { aul_svc_resolve_info_t *ri = &info->ri; int ret; - size_t n; ret = __get_resolve_info(info->b, ri); - if (ret < 0) - goto err; + if (ret < 0) { + __free_resolve_info_data(ri); + return ret; + } SECURE_LOGD("op - %s / mime - %s / scheme - %s", ri->op, ri->origin_mime, ri->scheme); - info->checksum = __make_checksum(ri->op, ri->uri, ri->origin_mime); - info->cache = __get_cache(info->checksum, info->uid); - if (info->cache) { - _D("Hit! %s / %s", info->checksum, info->cache); - n = strlen("@APP_SELECTOR "); - if (!strncmp("@APP_SELECTOR ", info->cache, n)) { - bundle_add(info->b, AUL_SVC_K_URI_R_INFO, - &info->cache[n]); - info->appid = strdup(APP_SELECTOR); - if (info->appid == NULL) { - _E("Out of memory"); - ret = AUL_SVC_RET_ERROR; - goto err; - } - } else if (!strcmp(info->cache, "^")) { - ret = AUL_SVC_RET_ENOMATCH; - goto err; - } else { - info->appid = info->cache; - } - - return AUL_SVC_RET_OK; - } - return AUL_SVC_RET_OK; - -err: - if (info->cache) { - free(info->cache); - info->cache = NULL; - } - - if (info->checksum) { - g_free(info->checksum); - info->checksum = NULL; - } - - __free_resolve_info_data(ri); - - return ret; } static int __resolution_uri(resolution_info_t *info) @@ -1029,12 +905,12 @@ static int __resolution_uri(resolution_info_t *info) char *id; char *query; - if (info->appid || info->list) + if (info->list) return AUL_SVC_RET_OK; id = _svc_db_get_app(ri->op, ri->origin_mime, ri->uri, info->uid); if (id) { - info->appid = id; + info->list = g_slist_append(info->list, strdup(id)); return AUL_SVC_RET_OK; } @@ -1072,8 +948,10 @@ static int __resolution_uri(resolution_info_t *info) __get_list_with_category(ri->category, &info->list, info->uid); __get_list_with_submode(ri->op, ri->win_id, &info->list, info->uid); - if (g_slist_length(info->list) > 1) + if (g_slist_length(info->list) > 1) { + _E("uri_r_info: %s, uri: %s", info->uri_r_info, ri->uri); info->uri_r_info = ri->uri; + } return AUL_SVC_RET_OK; } @@ -1084,7 +962,7 @@ static int __resolution_scheme_and_host(resolution_info_t *info) char *id; char *query = NULL; - if (info->appid || info->list) + if (info->list) return AUL_SVC_RET_OK; if (!ri->uri_r_info) @@ -1093,7 +971,7 @@ static int __resolution_scheme_and_host(resolution_info_t *info) id = _svc_db_get_app(ri->op, ri->origin_mime, ri->uri_r_info, info->uid); if (id) { - info->appid = id; + info->list = g_slist_append(info->list, strdup(id)); return AUL_SVC_RET_OK; } @@ -1124,8 +1002,11 @@ static int __resolution_scheme_and_host(resolution_info_t *info) __get_list_with_category(ri->category, &info->list, info->uid); __get_list_with_submode(ri->op, ri->win_id, &info->list, info->uid); - if (g_slist_length(info->list) > 1) + if (g_slist_length(info->list) > 1) { + _E("uri_r_info: %s, uri_r_info: %s", + info->uri_r_info, info->uri_r_info); info->uri_r_info = ri->uri_r_info; + } return AUL_SVC_RET_OK; } @@ -1136,12 +1017,12 @@ static int __resolution_scheme(resolution_info_t *info) char *id; char *query = NULL; - if (info->appid || info->list) + if (info->list) return AUL_SVC_RET_OK; id = _svc_db_get_app(ri->op, ri->origin_mime, ri->scheme, info->uid); if (id) { - info->appid = id; + info->list = g_slist_append(info->list, strdup(id)); return AUL_SVC_RET_OK; } @@ -1162,54 +1043,44 @@ static int __resolution_scheme(resolution_info_t *info) __get_list_with_category(ri->category, &info->list, info->uid); __get_list_with_submode(ri->op, ri->win_id, &info->list, info->uid); - if (g_slist_length(info->list) > 1) + if (g_slist_length(info->list) > 1) { + _E("uri_r_info: %s, scheme: %s", info->uri_r_info, ri->scheme); info->uri_r_info = ri->scheme; + } return AUL_SVC_RET_OK; } static int __resolution_post(resolution_info_t *info) { + GSList *iter; int ret = AUL_SVC_RET_OK; int count; - - if (info->appid) { - __put_cache(info->checksum, info->appid, info->uid); - goto end; - } + int i = 0; count = g_slist_length(info->list); _D("count: %d", count); - if (count == 1) { - info->appid = strdup((const char *)info->list->data); - if (info->appid == NULL) { - _E("Out of memory"); - ret = AUL_SVC_RET_ERROR; - goto end; - } - __put_cache(info->checksum, info->appid, info->uid); - } else if (count < 1) { - __put_cache(info->checksum, "^", info->uid); + if (count < 1) { ret = AUL_SVC_RET_ENOMATCH; } else { + _E("uri_r_info: %s", info->uri_r_info); bundle_add(info->b, AUL_SVC_K_URI_R_INFO, info->uri_r_info); - __put_cache_with_info(info->checksum, info->uri_r_info, - info->uid); - info->appid = strdup(APP_SELECTOR); - if (info->appid == NULL) { - _E("Out of memory"); - ret = AUL_SVC_RET_ERROR; + info->len = count; + info->appid_array = calloc(info->len, sizeof(char *)); + iter = info->list; + while (iter) { + info->appid_array[i++] = strdup((char *)iter->data); + iter = g_slist_next(iter); } } -end: __free_pkg_list(info->list); __free_resolve_info_data(&info->ri); - g_free(info->checksum); return ret; } -static int __get_appid(bundle *b, uid_t uid, char **appid) +API int aul_svc_resolve(bundle *b, uid_t uid, char ***appid_array, + unsigned int *len) { static const resolution_handler handlers[] = { __resolution_pre, @@ -1224,7 +1095,7 @@ static int __get_appid(bundle *b, uid_t uid, char **appid) int ret; int i; - if (b == NULL || appid == NULL) { + if (b == NULL || appid_array == NULL || len == NULL) { _E("Invalid parameter"); return AUL_SVC_RET_EINVAL; } @@ -1234,11 +1105,9 @@ static int __get_appid(bundle *b, uid_t uid, char **appid) if (id) { if (!op) aul_svc_set_operation(b, AUL_SVC_OPERATION_DEFAULT); - *appid = strdup(id); - if (*appid == NULL) { - _E("Out of memory"); - return AUL_SVC_RET_ERROR; - } + *appid_array = calloc(1, sizeof(char *)); + (*appid_array)[0] = strdup(id); + *len = 1; return AUL_SVC_RET_OK; } @@ -1246,11 +1115,9 @@ static int __get_appid(bundle *b, uid_t uid, char **appid) (op && (!strcmp(op, AUL_SVC_OPERATION_SHARE) || !strcmp(op, AUL_SVC_OPERATION_MULTI_SHARE) || !strcmp(op, AUL_SVC_OPERATION_SHARE_TEXT)))) { - *appid = strdup(SHARE_PANEL); - if (*appid == NULL) { - _E("Out of memory"); - return AUL_SVC_RET_ERROR; - } + *appid_array = calloc(1, sizeof(char *)); + (*appid_array)[0] = strdup(SHARE_PANEL); + *len = 1; return AUL_SVC_RET_OK; } @@ -1265,8 +1132,45 @@ static int __get_appid(bundle *b, uid_t uid, char **appid) } } - *appid = info.appid; + *appid_array = info.appid_array; + *len = info.len; + + return AUL_SVC_RET_OK; +} + +static int __get_appid(bundle *b, char **appid) +{ + const char *operation; + const char *pkgname; + char *app_id; + + if (!b || !appid) { + _E("Invalid parameter"); + return AUL_SVC_RET_EINVAL; + } + + operation = aul_svc_get_operation(b); + pkgname = aul_svc_get_pkgname(b); + if (!operation && !pkgname) { + _E("Invalid request"); + return AUL_SVC_RET_EINVAL; + } + + if (pkgname) { + if (!operation) + aul_svc_set_operation(b, AUL_SVC_OPERATION_DEFAULT); + app_id = strdup(pkgname); + } else { + app_id = strdup("@UNKNOWN"); + } + + if (!app_id) { + _E("Out of memory"); + return AUL_SVC_RET_ERROR; + } + + *appid = app_id; return AUL_SVC_RET_OK; } @@ -1277,7 +1181,7 @@ static int __run_service(bundle *b, int request_code, char *appid = NULL; int ret; - ret = __get_appid(b, uid, &appid); + ret = __get_appid(b, &appid); if (ret != AUL_SVC_RET_OK) { _E("Failed to get appid"); return ret; @@ -1965,7 +1869,7 @@ API int aul_svc_send_launch_request_sync_for_uid(bundle *b, int request_code, char *appid = NULL; int ret; - ret = __get_appid(b, uid, &appid); + ret = __get_appid(b, &appid); if (ret != AUL_SVC_RET_OK) { _E("Failed to find appid"); return ret; @@ -2256,7 +2160,7 @@ API int aul_svc_send_resume_request_for_uid(bundle *b, int request_code, return AUL_SVC_RET_EINVAL; } - ret = __get_appid(b, uid, &appid); + ret = __get_appid(b, &appid); if (ret != AUL_SVC_RET_OK) { _E("Failed to get appid"); return ret; @@ -2273,3 +2177,94 @@ API int aul_svc_send_resume_request_for_uid(bundle *b, int request_code, return ret; } + +API int aul_svc_get_appid_array(bundle *b, uid_t uid, char ***appid_array, + unsigned int *len) +{ + bundle *res_b = NULL; + app_pkt_t *pkt; + const char *str; + const char **str_arr; + int arr_len = 0; + int ret; + int fd; + int i; + + if (!b || !appid_array || !len) { + _E("Invalid parameter"); + return AUL_SVC_RET_EINVAL; + } + + str = bundle_get_val(b, AUL_K_APPID); + if (str && !strcmp(str, "@UNKNOWN")) { + *appid_array = calloc(1, sizeof(char *)); + (*appid_array)[0] = strdup(str); + *len = 1; + return AUL_SVC_RET_OK; + } + + bundle_del(b, AUL_K_APPID); + bundle_add(b, AUL_K_APPID, "@UNKNOWN"); + + fd = aul_sock_send_bundle(AUL_UTIL_PID, uid, APP_GET_APPID_LIST, + b, AUL_SOCK_ASYNC); + if (fd < 0) + return __error_convert(aul_error_convert(fd)); + + ret = aul_sock_recv_reply_pkt(fd, &pkt); + if (ret < 0) + return __error_convert(aul_error_convert(ret)); + + if (pkt->cmd != APP_GET_APPID_LIST) { + ret = pkt->cmd; + _E("Error(%d) occurs", ret); + free(pkt); + return __error_convert(aul_error_convert(ret)); + } + + if (pkt->opt & AUL_SOCK_BUNDLE) + res_b = bundle_decode(pkt->data, pkt->len); + + free(pkt); + + if (!res_b) { + _E("result bundle is nullptr"); + return AUL_SVC_RET_ERROR; + } + + str = bundle_get_val(res_b, AUL_SVC_K_URI_R_INFO); + if (str) { + bundle_del(b, AUL_SVC_K_URI_R_INFO); + bundle_add(b, AUL_SVC_K_URI_R_INFO, str); + } + + str_arr = bundle_get_str_array(res_b, AUL_K_APPID_LIST, &arr_len); + if (!str_arr) { + _E("Failed to get appid list. str_arr(%p), arr_len(%d)", + str_arr, arr_len); + bundle_free(res_b); + return AUL_SVC_RET_ERROR; + } + + *len = arr_len; + *appid_array = calloc(arr_len, sizeof(char *)); + for (i = 0; i < arr_len; ++i) + (*appid_array)[i] = strdup(str_arr[i]); + + bundle_free(res_b); + + return AUL_SVC_RET_OK; +} + +API void aul_svc_free_appid_array(char **appid_array, unsigned int len) +{ + unsigned int i; + + if (!appid_array) + return; + + for (i = 0; i < len; ++i) + free(appid_array[i]); + + free(appid_array); +} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c90fac83..db120982 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1 +1,2 @@ ADD_SUBDIRECTORY(unit_tests) +ADD_SUBDIRECTORY(app_control_tests) diff --git a/test/app_control_tests/CMakeLists.txt b/test/app_control_tests/CMakeLists.txt new file mode 100644 index 00000000..e5ac85fd --- /dev/null +++ b/test/app_control_tests/CMakeLists.txt @@ -0,0 +1,28 @@ +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/ APP_CONTROL_TESTS_SRCS) +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/mock/ APP_CONTROL_TESTS_SRCS) + +ADD_EXECUTABLE(${TARGET_APP_CONTROL_TESTS} + ${APP_CONTROL_TESTS_SRCS}) + +TARGET_INCLUDE_DIRECTORIES(${TARGET_APP_CONTROL_TESTS} PUBLIC + "${CMAKE_CURRENT_SOURCE_DIR}/mock" + "${CMAKE_CURRENT_SOURCE_DIR}/../" + "${CMAKE_CURRENT_SOURCE_DIR}/../../include" + "${CMAKE_CURRENT_SOURCE_DIR}/../../src" +) + +APPLY_PKG_CONFIG(${TARGET_APP_CONTROL_TESTS} PUBLIC + BUNDLE_DEPS + DLOG_DEPS + GLIB_DEPS + GMOCK_DEPS +) + +TARGET_LINK_LIBRARIES(${TARGET_APP_CONTROL_TESTS} PUBLIC ${TARGET_AUL}) +SET_TARGET_PROPERTIES(${TARGET_APP_CONTROL_TESTS} PROPERTIES COMPILE_FLAGS "-fPIE") +SET_TARGET_PROPERTIES(${TARGET_APP_CONTROL_TESTS} PROPERTIES LINK_FLAGS "-pie") + +INSTALL(TARGETS ${TARGET_APP_CONTROL_TESTS} DESTINATION bin) + +INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/res DESTINATION + ${AUL_RES_DIR}/../) diff --git a/test/app_control_tests/main.cc b/test/app_control_tests/main.cc new file mode 100644 index 00000000..3457f0f4 --- /dev/null +++ b/test/app_control_tests/main.cc @@ -0,0 +1,25 @@ +// Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved +// Use of this source code is governed by a apache 2.0 license that can be +// found in the LICENSE file. + +#include <gtest/gtest.h> +#include <gmock/gmock.h> + +int main(int argc, char** argv) { + try { + testing::InitGoogleTest(&argc, argv); + } catch (...) { + std::cout << "Exception occurred" << std::endl; + } + + int ret; + try { + ret = RUN_ALL_TESTS(); + } catch (const ::testing::internal::GoogleTestFailureException& e) { + ret = -1; + std::cout << "GoogleTestFailureException was thrown:" << e.what() + << std::endl; + } + + return ret; +} diff --git a/test/app_control_tests/mock/mock_hook.h b/test/app_control_tests/mock/mock_hook.h new file mode 100644 index 00000000..6d0de033 --- /dev/null +++ b/test/app_control_tests/mock/mock_hook.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2020 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 APP_CONTROL_TESTS_MOCK_MOCK_HOOK_H_ +#define APP_CONTROL_TESTS_MOCK_MOCK_HOOK_H_ + +#define MOCK_HOOK_P0(MOCK_CLASS, f) \ + TestFixture::GetMock<MOCK_CLASS>().f() + +#define MOCK_HOOK_P1(MOCK_CLASS, f, p1) \ + TestFixture::GetMock<MOCK_CLASS>().f(p1) + +#define MOCK_HOOK_P2(MOCK_CLASS, f, p1, p2) \ + TestFixture::GetMock<MOCK_CLASS>().f(p1, p2) + +#define MOCK_HOOK_P3(MOCK_CLASS, f, p1, p2, p3) \ + TestFixture::GetMock<MOCK_CLASS>().f(p1, p2, p3) + +#define MOCK_HOOK_P4(MOCK_CLASS, f, p1, p2, p3, p4) \ + TestFixture::GetMock<MOCK_CLASS>().f(p1, p2, p3, p4) + +#define MOCK_HOOK_P5(MOCK_CLASS, f, p1, p2, p3, p4, p5) \ + TestFixture::GetMock<MOCK_CLASS>().f(p1, p2, p3, p4, p5) + +#define MOCK_HOOK_P6(MOCK_CLASS, f, p1, p2, p3, p4, p5, p6) \ + TestFixture::GetMock<MOCK_CLASS>().f(p1, p2, p3, p4, p5, p6) + +#define MOCK_HOOK_P7(MOCK_CLASS, f, p1, p2, p3, p4, p5, p6, p7) \ + TestFixture::GetMock<MOCK_CLASS>().f(p1, p2, p3, p4, p5, p6, p7) + +#define MOCK_HOOK_P8(MOCK_CLASS, f, p1, p2, p3, p4, p5, p6, p7, p8) \ + TestFixture::GetMock<MOCK_CLASS>().f(p1, p2, p3, p4, p5, p6, p7, p8) + +#define MOCK_HOOK_P10(MOCK_CLASS, f, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) \ + TestFixture::GetMock<MOCK_CLASS>().f( \ + p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) + +#endif // APP_CONTROL_TESTS_MOCK_MOCK_HOOK_H_ diff --git a/test/app_control_tests/mock/module_mock.h b/test/app_control_tests/mock/module_mock.h new file mode 100644 index 00000000..0a7f226b --- /dev/null +++ b/test/app_control_tests/mock/module_mock.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2020 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 APP_CONTROL_TESTS_MOCK_MODULE_MOCK_H_ +#define APP_CONTROL_TESTS_MOCK_MODULE_MOCK_H_ + +class ModuleMock { + public: + virtual ~ModuleMock() {} +}; + +#endif // APP_CONTROL_TESTS_MOCK_MODULE_MOCK_H_ diff --git a/test/app_control_tests/mock/test_fixture.cc b/test/app_control_tests/mock/test_fixture.cc new file mode 100644 index 00000000..6b068e47 --- /dev/null +++ b/test/app_control_tests/mock/test_fixture.cc @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2020 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 "app_control_tests/mock/test_fixture.h" + +#include <memory> + +std::unique_ptr<ModuleMock> TestFixture::mock_; diff --git a/test/app_control_tests/mock/test_fixture.h b/test/app_control_tests/mock/test_fixture.h new file mode 100644 index 00000000..0197a0d8 --- /dev/null +++ b/test/app_control_tests/mock/test_fixture.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2020 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 APP_CONTROL_TESTS_MOCK_TEST_FIXTURE_H_ +#define APP_CONTROL_TESTS_MOCK_TEST_FIXTURE_H_ + +#include <gtest/gtest.h> + +#include <memory> +#include <stdexcept> +#include <string> +#include <utility> + +#include "app_control_tests/mock/module_mock.h" + +class TestFixture : public ::testing::Test { + public: + explicit TestFixture(std::unique_ptr<ModuleMock>&& mock) { + mock_ = std::move(mock); + } + virtual ~TestFixture() { + mock_.reset(); + } + + virtual void SetUp() {} + virtual void TearDown() {} + + template <typename T> + static T& GetMock() { + auto ptr = dynamic_cast<T*>(mock_.get()); + if (!ptr) + throw std::invalid_argument("The test does not provide mock of \"" + + std::string(typeid(T).name()) + "\""); + return *ptr; + } + + static std::unique_ptr<ModuleMock> mock_; +}; + +#endif // APP_CONTROL_TESTS_MOCK_TEST_FIXTURE_H_ diff --git a/test/app_control_tests/res/images/giraffe_800_1179.jpg b/test/app_control_tests/res/images/giraffe_800_1179.jpg Binary files differnew file mode 100644 index 00000000..fb50373e --- /dev/null +++ b/test/app_control_tests/res/images/giraffe_800_1179.jpg diff --git a/test/app_control_tests/res/images/plane_1024_768.png b/test/app_control_tests/res/images/plane_1024_768.png Binary files differnew file mode 100644 index 00000000..dc38ef7c --- /dev/null +++ b/test/app_control_tests/res/images/plane_1024_768.png diff --git a/test/app_control_tests/res/images/squee.gif b/test/app_control_tests/res/images/squee.gif Binary files differnew file mode 100644 index 00000000..bbb5dd09 --- /dev/null +++ b/test/app_control_tests/res/images/squee.gif diff --git a/test/app_control_tests/res/images/zebra_1024_680.bmp b/test/app_control_tests/res/images/zebra_1024_680.bmp Binary files differnew file mode 100644 index 00000000..a54990c3 --- /dev/null +++ b/test/app_control_tests/res/images/zebra_1024_680.bmp diff --git a/test/app_control_tests/res/sounds/SampleAAC.aac b/test/app_control_tests/res/sounds/SampleAAC.aac Binary files differnew file mode 100644 index 00000000..57e71a6e --- /dev/null +++ b/test/app_control_tests/res/sounds/SampleAAC.aac diff --git a/test/app_control_tests/res/sounds/SampleAMR.amr b/test/app_control_tests/res/sounds/SampleAMR.amr Binary files differnew file mode 100644 index 00000000..843247ea --- /dev/null +++ b/test/app_control_tests/res/sounds/SampleAMR.amr diff --git a/test/app_control_tests/res/sounds/SampleMP3.mp3 b/test/app_control_tests/res/sounds/SampleMP3.mp3 Binary files differnew file mode 100644 index 00000000..c608a70d --- /dev/null +++ b/test/app_control_tests/res/sounds/SampleMP3.mp3 diff --git a/test/app_control_tests/res/sounds/SampleWAV.wav b/test/app_control_tests/res/sounds/SampleWAV.wav Binary files differnew file mode 100644 index 00000000..d71cd064 --- /dev/null +++ b/test/app_control_tests/res/sounds/SampleWAV.wav diff --git a/test/app_control_tests/res/tpk/install.sh b/test/app_control_tests/res/tpk/install.sh new file mode 100755 index 00000000..91471180 --- /dev/null +++ b/test/app_control_tests/res/tpk/install.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +PATH_RES_TPK="/opt/usr/home/owner/share/aul/res/tpk" +TPK_LIST=`ls ${PATH_RES_TPK} | grep tpk` + +for tpk in ${TPK_LIST}; do + /usr/bin/pkgcmd -i -p ${PATH_RES_TPK}/${tpk} +done diff --git a/test/app_control_tests/res/tpk/org.tizen.example.OperationPick-1.0.0.tpk b/test/app_control_tests/res/tpk/org.tizen.example.OperationPick-1.0.0.tpk Binary files differnew file mode 100755 index 00000000..6c4ba630 --- /dev/null +++ b/test/app_control_tests/res/tpk/org.tizen.example.OperationPick-1.0.0.tpk diff --git a/test/app_control_tests/res/tpk/org.tizen.example.OperationView-1.0.0.tpk b/test/app_control_tests/res/tpk/org.tizen.example.OperationView-1.0.0.tpk Binary files differnew file mode 100755 index 00000000..95501766 --- /dev/null +++ b/test/app_control_tests/res/tpk/org.tizen.example.OperationView-1.0.0.tpk diff --git a/test/app_control_tests/res/videos/sampleH263.3gp b/test/app_control_tests/res/videos/sampleH263.3gp Binary files differnew file mode 100644 index 00000000..c0a0b39e --- /dev/null +++ b/test/app_control_tests/res/videos/sampleH263.3gp diff --git a/test/app_control_tests/res/videos/sampleH264.mp4 b/test/app_control_tests/res/videos/sampleH264.mp4 Binary files differnew file mode 100644 index 00000000..1d773f34 --- /dev/null +++ b/test/app_control_tests/res/videos/sampleH264.mp4 diff --git a/test/app_control_tests/res/videos/sampleMPEG4.mp4 b/test/app_control_tests/res/videos/sampleMPEG4.mp4 Binary files differnew file mode 100644 index 00000000..8e04bb13 --- /dev/null +++ b/test/app_control_tests/res/videos/sampleMPEG4.mp4 diff --git a/test/app_control_tests/test_app_control.cc b/test/app_control_tests/test_app_control.cc new file mode 100644 index 00000000..1ceaf754 --- /dev/null +++ b/test/app_control_tests/test_app_control.cc @@ -0,0 +1,641 @@ +/* + * Copyright (c) 2020 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 <aul_svc_internal.h> +#include <bundle_cpp.h> +#include <bundle_internal.h> +#include <gmock/gmock.h> +#include <gtest/gtest.h> +#include <stdio.h> +#include <stdlib.h> +#include <sys/types.h> +#include <unistd.h> + +#include <iostream> +#include <memory> +#include <string> + +#include "test_fixture.h" + +using ::testing::_; +using ::testing::DoAll; +using ::testing::Return; +using ::testing::SetArgPointee; +using ::testing::Invoke; + +namespace { + +std::string APP_CONTROL_OPERATION = + "http://tizen.org/appcontrol/operation"; +std::string APP_CONTROL_OPERATION_ADD = + APP_CONTROL_OPERATION + "/add"; +std::string APP_CONTROL_OPERATION_CALL = + APP_CONTROL_OPERATION + "/call"; +std::string APP_CONTROL_OPERATION_COMPOSE = + APP_CONTROL_OPERATION + "/compose"; +std::string APP_CONTROL_OPERATION_CONFIGURE_LOCATION = + APP_CONTROL_OPERATION + "/configure/location"; +std::string APP_CONTROL_OPERATION_DIAL = + APP_CONTROL_OPERATION + "/dial"; +std::string APP_CONTROL_OPERATION_DOWNLOAD = + APP_CONTROL_OPERATION + "/download"; +std::string APP_CONTROL_OPERATION_EDIT = + APP_CONTROL_OPERATION + "/edit"; +std::string APP_CONTROL_OPERATION_GET_INPUT = + APP_CONTROL_OPERATION + "/get_input"; +std::string APP_CONTROL_OPERATION_GUIDE_PRIVACY_SETTING = + APP_CONTROL_OPERATION + "/guide_privacy_setting"; +std::string APP_CONTROL_OPERATION_PICK = + APP_CONTROL_OPERATION + "/pick"; +std::string APP_CONTROL_OPERATION_READ_SCREEN = + APP_CONTROL_OPERATION + "/read_screen"; +std::string APP_CONTROL_OPERATION_SCREEN_READER_UI = + APP_CONTROL_OPERATION + "/screen_reader_ui"; +std::string APP_CONTROL_OPERATION_SETTING = + APP_CONTROL_OPERATION + "/setting"; +std::string APP_CONTROL_OPERATION_SETTING_AIRPLANE_MODE = + APP_CONTROL_OPERATION_SETTING + "/aireplane_mode"; +std::string APP_CONTROL_OPERATION_SETTING_APP_NOTIFICATIONS = + APP_CONTROL_OPERATION_SETTING + "/app_notifications"; +std::string APP_CONTROL_OPERATION_SETTING_BT_ENABLE = + APP_CONTROL_OPERATION_SETTING + "/bt_enable"; +std::string APP_CONTROL_OPERATION_SETTING_BT_VISIBILITY = + APP_CONTROL_OPERATION_SETTING + "/bt_visibility"; +std::string APP_CONTROL_OPERATION_SETTING_CALL = + APP_CONTROL_OPERATION_SETTING + "/call"; +std::string APP_CONTROL_OPERATION_SETTING_DO_NOT_DISTURB = + APP_CONTROL_OPERATION_SETTING + "/do_not_disturb"; +std::string APP_CONTROL_OPERATION_SETTING_LOCATION = + APP_CONTROL_OPERATION_SETTING + "/location"; +std::string APP_CONTROL_OPERATION_SETTING_MESSAGES = + APP_CONTROL_OPERATION_SETTING + "/messages"; +std::string APP_CONTROL_OPERATION_SETTING_MOBILE_NETWORK = + APP_CONTROL_OPERATION_SETTING + "/mobile_network"; +std::string APP_CONTROL_OPERATION_SETTING_NFC = + APP_CONTROL_OPERATION_SETTING + "/nfc"; +std::string APP_CONTROL_OPERATION_SETTING_NOTIFICATION_ON_LOCK_SCREEN = + APP_CONTROL_OPERATION_SETTING + "/notification_on_lock_screen"; +std::string APP_CONTROL_OPERATION_SETTING_VPN = + APP_CONTROL_OPERATION_SETTING + "/vpn"; +std::string APP_CONTROL_OPERATION_SHARE_TEXT = + APP_CONTROL_OPERATION + "/share_text"; +std::string APP_CONTROL_OPERATION_VIEW = + APP_CONTROL_OPERATION + "/view"; +std::string URI_FILE_AUL_RES = + "file://opt/usr/home/owner/share/aul/res/"; + +} // namespace + +class Mocks : public ::testing::NiceMock<ModuleMock> {}; + +class AppControlTest : public TestFixture { + public: + AppControlTest() : TestFixture(std::make_unique<Mocks>()) { + } + + virtual ~AppControlTest() { + } + + virtual void SetUp() { + } + + virtual void TearDown() { + } + + bool Compare(const std::string& operation, + const std::string& uri, const std::string& mime) { + tizen_base::Bundle b; + bundle* handle = b.GetHandle(); + aul_svc_set_operation(handle, operation.c_str()); + if (!uri.empty()) + aul_svc_set_uri(handle, uri.c_str()); + if (!mime.empty()) + aul_svc_set_mime(handle, mime.c_str()); + char** appid_array = nullptr; + unsigned int len = 0; + int ret1 = aul_svc_resolve(handle, getuid(), &appid_array, &len); + if (ret1 != AUL_SVC_RET_OK) + fprintf(stderr, "aul_svc_resolve() is failed. error(%d)\n", ret1); + + std::string uri_r_info1 = b.GetString(AUL_SVC_K_URI_R_INFO); + b.Delete(AUL_SVC_K_URI_R_INFO); + std::vector<std::string> result1; + result1.reserve(len); + for (unsigned int i = 0; i < len; ++i) + result1.push_back(appid_array[i]); + aul_svc_free_appid_array(appid_array, len); + + appid_array = nullptr; + len = 0; + int ret2 = aul_svc_get_appid_array(handle, getuid(), &appid_array, &len); + if (ret2 != AUL_SVC_RET_OK) + fprintf(stderr, "aul_svc_get_appid_array() is failed. error(%d)\n", ret2); + + std::string uri_r_info2 = b.GetString(AUL_SVC_K_URI_R_INFO); + std::vector<std::string> result2; + result2.reserve(len); + for (unsigned int i = 0; i < len; ++i) + result2.push_back(appid_array[i]); + aul_svc_free_appid_array(appid_array, len); + + if (ret1 != ret2) { + fprintf(stderr, "result1(%d) : result2(%d)", ret1, ret2); + return false; + } + + if (result1.size() != result2.size()) { + fprintf(stderr, "resul1.size(%u) is not equal to result2.size(%u)\n", + result1.size(), result2.size()); + return false; + } + + for (auto& str1 : result1) { + bool found = false; + for (auto& str2 : result2) { + if (str1 == str2) { + found = true; + break; + } + } + + if (found == false) { + fprintf(stderr, "%s is not found\n", str1.c_str()); + return false; + } + } + + if (uri_r_info1 != uri_r_info2) + fprintf(stderr, "%s : %s\n", uri_r_info1.c_str(), uri_r_info2.c_str()); + + return true; + } +}; + +TEST_F(AppControlTest, app_control_resolution_add_application) { + bool ret = Compare(APP_CONTROL_OPERATION_ADD, + "", "application/vnd.tizen.contact"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_call_tel) { + bool ret = Compare(APP_CONTROL_OPERATION_CALL, + "tel:+358-9-123-45678", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_compose) { + bool ret= Compare(APP_CONTROL_OPERATION_COMPOSE, "", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_compose_sms) { + bool ret= Compare(APP_CONTROL_OPERATION_COMPOSE, + "sms:+19725551212?body=hello%20there", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_compose_mmsto) { + bool ret= Compare(APP_CONTROL_OPERATION_COMPOSE, + "mmsto:addr1%2C%20addr2", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_configure_location) { + bool ret = Compare(APP_CONTROL_OPERATION_CONFIGURE_LOCATION, + "", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_dial_tel) { + bool ret = Compare(APP_CONTROL_OPERATION_DIAL, + "tel:+358-9-123-45678", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_download_http) { + bool ret = Compare(APP_CONTROL_OPERATION_DOWNLOAD, + "http://download.tizen.org/", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_download_https) { + bool ret = Compare(APP_CONTROL_OPERATION_DOWNLOAD, + "https://download.tizen.org/", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_download) { + bool ret = Compare(APP_CONTROL_OPERATION_DOWNLOAD, + "ftp://download.tizen.org/", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_edit_application) { + bool ret = Compare(APP_CONTROL_OPERATION_EDIT, + "", "application/vnd.tizen.contact"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_edit_application_on_off) { + bool ret = Compare(APP_CONTROL_OPERATION_EDIT, + "", "application/x-bluetooth-on-off"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_edit_application_visibility) { + bool ret = Compare(APP_CONTROL_OPERATION_EDIT, + "", "application/x-bluetooth-visibility"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_get_input) { + bool ret = Compare(APP_CONTROL_OPERATION_GET_INPUT, + "", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_get_input_text_plain) { + bool ret = Compare(APP_CONTROL_OPERATION_GET_INPUT, + "", "text/plain"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_get_input_audio_all) { + bool ret = Compare(APP_CONTROL_OPERATION_GET_INPUT, + "", "audio/*"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_get_input_image_all) { + bool ret = Compare(APP_CONTROL_OPERATION_GET_INPUT, + "", "image/*"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_get_input_all) { + bool ret = Compare(APP_CONTROL_OPERATION_GET_INPUT, + "", "*/*"); + EXPECT_EQ(ret, true); +} +TEST_F(AppControlTest, app_control_resolution_guide_privacy_setting) { + bool ret = Compare(APP_CONTROL_OPERATION_GUIDE_PRIVACY_SETTING, + "", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_pick_all) { + bool ret = Compare(APP_CONTROL_OPERATION_PICK, + "", "*/*"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_pick_image_all) { + bool ret = Compare(APP_CONTROL_OPERATION_PICK, + "", "image/*"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_pick_video_all) { + bool ret = Compare(APP_CONTROL_OPERATION_PICK, + "", "video/*"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_pick_audio_all) { + bool ret = Compare(APP_CONTROL_OPERATION_PICK, + "", "audio/*"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_pick_application) { + bool ret = Compare(APP_CONTROL_OPERATION_PICK, + "", "application/vnd.tizen.contact"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_pick_geo) { + bool ret = Compare(APP_CONTROL_OPERATION_PICK, + "geo:37.786971,-122.399677;u=35", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_pick_text_vcard) { + bool ret = Compare(APP_CONTROL_OPERATION_PICK, + "", "text/vcard"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_read_screen) { + bool ret = Compare(APP_CONTROL_OPERATION_READ_SCREEN, + "", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_screen_reader_ui) { + bool ret = Compare(APP_CONTROL_OPERATION_SCREEN_READER_UI, + "", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_setting) { + bool ret = Compare(APP_CONTROL_OPERATION_SETTING, + "", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_setting_airplane_mode) { + bool ret = Compare(APP_CONTROL_OPERATION_SETTING_AIRPLANE_MODE, + "", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_setting_app_notifications) { + bool ret = Compare(APP_CONTROL_OPERATION_SETTING_APP_NOTIFICATIONS, + "", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_setting_bt_enable) { + bool ret = Compare(APP_CONTROL_OPERATION_SETTING_BT_ENABLE, + "", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_setting_bt_visibility) { + bool ret = Compare(APP_CONTROL_OPERATION_SETTING_BT_VISIBILITY, + "", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_setting_call) { + bool ret = Compare(APP_CONTROL_OPERATION_SETTING_CALL, + "", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_setting_do_not_disturb) { + bool ret = Compare(APP_CONTROL_OPERATION_SETTING_DO_NOT_DISTURB, + "", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_setting_location) { + bool ret = Compare(APP_CONTROL_OPERATION_SETTING_LOCATION, + "", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_setting_messages) { + bool ret= Compare(APP_CONTROL_OPERATION_SETTING_MESSAGES, + "", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_setting_mobile_network) { + bool ret = Compare(APP_CONTROL_OPERATION_SETTING_MOBILE_NETWORK, + "", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_setting_nfc) { + bool ret = Compare(APP_CONTROL_OPERATION_SETTING_NFC, + "", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_setting_notification_on_lock_screen) { + bool ret = Compare(APP_CONTROL_OPERATION_SETTING_NOTIFICATION_ON_LOCK_SCREEN, + "", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_setting_vpn) { + bool ret = Compare(APP_CONTROL_OPERATION_SETTING_VPN, + "", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_share_text) { + bool ret= Compare(APP_CONTROL_OPERATION_SHARE_TEXT, + "", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_share_text_sms) { + bool ret= Compare(APP_CONTROL_OPERATION_SHARE_TEXT, + "sms:+19725551212?body=hello%20there", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_share_text_mmsto) { + bool ret= Compare(APP_CONTROL_OPERATION_SHARE_TEXT, + "mmsto:addr1%2C%20addr2", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_image_bmp) { + std::string uri = URI_FILE_AUL_RES + "images/zebra_1024_680.bmp"; + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + uri, "image/bmp"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_uri_bmp) { + std::string uri = URI_FILE_AUL_RES + "images/zebra_1024_680.bmp"; + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + uri, ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_image_jpeg) { + std::string uri = URI_FILE_AUL_RES + "images/giraffe_800_1179.jpg"; + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + uri, "image/jpeg"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_uri_jpeg) { + std::string uri = URI_FILE_AUL_RES + "images/giraffe_800_1179.jpg"; + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + uri, ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_image_gif) { + std::string uri = URI_FILE_AUL_RES + "images/squee.gif"; + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + uri, "image/gif"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_uri_gif) { + std::string uri = URI_FILE_AUL_RES + "images/squee.gif"; + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + uri, ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_image_png) { + std::string uri = URI_FILE_AUL_RES + "images/plane_1024_768.png"; + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + uri, "image/png"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_uri_png) { + std::string uri = URI_FILE_AUL_RES + "images/plane_1024_768.png"; + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + uri, ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_audio_aac) { + std::string uri = URI_FILE_AUL_RES + "sounds/SampleAAC.aac"; + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + uri, "audio/aac"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_uri_aac) { + std::string uri = URI_FILE_AUL_RES + "sounds/SampleAAC.aac"; + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + uri, ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_audio_amr) { + std::string uri = URI_FILE_AUL_RES + "sounds/SampleAMR.amr"; + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + uri, "audio/amr"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_uri_amr) { + std::string uri = URI_FILE_AUL_RES + "sounds/SampleAMR.amr"; + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + uri, ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_audio_mp3) { + std::string uri = URI_FILE_AUL_RES + "sounds/SampleMP3.mp3"; + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + uri, "audio/mp3"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_uri_mp3) { + std::string uri = URI_FILE_AUL_RES + "sounds/SampleMP3.mp3"; + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + uri, ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_audio_wav) { + std::string uri = URI_FILE_AUL_RES + "sounds/SampleWAV.wav"; + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + uri, "audio/wav"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_uri_wav) { + std::string uri = URI_FILE_AUL_RES + "sounds/SampleWAV.wav"; + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + uri, ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_video_3gpp) { + std::string uri = URI_FILE_AUL_RES + "videos/sampleH263.3gp"; + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + uri, "video/3gpp"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_uri_3gpp) { + std::string uri = URI_FILE_AUL_RES + "videos/sampleH263.3gp"; + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + uri, ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_video_mp4) { + std::string uri = URI_FILE_AUL_RES + "video/sampleMPEG4.mp4"; + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + uri, "video/mp4"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_uri_mp4) { + std::string uri = URI_FILE_AUL_RES + "video/sampleMPEG4.mp4"; + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + uri, ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_application_contact) { + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + "", "application/vnd.tizen.contact"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_application_number) { + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + "", "application/vnd.tizen.number"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_application_phone_log) { + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + "", "application/vnd.tizen.phone-log"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_geo) { + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + "geo:37.786971,-122.399677;u=35", ""); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_application_widget) { + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + "", "application/widget"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_application_widget_sharing) { + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + "", "application/vnd.wac.widget-sharing"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_application_rpm) { + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + "", "application/x-rpm"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_application_redhat) { + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + "", "application/x-redhat-package-manager"); + EXPECT_EQ(ret, true); +} + +TEST_F(AppControlTest, app_control_resolution_view_application_package) { + bool ret = Compare(APP_CONTROL_OPERATION_VIEW, + "", "application/vnd.tizen.package"); + EXPECT_EQ(ret, true); +} diff --git a/test/unit_tests/CMakeLists.txt b/test/unit_tests/CMakeLists.txt index 99bd4caf..9232e700 100644 --- a/test/unit_tests/CMakeLists.txt +++ b/test/unit_tests/CMakeLists.txt @@ -1,24 +1,27 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/ UNIT_TESTS_SRCS) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/mock/ UNIT_TESTS_SRCS) -ADD_EXECUTABLE(${TARGET_AUL_UNIT_TEST} ${UNIT_TESTS_SRCS}) -TARGET_INCLUDE_DIRECTORIES(${TARGET_AUL_UNIT_TEST} PUBLIC +ADD_EXECUTABLE(${TARGET_AUL_UNIT_TESTS} ${UNIT_TESTS_SRCS}) + +TARGET_INCLUDE_DIRECTORIES(${TARGET_AUL_UNIT_TESTS} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../" "${CMAKE_CURRENT_SOURCE_DIR}/../../include" "${CMAKE_CURRENT_SOURCE_DIR}/../../src" ) -APPLY_PKG_CONFIG(${TARGET_AUL_UNIT_TEST} PUBLIC +APPLY_PKG_CONFIG(${TARGET_AUL_UNIT_TESTS} PUBLIC GLIB_DEPS GMOCK_DEPS BUNDLE_DEPS ) -TARGET_LINK_LIBRARIES(${TARGET_AUL_UNIT_TEST} PUBLIC ${TARGET_AUL}) -SET_TARGET_PROPERTIES(${TARGET_AUL_UNIT_TEST} PROPERTIES COMPILE_FLAGS "-fPIE") -SET_TARGET_PROPERTIES(${TARGET_AUL_UNIT_TEST} PROPERTIES LINK_FLAGS "-pie") +TARGET_LINK_LIBRARIES(${TARGET_AUL_UNIT_TESTS} PUBLIC ${TARGET_AUL}) +SET_TARGET_PROPERTIES(${TARGET_AUL_UNIT_TESTS} PROPERTIES COMPILE_FLAGS "-fPIE") +SET_TARGET_PROPERTIES(${TARGET_AUL_UNIT_TESTS} PROPERTIES LINK_FLAGS "-pie") + +INSTALL(TARGETS ${TARGET_AUL_UNIT_TESTS} DESTINATION bin) ADD_TEST( - NAME ${TARGET_AUL_UNIT_TEST} - COMMAND ${TARGET_AUL_UNIT_TEST} + NAME ${TARGET_AUL_UNIT_TESTS} + COMMAND ${TARGET_AUL_UNIT_TESTS} ) |