From 91969957ec33581bc7801e0da766f9accfd60892 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Thu, 25 Mar 2021 11:23:25 +0900 Subject: [PATCH] Enhance unittest coverage lines: 54.8 (1035 of 1888 lines) -> 66.1% (1308 of 1980 lines) functions..: 73.4% (168 of 229 functions) -> 81.5% (202 of 248 functions) Change-Id: I71f38f23ee8cb02edd3494ffde705bf419c15b55 Signed-off-by: Jihoon Kim --- tests/src/sticker_consumer_unittests.cc | 153 ++++++++++++++++++++++++++++++++ tests/src/sticker_data_unittests.cc | 59 ++++++++++++ tests/src/sticker_provider_unittests.cc | 11 +++ 3 files changed, 223 insertions(+) diff --git a/tests/src/sticker_consumer_unittests.cc b/tests/src/sticker_consumer_unittests.cc index e1b59b4..398ed42 100644 --- a/tests/src/sticker_consumer_unittests.cc +++ b/tests/src/sticker_consumer_unittests.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -29,6 +30,7 @@ static bool callback_result = false; static sticker_data_h g_dh = NULL; +static sticker_provider_h g_ph = NULL; static sticker_consumer_h g_ch = NULL; namespace { @@ -138,6 +140,10 @@ void __fake_g_dbus_connection_signal_unsubscribe(GDBusConnection* c, void __fake_g_bus_unwatch_name(guint a) { } +static void event_cb(sticker_consumer_event_type_e event_type, sticker_data_h data_handle, void *user_data) +{ +} + class StickerConsumerTest : public testing::Test { public: virtual void SetUp() { @@ -172,6 +178,9 @@ class StickerConsumerTest : public testing::Test { sticker_data_set_group_name(g_dh, "tizen"); sticker_data_set_thumbnail(g_dh, "/res/test.png"); sticker_data_set_description(g_dh, "TCT Test"); + sticker_data_set_display_type(g_dh, STICKER_DATA_DISP_WALLPAPER); + sticker_provider_insert_data(g_ph, g_dh); + sticker_provider_set_group_image(g_ph, "tizen", STICKER_DATA_URI_WEB_RESOURCE, "www.valid.com/test/test.png"); } virtual void TearDown() { sticker_data_destroy(g_dh); @@ -258,6 +267,19 @@ TEST_F(StickerConsumerTest, utc_sticker_consumer_data_foreach_all_n) } /** + * @testcase utc_sticker_consumer_data_foreach_by_keyword_p + * @since_tizen 5.5 + * @description Positive UTC of the function that retrieves all sticker data using keyword. + */ +TEST_F(StickerConsumerTest, utc_sticker_consumer_data_foreach_by_keyword_p) +{ + int result = 0; + callback_result = false; + int ret = sticker_consumer_data_foreach_by_keyword(g_ch, 0, 1000, &result, "cute", sticker_data_foreach_cb, NULL); + EXPECT_EQ(ret, STICKER_ERROR_NONE); +} + +/** * @testcase utc_sticker_consumer_data_foreach_by_keyword_n * @since_tizen 5.5 * @description Negative UTC of the function that retrieves all sticker data using keyword. @@ -270,6 +292,19 @@ TEST_F(StickerConsumerTest, utc_sticker_consumer_data_foreach_by_keyword_n) } /** + * @testcase utc_sticker_consumer_data_foreach_by_group_p + * @since_tizen 5.5 + * @description Positive UTC of the function that retrieves all sticker data using group. + */ +TEST_F(StickerConsumerTest, utc_sticker_consumer_data_foreach_by_group_p) +{ + int result = 0; + callback_result = false; + int ret = sticker_consumer_data_foreach_by_group(g_ch, 0, 1000, &result, "tizen", sticker_data_foreach_cb, NULL); + EXPECT_EQ(ret, STICKER_ERROR_NONE); +} + +/** * @testcase utc_sticker_consumer_data_foreach_by_group_n * @since_tizen 5.5 * @description Negative UTC of the function that retrieves all sticker data using group. @@ -282,6 +317,19 @@ TEST_F(StickerConsumerTest, utc_sticker_consumer_data_foreach_by_group_n) } /** + * @testcase utc_sticker_consumer_data_foreach_by_type_p + * @since_tizen 5.5 + * @description Positive UTC of the function that retrieves all sticker data using type. + */ +TEST_F(StickerConsumerTest, utc_sticker_consumer_data_foreach_by_type_p) +{ + int result = 0; + callback_result = false; + int ret = sticker_consumer_data_foreach_by_type(g_ch, 0, 1000, &result, STICKER_DATA_URI_WEB_RESOURCE, sticker_data_foreach_cb, NULL); + EXPECT_EQ(ret, STICKER_ERROR_NONE); +} + +/** * @testcase utc_sticker_consumer_data_foreach_by_type_n * @since_tizen 5.5 * @description Negative UTC of the function that retrieves all sticker data using type. @@ -315,4 +363,109 @@ TEST_F(StickerConsumerTest, utc_sticker_consumer_keyword_list_foreach_all_n) EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER); } +/** + * @testcase utc_sticker_consumer_data_foreach_by_display_type_n + * @since_tizen 5.5 + * @description Negative UTC of the function that retrieves all sticker data using display type. + */ +TEST_F(StickerConsumerTest, utc_sticker_consumer_data_foreach_by_display_type_n) +{ + int result = 0; + int ret = sticker_consumer_data_foreach_by_display_type(g_ch, -1, 0, &result, STICKER_DATA_DISP_WALLPAPER, sticker_data_foreach_cb, NULL); + EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER); +} + +/** + * @testcase utc_sticker_consumer_group_list_foreach_by_display_type_n + * @since_tizen 5.5 + * @description Negative UTC of the function that retrieves all group name using display type. + */ +TEST_F(StickerConsumerTest, utc_sticker_consumer_group_list_foreach_by_display_type_n) +{ + int ret = sticker_consumer_group_list_foreach_by_display_type(g_ch, STICKER_DATA_DISP_WALLPAPER, NULL, NULL); + EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER); +} + +/** + * @testcase utc_sticker_consumer_add_recent_data_n + * @since_tizen 5.5 + * @description Negative UTC of the function that adds entry to recently used stickers list. + */ +TEST_F(StickerConsumerTest, utc_sticker_consumer_add_recent_data_n) +{ + int ret = sticker_consumer_add_recent_data(g_ch, NULL); + EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER); +} + +/** + * @testcase utc_sticker_consumer_get_recent_data_list_p + * @since_tizen 5.5 + * @description Positive UTC of the function that gets recently used stickers list. + */ +TEST_F(StickerConsumerTest, utc_sticker_consumer_get_recent_data_list_p) +{ + int result = 0; + callback_result = false; + sticker_consumer_add_recent_data(g_ch, g_dh); + int ret = sticker_consumer_get_recent_data_list(g_ch, 1, &result, sticker_data_foreach_cb, NULL); + EXPECT_EQ(ret, STICKER_ERROR_NONE); +} + +/** + * @testcase utc_sticker_consumer_get_recent_data_list_n + * @since_tizen 5.5 + * @description Negative UTC of the function that gets recently used stickers list. + */ +TEST_F(StickerConsumerTest, utc_sticker_consumer_get_recent_data_list_n) +{ + int result = 0; + int ret = sticker_consumer_get_recent_data_list(g_ch, 0, &result, sticker_data_foreach_cb, NULL); + EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER); +} + +/** + * @testcase utc_sticker_consumer_set_event_cb_p + * @since_tizen 5.5 + * @description Positive UTC of the function that registers a event callback function. + */ +TEST_F(StickerConsumerTest, utc_sticker_consumer_set_event_cb_p) +{ + callback_result = false; + int ret = sticker_consumer_set_event_cb(g_ch, event_cb, NULL); + EXPECT_EQ(ret, STICKER_ERROR_NONE); +} + +/** + * @testcase utc_sticker_consumer_set_event_cb_n + * @since_tizen 5.5 + * @description Negative UTC of the function that registers a event callback function. + */ +TEST_F(StickerConsumerTest, utc_sticker_consumer_set_event_cb_n) +{ + int ret = sticker_consumer_set_event_cb(g_ch, NULL, NULL); + EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER); +} + +/** + * @testcase utc_sticker_consumer_unset_event_cb_n + * @since_tizen 5.5 + * @description Negative UTC of the function that unregisters a event callback function. + */ +TEST_F(StickerConsumerTest, utc_sticker_consumer_unset_event_cb_n) +{ + int ret = sticker_consumer_unset_event_cb(NULL); + EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER); +} + +/** + * @testcase utc_sticker_consumer_group_image_list_foreach_all_n + * @since_tizen 6.5 + * @description Negative UTC of the function that retrieves images of all sticker groups. + */ +TEST_F(StickerConsumerTest, utc_sticker_consumer_group_image_list_foreach_all_n) +{ + int ret = sticker_consumer_group_image_list_foreach_all(g_ch, NULL, NULL); + EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER); +} + } // namespace diff --git a/tests/src/sticker_data_unittests.cc b/tests/src/sticker_data_unittests.cc index 57002ce..31b4468 100644 --- a/tests/src/sticker_data_unittests.cc +++ b/tests/src/sticker_data_unittests.cc @@ -18,6 +18,7 @@ #include #include +#include #include "app_common_mock.h" @@ -500,4 +501,62 @@ TEST_F(StickerDataTest, utc_sticker_data_get_date_n) EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER); } +/** + * @testcase utc_sticker_data_set_display_type_p + * @since_tizen 5.5 + * @description Positive UTC of the function that sets display type of sticker data. + */ +TEST_F(StickerDataTest, utc_sticker_data_set_display_type_p) +{ + int ret = sticker_data_set_display_type(g_dh, STICKER_DATA_DISP_EMOJI); + EXPECT_EQ(ret, STICKER_ERROR_NONE); +} + +/** + * @testcase utc_sticker_data_get_display_type_p + * @since_tizen 5.5 + * @description Positive UTC of the function that gets display type of sticker data. + */ +TEST_F(StickerDataTest, utc_sticker_data_get_display_type_p) +{ + sticker_data_display_type_e disp_type; + int ret = sticker_data_get_display_type(g_dh, &disp_type); + EXPECT_EQ(ret, STICKER_ERROR_NONE); +} + +/** + * @testcase utc_sticker_data_get_display_type_n + * @since_tizen 5.5 + * @description Negative UTC of the function that gets display type of sticker data. + */ +TEST_F(StickerDataTest, utc_sticker_data_get_display_type_n) +{ + int ret = sticker_data_get_display_type(g_dh, NULL); + EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER); +} + +/** + * @testcase utc_sticker_data_get_handle_n + * @since_tizen 5.5 + * @description Negative UTC of the function that gets the sticker data handle using URI. + */ +TEST_F(StickerDataTest, tc_sticker_data_get_handle_n) +{ + sticker_data_h tmp_handle = NULL; + int ret = sticker_data_get_handle("", &tmp_handle); + EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER); +} + +/** + * @testcase utc_sticker_data_get_handle_n2 + * @since_tizen 5.5 + * @description Negative UTC of the function that gets the sticker data handle using URI. + */ +TEST_F(StickerDataTest, utc_sticker_data_get_handle_n2) +{ + sticker_data_h tmp_handle = NULL; + int ret = sticker_data_get_handle("www.invalid.com", &tmp_handle); + EXPECT_EQ(ret, STICKER_ERROR_NO_SUCH_FILE); +} + } // namespace diff --git a/tests/src/sticker_provider_unittests.cc b/tests/src/sticker_provider_unittests.cc index 590c48a..98eb73e 100644 --- a/tests/src/sticker_provider_unittests.cc +++ b/tests/src/sticker_provider_unittests.cc @@ -355,4 +355,15 @@ TEST_F(StickerProviderTest, utc_sticker_provider_delete_data_by_uri_n) EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER); } +/** + * @testcase utc_sticker_provider_set_group_image_n + * @since_tizen 6.5 + * @description Negative UTC of the function that sets group image. + */ +TEST_F(StickerProviderTest, utc_sticker_provider_set_group_image_n) +{ + int ret = sticker_provider_set_group_image(g_ph, "invalid", STICKER_DATA_URI_WEB_RESOURCE, "www.valid.com/test/image.png"); + EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER); +} + } // namespace -- 2.7.4