aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/indicator-sound.c11
-rw-r--r--src/indicator-sound.h5
-rw-r--r--tests/Makefile.am41
-rw-r--r--tests/test-indicator-sound.c43
4 files changed, 56 insertions, 44 deletions
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index 546f404..3aca517 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -300,11 +300,22 @@ gint get_state()
return current_state;
}
+gchar* get_state_image_name(gint state)
+{
+ return g_hash_table_lookup(volume_states, GINT_TO_POINTER(state));
+}
+
void prepare_for_tests(IndicatorObject *io)
{
+ prepare_state_machine();
get_icon(io);
}
+void tidy_up_hash()
+{
+ g_hash_table_destroy(volume_states);
+}
+
static void update_state(const gint state)
{
/* g_debug("update state beginning - previous_state = %i", previous_state);*/
diff --git a/src/indicator-sound.h b/src/indicator-sound.h
index eaf8948..6d0c85c 100644
--- a/src/indicator-sound.h
+++ b/src/indicator-sound.h
@@ -21,9 +21,10 @@ You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
+// Essentially these are all exported to faciltiate testing
void prepare_state_machine();
void determine_state_from_volume(gdouble volume_percent);
gint get_state();
-// Not nice
+gchar* get_state_image_name(gint state);
void prepare_for_tests(IndicatorObject * io);
+void tidy_up_hash();
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 285a26c..b20b070 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,8 +1,8 @@
check_PROGRAMS = \
test-indicator-sound \
- test-indicator-sound-dbus-client \
- test-indicator-sound-dbus-server
+ test-indicator-sound-dbus-client
+# test-indicator-sound-dbus-server
TESTS =
DISTCLEANFILES = $(TESTS)
@@ -44,20 +44,21 @@ test_indicator_sound_dbus_client_LDADD = \
#########################################
## 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) \
- -I$(SOUNDSERVICE_CFLAGS)
+#test_indicator_sound_dbus_server_SOURCES = \
+# test-defines.h
-test_indicator_sound_dbus_server_LDADD = \
- $(SOUNDSERVICE_LIBS) \
- $(top_builddir)/src/libsoundmenu.la
+#test_indicator_sound_dbus_server_CFLAGS = \
+# $(SOUNDSERVICE_CFLAGS) \
+# -Wall -Werror \
+# -I$(srcdir) \
+# -I$(SOUNDSERVICE_CFLAGS)
+#test_indicator_sound_dbus_server_LDADD = \
+# $(SOUNDSERVICE_LIBS) \
+# $(top_builddir)/src/indicator_sound_service-sound-service.o \
+# $(top_builddir)/src/indicator_sound_service-pulse-manager.o \
+# $(top_builddir)/src/indicator_sound_service-slider-menu-item.o \
+# $(top_builddir)/src/indicator_sound_service-sound-service-dbus.o
@@ -83,14 +84,14 @@ TESTS += indicator-sound-tests
DISTCLEANFILES += $(XML_REPORT) $(HTML_REPORT) indicator-sound-tests-gtester
-DBUS_RUNNER=dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf
+#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-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
-TESTS += test-indicator-sound-dbus
+#TESTS += test-indicator-sound-dbus
diff --git a/tests/test-indicator-sound.c b/tests/test-indicator-sound.c
index 5dad56c..eb68b17 100644
--- a/tests/test-indicator-sound.c
+++ b/tests/test-indicator-sound.c
@@ -57,34 +57,33 @@ void test_libindicator_determine_state()
g_object_unref(G_OBJECT(sound_menu));
}
-/*void test_libindicator_image_names()*/
-/*{*/
-/* prepare_state_machine();*/
-
-/* gchar* muted_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED)); */
-/* g_assert(g_ascii_strncasecmp("audio-volume-muted-panel", muted_name, strlen("audio-volume-muted-panel")) == 0);*/
+void test_libindicator_image_names()
+{
+ prepare_state_machine();
-/* gchar* zero_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_ZERO)); */
-/* g_assert(g_ascii_strncasecmp("audio-volume-low-zero-panel", zero_name, strlen("audio-volume-low-zero-panel")) == 0);*/
+ gchar* muted_name = get_state_image_name(STATE_MUTED);
+ g_assert(g_ascii_strncasecmp("audio-volume-muted-panel", muted_name, strlen("audio-volume-muted-panel")) == 0);
-/* gchar* low_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_LOW)); */
-/* g_assert(g_ascii_strncasecmp("audio-volume-low-panel", low_name, strlen("audio-volume-low-panel")) == 0);*/
+ gchar* zero_name = get_state_image_name(STATE_ZERO);
+ g_assert(g_ascii_strncasecmp("audio-volume-low-zero-panel", zero_name, strlen("audio-volume-low-zero-panel")) == 0);
-/* gchar* medium_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MEDIUM)); */
-/* g_assert(g_ascii_strncasecmp("audio-volume-medium-panel", medium_name, strlen("audio-volume-medium-panel")) == 0);*/
+ gchar* low_name = get_state_image_name(STATE_LOW);
+ g_assert(g_ascii_strncasecmp("audio-volume-low-panel", low_name, strlen("audio-volume-low-panel")) == 0);
-/* gchar* high_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_HIGH)); */
-/* g_assert(g_ascii_strncasecmp("audio-volume-high-panel", high_name, strlen("audio-volume-high-panel")) == 0);*/
+ gchar* medium_name = get_state_image_name(STATE_MEDIUM);
+ g_assert(g_ascii_strncasecmp("audio-volume-medium-panel", medium_name, strlen("audio-volume-medium-panel")) == 0);
-/* gchar* blocked_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT)); */
-/* g_assert(g_ascii_strncasecmp("audio-volume-muted-blocking-panel", blocked_name, strlen("audio-volume-muted-blocking-panel")) == 0);*/
+ gchar* high_name = get_state_image_name(STATE_HIGH);
+ g_assert(g_ascii_strncasecmp("audio-volume-high-panel", high_name, strlen("audio-volume-high-panel")) == 0);
-/* gchar* none_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_SINKS_NONE)); */
-/* g_assert(g_ascii_strncasecmp("audio-output-none-panel", none_name, strlen("audio-output-none-panel")) == 0);*/
+ gchar* blocked_name = get_state_image_name(STATE_MUTED_WHILE_INPUT);
+ g_assert(g_ascii_strncasecmp("audio-volume-muted-blocking-panel", blocked_name, strlen("audio-volume-muted-blocking-panel")) == 0);
-/* // tidy up*/
-/* g_hash_table_destroy(volume_states);*/
-/*}*/
+ gchar* none_name = get_state_image_name(STATE_SINKS_NONE);
+ g_assert(g_ascii_strncasecmp("audio-output-none-panel", none_name, strlen("audio-output-none-panel")) == 0);
+
+ tidy_up_hash();
+}
@@ -95,7 +94,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/image_names", test_libindicator_image_names);
return g_test_run ();
}