From 04ed0becb075314a8570cad3995c81c4dd018d21 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 20 Jan 2023 15:53:37 +0900 Subject: [PATCH] Add cancel_fill_request unittests Change-Id: I69e5722e958acdfc51b930f5aa5b08017620fa60 Signed-off-by: Jihoon Kim --- tests/src/autofill_client_unittests.cpp | 83 +++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/tests/src/autofill_client_unittests.cpp b/tests/src/autofill_client_unittests.cpp index 50c511f..323c965 100644 --- a/tests/src/autofill_client_unittests.cpp +++ b/tests/src/autofill_client_unittests.cpp @@ -26,6 +26,10 @@ #define VIEW_ID "login" +static GMainLoop *g_mainloop = NULL; +static const char *g_app_id = "org.tizen.autofill-test"; +static bool g_connected = false; + namespace { //LCOV_EXCL_START @@ -45,6 +49,17 @@ void error_info_cb(autofill_h ah, autofill_error_info_h error_info, void *user_d } //LCOV_EXCL_STOP +static void connect_status_changed_cb(autofill_h ah, autofill_connection_status_e status, void* user_data) +{ + if (status == AUTOFILL_CONNECTION_STATUS_CONNECTED) + g_connected = true; + + if (g_mainloop) { + g_main_loop_quit(g_mainloop); + g_mainloop = NULL; + } +} + class AutofillClientTest : public testing::Test { public: autofill_h af_h = NULL; @@ -292,6 +307,74 @@ TEST_F(AutofillClientTest, utc_autofill_cancel_fill_request_n2) } /** + * @testcase utc_autofill_cancel_fill_request_p + * @since_tizen 5.5 + * @description Positive UTC of the function that cancels fill request without autofill item. + */ +TEST_F(AutofillClientTest, utc_autofill_cancel_fill_request_p) +{ + int ret = AUTOFILL_ERROR_NONE; + autofill_view_info_h vi_h; + + ret = autofill_connect(af_h, connect_status_changed_cb, NULL); + EXPECT_EQ(ret, AUTOFILL_ERROR_NONE); + + g_mainloop = g_main_loop_new(NULL, false); + g_main_loop_run(g_mainloop); + + autofill_view_info_create(&vi_h); + if (g_app_id) + autofill_view_info_set_app_id(vi_h, g_app_id); + + autofill_view_info_set_view_id(vi_h, VIEW_ID); + + ret = autofill_cancel_fill_request(af_h, vi_h); + + autofill_view_info_destroy(vi_h); + + EXPECT_EQ(ret, AUTOFILL_ERROR_NONE); +} + +/** + * @testcase utc_autofill_cancel_fill_request_p2 + * @since_tizen 5.5 + * @description Positive UTC of the function that cancels fill request with autofill item. + */ +TEST_F(AutofillClientTest, utc_autofill_cancel_fill_request_p2) +{ + int ret = AUTOFILL_ERROR_NONE; + autofill_view_info_h vi_h; + + ret = autofill_connect(af_h, connect_status_changed_cb, NULL); + EXPECT_EQ(ret, AUTOFILL_ERROR_NONE); + + g_mainloop = g_main_loop_new(NULL, false); + g_main_loop_run(g_mainloop); + + autofill_view_info_create(&vi_h); + if (g_app_id) + autofill_view_info_set_app_id(vi_h, g_app_id); + + autofill_view_info_set_view_id(vi_h, VIEW_ID); + + // create autofill item + autofill_item_h ai_h; + autofill_item_create(&ai_h); + autofill_item_set_autofill_hint(ai_h, AUTOFILL_HINT_NAME); + autofill_item_set_id(ai_h, "id"); + autofill_item_set_label(ai_h, "label"); + autofill_item_set_sensitive_data(ai_h, false); + + autofill_view_info_add_item(vi_h, ai_h); + + ret = autofill_cancel_fill_request(af_h, vi_h); + + autofill_view_info_destroy(vi_h); + + EXPECT_EQ(ret, AUTOFILL_ERROR_NONE); +} + +/** * @testcase utc_autofill_fill_response_set_received_cb_p * @since_tizen 5.5 * @description Positive UTC of the function that sets fill response received callback. -- 2.7.4