2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 static void startup(void);
24 static void cleanup(void);
26 void (*tet_startup)(void) = startup;
27 void (*tet_cleanup)(void) = cleanup;
29 static void utc_storage_foreach_device_supported_positive(void);
30 static void utc_storage_foreach_device_supported_negative(void);
31 static void utc_storage_get_root_directory_positive(void);
32 static void utc_storage_get_root_directory_negative1(void);
33 static void utc_storage_get_root_directory_negative2(void);
34 static void utc_storage_get_type_positive(void);
35 static void utc_storage_get_type_negative1(void);
36 static void utc_storage_get_type_negative2(void);
37 static void utc_storage_get_state_positive(void);
38 static void utc_storage_get_state_negative1(void);
39 static void utc_storage_get_state_negative2(void);
40 static void utc_storage_get_total_space_positive(void);
41 static void utc_storage_get_total_space_negative1(void);
42 static void utc_storage_get_total_space_negative2(void);
43 static void utc_storage_get_available_space_positive(void);
44 static void utc_storage_get_available_space_negative1(void);
45 static void utc_storage_get_available_space_negative2(void);
47 static void utc_storage_set_state_changed_cb_positive(void);
48 static void utc_storage_set_state_changed_cb_negative1(void);
49 static void utc_storage_set_state_changed_cb_negative2(void);
51 static void utc_storage_unset_state_changed_cb_positive(void);
52 static void utc_storage_unset_state_changed_cb_negative(void);
54 struct tet_testlist tet_testlist[] = {
55 {utc_storage_foreach_device_supported_positive, 1},
56 {utc_storage_foreach_device_supported_negative, 2},
57 {utc_storage_get_root_directory_positive, 1},
58 {utc_storage_get_root_directory_negative1, 2},
59 {utc_storage_get_root_directory_negative2, 2},
60 {utc_storage_get_type_positive, 1},
61 {utc_storage_get_type_negative1, 2},
62 {utc_storage_get_type_negative2, 2},
63 {utc_storage_get_state_positive, 1},
64 {utc_storage_get_state_negative1, 2},
65 {utc_storage_get_state_negative2, 2},
66 {utc_storage_get_total_space_positive, 1},
67 {utc_storage_get_total_space_negative1, 2},
68 {utc_storage_get_total_space_negative2, 2},
69 {utc_storage_get_available_space_positive, 1},
70 {utc_storage_get_available_space_negative1, 2},
71 {utc_storage_get_available_space_negative2, 2},
72 {utc_storage_set_state_changed_cb_positive, 1},
73 {utc_storage_set_state_changed_cb_negative1, 2},
74 {utc_storage_set_state_changed_cb_negative2, 2},
75 {utc_storage_unset_state_changed_cb_positive, 1},
76 {utc_storage_unset_state_changed_cb_negative, 2},
80 static int internal_storage_id;
82 bool get_internal_storage(int storage, storage_type_e type, storage_state_e state, const char *path, void *user_data)
84 if (type == STORAGE_TYPE_INTERNAL) {
85 internal_storage_id = storage;
92 static void startup(void)
94 storage_foreach_device_supported(get_internal_storage, NULL);
98 static void cleanup(void)
104 bool get_storage_device(int storage, storage_type_e type, storage_state_e state,
105 const char *path, void *user_data)
110 static void utc_storage_foreach_device_supported_positive(void)
114 err = storage_foreach_device_supported(get_storage_device, NULL);
116 if (err == STORAGE_ERROR_NONE) {
117 dts_pass("utc_storage_foreach_device_supported_positive", "passed");
119 dts_fail("utc_storage_foreach_device_supported_positive", "failed");
124 static void utc_storage_foreach_device_supported_negative(void)
128 err = storage_foreach_device_supported(NULL, NULL);
130 if (err == STORAGE_ERROR_INVALID_PARAMETER) {
131 dts_pass("utc_storage_foreach_device_supported_positive", "passed");
133 dts_fail("utc_storage_foreach_device_supported_positive", "failed");
137 static void utc_storage_get_root_directory_positive(void)
141 err = storage_get_root_directory(internal_storage_id, &path);
143 if ((err == STORAGE_ERROR_NONE) && (path != NULL)) {
144 dts_pass("utc_storage_get_root_directory_positive", "passed");
146 dts_fail("utc_storage_get_root_directory_positive", "failed");
150 static void utc_storage_get_root_directory_negative1(void)
154 err = storage_get_root_directory(10, &path);
156 if (err == STORAGE_ERROR_NOT_SUPPORTED) {
157 dts_pass("utc_storage_get_root_directory_negative1", "passed");
159 dts_fail("utc_storage_get_root_directory_negative1", "failed");
163 static void utc_storage_get_root_directory_negative2(void)
167 err = storage_get_root_directory(internal_storage_id, NULL);
169 if (err == STORAGE_ERROR_INVALID_PARAMETER) {
170 dts_pass("utc_storage_get_root_directory_negative2", "passed");
172 dts_fail("utc_storage_get_root_directory_negative2", "failed");
176 static void utc_storage_get_type_positive(void)
181 err = storage_get_type(internal_storage_id, &type);
183 if ((err == STORAGE_ERROR_NONE) && (type == STORAGE_TYPE_INTERNAL)) {
184 dts_pass("utc_storage_get_type_positive", "passed");
186 dts_fail("utc_storage_get_type_positive", "failed");
190 static void utc_storage_get_type_negative1(void)
194 err = storage_get_type(10, &type);
196 if (err == STORAGE_ERROR_NOT_SUPPORTED) {
197 dts_pass("utc_storage_get_type_negative1", "passed");
199 dts_fail("utc_storage_get_type_negative1", "failed");
203 static void utc_storage_get_type_negative2(void)
206 err = storage_get_type(internal_storage_id, NULL);
208 if (err == STORAGE_ERROR_INVALID_PARAMETER) {
209 dts_pass("utc_storage_get_type_negative2", "passed");
211 dts_fail("utc_storage_get_type_negative2", "failed");
216 static void utc_storage_get_state_positive(void)
219 storage_state_e state;
221 err = storage_get_state(internal_storage_id, &state);
223 if ((err == STORAGE_ERROR_NONE) && (state == STORAGE_STATE_MOUNTED)) {
224 dts_pass("utc_storage_get_state_positive", "passed");
226 dts_fail("utc_storage_get_state_positive", "failed");
230 static void utc_storage_get_state_negative1(void)
233 storage_state_e state;
234 err = storage_get_state(10, &state);
236 if (err == STORAGE_ERROR_NOT_SUPPORTED) {
237 dts_pass("utc_storage_get_state_negative1", "passed");
239 dts_fail("utc_storage_get_state_negative1", "failed");
243 static void utc_storage_get_state_negative2(void)
246 err = storage_get_state(internal_storage_id, NULL);
248 if (err == STORAGE_ERROR_INVALID_PARAMETER) {
249 dts_pass("utc_storage_get_state_negative2", "passed");
251 dts_fail("utc_storage_get_state_negative2", "failed");
256 static void utc_storage_get_total_space_positive(void)
259 unsigned long long size;
261 err = storage_get_total_space(internal_storage_id, &size);
263 if (err == STORAGE_ERROR_NONE) {
264 dts_pass("utc_storage_get_total_space_positive", "passed");
266 dts_fail("utc_storage_get_total_space_positive", "failed");
270 static void utc_storage_get_total_space_negative1(void)
273 unsigned long long size;
274 err = storage_get_total_space(10, &size);
276 if (err == STORAGE_ERROR_NOT_SUPPORTED) {
277 dts_pass("utc_storage_get_total_space_negative1", "passed");
279 dts_fail("utc_storage_get_total_space_negative1", "failed");
283 static void utc_storage_get_total_space_negative2(void)
286 err = storage_get_total_space(internal_storage_id, NULL);
288 if (err == STORAGE_ERROR_INVALID_PARAMETER) {
289 dts_pass("utc_storage_get_total_space_negative2", "passed");
291 dts_fail("utc_storage_get_total_space_negative2", "failed");
296 static void utc_storage_get_available_space_positive(void)
299 unsigned long long size;
301 err = storage_get_available_space(internal_storage_id, &size);
303 if (err == STORAGE_ERROR_NONE) {
304 dts_pass("utc_storage_get_available_space_positive", "passed");
306 dts_fail("utc_storage_get_available_space_positive", "failed");
310 static void utc_storage_get_available_space_negative1(void)
313 unsigned long long size;
314 err = storage_get_available_space(10, &size);
316 if (err == STORAGE_ERROR_NOT_SUPPORTED) {
317 dts_pass("utc_storage_get_available_space_negative1", "passed");
319 dts_fail("utc_storage_get_available_space_negative1", "failed");
323 static void utc_storage_get_available_space_negative2(void)
326 err = storage_get_available_space(internal_storage_id, NULL);
328 if (err == STORAGE_ERROR_INVALID_PARAMETER) {
329 dts_pass("utc_storage_get_available_space_negative2", "passed");
331 dts_fail("utc_storage_get_available_space_negative2", "failed");
335 static void dts_storage_state_changed_cb(int storage, storage_state_e state, void *user_data)
340 static void utc_storage_set_state_changed_cb_positive(void)
344 err = storage_set_state_changed_cb(0, dts_storage_state_changed_cb, NULL);
346 if (err == STORAGE_ERROR_NONE) {
347 dts_pass("utc_storage_set_state_changed_cb_positive", "passed");
349 dts_fail("utc_storage_set_state_changed_cb_positive", "failed");
353 static void utc_storage_set_state_changed_cb_negative1(void)
357 err = storage_set_state_changed_cb(-1, dts_storage_state_changed_cb, NULL);
359 if (err == STORAGE_ERROR_NOT_SUPPORTED) {
360 dts_pass("utc_storage_set_state_changed_cb_negative1", "passed");
362 dts_fail("utc_storage_set_state_changed_cb_negative1", "failed");
366 static void utc_storage_set_state_changed_cb_negative2(void)
370 err = storage_set_state_changed_cb(0, NULL, NULL);
372 if (err == STORAGE_ERROR_INVALID_PARAMETER) {
373 dts_pass("utc_storage_set_state_changed_cb_negative2", "passed");
375 dts_fail("utc_storage_set_state_changed_cb_negative2", "failed");
379 static void utc_storage_unset_state_changed_cb_positive(void)
383 storage_set_state_changed_cb(0, dts_storage_state_changed_cb, NULL);
385 err = storage_unset_state_changed_cb(0);
387 if (err == STORAGE_ERROR_NONE) {
388 dts_pass("utc_storage_unset_state_changed_cb_positive", "passed");
390 dts_fail("utc_storage_unset_state_changed_cb_positive", "failed");
394 static void utc_storage_unset_state_changed_cb_negative(void)
398 err = storage_unset_state_changed_cb(-1);
400 if (err == STORAGE_ERROR_NOT_SUPPORTED) {
401 dts_pass("utc_storage_unset_state_changed_cb_negative", "passed");
403 dts_fail("utc_storage_unset_state_changed_cb_negative", "failed");