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

# Conflicts:
#	taglib/ape/apefile.cpp
#	taglib/asf/asffile.cpp
#	taglib/asf/asftag.cpp
#	taglib/flac/flacfile.cpp
#	taglib/mp4/mp4tag.cpp
#	taglib/mpc/mpcfile.cpp
#	taglib/mpeg/mpegfile.cpp
#	taglib/mpeg/mpegfile.h
#	taglib/riff/wav/wavfile.cpp
#	taglib/tagunion.cpp
#	taglib/tagunion.h
#	taglib/trueaudio/trueaudiofile.cpp
#	taglib/wavpack/wavpackfile.cpp
This commit is contained in:
Tsuda Kageyu
2015-11-20 15:17:39 +09:00
47 changed files with 760 additions and 781 deletions

View File

@ -1,8 +1,10 @@
#include <string>
#include <stdio.h>
#include <tag.h>
#include <apetag.h>
#include <id3v1tag.h>
#include <tstringlist.h>
#include <tbytevectorlist.h>
#include <tpropertymap.h>
#include <apefile.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
@ -20,6 +22,7 @@ class TestAPE : public CppUnit::TestFixture
CPPUNIT_TEST(testProperties390);
CPPUNIT_TEST(testFuzzedFile1);
CPPUNIT_TEST(testFuzzedFile2);
CPPUNIT_TEST(testStripAndProperties);
CPPUNIT_TEST_SUITE_END();
public:
@ -111,6 +114,26 @@ public:
CPPUNIT_ASSERT(f.isValid());
}
void testStripAndProperties()
{
ScopedFileCopy copy("mac-399", ".ape");
{
APE::File f(copy.fileName().c_str());
f.APETag(true)->setTitle("APE");
f.ID3v1Tag(true)->setTitle("ID3v1");
f.save();
}
{
APE::File f(copy.fileName().c_str());
CPPUNIT_ASSERT_EQUAL(String("APE"), f.properties()["TITLE"].front());
f.strip(APE::File::APE);
CPPUNIT_ASSERT_EQUAL(String("ID3v1"), f.properties()["TITLE"].front());
f.strip(APE::File::ID3v1);
CPPUNIT_ASSERT(f.properties().isEmpty());
}
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestAPE);

View File

@ -25,6 +25,7 @@ class TestASF : public CppUnit::TestFixture
CPPUNIT_TEST(testSavePicture);
CPPUNIT_TEST(testSaveMultiplePictures);
CPPUNIT_TEST(testProperties);
CPPUNIT_TEST(testRepeatedSave);
CPPUNIT_TEST_SUITE_END();
public:
@ -270,6 +271,21 @@ public:
CPPUNIT_ASSERT_EQUAL(StringList("3"), tags["DISCNUMBER"]);
}
void testRepeatedSave()
{
ScopedFileCopy copy("silence-1", ".wma");
{
ASF::File f(copy.fileName().c_str());
f.tag()->setTitle(std::string(128 * 1024, 'X').c_str());
f.save();
CPPUNIT_ASSERT_EQUAL((offset_t)297578, f.length());
f.tag()->setTitle(std::string(16 * 1024, 'X').c_str());
f.save();
CPPUNIT_ASSERT_EQUAL((offset_t)68202, f.length());
}
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestASF);

View File

@ -3,6 +3,7 @@
#include <tstring.h>
#include <mpegfile.h>
#include <id3v1tag.h>
#include <id3v1genres.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
@ -13,6 +14,7 @@ class TestID3v1 : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(TestID3v1);
CPPUNIT_TEST(testStripWhiteSpace);
CPPUNIT_TEST(testGenres);
CPPUNIT_TEST_SUITE_END();
public:
@ -27,7 +29,7 @@ public:
f.ID3v1Tag(true)->setArtist("Artist ");
f.save();
}
{
MPEG::File f(newname.c_str());
CPPUNIT_ASSERT(f.ID3v1Tag(false));
@ -35,6 +37,12 @@ public:
}
}
void testGenres()
{
CPPUNIT_ASSERT_EQUAL(String("Darkwave"), ID3v1::genre(50));
CPPUNIT_ASSERT_EQUAL(100, ID3v1::genreIndex("Humour"));
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestID3v1);

View File

