Tizen 2.0 Release
[framework/api/nfc.git] / TC / testcase / utc_network_nfc.c
1 /*
2 * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17 #include <tet_api.h>
18 #include <nfc.h>
19
20 enum {
21         POSITIVE_TC_IDX = 0x01,
22         NEGATIVE_TC_IDX,
23 };
24
25 #define MY_ASSERT( fun , test , msg ) \
26 {\
27         if( !test ) \
28                 dts_fail(fun , msg ); \
29 }
30
31
32 static void startup(void);
33 static void cleanup(void);
34
35 void (*tet_startup)(void) = startup;
36 void (*tet_cleanup)(void) = cleanup;
37
38 static void nfc_manager_set_activation_changed_cb_p(void);
39 static void nfc_manager_set_activation_changed_cb_n(void);
40 static void nfc_manager_set_activation_p(void);
41 static void nfc_manager_set_activation_n(void);
42 static void nfc_manager_initialize_p(void);
43 static void nfc_manager_initialize_n(void);
44 static void nfc_manager_deinitialize_p(void);
45 static void nfc_manager_deinitialize_n(void);
46 static void nfc_manager_set_tag_discovered_cb_p(void);
47 static void nfc_manager_set_tag_discovered_cb_n(void);
48 static void nfc_manager_set_ndef_discovered_cb_p(void);
49 static void nfc_manager_set_ndef_discovered_cb_n(void);
50 static void nfc_manager_set_p2p_target_discovered_cb_p(void);
51 static void nfc_manager_set_p2p_target_discovered_cb_n(void);
52 static void nfc_manager_set_se_event_cb_p(void);
53 static void nfc_manager_set_se_event_cb_n(void);
54 static void nfc_manager_set_se_transaction_event_cb_p(void);
55 static void nfc_manager_set_se_transaction_event_cb_n(void);
56 static void nfc_manager_set_system_handler_enable_p(void);
57 static void nfc_manager_set_system_handler_enable_n(void);
58
59
60 void _activation_changed_cb(bool activated , void *user_data);
61 void _activation_completed_cb(int error, void *user_data);
62 void utc_test_cb(void * user_data);
63
64
65
66
67
68 struct tet_testlist tet_testlist[] = {
69         { nfc_manager_set_activation_changed_cb_p , POSITIVE_TC_IDX },
70         { nfc_manager_set_activation_changed_cb_n , NEGATIVE_TC_IDX },
71         { nfc_manager_set_activation_p , POSITIVE_TC_IDX },
72         { nfc_manager_set_activation_n , NEGATIVE_TC_IDX },
73         { nfc_manager_initialize_p , POSITIVE_TC_IDX },
74         { nfc_manager_initialize_n , NEGATIVE_TC_IDX },
75         { nfc_manager_deinitialize_p , POSITIVE_TC_IDX },
76         { nfc_manager_deinitialize_n , NEGATIVE_TC_IDX },
77         { nfc_manager_set_tag_discovered_cb_p , POSITIVE_TC_IDX },
78         { nfc_manager_set_tag_discovered_cb_n , NEGATIVE_TC_IDX },
79         { nfc_manager_set_ndef_discovered_cb_p , POSITIVE_TC_IDX },
80         { nfc_manager_set_ndef_discovered_cb_n , NEGATIVE_TC_IDX },
81         { nfc_manager_set_p2p_target_discovered_cb_p , POSITIVE_TC_IDX },
82         { nfc_manager_set_p2p_target_discovered_cb_n , NEGATIVE_TC_IDX },
83         { nfc_manager_set_se_event_cb_p , POSITIVE_TC_IDX },
84         { nfc_manager_set_se_event_cb_n , NEGATIVE_TC_IDX },
85         { nfc_manager_set_se_transaction_event_cb_p , POSITIVE_TC_IDX },
86         { nfc_manager_set_se_transaction_event_cb_n , NEGATIVE_TC_IDX },
87         { nfc_manager_set_system_handler_enable_p , POSITIVE_TC_IDX },
88         { nfc_manager_set_system_handler_enable_n , NEGATIVE_TC_IDX },
89
90         { NULL, 0 },
91 };
92
93 //this method is called only once in start
94 static void startup(void)
95 {
96         /* start of TC */
97 }
98
99 static void cleanup(void)
100 {
101         /* end of TC */
102 }
103
104 void _activation_changed_cb(bool activated , void *user_data)
105 {
106         if( activated == true)
107         {
108         }
109         else if( activated == false)
110         {
111         }
112 }
113
114 void  _activation_completed_cb(int error, void *user_data)
115 {
116         error = 0;
117         return error;
118 }
119
120 void utc_test_cb(void *user_data)
121 {
122         return true;
123 }
124
125
126 static void nfc_manager_set_activation_changed_cb_p(void)
127 {
128         int ret = NFC_ERROR_NONE;
129
130         ret = nfc_manager_set_activation_changed_cb(_activation_changed_cb , NULL);
131
132         dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_manager_set_activation_changed_cb_p is faild");
133 }
134
135 static void nfc_manager_set_activation_changed_cb_n(void)
136 {
137         int ret = NFC_ERROR_NONE;
138
139         ret = nfc_manager_set_activation_changed_cb(NULL , NULL);
140
141         dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_manager_set_activation_changed_cb_n not allow null");
142 }
143
144 static void nfc_manager_set_activation_p()
145 {
146         int ret = NFC_ERROR_NONE;
147
148         ret = nfc_manager_set_activation(1, _activation_completed_cb, NULL);
149
150         dts_pass(__func__, "PASS");
151 }
152
153 static void nfc_manager_set_activation_n()
154 {
155         int ret = NFC_ERROR_NONE;
156
157         ret = nfc_manager_set_activation(1, NULL, NULL);
158
159         dts_pass(__func__, "PASS");
160 }
161
162 static void nfc_manager_initialize_p()
163 {
164         int ret = NFC_ERROR_NONE;
165
166         ret = nfc_manager_initialize(NULL, NULL);
167
168         nfc_manager_deinitialize();
169
170         dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_manager_initialize_p is faild");
171 }
172
173 static void nfc_manager_initialize_n()
174 {
175         int ret = NFC_ERROR_NONE;
176
177         ret = nfc_manager_initialize(NULL, NULL);
178
179         dts_pass(__func__, "PASS");
180 }
181
182 static void nfc_manager_deinitialize_p()
183 {
184         int ret = NFC_ERROR_NONE;
185
186         nfc_manager_initialize(NULL, NULL);
187
188         ret = nfc_manager_deinitialize();
189
190         dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_manager_initialize_p is faild");
191 }
192
193 static void nfc_manager_deinitialize_n()
194 {
195         int ret = NFC_ERROR_NONE;
196
197         ret = nfc_manager_deinitialize();
198
199         dts_pass(__func__, "PASS");
200 }
201
202 static void nfc_manager_set_tag_discovered_cb_p()
203 {
204         int ret = NFC_ERROR_NONE;
205
206         ret = nfc_manager_set_tag_discovered_cb(utc_test_cb, NULL);
207
208         dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_manager_set_tag_discovered_cb_p is faild");
209 }
210
211 static void nfc_manager_set_tag_discovered_cb_n()
212 {
213         int ret = NFC_ERROR_NONE;
214
215         ret = nfc_manager_set_tag_discovered_cb(NULL, NULL);
216
217         dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_manager_set_tag_discovered_cb_n not allow null");
218 }
219
220 static void nfc_manager_set_ndef_discovered_cb_p()
221 {
222         int ret = NFC_ERROR_NONE;
223
224         ret = nfc_manager_set_ndef_discovered_cb(utc_test_cb , NULL);
225
226         dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_manager_set_ndef_discovered_cb_p is faild");
227 }
228
229 static void nfc_manager_set_ndef_discovered_cb_n()
230 {
231         int ret = NFC_ERROR_NONE;
232
233         ret = nfc_manager_set_ndef_discovered_cb(NULL, NULL);
234
235         dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_manager_set_ndef_discovered_cb_n not allow null");
236 }
237
238 static void nfc_manager_set_p2p_target_discovered_cb_p()
239 {
240         int ret = NFC_ERROR_NONE;
241
242         ret = nfc_manager_set_p2p_target_discovered_cb(utc_test_cb , NULL);
243
244         dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_manager_set_p2p_target_discovered_cb_p is faild");
245 }
246
247 static void nfc_manager_set_p2p_target_discovered_cb_n()
248 {
249         int ret;
250
251         ret = nfc_manager_set_p2p_target_discovered_cb(NULL, NULL);
252
253         dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_manager_set_p2p_target_discovered_cb_n not allow null");
254 }
255
256 static void nfc_manager_set_se_event_cb_p()
257 {
258         int ret = NFC_ERROR_NONE;
259
260         ret = nfc_manager_set_se_event_cb(utc_test_cb , NULL);
261
262         dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_manager_set_se_event_cb_p is faild");
263 }
264
265 static void nfc_manager_set_se_event_cb_n ()
266 {
267         int ret = NFC_ERROR_NONE;
268
269         ret = nfc_manager_set_se_event_cb(NULL, NULL);
270
271         dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_manager_set_se_event_cb_n not allow null");
272 }
273
274 static void nfc_manager_set_se_transaction_event_cb_p()
275 {
276         int ret = NFC_ERROR_NONE;
277
278         ret = nfc_manager_set_se_transaction_event_cb(utc_test_cb , NULL);
279
280         dts_check_eq(__func__, ret, NFC_ERROR_NONE, "nfc_manager_set_se_transaction_event_cb_p is faild");
281 }
282
283 static void nfc_manager_set_se_transaction_event_cb_n ()
284 {
285         int ret = NFC_ERROR_NONE;
286
287         ret = nfc_manager_set_se_transaction_event_cb(NULL, NULL);
288
289         dts_check_ne(__func__, ret, NFC_ERROR_NONE, "nfc_manager_set_se_transaction_event_cb_n not allow null");
290 }
291
292 static void nfc_manager_set_system_handler_enable_p()
293 {
294         int ret = NFC_ERROR_NONE;
295
296         ret = nfc_manager_set_system_handler_enable(true);
297
298         dts_pass(__func__, "PASS");
299
300 }
301
302 static void nfc_manager_set_system_handler_enable_n ()
303 {
304         int ret = NFC_ERROR_NONE;
305
306         ret = nfc_manager_set_system_handler_enable(NULL);
307
308         dts_pass(__func__, "PASS");
309 }