summaryrefslogtreecommitdiff
path: root/src/tests/elocation
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/elocation')
-rw-r--r--src/tests/elocation/elocation_suite.c235
1 files changed, 0 insertions, 235 deletions
diff --git a/src/tests/elocation/elocation_suite.c b/src/tests/elocation/elocation_suite.c
deleted file mode 100644
index afae6e0..0000000
--- a/src/tests/elocation/elocation_suite.c
+++ /dev/null
@@ -1,235 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include <stdlib.h>
6#include <stdio.h>
7
8#include <check.h>
9
10#include <Elocation.h>
11
12/* Test the init and shutdown pathes only. Good to do that as we don't set up
13 * other things and already triggered problems with this.
14 */
15EFL_START_TEST(elocation_test_init)
16{
17 Eina_Bool ret;
18
19 ret = elocation_init();
20 fail_if(ret != EINA_TRUE);
21
22 elocation_shutdown();
23}
24EFL_END_TEST
25
26/* Basic address object testing. Creating and freeing the object */
27EFL_START_TEST(elocation_test_address_object)
28{
29 Eina_Bool ret;
30 Elocation_Address *address = NULL;
31
32 ret = elocation_init();
33 fail_if(ret != EINA_TRUE);
34
35 address = elocation_address_new();
36 fail_if(address == NULL);
37
38 elocation_address_free(address);
39
40 elocation_shutdown();
41}
42EFL_END_TEST
43
44/* Basic position object testing. Creating and freeing the object */
45EFL_START_TEST(elocation_test_position_object)
46{
47 Eina_Bool ret;
48 Elocation_Position *position = NULL;
49
50 ret = elocation_init();
51 fail_if(ret != EINA_TRUE);
52
53 position = elocation_position_new();
54 fail_if(position == NULL);
55
56 elocation_position_free(position);
57
58 elocation_shutdown();
59}
60EFL_END_TEST
61
62/* Basic testing for the various functions of the GeoCode API */
63static int cb_count = 0;
64
65static Eina_Bool
66event_cb(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *event)
67{
68 fail_if(event == NULL);
69
70 /* We expect 3 callbacks right now */
71 if (++cb_count == 3)
72 ecore_main_loop_quit();
73
74 return ECORE_CALLBACK_DONE;
75}
76
77EFL_START_TEST(elocation_test_api_geocode)
78{
79 Eina_Bool ret;
80 Elocation_Position *position = NULL;
81 Elocation_Address *address = NULL;
82 Ecore_Event_Handler *handler;
83
84 ret = elocation_init();
85 fail_if(ret != EINA_TRUE);
86
87 handler = ecore_event_handler_add(ELOCATION_EVENT_GEOCODE, event_cb, NULL);
88 fail_if(handler == NULL);
89
90 handler = ecore_event_handler_add(ELOCATION_EVENT_REVERSEGEOCODE, event_cb, NULL);
91 fail_if(handler == NULL);
92
93 position = elocation_position_new();
94 fail_if(position == NULL);
95
96 address = elocation_address_new();
97 fail_if(address == NULL);
98
99 ret = elocation_freeform_address_to_position("London", position);
100 fail_if(ret != EINA_TRUE);
101
102 position->latitude = 51.7522;
103 position->longitude = -1.25596;
104 position->accur->level = 3;
105 ret = elocation_position_to_address(position, address);
106 fail_if(ret != EINA_TRUE);
107
108 address->locality = strdup("Cambridge");
109 address->countrycode = strdup("UK");
110 ret = elocation_address_to_position(address, position);
111 fail_if(ret != EINA_TRUE);
112
113 ecore_main_loop_begin();
114
115 elocation_position_free(position);
116 elocation_address_free(address);
117
118 elocation_shutdown();
119}
120EFL_END_TEST
121
122/* Basic testing for position API */
123EFL_START_TEST(elocation_test_api_position)
124{
125 Eina_Bool ret;
126 Elocation_Position *position = NULL;
127
128 ret = elocation_init();
129 fail_if(ret != EINA_TRUE);
130
131 position = elocation_position_new();
132 fail_if(position == NULL);
133
134 ret = elocation_position_get(position);
135 fail_if(ret != EINA_TRUE);
136
137 elocation_position_free(position);
138
139 elocation_shutdown();
140}
141EFL_END_TEST
142
143/* Basic testing for address API */
144EFL_START_TEST(elocation_test_api_address)
145{
146 Eina_Bool ret;
147 Elocation_Address *address = NULL;
148
149 ret = elocation_init();
150 fail_if(ret != EINA_TRUE);
151
152 address = elocation_address_new();
153 fail_if(address == NULL);
154
155 ret = elocation_address_get(address);
156 fail_if(ret != EINA_TRUE);
157
158 elocation_address_free(address);
159
160 elocation_shutdown();
161}
162EFL_END_TEST
163
164/* Basic testing for status API */
165EFL_START_TEST(elocation_test_api_status)
166{
167 Eina_Bool ret;
168 int status = 0;
169
170 ret = elocation_init();
171 fail_if(ret != EINA_TRUE);
172
173 ret = elocation_status_get(&status);
174 fail_if(ret != EINA_TRUE);
175
176 elocation_shutdown();
177}
178EFL_END_TEST
179
180Suite *
181elocation_suite(void)
182{
183 Suite *s;
184 TCase *tc;
185
186 s = suite_create("Elocation");
187
188 tc = tcase_create("Elocation_Init");
189 tcase_add_test(tc, elocation_test_init);
190 suite_add_tcase(s, tc);
191
192 tc = tcase_create("Elocation_Objects");
193 tcase_add_test(tc, elocation_test_address_object);
194 tcase_add_test(tc, elocation_test_position_object);
195 suite_add_tcase(s, tc);
196
197 tc = tcase_create("Elocation_API_Geocode");
198 tcase_add_test(tc, elocation_test_api_geocode);
199 suite_add_tcase(s, tc);
200
201 tc = tcase_create("Elocation_API_Position");
202 tcase_add_test(tc, elocation_test_api_position);
203 suite_add_tcase(s, tc);
204
205 tc = tcase_create("Elocation_API_Address");
206 tcase_add_test(tc, elocation_test_api_address);
207 suite_add_tcase(s, tc);
208/*
209 tc = tcase_create("Elocation_API_Status");
210 tcase_add_test(tc, elocation_test_api_status);
211 suite_add_tcase(s, tc);
212*/
213 return s;
214}
215
216int
217main(void)
218{
219 Suite *s;
220 SRunner *sr;
221 int failed_count;
222
223#ifdef NEED_RUN_IN_TREE
224 putenv("EFL_RUN_IN_TREE=1");
225#endif
226
227 s = elocation_suite();
228 sr = srunner_create(s);
229 srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml");
230 srunner_run_all(sr, CK_ENV);
231 failed_count = srunner_ntests_failed(sr);
232 srunner_free(sr);
233
234 return (failed_count == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
235}