diff options
author | Conor Curran <conor.curran@canonical.com> | 2010-03-01 21:54:03 +0000 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2010-03-01 21:54:03 +0000 |
commit | 6468402475d7bfced0ee905bdd56977cc2f4b7da (patch) | |
tree | 41defecba1b06a2b94cd666bebd53e3ac1619844 | |
parent | 4cb7db538df7b4e69e49ab047f401b8ba480f224 (diff) | |
download | ayatana-indicator-sound-6468402475d7bfced0ee905bdd56977cc2f4b7da.tar.gz ayatana-indicator-sound-6468402475d7bfced0ee905bdd56977cc2f4b7da.tar.bz2 ayatana-indicator-sound-6468402475d7bfced0ee905bdd56977cc2f4b7da.zip |
new tests for dbus stuff
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | tests/Makefile.am | 81 | ||||
-rw-r--r-- | tests/test-defines.h | 24 | ||||
-rw-r--r-- | tests/test-indicator-sound-dbus-client.c | 109 | ||||
-rw-r--r-- | tests/test-indicator-sound-dbus-server.c | 61 |
5 files changed, 256 insertions, 23 deletions
diff --git a/configure.ac b/configure.ac index c83df5c..4a2142e 100644 --- a/configure.ac +++ b/configure.ac @@ -1,10 +1,10 @@ -AC_INIT(src/indicator-sound.c) +AC_INIT(indicator-sound, 0.1.2, conor.curran@canonical.com) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-sound, 0.1.1) +AM_INIT_AUTOMAKE(indicator-sound, 0.1.2) AM_MAINTAINER_MODE diff --git a/tests/Makefile.am b/tests/Makefile.am index 4404333..7d061fb 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,6 +1,8 @@ check_PROGRAMS = \ test-indicator-sound + test-indicator-sound-dbus-client \ + test-indicator-sound-dbus-server TESTS = DISTCLEANFILES = $(TESTS) @@ -21,35 +23,72 @@ test_indicator_sound_LDADD = \ $(APPLET_LIBS) \ $(INDICATORDIR)/libsoundmenu.la -#DBUS_RUNNER=dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf +######################################### +## test-indicator-sound-dbus-client +######################################### + +test_indicator_sound_dbus_client_SOURCES = \ + test-defines.h \ + test-indicator-sound-dbus-client.c + +test_indicator_sound_dbus_client_CFLAGS = \ + $(SOUNDSERVICE_CFLAGS) \ + -Wall -Werror \ + -I$(srcdir) \ + -I$(SOUNDSERVICE_CFLAGS) + +test_indicator_sound_dbus_client_LDADD = \ + $(SOUNDSERVICE_LIBS) \ + $(INDICATORDIR)/libsoundmenu.la + +######################################### +## test-indicator-sound-dbus-server +######################################### +test_indicator_sound_dbus_server_SOURCES = \ + test-defines.h \ + test-indicator-sound-dbus-server.c + +test_indicator_sound_dbus_server_CFLAGS = \ + $(APPLET_CFLAGS) \ + -Wall -Werror \ + -I$(srcdir) + +test_libappindicator_dbus_server_LDADD = \ + $(SOUNDSERVICE_LIBS) \ + $(INDICATORDIR)/libsoundmenu.la + + +######################################### +## Actual tests +######################################### + +#XML_REPORT = indicator-sound-check-results.xml +#HTML_REPORT = indicator-sound-check-results.html + +#indicator-sound-tests: indicator-sound-tests-gtester Makefile.am +# @echo "#!/bin/sh" > $@ +# @echo $(DBUS_RUNNER) --task ./indicator-sound-tests-gtester >> $@ +# @chmod +x $@ -#test-indicator-sound-dbus: test-indicator-sound-dbus-client test-indicator-sound-dbus-server Makefile.am -# @echo "#!/bin/sh" > test-indicator-sound-dbus -# @echo $(DBUS_RUNNER) --task ./test-indicator-sound-dbus-client --task-name Client --task ./test-indicator-sound-dbus-server --task-name Server --ignore-return >> test-indicator-sound-dbus -# @chmod +x test-libappindicator-dbus +indicator-sound-tests-gtester: test-indicator-sound Makefile.am + @echo "#!/bin/sh" > $@ + @echo gtester -k --verbose -o=$(XML_REPORT) ./test-indicator-sound >> $@ + @chmod +x $@ -#TESTS += test-libappindicator-dbus +TESTS += indicator-sound-tests -XVFB_RUN=". $(srcdir)/run-xvfb.sh" +DISTCLEANFILES += $(XML_REPORT) $(HTML_REPORT) indicator-sound-tests-gtester -EXTRA_DIST = run-xvfb.sh +DBUS_RUNNER=dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf +test-indicator-sound-dbus: test-indicator-sound-dbus-client test-indicator-sound-dbus-server Makefile.am + @echo "#!/bin/sh" > test-indicator-sound-dbus + @echo $(DBUS_RUNNER) --task ./test-indicator-sound-dbus-client --task-name Client --task ./test-indicator-sound-dbus-server --task-name Server --ignore-return >> test-indicator-sound-dbus + @chmod +x test-indicator-sound-dbus -############################# -# Test stuff -############################# +TESTS += test-indicator-sound-dbus -#XML_REPORT = loader-check-results.xml -#HTML_REPORT = loader-check-results.html -#loader-tester: test-loader libsoundmenu.la Makefile -# @echo "#!/bin/bash" > loader-tester -# @echo $(XVFB_RUN) >> $@ -# @echo gtester -k --verbose -o=$(XML_REPORT) ./test-loader >> loader-tester -# @chmod +x loader-tester -#TESTS += loader-tester -#DISTCLEANFILES += loader-tester -#DISTCLEANFILES += $(XML_REPORT) $(HTML_REPORT) diff --git a/tests/test-defines.h b/tests/test-defines.h new file mode 100644 index 0000000..68064fc --- /dev/null +++ b/tests/test-defines.h @@ -0,0 +1,24 @@ +/* +Testing defines to be shared between various tests. + +Copyright 2010 Canonical Ltd. + +Authors: + Conor Curran <conor.curran@canonical.com> + Ted Gould <ted@canonical.com> + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#define TEST_MUTE FALSE + diff --git a/tests/test-indicator-sound-dbus-client.c b/tests/test-indicator-sound-dbus-client.c new file mode 100644 index 0000000..9d6f7ab --- /dev/null +++ b/tests/test-indicator-sound-dbus-client.c @@ -0,0 +1,109 @@ +/* +Tests for the libappindicator library that are over DBus. This is +the client side of those tests. + +Copyright 2010 Canonical Ltd. + +Authors: + Conor Curran <conor.curran@canonical.com> + Ted Gould <ted@canonical.com> + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + + +#include <glib.h> +#include <dbus/dbus-glib.h> +#include "../src/dbus-shared-names.h" +/*#include "../src/indicator-sound.c"*/ +#include "test-defines.h" + +static GMainLoop * mainloop = NULL; +static gboolean passed = TRUE; + +static void +fetch_mute_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) +{ + GError * error = NULL; + GValue value = {0}; + + if (!dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &value, G_TYPE_INVALID)) { + g_warning("Getting mute failed: %s", error->message); + g_error_free(error); + passed = FALSE; + return; + } + + if (TEST_MUTE != g_value_get_boolean(&value))) { + g_debug("Mute vale Returned: FAILED"); + passed = FALSE; + } else { + g_debug("Property ID Returned: PASSED"); + } + return; +} + + +gboolean +kill_func (gpointer userdata) +{ + g_main_loop_quit(mainloop); + g_warning("Forced to Kill"); + passed = FALSE; + return FALSE; +} + +gint +main (gint argc, gchar * argv[]) +{ + g_type_init(); + + g_usleep(500000); + + GError * error = NULL; + DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); + if (error != NULL) { + g_error("Unable to get session bus: %s", error->message); + return 1; + } + + DBusGProxy * props = dbus_g_proxy_new_for_name_owner(session_bus, + INDICATOR_SOUND_DBUS_NAME, + INDICATOR_SOUND_SERVICE_DBUS_OBJECT, + INDICATOR_SOUND_SERVICE_DBUS_INTERFACE, + &error); + if (error != NULL) { + g_error("Unable to get property proxy: %s", error->message); + return 1; + } + + dbus_g_proxy_begin_call (props, + "GetSinkMute", + fetch_mute_cb, + NULL, NULL, + G_TYPE_INVALID); + + g_timeout_add_seconds(2, kill_func, NULL); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + if (passed) { + g_debug("Quiting"); + return 0; + } else { + g_debug("Quiting as we're a failure"); + return 1; + } + return 0; +} diff --git a/tests/test-indicator-sound-dbus-server.c b/tests/test-indicator-sound-dbus-server.c new file mode 100644 index 0000000..c9ad61d --- /dev/null +++ b/tests/test-indicator-sound-dbus-server.c @@ -0,0 +1,61 @@ +/* +Tests for the libappindicator library that are over DBus. This is +the server side of those tests. + +Copyright 2009 Canonical Ltd. + +Authors: + Conor Curran <conor.curran@canonical.com> + Ted Gould <ted@canonical.com> + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + + +#include <dbus/dbus-glib.h> +#include <dbus/dbus-glib-lowlevel.h> +#include <glib.h> +#include "../src/sound-service-dbus.h" +#include "test-defines.h" + +static GMainLoop * mainloop = NULL; + +gboolean +kill_func (gpointer userdata) +{ + g_main_loop_quit(mainloop); + return FALSE; +} + +gint +main (gint argc, gchar * argv[]) +{ + g_type_init(); + g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL)))); + + dbus_interface = g_object_new(SOUND_SERVICE_DBUS_TYPE, NULL); + + // Set the mute value + sound_service_dbus_update_sink_mute(dbus_interface, TEST_MUTE); + g_timeout_add_seconds(2, kill_func, NULL); + + // Run the loop + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + g_debug("Quiting"); + + return 0; +} + + |