2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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.
21 #define LOG_TAG "LIVEBOX_TC"
23 #include <livebox-service.h>
24 #include <livebox-errno.h>
29 POSITIVE_TC_IDX = 0x01,
33 static void startup(void)
36 tet_printf("\n TC start");
40 static void cleanup(void)
43 tet_printf("\n TC end");
46 void (*tet_startup)(void) = startup;
47 void (*tet_cleanup)(void) = cleanup;
49 #define DUMMY_ID "/opt/usr/share/live_magazine/com.samsung.dummy.png"
50 #define DUMMY_INVALID_ID "/usr/share/live_magazine/com.samsung.dummy.png"
51 #define DUMMY_PKGNAME "com.samsung.dummy"
53 static void utc_livebox_desc_open_n(void)
56 struct livebox_desc *handle;
58 handle = livebox_desc_open(DUMMY_INVALID_ID, 0);
60 (void)livebox_desc_close(handle);
62 dts_check_eq("livebox_desc_open", handle, NULL, "Must return NULL in case of invalid id is used");
65 static void utc_livebox_desc_open_p(void)
68 struct livebox_desc *handle;
70 handle = livebox_desc_open(DUMMY_ID, 0);
71 dts_check_ne("livebox_desc_open", handle, NULL, "Must return valid handle");
74 static void utc_livebox_desc_close_n(void)
79 ret = livebox_desc_close(NULL);
80 dts_check_eq("livebox_desc_close", ret, LB_STATUS_ERROR_INVALID, "Must returns LB_STATUS_ERROR_INVALID");
83 static void utc_livebox_desc_close_p(void)
86 struct livebox_desc *handle;
89 handle = livebox_desc_open(DUMMY_ID, 0);
91 dts_check_ne("livebox_desc_close", handle, NULL, "Failed to create a handle");
95 ret = livebox_desc_close(handle);
96 dts_check_eq("livebox_desc_close", ret, LB_STATUS_SUCCESS, "Must returns LB_STATUS_SUCCESS");
99 static void utc_livebox_desc_set_category_n(void)
103 ret = livebox_desc_set_category(NULL, NULL, NULL);
105 dts_check_eq("livebox_desc_set_category", ret, LB_STATUS_ERROR_INVALID, "Invalid parameter used, LB_STATUS_ERROR_INVALID should be returned");
108 static void utc_livebox_desc_set_category_p(void)
111 struct livebox_desc *handle;
114 handle = livebox_desc_open(DUMMY_ID, 0);
116 dts_check_ne("livebox_desc_set_category", handle, NULL, "Failed to create a handle");
120 ret = livebox_desc_set_category(handle, NULL, "New Category");
121 (void)livebox_desc_close(handle);
122 dts_check_eq("livebox_desc_set_category", ret, LB_STATUS_SUCCESS, "LB_STATUS_SUCCESS should be returned\n");
125 static void utc_livebox_desc_set_id_n(void)
128 struct livebox_desc *handle;
131 handle = livebox_desc_open(DUMMY_ID, 0);
133 dts_check_ne("livebox_desc_set_id", handle, NULL, "Failed to create a handle");
136 ret = livebox_desc_set_id(handle, -1, NULL);
137 (void)livebox_desc_close(handle);
138 dts_check_eq("livebox_desc_set_id", ret, LB_STATUS_ERROR_NOT_EXIST, "LB_STATUS_ERROR_NOT_EXIST should be returned\n");
141 static void utc_livebox_desc_set_id_p(void)
144 struct livebox_desc *handle;
148 handle = livebox_desc_open(DUMMY_ID, 0);
150 dts_check_ne("livebox_desc_set_id", handle, NULL, "Failed to create a handle");
153 idx = livebox_desc_add_block(handle, NULL, LB_DESC_TYPE_SCRIPT, "swallow,part", "/usr/apps/com.samsung.test-app/res/edje/test.edj", "test,group");
155 dts_check_ge("livebox_desc_set_id", idx, 0, "Failed to add a desc block");
156 (void)livebox_desc_close(handle);
160 ret = livebox_desc_set_id(handle, idx, "new,id");
161 (void)livebox_desc_close(handle);
162 dts_check_eq("livebox_desc_set_id", ret, LB_STATUS_SUCCESS, "LB_STATUS_SUCCESS should be returned\n");
165 static void utc_livebox_desc_add_block_n(void)
170 idx = livebox_desc_add_block(NULL, NULL, LB_DESC_TYPE_SCRIPT, "swallow,part", "/usr/apps/com.samsung.test-app/res/edje/test.edj", "test,group");
171 dts_check_eq("livebox_desc_add_block", idx, LB_STATUS_ERROR_INVALID, "LB_STATUS_ERROR_INVALID should be returned\n");
174 static void utc_livebox_desc_add_block_p(void)
177 struct livebox_desc *handle;
180 handle = livebox_desc_open(DUMMY_ID, 0);
182 dts_check_ne("livebox_desc_add_block", handle, NULL, "Failed to create a handle");
186 idx = livebox_desc_add_block(handle, NULL, LB_DESC_TYPE_SCRIPT, "swallow,part", "/usr/apps/com.samsung.test-app/res/edje/test.edj", "test,group");
187 dts_check_ge("livebox_desc_add_block", idx, 0, "idx should not be less than 0\n");
188 (void)livebox_desc_close(handle);
191 static void utc_livebox_desc_del_block_n(void)
194 struct livebox_desc *handle;
197 handle = livebox_desc_open(DUMMY_ID, 0);
199 dts_check_ne("livebox_desc_del_block", handle, NULL, "Failed to create a handle");
203 ret = livebox_desc_del_block(handle, 0);
204 dts_check_eq("livebox_desc_del_block", ret, LB_STATUS_ERROR_NOT_EXIST, "Block is not found, LB_STATUS_ERROR_NOT_EXIST should be returned\n");
207 static void utc_livebox_desc_del_block_p(void)
210 struct livebox_desc *handle;
214 handle = livebox_desc_open(DUMMY_ID, 0);
215 if (handle == NULL) {
216 dts_check_ne("livebox_desc_del_block", handle, NULL, "Failed to create desc handle");
219 idx = livebox_desc_add_block(handle, NULL, LB_DESC_TYPE_SCRIPT, "swallow,part", "/usr/apps/com.samsung.test-app/res/edje/test.edj", "test,group");
221 dts_check_ge("livebox_desc_del_block", idx, 0, "Failed to add a desc block");
222 (void)livebox_desc_close(handle);
225 ret = livebox_desc_del_block(handle, idx);
226 (void)livebox_desc_close(handle);
227 dts_check_eq("livebox_desc_del_block", ret, LB_STATUS_SUCCESS, "del_block should returns LB_STATUS_SUCCESS\n");
230 int livebox_trigger_update_monitor(const char *id, int is_pd)
233 return LB_STATUS_ERROR_INVALID;
236 return LB_STATUS_SUCCESS;
239 static void utc_livebox_content_is_updated_n(void)
244 ret = livebox_content_is_updated(NULL, 0);
245 dts_check_eq("livebox_content_is_updated", ret, LB_STATUS_ERROR_INVALID, "should returns LB_STATUS_ERROR_INVALID\n");
248 static void utc_livebox_content_is_updated_p(void)
252 ret = livebox_content_is_updated(DUMMY_ID, 0);
253 dts_check_eq("livebox_content_is_updated", ret, LB_STATUS_SUCCESS, "should returns LB_STATUS_SUCCESS\n");
256 static void utc_livebox_request_close_pd_n(void)
261 ret = livebox_request_close_pd(DUMMY_PKGNAME, DUMMY_ID, LB_STATUS_SUCCESS);
262 dts_check_eq("livebox_request_close_pd", ret, LB_STATUS_ERROR_INVALID, "should returns LB_STATUS_ERROR_INVALID\n");
265 static void utc_livebox_request_close_pd_p(void)
270 * Unable to test the positive case
272 dts_pass("livebox_request_close_pd", "pass negative test");
275 static void utc_livebox_request_update_n(void)
279 ret = livebox_request_update(NULL);
280 dts_check_eq("livebox_request_update", ret, LB_STATUS_ERROR_INVALID, "should returns LB_STATUS_ERROR_INVALID");
283 static void utc_livebox_request_update_p(void)
288 * Unable to test the positive case
290 dts_pass("livebox_request_update", "pass negative test");
293 static void utc_livebox_util_nl2br_n(void)
298 nl2br = livebox_util_nl2br(NULL);
299 dts_check_eq("livebox_util_nl2br", nl2br, NULL, "should returns NULL\n");
302 static void utc_livebox_util_nl2br_p(void)
306 nl2br = livebox_util_nl2br("hello\nworld");
308 dts_check_str_eq("livebox_util_nl2br", nl2br, "hello<br>world", "should returns \"hello<br>world\"");
312 static void utc_livebox_acquire_buffer_n(void)
315 struct livebox_buffer *handle;
317 handle = livebox_acquire_buffer(NULL, 0, 720, 200, NULL, NULL);
318 dts_check_eq("livebox_acquire_buffer", handle, NULL, "should returns NULL\n");
321 static void utc_livebox_acquire_buffer_p(void)
326 * Unable to test the positive case
328 dts_pass("livebox_acquire_buffer", "pass positive test");
331 static void utc_livebox_acquire_buffer_NEW_n(void)
334 struct livebox_buffer *handle;
336 handle = livebox_acquire_buffer_NEW(NULL, 0, 720, 200, sizeof(int), NULL, NULL);
337 dts_check_eq("livebox_acquire_buffer_NEW", handle, NULL, "should returns NULL\n");
340 static void utc_livebox_acquire_buffer_NEW_p(void)
345 * Unable to test the positive case
347 dts_pass("livebox_acquire_buffer_NEW", "pass positive test");
351 static void utc_livebox_pixmap_id_n(void)
354 unsigned long pixmap;
356 pixmap = livebox_pixmap_id(NULL);
357 dts_check_eq("livebox_pixmap_id", pixmap, 0, "should returns 0\n");
360 static void utc_livebox_pixmap_id_p(void)
365 * Unable to test the positive case
367 dts_pass("livebox_pixmap_id", "pass positive test");
370 static void utc_livebox_ref_buffer_n(void)
374 ret = livebox_ref_buffer(NULL);
375 dts_check_eq("livebox_ref_buffer", ret, NULL, "should returns NULL\n");
378 static void utc_livebox_ref_buffer_p(void)
383 * Unable to test the positive case
385 dts_pass("livebox_ref_buffer", "pass positive test");
388 static void utc_livebox_sync_buffer_n(void)
392 ret = livebox_sync_buffer(NULL);
393 dts_check_eq("livebox_sync_buffer", ret, LB_STATUS_ERROR_INVALID, "should returns LB_STATUS_ERROR_INVALID\n");
396 static void utc_livebox_sync_buffer_p(void)
401 * Unable to test the positive case
403 dts_pass("livebox_sync_buffer", "pass positive test");
406 static void utc_livebox_support_hw_buffer_n(void)
410 ret = livebox_support_hw_buffer(NULL);
411 dts_check_eq("livebox_support_hw_buffer", ret, LB_STATUS_ERROR_INVALID, "should returns LB_STATUS_ERROR_INVALID\n");
414 static void utc_livebox_support_hw_buffer_p(void)
419 * Unable to test the positive case
421 dts_pass("livebox_support_hw_buffer", "pass positive test");
424 static void utc_livebox_create_hw_buffer_n(void)
428 ret = livebox_create_hw_buffer(NULL);
429 dts_check_eq("livebox_create_hw_buffer", ret, LB_STATUS_ERROR_INVALID, "should returns LB_STATUS_ERROR_INVALID\n");
432 static void utc_livebox_create_hw_buffer_p(void)
437 * Unable to test the positive case
439 dts_pass("livebox_create_hw_buffer", "pass positive test");
442 static void utc_livebox_destroy_hw_buffer_n(void)
446 ret = livebox_destroy_hw_buffer(NULL);
447 dts_check_eq("livebox_destroy_hw_buffer", ret, LB_STATUS_ERROR_INVALID, "should returns LB_STATUS_ERROR_INVALID\n");
450 static void utc_livebox_destroy_hw_buffer_p(void)
455 * Unable to test the positive case
457 dts_pass("livebox_destroy_hw_buffer", "pass positive test");
460 static void utc_livebox_buffer_hw_buffer_n(void)
464 ret = livebox_buffer_hw_buffer(NULL);
465 dts_check_eq("livebox_buffer_hw_buffer", ret, NULL, "should returns LB_STATUS_ERROR_INVALID");
468 static void utc_livebox_buffer_hw_buffer_p(void)
473 * Unable to test the positive case
475 dts_pass("livebox_buffer_hw_buffer", "pass positive test");
478 static void utc_livebox_buffer_pre_render_n(void)
482 ret = livebox_buffer_pre_render(NULL);
483 dts_check_eq("livebox_buffer_pre_render", ret, LB_STATUS_ERROR_INVALID, "should returns LB_STATUS_ERROR_INVALID\n");
486 static void utc_livebox_buffer_pre_render_p(void)
491 * Unable to test the positive case
493 dts_pass("livebox_buffer_pre_render", "pass positive test");
496 static void utc_livebox_buffer_post_render_n(void)
500 ret = livebox_buffer_post_render(NULL);
501 dts_check_eq("livebox_buffer_post_render", ret, LB_STATUS_ERROR_INVALID, "should returns LB_STATUS_ERROR_INVALID\n");
504 static void utc_livebox_buffer_post_render_p(void)
509 * Unable to test the positive case
511 dts_pass("livebox_buffer_post_render", "pass positive test");
514 static void utc_livebox_get_evas_object_n(void)
519 obj = livebox_get_evas_object(NULL, 1);
520 dts_check_eq("livebox_get_evas_object", obj, NULL, "should returns NULL\n");
523 static void utc_livebox_get_evas_object_p(void)
528 * Unable to test the positive case
530 dts_pass("livebox_get_evas_object", "pass positve test");
533 struct tet_testlist tet_testlist[] = {
534 { utc_livebox_desc_open_n, NEGATIVE_TC_IDX },
535 { utc_livebox_desc_open_p, POSITIVE_TC_IDX },
536 { utc_livebox_desc_close_n, NEGATIVE_TC_IDX },
537 { utc_livebox_desc_close_p, POSITIVE_TC_IDX },
538 { utc_livebox_desc_set_category_n, NEGATIVE_TC_IDX },
539 { utc_livebox_desc_set_category_p, POSITIVE_TC_IDX },
540 { utc_livebox_desc_set_id_n, NEGATIVE_TC_IDX },
541 { utc_livebox_desc_set_id_p, POSITIVE_TC_IDX },
542 { utc_livebox_desc_add_block_n, NEGATIVE_TC_IDX },
543 { utc_livebox_desc_add_block_p, POSITIVE_TC_IDX },
544 { utc_livebox_desc_del_block_n, NEGATIVE_TC_IDX },
545 { utc_livebox_desc_del_block_p, POSITIVE_TC_IDX },
546 { utc_livebox_content_is_updated_n, NEGATIVE_TC_IDX },
547 { utc_livebox_content_is_updated_p, POSITIVE_TC_IDX },
548 { utc_livebox_request_close_pd_n, NEGATIVE_TC_IDX },
549 { utc_livebox_request_close_pd_p, POSITIVE_TC_IDX },
550 { utc_livebox_request_update_n, NEGATIVE_TC_IDX },
551 { utc_livebox_request_update_p, POSITIVE_TC_IDX },
552 { utc_livebox_util_nl2br_n, NEGATIVE_TC_IDX },
553 { utc_livebox_util_nl2br_p, POSITIVE_TC_IDX },
555 { utc_livebox_acquire_buffer_n, NEGATIVE_TC_IDX },
556 { utc_livebox_acquire_buffer_p, POSITIVE_TC_IDX },
557 { utc_livebox_acquire_buffer_NEW_n, NEGATIVE_TC_IDX },
558 { utc_livebox_acquire_buffer_NEW_p, POSITIVE_TC_IDX },
560 { utc_livebox_pixmap_id_n, NEGATIVE_TC_IDX },
561 { utc_livebox_pixmap_id_p, POSITIVE_TC_IDX },
563 { utc_livebox_ref_buffer_n, NEGATIVE_TC_IDX },
564 { utc_livebox_ref_buffer_p, POSITIVE_TC_IDX },
566 { utc_livebox_sync_buffer_n, NEGATIVE_TC_IDX },
567 { utc_livebox_sync_buffer_p, POSITIVE_TC_IDX },
569 { utc_livebox_support_hw_buffer_n, NEGATIVE_TC_IDX },
570 { utc_livebox_support_hw_buffer_p, POSITIVE_TC_IDX },
571 { utc_livebox_create_hw_buffer_n, NEGATIVE_TC_IDX },
572 { utc_livebox_create_hw_buffer_p, POSITIVE_TC_IDX },
573 { utc_livebox_destroy_hw_buffer_n, NEGATIVE_TC_IDX },
574 { utc_livebox_destroy_hw_buffer_p, POSITIVE_TC_IDX },
575 { utc_livebox_buffer_hw_buffer_n, NEGATIVE_TC_IDX },
576 { utc_livebox_buffer_hw_buffer_p, POSITIVE_TC_IDX },
577 { utc_livebox_buffer_pre_render_n, NEGATIVE_TC_IDX },
578 { utc_livebox_buffer_pre_render_p, POSITIVE_TC_IDX },
579 { utc_livebox_buffer_post_render_n, NEGATIVE_TC_IDX },
580 { utc_livebox_buffer_post_render_p, POSITIVE_TC_IDX },
581 { utc_livebox_get_evas_object_n, NEGATIVE_TC_IDX },
582 { utc_livebox_get_evas_object_p, POSITIVE_TC_IDX },