Correction additional about "Removed system controller."
[profile/ivi/ico-uxf-homescreen.git] / tests / apps-framework / tst_common.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 Connect/Disconnect to System Controller API
11  *
12  * @date    Aug-19-2013
13  */
14
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <string.h>
18 #include <unistd.h>
19
20 #include <glib.h>
21
22 #include "ico_syc_common.h"
23
24 #include "tst_common.h"
25
26 /* ----------------------------------------------- */
27 /* Variable                                        */
28 /* ----------------------------------------------- */
29
30 /* ----------------------------------------------- */
31 /* Define of static function                       */
32 /* ----------------------------------------------- */
33 static void tst_connect(void);
34 static void tst_disconnect(void);
35 static int ico_syc_common_test(void);
36
37 /* ----------------------------------------------- */
38 /* Public API Test                                 */
39 /* ----------------------------------------------- */
40 /* test connect */
41 static void
42 tst_connect(void)
43 {
44     int ret;
45     char *func = "ico_syc_connect";
46
47     ret = ico_syc_connect(NULL, NULL);
48     if (ret != 0) {
49         print_ng("%s (ret: %d)", func, ret);
50     }
51     print_ok("%s", func);
52
53     return;
54 }
55
56 /* test disconnect */
57 static void
58 tst_disconnect(void)
59 {
60     (void)ico_syc_disconnect();
61     print_ok("(void)ico_syc_disconnect");
62
63     return;
64 }
65
66 /* test main */
67 static int
68 ico_syc_common_test()
69 {
70     tst_connect();
71     sleep(1);
72     tst_disconnect();
73
74     sleep(3);
75
76     return 1;
77 }
78
79 /* ----------------------------------------------- */
80 /* Main                                            */
81 /* ----------------------------------------------- */
82 static GMainLoop *g_mainloop = NULL;
83
84 static gboolean
85 exit_program(gpointer data)
86 {
87     g_main_loop_quit(g_mainloop);
88
89     return FALSE;
90 }
91
92 /* main */
93 int
94 main(int argc, char **argv)
95 {
96     g_setenv("PKG_NAME", "org.test.ico.syc_common", 1);
97     g_mainloop = g_main_loop_new(NULL, 0);
98
99     printf("\n");
100     printf("##### ico_syc_common API Test Start #####\n");
101     ico_syc_common_test();
102     printf("##### ico_syc_common API Test End #####\n");
103     printf("\n");
104
105     g_timeout_add_seconds(1, exit_program, NULL);
106     g_main_loop_run(g_mainloop);
107
108     return 0;
109 }
110 /* vim: set expandtab ts=4 sw=4: */