2 * Tested interface: AtkValue
4 * Tested AtkObject: EailCalendar
6 * Description: Test AtkValue interface
8 * Test input: accessible object representing EailCalendar
10 * Expected test result: test should return 0 (success)
13 #include <Elementary.h>
16 #include "eail_test_utils.h"
18 INIT_TEST("EailCalendar")
20 static int year_limit_min = 2000;
21 static int year_limit_max = 2030;
24 _printf_calendar_int(const char *str, time_t atime)
28 localtime_r(&atime, &tmp);
30 _printf("[%04d-%02d-%02d] (%s)\n",
31 tmp.tm_year + 1900, tmp.tm_mon + 1, tmp.tm_mday, str);
39 memset(&minimum, 0, sizeof(minimum));
41 minimum.tm_year = year - 1900;
48 return mktime(&minimum);
52 _val_date_cmp(time_t time1, time_t time2)
56 localtime_r(&time1, &tmp1);
57 localtime_r(&time2, &tmp2);
59 if (tmp1.tm_year == tmp2.tm_year &&
60 tmp1.tm_mon == tmp2.tm_mon &&
61 tmp1.tm_mday == tmp2.tm_mday)
76 memset(&maximum, 0, sizeof(maximum));
78 maximum.tm_year = year - 1900;
85 return mktime(&maximum);
89 _init_calendar(Evas_Object *win)
91 Evas_Object *bg, *cal;
94 elm_win_resize_object_add(win, bg);
95 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
98 cal = elm_calendar_add(win);
99 elm_calendar_min_max_year_set(cal, year_limit_min, year_limit_max);
100 elm_win_resize_object_add(win, cal);
101 evas_object_size_hint_weight_set(cal, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
102 evas_object_show(cal);
106 _do_test(AtkObject *obj)
108 int minimum, maximum, current, minimum_increment;
109 struct tm val_test_set;
111 g_assert(ATK_IS_VALUE(obj));
113 GValue value = G_VALUE_INIT;
115 atk_value_get_minimum_value(ATK_VALUE(obj), &value);
116 minimum = g_value_get_int(&value);
117 _printf_calendar_int("atk_value_get_minimum_value", minimum);
118 g_assert(_val_min(year_limit_min) == minimum);
120 atk_value_get_maximum_value(ATK_VALUE(obj), &value);
121 maximum = g_value_get_int(&value);
122 _printf_calendar_int("atk_value_get_maximum_value", maximum);
123 g_assert(_val_max(year_limit_max) == maximum);
125 atk_value_get_current_value(ATK_VALUE(obj), &value);
126 current = g_value_get_int(&value);
127 _printf_calendar_int("atk_value_get_current_value", current);
128 g_assert(_val_date_cmp(time(NULL), current));
130 atk_value_get_minimum_increment(ATK_VALUE(obj), &value);
131 minimum_increment = g_value_get_int(&value);
132 _printf_calendar_int("atk_value_get_minimum_increment", minimum_increment);
133 g_assert(1 == minimum_increment);
135 memset(&val_test_set, 0, sizeof(val_test_set));
136 val_test_set.tm_year = 120; // 120 + 1900 = 2020 years
137 val_test_set.tm_mon = 2;
138 val_test_set.tm_mday = 15;
139 val_test_set.tm_hour = 7;
140 val_test_set.tm_min = 21;
141 val_test_set.tm_sec = 33;
143 g_value_set_int(&value, mktime(&val_test_set));
144 g_assert(atk_value_set_current_value(ATK_VALUE(obj), &value));
145 _printf_calendar_int("atk_value_set_current_value", mktime(&val_test_set));
147 atk_value_get_current_value(ATK_VALUE(obj), &value);
148 current = g_value_get_int(&value);
149 _printf_calendar_int("atk_value_get_current_value", current);
150 g_assert(_val_date_cmp(mktime(&val_test_set), current));
152 val_test_set.tm_year = 99; // 99 + 1900 = 1999 years
153 g_value_set_int(&value, mktime(&val_test_set));
154 g_assert(!atk_value_set_current_value(ATK_VALUE(obj), &value));
156 val_test_set.tm_year = 131; // 131 + 1900 = 2031 years
157 g_value_set_int(&value, mktime(&val_test_set));
158 g_assert(!atk_value_set_current_value(ATK_VALUE(obj), &value));
160 eailu_test_code_called = 1;
164 elm_main(int argc, char **argv)
168 win = eailu_create_test_window_with_glib_init(_on_done, _on_focus_in);
171 evas_object_show(win);