Correction additional about "Removed system controller."
[profile/ivi/ico-uxf-homescreen.git] / tests / apps-framework / tst_inputctl.c
1 /*
2  * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
3  *
4  * This program is licensed under the terms and conditions of the
5  * Apache License, version 2.0.  The full text of the Apache License is at
6  * http://www.apache.org/licenses/LICENSE-2.0
7  *
8  */
9 /**
10  * @brief   test suite for Input Control API
11  *
12  * @date    July-31-2013
13  */
14
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <string.h>
18 #include <unistd.h>
19
20 #include <Ecore.h>
21 #include <Eina.h>
22
23 #include "ico_syc_common.h"
24 #include "ico_syc_inputctl.h"
25
26 #include "tst_common.h"
27
28 /* ----------------------------------------------- */
29 /* Variable                                        */
30 /* ----------------------------------------------- */
31
32
33 /* ----------------------------------------------- */
34 /* Define of static function                       */
35 /* ----------------------------------------------- */
36 static void tst_add_input(const char *appid, const char *device,
37                           int input, int fix, int keycode);
38 static void tst_delete_input(const char *appid, const char *device,
39                              int input);
40 static void tst_send_input(const char *appid, int surface, int ev_type,
41                            int deviceno, int ev_time, int ev_code, int ev_value);
42 static Eina_Bool ico_syc_inputctl_test(void *data);
43
44 /* ----------------------------------------------- */
45 /* Public API Test                                 */
46 /* ----------------------------------------------- */
47 /* test add input */
48 static void
49 tst_add_input(const char *appid, const char *device,
50               int input, int fix, int keycode)
51 {
52     int ret;
53     char *func = "ico_syc_add_input";
54
55     ret = ico_syc_add_input(appid, device, input, fix, keycode);
56     if (ret != 0) {
57         print_ng("%s (ret: %d)", func, ret);
58         return;
59     }
60     print_ok("%s", func);
61
62     return;
63 }
64
65 /* test delete input */
66 static void
67 tst_delete_input(const char *appid, const char *device, int input)
68 {
69     int ret;
70     char *func = "ico_syc_delete_input";
71
72     ret = ico_syc_delete_input(appid, device, input);
73     if (ret != 0) {
74         print_ng("%s (ret: %d)", func, ret);
75         return;
76     }
77     print_ok("%s", func);
78
79     return;
80 }
81
82 /* test send input */
83 static void
84 tst_send_input(const char *appid, int surface, int ev_type,
85                int deviceno, int ev_time, int ev_code, int ev_value)
86 {
87 #if 0           /* SystemController 0.9.21(with GENIVI ivi-shell) not support send_input */
88     int ret;
89     char *func = "ico_syc_send_input";
90
91     ret = ico_syc_send_input(appid, surface, ev_type, deviceno,
92                              ev_time, ev_code, ev_value);
93     if (ret != 0) {
94         print_ng("%s (ret: %d)", func, ret);
95         return;
96     }
97     print_ok("%s", func);
98 #endif
99     return;
100 }
101
102 /* test main */
103 static Eina_Bool
104 ico_syc_inputctl_test(void *data)
105 {
106     const char *appid   = "org.test.app.testapp";
107     const char *device  = "input.dev";
108     int input           = 100;
109     int fix             = ICO_SYC_INPUT_ALLOC_FIX;
110     int keycode         = 10;
111     int surface         = 12345;
112     int ev_type         = ICO_SYC_INPUT_TYPE_POINTER;
113     int deviceno        = 123;
114     int ev_time         = 2345;
115     int ev_code         = 1;
116     int ev_value        = 1;
117
118     printf("\n");
119     printf("##### ico_syc_inputctl API Test Start #####\n");
120
121     tst_add_input(appid, device, input, fix, keycode);
122     usleep(5000);
123     tst_delete_input(appid, device, input);
124     usleep(5000);
125     tst_send_input(appid, surface, ev_type, deviceno, ev_time, ev_code, ev_value);
126
127     printf("##### ico_syc_inputctl API Test End #####\n");
128     printf("\n");
129
130     return ECORE_CALLBACK_CANCEL;
131 }
132 /* ------------------------ */
133 /* quit test callback       */
134 /* ------------------------ */
135 static Eina_Bool
136 quit_test(void *data)
137 {
138     ico_syc_disconnect();
139     ecore_main_loop_quit();
140
141     return ECORE_CALLBACK_CANCEL;
142 }
143
144 /* ----------------------------------------------- */
145 /* Main                                            */
146 /* ----------------------------------------------- */
147 /* main */
148 int
149 main(int argc, char **argv)
150 {
151     ecore_init();
152
153     ico_syc_connect(NULL, NULL);
154
155     ecore_timer_add(1, ico_syc_inputctl_test, NULL);
156     ecore_timer_add(5, quit_test, NULL);
157
158     ecore_main_loop_begin();
159     ecore_shutdown();
160
161     return 0;
162 }
163 /* vim: set expandtab ts=4 sw=4: */