2 * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
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.
22 POSITIVE_TC_IDX = 0x01,
26 static void startup(void);
27 static void cleanup(void);
29 void (*tet_startup)(void) = startup;
30 void (*tet_cleanup)(void) = cleanup;
32 static void utc_nfc_ndef_message_create_p(void);
33 static void utc_nfc_ndef_message_create_n(void);
34 static void utc_nfc_ndef_message_create_from_rawdata_p(void);
35 static void utc_nfc_ndef_message_create_from_rawdata_n(void);
36 static void utc_nfc_ndef_message_destroy_p(void);
37 static void utc_nfc_ndef_message_destroy_n(void);
38 static void utc_nfc_ndef_message_get_record_count_p(void);
39 static void utc_nfc_ndef_message_get_record_count_n(void);
40 static void utc_nfc_ndef_message_get_rawdata_p(void);
41 static void utc_nfc_ndef_message_get_rawdata_n(void);
42 static void utc_nfc_ndef_message_append_record_p(void);
43 static void utc_nfc_ndef_message_append_record_n(void);
44 static void utc_nfc_ndef_message_insert_record_p(void);
45 static void utc_nfc_ndef_message_insert_record_n(void);
46 static void utc_nfc_ndef_message_remove_record_p(void);
47 static void utc_nfc_ndef_message_remove_record_n(void);
48 static void utc_nfc_ndef_message_get_record_p(void);
49 static void utc_nfc_ndef_message_get_record_n(void);
51 struct tet_testlist tet_testlist[] =
53 { utc_nfc_ndef_message_create_p, POSITIVE_TC_IDX },
54 { utc_nfc_ndef_message_create_n, NEGATIVE_TC_IDX },
55 { utc_nfc_ndef_message_create_from_rawdata_p, POSITIVE_TC_IDX },
56 { utc_nfc_ndef_message_create_from_rawdata_n, NEGATIVE_TC_IDX },
57 { utc_nfc_ndef_message_destroy_p, POSITIVE_TC_IDX },
58 { utc_nfc_ndef_message_destroy_n, NEGATIVE_TC_IDX },
59 { utc_nfc_ndef_message_get_record_count_p, POSITIVE_TC_IDX },
60 { utc_nfc_ndef_message_get_record_count_n, NEGATIVE_TC_IDX },
61 { utc_nfc_ndef_message_get_rawdata_p, POSITIVE_TC_IDX },
62 { utc_nfc_ndef_message_get_rawdata_n, NEGATIVE_TC_IDX },
63 { utc_nfc_ndef_message_append_record_p, POSITIVE_TC_IDX },
64 { utc_nfc_ndef_message_append_record_n, NEGATIVE_TC_IDX },
65 { utc_nfc_ndef_message_insert_record_p, POSITIVE_TC_IDX },
66 { utc_nfc_ndef_message_insert_record_n, NEGATIVE_TC_IDX },
67 { utc_nfc_ndef_message_remove_record_p, POSITIVE_TC_IDX },
68 { utc_nfc_ndef_message_remove_record_n, NEGATIVE_TC_IDX },
69 { utc_nfc_ndef_message_get_record_p, POSITIVE_TC_IDX },
70 { utc_nfc_ndef_message_get_record_n, NEGATIVE_TC_IDX },
75 //this method is called only once in start
76 static void startup(void)
81 static void cleanup(void)
86 static void utc_nfc_ndef_message_create_p(void)
89 nfc_ndef_message_h message;
91 ret = nfc_ndef_message_create(&message);
92 nfc_ndef_message_destroy(message);
94 dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_message_create is failed");
97 static void utc_nfc_ndef_message_create_n(void)
101 ret = nfc_ndef_message_create(NULL);
103 dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_message_create not allow null");
106 static void utc_nfc_ndef_message_create_from_rawdata_p(void)
109 unsigned char *buffer;
111 nfc_ndef_message_h message;
112 nfc_ndef_message_h message2;
113 nfc_ndef_record_h record1;
115 ret = nfc_ndef_message_create(&message);
116 nfc_ndef_record_create_text(&record1, "test", "en-US", NFC_ENCODE_UTF_8);
117 nfc_ndef_message_append_record(message, record1);
118 nfc_ndef_message_get_rawdata(message, &buffer, &size);
119 ret = nfc_ndef_message_create_from_rawdata(&message2, buffer, size);
121 nfc_ndef_message_destroy(message2);
122 nfc_ndef_message_destroy(message);
125 dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_message_create_from_rawdata is failed");
128 static void utc_nfc_ndef_message_create_from_rawdata_n(void)
132 ret = nfc_ndef_message_create_from_rawdata(NULL, NULL, 0);
134 dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_message_create_from_rawdata not allow null");
137 static void utc_nfc_ndef_message_destroy_p(void)
140 nfc_ndef_message_h message;
142 ret = nfc_ndef_message_create(&message);
143 ret = nfc_ndef_message_destroy(message);
145 dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_message_destroy is failed");
148 static void utc_nfc_ndef_message_destroy_n(void)
152 ret = nfc_ndef_message_destroy(NULL);
154 dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_message_destroy not allow null");
157 static void utc_nfc_ndef_message_get_record_count_p(void)
161 nfc_ndef_message_h message;
162 nfc_ndef_record_h record1;
164 ret = nfc_ndef_message_create(&message);
165 nfc_ndef_record_create_text(&record1, "test", "en-US", NFC_ENCODE_UTF_8);
166 nfc_ndef_message_append_record(message, record1);
167 ret = nfc_ndef_message_get_record_count(message, &count);
168 nfc_ndef_message_destroy(message);
170 dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_message_get_record_count is failed");
173 static void utc_nfc_ndef_message_get_record_count_n(void)
177 ret = nfc_ndef_message_get_record_count(NULL, NULL);
179 dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_message_get_record_count not allow null");
182 static void utc_nfc_ndef_message_get_rawdata_p(void)
185 unsigned char *buffer;
187 nfc_ndef_message_h message;
188 nfc_ndef_record_h record1;
190 ret = nfc_ndef_message_create(&message);
191 nfc_ndef_record_create_text(&record1, "test", "en-US", NFC_ENCODE_UTF_8);
192 nfc_ndef_message_append_record(message, record1);
193 ret = nfc_ndef_message_get_rawdata(message, &buffer, &size);
194 nfc_ndef_message_destroy(message);
197 dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_message_get_rawdata is failed");
200 static void utc_nfc_ndef_message_get_rawdata_n(void)
204 ret = nfc_ndef_message_get_rawdata(NULL, NULL, NULL);
206 dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_message_get_rawdata not allow null");
209 static void utc_nfc_ndef_message_append_record_p(void)
212 nfc_ndef_message_h message;
213 nfc_ndef_record_h record1;
215 ret = nfc_ndef_message_create(&message);
216 nfc_ndef_record_create_text(&record1, "test", "en-US", NFC_ENCODE_UTF_8);
217 ret = nfc_ndef_message_append_record(message, record1);
218 nfc_ndef_message_destroy(message);
220 dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_message_append_record is failed");
223 static void utc_nfc_ndef_message_append_record_n(void)
227 ret = nfc_ndef_message_append_record(NULL, NULL);
229 dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_message_append_record not allow null");
232 static void utc_nfc_ndef_message_insert_record_p(void)
235 nfc_ndef_message_h message;
236 nfc_ndef_record_h record1;
238 ret = nfc_ndef_message_create(&message);
239 nfc_ndef_record_create_text(&record1, "test", "en-US", NFC_ENCODE_UTF_8);
240 ret = nfc_ndef_message_insert_record(message, 0, record1);
241 nfc_ndef_message_destroy(message);
243 dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_message_insert_record is failed");
246 static void utc_nfc_ndef_message_insert_record_n(void)
250 ret = nfc_ndef_message_insert_record(NULL, 0, NULL);
252 dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_message_insert_record not allow null");
255 static void utc_nfc_ndef_message_remove_record_p(void)
258 nfc_ndef_message_h message;
259 nfc_ndef_record_h record1;
261 ret = nfc_ndef_message_create(&message);
262 nfc_ndef_record_create_text(&record1, "test", "en-US", NFC_ENCODE_UTF_8);
263 ret = nfc_ndef_message_insert_record(message, 0, record1);
264 ret = nfc_ndef_message_remove_record(message, 0);
265 nfc_ndef_message_destroy(message);
267 dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_message_remove_record is failed");
270 static void utc_nfc_ndef_message_remove_record_n(void)
274 ret = nfc_ndef_message_remove_record(NULL, 0);
276 dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_message_remove_record not allow null");
279 static void utc_nfc_ndef_message_get_record_p(void)
282 nfc_ndef_message_h message;
283 nfc_ndef_record_h record1, record2;
285 ret = nfc_ndef_message_create(&message);
286 nfc_ndef_record_create_text(&record1, "test", "en-US", NFC_ENCODE_UTF_8);
287 ret = nfc_ndef_message_insert_record(message, 0, record1);
288 ret = nfc_ndef_message_get_record(message, 0, &record2);
289 nfc_ndef_message_destroy(message);
291 dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_message_get_record is failed");
294 static void utc_nfc_ndef_message_get_record_n(void)
298 ret = nfc_ndef_message_get_record(NULL, 0, NULL);
300 dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_ndef_message_get_record not allow null");