summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Schmidt <s.schmidt@samsung.com>2014-10-28 15:55:02 +0100
committerStefan Schmidt <s.schmidt@samsung.com>2014-11-11 11:06:05 +0100
commitd3476bf77891547506f77c00d707e7b57b69aa35 (patch)
treefaedf2b5be98c0a1a77fb03c138d715fa24745b4
parenta80b88c0ea76017195d6f6db07b35717915380a1 (diff)
tests/elocation: Add elocation test suite.
Not covering all cases yet but still a good start.
-rw-r--r--src/Makefile_Elocation.am21
-rw-r--r--src/tests/elocation/elocation_suite.c251
2 files changed, 272 insertions, 0 deletions
diff --git a/src/Makefile_Elocation.am b/src/Makefile_Elocation.am
index 0fc5b69..4314725 100644
--- a/src/Makefile_Elocation.am
+++ b/src/Makefile_Elocation.am
@@ -14,3 +14,24 @@ lib_elocation_libelocation_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl @ELOCATIO
14lib_elocation_libelocation_la_LIBADD = @ELOCATION_LIBS@ 14lib_elocation_libelocation_la_LIBADD = @ELOCATION_LIBS@
15lib_elocation_libelocation_la_DEPENDENCIES = @ELOCATION_INTERNAL_LIBS@ 15lib_elocation_libelocation_la_DEPENDENCIES = @ELOCATION_INTERNAL_LIBS@
16lib_elocation_libelocation_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@ 16lib_elocation_libelocation_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@
17
18### Unit tests
19
20if EFL_ENABLE_TESTS
21
22check_PROGRAMS += tests/elocation/elocation_suite
23TESTS += tests/elocation/elocation_suite
24
25tests_elocation_elocation_suite_SOURCES = \
26tests/elocation/elocation_suite.c
27
28tests_elocation_elocation_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
29-DTESTS_WD=\"`pwd`\" \
30-DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests/elocation\" \
31-DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/elocation\" \
32@CHECK_CFLAGS@ \
33@ELOCATION_CFLAGS@
34tests_elocation_elocation_suite_LDADD = @CHECK_LIBS@ @USE_ELOCATION_LIBS@
35tests_elocation_elocation_suite_DEPENDENCIES = @USE_ELOCATION_INTERNAL_LIBS@
36
37endif
diff --git a/src/tests/elocation/elocation_suite.c b/src/tests/elocation/elocation_suite.c
new file mode 100644
index 0000000..c049bd1
--- /dev/null
+++ b/src/tests/elocation/elocation_suite.c
@@ -0,0 +1,251 @@
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 <Eina.h>
9
10#include <check.h>
11
12#include <Elocation.h>
13
14/* Test the init and shutdown pathes only. Good to do that as we don't set up
15 * other things and already triggered problems with this.
16 */
17START_TEST(elocation_test_init)
18{
19 Eina_Bool ret;
20
21 ret = ecore_init();
22 fail_if(ret != EINA_TRUE);
23 ret = eldbus_init();
24 fail_if(ret != EINA_TRUE);
25 ret = elocation_init();
26 fail_if(ret != EINA_TRUE);
27
28 elocation_shutdown();
29 eldbus_shutdown();
30 ecore_shutdown();
31}
32END_TEST
33
34/* Basic address object testing. Creating and freeing the object */
35START_TEST(elocation_test_address_object)
36{
37 Eina_Bool ret;
38 Elocation_Address *address = NULL;
39
40 ret = ecore_init();
41 fail_if(ret != EINA_TRUE);
42 ret = eldbus_init();
43 fail_if(ret != EINA_TRUE);
44 ret = elocation_init();
45 fail_if(ret != EINA_TRUE);
46
47 address = elocation_address_new();
48 fail_if(address == NULL);
49
50 elocation_address_free(address);
51
52 elocation_shutdown();
53 eldbus_shutdown();
54 ecore_shutdown();
55}
56END_TEST
57
58/* Basic position object testing. Creating and freeing the object */
59START_TEST(elocation_test_position_object)
60{
61 Eina_Bool ret;
62 Elocation_Position *position = NULL;
63
64 ret = ecore_init();
65 fail_if(ret != EINA_TRUE);
66 ret = eldbus_init();
67 fail_if(ret != EINA_TRUE);
68 ret = elocation_init();
69 fail_if(ret != EINA_TRUE);
70
71 position = elocation_position_new();
72 fail_if(position == NULL);
73
74 elocation_position_free(position);
75
76 elocation_shutdown();
77 eldbus_shutdown();
78 ecore_shutdown();
79}
80END_TEST
81
82/* Basic testing for the various functions of the GeoCode API */
83START_TEST(elocation_test_api_geocode)
84{
85 Eina_Bool ret;
86 Elocation_Position *position = NULL;
87 Elocation_Address *address = NULL;
88
89 ret = ecore_init();
90 fail_if(ret != EINA_TRUE);
91 ret = eldbus_init();
92 fail_if(ret != EINA_TRUE);
93 ret = elocation_init();
94 fail_if(ret != EINA_TRUE);
95
96 position = elocation_position_new();
97 fail_if(position == NULL);
98
99 address = elocation_address_new();
100 fail_if(address == NULL);
101
102 ret = elocation_freeform_address_to_position("London", position);
103 fail_if(ret != EINA_TRUE);
104
105 position->latitude = 51.7522;
106 position->longitude = -1.25596;
107 position->accur->level = 3;
108 ret = elocation_position_to_address(position, address);
109 fail_if(ret != EINA_TRUE);
110
111 address->locality = strdup("Cambridge");
112 address->countrycode = strdup("UK");
113 ret = elocation_address_to_position(address, position);
114 fail_if(ret != EINA_TRUE);
115
116 elocation_position_free(position);
117 elocation_address_free(address);
118
119 elocation_shutdown();
120 eldbus_shutdown();
121 ecore_shutdown();
122}
123END_TEST
124
125/* Basic testing for position API */
126START_TEST(elocation_test_api_position)
127{
128 Eina_Bool ret;
129 Elocation_Position *position = NULL;
130
131 ret = ecore_init();
132 fail_if(ret != EINA_TRUE);
133 ret = eldbus_init();
134 fail_if(ret != EINA_TRUE);
135 ret = elocation_init();
136 fail_if(ret != EINA_TRUE);
137
138 position = elocation_position_new();
139 fail_if(position == NULL);
140
141 ret = elocation_position_get(position);
142 fail_if(ret != EINA_TRUE);
143
144 elocation_position_free(position);
145
146 elocation_shutdown();
147 eldbus_shutdown();
148 ecore_shutdown();
149}
150END_TEST
151
152/* Basic testing for address API */
153START_TEST(elocation_test_api_address)
154{
155 Eina_Bool ret;
156 Elocation_Address *address = NULL;
157
158 ret = ecore_init();
159 fail_if(ret != EINA_TRUE);
160 ret = eldbus_init();
161 fail_if(ret != EINA_TRUE);
162 ret = elocation_init();
163 fail_if(ret != EINA_TRUE);
164
165 address = elocation_address_new();
166 fail_if(address == NULL);
167
168 ret = elocation_address_get(address);
169 fail_if(ret != EINA_TRUE);
170
171 elocation_address_free(address);
172
173 elocation_shutdown();
174 eldbus_shutdown();
175 ecore_shutdown();
176}
177END_TEST
178
179/* Basic testing for status API */
180START_TEST(elocation_test_api_status)
181{
182 Eina_Bool ret;
183 int status = 0;
184
185 ret = ecore_init();
186 fail_if(ret != EINA_TRUE);
187 ret = eldbus_init();
188 fail_if(ret != EINA_TRUE);
189 ret = elocation_init();
190 fail_if(ret != EINA_TRUE);
191
192 ret = elocation_status_get(&status);
193 fail_if(ret != EINA_TRUE);
194
195 elocation_shutdown();
196 eldbus_shutdown();
197 ecore_shutdown();
198}
199END_TEST
200
201Suite *
202elocation_suite(void)
203{
204 Suite *s;
205 TCase *tc;
206
207 s = suite_create("Elocation");
208
209 tc = tcase_create("Elocation_Init");
210 tcase_add_test(tc, elocation_test_init);
211 suite_add_tcase(s, tc);
212
213 tc = tcase_create("Elocation_Objects");
214 tcase_add_test(tc, elocation_test_address_object);
215 tcase_add_test(tc, elocation_test_position_object);
216 suite_add_tcase(s, tc);
217
218 tc = tcase_create("Elocation_API_Geocode");
219 tcase_add_test(tc, elocation_test_api_geocode);
220 suite_add_tcase(s, tc);
221
222 tc = tcase_create("Elocation_API_Position");
223 tcase_add_test(tc, elocation_test_api_position);
224 suite_add_tcase(s, tc);
225
226 tc = tcase_create("Elocation_API_Address");
227 tcase_add_test(tc, elocation_test_api_address);
228 suite_add_tcase(s, tc);
229
230 tc = tcase_create("Elocation_API_Status");
231 tcase_add_test(tc, elocation_test_api_status);
232 suite_add_tcase(s, tc);
233
234 return s;
235}
236
237int
238main(void)
239{
240 Suite *s;
241 SRunner *sr;
242 int failed_count;
243
244 s = elocation_suite();
245 sr = srunner_create(s);
246 srunner_run_all(sr, CK_ENV);
247 failed_count = srunner_ntests_failed(sr);
248 srunner_free(sr);
249
250 return (failed_count == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
251}