Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / tests / eail_test_utils.h
1 #ifndef EAIL_TEST_UTILS_H_
2 #define EAIL_TEST_UTILS_H_
3
4 #include <atk/atk.h>
5 #include <Elementary.h>
6
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10
11 #define float_epsilon 0.00001
12 #define float_equal(a,b) (fabs((a) - (b)) < float_epsilon)
13
14 #define INIT_TEST(type_name) \
15     static int eailu_test_code_called; \
16     static void _on_done(void *data, Evas_Object *obj, void *event_info) \
17        { \
18           elm_exit(); \
19        } \
20      static void _do_test(AtkObject *obj); \
21      static void _on_focus_in(void *data, Evas_Object *obj, void *event_info) \
22        { \
23             AtkObject *aobj = atk_get_root(); \
24             g_assert(aobj); \
25             eailu_traverse_children_for_type_call_cb( \
26                 aobj, type_name, _do_test); \
27             g_assert(eailu_test_code_called); \
28             _on_done(NULL, NULL, NULL); \
29        }
30
31 typedef void(* Eailu_Test_Func_Cb)(AtkObject *obj);
32
33 /**
34  * Checks is AktObject has given type name
35  */
36 gboolean eailu_is_object_with_type(AtkObject *obj, gchar *type_name);
37
38 /**
39  * Checks if AtkObject has given object name
40  */
41 gboolean eailu_is_object_with_name(AtkObject *obj, gchar *name);
42
43 /**
44  * Checks if AtkObject has given atk role (AtkRole enum)
45  */
46 gboolean eailu_is_object_with_role(AtkObject *obj, AtkRole role);
47
48 /**
49  * Goes for every child in objects hierarchy looking for given type_name.
50  * If given type has been found, then test_cb callback is called on it.
51  *
52  * @param obj Object to iterate on
53  * @param type_Name string representing type or NULL if all objects should
54  * be processed
55  * @param test_cb Callback to test function which will be performed on every
56  * matched object
57  */
58 void eailu_traverse_children_for_type_call_cb(AtkObject *obj,
59                                               gchar *type_name,
60                                               Eailu_Test_Func_Cb test_cb);
61
62 /**
63  * Goes for every child in objects hierarchy looking for given atk role.
64  * If given type has been found, then test_cb callback is called on it.
65  *
66  * @param obj Object to iterate on
67  * @param role representing atk role (AtkRole enum)
68  * @param test_cb Callback to test function which will be performed on every
69  * matched object
70  */
71 void eailu_traverse_children_for_role_call_cb(AtkObject *obj,
72                                               AtkRole role,
73                                               Eailu_Test_Func_Cb test_cb);
74
75 /**
76  * Gets object with given name from child hierarchy or NULL if not found
77  */
78 AtkObject * eailu_find_child_with_name(AtkObject *obj, gchar *name);
79
80 /**
81  * Initializes glib, gobject and creates EFL test window
82  *
83  */
84 Evas_Object * eailu_create_test_window_with_glib_init(Evas_Smart_Cb on_done,
85                                                       Evas_Smart_Cb on_focus_in);
86
87 void eailu_print_atk_object_info(AtkObject *obj);
88
89 /**
90  * Gets action number for given action name in AtkAction object
91  *
92  * @return returns action index number or -1 if action with given name has
93  * not been found
94  */
95 int eailu_get_action_number(AtkAction *action_obj,const gchar *action_name);
96
97 /* Executes test routing for action with given name. If something will be wrong
98  * with given action, then assertion will fail */
99 void eailu_test_action_activate(AtkAction *action_obj,
100                                     const gchar *action_name);
101
102 void eailu_test_action_description_all(AtkAction *action_obj);
103
104 /**
105  * Tests "focus" functionality
106  * @oaram obj: object to test
107  * @param focusable: TRUE if focusable shoulbe be handled by component or
108  * false otherwise
109  */
110 void eailu_test_atk_focus(AtkObject *obj, gboolean focusable);
111
112 /**
113  * Printf for debug
114  */
115 inline static void _printf(const char *format, ...)
116 {
117 #if DEBUG
118    va_list args;
119
120    va_start(args, format);
121    vfprintf(stdout, format, args);
122    va_end(args);
123 #endif
124 }
125
126
127 #ifdef __cplusplus
128 }
129 #endif
130
131 #endif /* TEST_UTILS_H_ */