summaryrefslogtreecommitdiff
path: root/src/gst
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2013-04-04 11:00:10 +0200
committerBastien Nocera <hadess@hadess.net>2013-04-04 11:00:10 +0200
commitbd743e6448499dc2e417d17c6f2a4803bdea41bb (patch)
treedb261a6618bbb9f7b96876b3333f1e3f53a87e48 /src/gst
parent032af8b000801e6a55a2987993fe8424bcc5e46d (diff)
downloadtotem-bd743e6448499dc2e417d17c6f2a4803bdea41bb.tar.gz
gst: Add test suite for time helpers
It's pretty small, but will stop us from doing stupid things.
Diffstat (limited to 'src/gst')
-rw-r--r--src/gst/Makefile.am14
-rw-r--r--src/gst/test-time.c57
2 files changed, 71 insertions, 0 deletions
diff --git a/src/gst/Makefile.am b/src/gst/Makefile.am
index c5f11599b..2e3c4cbde 100644
--- a/src/gst/Makefile.am
+++ b/src/gst/Makefile.am
@@ -51,6 +51,20 @@ libtotemtimehelpers_la_CFLAGS = \
libtotemtimehelpers_la_LIBADD = $(TIME_HELPER_LIBS)
libtotemtimehelpers_la_LDFLAGS= -no-undefined
+include $(top_srcdir)/Makefile.decl
+
+pwd=`pwd`
+INCLUDES = \
+ -I$(top_srcdir)/plparse \
+ -DTEST_SRCDIR=\""$(srcdir)/"\"
+
+noinst_PROGRAMS = $(TEST_PROGS)
+
+TEST_PROGS += test-time
+test_time_SOURCES = test-time.c
+test_time_CFLAGS = $(HELPER_CFLAGS) $(AM_CFLAGS)
+test_time_LDADD = libtotemtimehelpers.la $(HELPER_LIBS)
+
EXTRA_DIST = totem-time-helpers.h
-include $(top_srcdir)/git.mk
diff --git a/src/gst/test-time.c b/src/gst/test-time.c
new file mode 100644
index 000000000..8fd9f7748
--- /dev/null
+++ b/src/gst/test-time.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright Bastien Nocera <hadess@hadess.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+
+#include <locale.h>
+#include <glib.h>
+
+#include "totem-time-helpers.h"
+
+static void
+test_time (void)
+{
+ g_assert_cmpstr (totem_time_to_string (0, FALSE, FALSE), ==, "0:00");
+ g_assert_cmpstr (totem_time_to_string (500, FALSE, FALSE), ==, "0:00");
+ g_assert_cmpstr (totem_time_to_string (500, TRUE, FALSE), ==, "-0:01");
+ g_assert_cmpstr (totem_time_to_string (1250, FALSE, FALSE), ==, "0:01");
+ g_assert_cmpstr (totem_time_to_string (1250, TRUE, FALSE), ==, "-0:02");
+}
+
+static void
+log_handler (const char *log_domain, GLogLevelFlags log_level, const char *message, gpointer user_data)
+{
+ g_test_message ("%s", message);
+}
+
+int
+main (int argc, char *argv[])
+{
+ setlocale (LC_ALL, "en_US.UTF-8");
+
+ g_test_init (&argc, &argv, NULL);
+ g_test_bug_base ("http://bugzilla.gnome.org/show_bug.cgi?id=");
+
+ /* We need to handle log messages produced by g_message so they're interpreted correctly by the GTester framework */
+ g_log_set_handler (NULL, G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, log_handler, NULL);
+
+ g_test_add_func ("/time", test_time);
+
+ return g_test_run ();
+}