aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am23
-rw-r--r--tests/test-indicator-sound.c113
2 files changed, 136 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..05e1bd0
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,23 @@
+
+check_PROGRAMS = \
+ test-indicator-sound
+
+TESTS =
+DISTCLEANFILES = $(TESTS)
+
+#########################################
+## test-indicator-sound
+#########################################
+test_indicator_sound_SOURCES = \
+ test-indicator-sound.c
+
+test_indicator_sound_CFLAGS = \
+ $(APPLET_CFLAGS) \
+ -Wall -Werror \
+ -I$(srcdir) \
+ -DBUILD_DIR="\"$(builddir)\""
+
+test_indicator_sound_LDADD = \
+ $(APPLET_LIBS) \
+ $(INDICATORDIR)/libsoundmenu.la
+
diff --git a/tests/test-indicator-sound.c b/tests/test-indicator-sound.c
new file mode 100644
index 0000000..81fc966
--- /dev/null
+++ b/tests/test-indicator-sound.c
@@ -0,0 +1,113 @@
+/*
+Copyright 2010 Canonical Ltd.
+
+Authors:
+ Conor Curran <conor.curran@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 <math.h>*/
+/*#include <glib.h>*/
+/*#include <glib-object.h>*/
+/*#include <gtk/gtk.h>*/
+/*#include <gdk/gdkkeysyms.h>*/
+/*#include <libdbusmenu-gtk/menu.h>*/
+/*#include <libido/idoscalemenuitem.h>*/
+
+/*#include <dbus/dbus-glib.h>*/
+/*#include <dbus/dbus-glib-bindings.h>*/
+
+/*#include <libindicator/indicator.h>*/
+/*#include <libindicator/indicator-object.h>*/
+/*#include <libindicator/indicator-service-manager.h>*/
+
+#include <string.h>
+#include "../src/indicator-sound.c"
+
+
+void test_libindicator_sound_init()
+{
+ IndicatorObject * sound_menu = indicator_object_new_from_file("/home/ronoc/canonical/repos/branches/indicator-sound/tests-indicator-sound/indicator-sound/src/.libs/libsoundmenu.so");
+ g_assert(sound_menu != NULL);
+ g_object_unref(G_OBJECT(sound_menu));
+}
+
+void test_libindicator_determine_state()
+{
+ IndicatorObject * sound_menu = indicator_object_new_from_file("/home/ronoc/canonical/repos/branches/indicator-sound/tests-indicator-sound/indicator-sound/src/.libs/libsoundmenu.so");
+ get_icon(sound_menu);
+
+ determine_state_from_volume(40);
+ g_assert(current_state == STATE_MEDIUM);
+
+ determine_state_from_volume(0);
+ g_assert(current_state == STATE_ZERO);
+
+ determine_state_from_volume(15);
+ g_assert(current_state == STATE_LOW);
+
+ determine_state_from_volume(70);
+ g_assert(current_state == STATE_HIGH);
+
+ 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);
+
+ 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* 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* 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* 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* 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* 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);
+
+ // tidy up
+ g_hash_table_destroy(volume_states);
+}
+
+
+void test_libindicator_mute_switching()
+{
+
+}
+
+
+gint main (gint argc, gchar * argv[])
+{
+ g_type_init();
+ g_test_init(&argc, &argv, NULL);
+
+ 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);
+
+ return g_test_run ();
+}
+