Fix initializations in tests
[profile/ivi/weekeyboard.git] / src / wkb-ibus-test.c
1 /*
2  * Copyright © 2013 Intel Corporation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "wkb-ibus.h"
18
19 #define _GNU_SOURCE
20 #include <signal.h>
21
22 #include <Eina.h>
23 #include <Eet.h>
24 #include <Ecore.h>
25 #include <Eldbus.h>
26
27 static void
28 _finish(int foo)
29 {
30    printf("FINISH\n");
31    wkb_ibus_shutdown();
32 }
33
34 static Eina_Bool
35 _connect_timer(void *data)
36 {
37    return !wkb_ibus_connect();
38 }
39
40 int
41 main (int argc, char *argv[])
42 {
43    int ret = 0;
44    if (!eet_init())
45      {
46         printf("Error initializing eet");
47         return 1;
48      }
49
50    if (!ecore_init())
51      {
52         printf("Error initializing ecore");
53         ret = 1;
54         goto ecore_err;
55      }
56
57    if (!eldbus_init())
58      {
59         printf("Error initializing eldbus");
60         ret = 1;
61         goto eldbus_err;
62      }
63
64    if (!wkb_ibus_init())
65      {
66         printf("Error initializing ibus");
67         ret = 1;
68         goto end;
69      }
70
71    ecore_timer_add(1, _connect_timer, NULL);
72
73    signal(SIGTERM, _finish);
74    signal(SIGINT, _finish);
75
76    ecore_main_loop_begin();
77
78 end:
79    eldbus_shutdown();
80
81 eldbus_err:
82    ecore_shutdown();
83
84 ecore_err:
85    eet_shutdown();
86
87    return ret;
88 }