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

# Conflicts:
#	taglib/mp4/mp4atom.cpp
#	taglib/toolkit/tutils.h
#	tests/test_apetag.cpp
This commit is contained in:
Tsuda Kageyu
2016-11-09 11:05:53 +09:00
14 changed files with 190 additions and 59 deletions

Binary file not shown.

View File

@ -114,18 +114,21 @@ public:
PropertyMap properties;
properties["A"] = String("invalid key: one character");
properties["MP+"] = String("invalid key: forbidden string");
properties[L"\x1234\x3456"] = String("invalid key: Unicode");
properties["A B~C"] = String("valid key: space and tilde");
properties["ARTIST"] = String("valid key: normal one");
APE::Tag tag;
PropertyMap unsuccessful = tag.setProperties(properties);
CPPUNIT_ASSERT_EQUAL((size_t)2, unsuccessful.size());
CPPUNIT_ASSERT_EQUAL((size_t)3, unsuccessful.size());
CPPUNIT_ASSERT(unsuccessful.contains("A"));
CPPUNIT_ASSERT(unsuccessful.contains("MP+"));
CPPUNIT_ASSERT(unsuccessful.contains(L"\x1234\x3456"));
CPPUNIT_ASSERT_EQUAL((size_t)2, tag.itemListMap().size());
tag.addValue("VALID KEY", "Test Value 1");
tag.addValue("INVALID KEY \x7f", "Test Value 2");
tag.addValue(L"INVALID KEY \x1234\x3456", "Test Value 3");
CPPUNIT_ASSERT_EQUAL((size_t)3, tag.itemListMap().size());
}

View File

