2 * utc_network_bluetooth_pan_positive.c
4 * Created on: 20-Sep-2013
13 POSITIVE_TC_IDX = 0x01,
17 static void startup(void);
18 static void cleanup(void);
20 static GMainLoop *mainloop;
22 void (*tet_startup) (void) = startup;
23 void (*tet_cleanup) (void) = cleanup;
25 static void utc_network_bluetooth_nap_activate_p(void);
26 static void utc_network_bluetooth_nap_deactivate_p(void);
27 static void utc_network_bluetooth_nap_disconnect_all_p(void);
28 static void utc_network_bluetooth_nap_set_connection_state_changed_p(void);
29 static void utc_network_bluetooth_nap_unset_connection_state_changed_p(void);
30 static void utc_network_bluetooth_panu_set_connection_state_changed_p(void);
31 static void utc_network_bluetooth_panu_unset_connection_state_changed_p(void);
32 static void utc_network_bluetooth_panu_connect_p(void);
33 static void utc_network_bluetooth_nap_disconnect_p(void);
34 static void utc_network_bluetooth_panu_disconnect_p(void);
36 void connection_state_changed_cb_for_nap_p(bool connected,
37 const char *remote_address,
38 const char *interface_name,
40 void connection_state_changed_cb_for_panu_p(int result,
42 const char *remote_address,
43 bt_panu_service_type_e type,
46 void adapter_state_changed_cb_for_pan_p(int result,
47 bt_adapter_state_e adapter_state,
49 gboolean timeout_func(gpointer data);
51 struct tet_testlist tet_testlist[] = {
52 {utc_network_bluetooth_nap_activate_p, POSITIVE_TC_IDX},
53 {utc_network_bluetooth_nap_set_connection_state_changed_p, POSITIVE_TC_IDX},
54 {utc_network_bluetooth_nap_unset_connection_state_changed_p, POSITIVE_TC_IDX},
55 {utc_network_bluetooth_nap_deactivate_p, POSITIVE_TC_IDX},
56 {utc_network_bluetooth_nap_disconnect_all_p, POSITIVE_TC_IDX},
57 {utc_network_bluetooth_panu_connect_p, POSITIVE_TC_IDX},
58 {utc_network_bluetooth_panu_set_connection_state_changed_p, POSITIVE_TC_IDX},
59 {utc_network_bluetooth_panu_unset_connection_state_changed_p, POSITIVE_TC_IDX},
60 {utc_network_bluetooth_nap_disconnect_p, POSITIVE_TC_IDX},
61 {utc_network_bluetooth_panu_disconnect_p, POSITIVE_TC_IDX},
66 static void startup(void)
68 int ret = BT_ERROR_NONE;
72 mainloop = g_main_loop_new(NULL, FALSE);
75 if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_pan_p, "startup") != BT_ERROR_NONE) {
76 tet_printf("DTS may fail because bt_adapter_set_state_changed_cb() failed");
79 tet_printf("bt_adapter_enable() was called.");
81 ret = bt_adapter_enable();
82 if (ret == BT_ERROR_NONE) {
83 tet_printf("bt_adapter_enable() succeeded.");
84 timeout_id = g_timeout_add(60000, timeout_func, mainloop);
85 g_main_loop_run(mainloop);
86 g_source_remove(timeout_id);
87 } else if (ret != BT_ERROR_ALREADY_DONE) {
88 tet_printf("DTS may fail because bt_adapter_disable() failed");
91 if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE) {
92 tet_printf("bt_adapter_set_state_changed_cb() failed.");
95 tet_printf("TC start");
98 static void cleanup(void)
102 tet_printf("TC end.");
105 gboolean timeout_func(gpointer data)
107 tet_printf("Callback: Timeout.");
108 g_main_loop_quit((GMainLoop *) data);
113 * @brief Callback funtions
116 void adapter_state_changed_cb_for_pan_p(int result,
117 bt_adapter_state_e adapter_state,
123 void connection_state_changed_cb_for_nap_p(bool connected,
124 const char *remote_address,
125 const char *interface_name,
131 void connection_state_changed_cb_for_panu_p(int result,
133 const char *remote_address,
134 bt_panu_service_type_e type,
141 * @brief Positive test case of bt_nap_activate()
143 static void utc_network_bluetooth_nap_activate_p(void)
145 int ret = BT_ERROR_NONE;
146 ret = bt_nap_activate();
147 if (ret != BT_ERROR_ALREADY_DONE) {
148 dts_check_eq("bt_nap_activate", ret, BT_ERROR_NONE, "bt_nap_activate() failed.");
150 dts_check_eq("bt_nap_activate", ret, BT_ERROR_ALREADY_DONE,
151 "bt_nap_activate() failed.");
156 * @brief Positive test case of bt_nap_deactivate()
158 static void utc_network_bluetooth_nap_deactivate_p(void)
160 int ret = BT_ERROR_NONE;
161 ret = bt_nap_deactivate();
162 dts_check_eq("bt_nap_deactivate", ret, BT_ERROR_NONE,
163 "bt_nap_deactivate() failed.");
168 * @brief Positive test case of bt_nap_disconnect_all()
170 static void utc_network_bluetooth_nap_disconnect_all_p(void)
172 int ret = BT_ERROR_NONE;
173 ret = bt_nap_disconnect_all();
174 dts_check_eq("bt_nap_disconnect_all", ret, BT_ERROR_NONE,
175 "bt_nap_disconnect_all() failed.");
179 * @brief Positive test case of bt_nap_set_connection_state_changed_cb()
181 static void utc_network_bluetooth_nap_set_connection_state_changed_p(void)
183 int ret = BT_ERROR_NONE;
184 ret = bt_nap_set_connection_state_changed_cb(connection_state_changed_cb_for_nap_p, NULL);
185 dts_check_eq("bt_nap_set_connection_state_changed_cb", ret, BT_ERROR_NONE,
186 "bt_nap_set_connection_state_changed_cb() failed.");
191 * @brief Positive test case of bt_nap_unset_connection_state_changed_cb()
193 static void utc_network_bluetooth_nap_unset_connection_state_changed_p(void)
195 int ret = BT_ERROR_NONE;
196 ret = bt_nap_unset_connection_state_changed_cb();
197 dts_check_eq("bt_nap_unset_connection_state_changed_cb", ret, BT_ERROR_NONE,
198 "bt_nap_unset_connection_state_changed_cb() failed.");
203 * @brief Positive test case of bt_panu_set_connection_state_changed_cb()
205 static void utc_network_bluetooth_panu_set_connection_state_changed_p(void)
207 int ret = BT_ERROR_NONE;
209 ret = bt_panu_set_connection_state_changed_cb(connection_state_changed_cb_for_panu_p, NULL);
210 dts_check_eq("bt_panu_set_connection_state_changed_cb", ret, BT_ERROR_NONE,
211 "bt_panu_set_connection_state_changed_cb() failed.");
217 * @brief Positive test case of bt_panu_unset_connection_state_changed_cb()
219 static void utc_network_bluetooth_panu_unset_connection_state_changed_p(void)
221 int ret = BT_ERROR_NONE;
222 ret = bt_panu_unset_connection_state_changed_cb();
223 dts_check_eq("bt_panu_unset_connection_state_changed_cb", ret, BT_ERROR_NONE,
224 "bt_panu_unset_connection_state_changed_cb() failed.");
229 * @brief Positive test case of bt_panu_connect()
231 static void utc_network_bluetooth_panu_connect_p(void)
233 int ret = BT_ERROR_NONE;
234 const char *remote_address = "00:00:00:00:00:00";
235 ret = bt_panu_connect(remote_address, BT_PANU_SERVICE_TYPE_NAP);
236 dts_check_eq("bt_panu_connect", ret, BT_ERROR_NONE,
237 "bt_panu_connect() failed.");
242 * @brief Positive test case of bt_nap_disconnect()
244 static void utc_network_bluetooth_nap_disconnect_p(void)
246 int ret = BT_ERROR_NONE;
247 const char *remote_address = "00:00:00:00:00:00";
248 ret = bt_nap_disconnect(remote_address);
249 dts_check_eq("bt_nap_disconnect", ret, BT_ERROR_NONE,
250 "bt_nap_disconnect() failed.");
255 * @brief Positive test case of bt_panu_disconnect()
257 static void utc_network_bluetooth_panu_disconnect_p(void)
259 int ret = BT_ERROR_NONE;
260 const char *remote_address = "00:00:00:00:00:00";
261 ret = bt_panu_disconnect(remote_address);
262 dts_check_eq("bt_panu_disconnect", ret, BT_ERROR_NONE,
263 "bt_panu_disconnect() failed.");