diff options
Diffstat (limited to 'plugins/generic/tests/test-service-generic.c')
-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 (); +} |