Add comments for line/function coverage analysis
[platform/core/system/libsvi.git] / test / capi_feedback.c
1 #include <stdio.h>
2 #include <feedback.h>
3
4 static void print_menu(void)
5 {
6         printf("Which do you want to do?\n");
7         printf("\t0 : Play\n");
8         printf("\t1 : Change the path\n");
9         printf("\t2 : Reset the path\n");
10         printf("\tothers : quit\n");
11 }
12
13 static void print_play_menu(void)
14 {
15         printf("Which do you want to do?\n");
16         printf("\t0. all\n");
17         printf("\t1. sound\n");
18         printf("\t2. vibration\n");
19         printf("\t3. led\n");
20         printf("\tothers. quit\n");
21 }
22
23 static void play(void)
24 {
25         int a, b, val;
26
27         while (1) {
28                 print_play_menu();
29                 printf("Please enter the play menu : ");
30                 scanf("%d", &a);
31                 if (a < 0 || a > 4)
32                         break;
33                 printf("Please input value (exit:-1) : ");
34                 scanf("%d", &b);
35                 if (b == -1)
36                         break;
37
38                 if (a == 0)
39                         val = feedback_play(b);
40                 else
41                         val = feedback_play_type(a, b);
42
43                 printf("ret value : %d\n", val);
44         }
45 }
46
47 int main(int argc, char* argv[])
48 {
49         char buf[4096] = {0,};
50         int val;
51         int a, b;
52
53         val = feedback_initialize();
54         if (val != FEEDBACK_ERROR_NONE) {
55                 printf("feedback_initialize error : %d\n", val);
56                 return -1;
57         }
58
59         while (1) {
60                 print_menu();
61                 printf("Please input value : ");
62                 scanf("%d", &a);
63
64                 switch (a) {
65                 case 0:
66                         play();
67                         break;
68                 case 1:
69                         printf("Please input type(sound:0,vib:1), enum, new path  : ");
70                         scanf("%d %d %s", &a, &b, buf);
71                         val = feedback_set_resource_path((a == 0) ? FEEDBACK_TYPE_SOUND : FEEDBACK_TYPE_VIBRATION, b, buf);
72                         printf("ret value : %d\n", val);
73                         break;
74                 case 2:
75                         printf("Please input type(sound:0,vib:1), enum  : ");
76                         scanf("%d %d", &a, &b);
77                         val = feedback_set_resource_path((a == 0) ? FEEDBACK_TYPE_SOUND : FEEDBACK_TYPE_VIBRATION, b, NULL);
78                         printf("ret value : %d\n", val);
79                         break;
80                 default:
81                         goto exit;
82                 }
83         }
84
85 exit:
86         val = feedback_deinitialize();
87         if (val != FEEDBACK_ERROR_NONE) {
88                 printf("feedback_initialize error : %d\n", val);
89                 return -1;
90         }
91
92         return 0;
93 }