From c84f24977ce72fa829b38be24e4652e1a0c5b1b2 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Wed, 27 May 2020 18:05:51 +0900 Subject: [PATCH] Add more negative unit tests Change-Id: I7b1e4d2a81b19c4301805c138ad5b48a4785bbc0 Signed-off-by: Jihoon Kim --- tests/src/autofill_client_unittests.cpp | 44 ++++++++++++ tests/src/autofill_common_unittests.cpp | 117 ++++++++++++++++++++++++++++++++ 2 files changed, 161 insertions(+) diff --git a/tests/src/autofill_client_unittests.cpp b/tests/src/autofill_client_unittests.cpp index e08bbff..d1d1fc4 100644 --- a/tests/src/autofill_client_unittests.cpp +++ b/tests/src/autofill_client_unittests.cpp @@ -125,6 +125,17 @@ TEST_F(AutofillClientTest, utc_autofill_connect_n) } /** + * @testcase utc_autofill_connect_n2 + * @since_tizen 5.5 + * @description Negative UTC of the function that connects to autofill daemon. + */ +TEST_F(AutofillClientTest, utc_autofill_connect_n2) +{ + int ret = autofill_connect(af_h, NULL, NULL); + EXPECT_EQ(ret, AUTOFILL_ERROR_INVALID_PARAMETER); +} + +/** * @testcase utc_autofill_auth_info_request_n * @since_tizen 5.5 * @description Negative UTC of the function that sends authentication information. @@ -136,6 +147,17 @@ TEST_F(AutofillClientTest, utc_autofill_auth_info_request_n) } /** + * @testcase utc_autofill_auth_info_request_n2 + * @since_tizen 5.5 + * @description Negative UTC of the function that sends authentication information. + */ +TEST_F(AutofillClientTest, utc_autofill_auth_info_request_n2) +{ + int ret = autofill_auth_info_request(af_h, NULL); + EXPECT_EQ(ret, AUTOFILL_ERROR_INVALID_PARAMETER); +} + +/** * @testcase utc_autofill_auth_info_set_received_cb_p * @since_tizen 5.5 * @description Positive UTC of the function that sets auth info received callback. @@ -235,6 +257,17 @@ TEST_F(AutofillClientTest, utc_autofill_fill_request_n) } /** + * @testcase utc_autofill_fill_request_n2 + * @since_tizen 5.5 + * @description Negative UTC of the function that sends fill request. + */ +TEST_F(AutofillClientTest, utc_autofill_fill_request_n2) +{ + int ret = autofill_fill_request(af_h, NULL); + EXPECT_EQ(ret, AUTOFILL_ERROR_INVALID_PARAMETER); +} + +/** * @testcase utc_autofill_cancel_fill_request_n * @since_tizen 5.5 * @description Negative UTC of the function that cancels fill request. @@ -246,6 +279,17 @@ TEST_F(AutofillClientTest, utc_autofill_cancel_fill_request_n) } /** + * @testcase utc_autofill_cancel_fill_request_n2 + * @since_tizen 5.5 + * @description Negative UTC of the function that cancels fill request. + */ +TEST_F(AutofillClientTest, utc_autofill_cancel_fill_request_n2) +{ + int ret = autofill_cancel_fill_request(af_h, NULL); + EXPECT_EQ(ret, AUTOFILL_ERROR_INVALID_PARAMETER); +} + +/** * @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. diff --git a/tests/src/autofill_common_unittests.cpp b/tests/src/autofill_common_unittests.cpp index 038a831..e536f14 100644 --- a/tests/src/autofill_common_unittests.cpp +++ b/tests/src/autofill_common_unittests.cpp @@ -168,6 +168,33 @@ TEST_F(AutofillCommonTest, utc_autofill_item_clone_n) } /** + * @testcase utc_autofill_item_clone_n2 + * @since_tizen 5.5 + * @description Negative UTC of the function that clones autofill item. + */ +TEST_F(AutofillCommonTest, utc_autofill_item_clone_n2) +{ + autofill_item_h it_h = NULL; + int ret = autofill_item_create(&it_h); + ASSERT_EQ(ret, AUTOFILL_ERROR_NONE); + ASSERT_NE(it_h, nullptr); + + ret = autofill_item_set_id(it_h, "test"); + ASSERT_EQ(ret, AUTOFILL_ERROR_NONE); + + ret = autofill_item_set_label(it_h, "test"); + ASSERT_EQ(ret, AUTOFILL_ERROR_NONE); + + ret = autofill_item_set_value(it_h, "test"); + ASSERT_EQ(ret, AUTOFILL_ERROR_NONE); + + ret = autofill_item_clone(it_h, NULL); + EXPECT_EQ(ret, AUTOFILL_ERROR_INVALID_PARAMETER); + + autofill_item_destroy(it_h); +} + +/** * @testcase utc_autofill_item_set_autofill_hint_p * @since_tizen 5.5 * @description Positive UTC of the function that sets autofill hint in an autofill item. @@ -1857,6 +1884,35 @@ TEST_F(AutofillCommonTest, utc_autofill_fill_response_group_clone_n) } /** + * @testcase utc_autofill_fill_response_group_clone_n2 + * @since_tizen 5.5 + * @description Negative UTC of the function that clones autofill fill response group. + */ +TEST_F(AutofillCommonTest, utc_autofill_fill_response_group_clone_n2) +{ + int ret; + autofill_fill_response_group_h res_group; + autofill_fill_response_item_h res_it_h; + + ret = autofill_fill_response_group_create(&res_group); + ASSERT_EQ(ret, AUTOFILL_ERROR_NONE); + + /* item 1 */ + autofill_fill_response_item_create(&res_it_h); + autofill_fill_response_item_set_id(res_it_h, "id"); + autofill_fill_response_item_set_presentation_text(res_it_h, "tester1"); + autofill_fill_response_item_set_value(res_it_h, "tester1"); + + /* Add item in group */ + ret = autofill_fill_response_group_add_item(res_group, res_it_h); + ASSERT_EQ(ret, AUTOFILL_ERROR_NONE); + ret = autofill_fill_response_group_clone(res_group, NULL); + EXPECT_EQ(ret, AUTOFILL_ERROR_INVALID_PARAMETER); + + autofill_fill_response_group_destroy(res_group); +} + +/** * @testcase utc_autofill_fill_response_group_foreach_item_p * @since_tizen 5.5 * @description Positive UTC of the function that retrieve each autofill fill response item in autofill fill response group. @@ -1909,6 +1965,24 @@ TEST_F(AutofillCommonTest, utc_autofill_fill_response_group_foreach_item_n) } /** + * @testcase utc_autofill_fill_response_group_foreach_item_n2 + * @since_tizen 5.5 + * @description Negative UTC of the function that retrieve each autofill fill response item in autofill fill response group. + */ +TEST_F(AutofillCommonTest, utc_autofill_fill_response_group_foreach_item_n2) +{ + int ret; + autofill_fill_response_group_h res_group; + ret = autofill_fill_response_group_create(&res_group); + ASSERT_EQ(ret, AUTOFILL_ERROR_NONE); + + ret = autofill_fill_response_group_foreach_item(res_group, NULL, NULL); + EXPECT_EQ(ret, AUTOFILL_ERROR_INVALID_PARAMETER); + + autofill_fill_response_group_destroy(res_group); +} + +/** * @testcase utc_autofill_save_view_info_create_p * @since_tizen 5.5 * @description Positive UTC of the function that creates autofill save view information. @@ -2403,6 +2477,28 @@ TEST_F(AutofillCommonTest, utc_autofill_fill_response_item_clone_n) } /** + * @testcase utc_autofill_fill_response_item_clone_n2 + * @since_tizen 5.5 + * @description Negative UTC of the function that clones autofill fill response item. + */ +TEST_F(AutofillCommonTest, utc_autofill_fill_response_item_clone_n2) +{ + int ret; + autofill_fill_response_item_h res_it_h; + + ret = autofill_fill_response_item_create(&res_it_h); + ASSERT_EQ(ret, AUTOFILL_ERROR_NONE); + + ret = autofill_fill_response_item_set_id(res_it_h, "id"); + ASSERT_EQ(ret, AUTOFILL_ERROR_NONE); + + ret = autofill_fill_response_item_clone(res_it_h, NULL); + EXPECT_EQ(ret, AUTOFILL_ERROR_INVALID_PARAMETER); + + autofill_fill_response_item_destroy(res_it_h); +} + +/** * @testcase utc_autofill_fill_response_item_set_id_p * @since_tizen 5.5 * @description Positive UTC of the function that sets autofill id in autofill fill response item. @@ -2811,6 +2907,27 @@ TEST_F(AutofillCommonTest, utc_autofill_save_item_clone_n) } /** + * @testcase utc_autofill_save_item_clone_n2 + * @since_tizen 5.5 + * @description Negative UTC of the function that clones autofill save item. + */ +TEST_F(AutofillCommonTest, utc_autofill_save_item_clone_n2) +{ + autofill_save_item_h it_h = NULL; + int ret = autofill_save_item_create(&it_h); + ASSERT_EQ(ret, AUTOFILL_ERROR_NONE); + ASSERT_NE(it_h, nullptr); + + ret = autofill_save_item_set_id(it_h, "test"); + ASSERT_EQ(ret, AUTOFILL_ERROR_NONE); + + ret = autofill_save_item_clone(it_h, NULL); + EXPECT_EQ(ret, AUTOFILL_ERROR_INVALID_PARAMETER); + + autofill_save_item_destroy(it_h); +} + +/** * @testcase utc_autofill_save_item_set_autofill_hint_p * @since_tizen 5.5 * @description Positive UTC of the function that sets autofill hint in autofill save item. -- 2.7.4