2 * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
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
10 * @brief test suite for User Control API
23 #include "ico_syc_common.h"
24 #include "ico_syc_userctl.h"
26 #include "tst_common.h"
28 /* ----------------------------------------------- */
30 /* ----------------------------------------------- */
32 /* ----------------------------------------------- */
33 /* Define of static function */
34 /* ----------------------------------------------- */
35 static void _check_userlist(const char *ev_name, ico_syc_userlist_t *list);
36 static void _syc_callback(const ico_syc_ev_e event,
37 const void *detail, void *user_data);
38 static void tst_change_user(void);
39 static void tst_get_userlist(void);
40 static void tst_get_lastinfo(void);
41 static void tst_set_lastinfo(void);
42 static Eina_Bool ico_syc_userctl_test(void *data);
44 /* ----------------------------------------------- */
46 /* ----------------------------------------------- */
48 _check_userlist(const char *ev_name, ico_syc_userlist_t *list)
54 printf("--- %s userlist[%d] (", ev_name, list->user_num);
55 for (id = 0; id < list->user_num; id++) {
56 if (id > 0) printf(", ");
57 name = *(list->userlist);
59 if (strcmp(name, TST_USER_A) != 0 && strcmp(name, TST_USER_B) != 0
60 && strcmp(name, TST_USER_C) != 0) {
65 printf("), login[%s]\n", list->user_login);
67 if (strcmp(list->user_login, TST_USER_A) != 0) {
71 if (check_flag == 0) {
72 print_ok("callback (%s)", ev_name);
75 print_ng("callback (%s)", ev_name);
82 _syc_callback(const ico_syc_ev_e event,
83 const void *detail, void *user_data)
86 case ICO_SYC_EV_USERLIST:
87 _check_userlist("ICO_SYC_EV_USERLIST", (ico_syc_userlist_t *)detail);
89 case ICO_SYC_EV_AUTH_FAIL:
91 printf("--- ICO_SYC_EV_AUTH_FAIL (detail is NULL)\n");
92 print_ok("callback (ICO_SYC_EV_AUTH_FAIL)");
95 printf("--- ICO_SYC_EV_AUTH_FAIL (detail is not NULL)\n");
96 print_ng("callback (ICO_SYC_EV_AUTH_FAIL)");
99 case ICO_SYC_EV_LASTINFO:
100 printf("--- lastinfo: %s\n", (char *)detail);
101 if (strcmp((char *)detail, TST_LASTINFO) == 0) {
102 print_ok("callback (ICO_SYC_EV_LASTINFO)");
105 print_ng("callback (ICO_SYC_EV_LASTINFO)");
115 /* test change user */
117 tst_change_user(void)
119 (void)ico_syc_change_user("Alice", "");
120 print_ok("(void)ico_syc_change_user");
125 /* test get userlist */
127 tst_get_userlist(void)
129 (void)ico_syc_get_userlist();
130 print_ok("(void)ico_syc_get_userlist");
135 /* test get lastinfo */
137 tst_get_lastinfo(void)
139 (void)ico_syc_get_lastinfo();
140 print_ok("(void)ico_syc_get_lastinfo");
145 /* test set lastinfo */
147 tst_set_lastinfo(void)
149 (void)ico_syc_set_lastinfo(TST_LASTINFO);
150 print_ok("(void)ico_syc_set_lastinfo");
157 ico_syc_userctl_test(void *data)
160 printf("##### ico_syc_userctl API Test Start #####\n");
170 printf("##### ico_syc_userctl API Test End #####\n");
173 return ECORE_CALLBACK_CANCEL;
176 /* ------------------------ */
177 /* quit test callback */
178 /* ------------------------ */
180 quit_test(void *data)
182 ico_syc_disconnect();
183 ecore_main_loop_quit();
185 return ECORE_CALLBACK_CANCEL;
188 /* ----------------------------------------------- */
190 /* ----------------------------------------------- */
193 main(int argc, char **argv)
197 ico_syc_connect(_syc_callback, NULL);
199 ecore_timer_add(1, ico_syc_userctl_test, NULL);
200 ecore_timer_add(5, quit_test, NULL);
202 ecore_main_loop_begin();
207 /* vim: set expandtab ts=4 sw=4: */