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.
21 POSITIVE_TC_IDX = 0x01,
25 #define MY_ASSERT( fun , test , msg ) \
28 dts_fail(fun , msg ); \
32 static void startup(void);
33 static void cleanup(void);
35 void (*tet_startup)(void) = startup;
36 void (*tet_cleanup)(void) = cleanup;
38 static void utc_nfc_ndef_message_create_p(void);
39 static void utc_nfc_ndef_message_create_n(void);
40 static void utc_nfc_ndef_message_create_from_rawdata_p(void);
41 static void utc_nfc_ndef_message_create_from_rawdata_n(void);
42 static void utc_nfc_ndef_message_destroy_p(void);
43 static void utc_nfc_ndef_message_destroy_n(void);
44 static void utc_nfc_ndef_message_get_record_count_p(void);
45 static void utc_nfc_ndef_message_get_record_count_n(void);
46 static void utc_nfc_ndef_message_get_rawdata_p(void);
47 static void utc_nfc_ndef_message_get_rawdata_n(void);
48 static void utc_nfc_ndef_message_append_record_p(void);
49 static void utc_nfc_ndef_message_append_record_n(void);
50 static void utc_nfc_ndef_message_insert_record_p(void);
51 static void utc_nfc_ndef_message_insert_record_n(void);
52 static void utc_nfc_ndef_message_remove_record_p(void);
53 static void utc_nfc_ndef_message_remove_record_n(void);
54 static void utc_nfc_ndef_message_get_record_p(void);
55 static void utc_nfc_ndef_message_get_record_n(void);
58 struct tet_testlist tet_testlist[] = {
59 { utc_nfc_ndef_message_create_p , POSITIVE_TC_IDX },
60 { utc_nfc_ndef_message_create_n , NEGATIVE_TC_IDX },
61 { utc_nfc_ndef_message_create_from_rawdata_p , POSITIVE_TC_IDX },
62 { utc_nfc_ndef_message_create_from_rawdata_n , NEGATIVE_TC_IDX },
63 { utc_nfc_ndef_message_destroy_p , POSITIVE_TC_IDX },
64 { utc_nfc_ndef_message_destroy_n , NEGATIVE_TC_IDX },
65 { utc_nfc_ndef_message_get_record_count_p , POSITIVE_TC_IDX },
66 { utc_nfc_ndef_message_get_record_count_n , NEGATIVE_TC_IDX },
67 { utc_nfc_ndef_message_get_rawdata_p , POSITIVE_TC_IDX },
68 { utc_nfc_ndef_message_get_rawdata_n , NEGATIVE_TC_IDX },
69 { utc_nfc_ndef_message_append_record_p , POSITIVE_TC_IDX },
70 { utc_nfc_ndef_message_append_record_n , NEGATIVE_TC_IDX },
71 { utc_nfc_ndef_message_insert_record_p , POSITIVE_TC_IDX },
72 { utc_nfc_ndef_message_insert_record_n , NEGATIVE_TC_IDX },
73 { utc_nfc_ndef_message_remove_record_p , POSITIVE_TC_IDX },
74 { utc_nfc_ndef_message_remove_record_n , NEGATIVE_TC_IDX },
75 { utc_nfc_ndef_message_get_record_p , POSITIVE_TC_IDX },
76 { utc_nfc_ndef_message_get_record_n , NEGATIVE_TC_IDX },
81 //this method is called only once in start
82 static void startup(void)
87 static void cleanup(void)
93 static void utc_nfc_ndef_message_create_p(void)
96 nfc_ndef_message_h message;
97 ret = nfc_ndef_message_create(&message);
98 MY_ASSERT(__func__ , ret == NFC_ERROR_NONE , "FAIL");
99 nfc_ndef_message_destroy(message);
100 dts_pass(__func__, "PASS");
102 static void utc_nfc_ndef_message_create_n(void)
105 ret = nfc_ndef_message_create(NULL);
106 MY_ASSERT(__func__, ret != NFC_ERROR_NONE , "FAIL");
107 dts_pass(__func__, "PASS");
109 static void utc_nfc_ndef_message_create_from_rawdata_p(void)
112 unsigned char *buffer;
114 nfc_ndef_message_h message;
115 nfc_ndef_message_h message2;
116 nfc_ndef_record_h record1;
117 ret = nfc_ndef_message_create(&message);
118 nfc_ndef_record_create_text(&record1, "test", "en-US", NFC_ENCODE_UTF_8);
119 nfc_ndef_message_append_record(message, record1);
120 nfc_ndef_message_get_rawdata(message, &buffer, &size);
121 ret = nfc_ndef_message_create_from_rawdata(&message2, buffer,size);
123 MY_ASSERT(__func__ , ret == NFC_ERROR_NONE , "FAIL");
124 nfc_ndef_message_destroy(message2);
125 nfc_ndef_message_destroy(message);
127 dts_pass(__func__, "PASS");
130 static void utc_nfc_ndef_message_create_from_rawdata_n(void)
133 ret = nfc_ndef_message_create_from_rawdata(NULL, NULL, 0);
134 MY_ASSERT(__func__, ret != NFC_ERROR_NONE , "FAIL");
135 dts_pass(__func__, "PASS");
137 static void utc_nfc_ndef_message_destroy_p(void)
140 nfc_ndef_message_h message;
141 ret = nfc_ndef_message_create(&message);
142 ret = nfc_ndef_message_destroy(message);
143 MY_ASSERT(__func__ , ret == NFC_ERROR_NONE , "FAIL");
144 dts_pass(__func__, "PASS");
147 static void utc_nfc_ndef_message_destroy_n(void)
150 ret = nfc_ndef_message_destroy(NULL);
151 MY_ASSERT(__func__, ret != NFC_ERROR_NONE , "FAIL");
152 dts_pass(__func__, "PASS");
154 static void utc_nfc_ndef_message_get_record_count_p(void)
158 nfc_ndef_message_h message;
159 nfc_ndef_record_h record1;
160 ret = nfc_ndef_message_create(&message);
161 nfc_ndef_record_create_text(&record1, "test", "en-US", NFC_ENCODE_UTF_8);
162 nfc_ndef_message_append_record(message, record1);
163 ret = nfc_ndef_message_get_record_count(message, &count);
165 MY_ASSERT(__func__ , ret == NFC_ERROR_NONE , "FAIL");
166 nfc_ndef_message_destroy(message);
167 dts_pass(__func__, "PASS");
170 static void utc_nfc_ndef_message_get_record_count_n(void)
173 ret = nfc_ndef_message_get_record_count(NULL, NULL);
174 MY_ASSERT(__func__, ret != NFC_ERROR_NONE , "FAIL");
175 dts_pass(__func__, "PASS");
177 static void utc_nfc_ndef_message_get_rawdata_p(void)
180 unsigned char *buffer;
182 nfc_ndef_message_h message;
183 nfc_ndef_record_h record1;
184 ret = nfc_ndef_message_create(&message);
185 nfc_ndef_record_create_text(&record1, "test", "en-US", NFC_ENCODE_UTF_8);
186 nfc_ndef_message_append_record(message, record1);
187 ret= nfc_ndef_message_get_rawdata(message, &buffer, &size);
189 MY_ASSERT(__func__ , ret == NFC_ERROR_NONE , "FAIL");
190 nfc_ndef_message_destroy(message);
192 dts_pass(__func__, "PASS");
195 static void utc_nfc_ndef_message_get_rawdata_n(void)
198 ret = nfc_ndef_message_get_rawdata(NULL, NULL, NULL);
199 MY_ASSERT(__func__, ret != NFC_ERROR_NONE , "FAIL");
200 dts_pass(__func__, "PASS");
202 static void utc_nfc_ndef_message_append_record_p(void)
205 nfc_ndef_message_h message;
206 nfc_ndef_record_h record1;
207 ret = nfc_ndef_message_create(&message);
208 nfc_ndef_record_create_text(&record1, "test", "en-US", NFC_ENCODE_UTF_8);
209 ret = nfc_ndef_message_append_record(message, record1);
210 MY_ASSERT(__func__ , ret == NFC_ERROR_NONE , "FAIL");
211 nfc_ndef_message_destroy(message);
212 dts_pass(__func__, "PASS");
214 static void utc_nfc_ndef_message_append_record_n(void)
217 ret = nfc_ndef_message_append_record(NULL, NULL);
218 MY_ASSERT(__func__, ret != NFC_ERROR_NONE , "FAIL");
219 dts_pass(__func__, "PASS");
221 static void utc_nfc_ndef_message_insert_record_p(void)
224 nfc_ndef_message_h message;
225 nfc_ndef_record_h record1;
226 ret = nfc_ndef_message_create(&message);
227 nfc_ndef_record_create_text(&record1, "test", "en-US", NFC_ENCODE_UTF_8);
228 ret = nfc_ndef_message_insert_record(message,0, record1);
229 MY_ASSERT(__func__ , ret == NFC_ERROR_NONE , "FAIL");
230 nfc_ndef_message_destroy(message);
231 dts_pass(__func__, "PASS");
233 static void utc_nfc_ndef_message_insert_record_n(void)
236 ret = nfc_ndef_message_insert_record(NULL, 0 , NULL);
237 MY_ASSERT(__func__, ret != NFC_ERROR_NONE , "FAIL");
238 dts_pass(__func__, "PASS");
240 static void utc_nfc_ndef_message_remove_record_p(void)
243 nfc_ndef_message_h message;
244 nfc_ndef_record_h record1;
245 ret = nfc_ndef_message_create(&message);
246 nfc_ndef_record_create_text(&record1, "test", "en-US", NFC_ENCODE_UTF_8);
247 ret = nfc_ndef_message_insert_record(message,0, record1);
248 ret = nfc_ndef_message_remove_record(message, 0);
249 MY_ASSERT(__func__ , ret == NFC_ERROR_NONE , "FAIL");
250 nfc_ndef_message_destroy(message);
251 dts_pass(__func__, "PASS");
254 static void utc_nfc_ndef_message_remove_record_n(void)
257 ret = nfc_ndef_message_remove_record(NULL, 0);
258 MY_ASSERT(__func__, ret != NFC_ERROR_NONE , "FAIL");
259 dts_pass(__func__, "PASS");
261 static void utc_nfc_ndef_message_get_record_p(void)
264 nfc_ndef_message_h message;
265 nfc_ndef_record_h record1, record2;
266 ret = nfc_ndef_message_create(&message);
267 nfc_ndef_record_create_text(&record1, "test", "en-US", NFC_ENCODE_UTF_8);
268 ret = nfc_ndef_message_insert_record(message,0, record1);
269 ret = nfc_ndef_message_get_record(message, 0, &record2);
270 MY_ASSERT(__func__ , ret == NFC_ERROR_NONE , "FAIL");
271 nfc_ndef_message_destroy(message);
272 dts_pass(__func__, "PASS");
275 static void utc_nfc_ndef_message_get_record_n(void)
278 ret = nfc_ndef_message_get_record(NULL, 0 , NULL);
279 MY_ASSERT(__func__, ret != NFC_ERROR_NONE , "FAIL");
280 dts_pass(__func__, "PASS");