5 * Copyright (C) 2007-2010 Intel Corporation. All rights reserved.
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.
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.
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
24 #include <connman/dbus.h>
26 #include "../src/connman.h"
38 DBusConnection *main_connection;
42 struct test_manager manager;
43 GSourceFunc manager_changed;
45 /* session test cases */
46 unsigned int max_sessions;
47 struct test_session *session;
51 typedef void (* util_test_setup_cb) (struct test_fix *fix,
53 typedef void (* util_test_teardown_cb) (struct test_fix *fix,
56 gboolean util_quit_loop(gpointer fix);
57 guint util_idle_call(struct test_fix *fix, GSourceFunc func,
58 GDestroyNotify notify);
59 guint util_call(struct test_fix *fix, GSourceFunc func,
60 GDestroyNotify notify);
61 void util_test_add(const char *test_name, GSourceFunc test_func,
62 util_test_setup_cb setup_cb,
63 util_test_teardown_cb teardown_cb);
64 void util_setup(struct test_fix *fix, gconstpointer data);
65 void util_teardown(struct test_fix *fix, gconstpointer data);
67 void util_session_create(struct test_fix *fix, unsigned int max_sessions);
68 void util_session_destroy(gpointer fix);
69 void util_session_init(struct test_session *session);
70 void util_session_cleanup(struct test_session *session);
72 typedef void (* notify_cb) (struct test_session *session);
74 enum connman_session_state {
75 CONNMAN_SESSION_STATE_DISCONNECTED = 0,
76 CONNMAN_SESSION_STATE_CONNECTED = 1,
77 CONNMAN_SESSION_STATE_ONLINE = 2,
80 enum connman_session_type {
81 CONNMAN_SESSION_TYPE_ANY = 0,
82 CONNMAN_SESSION_TYPE_LOCAL = 1,
83 CONNMAN_SESSION_TYPE_INTERNET = 2,
86 enum connman_session_roaming_policy {
87 CONNMAN_SESSION_ROAMING_POLICY_UNKNOWN = 0,
88 CONNMAN_SESSION_ROAMING_POLICY_DEFAULT = 1,
89 CONNMAN_SESSION_ROAMING_POLICY_ALWAYS = 2,
90 CONNMAN_SESSION_ROAMING_POLICY_FORBIDDEN = 3,
91 CONNMAN_SESSION_ROAMING_POLICY_NATIONAL = 4,
92 CONNMAN_SESSION_ROAMING_POLICY_INTERNATIONAL = 5,
95 struct test_session_info {
97 enum connman_session_state state;
98 enum connman_session_type type;
100 /* ipv4, ipv6 dicts */
101 GSList *allowed_bearers;
102 connman_bool_t priority;
103 connman_bool_t avoid_handover;
104 connman_bool_t stay_connected;
105 unsigned int periodic_connect;
106 unsigned int idle_timeout;
107 connman_bool_t ecall;
108 enum connman_session_roaming_policy roaming_policy;
113 struct test_session {
116 struct test_fix *fix;
117 DBusConnection *connection;
123 struct test_session_info *info;
126 struct test_bearer_info {
131 void bearer_info_cleanup(gpointer bearer_info, gpointer user_data);
133 void session_append_settings(DBusMessageIter *dict,
134 struct test_session_info *info);
135 int session_notify_register(struct test_session *session,
136 const char *notify_path);
137 int session_notify_unregister(struct test_session *session,
138 const char *notify_path);
140 DBusMessage *session_connect(DBusConnection *connection,
141 struct test_session *session);
142 DBusMessage *session_disconnect(DBusConnection *connection,
143 struct test_session *session);
146 DBusMessage *manager_get_services(DBusConnection *connection);
147 DBusMessage *manager_get_properties(DBusConnection *connection);
148 DBusMessage *manager_create_session(DBusConnection *connection,
149 struct test_session_info *info,
150 const char *notifier_path);
151 DBusMessage *manager_destroy_session(DBusConnection *connection,
152 const char *notifier_path);
153 DBusMessage *manager_set_session_mode(DBusConnection *connection,
154 connman_bool_t enable);
155 int manager_parse_properties(DBusMessage *msg,
156 struct test_manager *manager);
162 #define LOG(fmt, arg...) do { \
163 fprintf(stdout, "%s:%s() " fmt "\n", \
164 __FILE__, __FUNCTION__ , ## arg); \
167 #define LOG(fmt, arg...)