@ -111,6 +111,7 @@ class TestID3v2 : public CppUnit::TestFixture
CPPUNIT_TEST(testW000);
CPPUNIT_TEST(testPropertyInterface);
CPPUNIT_TEST(testPropertyInterface2);
CPPUNIT_TEST(testPropertiesMovement);
CPPUNIT_TEST(testDeleteFrame);
CPPUNIT_TEST(testSaveAndStripID3v1ShouldNotAddFrameFromID3v1ToId3v2);
CPPUNIT_TEST(testParseChapterFrame);
@ -932,6 +933,48 @@ public:
CPPUNIT_ASSERT_EQUAL(frame6, ID3v2::UniqueFileIdentifierFrame::findByOwner(&tag, "http://musicbrainz.org"));
}
void testPropertiesMovement()
{
ID3v2::Tag tag;
ID3v2::TextIdentificationFrame *frameMvnm = new ID3v2::TextIdentificationFrame("MVNM");
frameMvnm->setText("Movement Name");
tag.addFrame(frameMvnm);
ID3v2::TextIdentificationFrame *frameMvin = new ID3v2::TextIdentificationFrame("MVIN");
frameMvin->setText("2/3");
tag.addFrame(frameMvin);
PropertyMap properties = tag.properties();
CPPUNIT_ASSERT(properties.contains("MOVEMENTNAME"));
CPPUNIT_ASSERT(properties.contains("MOVEMENTNUMBER"));
CPPUNIT_ASSERT_EQUAL(String("Movement Name"), properties["MOVEMENTNAME"].front());
CPPUNIT_ASSERT_EQUAL(String("2/3"), properties["MOVEMENTNUMBER"].front());
ByteVector frameDataMvnm("MVNM"
"\x00\x00\x00\x0e"
"\x00\x00"
"\x00"
"Movement Name", 24);
CPPUNIT_ASSERT_EQUAL(frameDataMvnm, frameMvnm->render());
ByteVector frameDataMvin("MVIN"
"\x00\x00\x00\x04"
"\x00\x00"
"\x00"
"2/3", 14);
CPPUNIT_ASSERT_EQUAL(frameDataMvin, frameMvin->render());
ID3v2::Header header;
ID3v2::FrameFactory *factory = ID3v2::FrameFactory::instance();
ID3v2::TextIdentificationFrame *parsedFrameMvnm =
dynamic_cast<ID3v2::TextIdentificationFrame *>(factory->createFrame(frameDataMvnm, &header));
ID3v2::TextIdentificationFrame *parsedFrameMvin =
dynamic_cast<ID3v2::TextIdentificationFrame *>(factory->createFrame(frameDataMvin, &header));
CPPUNIT_ASSERT(parsedFrameMvnm);
CPPUNIT_ASSERT(parsedFrameMvin);
CPPUNIT_ASSERT_EQUAL(String("Movement Name"), parsedFrameMvnm->toString());
CPPUNIT_ASSERT_EQUAL(String("2/3"), parsedFrameMvin->toString());
}
void testDeleteFrame()
{
ScopedFileCopy copy("rare_frames", ".mp3");

View File

@ -55,8 +55,10 @@ class TestMP4 : public CppUnit::TestFixture
CPPUNIT_TEST(testCovrWrite);
CPPUNIT_TEST(testCovrRead2);
CPPUNIT_TEST(testProperties);
CPPUNIT_TEST(testPropertiesMovement);
CPPUNIT_TEST(testFuzzedFile);
CPPUNIT_TEST(testRepeatedSave);
CPPUNIT_TEST(testWithZeroLengthAtom);
CPPUNIT_TEST_SUITE_END();
public:
@ -378,6 +380,58 @@ public:
f.setProperties(tags);
}
void testPropertiesMovement()
{
MP4::File f(TEST_FILE_PATH_C("has-tags.m4a"));
PropertyMap tags = f.properties();
tags["WORK"] = StringList("Foo");
tags["MOVEMENTNAME"] = StringList("Bar");
tags["MOVEMENTNUMBER"] = StringList("2");
tags["MOVEMENTCOUNT"] = StringList("3");
tags["SHOWWORKMOVEMENT"] = StringList("1");
f.setProperties(tags);
tags = f.properties();
CPPUNIT_ASSERT(f.tag()->contains("\251wrk"));
CPPUNIT_ASSERT_EQUAL(StringList("Foo"), f.tag()->item("\251wrk").toStringList());
CPPUNIT_ASSERT_EQUAL(StringList("Foo"), tags["WORK"]);
CPPUNIT_ASSERT(f.tag()->contains("\251mvn"));
CPPUNIT_ASSERT_EQUAL(StringList("Bar"), f.tag()->item("\251mvn").toStringList());
CPPUNIT_ASSERT_EQUAL(StringList("Bar"), tags["MOVEMENTNAME"]);
CPPUNIT_ASSERT(f.tag()->contains("\251mvi"));
CPPUNIT_ASSERT_EQUAL(2, f.tag()->item("\251mvi").toInt());
CPPUNIT_ASSERT_EQUAL(StringList("2"), tags["MOVEMENTNUMBER"]);
CPPUNIT_ASSERT(f.tag()->contains("\251mvc"));
CPPUNIT_ASSERT_EQUAL(3, f.tag()->item("\251mvc").toInt());
CPPUNIT_ASSERT_EQUAL(StringList("3"), tags["MOVEMENTCOUNT"]);
CPPUNIT_ASSERT(f.tag()->contains("shwm"));
CPPUNIT_ASSERT_EQUAL(true, f.tag()->item("shwm").toBool());
CPPUNIT_ASSERT_EQUAL(StringList("1"), tags["SHOWWORKMOVEMENT"]);
tags["SHOWWORKMOVEMENT"] = StringList("0");
f.setProperties(tags);
tags = f.properties();
CPPUNIT_ASSERT(f.tag()->contains("shwm"));
CPPUNIT_ASSERT_EQUAL(false, f.tag()->item("shwm").toBool());
CPPUNIT_ASSERT_EQUAL(StringList("0"), tags["SHOWWORKMOVEMENT"]);
tags["WORK"] = StringList();
tags["MOVEMENTNAME"] = StringList();
tags["MOVEMENTNUMBER"] = StringList();
tags["MOVEMENTCOUNT"] = StringList();
tags["SHOWWORKMOVEMENT"] = StringList();
f.setProperties(tags);
}
void testFuzzedFile()
{
MP4::File f(TEST_FILE_PATH_C("infloop.m4a"));
@ -395,6 +449,15 @@ public:
CPPUNIT_ASSERT_EQUAL(2862LL, f.find("0123456789"));
CPPUNIT_ASSERT_EQUAL(-1LL, f.find("0123456789", 2863));
}
void testWithZeroLengthAtom()
{
MP4::File f(TEST_FILE_PATH_C("zero-length-mdat.m4a"));
CPPUNIT_ASSERT(f.isValid());
CPPUNIT_ASSERT_EQUAL(1115, f.audioProperties()->lengthInMilliseconds());
CPPUNIT_ASSERT_EQUAL(22050, f.audioProperties()->sampleRate());
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestMP4);