Beispiel #1
0
static void test_session_connect_free_ride_notify(struct test_session *session)
{
	struct test_session *session0 = get_session(session, 0);
	struct test_session *session1 = get_session(session, 1);
	enum test_session_state state = get_session_state(session);
	enum test_session_state next_state = state;
	DBusMessage *msg;

	LOG("state %d session %p %s state %d", state, session,
		session->notify_path, session->info->state);

	switch (state) {
	case TEST_SESSION_STATE_0:
		if (session0->info->state == CONNMAN_SESSION_STATE_DISCONNECTED
				&& session1->info->state ==
					CONNMAN_SESSION_STATE_DISCONNECTED) {
			next_state = TEST_SESSION_STATE_1;
		}
		if (session0->info->state == CONNMAN_SESSION_STATE_CONNECTED &&
				session1->info->state ==
				CONNMAN_SESSION_STATE_CONNECTED) {
			LOG("state was already connected, continuing");
			next_state = TEST_SESSION_STATE_2;
		}

		break;
	case TEST_SESSION_STATE_1:
		if (session0->info->state >= CONNMAN_SESSION_STATE_CONNECTED &&
				session1->info->state >=
					CONNMAN_SESSION_STATE_CONNECTED) {
			next_state = TEST_SESSION_STATE_2;
		}

		break;
	case TEST_SESSION_STATE_2:
		if (session0->info->state == CONNMAN_SESSION_STATE_DISCONNECTED
				&& (session1->info->state ==
					CONNMAN_SESSION_STATE_DISCONNECTED ||
						session1->info->state ==
					CONNMAN_SESSION_STATE_CONNECTED) ) {
			LOG("session0 /foo is disconnected, session1 /bar "
				"can be either connected or disconnected");
			next_state = TEST_SESSION_STATE_3;
		}

		break;
	case TEST_SESSION_STATE_3:

		return;
	}

	if (state == next_state)
		return;

	set_session_state(session, next_state);

	LOG("next_state %d", next_state);

	switch (next_state) {
	case TEST_SESSION_STATE_0:

		return;
	case TEST_SESSION_STATE_1:
		msg = session_connect(session0->connection, session0);
		g_assert(msg);
		dbus_message_unref(msg);

		return;

	case TEST_SESSION_STATE_2:
		msg = session_disconnect(session0->connection, session0);
		g_assert(msg);
		dbus_message_unref(msg);

		return;
	case TEST_SESSION_STATE_3:
		util_session_cleanup(session0);
		util_session_cleanup(session1);

		util_idle_call(session0->fix, util_quit_loop,
				util_session_destroy);

		return;
	}
}
Beispiel #2
0
static void teardown_cb(struct test_fix *fix)
{
	util_call(fix, disable_session_mode, NULL);
	util_idle_call(fix, util_quit_loop, NULL);
}
static void test_session_create_notify(struct test_session *session)
{
	LOG("session %p", session);

	util_idle_call(session->fix, util_quit_loop, util_session_destroy);
}