diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2013-11-25 18:32:20 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2014-02-13 13:41:58 +0100 |
commit | bff2a8d2f29fbf5e493c115101e48dd0ce37c3cd (patch) | |
tree | db561db4080a2a6a08737a47ebdcddc14428be1c /plugins/generic/tests | |
parent | ba58aa42f2ff931b561c45e2073772bc9b419dfc (diff) |
tests: added support for DBus service tests
We can now run 'simulated' modems against a ModemManager running in its own
session bus.
Diffstat (limited to 'plugins/generic/tests')
-rw-r--r-- | plugins/generic/tests/test-service-generic.c | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/plugins/generic/tests/test-service-generic.c b/plugins/generic/tests/test-service-generic.c new file mode 100644 index 00000000..7ab3887b --- /dev/null +++ b/plugins/generic/tests/test-service-generic.c @@ -0,0 +1,84 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details: + * + * Copyright (C) 2013 Aleksander Morgado <aleksander@gnu.org> + */ + +#include <unistd.h> +#include <glib.h> +#include <glib-object.h> + +#include <libmm-glib.h> + +#include "test-port-context.h" +#include "test-fixture.h" + +/*****************************************************************************/ + +static void +test_something (TestFixture *fixture) +{ + GError *error = NULL; + MMObject *obj; + MMModem *modem; + TestPortContext *port0; + const gchar *ports [] = { + "abstract:port0", + NULL + }; + + /* Setup new port context */ + port0 = test_port_context_new (ports[0]); + test_port_context_load_commands (port0, COMMON_GSM_PORT_CONF); + test_port_context_start (port0); + + /* Ensure no modem is modem exported */ + test_fixture_no_modem (fixture); + + /* Set the test profile */ + test_fixture_set_profile (fixture, + "test-something", + "Generic", + (const gchar *const *)ports); + + /* Wait and get the modem object */ + obj = test_fixture_get_modem (fixture); + + /* Get Modem interface, and enable */ + modem = mm_object_get_modem (obj); + g_assert (modem != NULL); + mm_modem_enable_sync (modem, NULL, &error); + g_assert_no_error (error); + + /* And disable */ + mm_modem_disable_sync (modem, NULL, &error); + g_assert_no_error (error); + + g_object_unref (modem); + g_object_unref (obj); + + /* Stop port context */ + test_port_context_stop (port0); + test_port_context_free (port0); +} + +/*****************************************************************************/ + +int main (int argc, + char *argv[]) +{ + g_test_init (&argc, &argv, NULL); + + TEST_ADD ("/MM/Service/Generic", test_something); + + return g_test_run (); +} |