apply FSL(Flora Software License)
[framework/connectivity/nfc-manager.git] / TC / testcase / utc_net_nfc_client_nfc.c
1 /*
2   * Copyright 2012  Samsung Electronics Co., Ltd
3   *
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
7
8   *     http://www.tizenopensource.org/license
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
19 #include "net_nfc.h"
20 #include "net_nfc_typedef.h"
21 #include "net_nfc_util_private.h"
22
23 #ifdef SECURITY_SERVER
24 #include <security-server.h>
25 #endif
26
27
28 enum {
29         POSITIVE_TC_IDX = 0x01,
30         NEGATIVE_TC_IDX,
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 utc_net_nfc_initialize_p(void);
39 static void utc_net_nfc_initialize_n(void);
40 static void utc_net_nfc_deinitialize_p(void);
41 static void utc_net_nfc_deinitialize_n(void);
42 static void utc_net_nfc_set_response_callback_p(void);
43 static void utc_net_nfc_set_response_callback_n(void);
44 static void utc_net_nfc_unset_response_callback_p(void);
45 static void utc_net_nfc_unset_response_callback_n(void);
46
47 static void net_nfc_test_client_cb(net_nfc_message_e message, net_nfc_error_e result, void* data, void* user_param, void * trans_data )
48 {
49 };
50
51
52
53 struct tet_testlist tet_testlist[] = {
54         { utc_net_nfc_initialize_p , POSITIVE_TC_IDX },
55         { utc_net_nfc_initialize_n , NEGATIVE_TC_IDX },
56         { utc_net_nfc_deinitialize_p, POSITIVE_TC_IDX },
57         { utc_net_nfc_deinitialize_n , NEGATIVE_TC_IDX},
58         { utc_net_nfc_set_response_callback_p, 1},
59         { utc_net_nfc_set_response_callback_n, 2 },
60         { utc_net_nfc_unset_response_callback_p, 1},
61         { utc_net_nfc_unset_response_callback_n, 2},
62         { NULL, 0 },
63 };
64
65 //this method is called only once in start
66 static void startup(void)
67 {
68         /* start of TC */
69 }
70
71 static void cleanup(void)
72 {
73         /* end of TC */
74 }
75 static void utc_net_nfc_initialize_p(void)
76 {
77         int ret ;
78
79         ret = net_nfc_initialize();
80         net_nfc_deinitialize();
81
82         dts_pass(__func__, "PASS");
83 }
84
85 static void utc_net_nfc_initialize_n(void)
86 {
87         int ret=0;
88
89         ret = net_nfc_initialize();
90         net_nfc_deinitialize();
91
92         dts_pass(__func__, "PASS");
93 }
94
95 static void utc_net_nfc_deinitialize_p(void)
96 {
97         int ret ;
98
99         net_nfc_initialize();
100         ret = net_nfc_deinitialize();
101
102         dts_check_eq(__func__, ret, NET_NFC_OK, "net_nfc_deinitialize is failed");
103 }
104
105 static void utc_net_nfc_deinitialize_n(void)
106 {
107         int ret=0;
108
109         ret = net_nfc_deinitialize();
110
111         dts_check_eq(__func__, ret, NET_NFC_OK, "net_nfc_deinitialize not allow null");
112 }
113
114 static void utc_net_nfc_set_response_callback_p(void)
115 {
116         int ret ;
117         //net_nfc_response_cb cb;
118
119         net_nfc_initialize();
120
121         ret = net_nfc_set_response_callback(net_nfc_test_client_cb, NULL);
122
123         net_nfc_unset_response_callback();
124
125         dts_check_eq(__func__, ret, NET_NFC_OK, "net_nfc_set_response_callback is failed");
126 }
127
128 static void utc_net_nfc_set_response_callback_n(void)
129 {
130         int ret=0;
131
132         ret = net_nfc_set_response_callback(NULL, NULL);
133
134         dts_check_ne(__func__, ret, NET_NFC_OK, "net_nfc_set_response_callback not allow null");
135 }
136
137 static void utc_net_nfc_unset_response_callback_p(void)
138 {
139         int ret ;
140         //net_nfc_response_cb cb;
141
142         net_nfc_initialize();
143
144         net_nfc_set_response_callback(net_nfc_test_client_cb, NULL);
145
146         ret = net_nfc_unset_response_callback();
147
148         net_nfc_deinitialize();
149
150         dts_check_eq(__func__, ret, NET_NFC_OK, "net_nfc_unset_response_callback is failed");
151 }
152
153 static void utc_net_nfc_unset_response_callback_n(void)
154 {
155         int ret=0;
156
157         ret = net_nfc_unset_response_callback();
158
159         dts_check_ne(__func__, ret, NET_NFC_OK, "net_nfc_unset_response_callback not allow null");
160 }