@ -95,6 +95,7 @@ class TestID3v2 : public CppUnit::TestFixture
CPPUNIT_TEST(testRenderTableOfContentsFrame);
CPPUNIT_TEST(testShrinkPadding);
CPPUNIT_TEST(testEmptyFrame);
CPPUNIT_TEST(testDuplicateTags);
CPPUNIT_TEST_SUITE_END();
public:
@ -1128,6 +1129,41 @@ public:
}
}
void testDuplicateTags()
{
ScopedFileCopy copy("duplicate_id3v2", ".mp3");
ByteVector audioStream;
{
MPEG::File f(copy.fileName().c_str());
f.seek(f.ID3v2Tag()->header()->completeTagSize());
audioStream = f.readBlock(2089);
// duplicate_id3v2.mp3 has duplicate ID3v2 tags.
// Sample rate will be 32000 if we can't skip the second tag.
CPPUNIT_ASSERT(f.hasID3v2Tag());
CPPUNIT_ASSERT_EQUAL((TagLib::uint)8049, f.ID3v2Tag()->header()->completeTagSize());
CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
f.ID3v2Tag()->setArtist("Artist A");
f.save(MPEG::File::ID3v2, true);
}
{
MPEG::File f(copy.fileName().c_str());
CPPUNIT_ASSERT(f.hasID3v2Tag());
CPPUNIT_ASSERT_EQUAL((offset_t)3594, f.length());
CPPUNIT_ASSERT_EQUAL((TagLib::uint)1505, f.ID3v2Tag()->header()->completeTagSize());
CPPUNIT_ASSERT_EQUAL(String("Artist A"), f.ID3v2Tag()->artist());
CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
f.seek(f.ID3v2Tag()->header()->completeTagSize());
CPPUNIT_ASSERT_EQUAL(f.readBlock(2089), audioStream);
}
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestID3v2);

View File

@ -40,7 +40,7 @@ public:
CPPUNIT_ASSERT(f.audioProperties());
CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->length());
CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->lengthInSeconds());
CPPUNIT_ASSERT_EQUAL(3707, f.audioProperties()->lengthInMilliseconds());
CPPUNIT_ASSERT_EQUAL(3708, f.audioProperties()->lengthInMilliseconds());
CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->bitrate());
CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels());
CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());

View File

@ -1,8 +1,10 @@
#include <string>
#include <stdio.h>
#include <tag.h>
#include <apetag.h>
#include <id3v1tag.h>
#include <tstringlist.h>
#include <tbytevectorlist.h>
#include <tpropertymap.h>
#include <mpcfile.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
@ -21,6 +23,7 @@ class TestMPC : public CppUnit::TestFixture
CPPUNIT_TEST(testFuzzedFile2);
CPPUNIT_TEST(testFuzzedFile3);
CPPUNIT_TEST(testFuzzedFile4);
CPPUNIT_TEST(testStripAndProperties);
CPPUNIT_TEST_SUITE_END();
public:
@ -109,6 +112,26 @@ public:
CPPUNIT_ASSERT(f.isValid());
}
void testStripAndProperties()
{
ScopedFileCopy copy("click", ".mpc");
{
MPC::File f(copy.fileName().c_str());
f.APETag(true)->setTitle("APE");
f.ID3v1Tag(true)->setTitle("ID3v1");
f.save();
}
{
MPC::File f(copy.fileName().c_str());
CPPUNIT_ASSERT_EQUAL(String("APE"), f.properties()["TITLE"].front());
f.strip(MPC::File::APE);
CPPUNIT_ASSERT_EQUAL(String("ID3v1"), f.properties()["TITLE"].front());
f.strip(MPC::File::ID3v1);
CPPUNIT_ASSERT(f.properties().isEmpty());
}
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestMPC);

View File

@ -1,8 +1,11 @@
#include <string>
#include <stdio.h>
#include <tstring.h>
#include <tpropertymap.h>
#include <mpegfile.h>
#include <id3v2tag.h>
#include <id3v1tag.h>
#include <apetag.h>
#include <mpegproperties.h>
#include <xingheader.h>
#include <mpegheader.h>
@ -26,6 +29,7 @@ class TestMPEG : public CppUnit::TestFixture
CPPUNIT_TEST(testDuplicateID3v2);
CPPUNIT_TEST(testFuzzedFile);
CPPUNIT_TEST(testFrameOffset);
CPPUNIT_TEST(testStripAndProperties);
CPPUNIT_TEST_SUITE_END();
public:
@ -212,6 +216,29 @@ public:
}
}
void testStripAndProperties()
{
ScopedFileCopy copy("xing", ".mp3");
{
MPEG::File f(copy.fileName().c_str());
f.ID3v2Tag(true)->setTitle("ID3v2");
f.APETag(true)->setTitle("APE");
f.ID3v1Tag(true)->setTitle("ID3v1");
f.save();
}
{
MPEG::File f(copy.fileName().c_str());
CPPUNIT_ASSERT_EQUAL(String("ID3v2"), f.properties()["TITLE"].front());
f.strip(MPEG::File::ID3v2);
CPPUNIT_ASSERT_EQUAL(String("APE"), f.properties()["TITLE"].front());
f.strip(MPEG::File::APE);
CPPUNIT_ASSERT_EQUAL(String("ID3v1"), f.properties()["TITLE"].front());
f.strip(MPEG::File::ID3v1);
CPPUNIT_ASSERT(f.properties().isEmpty());
}
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestMPEG);

View File

