From: tasn Date: Thu, 23 Feb 2012 13:58:14 +0000 (+0000) Subject: elementary: Updated test_calendar.c to do API testing X-Git-Tag: REL_F_I9500_20120323_1~17^2~569 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d45eec5d389b24ae9b43d9a37d6a60f7efd27e9f;p=framework%2Fuifw%2Felementary.git elementary: Updated test_calendar.c to do API testing Signed-off-by: Aharon Hillel git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@68324 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/bin/test_calendar.c b/src/bin/test_calendar.c index c958e0e..246adb4 100644 --- a/src/bin/test_calendar.c +++ b/src/bin/test_calendar.c @@ -3,25 +3,162 @@ # include "elementary_config.h" #endif #ifndef ELM_LIB_QUICKLAUNCH +struct _api_data +{ + unsigned int state; /* What state we are testing */ + void *box; /* box used in set_api_state */ +}; +typedef struct _api_data api_data; + +enum _api_state +{ + STATE_MARK_MONTHLY, + STATE_MARK_WEEKLY, + STATE_SUNDAY_HIGHLIGHT, + STATE_SELECT_DATE_DISABLED_WITH_MARKS, + STATE_SELECT_DATE_DISABLED_NO_MARKS, + API_STATE_LAST +}; +typedef enum _api_state api_state; + +static void +set_api_state(api_data *api) +{ + const Eina_List *items = elm_box_children_get(api->box); + static Elm_Calendar_Mark *m = NULL; + if(!eina_list_count(items)) + return; + + switch(api->state) + { /* Put all api-changes under switch */ + case STATE_MARK_MONTHLY: + { + Evas_Object *cal = eina_list_nth(items, 0); + time_t sec_per_day = (60*60*24); + time_t sec_per_year = sec_per_day * 365; + time_t the_time = (sec_per_year * 41) + (sec_per_day * 9); /* Set date to DEC 31, 2010 */ + elm_calendar_min_max_year_set(cal, 2010, 2011); + m = elm_calendar_mark_add(cal, "checked", gmtime(&the_time), ELM_CALENDAR_MONTHLY); + elm_calendar_selected_time_set(cal, gmtime(&the_time)); + } + break; + case STATE_MARK_WEEKLY: + { + Evas_Object *cal = eina_list_nth(items, 0); + time_t sec_per_day = (60*60*24); + time_t sec_per_year = sec_per_day * 365; + time_t the_time = (sec_per_year * 41) + (sec_per_day * 4); /* Set date to DEC 26, 2010 */ + elm_calendar_mark_del(m); + m = elm_calendar_mark_add(cal, "checked", gmtime(&the_time), ELM_CALENDAR_WEEKLY); + elm_calendar_selected_time_set(cal, gmtime(&the_time)); + } + break; + case STATE_SUNDAY_HIGHLIGHT: + { + Evas_Object *cal = eina_list_nth(items, 0); + time_t sec_per_day = (60*60*24); + time_t sec_per_year = sec_per_day * 365; + time_t the_time = (sec_per_year * 41) + (sec_per_day * 3); /* Set date to DEC 25, 2010 */ + /* elm_calendar_mark_del(m); */ + m = elm_calendar_mark_add(cal, "holiday", gmtime(&the_time), ELM_CALENDAR_WEEKLY); + elm_calendar_selected_time_set(cal, gmtime(&the_time)); + } + break; + case STATE_SELECT_DATE_DISABLED_WITH_MARKS: + { + Evas_Object *cal = eina_list_nth(items, 0); + time_t sec_per_day = (60*60*24); + time_t sec_per_year = sec_per_day * 365; + time_t the_time = (sec_per_year * 41) + (sec_per_day * 10); /* Set date to JAN 01, 2011 */ + elm_calendar_day_selection_enabled_set(cal, EINA_FALSE); + elm_calendar_selected_time_set(cal, gmtime(&the_time)); + } + break; + case STATE_SELECT_DATE_DISABLED_NO_MARKS: + { + Evas_Object *cal = eina_list_nth(items, 0); + time_t sec_per_day = (60*60*24); + time_t sec_per_year = sec_per_day * 365; + time_t the_time = (sec_per_year * 41) + (sec_per_day * 40); /* Set date to FEB 01, 2011 */ + elm_calendar_marks_clear(cal); + elm_calendar_day_selection_enabled_set(cal, EINA_FALSE); + elm_calendar_selected_time_set(cal, gmtime(&the_time)); + } + break; + case API_STATE_LAST: + break; + default: + return; + } +} + +static void +_api_bt_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__) +{ /* Will add here a SWITCH command containing code to modify test-object */ + /* in accordance a->state value. */ + api_data *a = data; + char str[128]; + + printf("clicked event on API Button: api_state=<%d>\n", a->state); + set_api_state(a); + a->state++; + sprintf(str, "Next API function (%u)", a->state); + elm_object_text_set(obj, str); + elm_object_disabled_set(obj, a->state == API_STATE_LAST); +} + +static void +_cleanup_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + free(data); +} /* A simple test, just displaying calendar in it's default state */ void test_calendar(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - Evas_Object *win, *bg, *cal; + Evas_Object *win, *bg, *cal, *bx, *bxx, *bt; + api_data *api = calloc(1, sizeof(api_data)); win = elm_win_add(NULL, "calendar", ELM_WIN_BASIC); elm_win_title_set(win, "Calendar"); elm_win_autodel_set(win, EINA_TRUE); + evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api); bg = elm_bg_add(win); elm_win_resize_object_add(win, bg); evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_show(bg); + bxx = elm_box_add(win); + elm_win_resize_object_add(win, bxx); + evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_show(bxx); + + bx = elm_box_add(win); + evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + api->box = bx; + evas_object_show(bx); + + bt = elm_button_add(win); + elm_object_text_set(bt, "Next API function"); + evas_object_smart_callback_add(bt, "clicked", _api_bt_clicked, (void *) api); + elm_box_pack_end(bxx, bt); + elm_object_disabled_set(bt, api->state == API_STATE_LAST); + evas_object_show(bt); + + elm_box_pack_end(bxx, bx); + cal = elm_calendar_add(win); - elm_win_resize_object_add(win, cal); evas_object_size_hint_weight_set(cal, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_box_pack_end(bx, cal); + + time_t sec_per_day = (60*60*24); + time_t sec_per_year = sec_per_day * 365; + time_t the_time = (sec_per_year * 41) + (sec_per_day * 9); /* Set date to DEC 31, 2010 */ + elm_calendar_selected_time_set(cal, gmtime(&the_time)); + elm_calendar_min_max_year_set(cal, 2010, 2012); + evas_object_show(cal); evas_object_show(win);