Merge branch 'master' into merge-master-to-taglib2

Conflicts:
	taglib/asf/asftag.cpp
	taglib/mp4/mp4tag.cpp
	taglib/toolkit/tstring.h
This commit is contained in:
Tsuda Kageyu
2014-04-11 18:31:49 +09:00
12 changed files with 939 additions and 5 deletions

View File

@ -14,6 +14,8 @@
#include <textidentificationframe.h>
#include <attachedpictureframe.h>
#include <unsynchronizedlyricsframe.h>
#include <synchronizedlyricsframe.h>
#include <eventtimingcodesframe.h>
#include <generalencapsulatedobjectframe.h>
#include <relativevolumeframe.h>
#include <popularimeterframe.h>
@ -71,6 +73,10 @@ class TestID3v2 : public CppUnit::TestFixture
CPPUNIT_TEST(testRenderUserUrlLinkFrame);
CPPUNIT_TEST(testParseOwnershipFrame);
CPPUNIT_TEST(testRenderOwnershipFrame);
CPPUNIT_TEST(testParseSynchronizedLyricsFrame);
CPPUNIT_TEST(testRenderSynchronizedLyricsFrame);
CPPUNIT_TEST(testParseEventTimingCodesFrame);
CPPUNIT_TEST(testRenderEventTimingCodesFrame);
CPPUNIT_TEST(testSaveUTF16Comment);
CPPUNIT_TEST(testUpdateGenre23_1);
CPPUNIT_TEST(testUpdateGenre23_2);
@ -429,6 +435,104 @@ public:
f.render());
}
void testParseSynchronizedLyricsFrame()
{
ID3v2::SynchronizedLyricsFrame f(
ByteVector("SYLT" // Frame ID
"\x00\x00\x00\x21" // Frame size
"\x00\x00" // Frame flags
"\x00" // Text encoding
"eng" // Language
"\x02" // Time stamp format
"\x01" // Content type
"foo\x00" // Content descriptor
"Example\x00" // 1st text
"\x00\x00\x04\xd2" // 1st time stamp
"Lyrics\x00" // 2nd text
"\x00\x00\x11\xd7", 43)); // 2nd time stamp
CPPUNIT_ASSERT_EQUAL(String::Latin1, f.textEncoding());
CPPUNIT_ASSERT_EQUAL(ByteVector("eng", 3), f.language());
CPPUNIT_ASSERT_EQUAL(ID3v2::SynchronizedLyricsFrame::AbsoluteMilliseconds,
f.timestampFormat());
CPPUNIT_ASSERT_EQUAL(ID3v2::SynchronizedLyricsFrame::Lyrics, f.type());
CPPUNIT_ASSERT_EQUAL(String("foo"), f.description());
ID3v2::SynchronizedLyricsFrame::SynchedTextList stl = f.synchedText();
CPPUNIT_ASSERT_EQUAL(size_t(2), stl.size());
CPPUNIT_ASSERT_EQUAL(String("Example"), stl[0].text);
CPPUNIT_ASSERT_EQUAL(TagLib::uint(1234), stl[0].time);
CPPUNIT_ASSERT_EQUAL(String("Lyrics"), stl[1].text);
CPPUNIT_ASSERT_EQUAL(TagLib::uint(4567), stl[1].time);
}
void testRenderSynchronizedLyricsFrame()
{
ID3v2::SynchronizedLyricsFrame f;
f.setTextEncoding(String::Latin1);
f.setLanguage(ByteVector("eng", 3));
f.setTimestampFormat(ID3v2::SynchronizedLyricsFrame::AbsoluteMilliseconds);
f.setType(ID3v2::SynchronizedLyricsFrame::Lyrics);
f.setDescription("foo");
ID3v2::SynchronizedLyricsFrame::SynchedTextList stl;
stl.append(ID3v2::SynchronizedLyricsFrame::SynchedText(1234, "Example"));
stl.append(ID3v2::SynchronizedLyricsFrame::SynchedText(4567, "Lyrics"));
f.setSynchedText(stl);
CPPUNIT_ASSERT_EQUAL(
ByteVector("SYLT" // Frame ID
"\x00\x00\x00\x21" // Frame size
"\x00\x00" // Frame flags
"\x00" // Text encoding
"eng" // Language
"\x02" // Time stamp format
"\x01" // Content type
"foo\x00" // Content descriptor
"Example\x00" // 1st text
"\x00\x00\x04\xd2" // 1st time stamp
"Lyrics\x00" // 2nd text
"\x00\x00\x11\xd7", 43), // 2nd time stamp
f.render());
}
void testParseEventTimingCodesFrame()
{
ID3v2::EventTimingCodesFrame f(
ByteVector("ETCO" // Frame ID
"\x00\x00\x00\x0b" // Frame size
"\x00\x00" // Frame flags
"\x02" // Time stamp format
"\x02" // 1st event
"\x00\x00\xf3\x5c" // 1st time stamp
"\xfe" // 2nd event
"\x00\x36\xee\x80", 21)); // 2nd time stamp
CPPUNIT_ASSERT_EQUAL(ID3v2::EventTimingCodesFrame::AbsoluteMilliseconds,
f.timestampFormat());
ID3v2::EventTimingCodesFrame::SynchedEventList sel = f.synchedEvents();
CPPUNIT_ASSERT_EQUAL(size_t(2), sel.size());
CPPUNIT_ASSERT_EQUAL(ID3v2::EventTimingCodesFrame::IntroStart, sel[0].type);
CPPUNIT_ASSERT_EQUAL(TagLib::uint(62300), sel[0].time);
CPPUNIT_ASSERT_EQUAL(ID3v2::EventTimingCodesFrame::AudioFileEnds, sel[1].type);
CPPUNIT_ASSERT_EQUAL(TagLib::uint(3600000), sel[1].time);
}
void testRenderEventTimingCodesFrame()
{
ID3v2::EventTimingCodesFrame f;
f.setTimestampFormat(ID3v2::EventTimingCodesFrame::AbsoluteMilliseconds);
ID3v2::EventTimingCodesFrame::SynchedEventList sel;
sel.append(ID3v2::EventTimingCodesFrame::SynchedEvent(62300, ID3v2::EventTimingCodesFrame::IntroStart));
sel.append(ID3v2::EventTimingCodesFrame::SynchedEvent(3600000, ID3v2::EventTimingCodesFrame::AudioFileEnds));
f.setSynchedEvents(sel);
CPPUNIT_ASSERT_EQUAL(
ByteVector("ETCO" // Frame ID
"\x00\x00\x00\x0b" // Frame size
"\x00\x00" // Frame flags
"\x02" // Time stamp format
"\x02" // 1st event
"\x00\x00\xf3\x5c" // 1st time stamp
"\xfe" // 2nd event
"\x00\x36\xee\x80", 21), // 2nd time stamp
f.render());
}
void testItunes24FrameSize()
{
MPEG::File f(TEST_FILE_PATH_C("005411.id3"), false);