Tizen 2.0 Release
[framework/system/libslp-sensor.git] / TC / unit / utc_SensorFW_sf_unregister_event_func.c
1 #include <tet_api.h>
2 #include <sensor.h>
3
4 int handle = 0;
5
6 void my_callback_func(unsigned int event_type, sensor_event_data_t *event , void *data)
7 {
8 }
9
10 static void startup(void);
11 static void cleanup(void);
12
13 void (*tet_startup)(void) = startup;
14 void (*tet_cleanup)(void) = cleanup;
15
16 static void utc_SensorFW_sf_unregister_event_func_01(void);
17 static void utc_SensorFW_sf_unregister_event_func_02(void);
18
19 enum {
20         POSITIVE_TC_IDX = 0x01,
21         NEGATIVE_TC_IDX,
22 };
23
24 struct tet_testlist tet_testlist[] = {
25         { utc_SensorFW_sf_unregister_event_func_01, POSITIVE_TC_IDX },
26         { utc_SensorFW_sf_unregister_event_func_02, NEGATIVE_TC_IDX },
27         { NULL, 0},
28 };
29
30 static void startup(void)
31 {
32         handle = sf_connect(ACCELEROMETER_SENSOR);
33         sf_register_event(handle, ACCELEROMETER_EVENT_ROTATION_CHECK, NULL,  my_callback_func,NULL);
34
35 }
36
37 static void cleanup(void)
38 {
39         sf_disconnect(handle);
40 }
41 /**
42  * @brief Positive test case of sf_unregister_event()
43  */
44 static void utc_SensorFW_sf_unregister_event_func_01(void)
45 {
46         int r = 0;
47
48
49         r = sf_unregister_event(handle, ACCELEROMETER_EVENT_ROTATION_CHECK);
50
51         if (r < 0) {
52                 tet_infoline("sf_unregister_event() failed in positive test case");
53                 tet_result(TET_FAIL);
54                 return;
55         }
56         tet_result(TET_PASS);
57 }
58
59 /**
60  * @brief Negative test case of ug_init sf_unregister_event()
61  */
62 static void utc_SensorFW_sf_unregister_event_func_02(void)
63 {
64         int r = 0;
65
66         r = sf_unregister_event(handle, NULL);
67
68         if (r > 0) {
69                 tet_infoline("sf_unregister_event() failed in negative test case");
70                 tet_result(TET_FAIL);
71                 return;
72         }
73         tet_result(TET_PASS);
74 }