1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
|
/*
* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <tet_api.h>
#include <location_preference.h>
#include <geocoder.h>
enum {
POSITIVE_TC_IDX = 0x01,
NEGATIVE_TC_IDX,
};
static void startup(void);
static void cleanup(void);
void (*tet_startup) (void) = startup;
void (*tet_cleanup) (void) = cleanup;
static void utc_location_location_preference_foreach_available_property_keys_p(void);
static void utc_location_location_preference_foreach_available_property_keys_n(void);
static void utc_location_location_preference_foreach_available_property_values_p(void);
static void utc_location_location_preference_foreach_available_property_values_n(void);
static void utc_location_location_preference_foreach_available_languages_p(void);
static void utc_location_location_preference_foreach_available_languages_n(void);
static void utc_location_location_preference_foreach_properties_p(void);
static void utc_location_location_preference_foreach_properties_n(void);
static void utc_location_location_preference_set_p(void);
static void utc_location_location_preference_set_n(void);
static void utc_location_location_preference_get_p(void);
static void utc_location_location_preference_get_n(void);
static void utc_location_location_preference_get_provider_name_p(void);
static void utc_location_location_preference_get_provider_name_n(void);
static void utc_location_location_preference_get_distance_unit_p(void);
static void utc_location_location_preference_get_distance_unit_n(void);
static void utc_location_location_preference_set_distance_unit_p(void);
static void utc_location_location_preference_set_distance_unit_n(void);
static void utc_location_location_preference_get_language_p(void);
static void utc_location_location_preference_get_language_n(void);
static void utc_location_location_preference_set_language_p(void);
static void utc_location_location_preference_set_language_n(void);
struct tet_testlist tet_testlist[] = {
// { utc_location_location_preference_foreach_available_property_keys_p, POSITIVE_TC_IDX },
{utc_location_location_preference_foreach_available_property_keys_n, NEGATIVE_TC_IDX},
// { utc_location_location_preference_foreach_available_property_values_p, POSITIVE_TC_IDX },
{utc_location_location_preference_foreach_available_property_values_n, NEGATIVE_TC_IDX},
{utc_location_location_preference_foreach_available_languages_p, POSITIVE_TC_IDX},
{utc_location_location_preference_foreach_available_languages_n, NEGATIVE_TC_IDX},
{utc_location_location_preference_set_p, POSITIVE_TC_IDX},
{utc_location_location_preference_set_n, NEGATIVE_TC_IDX},
{utc_location_location_preference_foreach_properties_p, POSITIVE_TC_IDX},
{utc_location_location_preference_foreach_properties_n, NEGATIVE_TC_IDX},
{utc_location_location_preference_get_p, POSITIVE_TC_IDX},
{utc_location_location_preference_get_n, NEGATIVE_TC_IDX},
{utc_location_location_preference_get_provider_name_p, POSITIVE_TC_IDX},
{utc_location_location_preference_get_provider_name_n, NEGATIVE_TC_IDX},
{utc_location_location_preference_set_distance_unit_p, POSITIVE_TC_IDX},
{utc_location_location_preference_set_distance_unit_n, NEGATIVE_TC_IDX},
{utc_location_location_preference_get_distance_unit_p, POSITIVE_TC_IDX},
{utc_location_location_preference_get_distance_unit_n, NEGATIVE_TC_IDX},
{utc_location_location_preference_set_language_p, POSITIVE_TC_IDX},
{utc_location_location_preference_set_language_n, NEGATIVE_TC_IDX},
{utc_location_location_preference_get_language_p, POSITIVE_TC_IDX},
{utc_location_location_preference_get_language_n, NEGATIVE_TC_IDX},
{NULL, 0},
};
static geocoder_h geocoder;
static char *available_language;
static char *available_key;
static char *available_value;
static void startup(void)
{
g_setenv("PKG_NAME", "com.samsung.capi-location-preference", 1);
g_setenv("LOCATION_TEST_ENABLE", "1", 1);
tet_printf("TC start");
int ret = geocoder_create(&geocoder);
available_language = NULL;
available_key = NULL;
available_value = NULL;
if (ret != GEOCODER_ERROR_NONE) {
tet_printf("Creating the handle of geocoder failed");
return;
} else {
tet_printf("Creating the handle of geocoder succeeded");
}
}
static void cleanup(void)
{
geocoder_destroy(geocoder);
}
bool location_preference_available_property_key_cb_impl(const char *key, void *user_data)
{
tet_printf("key : %s", key);
available_key = strdup(key);
return false;
}
bool location_preference_available_property_value_cb_impl(const char *value, void *user_data)
{
tet_printf("value : %s", value);
available_value = strdup(value);
return false;
}
bool location_preference_available_language_cb_impl(const char *language, void *user_data)
{
available_language = strdup(language);
tet_printf("available language : %s", available_language);
return false;
}
bool location_preference_property_cb_impl(const char *key, const char *value, void *user_data)
{
tet_printf("key : %s", key);
tet_printf("value : %s", value);
return false;
}
static void utc_location_location_preference_foreach_available_property_keys_p(void)
{
int ret = location_preference_foreach_available_property_keys(GET_LOCATION_SERVICE(geocoder),
location_preference_available_property_key_cb_impl, NULL);
if (ret == LOCATION_PREFERENCE_ERROR_NONE) {
dts_pass(__func__, "location_preference_foreach_available_property_keys passed");
} else {
dts_fail(__func__, "location_preference_foreach_available_property_keys failed");
}
}
static void utc_location_location_preference_foreach_available_property_keys_n(void)
{
int ret = location_preference_foreach_available_property_keys(GET_LOCATION_SERVICE(geocoder), NULL, NULL);
dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER,
"LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER was not returned.");
}
static void utc_location_location_preference_foreach_available_property_values_p(void)
{
int ret = location_preference_foreach_available_property_values(GET_LOCATION_SERVICE(geocoder), available_key,
location_preference_available_property_value_cb_impl,
NULL);
if (ret == LOCATION_PREFERENCE_ERROR_NONE) {
dts_pass(__func__, "location_preference_foreach_available_property_values passed");
} else {
dts_fail(__func__, "location_preference_foreach_available_property_values failed");
}
}
static void utc_location_location_preference_foreach_available_property_values_n(void)
{
int ret = location_preference_foreach_available_property_values(GET_LOCATION_SERVICE(geocoder), NULL, NULL, NULL);
dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER,
"LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER was not returned.");
}
static void utc_location_location_preference_foreach_available_languages_p(void)
{
int ret = location_preference_foreach_available_languages(GET_LOCATION_SERVICE(geocoder),
location_preference_available_language_cb_impl, NULL);
if (ret == LOCATION_PREFERENCE_ERROR_NONE) {
dts_pass(__func__, "location_preference_foreach_available_languages passed");
} else {
dts_fail(__func__, "location_preference_foreach_available_languages failed");
}
}
static void utc_location_location_preference_foreach_available_languages_n(void)
{
int ret = location_preference_foreach_available_languages(GET_LOCATION_SERVICE(geocoder), NULL, NULL);
dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER,
"LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER was not returned.");
}
static void utc_location_location_preference_foreach_properties_p(void)
{
int ret =
location_preference_foreach_properties(GET_LOCATION_SERVICE(geocoder), location_preference_property_cb_impl, NULL);
dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_NONE, "location_preference_foreach_properties failed.");
}
static void utc_location_location_preference_foreach_properties_n(void)
{
int ret = location_preference_foreach_properties(GET_LOCATION_SERVICE(geocoder), NULL, NULL);
dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER,
"LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER was not returned.");
}
static void utc_location_location_preference_set_p(void)
{
if (available_key == NULL) {
available_key = strdup("test_key");
available_value = strdup("test_value");
}
int ret = location_preference_set(GET_LOCATION_SERVICE(geocoder), available_key, available_value);
dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_NONE, "location_preference_set failed.");
}
static void utc_location_location_preference_set_n(void)
{
int ret = location_preference_set(GET_LOCATION_SERVICE(geocoder), NULL, NULL);
dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER,
"LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER was not returned.");
}
static void utc_location_location_preference_get_p(void)
{
int ret = 0;
char *value = NULL;
ret = location_preference_get(GET_LOCATION_SERVICE(geocoder), available_key, &value);
if (value != NULL) {
tet_printf("value: %s", value);
}
dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_NONE, "location_preference_get failed.");
}
static void utc_location_location_preference_get_n(void)
{
int ret = location_preference_get(GET_LOCATION_SERVICE(geocoder), NULL, NULL);
dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER,
"LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER was not returned.");
}
static void utc_location_location_preference_get_provider_name_p(void)
{
int ret = 0;
char *name = NULL;
ret = location_preference_get_provider_name(GET_LOCATION_SERVICE(geocoder), &name);
if (ret == LOCATION_PREFERENCE_ERROR_NONE) {
if (name != NULL) {
tet_printf("provider name: %s", name);
}
dts_pass(__func__, "location_preference_get_provider_name passed");
} else
dts_fail(__func__, "location_preference_get_provider_name failed");
}
static void utc_location_location_preference_get_provider_name_n(void)
{
int ret = location_preference_get_provider_name(GET_LOCATION_SERVICE(geocoder), NULL);
dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER,
"LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER was not returned.");
}
static void utc_location_location_preference_set_distance_unit_p(void)
{
int ret = location_preference_set_distance_unit(GET_LOCATION_SERVICE(geocoder), LOCATION_PREFERENCE_DISTANCE_UNIT_FT);
dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_NONE, "location_preference_set_distance_unit failed.");
}
static void utc_location_location_preference_set_distance_unit_n(void)
{
int ret = location_preference_set_distance_unit(GET_LOCATION_SERVICE(geocoder), -1);
dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER,
"LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER was not returned.");
}
static void utc_location_location_preference_get_distance_unit_p(void)
{
int ret = 0;
location_preference_distance_unit_e unit = LOCATION_PREFERENCE_DISTANCE_UNIT_FT;
ret = location_preference_get_distance_unit(GET_LOCATION_SERVICE(geocoder), &unit);
if (ret == LOCATION_PREFERENCE_ERROR_NONE) {
dts_pass(__func__, "location_preference_get_distance_unit passed");
} else {
dts_fail(__func__, "location_preference_get_distance_unit failed");
}
}
static void utc_location_location_preference_get_distance_unit_n(void)
{
int ret = location_preference_get_distance_unit(GET_LOCATION_SERVICE(geocoder), NULL);
dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER,
"LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER was not returned.");
}
static void utc_location_location_preference_set_language_p(void)
{
if (available_language == NULL) {
available_language = strdup("KR");
}
int ret = location_preference_set_language(GET_LOCATION_SERVICE(geocoder), available_language);
dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_NONE, "location_preference_set_language_unit failed.");
}
static void utc_location_location_preference_set_language_n(void)
{
int ret = location_preference_set_language(GET_LOCATION_SERVICE(geocoder), NULL);
dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER,
"LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER was not returned.");
}
static void utc_location_location_preference_get_language_p(void)
{
int ret = 0;
char *language = NULL;
ret = location_preference_get_language(GET_LOCATION_SERVICE(geocoder), &language);
if (ret == LOCATION_PREFERENCE_ERROR_NONE) {
dts_pass(__func__, "location_preference_get_distance_unit passed");
} else {
dts_fail(__func__, "location_preference_get_distance_unit failed");
}
}
static void utc_location_location_preference_get_language_n(void)
{
int ret = location_preference_get_language(GET_LOCATION_SERVICE(geocoder), NULL);
dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER,
"LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER was not returned.");
}
|