From: Hwankyu Jhun Date: Mon, 1 Oct 2018 02:43:12 +0000 (+0900) Subject: [UTC][application][ACR-1303][Add new testcases for app_control_send_launch_request_as... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dce348373ee04b28e13d96c1b402427d51a87574;p=test%2Ftct%2Fnative%2Fapi.git [UTC][application][ACR-1303][Add new testcases for app_control_send_launch_request_async function] Change-Id: I537cda53991e8d6ba7f2d585a410cb5ca9366976 Signed-off-by: Hwankyu Jhun --- diff --git a/src/utc/application/public.list b/src/utc/application/public.list index 8376e8e8e..b30c95e08 100755 --- a/src/utc/application/public.list +++ b/src/utc/application/public.list @@ -27,6 +27,7 @@ app_control_set_uri app_control_set_launch_mode app_control_get_launch_mode app_control_enable_app_started_result_event +app_control_send_launch_request_async app_get_cache_path app_get_data_path app_get_device_orientation diff --git a/src/utc/application/tct-application-core_mobile.h b/src/utc/application/tct-application-core_mobile.h index 6ef9b0c75..33bde6f75 100755 --- a/src/utc/application/tct-application-core_mobile.h +++ b/src/utc/application/tct-application-core_mobile.h @@ -269,6 +269,14 @@ extern int utc_application_app_event_publish_trusted_app_event_n4(void); extern int utc_application_app_event_publish_trusted_app_event_n5(void); extern int utc_application_app_event_keep_last_event_data_p(void); extern int utc_application_app_event_keep_last_event_data_n(void); +extern int utc_application_app_control_send_launch_request_async_p1(void); +extern int utc_application_app_control_send_launch_request_async_p2(void); +extern int utc_application_app_control_send_launch_request_async_p3(void); +extern int utc_application_app_control_send_launch_request_async_p4(void); +extern int utc_application_app_control_send_launch_request_async_n1(void); +extern int utc_application_app_control_send_launch_request_async_n2(void); +extern int utc_application_app_control_send_launch_request_async_n3(void); +extern int utc_application_app_control_send_launch_request_async_n4(void); testcase tc_array[] = { {"utc_application_app_get_name_p",utc_application_app_get_name_p,NULL,NULL}, @@ -460,6 +468,14 @@ testcase tc_array[] = { {"utc_application_app_control_get_launch_mode_n1",utc_application_app_control_get_launch_mode_n1,utc_application_app_control_startup,NULL}, {"utc_application_app_control_enable_app_started_result_event_p1",utc_application_app_control_enable_app_started_result_event_p1,utc_application_app_control_startup,NULL}, {"utc_application_app_control_enable_app_started_result_event_n1",utc_application_app_control_enable_app_started_result_event_n1,utc_application_app_control_startup,NULL}, + {"utc_application_app_control_send_launch_request_async_p1", utc_application_app_control_send_launch_request_async_p1, NULL, NULL}, + {"utc_application_app_control_send_launch_request_async_p2", utc_application_app_control_send_launch_request_async_p2, NULL, NULL}, + {"utc_application_app_control_send_launch_request_async_p3", utc_application_app_control_send_launch_request_async_p3, NULL, NULL}, + {"utc_application_app_control_send_launch_request_async_p4", utc_application_app_control_send_launch_request_async_p4, NULL, NULL}, + {"utc_application_app_control_send_launch_request_async_n1", utc_application_app_control_send_launch_request_async_n1, NULL, NULL}, + {"utc_application_app_control_send_launch_request_async_n2", utc_application_app_control_send_launch_request_async_n2, NULL, NULL}, + {"utc_application_app_control_send_launch_request_async_n3", utc_application_app_control_send_launch_request_async_n3, NULL, NULL}, + {"utc_application_app_control_send_launch_request_async_n4", utc_application_app_control_send_launch_request_async_n4, NULL, NULL}, {"utc_application_app_resource_manager_get_p1",utc_application_app_resource_manager_get_p1,utc_application_app_resource_manager_startup,utc_application_app_resource_manager_cleanup}, {"utc_application_app_resource_manager_get_p2",utc_application_app_resource_manager_get_p2,utc_application_app_resource_manager_startup,utc_application_app_resource_manager_cleanup}, {"utc_application_app_resource_manager_get_p3",utc_application_app_resource_manager_get_p3,utc_application_app_resource_manager_startup,utc_application_app_resource_manager_cleanup}, diff --git a/src/utc/application/tct-application-core_tizeniot.h b/src/utc/application/tct-application-core_tizeniot.h index 6ef9b0c75..33bde6f75 100755 --- a/src/utc/application/tct-application-core_tizeniot.h +++ b/src/utc/application/tct-application-core_tizeniot.h @@ -269,6 +269,14 @@ extern int utc_application_app_event_publish_trusted_app_event_n4(void); extern int utc_application_app_event_publish_trusted_app_event_n5(void); extern int utc_application_app_event_keep_last_event_data_p(void); extern int utc_application_app_event_keep_last_event_data_n(void); +extern int utc_application_app_control_send_launch_request_async_p1(void); +extern int utc_application_app_control_send_launch_request_async_p2(void); +extern int utc_application_app_control_send_launch_request_async_p3(void); +extern int utc_application_app_control_send_launch_request_async_p4(void); +extern int utc_application_app_control_send_launch_request_async_n1(void); +extern int utc_application_app_control_send_launch_request_async_n2(void); +extern int utc_application_app_control_send_launch_request_async_n3(void); +extern int utc_application_app_control_send_launch_request_async_n4(void); testcase tc_array[] = { {"utc_application_app_get_name_p",utc_application_app_get_name_p,NULL,NULL}, @@ -460,6 +468,14 @@ testcase tc_array[] = { {"utc_application_app_control_get_launch_mode_n1",utc_application_app_control_get_launch_mode_n1,utc_application_app_control_startup,NULL}, {"utc_application_app_control_enable_app_started_result_event_p1",utc_application_app_control_enable_app_started_result_event_p1,utc_application_app_control_startup,NULL}, {"utc_application_app_control_enable_app_started_result_event_n1",utc_application_app_control_enable_app_started_result_event_n1,utc_application_app_control_startup,NULL}, + {"utc_application_app_control_send_launch_request_async_p1", utc_application_app_control_send_launch_request_async_p1, NULL, NULL}, + {"utc_application_app_control_send_launch_request_async_p2", utc_application_app_control_send_launch_request_async_p2, NULL, NULL}, + {"utc_application_app_control_send_launch_request_async_p3", utc_application_app_control_send_launch_request_async_p3, NULL, NULL}, + {"utc_application_app_control_send_launch_request_async_p4", utc_application_app_control_send_launch_request_async_p4, NULL, NULL}, + {"utc_application_app_control_send_launch_request_async_n1", utc_application_app_control_send_launch_request_async_n1, NULL, NULL}, + {"utc_application_app_control_send_launch_request_async_n2", utc_application_app_control_send_launch_request_async_n2, NULL, NULL}, + {"utc_application_app_control_send_launch_request_async_n3", utc_application_app_control_send_launch_request_async_n3, NULL, NULL}, + {"utc_application_app_control_send_launch_request_async_n4", utc_application_app_control_send_launch_request_async_n4, NULL, NULL}, {"utc_application_app_resource_manager_get_p1",utc_application_app_resource_manager_get_p1,utc_application_app_resource_manager_startup,utc_application_app_resource_manager_cleanup}, {"utc_application_app_resource_manager_get_p2",utc_application_app_resource_manager_get_p2,utc_application_app_resource_manager_startup,utc_application_app_resource_manager_cleanup}, {"utc_application_app_resource_manager_get_p3",utc_application_app_resource_manager_get_p3,utc_application_app_resource_manager_startup,utc_application_app_resource_manager_cleanup}, diff --git a/src/utc/application/tct-application-core_wearable.h b/src/utc/application/tct-application-core_wearable.h index 6ef9b0c75..33bde6f75 100755 --- a/src/utc/application/tct-application-core_wearable.h +++ b/src/utc/application/tct-application-core_wearable.h @@ -269,6 +269,14 @@ extern int utc_application_app_event_publish_trusted_app_event_n4(void); extern int utc_application_app_event_publish_trusted_app_event_n5(void); extern int utc_application_app_event_keep_last_event_data_p(void); extern int utc_application_app_event_keep_last_event_data_n(void); +extern int utc_application_app_control_send_launch_request_async_p1(void); +extern int utc_application_app_control_send_launch_request_async_p2(void); +extern int utc_application_app_control_send_launch_request_async_p3(void); +extern int utc_application_app_control_send_launch_request_async_p4(void); +extern int utc_application_app_control_send_launch_request_async_n1(void); +extern int utc_application_app_control_send_launch_request_async_n2(void); +extern int utc_application_app_control_send_launch_request_async_n3(void); +extern int utc_application_app_control_send_launch_request_async_n4(void); testcase tc_array[] = { {"utc_application_app_get_name_p",utc_application_app_get_name_p,NULL,NULL}, @@ -460,6 +468,14 @@ testcase tc_array[] = { {"utc_application_app_control_get_launch_mode_n1",utc_application_app_control_get_launch_mode_n1,utc_application_app_control_startup,NULL}, {"utc_application_app_control_enable_app_started_result_event_p1",utc_application_app_control_enable_app_started_result_event_p1,utc_application_app_control_startup,NULL}, {"utc_application_app_control_enable_app_started_result_event_n1",utc_application_app_control_enable_app_started_result_event_n1,utc_application_app_control_startup,NULL}, + {"utc_application_app_control_send_launch_request_async_p1", utc_application_app_control_send_launch_request_async_p1, NULL, NULL}, + {"utc_application_app_control_send_launch_request_async_p2", utc_application_app_control_send_launch_request_async_p2, NULL, NULL}, + {"utc_application_app_control_send_launch_request_async_p3", utc_application_app_control_send_launch_request_async_p3, NULL, NULL}, + {"utc_application_app_control_send_launch_request_async_p4", utc_application_app_control_send_launch_request_async_p4, NULL, NULL}, + {"utc_application_app_control_send_launch_request_async_n1", utc_application_app_control_send_launch_request_async_n1, NULL, NULL}, + {"utc_application_app_control_send_launch_request_async_n2", utc_application_app_control_send_launch_request_async_n2, NULL, NULL}, + {"utc_application_app_control_send_launch_request_async_n3", utc_application_app_control_send_launch_request_async_n3, NULL, NULL}, + {"utc_application_app_control_send_launch_request_async_n4", utc_application_app_control_send_launch_request_async_n4, NULL, NULL}, {"utc_application_app_resource_manager_get_p1",utc_application_app_resource_manager_get_p1,utc_application_app_resource_manager_startup,utc_application_app_resource_manager_cleanup}, {"utc_application_app_resource_manager_get_p2",utc_application_app_resource_manager_get_p2,utc_application_app_resource_manager_startup,utc_application_app_resource_manager_cleanup}, {"utc_application_app_resource_manager_get_p3",utc_application_app_resource_manager_get_p3,utc_application_app_resource_manager_startup,utc_application_app_resource_manager_cleanup}, diff --git a/src/utc/application/utc_app_control.c b/src/utc/application/utc_app_control.c index dc5320857..1c397e91f 100755 --- a/src/utc/application/utc_app_control.c +++ b/src/utc/application/utc_app_control.c @@ -13,15 +13,24 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#include "assert.h" -#include "assert_common.h" + #include #include #include #include #include #include +#include + #include "tct_app_common.h" +#include "assert.h" +#include "assert_common.h" + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "NativeTCT" /** * @function utc_application_app_control_startup @@ -3278,3 +3287,414 @@ int utc_application_app_control_enable_app_started_result_event_n1(void) return 0; } + +static void __app_control_result_cb(app_control_h request, + app_control_error_e result, void *user_data) +{ + dlog_print(DLOG_INFO, LOG_TAG, "Result: %d", result); + if (result == APP_CONTROL_ERROR_NONE) + normal_exit(0); + else + normal_exit(1); +} + +/** + * @testcase utc_application_app_control_send_launch_request_async_p1 + * @since_tizen 5.0 + * @type Positive + * @description Sends the launch request asynchronously. + * @scenario Sends the launch request asynchronously. + */ +int utc_application_app_control_send_launch_request_async_p1(void) +{ + app_control_h handle; + int ret; + + ret = app_control_create(&handle); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create app control handle"); + normal_exit(1); + return -1; + } + + ret = app_control_set_operation(handle, + APP_CONTROL_OPERATION_DEFAULT); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set operation"); + normal_exit(1); + goto end; + } + + ret = app_control_set_app_id(handle, "org.tizen.helloworld"); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set application ID"); + normal_exit(1); + goto end; + } + + ret = app_control_send_launch_request_async(handle, __app_control_result_cb, + NULL, NULL); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to send launch request async"); + normal_exit(1); + } + +end: + app_control_destroy(handle); + + return ret; +} + + +/** + * @testcase utc_application_app_control_send_launch_request_async_p2 + * @since_tizen 5.0 + * @type Positive + * @description Sends the launch request asynchronously. + * @scenario Sends the launch request asynchronously with the reply callback. + */ +int utc_application_app_control_send_launch_request_async_p2(void) +{ + app_control_h handle; + int ret; + + ret = app_control_create(&handle); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create app control handle"); + normal_exit(1); + return -1; + } + + ret = app_control_set_operation(handle, + APP_CONTROL_OPERATION_DEFAULT); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set operation"); + normal_exit(1); + goto end; + } + + ret = app_control_set_app_id(handle, "org.tizen.helloworld"); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set application ID"); + normal_exit(1); + goto end; + } + + ret = app_control_send_launch_request_async(handle, __app_control_result_cb, + dts_app_control_reply_cb, NULL); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to send launch request async"); + normal_exit(1); + } + +end: + app_control_destroy(handle); + + return ret; +} + +/** + * @testcase utc_application_app_control_send_launch_request_async_p3 + * @since_tizen 5.0 + * @type Positive + * @description Sends the launch request asynchronously.. + * @scenario Sets the operation, the mime and the appid, + * and then sends the launch request asynchronously. + */ +int utc_application_app_control_send_launch_request_async_p3(void) +{ + app_control_h handle; + int ret; + + ret = app_control_create(&handle); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create app control handle"); + normal_exit(1); + return -1; + } + + ret = app_control_set_operation(handle, + APP_CONTROL_OPERATION_DEFAULT); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set operation"); + normal_exit(1); + goto end; + } + + ret = app_control_set_mime(handle, "type/custom"); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set MIME-Type"); + normal_exit(1); + goto end; + } + + ret = app_control_set_app_id(handle, "org.tizen.helloworld"); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set application ID"); + normal_exit(1); + goto end; + } + + ret = app_control_send_launch_request_async(handle, __app_control_result_cb, + NULL, NULL); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to send launch request async"); + normal_exit(1); + } + +end: + app_control_destroy(handle); + + return ret; +} + +/** + * @testcase utc_application_app_control_send_launch_request_async_p4 + * @since_tizen 5.0 + * @type Positive + * @description Sends the launch request asynchronously. + * @scenario Sets the operation, the appid, and then sends the + * launch request asynchronously. This target application requires + * privilege(http://tizen.org/privilege/alarm.get) to + * send app_control. + */ +int utc_application_app_control_send_launch_request_async_p4(void) +{ + app_control_h handle; + int ret; + + ret = app_control_create(&handle); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create app control handle"); + normal_exit(1); + return -1; + } + + ret = app_control_set_operation(handle, + APP_CONTROL_OPERATION_DEFAULT); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set operation"); + normal_exit(1); + goto end; + } + + ret = app_control_set_app_id(handle, "org.example.appcontrolprivilegetest"); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set application ID"); + normal_exit(1); + goto end; + } + + ret = app_control_send_launch_request_async(handle, __app_control_result_cb, + NULL, NULL); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to send launch request async"); + normal_exit(1); + } + +end: + app_control_destroy(handle); + + return ret; +} + +/** + * @testcase utc_application_app_control_send_launch_request_async_n1 + * @since_tizen 5.0 + * @type Negative + * @description Sends the launch request asynchronously. + * @scenario Calls the app_control_send_launch_request() with the invalid parameters. + */ +int utc_application_app_control_send_launch_request_async_n1(void) +{ + app_control_h handle; + int ret; + + ret = app_control_create(&handle); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create app control handle"); + normal_exit(1); + return -1; + } + + ret = app_control_send_launch_request_async(NULL, NULL, NULL, NULL); + if (ret != APP_CONTROL_ERROR_INVALID_PARAMETER) { + dlog_print(DLOG_ERROR, LOG_TAG, "error: %d", ret); + normal_exit(1); + goto end; + } + + ret = app_control_send_launch_request_async(handle, NULL, NULL, NULL); + if (ret != APP_CONTROL_ERROR_INVALID_PARAMETER) { + dlog_print(DLOG_ERROR, LOG_TAG, "error: %d", ret); + normal_exit(1); + goto end; + } + + normal_exit(0); + +end: + app_control_destroy(handle); + + return 0; +} + +/** + * @testcase utc_application_app_control_send_launch_request_async_n2 + * @since_tizen 5.0 + * @type Negative + * @description Sends the launch request asynchronously. + * @scenario Sends the launch request without the given appid. + * If the operation is APP_CONTROL_OPERATION_DEFAULT, + * the app_control requires the appid for sending the launch request asynchronously. + */ +int utc_application_app_control_send_launch_request_async_n2(void) +{ + app_control_h handle; + int ret; + + ret = app_control_create(&handle); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create app control handle"); + normal_exit(1); + return -1; + } + + ret = app_control_set_operation(handle, + APP_CONTROL_OPERATION_DEFAULT); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set operation"); + normal_exit(1); + goto end; + } + + ret = app_control_send_launch_request_async(handle, __app_control_result_cb, + NULL, NULL); + if (ret != APP_CONTROL_ERROR_APP_NOT_FOUND) { + dlog_print(DLOG_ERROR, LOG_TAG, "error: %d", ret); + normal_exit(1); + } + normal_exit(0); + +end: + app_control_destroy(handle); + + return 0; +} + +static void __app_control_result_cb_n3(app_control_h request, + app_control_error_e result, void *user_data) +{ + dlog_print(DLOG_INFO, LOG_TAG, "Result: %d", result); + if (result == APP_CONTROL_ERROR_APP_NOT_FOUND) + normal_exit(0); + else + normal_exit(1); +} + +/** + * @testcase utc_application_app_control_send_launch_request_async_n3 + * @since_tizen 5.0 + * @type Negative + * @description Sends the launch request asynchronously. + * @scenario Sends the launch request asynchronously with the invalid appid. + */ +int utc_application_app_control_send_launch_request_async_n3(void) +{ + app_control_h handle; + int ret; + + ret = app_control_create(&handle); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create app control handle"); + normal_exit(1); + return -1; + } + + ret = app_control_set_operation(handle, + APP_CONTROL_OPERATION_DEFAULT); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set operation"); + normal_exit(1); + goto end; + } + + ret = app_control_set_app_id(handle, "org.tizen.hellohelloworld"); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set application ID"); + normal_exit(1); + goto end; + } + + ret = app_control_send_launch_request_async(handle, + __app_control_result_cb_n3, + NULL, NULL); + if (ret != APP_CONTROL_ERROR_APP_NOT_FOUND) { + dlog_print(DLOG_ERROR, LOG_TAG, "error: %d", ret); + normal_exit(1); + } + +end: + app_control_destroy(handle); + + return 0; +} + +static void __app_control_result_cb_n4(app_control_h request, + app_control_error_e result, void *user_data) +{ + dlog_print(DLOG_INFO, LOG_TAG, "Result: %d", result); + if (result == APP_CONTROL_ERROR_PERMISSION_DENIED) + normal_exit(0); + else + normal_exit(1); +} + +/** + * @testcase utc_application_app_control_send_launch_request_async_n4 + * @since_tizen 5.0 + * @type Negative + * @description Sends the launch request asynchronously. + * @scenario Sends the launch request asynchronously to application which requires + * privilege(http://tizen.org/privilege/notification). + */ +int utc_application_app_control_send_launch_request_async_n4(void) +{ + app_control_h handle; + int ret; + + ret = app_control_create(&handle); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create app control handle"); + normal_exit(1); + return -1; + } + + ret = app_control_set_operation(handle, + APP_CONTROL_OPERATION_DEFAULT); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set operation"); + normal_exit(1); + goto end; + } + + ret = app_control_set_app_id(handle, "org.example.appcontrolprivilegetest2"); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set application ID"); + normal_exit(1); + goto end; + } + + ret = app_control_send_launch_request_async(handle, + __app_control_result_cb_n4, + NULL, NULL); + if (ret != APP_CONTROL_ERROR_PERMISSION_DENIED) { + dlog_print(DLOG_ERROR, LOG_TAG, "error: %d", ret); + normal_exit(1); + } + +end: + app_control_destroy(handle); + + return 0; +}