aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRobert Collins <robertc@robertcollins.net>2010-03-04 21:23:40 +1100
committerRobert Collins <robertc@robertcollins.net>2010-03-04 21:23:40 +1100
commit9d0d8eaa8b9c021fbb45368f96489f520aab86e7 (patch)
treec036a36f625519e3cbc211306b9d58abce181212 /tests
parent84afe8ad635ba3294bc92e11d2b0f227996b48d5 (diff)
downloadayatana-indicator-sound-9d0d8eaa8b9c021fbb45368f96489f520aab86e7.tar.gz
ayatana-indicator-sound-9d0d8eaa8b9c021fbb45368f96489f520aab86e7.tar.bz2
ayatana-indicator-sound-9d0d8eaa8b9c021fbb45368f96489f520aab86e7.zip
Put mocking core in place for Connor.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am20
-rw-r--r--tests/mockpulse.c28
-rw-r--r--tests/test-indicator-sound.c6
3 files changed, 51 insertions, 3 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f636762..e29df33 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -4,9 +4,14 @@ check_PROGRAMS = \
test-indicator-sound-dbus-client
# test-indicator-sound-dbus-server
-TESTS =
+TESTS = test-indicator-sound
DISTCLEANFILES = $(TESTS)
+noinst_LTLIBRARIES = libmockpulse.la
+libmockpulse_la_SOURCES = mockpulse.c
+libmockpulse_la_CFLAGS = $(PULSEAUDIO_CFLAGS)
+
+
#########################################
## test-indicator-sound
#########################################
@@ -15,12 +20,15 @@ test_indicator_sound_SOURCES = \
$(top_builddir)/src/indicator-sound.c
test_indicator_sound_CFLAGS = \
+ $(PULSEAUDIO_CFLAGS) \
$(APPLET_CFLAGS) \
-Wall -Werror \
-I$(srcdir) \
-DTOP_BUILD_DIR="\"${abs_top_builddir}\""
test_indicator_sound_LDADD = \
+ libmockpulse.la \
+ $(PULSEAUDIO_LIBS) \
$(APPLET_LIBS)
@@ -33,12 +41,15 @@ test_indicator_sound_dbus_client_SOURCES = \
test-indicator-sound-dbus-client.c
test_indicator_sound_dbus_client_CFLAGS = \
+ $(PULSEAUDIO_CFLAGS) \
$(SOUNDSERVICE_CFLAGS) \
-Wall -Werror \
-I$(srcdir) \
-I$(SOUNDSERVICE_CFLAGS)
test_indicator_sound_dbus_client_LDADD = \
+ libmockpulse.la \
+ $(PULSEAUDIO_LIBS) \
$(SOUNDSERVICE_LIBS)
#########################################
@@ -48,12 +59,15 @@ test_indicator_sound_dbus_client_LDADD = \
# test-defines.h
#test_indicator_sound_dbus_server_CFLAGS = \
+# $(PULSEAUDIO_CFLAGS) \
# $(SOUNDSERVICE_CFLAGS) \
# -Wall -Werror \
# -I$(srcdir) \
# -I$(SOUNDSERVICE_CFLAGS)
#test_indicator_sound_dbus_server_LDADD = \
+# libmockpulse.la \
+# $(PULSEAUDIO_LIBS) \
# $(SOUNDSERVICE_LIBS) \
# $(top_builddir)/src/indicator_sound_service-sound-service.o \
# $(top_builddir)/src/indicator_sound_service-pulse-manager.o \
@@ -77,10 +91,10 @@ test_indicator_sound_dbus_client_LDADD = \
indicator-sound-tests-gtester: test-indicator-sound Makefile.am
@echo "#!/bin/sh" > $@
- @echo gtester -k --verbose -o=$(XML_REPORT) ./test-indicator-sound >> $@
+ @echo gtester -k --verbose -o=indicator-sound-check-results.xml ./test-indicator-sound >> $@
@chmod +x $@
-# TESTS += indicator-sound-tests
+ TESTS += indicator-sound-tests-gtester
DISTCLEANFILES += $(XML_REPORT) $(HTML_REPORT) indicator-sound-tests-gtester
diff --git a/tests/mockpulse.c b/tests/mockpulse.c
new file mode 100644
index 0000000..297780b
--- /dev/null
+++ b/tests/mockpulse.c
@@ -0,0 +1,28 @@
+/*
+Copyright 2010 Canonical Ltd.
+
+Authors:
+ Robert Collins <robert.collins@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 <pulse/glib-mainloop.h>
+
+pa_glib_mainloop*
+pa_glib_mainloop_new(GMainContext *c)
+{
+ printf("This is reached\n", c);
+ return NULL;
+}
+
diff --git a/tests/test-indicator-sound.c b/tests/test-indicator-sound.c
index eb68b17..1d3569a 100644
--- a/tests/test-indicator-sound.c
+++ b/tests/test-indicator-sound.c
@@ -20,6 +20,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <string.h>
#include <gtk/gtk.h>
#include <libindicator/indicator-object.h>
+#include <pulse/glib-mainloop.h>
#include "../src/indicator-sound.h"
static const gint STATE_MUTED = 0;
@@ -85,6 +86,10 @@ void test_libindicator_image_names()
tidy_up_hash();
}
+void test_libindicator_pa_mocked()
+{ g_assert(pa_glib_mainloop_new(NULL) == NULL);
+}
+
gint main (gint argc, gchar * argv[])
@@ -95,6 +100,7 @@ gint main (gint argc, gchar * argv[])
g_test_add_func("/indicator-sound/indicator-sound/init", test_libindicator_sound_init);
g_test_add_func("/indicator-sound/indicator-sound/state_machine", test_libindicator_determine_state);
g_test_add_func("/indicator-sound/indicator-sound/image_names", test_libindicator_image_names);
+ g_test_add_func("/indicator-sound/indicator-sound/pa_is_mocked", test_libindicator_pa_mocked);
return g_test_run ();
}