2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <gtest/gtest.h>
18 #include <gmock/gmock.h>
20 #include <sticker_data.h>
22 #include "app_common_mock.h"
28 static bool callback_result = false;
29 static sticker_data_h g_dh = NULL;
31 static void foreach_keyword_cb(const char *keyword, void *user_data)
33 callback_result = true;
36 class StickerDataTest : public testing::Test {
38 virtual void SetUp() {
39 sticker_data_create(&g_dh);
40 sticker_data_set_uri(g_dh, STICKER_DATA_URI_WEB_RESOURCE, "www.samsung.com");
41 sticker_data_add_keyword(g_dh, "smile");
42 sticker_data_add_keyword(g_dh, "face");
43 sticker_data_add_keyword(g_dh, "cute");
44 sticker_data_set_group_name(g_dh, "tizen");
45 sticker_data_set_thumbnail(g_dh, "/res/test.png");
46 sticker_data_set_description(g_dh, "TCT Test");
48 virtual void TearDown() {
50 sticker_data_destroy(g_dh);
56 int __fake_app_get_id(char** app_id) {
58 *app_id = strdup("org.tizen.hello");
64 * @function utc_sticker_data_create_p
65 * @description Positive UTC of the function that creates sticker data handle
68 TEST_F(StickerDataTest, utc_sticker_data_create_p)
70 app_get_id_fake.custom_fake = __fake_app_get_id;
72 sticker_data_h sd_h = NULL;
73 int ret = sticker_data_create(&sd_h);
74 EXPECT_EQ(ret, STICKER_ERROR_NONE);
78 * @function utc_sticker_data_create_n
79 * @description Negative UTC of the function that creates sticker data handle
82 TEST_F(StickerDataTest, utc_sticker_data_create_n)
84 int ret = sticker_data_create(NULL);
85 EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER);
89 * @function utc_sticker_data_destroy_p
90 * @description Positive UTC of the function that destroys sticker data handle
93 TEST_F(StickerDataTest, utc_sticker_data_destroy_p)
95 app_get_id_fake.custom_fake = __fake_app_get_id;
97 sticker_data_h sd_h = NULL;
98 int ret = sticker_data_create(&sd_h);
99 EXPECT_EQ(ret, STICKER_ERROR_NONE);
101 ret = sticker_data_destroy(sd_h);
102 EXPECT_EQ(ret, STICKER_ERROR_NONE);
106 * @function utc_sticker_data_destroy_n
107 * @description Negative UTC of the function that destroys sticker data handle
110 TEST_F(StickerDataTest, utc_sticker_data_destroy_n)
112 int ret = sticker_data_destroy(NULL);
113 EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER);
117 * @testcase utc_sticker_data_clone_p
119 * @description Positive UTC of the function that clones sticker data.
121 TEST_F(StickerDataTest, utc_sticker_data_clone_p)
123 sticker_data_h clone = NULL;
124 int ret = sticker_data_clone(g_dh, &clone);
125 EXPECT_EQ(ret, STICKER_ERROR_NONE);
127 sticker_data_destroy(clone);
132 * @testcase utc_sticker_data_clone_n
134 * @description Negative UTC of the function that clones sticker data.
136 TEST_F(StickerDataTest, utc_sticker_data_clone_n)
138 int ret = sticker_data_clone(NULL, NULL);
139 EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER);
143 * @testcase utc_sticker_data_get_app_id_p
145 * @description Positive UTC of the function that gets application id of sticker data.
147 TEST_F(StickerDataTest, utc_sticker_data_get_app_id_p)
150 int ret = sticker_data_get_app_id(g_dh, &app_id);
151 EXPECT_EQ(ret, STICKER_ERROR_NONE);
158 * @testcase utc_sticker_data_get_app_id_n
160 * @description Negative UTC of the function that gets application id of sticker data.
162 TEST_F(StickerDataTest, utc_sticker_data_get_app_id_n)
165 int ret = sticker_data_get_app_id(NULL, &app_id);
166 EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER);
170 * @testcase utc_sticker_data_set_uri_p
172 * @description Positive UTC of the function that sets uri of sticker data.
174 TEST_F(StickerDataTest, utc_sticker_data_set_uri_p)
176 int ret = sticker_data_set_uri(g_dh, STICKER_DATA_URI_WEB_RESOURCE, "www.tizen.org");
177 EXPECT_EQ(ret, STICKER_ERROR_NONE);
181 * @testcase utc_sticker_data_set_uri_n
183 * @description Negative UTC of the function that sets uri of sticker data.
185 TEST_F(StickerDataTest, utc_sticker_data_set_uri_n)
187 int ret = sticker_data_set_uri(NULL, STICKER_DATA_URI_WEB_RESOURCE, "www.tizen.org");
188 EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER);
192 * @testcase utc_sticker_data_set_uri_n2
194 * @description Negative UTC of the function that sets uri of sticker data.
196 TEST_F(StickerDataTest, utc_sticker_data_set_uri_n2)
198 int ret = sticker_data_set_uri(g_dh, STICKER_DATA_URI_LOCAL_PATH, "/aaa/bbb/ccc.png");
199 EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER);
203 * @testcase utc_sticker_data_get_uri_p
205 * @description Positive UTC of the function that gets uri of sticker data.
207 TEST_F(StickerDataTest, utc_sticker_data_get_uri_p)
209 sticker_data_uri_type_e type;
212 int ret = sticker_data_get_uri(g_dh, &type, &uri);
213 EXPECT_EQ(ret, STICKER_ERROR_NONE);
220 * @testcase utc_sticker_data_get_uri_n
222 * @description Negative UTC of the function that gets uri of sticker data.
224 TEST_F(StickerDataTest, utc_sticker_data_get_uri_n)
226 int ret = sticker_data_get_uri(g_dh, NULL, NULL);
227 EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER);
231 * @testcase utc_sticker_data_foreach_keyword_p
233 * @description Positive UTC of the function that retrieves all keywords of sticker data.
235 TEST_F(StickerDataTest, utc_sticker_data_foreach_keyword_p)
237 callback_result = false;
238 int ret = sticker_data_foreach_keyword(g_dh, foreach_keyword_cb, NULL);
239 EXPECT_EQ(callback_result, true);
240 EXPECT_EQ(ret, STICKER_ERROR_NONE);
244 * @testcase utc_sticker_data_foreach_keyword_n
246 * @description Negative UTC of the function that retrieves all keywords of sticker data.
248 TEST_F(StickerDataTest, utc_sticker_data_foreach_keyword_n)
250 int ret = sticker_data_foreach_keyword(g_dh, NULL, NULL);
251 EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER);
255 * @testcase utc_sticker_data_add_keyword_p
257 * @description Positive UTC of the function that adds keyword of sticker data.
259 TEST_F(StickerDataTest, utc_sticker_data_add_keyword_p)
261 int ret = sticker_data_add_keyword(g_dh, "test");
262 EXPECT_EQ(ret, STICKER_ERROR_NONE);
266 * @testcase utc_sticker_data_add_keyword_n
268 * @description Negative UTC of the function that adds keyword of sticker data.
270 TEST_F(StickerDataTest, utc_sticker_data_add_keyword_n)
272 int ret = sticker_data_add_keyword(g_dh, NULL);
273 EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER);
277 * @testcase utc_sticker_data_add_keyword_n2
279 * @description Negative UTC of the function that adds keyword of sticker data.
281 TEST_F(StickerDataTest, utc_sticker_data_add_keyword_n2)
283 int ret = sticker_data_add_keyword(g_dh, "smile");
284 EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER);
288 * @testcase utc_sticker_data_remove_keyword_p
290 * @description Positive UTC of the function that removes keyword of sticker data.
292 TEST_F(StickerDataTest, utc_sticker_data_remove_keyword_p)
294 int ret = sticker_data_remove_keyword(g_dh, "face");
295 EXPECT_EQ(ret, STICKER_ERROR_NONE);
299 * @testcase utc_sticker_data_remove_keyword_n
301 * @description Negative UTC of the function that removes keyword of sticker data.
303 TEST_F(StickerDataTest, utc_sticker_data_remove_keyword_n)
305 int ret = sticker_data_remove_keyword(g_dh, NULL);
306 EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER);
310 * @testcase utc_sticker_data_remove_keyword_n2
312 * @description Negative UTC of the function that removes keyword of sticker data.
314 TEST_F(StickerDataTest, utc_sticker_data_remove_keyword_n2)
316 int ret = sticker_data_remove_keyword(g_dh, "test");
317 EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER);
321 * @testcase utc_sticker_data_set_group_name_p
323 * @description Positive UTC of the function that sets group name of sticker data.
325 TEST_F(StickerDataTest, utc_sticker_data_set_group_name_p)
327 int ret = sticker_data_set_group_name(g_dh, "samsung");
328 EXPECT_EQ(ret, STICKER_ERROR_NONE);
332 * @testcase utc_sticker_data_set_group_name_n
334 * @description Negative UTC of the function that sets group name of sticker data.
336 TEST_F(StickerDataTest, utc_sticker_data_set_group_name_n)
338 int ret = sticker_data_set_group_name(g_dh, NULL);
339 EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER);
343 * @testcase utc_sticker_data_get_group_name_p
345 * @description Positive UTC of the function that gets group name of sticker data.
347 TEST_F(StickerDataTest, utc_sticker_data_get_group_name_p)
350 int ret = sticker_data_get_group_name(g_dh, &group);
357 EXPECT_EQ(ret, STICKER_ERROR_NONE);
361 * @testcase utc_sticker_data_get_group_name_n
363 * @description Negative UTC of the function that gets group name of sticker data.
365 TEST_F(StickerDataTest, utc_sticker_data_get_group_name_n)
367 int ret = sticker_data_get_group_name(g_dh, NULL);
368 EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER);
372 * @testcase utc_sticker_data_set_thumbnail_n
374 * @description Negative UTC of the function that sets thumbnail of sticker data.
376 TEST_F(StickerDataTest, utc_sticker_data_set_thumbnail_n)
378 int ret = sticker_data_set_thumbnail(g_dh, NULL);
379 EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER);
383 * @testcase utc_sticker_data_set_thumbnail_n2
385 * @description Negative UTC of the function that sets thumbnail of sticker data.
387 TEST_F(StickerDataTest, utc_sticker_data_set_thumbnail_n2)
389 int ret = sticker_data_set_thumbnail(g_dh, "/aaa/bbb/ccc.png");
390 EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER);
394 * @testcase utc_sticker_data_get_thumbnail_p
396 * @description Positive UTC of the function that gets thumbnail of sticker data.
398 TEST_F(StickerDataTest, utc_sticker_data_get_thumbnail_p)
400 char *thumbnail = NULL;
401 int ret = sticker_data_get_thumbnail(g_dh, &thumbnail);
408 EXPECT_EQ(ret, STICKER_ERROR_NONE);
412 * @testcase utc_sticker_data_get_thumbnail_n
414 * @description Negative UTC of the function that gets thumbnail of sticker data.
416 TEST_F(StickerDataTest, utc_sticker_data_get_thumbnail_n)
418 int ret = sticker_data_get_thumbnail(g_dh, NULL);
419 EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER);
423 * @testcase utc_sticker_data_set_description_p
425 * @description Positive UTC of the function that sets description of sticker data.
427 TEST_F(StickerDataTest, utc_sticker_data_set_description_p)
429 int ret = sticker_data_set_description(g_dh, "capi-ui-sticker TCT Test");
430 EXPECT_EQ(ret, STICKER_ERROR_NONE);
434 * @testcase utc_sticker_data_set_description_n
436 * @description Negative UTC of the function that sets description of sticker data.
438 TEST_F(StickerDataTest, utc_sticker_data_set_description_n)
440 int ret = sticker_data_set_description(g_dh, NULL);
441 EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER);
445 * @testcase utc_sticker_data_get_description_p
447 * @description Positive UTC of the function that gets description of sticker data.
449 TEST_F(StickerDataTest, utc_sticker_data_get_description_p)
451 char *description = NULL;
452 int ret = sticker_data_get_description(g_dh, &description);
459 EXPECT_EQ(ret, STICKER_ERROR_NONE);
463 * @testcase utc_sticker_data_get_description_n
465 * @description Negative UTC of the function that gets description of sticker data.
467 TEST_F(StickerDataTest, utc_sticker_data_get_description_n)
469 int ret = sticker_data_get_description(g_dh, NULL);
470 EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER);
474 * @testcase utc_sticker_data_get_date_p
476 * @description Positive UTC of the function that gets last updated date.
478 TEST_F(StickerDataTest, utc_sticker_data_get_date_p)
481 int ret = sticker_data_get_date(g_dh, &date);
488 EXPECT_NE(ret, STICKER_ERROR_INVALID_PARAMETER);
492 * @testcase utc_sticker_data_get_date_n
494 * @description Negative UTC of the function that gets last updated date.
496 TEST_F(StickerDataTest, utc_sticker_data_get_date_n)
498 int ret = sticker_data_get_date(g_dh, NULL);
499 EXPECT_EQ(ret, STICKER_ERROR_INVALID_PARAMETER);