tests: rewrite test a little

Rewrite the tag check so that we don't need to deal with tag lists.
This commit is contained in:
Wim Taymans 2012-01-03 14:42:28 +01:00
parent 8e39d52bbb
commit 386ccc52e7

View file

@ -143,7 +143,7 @@ test_demux_tags (const gchar * tag_str, const gchar * demuxer,
GstBus *bus; GstBus *bus;
GMainLoop *loop; GMainLoop *loop;
GstTagList *sent_tags; GstTagList *sent_tags;
gint i, j, n_recv, n_sent; gint i, j, k, n_recv, n_sent;
const gchar *name_sent, *name_recv; const gchar *name_sent, *name_recv;
const GValue *value_sent, *value_recv; const GValue *value_sent, *value_recv;
gboolean found; gboolean found;
@ -192,12 +192,25 @@ test_demux_tags (const gchar * tag_str, const gchar * demuxer,
/* FIXME: compare taglits values */ /* FIXME: compare taglits values */
for (i = 0; i < n_sent; i++) { for (i = 0; i < n_sent; i++) {
name_sent = gst_tag_list_nth_tag_name (sent_tags, i); name_sent = gst_tag_list_nth_tag_name (sent_tags, i);
value_sent = gst_tag_list_get_value (sent_tags, name_sent);
found = FALSE; found = FALSE;
for (j = 0; j < n_recv; j++) { for (j = 0; j < n_recv; j++) {
name_recv = gst_tag_list_nth_tag_name (received_tags, j); name_recv = gst_tag_list_nth_tag_name (received_tags, j);
if (!strcmp (name_sent, name_recv)) { if (!strcmp (name_sent, name_recv)) {
value_recv = gst_tag_list_get_value (received_tags, name_recv); guint sent_len, recv_len;
sent_len = gst_tag_list_get_tag_size (sent_tags, name_sent);
recv_len = gst_tag_list_get_tag_size (received_tags, name_recv);
fail_unless (sent_len == recv_len,
"tag item %s has been received with different size", name_sent);
for (k = 0; k < sent_len; k++) {
value_sent = gst_tag_list_get_value_index (sent_tags, name_sent, k);
value_recv =
gst_tag_list_get_value_index (received_tags, name_recv, k);
comparison = gst_value_compare (value_sent, value_recv); comparison = gst_value_compare (value_sent, value_recv);
if (comparison != GST_VALUE_EQUAL) { if (comparison != GST_VALUE_EQUAL) {
gchar *vs = g_strdup_value_contents (value_sent); gchar *vs = g_strdup_value_contents (value_sent);
@ -215,6 +228,7 @@ test_demux_tags (const gchar * tag_str, const gchar * demuxer,
break; break;
} }
} }
}
fail_unless (found, "tag item %s is lost", name_sent); fail_unless (found, "tag item %s is lost", name_sent);
} }