summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorDaniel Juyung Seo <seojuyung2@gmail.com>2013-11-13 17:03:49 +0900
committerDaniel Juyung Seo <seojuyung2@gmail.com>2013-11-13 17:07:15 +0900
commit5101cb93f8e83135f9446a7f6047424881db7d5f (patch)
treeda4791e2bde60c25674fb0971c0f6c1543f7945f /src/bin
parent0a871e1864cded8f1b1bb5cfa27b3f3a3d7b4daa (diff)
test_genlist.c: added "genlist del" example to reveal more genlist issues.
This example tests the following cases on item selection. 1. genlist item deletion 2. genlist clear and item append 3. genlist del
Diffstat (limited to 'src/bin')
-rwxr-xr-xsrc/bin/test.c2
-rw-r--r--src/bin/test_genlist.c129
2 files changed, 131 insertions, 0 deletions
diff --git a/src/bin/test.c b/src/bin/test.c
index 340d03828..6a54dad8a 100755
--- a/src/bin/test.c
+++ b/src/bin/test.c
@@ -111,6 +111,7 @@ void test_genlist19(void *data, Evas_Object *obj, void *event_info);
111void test_genlist20(void *data, Evas_Object *obj, void *event_info); 111void test_genlist20(void *data, Evas_Object *obj, void *event_info);
112void test_genlist_item_styles(void *data, Evas_Object *obj, void *event_info); 112void test_genlist_item_styles(void *data, Evas_Object *obj, void *event_info);
113void test_genlist_multi_select(void *data, Evas_Object *obj, void *event_info); 113void test_genlist_multi_select(void *data, Evas_Object *obj, void *event_info);
114void test_genlist_del(void *data, Evas_Object *obj, void *event_info);
114void test_gesture_layer(void *data, Evas_Object *obj, void *event_info); 115void test_gesture_layer(void *data, Evas_Object *obj, void *event_info);
115void test_gesture_layer2(void *data, Evas_Object *obj, void *event_info); 116void test_gesture_layer2(void *data, Evas_Object *obj, void *event_info);
116void test_gesture_layer3(void *data, Evas_Object *obj, void *event_info); 117void test_gesture_layer3(void *data, Evas_Object *obj, void *event_info);
@@ -664,6 +665,7 @@ add_tests:
664 ADD_TEST(NULL, "Lists - Genlist", "Genlist Focus", test_genlist20); 665 ADD_TEST(NULL, "Lists - Genlist", "Genlist Focus", test_genlist20);
665 ADD_TEST(NULL, "Lists - Genlist", "Genlist Item Styles", test_genlist_item_styles); 666 ADD_TEST(NULL, "Lists - Genlist", "Genlist Item Styles", test_genlist_item_styles);
666 ADD_TEST(NULL, "Lists - Genlist", "Genlist Multi Select", test_genlist_multi_select); 667 ADD_TEST(NULL, "Lists - Genlist", "Genlist Multi Select", test_genlist_multi_select);
668 ADD_TEST(NULL, "Lists - Genlist", "Genlist Del", test_genlist_del);
667 669
668 //------------------------------// 670 //------------------------------//
669 671
diff --git a/src/bin/test_genlist.c b/src/bin/test_genlist.c
index dd56103e9..96396143b 100644
--- a/src/bin/test_genlist.c
+++ b/src/bin/test_genlist.c
@@ -3630,3 +3630,132 @@ test_genlist_multi_select(void *data EINA_UNUSED,
3630 } 3630 }
3631 elm_genlist_item_class_free(itc); 3631 elm_genlist_item_class_free(itc);
3632} 3632}
3633
3634/* test genlist deletion */
3635
3636static void _gl_del_sel(void *data, Evas_Object *obj, void *event_info);
3637
3638static void
3639_gl_del_win_del_cb(void *data, Evas *e EINA_UNUSED,
3640 Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
3641{
3642 if (!data) return;
3643 elm_genlist_item_class_free(data);
3644}
3645
3646static Evas_Object *
3647_gl_del_genlist_add(Evas_Object *bx)
3648{
3649 Evas_Object *gl = NULL;
3650
3651 gl = elm_genlist_add(bx);
3652 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3653 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
3654 elm_box_pack_end(bx, gl);
3655 evas_object_show(gl);
3656
3657 return gl;
3658}
3659
3660static void
3661_gl_del_item_append(Evas_Object *gl, Elm_Genlist_Item_Class *itc)
3662{
3663 int i = 0;
3664 for (i = 0; i < 1000; i++)
3665 {
3666 elm_genlist_item_append(gl, itc,
3667 (void *)(uintptr_t)i/* item data */,
3668 NULL/* parent */,
3669 ELM_GENLIST_ITEM_NONE,
3670 _gl_del_sel/* func */,
3671 (void *)(uintptr_t)(i)/* func data */);
3672 }
3673}
3674
3675char *_gl_del_text_get(void *data, Evas_Object *obj EINA_UNUSED,
3676 const char *part EINA_UNUSED)
3677{
3678 char buf[256] = { 0 };
3679 int num = (int)(uintptr_t)data;
3680 int num_category = num % 3;
3681
3682 if (num_category == 0)
3683 snprintf(buf, sizeof(buf), "Item # %i - Item Del", num);
3684 else if (num_category == 1)
3685 snprintf(buf, sizeof(buf), "Item # %i - Genlist Clear and Item Append",
3686 num);
3687 else if (num_category == 2)
3688 snprintf(buf, sizeof(buf), "Item # %i - Genlist Del", num);
3689
3690 return strdup(buf);
3691}
3692
3693static void
3694_gl_del_sel(void *data, Evas_Object *obj, void *event_info)
3695{
3696 int num = (int)(uintptr_t)data;
3697 int num_category = num % 3;
3698 Elm_Object_Item *it = event_info;
3699 Elm_Genlist_Item_Class *itc =
3700 (Elm_Genlist_Item_Class *)elm_genlist_item_item_class_get(it);
3701
3702 if (num_category == 0)
3703 elm_object_item_del(it);
3704 else if (num_category == 1)
3705 {
3706 elm_genlist_clear(obj);
3707 _gl_del_item_append(elm_object_item_widget_get(it), itc);
3708 }
3709 else if (num_category == 2)
3710 {
3711 evas_object_del(obj);
3712 }
3713}
3714
3715void
3716test_genlist_del(void *data EINA_UNUSED,
3717 Evas_Object *obj EINA_UNUSED,
3718 void *event_info EINA_UNUSED)
3719{
3720 Evas_Object *win, *bx, *fr, *lb, *gl;
3721 Elm_Genlist_Item_Class *itc = NULL;
3722
3723 win = elm_win_util_standard_add("genlist-del", "Genlist Del");
3724 elm_win_autodel_set(win, EINA_TRUE);
3725 evas_object_resize(win, 320, 500);
3726 evas_object_show(win);
3727
3728 bx = elm_box_add(win);
3729 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3730 elm_win_resize_object_add(win, bx);
3731 elm_box_align_set(bx, 0.5, 0.0);
3732 evas_object_show(bx);
3733
3734 fr = elm_frame_add(bx);
3735 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, 0.0);
3736 evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
3737 elm_object_text_set(fr, "Information");
3738 elm_box_pack_end(bx, fr);
3739 evas_object_show(fr);
3740
3741 lb = elm_label_add(fr);
3742 elm_object_text_set(lb, "<align=left>This example tests the following cases"
3743 " on item selection.<br/>"
3744 " 1. genlist item deletion<br/>"
3745 " 2. genlist clear and item append<br/>"
3746 " 3. genlist del</align>");
3747 elm_object_content_set(fr, lb);
3748 evas_object_show(lb);
3749
3750 itc = elm_genlist_item_class_new();
3751 itc->item_style = "default";
3752 itc->func.text_get = _gl_del_text_get;
3753 itc->func.content_get = gl_content_get;
3754 itc->func.state_get = NULL;
3755 itc->func.del = NULL;
3756 evas_object_event_callback_add(win, EVAS_CALLBACK_DEL,
3757 _gl_del_win_del_cb, itc);
3758
3759 gl = _gl_del_genlist_add(bx);
3760 _gl_del_item_append(gl, itc);
3761}