tests: Add some utils for test writing

This commit is contained in:
Thibault Saunier 2012-09-23 02:23:20 +02:00
parent fbefd6dae3
commit 6462b86ac4
3 changed files with 142 additions and 8 deletions

View file

@ -10,8 +10,21 @@ install-pluginLTLIBRARIES:
# the core dumps of some machines have PIDs appended
CLEANFILES = core.* test-registry.*
common_cflags=-I$(top_srcdir) $(GST_PLUGINS_BASE_CFLAGS) $(GST_OBJ_CFLAGS) \
$(GST_CHECK_CFLAGS) $(GST_OPTION_CFLAGS) $(GST_CFLAGS)
common_ldadd=$(top_builddir)/ges/libges-@GST_API_VERSION@.la \
$(GST_PLUGINS_BASE_LIBS) -lgstpbutils-$(GST_API_VERSION) \
$(GST_OBJ_LIBS) $(GST_CHECK_LIBS)
testutils_noisnt_libraries=libtestutils.la
testutils_noinst_headers=ges/test-utils.h
libtestutils_la_LIBADD=$(common_ldadd)
libtestutils_la_CFLAGS=$(common_cflags)
libtestutils_la_SOURCES=ges/test-utils.c
SUPPRESSIONS = $(top_srcdir)/common/gst.supp # $(srcdir)/gst-plugins-bad.supp
clean-local: clean-local-check
check_PROGRAMS = \
@ -29,16 +42,12 @@ check_PROGRAMS = \
ges/text_properties\
ges/save_and_load
noinst_HEADERS =
noinst_LTLIBRARIES=$(testutils_noisnt_libraries)
noinst_HEADERS=$(testutils_noinst_headers)
TESTS = $(check_PROGRAMS)
AM_CFLAGS = -I$(top_srcdir) $(GST_PLUGINS_BASE_CFLAGS) $(GST_OBJ_CFLAGS) \
$(GST_CHECK_CFLAGS) $(GST_OPTION_CFLAGS) $(GST_CFLAGS) \
-UG_DISABLE_ASSERT -UG_DISABLE_CAST_CHECKS
LDADD = $(top_builddir)/ges/libges-@GST_API_VERSION@.la \
$(GST_PLUGINS_BASE_LIBS) -lgstpbutils-$(GST_API_VERSION) \
$(GST_OBJ_LIBS) $(GST_CHECK_LIBS)
AM_CFLAGS = $(common_cflags) -UG_DISABLE_ASSERT -UG_DISABLE_CAST_CHECKS
LDADD = $(common_ldadd) libtestutils.la
EXTRA_DIST = #gst-plugins-bad.supp

View file

@ -0,0 +1,80 @@
/**
* Gstreamer Editing Services
*
* Copyright (C) <2012> Thibault Saunier <thibault.saunier@collabora.com>
*
* 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., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "test-utils.h"
#include <gio/gio.h>
gchar *
ges_test_get_audio_only_uri (void)
{
gchar *uri;
GFile *cfile, *fdir, *f_audio_only;
cfile = g_file_new_for_path (__FILE__);
fdir = g_file_get_parent (cfile);
f_audio_only = g_file_get_child (fdir, "audio_only.ogg");
uri = g_file_get_uri (f_audio_only);
g_object_unref (cfile);
g_object_unref (fdir);
g_object_unref (f_audio_only);
return uri;
}
gchar *
ges_test_get_audio_video_uri (void)
{
gchar *uri;
GFile *cfile, *fdir, *f_audio_video;
cfile = g_file_new_for_path (__FILE__);
fdir = g_file_get_parent (cfile);
f_audio_video = g_file_get_child (fdir, "audio_video.ogg");
uri = g_file_get_uri (f_audio_video);
g_object_unref (cfile);
g_object_unref (fdir);
g_object_unref (f_audio_video);
return uri;
}
gchar *
ges_test_file_uri (const gchar * filename)
{
gchar *uri;
GFile *cfile, *fdir, *f_xptv;
cfile = g_file_new_for_path (__FILE__);
fdir = g_file_get_parent (cfile);
f_xptv = g_file_get_child (fdir, filename);
uri = g_file_get_uri (f_xptv);
g_object_unref (cfile);
g_object_unref (fdir);
g_object_unref (f_xptv);
return uri;
}

View file

@ -0,0 +1,45 @@
/**
* Gstreamer Editing Services
*
* Copyright (C) <2012> Thibault Saunier <thibault.saunier@collabora.com>
*
* 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., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef _GES_TEST_UTILS
#define _GES_TEST_UTILS
#include <ges/ges.h>
gchar * ges_test_get_audio_only_uri (void);
gchar * ges_test_get_audio_video_uri (void);
gchar * ges_test_file_uri (const gchar *filename);
#define gnl_object_check(gnlobj, start, duration, mstart, mduration, priority, active) { \
guint64 pstart, pdur, pmstart, pmdur, pprio, pact; \
g_object_get (gnlobj, "start", &pstart, "duration", &pdur, \
"media-start", &pmstart, "media-duration", &pmdur, \
"priority", &pprio, "active", &pact, \
NULL); \
assert_equals_uint64 (pstart, start); \
assert_equals_uint64 (pdur, duration); \
assert_equals_uint64 (pmstart, mstart); \
assert_equals_uint64 (pmdur, mduration); \
assert_equals_int (pprio, priority); \
assert_equals_int (pact, active); \
}
#endif /* _GES_TEST_UTILS */