aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am75
-rw-r--r--tests/test-defines.h5
-rw-r--r--tests/test-indicator-sound-dbus-client.c99
-rw-r--r--tests/test-indicator-sound-dbus-server.c10
4 files changed, 113 insertions, 76 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a0562a4..bc67c30 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,7 +1,8 @@
check_PROGRAMS = \
- test-indicator-sound
-# test-indicator-sound-dbus-client \
-# test-indicator-sound-dbus-server
+ test-indicator-sound \
+ test-pulse-manager \
+ test-indicator-sound-dbus-client \
+ test-indicator-sound-dbus-server
TESTS = \
test-indicator-sound \
@@ -10,8 +11,8 @@ TESTS = \
DISTCLEANFILES = $(TESTS)
noinst_LTLIBRARIES = libmockpulse.la
-libmockpulse_la_SOURCES = mockpulse.c mockpulse.h
-libmockpulse_la_CFLAGS = $(PULSEAUDIO_CFLAGS)
+libmockpulse_la_SOURCES = mockpulse.c mockpulse.h
+libmockpulse_la_CFLAGS = $(PULSEAUDIO_CFLAGS)
#########################################
@@ -35,6 +36,33 @@ test_indicator_sound_LDADD = \
#########################################
+## test-pulse-manager
+#########################################
+
+check_PROGRAMS += test-pulse-manager
+
+test_pulse_manager_SOURCES = \
+ test-pulse-manager.c \
+ $(top_builddir)/src/dbus-menu-manager.c \
+ $(top_builddir)/src/sound-service-dbus.c \
+ $(top_builddir)/src/slider-menu-item.c
+
+test_pulse_manager_CFLAGS = \
+ $(PULSEAUDIO_CFLAGS) \
+ $(SOUNDSERVICE_CFLAGS) \
+ $(GCONF_CFLAGS) \
+ -Wall -Werror \
+ -I$(srcdir) \
+ -I$(SOUNDSERVICE_CFLAGS)
+
+test_pulse_manager_LDADD = \
+ libmockpulse.la \
+ $(PULSEAUDIO_LIBS) \
+ $(SOUNDSERVICE_LIBS) \
+ $(GCONF_LIBS) \
+ $(APPLET_LIBS)
+
+#########################################
## test-indicator-sound-dbus-client
#########################################
test_indicator_sound_dbus_client_SOURCES = \
@@ -72,32 +100,6 @@ test_indicator_sound_dbus_server_LDADD = \
$(SOUNDSERVICE_LIBS) \
$(PULSEAUDIO_LIBS)
-#########################################
-## test-pulse-manager
-#########################################
-
-check_PROGRAMS += test-pulse-manager
-
-test_pulse_manager_SOURCES = \
- test-pulse-manager.c \
- $(top_builddir)/src/dbus-menu-manager.c \
- $(top_builddir)/src/sound-service-dbus.c \
- $(top_builddir)/src/slider-menu-item.c
-
-test_pulse_manager_CFLAGS = \
- $(PULSEAUDIO_CFLAGS) \
- $(SOUNDSERVICE_CFLAGS) \
- $(GCONF_CFLAGS) \
- -Wall -Werror \
- -I$(srcdir) \
- -I$(SOUNDSERVICE_CFLAGS)
-
-test_pulse_manager_LDADD = \
- libmockpulse.la \
- $(PULSEAUDIO_LIBS) \
- $(SOUNDSERVICE_LIBS) \
- $(GCONF_LIBS) \
- $(APPLET_LIBS)
#########################################
## Actual tests
@@ -116,7 +118,14 @@ indicator-sound-tests-gtester: test-indicator-sound Makefile.am
@echo gtester -k --verbose -o=indicator-sound-check-results.xml ./test-indicator-sound >> $@
@chmod +x $@
- TESTS += indicator-sound-tests-gtester
+TESTS += indicator-sound-tests-gtester
+
+pulse-manager-tests-gtester: test-pulse-manager Makefile.am
+ @echo "#!/bin/sh" > $@
+ @echo gtester -k --verbose -o=pulse-manager-check-results.xml ./test-pulse-manager >> $@
+ @chmod +x $@
+
+TESTS += pulse-manager-tests-gtester
DISTCLEANFILES += $(XML_REPORT) $(HTML_REPORT) indicator-sound-tests-gtester
@@ -124,7 +133,7 @@ DBUS_RUNNER=dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.c
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
+ @echo $(DBUS_RUNNER) --task ./test-indicator-sound-dbus-server --task-name Server --ignore-return >> test-indicator-sound-dbus --task ./test-indicator-sound-dbus-client --task-name Client
@chmod +x test-indicator-sound-dbus
TESTS += test-indicator-sound-dbus
diff --git a/tests/test-defines.h b/tests/test-defines.h
index 68064fc..214274e 100644
--- a/tests/test-defines.h
+++ b/tests/test-defines.h
@@ -20,5 +20,6 @@ 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
-
+#define TEST_MUTE_VALUE TRUE
+#define TEST_VOLUME_VALUE 77.77777
+#define TEST_AVAILABLE_VALUE TRUE
diff --git a/tests/test-indicator-sound-dbus-client.c b/tests/test-indicator-sound-dbus-client.c
index 08ce93e..1c23dc5 100644
--- a/tests/test-indicator-sound-dbus-client.c
+++ b/tests/test-indicator-sound-dbus-client.c
@@ -26,39 +26,68 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <dbus/dbus-glib.h>
#include "../src/dbus-shared-names.h"
#include "test-defines.h"
+#include "../src/sound-service-client.h"
static GMainLoop * mainloop = NULL;
-static gboolean passed = TRUE;
+static DBusGProxy * proxy= NULL;
static void
-fetch_mute_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data)
+test_fetch_mute(DBusGProxy * proxy)
{
- 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);
+ GError * error = NULL;
+ gboolean *fetched_mute_value;
+ fetched_mute_value = g_new0(gboolean, 1);
+ org_ayatana_indicator_sound_get_sink_mute(proxy, fetched_mute_value, &error);
+ if (error != NULL) {
+ g_warning("test-indicator-sound-dbus-client::test_fetch_mute - Unable to fetch mute: %s", error->message);
g_error_free(error);
- passed = FALSE;
- return;
+ g_free(fetched_mute_value);
+ return;
}
+ g_assert(TEST_MUTE_VALUE == *fetched_mute_value);
+ g_free(fetched_mute_value);
+}
- if (TEST_MUTE != g_value_get_boolean(&value)) {
- g_debug("Mute vale Returned: FAILED");
- passed = FALSE;
- } else {
- g_debug("Property ID Returned: PASSED");
+static void
+test_fetch_volume(DBusGProxy * proxy)
+{
+ GError * error = NULL;
+ gdouble *volume_percent_input;
+ volume_percent_input = g_new0(gdouble, 1);
+ org_ayatana_indicator_sound_get_sink_volume(proxy, volume_percent_input, &error);
+ if (error != NULL) {
+ g_warning("test-indicator-sound-dbus-client::test_fetch_volume - Unable to fetch VOLUME: %s", error->message);
+ g_error_free(error);
+ g_free(volume_percent_input);
+ return;
}
- return;
+ g_assert(TEST_VOLUME_VALUE == *volume_percent_input);
+ g_free(volume_percent_input);
+}
+
+static void
+test_fetch_availability(DBusGProxy * proxy)
+{
+ GError * error = NULL;
+ gboolean * available_input;
+ available_input = g_new0(gboolean, 1);
+ org_ayatana_indicator_sound_get_sink_availability(proxy, available_input, &error);
+ if (error != NULL) {
+ g_warning("test-indicator-sound-dbus-client::test_fetch_availability - unable to fetch availability %s", error->message);
+ g_error_free(error);
+ g_free(available_input);
+ return;
+ }
+ g_assert(TEST_AVAILABLE_VALUE == *available_input);
+ g_free(available_input);
}
gboolean
kill_func (gpointer userdata)
{
+ g_free(proxy);
g_main_loop_quit(mainloop);
- g_warning("Forced to Kill");
- passed = FALSE;
return FALSE;
}
@@ -66,6 +95,7 @@ gint
main (gint argc, gchar * argv[])
{
g_type_init();
+ g_test_init(&argc, &argv, NULL);
g_usleep(500000);
@@ -76,37 +106,30 @@ main (gint argc, gchar * argv[])
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);
-/* ":1.0",*/
-/* "/need/a/path",*/
-/* DBUS_INTERFACE_PROPERTIES,*/
-/* &error);*/
+ DBusGProxy * proxy = dbus_g_proxy_new_for_name_owner(session_bus,
+ ":1.0",
+ 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_test_add_func("/test-indicator-sound-dbus/test-fetch-mute", test_fetch_mute);*/
+/* g_test_add_func("/test-indicator-sound-dbus/test-fetch-volume", test_fetch_volume);*/
+/* g_test_add_func("/test-indicator-sound-dbus/test-fetch-availability", test_fetch_availability);*/
+/* g_test_queue_free(proxy);*/
+/* return g_test_run();*/
+
+ test_fetch_mute(proxy);
+ test_fetch_volume(proxy);
+ test_fetch_availability(proxy);
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
index 21d7dfe..6912dc4 100644
--- a/tests/test-indicator-sound-dbus-server.c
+++ b/tests/test-indicator-sound-dbus-server.c
@@ -43,13 +43,17 @@ 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))));
+
+ //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);
+ sound_service_dbus_update_sink_mute(dbus_interface, TEST_MUTE_VALUE);
+ sound_service_dbus_update_sink_volume(dbus_interface, TEST_VOLUME_VALUE);
+ sound_service_dbus_update_sink_availability(dbus_interface, TEST_AVAILABLE_VALUE);
+
+ g_timeout_add_seconds(4, kill_func, NULL);
// Run the loop
mainloop = g_main_loop_new(NULL, FALSE);