tools/gst-inspect.c (print_field): Change prototype for non-mutating caps_foreach.

Original commit message from CVS:
2005-02-11  Andy Wingo  <wingo@pobox.com>

* tools/gst-inspect.c (print_field): Change prototype for
non-mutating caps_foreach.

* check/gst/gstobject.c (test_fail_abstract_new): Expect a warning
from GLib.

* check/gst/gstcaps.c (test_double_append): Renamed from
test_fail_double_append.
(test_mutability): New test, tests that caps and structures are
mutable only with refcount 1, or in the case of structures, also
when unparented.

* check/gstcheck.c (gst_check_init): Handle WARNING in addition to
CRITICAL.
(gst_check_log_critical_func): Print criticals in both the
expected and unexpected cases.
This commit is contained in:
Andy Wingo 2005-02-11 15:28:20 +00:00
parent cf4e552e1d
commit 98e3377631
8 changed files with 116 additions and 39 deletions

View file

@ -1,19 +1,22 @@
2005-02-11 Thomas Vander Stichele <thomas at apestaart dot org>
* configure.ac:
* docs/gst/Makefile.am:
* docs/libs/Makefile.am:
merge from HEAD: add popt to gtk-doc build
2005-02-11 Thomas Vander Stichele <thomas at apestaart dot org>
* gst/gsterror.c:
* gst/gsterror.h:
merge docs from HEAD
remove unused and unneeded error to combat inflation
2005-02-11 Andy Wingo <wingo@pobox.com>
* tools/gst-inspect.c (print_field): Change prototype for
non-mutating caps_foreach.
* check/gst/gstobject.c (test_fail_abstract_new): Expect a warning
from GLib.
* check/gst/gstcaps.c (test_double_append): Renamed from
test_fail_double_append.
(test_mutability): New test, tests that caps and structures are
mutable only with refcount 1, or in the case of structures, also
when unparented.
* check/gstcheck.c (gst_check_init): Handle WARNING in addition to
CRITICAL.
(gst_check_log_critical_func): Print criticals in both the
expected and unexpected cases.
* check/gst/gstcaps.c: New test suite. Only one test at the moment
-- this is an infrastructure commit.
@ -40,6 +43,20 @@
have some new mechanisms for that.
(TESTS): Added gst/gstcaps.
2005-02-11 Thomas Vander Stichele <thomas at apestaart dot org>
* configure.ac:
* docs/gst/Makefile.am:
* docs/libs/Makefile.am:
merge from HEAD: add popt to gtk-doc build
2005-02-11 Thomas Vander Stichele <thomas at apestaart dot org>
* gst/gsterror.c:
* gst/gsterror.h:
merge docs from HEAD
remove unused and unneeded error to combat inflation
2005-02-10 Wim Taymans <wim@fluendo.com>
* docs/design/part-events.txt:

View file

@ -23,7 +23,7 @@
#include "../gstcheck.h"
START_TEST (test_fail_double_append)
START_TEST (test_double_append)
{
GstStructure *s1;
GstCaps *c1;
@ -33,13 +33,42 @@ START_TEST (test_fail_double_append)
gst_caps_append_structure (c1, s1);
ASSERT_CRITICAL (gst_caps_append_structure (c1, s1));
}
END_TEST
START_TEST (test_mutability)
{
GstStructure *s1;
GstCaps *c1;
gint ret;
c1 = gst_caps_new_any ();
s1 = gst_structure_from_string ("audio/x-raw-int,rate=44100", NULL);
gst_structure_set (s1, "rate", G_TYPE_INT, 48000, NULL);
gst_caps_append_structure (c1, s1);
gst_structure_set (s1, "rate", G_TYPE_INT, 22500, NULL);
gst_caps_ref (c1);
ASSERT_CRITICAL (gst_structure_set (s1, "rate", G_TYPE_INT, 11250, NULL));
fail_unless (gst_structure_get_int (s1, "rate", &ret));
fail_unless (ret == 22500);
ASSERT_CRITICAL (gst_caps_set_simple (c1, "rate", G_TYPE_INT, 11250, NULL));
fail_unless (gst_structure_get_int (s1, "rate", &ret));
fail_unless (ret == 22500);
gst_caps_unref (c1);
gst_structure_set (s1, "rate", G_TYPE_INT, 11250, NULL);
fail_unless (gst_structure_get_int (s1, "rate", &ret));
fail_unless (ret == 11250);
gst_caps_set_simple (c1, "rate", G_TYPE_INT, 1, NULL);
fail_unless (gst_structure_get_int (s1, "rate", &ret));
fail_unless (ret == 1);
}
END_TEST Suite * gst_caps_suite (void)
{
Suite *s = suite_create ("GstCaps");
TCase *tc_chain = tcase_create ("mutability");
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_fail_double_append);
tcase_add_test (tc_chain, test_double_append);
tcase_add_test (tc_chain, test_mutability);
return s;
}

View file

@ -71,8 +71,7 @@ START_TEST (test_fail_abstract_new)
{
GstObject *object;
object = g_object_new (gst_object_get_type (), NULL);
/* this should assert and segfault, but we add fallbacks anyway */
ASSERT_CRITICAL (object = g_object_new (gst_object_get_type (), NULL));
fail_unless (object == NULL, "Created an instance of abstract GstObject");
}

View file

