Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / tests / eail_datetime_tc2.c
1 /*
2  * Tested interface: AtkValue
3  *
4  * Tested AtkObject: EailDatetime
5  *
6  * Description: Test AtkValue 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 #include "eail_test_utils.h"
16
17 static time_t time_min, time_max, time_current;
18
19 INIT_TEST("EailDatetime")
20
21 static void
22 _init_datetime(Evas_Object *win)
23 {
24    Evas_Object *bg, *bx, *dt;
25    struct tm tmp;
26
27    bg = elm_bg_add(win);
28    elm_win_resize_object_add(win, bg);
29    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
30    evas_object_show(bg);
31
32    bx = elm_box_add(win);
33    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
34    elm_win_resize_object_add(win, bx);
35    elm_box_horizontal_set(bx, EINA_FALSE);
36    evas_object_show(bx);
37
38    dt = elm_datetime_add(bx);
39    evas_object_size_hint_weight_set(dt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
40    evas_object_size_hint_align_set(dt, EVAS_HINT_FILL, 0.5);
41
42    time_min = time(NULL) - 3600;
43    localtime_r(&time_min, &tmp);
44    elm_datetime_value_min_set(dt, &tmp);
45
46    time_max = time(NULL) + 3600;
47    localtime_r(&time_max, &tmp);
48    elm_datetime_value_max_set(dt, &tmp);
49
50    time_current = time(NULL);
51    localtime_r(&time_current, &tmp);
52    elm_datetime_value_set(dt, &tmp);
53
54    elm_box_pack_end(bx, dt);
55    evas_object_show(dt);
56 }
57
58 static void
59 _do_test(AtkObject *obj)
60 {
61    time_t time_set;
62
63    g_assert(ATK_IS_VALUE(obj));
64
65    GValue value = G_VALUE_INIT;
66
67    atk_value_get_minimum_value(ATK_VALUE(obj), &value);
68    g_assert(g_value_get_int(&value) == time_min);
69
70    atk_value_get_maximum_value(ATK_VALUE(obj), &value);
71    g_assert(g_value_get_int(&value) == time_max);
72
73    atk_value_get_current_value(ATK_VALUE(obj), &value);
74    g_assert(g_value_get_int(&value) == time_current);
75
76    atk_value_get_minimum_increment(ATK_VALUE(obj), &value);
77    g_assert(g_value_get_int(&value) == 1);
78
79    time_set = time_current + 60;
80
81    g_value_set_int(&value, time_set);
82
83    atk_value_get_current_value(ATK_VALUE(obj), &value);
84    g_assert(g_value_get_int(&value) != time_set);
85
86    eailu_test_code_called = 1;
87 }
88
89 EAPI_MAIN int
90 elm_main(int argc, char **argv)
91 {
92    Evas_Object *win;
93
94    win = eailu_create_test_window_with_glib_init(_on_done, _on_focus_in);
95    g_assert(win);
96    _init_datetime(win);
97    evas_object_show(win);
98    elm_run();
99    elm_shutdown();
100
101    return 0;
102 }
103 ELM_MAIN()