Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / tests / eail_datetime_tc1.c
1 /*
2  * Tested interface: AtkObject
3  *
4  * Tested AtkObject: EailDatetime
5  *
6  * Description: Test AtkObject interface
7  *
8  * Test input: accessible object representing EailDatetime
9  *
10  * Expected test result: test should return 0 (success)
11  */
12
13 #include <Elementary.h>
14 #include <atk/atk.h>
15
16 #include "eail_test_utils.h"
17
18 static time_t time_min, time_max, time_current;
19
20 INIT_TEST("EailDatetime")
21
22 static void
23 _changed_cb(void *data, Evas_Object *obj, void *event_info)
24 {
25    _printf("action: changed\n");
26 }
27
28 static void
29 _printf_datetime_int(time_t atime, const char *str)
30 {
31    struct tm tmp;
32
33    localtime_r(&atime, &tmp);
34
35    _printf("[%04d-%02d-%02d] [%02d:%02d:%02d] (%s)\n",
36            tmp.tm_year + 1900, tmp.tm_mon + 1, tmp.tm_mday,
37            tmp.tm_hour, tmp.tm_min, tmp.tm_sec, str);
38 }
39
40 static void
41 _init_datetime(Evas_Object *win)
42 {
43    Evas_Object *bg, *bx, *dt;
44    struct tm tmp;
45
46    bg = elm_bg_add(win);
47    elm_win_resize_object_add(win, bg);
48    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
49    evas_object_show(bg);
50
51    bx = elm_box_add(win);
52    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
53    elm_win_resize_object_add(win, bx);
54    elm_box_horizontal_set(bx, EINA_FALSE);
55    evas_object_show(bx);
56
57    dt = elm_datetime_add(bx);
58    evas_object_size_hint_weight_set(dt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
59    evas_object_size_hint_align_set(dt, EVAS_HINT_FILL, 0.5);
60    evas_object_smart_callback_add(dt, "changed", _changed_cb, NULL);
61
62    time_min = time(NULL) - 3600;
63    localtime_r(&time_min, &tmp);
64    elm_datetime_value_min_set(dt, &tmp);
65    _printf_datetime_int(time_min, "time_min");
66
67    time_max = time(NULL) + 3600;
68    localtime_r(&time_max, &tmp);
69    elm_datetime_value_max_set(dt, &tmp);
70    _printf_datetime_int(time_max, "time_max");
71
72    time_current = time(NULL);
73    localtime_r(&time_current, &tmp);
74    elm_datetime_value_set(dt, &tmp);
75    _printf_datetime_int(time_current, "time_current");
76
77    elm_box_pack_end(bx, dt);
78    evas_object_show(dt);
79 }
80
81 static void
82 _do_test(AtkObject *obj)
83 {
84    g_assert(ATK_IS_OBJECT(obj));
85    g_assert(atk_object_get_role(obj) == ATK_ROLE_DATE_EDITOR);
86
87    atk_object_set_description(obj, "test");
88    g_assert_cmpstr(atk_object_get_description(obj), ==, "test");
89
90    atk_object_set_name(obj, "test name");
91    g_assert_cmpstr(atk_object_get_name(obj), ==, "test name");
92
93    eailu_test_code_called = 1;
94 }
95
96 EAPI_MAIN int
97 elm_main(int argc, char **argv)
98 {
99    Evas_Object *win;
100
101    win = eailu_create_test_window_with_glib_init(NULL, _on_focus_in);
102    g_assert(win);
103    _init_datetime(win);
104
105    evas_object_show(win);
106    elm_run();
107    elm_shutdown();
108
109    return 0;
110 }
111 ELM_MAIN()