tizen 2.3.1 release
[framework/system/libfeedback.git] / test / feedback_test.c
1 /*
2  *  libfeedback
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Seokkyu Jang <seokkyu.jang@samsung.com>
7  * Contact: Sangil Yoon <si83.yoon@samsung.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */
22
23 #include <stdio.h>
24 #include "feedback.h"
25
26 int main(int argc, char* argv[])
27 {
28         char buf[4096] = {0,};
29         char *temp = NULL;
30         int val, input;
31         int a, b;
32
33         val = feedback_initialize();
34         if (val != FEEDBACK_ERROR_NONE) {
35                 printf("feedback_initialize error : %d\n", val);
36                 return -1;
37         }
38
39         while(1)
40         {
41                 printf("Which do you want to work play(0) or change the path(1)?");
42                 scanf("%d", &a);
43                 if (a == 0) {
44                         printf("Please input value : ");
45                         scanf("%d", &a);
46                         if (a == -1)
47                                 break;
48                         val = feedback_play(a);
49                         printf("ret value : %d\n", val);        
50                 } else if (a == 1) {
51                         printf("Please input type(sound:0,vib:1), enum, new path  : ");
52                         scanf("%d %d %s", &a, &b, buf);
53                         val = feedback_get_resource_path( (a == 0) ? FEEDBACK_TYPE_SOUND : FEEDBACK_TYPE_VIBRATION, b, &temp);
54                         printf("Prev : %s", temp);
55                         free(temp);
56                         val = feedback_set_resource_path( (a == 0) ? FEEDBACK_TYPE_SOUND : FEEDBACK_TYPE_VIBRATION, b, buf);
57                         val = feedback_get_resource_path( (a == 0) ? FEEDBACK_TYPE_SOUND : FEEDBACK_TYPE_VIBRATION, b, &temp);
58                         printf("Curr : %s", temp);
59                         free(temp);
60                 } else {
61                         printf("Input error!!");
62                 }
63         }
64
65         val = feedback_deinitialize();
66         if (val != FEEDBACK_ERROR_NONE) {
67                 printf("feedback_initialize error : %d\n", val);
68                 return -1;
69         }
70
71         return 0;
72 }