tests: tags: add unit test for ID3 v2.4 extended headers

https://bugzilla.gnome.org/show_bug.cgi?id=792983
This commit is contained in:
Tim-Philipp Müller 2018-03-01 12:43:25 +00:00
parent 6f5c9db1cc
commit 556bc04f1c

View file

@ -764,6 +764,25 @@ parse_id3v2_tag_from_data (const guint8 * id3v2, gsize id3v2_size)
GST_START_TEST (test_id3v2_extended_header)
{
const guint8 id3v24_exthdr[1024] = {
0x49, 0x44, 0x33, 0x04, 0x00, 0x40, 0x00, 0x00, 0x07, 0x76,
0x00, 0x00, 0x00, 0x0c, 0x01, 0x20, 0x05, 0x0b, 0x7f, 0x06,
0x43, 0x22, 0x54, 0x53, 0x53, 0x45, 0x00, 0x00, 0x00, 0x0e,
0x00, 0x00, 0x03, 0x4c, 0x61, 0x76, 0x66, 0x35, 0x37, 0x2e,
0x37, 0x31, 0x2e, 0x31, 0x30, 0x30, 0x54, 0x49, 0x54, 0x32,
0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x03, 0x53, 0x69, 0x6c,
0x65, 0x6e, 0x63, 0x65, 0x54, 0x50, 0x45, 0x31, 0x00, 0x00,
0x00, 0x07, 0x00, 0x00, 0x03, 0x4e, 0x6f, 0x20, 0x6f, 0x6e,
0x65, 0x54, 0x50, 0x45, 0x32, 0x00, 0x00, 0x00, 0x05, 0x00,
0x00, 0x03, 0x4e, 0x6f, 0x6e, 0x65, 0x54, 0x41, 0x4c, 0x42,
0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x03, 0x4e, 0x65, 0x69,
0x74, 0x68, 0x65, 0x72, 0x54, 0x44, 0x52, 0x43, 0x00, 0x00,
0x00, 0x05, 0x00, 0x00, 0x03, 0x32, 0x30, 0x31, 0x38, 0x54,
0x52, 0x43, 0x4b, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x03,
0x30, 0x31, 0x2f, 0x30, 0x31, 0x54, 0x43, 0x4f, 0x4e, 0x00,
0x00, 0x00, 0x06, 0x00, 0x00, 0x03, 0x28, 0x31, 0x34, 0x38,
0x29,
};
const guint8 id3v2_exthdr[] = {
0x49, 0x44, 0x33, 0x03, 0x00, 0x40, 0x00, 0x00, 0x00, 0x1b,
0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@ -778,11 +797,17 @@ GST_START_TEST (test_id3v2_extended_header)
GstTagList *tags;
tags = parse_id3v2_tag_from_data (id3v2_exthdr, sizeof (id3v2_exthdr));
fail_if (tags == NULL, "Failed to parse ID3 tag with extension header");
fail_if (tags == NULL, "Failed to parse ID3 v2.3 tag with extension header");
GST_LOG ("tags: %" GST_PTR_FORMAT, tags);
fail_unless_equals_int (gst_tag_list_n_tags (tags), 1);
gst_tag_list_unref (tags);
tags = parse_id3v2_tag_from_data (id3v24_exthdr, sizeof (id3v24_exthdr));
fail_if (tags == NULL, "Failed to parse ID3 v2.4 tag with extension header");
GST_LOG ("tags: %" GST_PTR_FORMAT, tags);
fail_unless_equals_int (gst_tag_list_n_tags (tags), 9);
gst_tag_list_unref (tags);
tags = parse_id3v2_tag_from_data (id3v2_no_exthdr, sizeof (id3v2_no_exthdr));
fail_if (tags == NULL, "Failed to parse ID3 tag without extension header");
GST_LOG ("tags: %" GST_PTR_FORMAT, tags);