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

# Conflicts:
#	taglib/flac/flacfile.h
#	taglib/mpeg/mpegheader.cpp
#	taglib/mpeg/mpegproperties.cpp
#	taglib/ogg/oggfile.cpp
#	taglib/ogg/oggpage.cpp
#	taglib/ogg/oggpageheader.cpp
#	tests/test_mpeg.cpp
This commit is contained in:
Tsuda Kageyu
2016-01-06 10:28:09 +09:00
22 changed files with 541 additions and 435 deletions

Binary file not shown.

Binary file not shown.

View File

@ -36,6 +36,7 @@ class TestFLAC : public CppUnit::TestFixture
CPPUNIT_TEST(testSaveID3v1);
CPPUNIT_TEST(testUpdateID3v2);
CPPUNIT_TEST(testEmptyID3v2);
CPPUNIT_TEST(testStripTags);
CPPUNIT_TEST_SUITE_END();
public:
@ -416,6 +417,57 @@ public:
}
}
void testStripTags()
{
ScopedFileCopy copy("silence-44-s", ".flac");
{
FLAC::File f(copy.fileName().c_str());
f.xiphComment(true)->setTitle("XiphComment Title");
f.ID3v1Tag(true)->setTitle("ID3v1 Title");
f.ID3v2Tag(true)->setTitle("ID3v2 Title");
f.save();
}
{
FLAC::File f(copy.fileName().c_str());
CPPUNIT_ASSERT(f.hasXiphComment());
CPPUNIT_ASSERT(f.hasID3v1Tag());
CPPUNIT_ASSERT(f.hasID3v2Tag());
CPPUNIT_ASSERT_EQUAL(String("XiphComment Title"), f.xiphComment()->title());
CPPUNIT_ASSERT_EQUAL(String("ID3v1 Title"), f.ID3v1Tag()->title());
CPPUNIT_ASSERT_EQUAL(String("ID3v2 Title"), f.ID3v2Tag()->title());
f.strip(FLAC::File::ID3v2);
f.save();
}
{
FLAC::File f(copy.fileName().c_str());
CPPUNIT_ASSERT(f.hasXiphComment());
CPPUNIT_ASSERT(f.hasID3v1Tag());
CPPUNIT_ASSERT(!f.hasID3v2Tag());
CPPUNIT_ASSERT_EQUAL(String("XiphComment Title"), f.xiphComment()->title());
CPPUNIT_ASSERT_EQUAL(String("ID3v1 Title"), f.ID3v1Tag()->title());
f.strip(FLAC::File::ID3v1);
f.save();
}
{
FLAC::File f(copy.fileName().c_str());
CPPUNIT_ASSERT(f.hasXiphComment());
CPPUNIT_ASSERT(!f.hasID3v1Tag());
CPPUNIT_ASSERT(!f.hasID3v2Tag());
CPPUNIT_ASSERT_EQUAL(String("XiphComment Title"), f.xiphComment()->title());
f.strip(FLAC::File::XiphComment);
f.save();
}
{
FLAC::File f(copy.fileName().c_str());
CPPUNIT_ASSERT(f.hasXiphComment());
CPPUNIT_ASSERT(!f.hasID3v1Tag());
CPPUNIT_ASSERT(!f.hasID3v2Tag());
CPPUNIT_ASSERT(f.xiphComment()->isEmpty());
CPPUNIT_ASSERT_EQUAL(String("reference libFLAC 1.1.0 20030126"), f.xiphComment()->vendorID());
}
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestFLAC);

View File

@ -717,11 +717,13 @@ public:
CPPUNIT_ASSERT(!bar.ID3v2Tag()->frameListMap().contains("TDTG"));
CPPUNIT_ASSERT(!bar.ID3v2Tag()->frameListMap().contains("TMOO"));
CPPUNIT_ASSERT(!bar.ID3v2Tag()->frameListMap().contains("TPRO"));
#ifdef NO_ITUNES_HACKS
CPPUNIT_ASSERT(!bar.ID3v2Tag()->frameListMap().contains("TSOA"));
CPPUNIT_ASSERT(!bar.ID3v2Tag()->frameListMap().contains("TSOT"));
CPPUNIT_ASSERT(!bar.ID3v2Tag()->frameListMap().contains("TSST"));
CPPUNIT_ASSERT(!bar.ID3v2Tag()->frameListMap().contains("TSOP"));
}
#endif
CPPUNIT_ASSERT(!bar.ID3v2Tag()->frameListMap().contains("TSST"));
}
}
void testCompressedFrameWithBrokenLength()

View File

@ -22,7 +22,8 @@ class TestMPEG : public CppUnit::TestFixture
CPPUNIT_TEST(testAudioPropertiesXingHeaderVBR);
CPPUNIT_TEST(testAudioPropertiesVBRIHeader);
CPPUNIT_TEST(testAudioPropertiesNoVBRHeaders);
CPPUNIT_TEST(testSkipInvalidFrames);
CPPUNIT_TEST(testSkipInvalidFrames1);
CPPUNIT_TEST(testSkipInvalidFrames2);
CPPUNIT_TEST(testVersion2DurationWithXingHeader);
CPPUNIT_TEST(testSaveID3v24);
CPPUNIT_TEST(testSaveID3v24WrongParam);
@ -93,35 +94,43 @@ public:
CPPUNIT_ASSERT(!f.audioProperties()->xingHeader());
long long last = f.lastFrameOffset();
MPEG::Header lastHeader(&f, last, false);
f.seek(last);
MPEG::Header lastHeader(f.readBlock(4));
while (!lastHeader.isValid()) {
while(!lastHeader.isValid()) {
last = f.previousFrameOffset(last);
f.seek(last);
lastHeader = MPEG::Header(f.readBlock(4));
lastHeader = MPEG::Header(&f, last, false);
}
CPPUNIT_ASSERT_EQUAL(28213LL, last);
CPPUNIT_ASSERT_EQUAL(209, lastHeader.frameLength());
}
void testSkipInvalidFrames()
void testSkipInvalidFrames1()
{
MPEG::File f(TEST_FILE_PATH_C("invalid-frames.mp3"));
CPPUNIT_ASSERT(f.audioProperties());
CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->length());
CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->lengthInSeconds());
CPPUNIT_ASSERT_EQUAL(393, f.audioProperties()->lengthInMilliseconds());
CPPUNIT_ASSERT_EQUAL(392, f.audioProperties()->lengthInMilliseconds());
CPPUNIT_ASSERT_EQUAL(160, f.audioProperties()->bitrate());
CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
CPPUNIT_ASSERT(!f.audioProperties()->xingHeader());
}
void testSkipInvalidFrames2()
{
MPEG::File f(TEST_FILE_PATH_C("invalid-frames2.mp3"));
CPPUNIT_ASSERT(f.audioProperties());
CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->length());
CPPUNIT_ASSERT_EQUAL(0, f.audioProperties()->lengthInSeconds());
CPPUNIT_ASSERT_EQUAL(314, f.audioProperties()->lengthInMilliseconds());
CPPUNIT_ASSERT_EQUAL(192, f.audioProperties()->bitrate());
CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
CPPUNIT_ASSERT(!f.audioProperties()->xingHeader());
}
void testVersion2DurationWithXingHeader()
{
MPEG::File f(TEST_FILE_PATH_C("mpeg2.mp3"));