2 * Tested interface: AtkValue
4 * Tested AtkObject: EailClock
6 * Description: Test AtkValue interface
8 * Test input: accessible object representing EailClock
10 * Expected test result: test should return 0 (success)
13 #include <Elementary.h>
15 #include "eail_test_utils.h"
17 INIT_TEST("EailClock")
20 _printf_clock_int(const char *str, int current_second_day)
22 int hour, minute, second;
24 hour = current_second_day / 3600;
25 minute = (current_second_day % 3600) / 60;
26 second = current_second_day % 60;
28 _printf("[%02d:%02d:%02d] (%s)\n", hour, minute, second, str);
32 _do_test(AtkObject *obj)
34 int minimum, maximum, current, minimum_increment;
35 const int lambda = 5; /*tolerance for get time in case that test will take
36 longer than expected on very slow machine*/
37 const int val_test_init = 4 * 3600 + 44 * 60 + 22; // 04:44:22
38 const int val_test_set = 12 * 3600 + 4 * 60 + 7; // 12:04:07
40 g_assert(atk_object_get_role(obj) == ATK_ROLE_TEXT);
42 GValue value = G_VALUE_INIT;
44 atk_value_get_minimum_value(ATK_VALUE(obj), &value);
45 minimum = g_value_get_int(&value);
46 _printf_clock_int("atk_value_get_minimum_value", minimum);
47 g_assert(0 == minimum);
49 atk_value_get_maximum_value(ATK_VALUE(obj), &value);
50 maximum = g_value_get_int(&value);
51 _printf_clock_int("atk_value_get_maximum_value", maximum);
52 g_assert((24 * 3600 - 1) == maximum);
54 atk_value_get_current_value(ATK_VALUE(obj), &value);
55 current = g_value_get_int(&value);
56 _printf_clock_int("atk_value_get_current_value", current);
57 g_assert(abs(current - val_test_init) < lambda);
59 atk_value_get_minimum_increment(ATK_VALUE(obj), &value);
60 minimum_increment = g_value_get_int(&value);
61 _printf_clock_int("atk_value_get_minimum_increment", minimum_increment);
62 g_assert(1 == minimum_increment);
64 g_value_set_int(&value, val_test_set);
65 g_assert(atk_value_set_current_value(ATK_VALUE(obj), &value));
66 _printf_clock_int("atk_value_set_current_value", val_test_set);
68 atk_value_get_current_value(ATK_VALUE(obj), &value);
69 current = g_value_get_int(&value);
70 _printf_clock_int("atk_value_get_current_value", current);
71 g_assert(abs(current - val_test_set) < lambda);
73 g_value_set_int(&value, 24 * 3600);
74 g_assert(!atk_value_set_current_value(ATK_VALUE(obj), &value));
76 eailu_test_code_called = 1;
80 _init_clock(Evas_Object *win)
82 Evas_Object *bg, *bx, *cl;
85 elm_win_resize_object_add(win, bg);
86 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
89 bx = elm_box_add(win);
90 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
91 elm_win_resize_object_add(win, bx);
94 cl = elm_clock_add(win);
95 elm_clock_show_seconds_set(cl, EINA_TRUE);
96 elm_box_pack_end(bx, cl);
97 elm_clock_time_set(cl, 4, 44, 22);
102 elm_main(int argc, char **argv)
106 win = eailu_create_test_window_with_glib_init(_on_done, _on_focus_in);
109 evas_object_show(win);