unit: Add Manager API binding
[framework/connectivity/connman.git] / unit / test-connman.h
1 /*
2  *
3  *  Connection Manager
4  *
5  *  Copyright (C) 2007-2010  Intel Corporation. All rights reserved.
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License version 2 as
9  *  published by the Free Software Foundation.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  */
21
22 #include <glib.h>
23
24 #include <connman/dbus.h>
25
26 #include "connman.h"
27
28 struct test_session;
29
30 struct test_fix {
31         gpointer user_data;
32
33         GMainLoop *main_loop;
34         DBusConnection *main_connection;
35
36         /* session test cases */
37         unsigned int max_sessions;
38         struct test_session *session;
39 };
40
41 /* utils.c */
42 typedef void (* util_test_setup_cb) (struct test_fix *fix,
43                                         gconstpointer data);
44 typedef void (* util_test_teardown_cb) (struct test_fix *fix,
45                                         gconstpointer data);
46
47 gboolean util_quit_loop(gpointer fix);
48 guint util_idle_call(struct test_fix *fix, GSourceFunc func,
49                         GDestroyNotify notify);
50 guint util_call(struct test_fix *fix, GSourceFunc func,
51                 GDestroyNotify notify);
52 void util_test_add(const char *test_name, GSourceFunc test_func,
53                         util_test_setup_cb setup_cb,
54                         util_test_teardown_cb teardown_cb);
55 void util_setup(struct test_fix *fix, gconstpointer data);
56 void util_teardown(struct test_fix *fix, gconstpointer data);
57
58 typedef void (* notify_cb) (struct test_session *session);
59
60 enum connman_session_roaming_policy {
61         CONNMAN_SESSION_ROAMING_POLICY_UNKNOWN          = 0,
62         CONNMAN_SESSION_ROAMING_POLICY_DEFAULT          = 1,
63         CONNMAN_SESSION_ROAMING_POLICY_ALWAYS           = 2,
64         CONNMAN_SESSION_ROAMING_POLICY_FORBIDDEN        = 3,
65         CONNMAN_SESSION_ROAMING_POLICY_NATIONAL         = 4,
66         CONNMAN_SESSION_ROAMING_POLICY_INTERNATIONAL    = 5,
67 };
68
69 struct test_session_info {
70         char *bearer;
71         connman_bool_t online;
72         char *name;
73         /* ipv4, ipv6 dicts */
74         GSList *allowed_bearers;
75         connman_bool_t priority;
76         connman_bool_t avoid_handover;
77         connman_bool_t stay_connected;
78         unsigned int periodic_connect;
79         unsigned int idle_timeout;
80         connman_bool_t ecall;
81         enum connman_session_roaming_policy roaming_policy;
82         char *interface;
83         unsigned int marker;
84 };
85
86 struct test_session {
87         gpointer user_data;
88
89         struct test_fix *fix;
90         DBusConnection *connection;
91
92         char *session_path;
93         char *notify_path;
94         notify_cb notify;
95
96         struct test_session_info *info;
97 };
98
99 /* manager-api.c */
100 DBusMessage *manager_get_services(DBusConnection *connection);
101 DBusMessage *manager_create_session(DBusConnection *connection,
102                                         struct test_session_info *info,
103                                         const char *notifier_path);
104 DBusMessage *manager_destroy_session(DBusConnection *connection,
105                                         const char *notifier_path);
106 DBusMessage *manager_set_session_mode(DBusConnection *connection,
107                                         connman_bool_t enable);
108
109
110 /* #define DEBUG */
111 #ifdef DEBUG
112 #include <stdio.h>
113
114 #define LOG(fmt, arg...) do { \
115         fprintf(stdout, "%s:%s() " fmt "\n", \
116                         __FILE__, __FUNCTION__ , ## arg); \
117 } while (0)
118 #else
119 #define LOG(fmt, arg...)
120 #endif