@ -52,13 +52,13 @@ void gst_check_log_critical_func
(const gchar * log_domain, GLogLevelFlags log_level,
const gchar * message, gpointer user_data)
{
if (!_gst_check_expecting_log)
fail ("Unexpected assertion: %s", message);
if (_gst_check_debug) {
g_print (message);
if (!_gst_check_expecting_log) {
g_print ("\n\nUnexpected critical/warning: %s\n", message);
fail ("Unexpected critical/warning: %s", message);
}
g_print ("\nExpected critical/warning: %s\n", message);
if (log_level & G_LOG_LEVEL_CRITICAL)
_gst_check_raised_critical = TRUE;
}
@ -74,8 +74,10 @@ gst_check_init (int *argc, char **argv[])
g_log_set_handler (NULL, G_LOG_LEVEL_MESSAGE, gst_check_log_message_func,
NULL);
g_log_set_handler (NULL, G_LOG_LEVEL_CRITICAL, gst_check_log_critical_func,
NULL);
g_log_set_handler ("GStreamer", G_LOG_LEVEL_CRITICAL,
g_log_set_handler (NULL, G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING,
gst_check_log_critical_func, NULL);
g_log_set_handler ("GStreamer", G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING,
gst_check_log_critical_func, NULL);
g_log_set_handler ("GLib-GObject", G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING,
gst_check_log_critical_func, NULL);
}

View file

@ -23,7 +23,7 @@
#include "../gstcheck.h"
START_TEST (test_fail_double_append)
START_TEST (test_double_append)
{
GstStructure *s1;
GstCaps *c1;
@ -33,13 +33,42 @@ START_TEST (test_fail_double_append)
gst_caps_append_structure (c1, s1);
ASSERT_CRITICAL (gst_caps_append_structure (c1, s1));
}
END_TEST
START_TEST (test_mutability)
{
GstStructure *s1;
GstCaps *c1;
gint ret;
c1 = gst_caps_new_any ();
s1 = gst_structure_from_string ("audio/x-raw-int,rate=44100", NULL);
gst_structure_set (s1, "rate", G_TYPE_INT, 48000, NULL);
gst_caps_append_structure (c1, s1);
gst_structure_set (s1, "rate", G_TYPE_INT, 22500, NULL);
gst_caps_ref (c1);
ASSERT_CRITICAL (gst_structure_set (s1, "rate", G_TYPE_INT, 11250, NULL));
fail_unless (gst_structure_get_int (s1, "rate", &ret));
fail_unless (ret == 22500);
ASSERT_CRITICAL (gst_caps_set_simple (c1, "rate", G_TYPE_INT, 11250, NULL));
fail_unless (gst_structure_get_int (s1, "rate", &ret));
fail_unless (ret == 22500);
gst_caps_unref (c1);
gst_structure_set (s1, "rate", G_TYPE_INT, 11250, NULL);
fail_unless (gst_structure_get_int (s1, "rate", &ret));
fail_unless (ret == 11250);
gst_caps_set_simple (c1, "rate", G_TYPE_INT, 1, NULL);
fail_unless (gst_structure_get_int (s1, "rate", &ret));
fail_unless (ret == 1);
}
END_TEST Suite * gst_caps_suite (void)
{
Suite *s = suite_create ("GstCaps");
TCase *tc_chain = tcase_create ("mutability");
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_fail_double_append);
tcase_add_test (tc_chain, test_double_append);
tcase_add_test (tc_chain, test_mutability);
return s;
}

View file

@ -71,8 +71,7 @@ START_TEST (test_fail_abstract_new)
{
GstObject *object;
object = g_object_new (gst_object_get_type (), NULL);
/* this should assert and segfault, but we add fallbacks anyway */
ASSERT_CRITICAL (object = g_object_new (gst_object_get_type (), NULL));
fail_unless (object == NULL, "Created an instance of abstract GstObject");
}

View file

@ -52,13 +52,13 @@ void gst_check_log_critical_func
(const gchar * log_domain, GLogLevelFlags log_level,
const gchar * message, gpointer user_data)
{
if (!_gst_check_expecting_log)
fail ("Unexpected assertion: %s", message);
if (_gst_check_debug) {
g_print (message);
if (!_gst_check_expecting_log) {
g_print ("\n\nUnexpected critical/warning: %s\n", message);
fail ("Unexpected critical/warning: %s", message);
}
g_print ("\nExpected critical/warning: %s\n", message);
if (log_level & G_LOG_LEVEL_CRITICAL)
_gst_check_raised_critical = TRUE;
}
@ -74,8 +74,10 @@ gst_check_init (int *argc, char **argv[])
g_log_set_handler (NULL, G_LOG_LEVEL_MESSAGE, gst_check_log_message_func,
NULL);
g_log_set_handler (NULL, G_LOG_LEVEL_CRITICAL, gst_check_log_critical_func,
NULL);
g_log_set_handler ("GStreamer", G_LOG_LEVEL_CRITICAL,
g_log_set_handler (NULL, G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING,
gst_check_log_critical_func, NULL);
g_log_set_handler ("GStreamer", G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING,
gst_check_log_critical_func, NULL);
g_log_set_handler ("GLib-GObject", G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING,
gst_check_log_critical_func, NULL);
}

View file

@ -54,7 +54,7 @@ n_print (const char *format, ...)
}
static gboolean
print_field (GQuark field, GValue * value, gpointer pfx)
print_field (GQuark field, const GValue * value, gpointer pfx)
{
gchar *str = gst_value_serialize (value);