@ -1,5 +1,8 @@
#include <string>
#include <stdio.h>
#include <id3v1tag.h>
#include <id3v2tag.h>
#include <tpropertymap.h>
#include <trueaudiofile.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
@ -12,6 +15,7 @@ class TestTrueAudio : public CppUnit::TestFixture
CPPUNIT_TEST_SUITE(TestTrueAudio);
CPPUNIT_TEST(testReadPropertiesWithoutID3v2);
CPPUNIT_TEST(testReadPropertiesWithTags);
CPPUNIT_TEST(testStripAndProperties);
CPPUNIT_TEST_SUITE_END();
public:
@ -46,6 +50,26 @@ public:
CPPUNIT_ASSERT_EQUAL(1, f.audioProperties()->ttaVersion());
}
void testStripAndProperties()
{
ScopedFileCopy copy("empty", ".tta");
{
TrueAudio::File f(copy.fileName().c_str());
f.ID3v2Tag(true)->setTitle("ID3v2");
f.ID3v1Tag(true)->setTitle("ID3v1");
f.save();
}
{
TrueAudio::File f(copy.fileName().c_str());
CPPUNIT_ASSERT_EQUAL(String("ID3v2"), f.properties()["TITLE"].front());
f.strip(TrueAudio::File::ID3v2);
CPPUNIT_ASSERT_EQUAL(String("ID3v1"), f.properties()["TITLE"].front());
f.strip(TrueAudio::File::ID3v1);
CPPUNIT_ASSERT(f.properties().isEmpty());
}
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestTrueAudio);

View File

@ -1,9 +1,9 @@
#include <string>
#include <stdio.h>
#include <tag.h>
#include <id3v2tag.h>
#include <infotag.h>
#include <tbytevectorlist.h>
#include <tpropertymap.h>
#include <wavfile.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
@ -24,6 +24,7 @@ class TestWAV : public CppUnit::TestFixture
CPPUNIT_TEST(testDuplicateTags);
CPPUNIT_TEST(testFuzzedFile1);
CPPUNIT_TEST(testFuzzedFile2);
CPPUNIT_TEST(testStripAndProperties);
CPPUNIT_TEST_SUITE_END();
public:
@ -187,7 +188,10 @@ public:
void testDuplicateTags()
{
RIFF::WAV::File f(TEST_FILE_PATH_C("duplicate_tags.wav"));
ScopedFileCopy copy("duplicate_tags", ".wav");
RIFF::WAV::File f(copy.fileName().c_str());
CPPUNIT_ASSERT_EQUAL((offset_t)17052, f.length());
// duplicate_tags.wav has duplicate ID3v2/INFO tags.
// title() returns "Title2" if can't skip the second tag.
@ -197,6 +201,10 @@ public:
CPPUNIT_ASSERT(f.hasInfoTag());
CPPUNIT_ASSERT_EQUAL(String("Title1"), f.InfoTag()->title());
f.save();
CPPUNIT_ASSERT_EQUAL((offset_t)15898, f.length());
CPPUNIT_ASSERT_EQUAL((offset_t)-1, f.find("Title2"));
}
void testFuzzedFile1()
@ -211,6 +219,26 @@ public:
CPPUNIT_ASSERT(f2.isValid());
}
void testStripAndProperties()
{
ScopedFileCopy copy("empty", ".wav");
{
RIFF::WAV::File f(copy.fileName().c_str());
f.ID3v2Tag()->setTitle("ID3v2");
f.InfoTag()->setTitle("INFO");
f.save();
}
{
RIFF::WAV::File f(copy.fileName().c_str());
CPPUNIT_ASSERT_EQUAL(String("ID3v2"), f.properties()["TITLE"].front());
f.strip(RIFF::WAV::File::ID3v2);
CPPUNIT_ASSERT_EQUAL(String("INFO"), f.properties()["TITLE"].front());
f.strip(RIFF::WAV::File::Info);
CPPUNIT_ASSERT(f.properties().isEmpty());
}
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestWAV);

View File

@ -1,7 +1,9 @@
#include <string>
#include <stdio.h>
#include <tag.h>
#include <apetag.h>
#include <id3v1tag.h>
#include <tbytevectorlist.h>
#include <tpropertymap.h>
#include <wavpackfile.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
@ -16,6 +18,7 @@ class TestWavPack : public CppUnit::TestFixture
CPPUNIT_TEST(testMultiChannelProperties);
CPPUNIT_TEST(testTaggedProperties);
CPPUNIT_TEST(testFuzzedFile);
CPPUNIT_TEST(testStripAndProperties);
CPPUNIT_TEST_SUITE_END();
public:
@ -73,6 +76,27 @@ public:
WavPack::File f(TEST_FILE_PATH_C("infloop.wv"));
CPPUNIT_ASSERT(f.isValid());
}
void testStripAndProperties()
{
ScopedFileCopy copy("click", ".wv");
{
WavPack::File f(copy.fileName().c_str());
f.APETag(true)->setTitle("APE");
f.ID3v1Tag(true)->setTitle("ID3v1");
f.save();
}
{
WavPack::File f(copy.fileName().c_str());
CPPUNIT_ASSERT_EQUAL(String("APE"), f.properties()["TITLE"].front());
f.strip(WavPack::File::APE);
CPPUNIT_ASSERT_EQUAL(String("ID3v1"), f.properties()["TITLE"].front());
f.strip(WavPack::File::ID3v1);
CPPUNIT_ASSERT(f.properties().isEmpty());
}
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestWavPack);