aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYeongjong Lee <yj34.lee@samsung.com>2019-03-11 00:59:07 +0000
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-03-11 21:23:51 +0100
commit0838c1af6351d2be6164f5f07c06f5de08a8179b (patch)
tree5a2d04de327c197aee92d4918b1e9296463b883e
parentefl_ui_widget: mark some oversawn event as beta (diff)
downloadefl-0838c1af6351d2be6164f5f07c06f5de08a8179b.tar.gz
ui.widget: add exception handling code and unit test of sub_object_add/del function
Add missing exception check code with unit test. Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D8282
-rw-r--r--src/lib/elementary/efl_ui_widget.c3
-rw-r--r--src/tests/elementary/efl_ui_test_widget.c17
2 files changed, 20 insertions, 0 deletions
diff --git a/src/lib/elementary/efl_ui_widget.c b/src/lib/elementary/efl_ui_widget.c
index ed959eb479..acab4f32f5 100644
--- a/src/lib/elementary/efl_ui_widget.c
+++ b/src/lib/elementary/efl_ui_widget.c
@@ -1460,6 +1460,9 @@ _efl_ui_widget_widget_sub_object_add(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Ob
{
Efl_Ui_Widget *parent;
+ if (!sobj) return EINA_FALSE;
+ EINA_SAFETY_ON_TRUE_RETURN_VAL(obj == sobj, EINA_FALSE);
+
//first make sure that we unregister the sobj from the parent
if (elm_widget_is(sobj))
parent = efl_ui_widget_parent_get(sobj);
diff --git a/src/tests/elementary/efl_ui_test_widget.c b/src/tests/elementary/efl_ui_test_widget.c
index ad1a60fa0e..d5f9c4d525 100644
--- a/src/tests/elementary/efl_ui_test_widget.c
+++ b/src/tests/elementary/efl_ui_test_widget.c
@@ -172,6 +172,22 @@ EFL_START_TEST(efl_ui_test_widget_sub_iterator)
}
EFL_END_TEST
+EFL_START_TEST(efl_ui_test_widget_sub_object_add_del)
+{
+ State s;
+
+ _small_ui(&s);
+ ck_assert(!efl_ui_widget_sub_object_add(s.btn1, s.btn1));
+ ck_assert(efl_ui_widget_sub_object_add(s.box, s.btn1));
+ ck_assert(!efl_ui_widget_sub_object_add(s.box, NULL));
+
+ ck_assert(!efl_ui_widget_sub_object_del(s.btn1, s.btn1));
+ ck_assert(!efl_ui_widget_sub_object_del(s.box, NULL));
+ ck_assert(!efl_ui_widget_sub_object_del(s.btn1, s.box));
+ ck_assert(efl_ui_widget_sub_object_del(s.box, s.btn1));
+}
+EFL_END_TEST
+
void efl_ui_test_widget(TCase *tc)
{
tcase_add_test(tc, efl_ui_test_widget_parent_iterator);
@@ -179,4 +195,5 @@ void efl_ui_test_widget(TCase *tc)
tcase_add_test(tc, efl_ui_test_widget_widget_sub_iterator);
tcase_add_test(tc, efl_ui_test_widget_iterator);
tcase_add_test(tc, efl_ui_test_widget_sub_iterator);
+ tcase_add_test(tc, efl_ui_test_widget_sub_object_add_del);
}