2 * utc_network_bluetooth_pan_negative.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_set_connection_state_changed_n(void);
26 static void utc_network_bluetooth_panu_set_connection_state_changed_n(void);
27 static void utc_network_bluetooth_panu_connect_n(void);
28 static void utc_network_bluetooth_nap_disconnect_n(void);
29 static void utc_network_bluetooth_panu_disconnect_n(void);
31 void adapter_state_changed_cb_for_pan_n(int result,
32 bt_adapter_state_e adapter_state, void *user_data);
33 gboolean timeout_func(gpointer data);
36 struct tet_testlist tet_testlist[] = {
37 {utc_network_bluetooth_nap_set_connection_state_changed_n, NEGATIVE_TC_IDX},
38 {utc_network_bluetooth_panu_set_connection_state_changed_n, NEGATIVE_TC_IDX},
39 {utc_network_bluetooth_panu_connect_n, NEGATIVE_TC_IDX},
40 {utc_network_bluetooth_nap_disconnect_n, NEGATIVE_TC_IDX},
41 {utc_network_bluetooth_panu_disconnect_n, NEGATIVE_TC_IDX},
45 static void startup(void)
47 int ret = BT_ERROR_NONE;
51 mainloop = g_main_loop_new(NULL, FALSE);
54 if (bt_adapter_set_state_changed_cb(adapter_state_changed_cb_for_pan_n, "startup") != BT_ERROR_NONE) {
55 tet_printf("DTS may fail because bt_adapter_set_state_changed_cb() failed");
58 tet_printf("bt_adapter_disable() was called.");
59 ret = bt_adapter_disable();
60 if (ret == BT_ERROR_NONE) {
61 tet_printf("bt_adapter_disable() succeeded.");
62 timeout_id = g_timeout_add(60000, timeout_func, mainloop);
63 g_main_loop_run(mainloop);
64 g_source_remove(timeout_id);
65 } else if (ret == BT_ERROR_NOT_ENABLED) {
66 tet_printf("Bluetooth adapter is not enabled.");
68 tet_printf("DTS may fail because bt_adapter_disable() failed");
71 if (bt_adapter_unset_state_changed_cb() != BT_ERROR_NONE) {
72 tet_printf("bt_adapter_set_state_changed_cb() failed.");
75 tet_printf("TC start");
79 static void cleanup(void)
83 tet_printf("TC end.");
87 gboolean timeout_func(gpointer data)
89 tet_printf("Callback: Timeout.");
90 g_main_loop_quit((GMainLoop *)data);
98 * @brief Negative test case of bt_nap_set_connection_state_changed_cb()
101 void adapter_state_changed_cb_for_pan_n(int result,
102 bt_adapter_state_e adapter_state,
108 static void utc_network_bluetooth_nap_set_connection_state_changed_n(void)
110 int ret = BT_ERROR_NONE;
112 ret = bt_nap_set_connection_state_changed_cb(NULL, NULL);
113 dts_check_eq("bt_nap_set_connection_state_changed_cb", ret,
114 BT_ERROR_INVALID_PARAMETER,
115 "bt_nap_set_connection_state_changed_cb() failed.");
120 * @brief Negative test case of bt_panu_set_connection_state_changed_cb()
122 static void utc_network_bluetooth_panu_set_connection_state_changed_n(void)
124 int ret = BT_ERROR_NONE;
126 ret = bt_panu_set_connection_state_changed_cb(NULL, NULL);
127 dts_check_eq("bt_panu_set_connection_state_changed_cb", ret,
128 BT_ERROR_INVALID_PARAMETER,
129 "bt_panu_set_connection_state_changed_cb() failed.");
134 * @brief Negative test case of bt_panu_connect()
136 static void utc_network_bluetooth_panu_connect_n(void)
138 int ret = BT_ERROR_NONE;
139 ret = bt_panu_connect(NULL, BT_PANU_SERVICE_TYPE_NAP);
140 dts_check_eq("bt_panu_connect", ret, BT_ERROR_INVALID_PARAMETER,
141 "bt_panu_connect() failed.");
146 * @brief Negative test case of bt_nap_disconnect()
148 static void utc_network_bluetooth_nap_disconnect_n(void)
150 int ret = BT_ERROR_NONE;
151 ret = bt_nap_disconnect(NULL);
152 dts_check_eq("bt_nap_disconnect", ret, BT_ERROR_INVALID_PARAMETER,
153 "bt_nap_disconnect() failed.");
157 * @brief Negative test case of bt_panu_disconnect()
159 static void utc_network_bluetooth_panu_disconnect_n(void)
161 int ret = BT_ERROR_NONE;
162 ret = bt_panu_disconnect(NULL);
163 dts_check_eq("bt_panu_disconnect", ret, BT_ERROR_INVALID_PARAMETER,
164 "bt_panu_disconnect() failed.");