1 #include <Elementary.h>
6 #include "eail_test_utils.h"
8 static int year_limit_min = 2000;
9 static int year_limit_max = 2030;
12 _printf_calendar_int(const char *str, time_t atime)
16 localtime_r(&atime, &tmp);
18 _printf("[%04d-%02d-%02d] (%s)\n",
19 tmp.tm_year + 1900, tmp.tm_mon + 1, tmp.tm_mday, str);
27 memset(&minimum, 0, sizeof(minimum));
29 minimum.tm_year = year - 1900;
36 return mktime(&minimum);
40 _val_date_cmp(time_t time1, time_t time2)
44 localtime_r(&time1, &tmp1);
45 localtime_r(&time2, &tmp2);
47 if (tmp1.tm_year == tmp2.tm_year &&
48 tmp1.tm_mon == tmp2.tm_mon &&
49 tmp1.tm_mday == tmp2.tm_mday)
64 memset(&maximum, 0, sizeof(maximum));
66 maximum.tm_year = year - 1900;
73 return mktime(&maximum);
77 _init_calendar(Evas_Object *win)
79 Evas_Object *bg, *cal;
82 elm_win_resize_object_add(win, bg);
83 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
86 cal = elm_calendar_add(win);
87 elm_calendar_min_max_year_set(cal, year_limit_min, year_limit_max);
88 elm_win_resize_object_add(win, cal);
89 evas_object_size_hint_weight_set(cal, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
90 evas_object_show(cal);
94 _do_test(AtkObject *obj)
96 const char *type_name = g_type_name(G_TYPE_FROM_INSTANCE(obj));
97 int minimum, maximum, current, minimum_increment;
98 struct tm val_test_set;
100 _printf("type_name: %s\n", type_name ? type_name : "NULL");
102 g_assert_cmpstr(type_name, ==, "EailCalendar");
104 GValue value = G_VALUE_INIT;
106 atk_value_get_minimum_value(ATK_VALUE(obj), &value);
107 minimum = g_value_get_int(&value);
108 _printf_calendar_int("atk_value_get_minimum_value", minimum);
109 g_assert(_val_min(year_limit_min) == minimum);
111 atk_value_get_maximum_value(ATK_VALUE(obj), &value);
112 maximum = g_value_get_int(&value);
113 _printf_calendar_int("atk_value_get_maximum_value", maximum);
114 g_assert(_val_max(year_limit_max) == maximum);
116 atk_value_get_current_value(ATK_VALUE(obj), &value);
117 current = g_value_get_int(&value);
118 _printf_calendar_int("atk_value_get_current_value", current);
119 g_assert(_val_date_cmp(time(NULL), current));
121 atk_value_get_minimum_increment(ATK_VALUE(obj), &value);
122 minimum_increment = g_value_get_int(&value);
123 _printf_calendar_int("atk_value_get_minimum_increment", minimum_increment);
124 g_assert(1 == minimum_increment);
126 memset(&val_test_set, 0, sizeof(val_test_set));
127 val_test_set.tm_year = 120; // 120 + 1900 = 2020 years
128 val_test_set.tm_mon = 2;
129 val_test_set.tm_mday = 15;
130 val_test_set.tm_hour = 7;
131 val_test_set.tm_min = 21;
132 val_test_set.tm_sec = 33;
134 g_value_set_int(&value, mktime(&val_test_set));
135 g_assert(atk_value_set_current_value(ATK_VALUE(obj), &value));
136 _printf_calendar_int("atk_value_set_current_value", mktime(&val_test_set));
138 atk_value_get_current_value(ATK_VALUE(obj), &value);
139 current = g_value_get_int(&value);
140 _printf_calendar_int("atk_value_get_current_value", current);
141 g_assert(_val_date_cmp(mktime(&val_test_set), current));
143 val_test_set.tm_year = 99; // 99 + 1900 = 1999 years
144 g_value_set_int(&value, mktime(&val_test_set));
145 g_assert(!atk_value_set_current_value(ATK_VALUE(obj), &value));
147 val_test_set.tm_year = 131; // 131 + 1900 = 2031 years
148 g_value_set_int(&value, mktime(&val_test_set));
149 g_assert(!atk_value_set_current_value(ATK_VALUE(obj), &value));
151 /* calendar object to support focus */
152 eailu_test_atk_focus(obj, TRUE);
156 _on_done(void *data, Evas_Object *obj, void *event_info)
162 _on_focus_in(void *data, Evas_Object *obj, void *event_info)
164 AtkObject *aobj = atk_get_root();
167 eailu_traverse_children_for_role_call_cb(aobj, ATK_ROLE_CALENDAR, _do_test);
169 _on_done(NULL, obj, NULL);
173 elm_main(int argc, char **argv)
177 win = eailu_create_test_window_with_glib_init(_on_done, _on_focus_in);
180 evas_object_show(win);