Added a new test case for elm_combobox_add
authorAnil Kumar Nahak <ak.nahak@samsung.com>
Fri, 1 Jun 2018 07:39:30 +0000 (13:09 +0530)
committerYeongjong Lee <yj34.lee@samsung.com>
Fri, 13 Jul 2018 10:51:56 +0000 (19:51 +0900)
Change-Id: I9c543fd96ba3a55b366eea717a20c24a810dc9f5
Signed-off-by: Anil Kumar Nahak <ak.nahak@samsung.com>
TC/elementary/combobox/Makefile [new file with mode: 0644]
TC/elementary/combobox/tslist [new file with mode: 0644]
TC/elementary/combobox/tslist_mobile [new file with mode: 0644]
TC/elementary/combobox/tslist_tv [new file with mode: 0644]
TC/elementary/combobox/tslist_wear [new file with mode: 0644]
TC/elementary/combobox/utc_elm_combobox_add.c [new file with mode: 0644]
TC/elementary/combobox/utc_elm_combobox_hover_begin_and_end.c [new file with mode: 0644]
TC/tet_scen

diff --git a/TC/elementary/combobox/Makefile b/TC/elementary/combobox/Makefile
new file mode 100644 (file)
index 0000000..a0146e8
--- /dev/null
@@ -0,0 +1,21 @@
+CC ?= gcc
+
+C_FILES = $(shell cat tslist)
+
+PKGS = elementary check
+
+LDFLAGS = `pkg-config --libs $(PKGS)`
+
+CFLAGS = -I. `pkg-config --cflags $(PKGS)`
+CFLAGS += -Wall
+
+#TARGETS = $(C_FILES:%.c=tc-%)
+TCS := $(shell ls -1 *.c | cut -d. -f1)
+
+all: $(TCS)
+
+%: %.c
+       $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
+
+clean:
+       rm -f $(TCS)
diff --git a/TC/elementary/combobox/tslist b/TC/elementary/combobox/tslist
new file mode 100644 (file)
index 0000000..4def886
--- /dev/null
@@ -0,0 +1,2 @@
+utc_elm_combobox_add.c
+utc_elm_combobox_hover_begin_and_end.c
diff --git a/TC/elementary/combobox/tslist_mobile b/TC/elementary/combobox/tslist_mobile
new file mode 100644 (file)
index 0000000..4def886
--- /dev/null
@@ -0,0 +1,2 @@
+utc_elm_combobox_add.c
+utc_elm_combobox_hover_begin_and_end.c
diff --git a/TC/elementary/combobox/tslist_tv b/TC/elementary/combobox/tslist_tv
new file mode 100644 (file)
index 0000000..4def886
--- /dev/null
@@ -0,0 +1,2 @@
+utc_elm_combobox_add.c
+utc_elm_combobox_hover_begin_and_end.c
diff --git a/TC/elementary/combobox/tslist_wear b/TC/elementary/combobox/tslist_wear
new file mode 100644 (file)
index 0000000..4def886
--- /dev/null
@@ -0,0 +1,2 @@
+utc_elm_combobox_add.c
+utc_elm_combobox_hover_begin_and_end.c
diff --git a/TC/elementary/combobox/utc_elm_combobox_add.c b/TC/elementary/combobox/utc_elm_combobox_add.c
new file mode 100644 (file)
index 0000000..893c484
--- /dev/null
@@ -0,0 +1,123 @@
+#include <check.h>
+#include <Elementary.h>
+#include "../../utc_negative_unitest.h"
+Evas_Object *main_win = NULL;
+
+/**
+ * @addtogroup elm_combobox
+ * @{
+ * @defgroup  elm_combobox_add()
+ *
+ * @precondition
+ * @step 1 Initialize Elementary
+ * @step 2 Create a main window
+ */
+
+static void
+setup(void) {
+       printf(" ============ Startup ============ \n");
+       elm_init(0, NULL);
+       main_win = elm_win_add(NULL, "main", ELM_WIN_BASIC);
+       if (main_win == NULL) {
+               ck_abort_msg("[TEST_FAIL]:: %s[%d] : Unable to create a main window..", __FILE__, __LINE__);
+               return;
+       }
+}
+
+static void
+teardown(void) {
+       if (main_win != NULL) {
+               evas_object_del(main_win);
+               main_win = NULL;
+       }
+       elm_shutdown();
+       printf(" ============ Cleanup ============ \n");
+}
+
+/**
+ * @addtogroup elm_combobox_add
+ * @{
+ * @objective Positive Test case checks if function call with valid value to add a new combobox
+ * to the parent's canvas works properly and without segmentation fault
+ * @n Input Data:
+ * @li the window object
+ *
+ * @procedure
+ * @step 1 Call elm_combobox_add with valid value
+ *
+ * @passcondition
+ * @li Test passes if returned value is not NULL and there is no segmentation fault
+ * @}
+ */
+START_TEST(utc_elm_combobox_add_p) {
+       if (main_win == NULL) {
+               return;
+       }
+
+       Evas_Object *combobox = NULL;
+
+       combobox = elm_combobox_add(main_win);
+       if (combobox == NULL) {
+               ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+               return;
+       }
+       printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
+       evas_object_del(combobox);
+}
+END_TEST
+
+/**
+ * @addtogroup elm_combobox_add
+ * @{
+ * @objective Negative Test case checks if function call with invalid value to add a new combobox
+ * to the parent's canvas works properly and without segmentation fault
+ * @n Input Data:
+ * @li NULL instead of the window object
+ *
+ * @procedure
+ * @step 1 Call elm_combobox_add with invalid value instead of the window object
+ *
+ * @passcondition
+ * @li Test passes if returned value is NULL and there is no segmentation fault
+ * @}
+ */
+START_TEST(utc_elm_combobox_add_n) {
+       if (TEST_FAIL == UNITEST_FUNC_NEG_RET(NULL, elm_combobox_add, main_win)) {
+               ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+               return;
+       }
+       printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
+}
+END_TEST
+
+/**
+ * @}
+ */
+Suite *
+test_suite(void) {
+       Suite *suite = suite_create("utc_elm_combobox_add");
+
+       TCase *tcase = tcase_create("TCase");
+       tcase_set_timeout(tcase, 30);
+       tcase_add_checked_fixture(tcase, setup, teardown);
+       tcase_add_test(tcase, utc_elm_combobox_add_p);
+       tcase_add_test(tcase, utc_elm_combobox_add_n);
+       suite_add_tcase(suite, tcase);
+
+       return suite;
+}
+
+int
+main() {
+       int number_failed;
+
+       Suite *suite = test_suite();
+       SRunner *srunner = srunner_create(suite);
+       srunner_set_log(srunner, "utc_elm_combobox_add.log");
+       srunner_set_xml(srunner, "utc_elm_combobox_add.xml");
+       srunner_run_all(srunner, CK_NORMAL);
+       number_failed = srunner_ntests_failed(srunner);
+       srunner_free(srunner);
+
+       return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/TC/elementary/combobox/utc_elm_combobox_hover_begin_and_end.c b/TC/elementary/combobox/utc_elm_combobox_hover_begin_and_end.c
new file mode 100644 (file)
index 0000000..51648cd
--- /dev/null
@@ -0,0 +1,226 @@
+#include <check.h>
+#include <Elementary.h>
+#include "../../utc_negative_unitest.h"
+
+Evas_Object *main_win = NULL, *combobox = NULL;
+static Eina_Bool is_expanded = EINA_FALSE;
+
+static char *
+gl_text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED) {
+
+       char buf[256];
+       snprintf(buf, sizeof(buf), "Item # %i", (int)(uintptr_t)data);
+       return strdup(buf);
+}
+
+static void
+_combobox_dismissed_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) {
+       is_expanded = EINA_FALSE;
+       printf("[Debug]:: %s[%d] : _combobox_dismissed_cb ", __FILE__, __LINE__);
+       ecore_main_loop_quit();
+}
+
+static void
+_combobox_expanded_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) {
+       is_expanded = EINA_TRUE;
+       printf("[Debug]:: %s[%d] : _combobox_expand_cb ", __FILE__, __LINE__);
+       ecore_main_loop_quit();
+}
+
+/**
+ * @add to group elm_combobox
+ * @{
+ * @defgroup elm_combobox_hover_begin();
+ *
+ * @precondition
+ * @step 1 Initialize Elementary
+ * @step 2 Create and show main window
+ * @step 3 Add a combobox to the main window
+ * @step 4 Add items in combobox
+ * @step 5 Register "expand" & "dismiss" callback of combobox
+ */
+static void
+setup(void) {
+       Evas_Object *bg;
+       Elm_Genlist_Item_Class *itc;
+       Evas_Object *bx;
+
+       elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
+
+       printf(" ============ Startup ============ \n");
+       elm_init(0, NULL);
+       main_win = elm_win_add(NULL, "main", ELM_WIN_BASIC);
+       if (main_win == NULL) {
+               return;
+       }
+
+       bx = elm_box_add(main_win);
+       evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       elm_win_resize_object_add(main_win, bx);
+       evas_object_show(bx);
+
+       combobox = elm_combobox_add(main_win);
+
+       if (combobox == NULL) {
+               return;
+       }
+       evas_object_size_hint_weight_set(combobox, EVAS_HINT_EXPAND, 0);
+       evas_object_size_hint_align_set(combobox, EVAS_HINT_FILL, 0);
+       elm_object_part_text_set(combobox, "guide", "A Simple list");
+       elm_box_pack_end(bx, combobox);
+       evas_object_show(combobox);
+
+       itc = elm_genlist_item_class_new();
+       itc->item_style = "default";
+       itc->func.text_get = gl_text_get;
+       itc->func.content_get = NULL;
+       itc->func.state_get = NULL;
+       itc->func.filter_get = NULL;
+       itc->func.del = NULL;
+
+       for (int i = 0; i < 2; i++)
+               elm_genlist_item_append(combobox, itc, (void *)(uintptr_t)i,
+                               NULL, ELM_GENLIST_ITEM_NONE, NULL, (void*)(uintptr_t)(i * 10));
+       evas_object_smart_callback_add(combobox, "dismissed",
+                               _combobox_dismissed_cb, NULL);
+       evas_object_smart_callback_add(combobox, "expanded",
+               _combobox_expanded_cb, NULL);
+
+       evas_object_show(main_win);
+}
+
+static void
+teardown(void) {
+       if (main_win != NULL) {
+               evas_object_del(main_win);
+               main_win = NULL;
+       }
+       elm_shutdown();
+       printf(" ============ Cleanup ============ \n");
+}
+
+static Eina_Bool
+_combobox_expand_state_cb(void *data) {
+       ecore_main_loop_quit();
+       return EINA_FALSE;
+}
+
+/**
+ * @add to group elm_combobox_hover_begin & elm_combobox_hover_end
+ * @{
+ * @objective Positive test case checks
+ *     1. whether function call to change the expanded state of the combobox works properly
+ *  2. whether function call to change the compress state of the combobox works properly
+ * @n Input Data: the combobox object
+ *
+ * @procedure
+ * @step 1 Call the elm_combobox_hover_begin() for the combobox to change the expanded state to expanded
+ * @step 2 Get the expanded state of the combobox
+ * @step 3 Call the elm_combobox_hover_end() for the combobox to change the expanded state to collapsed
+ * @step 4 Get the expanded state of the combobox
+ *
+ * @passcondition Test passes if returned values are the same as set values
+ * @}
+ */
+START_TEST(utc_elm_combobox_hover_begin_and_end_p) {
+       if (main_win == NULL || combobox == NULL) {
+               ck_abort_msg("[TEST_FAIL:: %s[%d] : Test has failed in precondition", __FILE__, __LINE__);
+               return;
+       }
+       elm_combobox_hover_begin(combobox);
+       ecore_main_loop_begin();
+
+       if (is_expanded == EINA_FALSE) {
+               ck_abort_msg("[TEST_FAIL]:: %s[%d] : elm_combobox_hover_begin() has failed", __FILE__, __LINE__);
+               return;
+       }
+       if (elm_combobox_expanded_get(combobox) == EINA_FALSE) {
+               ck_abort_msg("[TEST_FAIL]:: %s[%d] : elm_combobox_hover_begin() has failed", __FILE__, __LINE__);
+               return;
+       }
+
+       elm_combobox_hover_end(combobox);
+       ecore_main_loop_begin();
+
+       if (is_expanded == EINA_TRUE) {
+               ck_abort_msg("[TEST_FAIL]:: %s[%d] : elm_combobox_hover_end() has failed ...", __FILE__, __LINE__);
+               return;
+       }
+       if (elm_combobox_expanded_get(combobox) == EINA_TRUE) {
+               ck_abort_msg("[TEST_FAIL]:: %s[%d] : elm_combobox_hover_begin() has failed", __FILE__, __LINE__);
+               return;
+       }
+       printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
+}
+END_TEST
+
+/**
+ * @addtogroup elm_combobox_hover_begin
+ * @{
+ * @objective Negative test case checks whether function call with NULL instead of the combobox object
+ * works properly and without segmentation fault
+ * @n Input Data: NULL instead of the combobox object
+ *
+ * @procedure
+ * @step 1 Call function with NULL instead of the combobox object
+ *
+ * @passcondition Test passes if there is no segmentation fault
+ * @}
+ */
+START_TEST(utc_elm_combobox_hover_begin_n) {
+       UNITEST_FUNC_NEG(elm_combobox_hover_begin, NULL);
+       printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
+}
+END_TEST
+
+/**
+ * @addtogroup elm_combobox_hover_end
+ * @{
+ * @objective Negative test case checks whether function call with NULL instead of the combobox object
+ * works properly and without segmentation fault
+ * @n Input Data: NULL instead of the combobox object
+ *
+ * @procedure
+ * @step 1 Call function with NULL instead of the combobox object
+ *
+ * @passcondition Test passes if there is no segmentation fault
+ * @}
+ */
+START_TEST(utc_elm_combobox_hover_end_n) {
+       UNITEST_FUNC_NEG(elm_combobox_hover_end, NULL);
+       printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
+}
+END_TEST
+
+/**
+ * @}
+ */
+Suite *
+test_suite(void) {
+       Suite *suite = suite_create("utc_elm_combobox_hover_begin_and_end");
+
+       TCase *tcase = tcase_create("TCase");
+       tcase_set_timeout(tcase, 30);
+       tcase_add_checked_fixture(tcase, setup, teardown);
+       tcase_add_test(tcase, utc_elm_combobox_hover_begin_and_end_p);
+       tcase_add_test(tcase, utc_elm_combobox_hover_begin_n);
+       tcase_add_test(tcase, utc_elm_combobox_hover_end_n);
+       suite_add_tcase(suite, tcase);
+
+       return suite;
+}
+
+int
+main() {
+       int number_failed;
+
+       Suite *suite = test_suite();
+       SRunner *srunner = srunner_create(suite);
+       srunner_set_log(srunner, "utc_elm_combobox_hover_begin_and_end.log");
+       srunner_set_xml(srunner, "utc_elm_combobox_hover_begin_and_end.xml");
+       srunner_run_all(srunner, CK_NORMAL);
+       number_failed = srunner_ntests_failed(srunner);
+       srunner_free(srunner);
+
+       return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
index 3910d03817d2eedfca16c6833b2635e9cb02719c..0150e9a2cc0ff94fb6897f881007ac523f319593 100644 (file)
@@ -219,6 +219,7 @@ ELEMENTARY-build
 #/elementary/clock/tslist
 /elementary/cnp/tslist
 /elementary/colorselector/tslist
+/elementary/combobox/tslist
 /elementary/conformant/tslist
 /elementary/ctxpopup/tslist
 /elementary/datetime/tslist
@@ -492,6 +493,7 @@ ELEMENTARY-mobile
 #/elementary/clock/tslist_mobile
 /elementary/cnp/tslist_mobile
 /elementary/colorselector/tslist_mobile
+/elementary/combobox/tslist_mobile
 /elementary/conformant/tslist_mobile
 /elementary/ctxpopup/tslist_mobile
 /elementary/datetime/tslist_mobile
@@ -763,6 +765,7 @@ ELEMENTARY-wear
 #/elementary/clock/tslist_wear
 /elementary/cnp/tslist_wear
 #/elementary/colorselector/tslist_wear
+/elementary/combobox/tslist_wear
 /elementary/conformant/tslist_wear
 /elementary/ctxpopup/tslist_wear
 /elementary/datetime/tslist_wear
@@ -1034,6 +1037,7 @@ ELEMENTARY-tv
 #/elementary/clock/tslist_tv
 #/elementary/cnp/tslist_tv
 /elementary/colorselector/tslist_tv
+/elementary/combobox/tslist_tv
 /elementary/conformant/tslist_tv
 /elementary/ctxpopup/tslist_tv
 /elementary/datetime/tslist_tv