2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
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.
20 #include "net_nfc_ndef_message.h"
21 #include "net_nfc_util_private.h"
22 #include "net_nfc.h" // to use net_nfc_data
26 POSITIVE_TC_IDX = 0x01,
29 static void startup(void);
30 static void cleanup(void);
32 void (*tet_startup)(void) = startup;
33 void (*tet_cleanup)(void) = cleanup;
35 static void utc_net_nfc_create_ndef_message_p(void);
36 static void utc_net_nfc_create_ndef_message_n(void);
37 static void utc_net_nfc_create_rawdata_from_ndef_message_p(void);
38 static void utc_net_nfc_create_rawdata_from_ndef_message_n(void);
39 static void utc_net_nfc_create_ndef_message_from_rawdata_p(void);
40 static void utc_net_nfc_create_ndef_message_from_rawdata_n(void);
41 static void utc_net_nfc_get_ndef_message_byte_length_p(void);
42 static void utc_net_nfc_get_ndef_message_byte_length_n(void);
43 static void utc_net_nfc_append_record_to_ndef_message_p(void);
44 static void utc_net_nfc_append_record_to_ndef_message_n(void);
45 static void utc_net_nfc_free_ndef_message_p(void);
46 static void utc_net_nfc_free_ndef_message_n(void);
47 static void utc_net_nfc_get_ndef_message_record_count_p(void);
48 static void utc_net_nfc_get_ndef_message_record_count_n(void);
53 struct tet_testlist tet_testlist[] = {
54 { utc_net_nfc_create_ndef_message_p , POSITIVE_TC_IDX },
55 { utc_net_nfc_create_ndef_message_n , NEGATIVE_TC_IDX },
56 { utc_net_nfc_create_rawdata_from_ndef_message_p, POSITIVE_TC_IDX },
57 { utc_net_nfc_create_rawdata_from_ndef_message_n , NEGATIVE_TC_IDX},
58 { utc_net_nfc_create_ndef_message_from_rawdata_p, 1},
59 { utc_net_nfc_create_ndef_message_from_rawdata_n, 2 },
60 { utc_net_nfc_get_ndef_message_byte_length_p, 1},
61 { utc_net_nfc_get_ndef_message_byte_length_n, 2},
62 { utc_net_nfc_append_record_to_ndef_message_p, 1},
63 { utc_net_nfc_append_record_to_ndef_message_n, 2},
64 { utc_net_nfc_free_ndef_message_p, 1},
65 { utc_net_nfc_free_ndef_message_n, 2},
66 { utc_net_nfc_get_ndef_message_record_count_p, 1},
67 { utc_net_nfc_get_ndef_message_record_count_n, 2},
71 //this method is called only once in start
72 static void startup(void)
77 static void cleanup(void)
81 static void utc_net_nfc_create_ndef_message_p(void)
84 ndef_message_h message;
86 ret = net_nfc_create_ndef_message(&message);
87 net_nfc_free_ndef_message(message);
89 dts_check_eq(__func__, ret, NET_NFC_OK, "net_nfc_create_ndef_message is failed");
92 static void utc_net_nfc_create_ndef_message_n(void)
96 ret = net_nfc_create_ndef_message( NULL);
98 dts_check_ne(__func__, ret, NET_NFC_OK, "net_nfc_create_ndef_message not allow null");
101 static void utc_net_nfc_create_rawdata_from_ndef_message_p(void)
104 char url[] = "samsung.com";
105 ndef_record_h record = NULL;
106 ndef_message_h msg = NULL;
107 data_h rawdata = NULL;
109 net_nfc_create_uri_type_record(&record, url, NET_NFC_SCHEMA_HTTPS_WWW);
111 net_nfc_create_ndef_message(&msg);
113 net_nfc_append_record_to_ndef_message(msg, record);
115 ret = net_nfc_create_rawdata_from_ndef_message (msg, &rawdata);
117 dts_check_eq(__func__, ret, NET_NFC_OK, "net_nfc_create_rawdata_from_ndef_message is failed");
120 static void utc_net_nfc_create_rawdata_from_ndef_message_n(void)
124 ret = net_nfc_create_rawdata_from_ndef_message (NULL, NULL);
126 dts_check_ne(__func__, ret, NET_NFC_OK, "net_nfc_create_rawdata_from_ndef_message not allow null");
129 static void utc_net_nfc_create_ndef_message_from_rawdata_p(void)
132 uint8_t url[] = "samsung.com";
133 ndef_message_s* msg = NULL;
134 data_s* rawdata = NULL;
136 rawdata = calloc(1, sizeof(data_s));
137 msg = calloc(1, sizeof(ndef_message_s));
139 rawdata->buffer = url;
140 rawdata->length = 11;
142 ret = net_nfc_create_ndef_message_from_rawdata ((ndef_message_h*)msg, (data_h)rawdata);
144 net_nfc_free_ndef_message((ndef_message_h)msg);
146 dts_check_eq(__func__, ret, NET_NFC_OK, "net_nfc_create_ndef_message_from_rawdata is failed");
149 static void utc_net_nfc_create_ndef_message_from_rawdata_n(void)
153 ret = net_nfc_create_ndef_message_from_rawdata (NULL, NULL);
155 dts_check_ne(__func__, ret, NET_NFC_OK,"net_nfc_create_ndef_message_from_rawdata not allow null");
158 static void utc_net_nfc_get_ndef_message_byte_length_p(void)
161 char url[] = "samsung.com";
162 ndef_record_h record = NULL;
163 ndef_message_h msg = NULL;
166 net_nfc_create_uri_type_record(&record, url, NET_NFC_SCHEMA_HTTPS_WWW);
168 net_nfc_create_ndef_message(&msg);
170 net_nfc_append_record_to_ndef_message(msg, record);
172 ret = net_nfc_get_ndef_message_byte_length( msg , &length);
174 dts_check_eq(__func__, ret, NET_NFC_OK, "net_nfc_get_ndef_message_byte_length is failed");
177 static void utc_net_nfc_get_ndef_message_byte_length_n(void)
181 ret = net_nfc_get_ndef_message_byte_length (NULL, NULL);
183 dts_check_ne(__func__, ret, NET_NFC_OK,"net_nfc_get_ndef_message_byte_length not allow null");
186 static void utc_net_nfc_append_record_to_ndef_message_p(void)
189 char url[] = "samsung.com";
190 ndef_record_h record = NULL;
191 ndef_message_h msg = NULL;
193 net_nfc_create_uri_type_record(&record, url, NET_NFC_SCHEMA_HTTPS_WWW);
195 net_nfc_create_ndef_message(&msg);
197 ret = net_nfc_append_record_to_ndef_message(msg, record);
199 dts_check_eq(__func__, ret, NET_NFC_OK, "net_nfc_append_record_to_ndef_message is failed");
202 static void utc_net_nfc_append_record_to_ndef_message_n(void)
206 ret = net_nfc_append_record_to_ndef_message (NULL, NULL);
208 dts_check_ne(__func__, ret, NET_NFC_OK,"net_nfc_append_record_to_ndef_message not allow null");
211 static void utc_net_nfc_free_ndef_message_p(void)
214 ndef_message_h message;
216 net_nfc_create_ndef_message(&message);
217 ret = net_nfc_free_ndef_message(message);
219 dts_check_eq(__func__, ret, NET_NFC_OK, "utc_net_nfc_free_ndef_message_n is failed");
222 static void utc_net_nfc_free_ndef_message_n(void)
226 ret = net_nfc_free_ndef_message( NULL);
228 dts_check_ne(__func__, ret, NET_NFC_OK, "utc_net_nfc_free_ndef_message_n not allow null");
231 static void utc_net_nfc_get_ndef_message_record_count_p(void)
234 char url[] = "samsung.com";
235 ndef_record_h record = NULL;
236 ndef_message_h msg = NULL;
239 net_nfc_create_uri_type_record(&record, url, NET_NFC_SCHEMA_HTTPS_WWW);
241 net_nfc_create_ndef_message(&msg);
243 net_nfc_append_record_to_ndef_message(msg, record);
245 ret = net_nfc_get_ndef_message_record_count( msg , &count );
247 dts_check_eq(__func__, ret, NET_NFC_OK, "net_nfc_get_ndef_message_record_count is failed");
250 static void utc_net_nfc_get_ndef_message_record_count_n(void)
254 ret = net_nfc_get_ndef_message_record_count( NULL , NULL);
256 dts_check_ne(__func__, ret, NET_NFC_OK, "net_nfc_get_ndef_message_record_count not allow null");